Skip to content

Commit d1c135b

Browse files
committed
Updated migration example
1 parent b7213f0 commit d1c135b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

docs/datatypes/matrices.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,18 +352,20 @@ With the release of math.js v15, the behavior of `subset` when indexing matrices
352352
### Migration examples
353353

354354
```js
355-
const m = math.matrix([[10, 11, 12], [20, 21, 22]])
355+
const m = math.matrix([[1, 2, 3], [4, 5, 6]])
356356
```
357357

358-
| Code example | v15+ (default) result | v14- and v15+ (legacy mode) result | How to get old result in v15+. |
359-
|------------------------------------|-------------------------------|------------------------------------|----------------------------------|
360-
| `m.subset(math.index(1, [2]))` | `[22]` | `22` | Use `m.subset(math.index(1, 2))` |
361-
| `m.subset(math.index([1], 2))` | `[22]` | `22` | Use `m.subset(math.index(1, 2))` |
362-
| `m.subset(math.index([1], [2]))` | `[[22]]` | `22` | Use `m.subset(math.index(1, 2))` |
363-
| `m.subset(math.index(1, 2))` | `22` | `22` | No change needed |
358+
| v14 code | v15 equivalent code | Result |
359+
|----------------------------------------------|-------------------------------------------|--------------------|
360+
| `math.subset(m, math.index([0, 1], [1, 2]))` | No change needed | `[[2, 3], [5, 6]]` |
361+
| `math.subset(m, math.index(1, [1, 2]))` | `math.subset(m, math.index([1], [1, 2]))` | `[[5, 6]]` |
362+
| `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 |
364+
364365

365366
> **Tip:**
366367
> If you want to always get a scalar value, use scalar indices.
368+
>
367369
> If you want to preserve dimensions, use array, matrix or range indices.
368370
369371
## Getting and setting a value in a matrix

0 commit comments

Comments
 (0)