stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

[RFC]: Add C implementations to base special math functions (tracking issue)

Open kgryte opened this issue 3 years ago • 36 comments

Description

This RFC proposes adding C implementations to all base special math functions. The purpose of this issue is to serve as a tracking issue for adding C implementations.

Packages

  • [x] abs
  • [x] abs2
  • [x] abs2f
  • [x] absf
  • [x] acos
  • [x] acosf
  • [x] acosd
  • [x] acosdf
  • [x] acosh
  • [ ] acoshf
  • [x] acot
  • [x] acotf
  • [x] acotd
  • [x] acotdf
  • [x] acoth
  • [ ] acothf
  • [x] acovercos
  • [x] acovercosf
  • [x] acoversin
  • [x] acoversinf
  • [x] acsc
  • [x] acscf
  • [x] acscd
  • [x] acscdf
  • [x] acsch
  • [ ] acschf
  • [x] ahavercos
  • [x] ahavercosf
  • [x] ahaversin
  • [x] ahaversinf
  • [x] asec
  • [x] asecf
  • [x] asecd
  • [x] asecdf
  • [x] asech
  • [ ] asechf
  • [x] asin
  • [x] asinf
  • [x] asind
  • [x] asindf
  • [x] asinf
  • [x] asinh
  • [ ] asinhf
  • [x] atan
  • [x] atanf
  • [x] atan2
  • [x] atan2f
  • [x] atand
  • [x] atandf
  • [x] atanh
  • [ ] atanhf
  • [x] avercos
  • [x] avercosf
  • [x] aversin
  • [x] aversinf
  • [x] bernoulli
  • [x] bernoullif
  • [x] besselj0
  • [ ] besselj0f
  • [x] besselj1
  • [ ] besselj1f
  • [x] bessely0
  • [ ] bessely0f
  • [x] bessely1
  • [ ] bessely1f
  • [x] beta
  • [ ] betaf
  • [ ] betainc
  • [ ] betaincf
  • [ ] betaincinv
  • [ ] betaincinvf
  • [x] betaln
  • [ ] betalnf
  • [x] binet
  • [ ] binetf
  • [x] binomcoef
  • [x] binomcoeff
  • [x] binomcoefln
  • [ ] binomcoeflnf
  • [x] boxcox
  • [ ] boxcoxf
  • [x] boxcox1p
  • [ ] boxcox1pf
  • [x] boxcox1pinv
  • [ ] boxcox1pinvf
  • [x] boxcoxinv
  • [ ] boxcoxinvf
  • [x] cabs
  • [x] cabs2
  • [x] cabs2f
  • [x] cabsf
  • [x] cbrt
  • [x] cbrtf
  • [x] cceil
  • [x] cceilf
  • [x] cceiln
  • [ ] cceilnf
  • [x] ccis
  • [ ] ccisf
  • [x] ceil
  • [x] ceil10
  • [ ] ceil10f
  • [x] ceil2
  • [ ] ceil2f
  • [x] ceilb
  • [ ] ceilbf
  • [x] ceilf
  • [x] ceiln
  • [ ] ceilnf
  • [x] ceilsd
  • [ ] ceilsdf
  • [x] cexp
  • [ ] cexpf
  • [x] cflipsign
  • [x] cflipsignf
  • [x] cfloor
  • [x] cfloorf
  • [x] cfloorn
  • [ ] cfloornf
  • [x] cidentity
  • [x] cidentityf
  • [x] cinv
  • [x] cinvf
  • [x] clamp
  • [x] clampf
  • [x] copysign
  • [x] copysignf
  • [x] cos
  • [x] cosf
  • [x] cosd
  • [x] cosdf
  • [x] cosh
  • [ ] coshf
  • [x] cosm1
  • [x] cosm1f
  • [x] cospi
  • [x] cospif
  • [x] cot
  • [x] cotf
  • [x] cotd
  • [x] cotdf
  • [x] coth
  • [ ] cothf
  • [x] covercos
  • [x] covercosf
  • [x] coversin
  • [x] coversinf
  • [x] cphase
  • [x] cphasef
  • [x] cpolar
  • [x] cpolarf
  • [x] cround
  • [x] croundf
  • [x] croundn
  • [ ] croundnf
  • [x] csc
  • [x] cscf
  • [x] cscd
  • [x] cscdf
  • [x] csch
  • [ ] cschf
  • [x] csignum
  • [x] csignumf
  • [x] deg2rad
  • [x] deg2radf
  • [x] digamma
  • [ ] digammaf
  • [x] dirac-delta
  • [x] dirac-deltaf
  • [x] dirichlet-eta
  • [ ] dirichlet-etaf
  • [x] ellipe
  • [ ] ellipef
  • [x] ellipj
  • [ ] ellipjf
  • [x] ellipk
  • [ ] ellipkf
  • [x] erf
  • [ ] erff
  • [x] erfc
  • [ ] erfcf
  • [x] erfcinv
  • [ ] erfcinvf
  • [x] erfcx
  • [ ] erfcxf
  • [x] erfinv
  • [ ] erfinvf
  • [x] exp
  • [ ] expf
  • [x] exp10
  • [ ] exp10f
  • [x] exp2
  • [ ] exp2f
  • [x] expit
  • [ ] expitf
  • [x] expm1
  • [ ] expm1f
  • [x] expm1rel
  • [ ] expm1relf
  • [x] factorial
  • [ ] factorialf
  • [x] factorial2
  • [x] factorial2f
  • [x] factorialln
  • [x] factoriallnf
  • [x] falling-factorial
  • [ ] falling-factorialf
  • [x] fast/*
  • [x] fibonacci
  • [x] fibonaccif
  • [x] fibonacci-index
  • [x] fibonacci-indexf
  • [x] flipsign
  • [x] flipsignf
  • [x] floor
  • [x] floor10
  • [ ] floor10f
  • [x] floor2
  • [ ] floor2f
  • [x] floorb
  • [ ] floorbf
  • [x] floorf
  • [x] floorn
  • [ ] floornf
  • [x] floorsd
  • [ ] floorsdf
  • [x] fmod
  • [x] fmodf
  • [x] fresnel
  • [ ] fresnelf
  • [x] fresnelc
  • [ ] fresnelcf
  • [x] fresnels
  • [ ] fresnelsf
  • [x] frexp
  • [x] frexpf
  • [x] gamma
  • [ ] gammaf
  • [x] gamma-delta-ratio
  • [ ] gamma-delta-ratiof
  • [x] gamma-lanczos-sum
  • [ ] gamma-lanczos-sumf
  • [x] gamma-lanczos-sum-expg-scaled
  • [x] gamma-lanczos-sum-expg-scaledf
  • [x] gamma1pm1
  • [ ] gamma1pm1f
  • [x] gammainc
  • [ ] gammaincf
  • [ ] gammaincinv
  • [ ] gammaincinvf
  • [x] gammaln
  • [ ] gammalnf
  • [x] gammasgn
  • [x] gammasgnf
  • [x] gcd
  • [x] gcdf
  • [x] hacovercos
  • [x] hacovercosf
  • [x] hacoversin
  • [x] hacoversinf
  • [x] havercos
  • [x] havercosf
  • [x] haversin
  • [x] haversinf
  • [ ] heaviside
  • [x] heavisidef
  • [x] hypot
  • [x] hypotf
  • [x] identity
  • [x] identityf
  • [x] inv
  • [x] invf
  • [ ] kernel-betainc
  • [ ] kernel-betaincf
  • [ ] kernel-betaincinv
  • [ ] kernel-betaincinvf
  • [x] kernel-cos
  • [x] kernel-cosf
  • [x] kernel-sin
  • [x] kernel-sinf
  • [x] kernel-tan
  • [x] kernel-tanf
  • [x] kronecker-delta
  • [x] kronecker-deltaf
  • [x] labs
  • [x] lcm
  • [x] lcmf
  • [x] ldexp
  • [x] ldexpf
  • [x] ln
  • [x] lnf
  • [x] log
  • [x] logf
  • [x] log10
  • [ ] log10f
  • [x] log1mexp
  • [ ] log1mexpf
  • [x] log1p
  • [x] log1pf
  • [x] log1pexp
  • [ ] log1pexpf
  • [x] log1pmx
  • [ ] log1pmxf
  • [x] log2
  • [ ] log2f
  • [x] logaddexp
  • [ ] logaddexpf
  • [x] logit
  • [x] logitf
  • [x] lucas
  • [x] lucasf
  • [x] max
  • [x] maxf
  • [x] maxabs
  • [x] maxabsf
  • [ ] ~~maxabsn~~
  • [ ] ~~maxn~~
  • [x] min
  • [x] minf
  • [x] minabs
  • [x] minabsf
  • [ ] ~~minabsn~~
  • [x] minmax
  • [x] minmaxf
  • [x] minmaxabs
  • [x] minmaxabsf
  • [ ] ~~minmaxabsn~~
  • [ ] ~~minmaxn~~
  • [ ] ~~minn~~
  • [x] modf
  • [x] modff
  • [x] nanmax
  • [x] nanmaxf
  • [x] nanmin
  • [x] nanminf
  • [x] negafibonacci
  • [x] negafibonaccif
  • [x] negalucas
  • [x] negalucasf
  • [x] nonfibonacci
  • [x] nonfibonaccif
  • [x] pdiff
  • [x] pdifff
  • [ ] polygamma
  • [ ] polygammaf
  • [x] pow
  • [x] powf
  • [x] powm1
  • [ ] powm1f
  • [x] rad2deg
  • [x] rad2degf
  • [x] ramp
  • [x] rampf
  • [x] rcbrt
  • [x] rcbrtf
  • [x] rempio2
  • [x] rempio2f
  • [x] riemann-zeta
  • [ ] riemann-zetaf
  • [x] rising-factorial
  • [ ] rising-factorialf
  • [x] round
  • [x] roundf
  • [x] round10
  • [ ] round10f
  • [x] round2
  • [ ] round2f
  • [x] roundb
  • [ ] roundbf
  • [x] roundn
  • [ ] roundnf
  • [x] roundsd
  • [ ] roundsdf
  • [x] rsqrt
  • [x] rsqrtf
  • [x] sec
  • [x] secd
  • [x] secdf
  • [x] secf
  • [ ] sici
  • [ ] sicif
  • [x] signum
  • [x] signumf
  • [x] sin
  • [x] sinf
  • [x] sinc
  • [x] sincf
  • [x] sincos
  • [x] sincosd
  • [ ] sincosdf
  • [x] sincosf
  • [x] sincospi
  • [ ] sincospif
  • [x] sinh
  • [ ] sinhf
  • [x] sinpi
  • [x] sinpif
  • [x] spence
  • [x] spencef
  • [x] sqrt
  • [x] sqrt1pm1
  • [ ] sqrt1pm1f
  • [x] sqrtf
  • [x] sqrtpi
  • [x] sqrtpif
  • [x] tan
  • [x] tanf
  • [x] tand
  • [x] tandf
  • [x] tanh
  • [ ] tanhf
  • [x] tribonacci
  • [x] tribonaccif
  • [x] trigamma
  • [x] trigammaf
  • [x] trunc
  • [x] trunc10
  • [ ] trunc10f
  • [x] trunc2
  • [ ] trunc2f
  • [x] truncb
  • [ ] truncbf
  • [x] truncf
  • [x] truncn
  • [ ] truncnf
  • [x] truncsd
  • [ ] truncsdf
  • [x] vercos
  • [x] vercosf
  • [x] versin
  • [x] versinf
  • [x] wrap
  • [x] wrapf
  • [x] xlog1py
  • [ ] xlog1pyf
  • [x] xlogy
  • [x] xlogyf

Related Issues

None.

Questions

No.

Other

No.

Checklist

  • [X] I have read and understood the Code of Conduct.
  • [X] Searched for existing issues and pull requests.
  • [X] The issue name begins with RFC:.

kgryte avatar Dec 02 '22 08:12 kgryte

@kgryte I would like to work on this.

Pratik772846 avatar Mar 05 '24 04:03 Pratik772846

@Pratik772846 I suggest picking one of the associated RFCs for updating a single package. This is a tracking issue.

kgryte avatar Mar 06 '24 21:03 kgryte

@Pranavchiku As you've been managing a number of the RFCs and PRs, would you mind updating the OP to match the current state of implementations?

kgryte avatar Mar 06 '24 21:03 kgryte

I am not sure if this can be closed now, reopening this.

Pranavchiku avatar Mar 12 '24 13:03 Pranavchiku

@Pranavchiku Yeah, I think GitHub unfortunately auto-closes it when we have a PR where the opening comment includes "Fixes #649" or something of the sort. Thanks for opening again!

But I see that I accidentally included "Closes #649" in the merge commit message. Will avoid and see whether that solves it going forward.

Planeshifter avatar Mar 12 '24 13:03 Planeshifter

No worries, we can open it anytime so that is fine. Updated tracker to latest main.

Small script, not sure if it traps all cases. There can be false negatives but no false positives.

set -ex

# iterate over all folder in <.../math/base/special/*>
for d in <path>; do
  # if the folder is a directory
  if [ -d "$d" ]; then
	# get the name of the folder
	folder=$(basename $d)
	# check if it has `manifest.json` file
	if [ -f "$d/manifest.json" ]; then
		# if it has `manifest.json` file, then open it as j_, lookup js_[confs][dependencies] and see if it has "@stdlib/math/base/napi/unary"
		# if it has "@stdlib/math/base/napi/unary" then add it to the `names.md`
		jq -r '.jsdoc.confs.dependencies["@stdlib/math/base/napi/unary"]' $d/manifest.json
		if [ $? -eq 0 ]; then
			echo "- [x] $folder" >> names.md
		else
			echo "- [ ] $folder" >> names.md
		fi
	else
		echo "- [ ] $folder" >> names.md
	fi
  fi
done

Pranavchiku avatar Mar 12 '24 14:03 Pranavchiku

@Planeshifter You should always check the PR OP to ensure it properly links to issues and does not auto-close tracking issues. I often correct contributor PR OPs as they commonly include errors, including linking to incorrect issues or closing tracking issues.

kgryte avatar Mar 12 '24 21:03 kgryte

Updated as per latest develop

Pranavchiku avatar Mar 26 '24 11:03 Pranavchiku

@gunjjoshi Would you mind updating the tracking issue with completed APIs? I believe rempio2, csc, and maybe others are finished.

kgryte avatar Jun 13 '24 23:06 kgryte

Would also be good to add relevant single-precision variants which have been, or still need to be, completed.

kgryte avatar Jun 13 '24 23:06 kgryte

Yes @kgryte, I'll do that. But as this issue wasn't opened by me, I am unable to modify or edit this. Should I make a comment consisting of a list of the completed ones, and modifying that each time?

gunjjoshi avatar Jun 14 '24 00:06 gunjjoshi

@kgryte The C implementations of the following functions have been done. They can be marked as completed now.

  • cos
  • cot
  • coversin
  • csc
  • exp2
  • fast
  • fibonacci-index
  • lcm
  • log10
  • negafibonacci
  • rempio2
  • round
  • sin
  • spence
  • tan

gunjjoshi avatar Jun 15 '24 08:06 gunjjoshi

@gunjjoshi Marked as completed. 🚀

Planeshifter avatar Jun 15 '24 18:06 Planeshifter

I updated the issue to include missing single-precision variants.

kgryte avatar Jun 15 '24 19:06 kgryte

The following single-precision variants can also be marked as completed.

  • acosf
  • acotf
  • acscf
  • acscdf
  • asecdf
  • asecf
  • asindf
  • atanf
  • lnf
  • rad2degf
  • rcbrtf

gunjjoshi avatar Jun 16 '24 19:06 gunjjoshi

@gunjjoshi Updated!

kgryte avatar Jun 16 '24 19:06 kgryte