linalg::substitute -- replace
a part of a matrix by another matrix
Introductionlinalg::substitute(B, A, m, n) returns a
copy of the matrix B, where entries starting at position
[m,n] are replaced by the entries of the matrix
A.
Call(s)linalg::substitute(B, A, m, n)
ParametersA, B |
- | matrices of a domain of category Cat::Matrix |
m, n |
- | positive integers |
Returnsa matrix of the same domain type as B.
Related
Functionslinalg::submatrix, linalg::concatMatrix, linalg::setCol, linalg::setRow, linalg::stackMatrix
Detailslinalg::substitute(B, A, m, n) returns a
copy of the matrix B, where entries starting at position
[m,n] are replaced by the entries of the matrix
A, i.e., B[m,n] is A[1,1].A are converted into elements of the
component domain of the matrix B. If one of these
conversions fails, then an error message is returned.
Example
1We define the following matrix:
>> B := matrix(
[[1, 2, 3, 4], [5, 6, 7, 8],
[9, 10, 11, 12], [13, 14, 15, 16]]
)
+- -+
| 1, 2, 3, 4 |
| |
| 5, 6, 7, 8 |
| |
| 9, 10, 11, 12 |
| |
| 13, 14, 15, 16 |
+- -+
and copy the 2 x 2 zero matrix into the
matrix B, beginning at position [3,3]:
>> A := matrix(2, 2): linalg::substitute(B, A, 3, 3)
+- -+
| 1, 2, 3, 4 |
| |
| 5, 6, 7, 8 |
| |
| 9, 10, 0, 0 |
| |
| 13, 14, 0, 0 |
+- -+
Matrix entries out of range are ignored:
>> linalg::substitute(B, A, 4, 4)
+- -+
| 1, 2, 3, 4 |
| |
| 5, 6, 7, 8 |
| |
| 9, 10, 11, 12 |
| |
| 13, 14, 15, 0 |
+- -+