invalid arguments (in rtable Sum) - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Error Message Guide : invalid arguments (in rtable Sum)

Error, (in rtable/Sum) invalid input

Error, (in rtable/Sum) invalid arguments

 

Description

Examples

See Also

Description

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.

 

Examples

Example 1

 

M  1,2

M12

(2.1)

V  5,6

V56

(2.2)

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

(2.3)

whattypeV

Vectorcolumn

(2.4)

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

(2.5)

 

Example 2 

Here we try adding two column Vectors.

Y1,2,3

Y123

(2.6)

Z4,5

Z45

(2.7)

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.

 

Solution:

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

(2.8)

Y+Vector3,Z

573

(2.9)

 

Example 3 

Here we try adding two Arrays with different dimension.

AArray1,2,3,4,5,6,7,8,9

A123456789

(2.10)

BArray1,10,2,20

B110220

(2.11)

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)

 

Solution:

Again, the solution is to use Array to construct a 3X3 Array using B as the initializer.

 

Array1..3,1..3,B

11002200000

(2.12)

A+Array1..3,1..3,B

21236256789

(2.13)

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:

A+B

Error, (in rtable/Sum) invalid arguments

 

See Also

Array, convert,  Matrix, Vector