@smockle/matrix 3.0.6 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CODEOWNERS +1 -0
- package/.github/workflows/publish.yml +33 -0
- package/.github/workflows/test.yml +30 -0
- package/LICENSE +21 -13
- package/README.md +97 -82
- package/package.json +28 -39
- package/src/__tests__/index.test.ts +540 -0
- package/src/index.ts +290 -0
- package/tsconfig.json +17 -0
- package/.editorconfig +0 -7
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -6
- package/.flowconfig +0 -27
- package/.prettierignore +0 -1
- package/.travis.yml +0 -19
- package/appveyor.yml +0 -21
- package/flow-typed/npm/@std/esm_vx.x.x.js +0 -33
- package/flow-typed/npm/codecov_vx.x.x.js +0 -276
- package/flow-typed/npm/colortape_vx.x.x.js +0 -80
- package/flow-typed/npm/eslint-config-standard_vx.x.x.js +0 -45
- package/flow-typed/npm/eslint-plugin-import_vx.x.x.js +0 -333
- package/flow-typed/npm/eslint-plugin-node_vx.x.x.js +0 -249
- package/flow-typed/npm/eslint-plugin-promise_vx.x.x.js +0 -150
- package/flow-typed/npm/eslint-plugin-standard_vx.x.x.js +0 -87
- package/flow-typed/npm/eslint_vx.x.x.js +0 -2363
- package/flow-typed/npm/flow-bin_v0.x.x.js +0 -6
- package/flow-typed/npm/flow-typed_vx.x.x.js +0 -193
- package/flow-typed/npm/husky_vx.x.x.js +0 -88
- package/flow-typed/npm/jsdoc-to-markdown_vx.x.x.js +0 -95
- package/flow-typed/npm/lint-staged_vx.x.x.js +0 -143
- package/flow-typed/npm/lodash_v4.x.x.js +0 -530
- package/flow-typed/npm/mathjs_vx.x.x.js +0 -5561
- package/flow-typed/npm/nyc_vx.x.x.js +0 -108
- package/flow-typed/npm/prettier-eslint-cli_vx.x.x.js +0 -74
- package/jsdoc.json +0 -6
- package/jsdoc2md/README.hbs +0 -41
- package/lib/matrix.js +0 -4
- package/lib/matrix.mjs +0 -312
- package/test/matrix.mjs +0 -243
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import { inspect } from "node:util";
|
|
2
|
+
import { describe, test, expect } from "@jest/globals";
|
|
3
|
+
import Matrix from "../index.js";
|
|
4
|
+
|
|
5
|
+
describe("Matrix", () => {
|
|
6
|
+
const error = new TypeError("Matrix must be a number or array of numbers");
|
|
7
|
+
|
|
8
|
+
test("instanceof Matrix", () => {
|
|
9
|
+
expect(Matrix([])).toBeInstanceOf(Matrix);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test("throws unnecessary nesting", () => {
|
|
13
|
+
expect(Matrix.bind(Matrix, [[1, 2]])).toThrowError(error);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test("throws uneven rows", () => {
|
|
17
|
+
expect(Matrix.bind(Matrix, [[1, 2], [3], [4, 5]])).toThrowError(error);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test("does not throw number", () => {
|
|
21
|
+
expect(Matrix.bind(Matrix, 1)).not.toThrowError(error);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("does not throw number array", () => {
|
|
25
|
+
expect(Matrix.bind(Matrix, [1])).not.toThrowError(error);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("does not throw 2D number array", () => {
|
|
29
|
+
expect(Matrix.bind(Matrix, [[1], [2]])).not.toThrowError(error);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe("Matrix.addable", () => {
|
|
34
|
+
test("addable mismatched columns", () => {
|
|
35
|
+
expect(
|
|
36
|
+
Matrix.addable(
|
|
37
|
+
Matrix([
|
|
38
|
+
[1, 2],
|
|
39
|
+
[3, 4],
|
|
40
|
+
]),
|
|
41
|
+
Matrix([
|
|
42
|
+
[1, 2, 3],
|
|
43
|
+
[4, 5, 6],
|
|
44
|
+
])
|
|
45
|
+
)
|
|
46
|
+
).toBeFalsy();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("addable mismatched rows", () => {
|
|
50
|
+
expect(
|
|
51
|
+
Matrix.addable(
|
|
52
|
+
Matrix([
|
|
53
|
+
[1, 2],
|
|
54
|
+
[3, 4],
|
|
55
|
+
]),
|
|
56
|
+
Matrix([
|
|
57
|
+
[1, 2],
|
|
58
|
+
[4, 5],
|
|
59
|
+
[7, 8],
|
|
60
|
+
])
|
|
61
|
+
)
|
|
62
|
+
).toBeFalsy();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("addable", () => {
|
|
66
|
+
expect(
|
|
67
|
+
Matrix.addable(
|
|
68
|
+
Matrix([
|
|
69
|
+
[1, 2],
|
|
70
|
+
[3, 4],
|
|
71
|
+
]),
|
|
72
|
+
Matrix([
|
|
73
|
+
[5, 6],
|
|
74
|
+
[7, 8],
|
|
75
|
+
])
|
|
76
|
+
)
|
|
77
|
+
).toBeTruthy();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("Matrix#addable", () => {
|
|
82
|
+
test("addable mismatched columns", () => {
|
|
83
|
+
expect(
|
|
84
|
+
Matrix([
|
|
85
|
+
[1, 2],
|
|
86
|
+
[3, 4],
|
|
87
|
+
]).addable(
|
|
88
|
+
Matrix([
|
|
89
|
+
[1, 2, 3],
|
|
90
|
+
[4, 5, 6],
|
|
91
|
+
])
|
|
92
|
+
)
|
|
93
|
+
).toBeFalsy();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("addable mismatched rows", () => {
|
|
97
|
+
expect(
|
|
98
|
+
Matrix([
|
|
99
|
+
[1, 2],
|
|
100
|
+
[3, 4],
|
|
101
|
+
]).addable(
|
|
102
|
+
Matrix([
|
|
103
|
+
[1, 2],
|
|
104
|
+
[4, 5],
|
|
105
|
+
[7, 8],
|
|
106
|
+
])
|
|
107
|
+
)
|
|
108
|
+
).toBeFalsy();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test("addable", () => {
|
|
112
|
+
expect(
|
|
113
|
+
Matrix([
|
|
114
|
+
[1, 2],
|
|
115
|
+
[3, 4],
|
|
116
|
+
]).addable(
|
|
117
|
+
Matrix([
|
|
118
|
+
[5, 6],
|
|
119
|
+
[7, 8],
|
|
120
|
+
])
|
|
121
|
+
)
|
|
122
|
+
).toBeTruthy();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe("Matrix.add", () => {
|
|
127
|
+
test("add throws typerror", () => {
|
|
128
|
+
expect(
|
|
129
|
+
Matrix.add.bind(
|
|
130
|
+
Matrix,
|
|
131
|
+
Matrix([
|
|
132
|
+
[1, 2],
|
|
133
|
+
[3, 4],
|
|
134
|
+
]),
|
|
135
|
+
Matrix([
|
|
136
|
+
[1, 2, 3],
|
|
137
|
+
[4, 5, 6],
|
|
138
|
+
])
|
|
139
|
+
)
|
|
140
|
+
).toThrowError(new TypeError("Matrices are not addable"));
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("add", () => {
|
|
144
|
+
expect(
|
|
145
|
+
Matrix.add(
|
|
146
|
+
Matrix([
|
|
147
|
+
[1, 2],
|
|
148
|
+
[3, 4],
|
|
149
|
+
]),
|
|
150
|
+
Matrix([
|
|
151
|
+
[5, 6],
|
|
152
|
+
[7, 8],
|
|
153
|
+
])
|
|
154
|
+
)
|
|
155
|
+
).toStrictEqual(
|
|
156
|
+
Matrix([
|
|
157
|
+
[6, 8],
|
|
158
|
+
[10, 12],
|
|
159
|
+
])
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
describe("Matrix#add", () => {
|
|
165
|
+
const addmatrix = Matrix([
|
|
166
|
+
[1, 2],
|
|
167
|
+
[3, 4],
|
|
168
|
+
]);
|
|
169
|
+
|
|
170
|
+
test("add throws typerror", () => {
|
|
171
|
+
expect(
|
|
172
|
+
addmatrix.add.bind(
|
|
173
|
+
addmatrix,
|
|
174
|
+
Matrix([
|
|
175
|
+
[1, 2, 3],
|
|
176
|
+
[4, 5, 6],
|
|
177
|
+
])
|
|
178
|
+
)
|
|
179
|
+
).toThrowError(new TypeError("Matrices are not addable"));
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test("add", () => {
|
|
183
|
+
expect(
|
|
184
|
+
Matrix([
|
|
185
|
+
[1, 2],
|
|
186
|
+
[3, 4],
|
|
187
|
+
]).add(
|
|
188
|
+
Matrix([
|
|
189
|
+
[5, 6],
|
|
190
|
+
[7, 8],
|
|
191
|
+
])
|
|
192
|
+
)
|
|
193
|
+
).toStrictEqual(
|
|
194
|
+
Matrix([
|
|
195
|
+
[6, 8],
|
|
196
|
+
[10, 12],
|
|
197
|
+
])
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
describe("Matrix.multipliable", () => {
|
|
203
|
+
test("multipliable mismatched columns and rows", () => {
|
|
204
|
+
expect(
|
|
205
|
+
Matrix.multipliable(
|
|
206
|
+
Matrix([
|
|
207
|
+
[1, 2, 3],
|
|
208
|
+
[4, 5, 6],
|
|
209
|
+
]),
|
|
210
|
+
Matrix([
|
|
211
|
+
[1, 2],
|
|
212
|
+
[4, 5],
|
|
213
|
+
])
|
|
214
|
+
)
|
|
215
|
+
).toBeFalsy();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test("multipliable", () => {
|
|
219
|
+
expect(
|
|
220
|
+
Matrix.multipliable(
|
|
221
|
+
Matrix([
|
|
222
|
+
[1, 2],
|
|
223
|
+
[3, 4],
|
|
224
|
+
]),
|
|
225
|
+
Matrix([
|
|
226
|
+
[5, 6],
|
|
227
|
+
[7, 8],
|
|
228
|
+
])
|
|
229
|
+
)
|
|
230
|
+
).toBeTruthy();
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
describe("Matrix#multipliable", () => {
|
|
235
|
+
test("multipliable mismatched columns and rows", () => {
|
|
236
|
+
expect(
|
|
237
|
+
Matrix([
|
|
238
|
+
[1, 2, 3],
|
|
239
|
+
[4, 5, 6],
|
|
240
|
+
]).multipliable(
|
|
241
|
+
Matrix([
|
|
242
|
+
[1, 2],
|
|
243
|
+
[4, 5],
|
|
244
|
+
])
|
|
245
|
+
)
|
|
246
|
+
).toBeFalsy();
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("multipliable", () => {
|
|
250
|
+
expect(
|
|
251
|
+
Matrix([
|
|
252
|
+
[1, 2],
|
|
253
|
+
[3, 4],
|
|
254
|
+
]).multipliable(
|
|
255
|
+
Matrix([
|
|
256
|
+
[5, 6],
|
|
257
|
+
[7, 8],
|
|
258
|
+
])
|
|
259
|
+
)
|
|
260
|
+
).toBeTruthy();
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
describe("Matrix.multiply", () => {
|
|
265
|
+
const multiplymatrix = Matrix([1, 2, 3]);
|
|
266
|
+
|
|
267
|
+
test("multiply throws typerror", () => {
|
|
268
|
+
expect(
|
|
269
|
+
multiplymatrix.multiply.bind(
|
|
270
|
+
multiplymatrix,
|
|
271
|
+
Matrix([
|
|
272
|
+
[1, 2],
|
|
273
|
+
[3, 4],
|
|
274
|
+
])
|
|
275
|
+
)
|
|
276
|
+
).toThrowError(new TypeError("Matrices are not multipliable"));
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
test("multiply number", () => {
|
|
280
|
+
expect(Matrix(3).multiply(Matrix(6))).toStrictEqual(Matrix(18));
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
test("multiply A (1x2) and B (2x1)", () => {
|
|
284
|
+
expect(Matrix([1, 2]).multiply(Matrix([[3], [4]]))).toStrictEqual(
|
|
285
|
+
Matrix([11])
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
test("multiply A (2x2) and B (2x2)", () => {
|
|
290
|
+
expect(
|
|
291
|
+
Matrix([
|
|
292
|
+
[1, 2],
|
|
293
|
+
[3, 4],
|
|
294
|
+
]).multiply(
|
|
295
|
+
Matrix([
|
|
296
|
+
[5, 6],
|
|
297
|
+
[7, 8],
|
|
298
|
+
])
|
|
299
|
+
)
|
|
300
|
+
).toStrictEqual(
|
|
301
|
+
Matrix([
|
|
302
|
+
[19, 22],
|
|
303
|
+
[43, 50],
|
|
304
|
+
])
|
|
305
|
+
);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
test("multiply A (2x3) and B (3x2)", () => {
|
|
309
|
+
expect(
|
|
310
|
+
Matrix([
|
|
311
|
+
[1, 9, 7],
|
|
312
|
+
[8, 1, 2],
|
|
313
|
+
]).multiply(
|
|
314
|
+
Matrix([
|
|
315
|
+
[3, 2, 1, 5],
|
|
316
|
+
[5, 4, 7, 3],
|
|
317
|
+
[6, 9, 6, 8],
|
|
318
|
+
])
|
|
319
|
+
)
|
|
320
|
+
).toStrictEqual(
|
|
321
|
+
Matrix([
|
|
322
|
+
[90, 101, 106, 88],
|
|
323
|
+
[41, 38, 27, 59],
|
|
324
|
+
])
|
|
325
|
+
);
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
describe("Matrix#multiply", () => {
|
|
330
|
+
test("multiply throws typerror", () => {
|
|
331
|
+
expect(
|
|
332
|
+
Matrix.multiply.bind(
|
|
333
|
+
Matrix,
|
|
334
|
+
Matrix([1, 2, 3]),
|
|
335
|
+
Matrix([
|
|
336
|
+
[1, 2],
|
|
337
|
+
[3, 4],
|
|
338
|
+
])
|
|
339
|
+
)
|
|
340
|
+
).toThrowError(new TypeError("Matrices are not multipliable"));
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test("multiply number", () => {
|
|
344
|
+
expect(Matrix.multiply(Matrix(3), Matrix(6))).toStrictEqual(Matrix(18));
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
test("multiply A (1x2) and B (2x1)", () => {
|
|
348
|
+
expect(Matrix.multiply(Matrix([1, 2]), Matrix([[3], [4]]))).toStrictEqual(
|
|
349
|
+
Matrix([11])
|
|
350
|
+
);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
test("multiply A (2x2) and B (2x2)", () => {
|
|
354
|
+
expect(
|
|
355
|
+
Matrix.multiply(
|
|
356
|
+
Matrix([
|
|
357
|
+
[1, 2],
|
|
358
|
+
[3, 4],
|
|
359
|
+
]),
|
|
360
|
+
Matrix([
|
|
361
|
+
[5, 6],
|
|
362
|
+
[7, 8],
|
|
363
|
+
])
|
|
364
|
+
)
|
|
365
|
+
).toStrictEqual(
|
|
366
|
+
Matrix([
|
|
367
|
+
[19, 22],
|
|
368
|
+
[43, 50],
|
|
369
|
+
])
|
|
370
|
+
);
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
test("multiply A (2x3) and B (3x2)", () => {
|
|
374
|
+
expect(
|
|
375
|
+
Matrix.multiply(
|
|
376
|
+
Matrix([
|
|
377
|
+
[1, 9, 7],
|
|
378
|
+
[8, 1, 2],
|
|
379
|
+
]),
|
|
380
|
+
Matrix([
|
|
381
|
+
[3, 2, 1, 5],
|
|
382
|
+
[5, 4, 7, 3],
|
|
383
|
+
[6, 9, 6, 8],
|
|
384
|
+
])
|
|
385
|
+
)
|
|
386
|
+
).toStrictEqual(
|
|
387
|
+
Matrix([
|
|
388
|
+
[90, 101, 106, 88],
|
|
389
|
+
[41, 38, 27, 59],
|
|
390
|
+
])
|
|
391
|
+
);
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
describe("Matrix#valueOf", () => {
|
|
396
|
+
const array = [3];
|
|
397
|
+
|
|
398
|
+
test("valueOf Matrix", () => {
|
|
399
|
+
expect(Matrix(array).valueOf()).toBe(array);
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
describe("Matrix#countRows", () => {
|
|
404
|
+
test("countRows number", () => {
|
|
405
|
+
expect(Matrix(1).countRows()).toBe(0);
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
test("countRows number array", () => {
|
|
409
|
+
expect(Matrix([1]).countRows()).toBe(1);
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
test("countRows 2D number array", () => {
|
|
413
|
+
expect(
|
|
414
|
+
Matrix([
|
|
415
|
+
[1, 2],
|
|
416
|
+
[3, 4],
|
|
417
|
+
[5, 6],
|
|
418
|
+
]).countRows()
|
|
419
|
+
).toBe(3);
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
describe("Matrix#countColumns", () => {
|
|
424
|
+
test("countColumns number", () => {
|
|
425
|
+
expect(Matrix(1).countColumns()).toBe(0);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
test("countColumns number array", () => {
|
|
429
|
+
expect(Matrix([1]).countColumns()).toBe(1);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
test("countColumns 2D number array", () => {
|
|
433
|
+
expect(Matrix([[1], [2]]).countColumns()).toBe(1);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
test("countColumns many 2D number array", () => {
|
|
437
|
+
expect(
|
|
438
|
+
Matrix([
|
|
439
|
+
[1, 2],
|
|
440
|
+
[3, 4],
|
|
441
|
+
[5, 6],
|
|
442
|
+
]).countColumns()
|
|
443
|
+
).toBe(2);
|
|
444
|
+
});
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
describe("Matrix#transpose", () => {
|
|
448
|
+
test("transpose number", () => {
|
|
449
|
+
expect(Matrix(1).transpose()).toStrictEqual(Matrix(1));
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
test("transpose number array", () => {
|
|
453
|
+
expect(Matrix([1, 2]).transpose()).toStrictEqual(Matrix([[1], [2]]));
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
test("transpose 2D number array", () => {
|
|
457
|
+
expect(
|
|
458
|
+
Matrix([
|
|
459
|
+
[1, 2, 3],
|
|
460
|
+
[4, 5, 6],
|
|
461
|
+
]).transpose()
|
|
462
|
+
).toStrictEqual(
|
|
463
|
+
Matrix([
|
|
464
|
+
[1, 4],
|
|
465
|
+
[2, 5],
|
|
466
|
+
[3, 6],
|
|
467
|
+
])
|
|
468
|
+
);
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
describe("Matrix#invert", () => {
|
|
473
|
+
test("invert 2D number array", () => {
|
|
474
|
+
expect(
|
|
475
|
+
Matrix([
|
|
476
|
+
[1, 2],
|
|
477
|
+
[3, 4],
|
|
478
|
+
]).invert()
|
|
479
|
+
).toStrictEqual(
|
|
480
|
+
Matrix([
|
|
481
|
+
[-2, 1],
|
|
482
|
+
[1.5, -0.5],
|
|
483
|
+
])
|
|
484
|
+
);
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
describe("Matrix#map", () => {
|
|
489
|
+
const matrix = Matrix([1, 2, 3]);
|
|
490
|
+
|
|
491
|
+
test("map returns a matrix", () => {
|
|
492
|
+
expect(matrix.map((x: number) => x + 1)).toBeInstanceOf(Matrix);
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
test("map identity", () => {
|
|
496
|
+
expect(matrix.map((x: number) => x)).toStrictEqual(matrix);
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
test("map increment", () => {
|
|
500
|
+
expect(matrix.map((x: number) => x + 1)).toStrictEqual(Matrix([2, 3, 4]));
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
test("map non-mutable", () => {
|
|
504
|
+
expect(matrix).toStrictEqual(Matrix([1, 2, 3]));
|
|
505
|
+
});
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
describe("Matrix#inspect", () => {
|
|
509
|
+
test("inspect number", () => {
|
|
510
|
+
expect(inspect(Matrix(3))).toBe("3");
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
test("inspect number array", () => {
|
|
514
|
+
expect(inspect(Matrix([1, 2, 3]))).toBe("[ 1 2 3 ]");
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
test("inspect 2D number array", () => {
|
|
518
|
+
expect(
|
|
519
|
+
inspect(
|
|
520
|
+
Matrix([
|
|
521
|
+
[1, 2, 3],
|
|
522
|
+
[4, 5, 6],
|
|
523
|
+
[7, 8, 9],
|
|
524
|
+
])
|
|
525
|
+
)
|
|
526
|
+
).toBe("[ 1 2 3 ]\n[ 4 5 6 ]\n[ 7 8 9 ]");
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
test("inspect padded 2D number array", () => {
|
|
530
|
+
expect(
|
|
531
|
+
inspect(
|
|
532
|
+
Matrix([
|
|
533
|
+
[1, 2, 3],
|
|
534
|
+
[-10, 11, -12],
|
|
535
|
+
[100, 0, 0],
|
|
536
|
+
])
|
|
537
|
+
)
|
|
538
|
+
).toBe("[ 1 2 3 ]\n[ -10 11 -12 ]\n[ 100 0 0 ]");
|
|
539
|
+
});
|
|
540
|
+
});
|