Previous Up Next

14.3.2  Addition and subtraction of two matrices

The infixed operator + or .+ (resp. - or .-) is used for matrix addition (resp. subtraction). Note that + and - can also be used as prefixed operators, in which case they must be quoted, like ’+’ and ’-’ (see Section 14.1.3 and Section 14.1.4).

Examples

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


68
1012


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


−4−4
−4−4


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


810
1315


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


−4−4
−4−4


          

Previous Up Next