## `linalg::substitute` -- replace a part of a matrix by another matrix

#### Introduction

`linalg::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)`

#### Parameters

`A, B` | - | matrices of a domain of category `Cat::Matrix`
`m, n` | - | positive integers

#### Returns

a matrix of the same domain type as `B`.

#### Related Functions

`linalg::submatrix`, `linalg::concatMatrix`, `linalg::setCol`, `linalg::setRow`, `linalg::stackMatrix`

#### Details

- `linalg::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].
- If the matrices are defined over different component domains, then the entries of `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 1

We 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  |
                               +-                -+

#### Changes

- new function

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000