Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ghost opened this issue Nov 21, 2022 · 3 comments
Open

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

ghost opened this issue Nov 21, 2022 · 3 comments

Comments

@ghost
Copy link

ghost commented Nov 21, 2022

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
Copy link
Member

targos commented Nov 21, 2022

@lpatiny

@lpatiny
Copy link
Member

lpatiny commented Nov 21, 2022

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 (

export type NumberArray =
| number[]
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array;
)

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
Copy link
Author

ghost commented Nov 22, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants