Skip to content

Commit b81420f

Browse files
orelbngwhitney
andauthored
chore: update matrix documentation to align with v15 (#3591)
Resolves #3565. --------- Co-authored-by: Glen Whitney <glen@studioinfinity.org>
1 parent 3c2a915 commit b81420f

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# History
22

3+
# unreleased changes since 15.1.0
4+
5+
- Docs: fix #3565, update Matrix documentation (#3591). Thanks @orelbn.
6+
37
# 2025-11-05, 15.1.0
48

59
- Feat: implement functions `isFinite` and `isBounded` (#3554, #3553).

docs/datatypes/matrices.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ Functions that require two or more matrix like arguments that operate elementwis
156156

157157
```js
158158
A = math.matrix([1, 2]) // Matrix, [1, 2]
159-
math.add(A, 3) // Matrix, [3, 4]
159+
math.add(A, 3) // Matrix, [4, 5]
160160

161161
B = math.matrix([[3], [4]]) // Matrix, [[3], [4]]
162162
math.add(A, B) // Matrix, [[4, 5], [5, 6]]
@@ -181,31 +181,30 @@ Math.js uses geometric dimensions:
181181
- A vector is one-dimensional.
182182
- A matrix is two or multidimensional.
183183

184-
The size of a matrix can be calculated with the function `size`. Function `size`
185-
returns a `Matrix` or `Array`, depending on the configuration option `matrix`.
186-
Furthermore, matrices have a function `size` as well, which always returns
187-
an Array.
184+
The size of a matrix can be calculated with the function `size`. This function
185+
returns an `Array`, giving the length of its input (`Matrix` or `Array`) in
186+
each dimension. You can also call `size()` as a method on a Matrix.
188187

189188
```js
190189
// get the size of a scalar
191-
math.size(2.4) // Matrix, []
192-
math.size(math.complex(3, 2)) // Matrix, []
193-
math.size(math.unit('5.3 mm')) // Matrix, []
190+
math.size(2.4) // Array, []
191+
math.size(math.complex(3, 2)) // Array, []
192+
math.size(math.unit('5.3 mm')) // Array, []
194193

195194
// get the size of a one-dimensional matrix (a vector) and a string
196195
math.size([0, 1, 2, 3]) // Array, [4]
197-
math.size('hello world') // Matrix, [11]
196+
math.size('hello world') // Array, [11]
198197

199198
// get the size of a two-dimensional matrix
200199
const a = [[0, 1, 2, 3]] // Array
201200
const b = math.matrix([[0, 1, 2], [3, 4, 5]]) // Matrix
202201
math.size(a) // Array, [1, 4]
203-
math.size(b) // Matrix, [2, 3]
202+
math.size(b) // Array, [2, 3]
204203

205-
// matrices have a function size (always returns an Array)
204+
// matrices have a method size
206205
b.size() // Array, [2, 3]
207206

208-
// get the size of a multi-dimensional matrix
207+
// get the size of a multi-dimensional array
209208
const c = [[[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]]]
210209
math.size(c) // Array, [2, 2, 3]
211210
```
@@ -360,7 +359,7 @@ const m = math.matrix([[1, 2, 3], [4, 5, 6]])
360359
| `math.subset(m, math.index([0, 1], [1, 2]))` | No change needed | `[[2, 3], [5, 6]]` |
361360
| `math.subset(m, math.index(1, [1, 2]))` | `math.subset(m, math.index([1], [1, 2]))` | `[[5, 6]]` |
362361
| `math.subset(m, math.index([0, 1], 2))` | `math.subset(m, math.index([0, 1], [2]))` | `[[3], [6]]` |
363-
| `math.subset(m, math.index(1, 2))` | No change needed | 6 |
362+
| `math.subset(m, math.index(1, 2))` | No change needed | `6` |
364363

365364

366365
> **Tip:**

0 commit comments

Comments
 (0)