Previous Up Next

5.49.2  Addition and subtraction of two matrices: + - .+ .-

The infixed operator + or .+ (resp. - or .-) are used for the addition (resp. subtraction) of two matrices.
Input:

[[1,2],[3,4]] + [[5,6],[7,8]]

Output:

[[6,8],[10,12]]

Input:

[[1,2],[3,4]] - [[5,6],[7,8]]

Output:

[[-4,-4],[-4,-4]]

Remark
+ can be used as a prefixed operator, in that case + must be quoted (’+’).
Input:

’+’([[1,2],[3,4]],[[5,6],[7,8]],[[2,2],[3,3]])

Output:

[[8,10],[13,15]]

Previous Up Next