stdlib-js / stdlib

✨ Standard library for JavaScript and Node.js. ✨
https://stdlib.io
Apache License 2.0
4.55k stars 509 forks source link

[RFC]: move `@stdlib/math/base/ops/*` packages to `@stdlib/number/*` and `@stdlib/complex/*` #2261

Open kgryte opened 6 months ago

kgryte commented 6 months ago

Description

This RFC proposes moving packages found in @stdlib/math/base/ops to respective sub-namespaces in @stdlib/number/* and @stdlib/complex/*. For example,

Currently, we rely on prefixes and suffixes to distinguish packages in ops; however, this practice breaks down when wanting to add C variants for various integer dtypes. To keep things cleaner, this RFC advocates for migrating to dedicated dtype sub-namespaces for arithmetic, binary, and logical operations, where the latter were already planned for dtype sub-namespaces. Moving their arithmetic counterparts seems better for the sake of consistency than following the math/base/special precedent which stems from C99 and is primarily oriented to floating-point numbers.

Related Issues

Questions

No.

Other

Note that this RFC does not propose changing math/base/special. This applies only to ops which are more universal for each numeric dtype, and where we do actually want dedicated C interfaces for each dtype (e.g., int8_t stdlib_int8_base_add( int8_t x, int8_t y )).

The migration path would be as follows:

cc @Planeshifter

Checklist

yashathwani commented 4 months ago

Please assign me this issue!

gururaj1512 commented 1 month ago

@stdlib/math/base/ops/add => @stdlib/number/float64/base/add @stdlib/math/base/ops/add3 => @stdlib/number/float64/base/add3 @stdlib/math/base/ops/add4 => @stdlib/number/float64/base/add4 @stdlib/math/base/ops/add5 => @stdlib/number/float64/base/add5 @stdlib/math/base/ops/addf => @stdlib/number/float32/base/add

@stdlib/math/base/ops/cdiv => @stdlib/complex/float64/base/cdiv @stdlib/math/base/ops/cneg => @stdlib/complex/float64/base/cneg @stdlib/math/base/ops/cnegf => @stdlib/complex/float32/base/cneg @stdlib/math/base/ops/csub => @stdlib/complex/float64/base/csub @stdlib/math/base/ops/csubf => @stdlib/complex/float32/base/csub

@stdlib/math/base/ops/div => @stdlib/number/float64/base/div @stdlib/math/base/ops/divf => @stdlib/number/float32/base/div @stdlib/math/base/ops/mul => @stdlib/number/float64/base/mul @stdlib/math/base/ops/mulf => @stdlib/number/float32/base/mul @stdlib/math/base/ops/sub => @stdlib/number/float64/base/sub @stdlib/math/base/ops/subf => @stdlib/number/float32/base/sub

@stdlib/math/base/ops/imul => @stdlib/number/int32/base/imul @stdlib/math/base/ops/imuldw => @stdlib/number/int32/base/imuldw @stdlib/math/base/ops/umul => @stdlib/number/uint32/base/umul @stdlib/math/base/ops/umuldw => @stdlib/number/uint32/base/umuldw

@kgryte, can you confirm if these mappings are correct or if any adjustments are needed