Previous Page Next Page Contents

linalg::setCol -- change a column of a matrix

Introduction

linalg::setCol(A, p, c) returns a copy of matrix A with the p-th column replaced by the column vector c.

Call(s)

linalg::setCol(A, p, c)

Parameters

A - an m x n matrix of a domain of category Cat::Matrix
c - a column vector, or a list that can be converted into a column vector of the domain Dom::Matrix(R), where R is the component ring of A (a column vector is an m x 1 matrix)

Returns

a matrix of the same domain type as A.

Related Functions

linalg::col, linalg::delCol, linalg::delRow, linalg::row, linalg::setRow

Details

Example 1

We define a matrix over the rationals:

>> MatQ := Dom::Matrix(Dom::Rational): 
   A := MatQ([[1, 2], [3, 2]])
                                +-      -+
                                |  1, 2  |
                                |        |
                                |  3, 2  |
                                +-      -+

and replace the 2nd column by the 2x1 zero vector:

>> linalg::setCol(A, 2, MatQ([0, 0]))
                                +-      -+
                                |  1, 0  |
                                |        |
                                |  3, 0  |
                                +-      -+

Example 2

We create the 2x2 zero matrix over Z6:

>> B := Dom::Matrix(Dom::IntegerMod(6))(2, 2)
                          +-                  -+
                          |  0 mod 6, 0 mod 6  |
                          |                    |
                          |  0 mod 6, 0 mod 6  |
                          +-                  -+

and replace the 2nd column by the vector [[1,-1]]. We give the column vector in form of a list. Its elements are converted implicitly into objects of the component ring of B:

>> linalg::setCol(B, 2, [1, -1])
                          +-                  -+
                          |  0 mod 6, 1 mod 6  |
                          |                    |
                          |  0 mod 6, 5 mod 6  |
                          +-                  -+

The following input leads to an error message because the number 1/3 can not be converted into an object of type Dom::IntegerMod(6):

>> linalg::setCol(B, 1, [1/3, 0])
      Error: invalid column vector [linalg::setCol]




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000