LinearAlgebra - Maple Programming Help

Home : Support : Online Help : Mathematics : Linear Algebra : LinearAlgebra Package : Standard : LinearAlgebra/Add

LinearAlgebra

 compute a linear combination of Matrices, Vectors and scalars

 Calling Sequence Add(A, B, c1, c2, ip, options)

Parameters

 A - Matrix, Vector, or scalar B - Matrix, Vector, or scalar c1, c2 - (optional) scalars ip - (optional) BooleanOpt(inplace); specifies if output overwrites input options - (optional); constructor options for the result object

Description

 • The Add(A, B) function, where A and B are either both Matrices or both Vectors, computes the elementwise sum of A and B. The special case of the sum of a scalar and a Matrix is described below. Any other combination for the types of A and B results in an error.
 The default values of c1 and c2 is 1.
 If A and B are both Matrices or both Vectors, Add(A, B, c1, c2)  computes the sum $A\mathrm{c1}+B\mathrm{c2}$.
 If A is a scalar and B is a Matrix, then Add(A, B, c1, c2) computes the sum $\mathrm{c1}\mathrm{ScalarMatrix}\left(A,\mathrm{op}\left(1,B\right)\right)+\mathrm{c2}B$.
 If A is a Matrix and B is a scalar, Add(A, B, c1, c2) returns the sum $\mathrm{c1}A+\mathrm{c2}\mathrm{ScalarMatrix}\left(B,\mathrm{op}\left(1,A\right)\right)$.
 If A is a scalar and B is a scalar, Add(A, B, c1, c2)  returns the sum $A\mathrm{c1}+B\mathrm{c2}$.
 • 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.
 • This function is part of the LinearAlgebra package, and so it can be used in the form Add(..) only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[Add](..).
 Note:  This routine uses the types of the first two parameters to select between the MatrixAdd and VectorAdd LinearAlgebra routines to do the actual computation.

Examples

 > $\mathrm{with}\left(\mathrm{LinearAlgebra}\right):$
 > $\mathrm{Ax}≔⟨1.00004,1.99987,-0.00012⟩:$
 > $b≔⟨1.,2.,0.⟩:$
 > $\mathrm{Add}\left(\mathrm{Ax},b,1,-1\right)$
 $\left[\begin{array}{c}{0.0000400000000000400}\\ {-}{0.000129999999999963}\\ {-}{0.000120000000000000}\end{array}\right]$ (1)
 > $M≔⟨⟨m,o⟩|⟨n,p⟩⟩:$
 > $\mathrm{Add}\left(M,-\mathrm{λ},\mathrm{inplace}\right)$
 $\left[\begin{array}{cc}{m}{-}{\mathrm{λ}}& {n}\\ {o}& {p}{-}{\mathrm{λ}}\end{array}\right]$ (2)
 > $M$
 $\left[\begin{array}{cc}{m}{-}{\mathrm{λ}}& {n}\\ {o}& {p}{-}{\mathrm{λ}}\end{array}\right]$ (3)