You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Type declarations for rounding functions (#2539)
This is a sequel to #2531. Uniformizes the signatures of ceil, fix, floor,
and round, and updates the TypeScript declarations to match. Adds the
optional "number of places" argument to the chain versions of ceil, fix,
and floor. Adds TypeScript tests for all rounding functions.
Also corrects the TypeScript declaration for `bignumber()` and introduces
a couple more common abbreviations for TypeScript types.
Fixes the number-only implementations of floor, ceil, fix, and nthRoot
to match the full implementation behavior on numbers, and tests this for
floor.
Includes some minor documentation updates and additional unit tests for
the rounding functions.
Reverts inclusion in AUTHORS of incorrect email for one contributor,
that occurred in #2531.
Resolves#2526.
Resolves#2529.
You can also coerce an array or matrix into sparse storage format with the
346
+
`sparse` function.
347
+
```js
348
+
constmd=math.matrix([[0, 1], [0,0]]) // dense
349
+
constms=math.sparse(md) // sparse
350
+
```
351
+
352
+
Caution: `sparse` called on a JavaScript array of _n_ plain numbers produces
353
+
a matrix with one column and _n_ rows -- in contrast to `matrix`, which
354
+
produces a 1-dimensional matrix object with _n_ entries, i.e., a vector
355
+
(_not_ a 1 by _n_ "row vector" nor an _n_ by 1 "column vector", but just a plain
356
+
vector of length _n_).
357
+
```js
358
+
constmv=math.matrix([0, 0, 1]) // Has size [3]
359
+
constmc=math.sparse([0, 0, 1]) // A "column vector," has size [3, 1]
360
+
```
361
+
345
362
## API
346
363
347
364
All relevant functions in math.js support Matrices and Arrays. Functions like `math.add` and `math.subtract`, `math.sqrt` handle matrices element wise. There is a set of functions specifically for creating or manipulating matrices, such as:
0 commit comments