stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

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

Open kgryte opened this issue 1 year ago • 2 comments

Description

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

  • @stdlib/math/base/ops/add => @stdlib/number/float64/base/add
  • @stdlib/math/base/ops/addf => @stdlib/number/float32/base/add
  • ...

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

  • https://github.com/stdlib-js/stdlib/issues/2260

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:

  • Copy dtype-specific packages to their respective sub-namespaces.
  • Update all require paths using the dtype-specific packages.
  • Remove all dtype-specific packages from @stdlib/math/base/ops namespace.

cc @Planeshifter

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 May 24 '24 02:05 kgryte

Please assign me this issue!

yashathwani avatar Jul 26 '24 12:07 yashathwani

@gururaj1512 Would you also mind migrating the math/base/special/*identity* functions to similar destinations?

kgryte avatar Mar 15 '25 07:03 kgryte

@gururaj1512 Would you also mind migrating the math/base/special/*identity* functions to similar destinations?

Sure. Should the migrations be carried out under this issue or a issue needs to be created

gururaj1512 avatar Mar 15 '25 08:03 gururaj1512

@gururaj1512 Under this issue is fine.

kgryte avatar Mar 15 '25 08:03 kgryte

@kgryte, I'll on it

gururaj1512 avatar Mar 15 '25 08:03 gururaj1512

@gururaj1512 Would you also mind migrating the math/base/special/*identity* functions to similar destinations?

Correct me if I'm wrong, Should the math/base/special/*identity* functions be migrated to @stdlib/number/*?

gururaj1512 avatar Mar 16 '25 07:03 gururaj1512

@gururaj1512

  • math/base/special/identity => number/float64/base/identity
  • math/base/special/identityf => number/float32/base/identityf
  • math/base/special/cidentity => complex/float64/base/identity
  • etc.

kgryte avatar Mar 16 '25 07:03 kgryte

@kgryte, The last export cmul is to be removed from parent namespace. Should the lib/index.js & docs/index.d.ts be deleted here?

gururaj1512 avatar Mar 18 '25 09:03 gururaj1512

@gururaj1512 Go ahead and delete all of math/base/ops and remove its symbol from the parent namespace.

kgryte avatar Mar 18 '25 09:03 kgryte

@kgryte, I think this issue can be closed...!

gururaj1512 avatar Mar 23 '25 08:03 gururaj1512

@gururaj1512 Thank you for all your help on this!

kgryte avatar Mar 23 '25 08:03 kgryte