mateogianolio / vectorious

Linear algebra in TypeScript.
https://docs.vectorious.org
MIT License
920 stars 43 forks source link

blas `axpy` test is not meaningful #255

Open rotu opened 1 year ago

rotu commented 1 year ago

The axpy test checks that the return value of axpy is the same as the return value of nblas.daxpy. These functions actually have return type void so the check is just that undefined === undefined!

The actual thing saxpy/daxpy should do is mutate y in place. https://github.com/mateogianolio/vectorious/blob/3ec25615d3871224cbcb6f5bb3e154208faab276/src/blas.spec.ts#L17

rotu commented 1 year ago

Note this might have been at least partly obscured by TypeScript itself. Changing the dynamic require('nblas') to a static import import * as nblas from 'nblas' causes a number of typescript warnings in blas.ts to surface. Notably, blas.ts does not seem to check whether the TypedArrays match the provided dtype (or are even the same type, for multi-argument functions), which I think could lead to a runtime segfault.

mateogianolio commented 1 year ago

Good catch!

It's a result of having the nblas module optional. When I implemented the try..catch-require, it made typescript typing impossible because the nblas types (https://github.com/nperf/nblas/blob/master/src/types.ts) are not there because the package is not installed. Maybe there is a modern solution for this?