cheminfo / cheminfo-types

https://cheminfo.github.io/cheminfo-types/
MIT License
2 stars 3 forks source link

Question: could it be possible to accept other TypedArrays? #88

Open ghost opened 1 year ago

ghost commented 1 year ago

The most useful one to add seems Float32Array, but maybe any array could be better ?

One current issue is that a Typed Array (8,16,32) will have to be converted to 64 and takes time and extra memory.

Currently only accepts extensions of DoubleArray, from this interface.

targos commented 1 year ago

@lpatiny

lpatiny commented 1 year ago

Yes we could.

It makes sense indeed if we can to keep the memory footprint as small as possible. This will be justified for large high-resolution GC/MS (or a dataset of 1000 NMR spectra).

There is already the concept of NumberArray (https://github.com/cheminfo/cheminfo-types/blob/946936b3dd5d4af1e1a4298c9cc9bf317b470a45/src/core/NumberArray.d.ts#L6-L16)

Some methods of spectra-processing also already accepts the NumberArray: https://github.com/search?q=repo%3Amljs%2Fspectra-processing%20%20NumberArray&type=code

I don't know however if we should go directly to NumberArray, extend DoubleArray (and allow Float32) or add one more numerical array type.

ghost commented 1 year ago

NumberArray seems useful. Using < T = number [ ] | TypedArray > seems less useful.