LinearAlgebra

 compute a linear combination of two Matrices
 compute a linear combination of two Vectors

 Calling Sequence MatrixAdd(A, B, c1, c2, ip, options) VectorAdd(U, V, c1, c2, ip, options)

Parameters

 A, B - Matrices with consistent dimensions U, V - Vectors with consistent orientations and dimensions c1, c2 - (optional) scalars ip - (optional) equation of the form inplace=true or false; specifies if output overwrites input options - (optional); constructor options for the result object

Description

 • The MatrixAdd(A, B) function computes the elementwise sum of A and B.
 If A and B are mXn Matrices and M := MatrixAdd(A, B), then ${M}_{i,j}={A}_{i,j}+{B}_{i,j}$ for i=1..m and j=1..n.
 If the optional scalar parameters c1 and c2 are included in the calling sequence, then ${M}_{i,j}=\mathrm{c1}{A}_{i,j}+\mathrm{c2}{B}_{i,j}$.
 • The VectorAdd(U, V) function computes the elementwise linear combination of U and V.
 If U and V are n-dimensional Vectors with the same orientation and $M≔\mathrm{VectorAdd}\left(U,V\right)$, then ${M}_{i}={U}_{i}+{V}_{i}$ for i=1..n.
 If the optional scalar parameters c1 and c2 are  included in the calling sequence, then ${M}_{i}=\mathrm{c1}{U}_{i}+\mathrm{c2}{V}_{i}$.
 • The inplace option (ip) determines where the result is returned. If given as inplace=true, the result overwrites the first argument. If given as inplace=false, or if this option is not included in the calling sequence, the result is returned in a new Matrix (or Vector).
 The condition inplace=true can be abbreviated to inplace.
 The inplace option must be used with caution since, if the operation fails, the original Matrix (or Vector) argument may be corrupted.
 • The constructor options provide additional information (readonly, shape, storage, order, datatype, and attributes) to the Matrix or Vector constructor that builds the result. These options may also be provided in the form outputoptions=[...], where [...] represents a Maple list.  If a constructor option is provided in both the calling sequence directly and in an outputoptions option, the latter takes precedence (regardless of the order).
 • The inplace and constructor options are mutually exclusive.
 • These functions are part of the LinearAlgebra package, and so they can be used in the form MatrixAdd(..) or VectorAdd(..)only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[MatrixAdd](..) or LinearAlgebra[VectorAdd](..).

Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$
 > $A≔⟨⟨a,d⟩|⟨b,e⟩|⟨c,f⟩⟩$
 ${A}{≔}\left[\begin{array}{ccc}{a}& {b}& {c}\\ {d}& {e}& {f}\end{array}\right]$ (1)
 > $\mathrm{MatrixAdd}\left(A,\mathrm{IdentityMatrix}\left(2,3\right)\right)$
 $\left[\begin{array}{ccc}{a}{+}{1}& {b}& {c}\\ {d}& {e}{+}{1}& {f}\end{array}\right]$ (2)
 > $\mathrm{MatrixAdd}\left(\mathrm{ConstantMatrix}\left(1,2,3\right),A,n\right)$
 $\left[\begin{array}{ccc}{n}{+}{a}& {n}{+}{b}& {n}{+}{c}\\ {n}{+}{d}& {n}{+}{e}& {n}{+}{f}\end{array}\right]$ (3)
 > $V≔⟨3|0|0⟩$
 ${V}{≔}\left[\begin{array}{ccc}{3}& {0}& {0}\end{array}\right]$ (4)
 > $\mathrm{VectorAdd}\left(V,⟨i|j|k⟩,1,-2,\mathrm{inplace}\right)$
 $\left[\begin{array}{ccc}{3}{-}{2}{}{i}& {-}{2}{}{j}& {-}{2}{}{k}\end{array}\right]$ (5)
 > $V$
 $\left[\begin{array}{ccc}{3}{-}{2}{}{i}& {-}{2}{}{j}& {-}{2}{}{k}\end{array}\right]$ (6)