Error, (in rtable/Sum) invalid input
Error, (in rtable/Sum) invalid arguments
Description
Examples
See Also
This error occurs when trying to add or subtract two Arrays, Matrices, or Vectors that are either not of the same type or do not have the same dimensions.
The usual fix for this is to convert one of both of the elements so that they are both of the same type and/or dimension using either convert, Transpose, or the constructors for Array, Matrix, or Vector.
Example 1
M ≔ 1,2
M≔12
V ≔ 5,6
V≔56
M+V
Error, (in rtable/Sum) invalid input: dimensions do not match: Matrix(1 .. 2, 1 .. 1) cannot be added to Vector[column](1 .. 2)
In this first example, M and V appear to be of the same type, but they are not:
whattypeM
Matrix
whattypeV
Vectorcolumn
When addition is attempted an error occurs.
Solution:
To solve this error, use convert on one (or both) of the elements to be added. Here, we convert V to a Matrix before adding it to M:
M+convertV,Matrix
68
Example 2
Here we try adding two column Vectors.
Y≔1,2,3
Y≔123
Z≔4,5
Z≔45
Y+Z
Error, (in rtable/Sum) invalid input: dimensions do not match: Vector[column](1 .. 3) cannot be added to Vector[column](1 .. 2)
The error occurs because Y is a 3-element column Vector and Z is a 2-element column Vector.
To correct this error, use the Vector constructor to create a 3-element Vector using Z as the initializer for the first two elements. If the new Vector has more elements than the initializer, the remaining elements are set to zero.
Vector3,Z
450
Y+Vector3,Z
573
Example 3
Here we try adding two Arrays with different dimension.
A≔Array1,2,3,4,5,6,7,8,9
A≔123456789
B≔Array1,10,2,20
B≔110220
A+B
Error, (in rtable/Sum) invalid input: dimensions do not match: Array(1 .. 3, 1 .. 3) cannot be added to Array(1 .. 2, 1 .. 2)
Again, the solution is to use Array to construct a 3X3 Array using B as the initializer.
Array1..3,1..3,B
11002200000
A+Array1..3,1..3,B
21236256789
For users of Maple 18 and earlier versions: These examples resulted in a different error message. The solutions are the same. For example, the example 3 given above resulted in:
Array, convert, Matrix, Vector
Download Help Document