Matrix and Vector Entry Assignment - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Linear Algebra : LinearAlgebra Package : Entry Operations : LinearAlgebra/General/MVassignment

Matrix and Vector Entry Assignment

Assignment statements can be used to change the value of entries in an existing Matrix or Vector (whose constructor option ro has not been set to readonly).

If assignment statements are used for this purpose, there are consequences regarding how the resulting Matrix or Vector is returned.

  

In the following sections, A is a Matrix and V is a Vector.

 

Assigning Values to Entries

Properties of the Resulting Matrix or Vector

Assigning Values to Entries

  

Each of the entry selection formats described in Matrix and Vector Entry Extraction can be used on the left-hand side of an assignment statement. Entries selected in the left-hand side of the assignment statement are replaced by the corresponding entries of the right-hand side.  Unspecified entries are set to 0. The number of dimensions in such an assignment statement must match; a Vector can be assigned to a submatrix, provided it is a 1 x n submatrix.

  

For example, the assignment

A := Matrix([[9,9,9,9],[9,9,9,9],[9,9,9,9],[9,9,9,9]]);

A:=9999999999999999

(1)

A[1..2, 2..4] := Matrix([[5, 6], [7, 8]]);

A1..2,2..4:=5678

(2)

A;

9560978099999999

(3)
  

replaces A[1, 2] with 5, A[1, 3] with 6, A[2, 2] with 7, and A[2, 3] with 8. The entries A[1, 4] and A[2, 4] are set to 0.

  

It is not necessary for the selection on the left-hand side of an assignment statement to represent contiguous nor ordered components of the Matrix or Vector. For example, A[[ 3, 1], 1..-1] := B replaces row 3 and row 1 of A with, respectively, row 1 and row 2 of some existing Matrix B.

Properties of the Resulting Matrix or Vector

  

All of the assignment operations mentioned operate in place -- the resulting Matrix or Vector overwrites the original Matrix or Vector. One consequence is that the command A[1..-1, 1..-1] := Matrix([[...], ..., [...]]) causes a replacement of all the entries of A, whereas the command A := Matrix([[...], ..., [...]]) creates a new Matrix.

  

For all assignments, the values on the right-hand side must be of the same or compatible datatype as that of the Matrix or Vector on the left-hand side. Furthermore, it is an error if the right-hand side does not fit into the selected submatrix, subvector, or scalar location specified on the left-hand side. It is not an error if the right-hand side is smaller than the left-hand side.

See Also

assignment

Matrix

Matrix and Vector Entry Extraction

rtable_indexing

Vector

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam