(a, b)
| 59 | * @trows {Error} |
| 60 | */ |
| 61 | export const validateSameShape = (a, b) => { |
| 62 | validateType(a); |
| 63 | validateType(b); |
| 64 | |
| 65 | const aShape = shape(a); |
| 66 | const bShape = shape(b); |
| 67 | |
| 68 | if (aShape.length !== bShape.length) { |
| 69 | throw new Error('Matrices have different dimensions'); |
| 70 | } |
| 71 | |
| 72 | while (aShape.length && bShape.length) { |
| 73 | if (aShape.pop() !== bShape.pop()) { |
| 74 | throw new Error('Matrices have different shapes'); |
| 75 | } |
| 76 | } |
| 77 | }; |
| 78 | |
| 79 | /** |
| 80 | * Generates the matrix of specific shape with specific values. |