Previous Page Next Page Contents

linalg::delCol -- delete matrix columns

Introduction

linalg::delCol(A, c) returns a copy of the matrix A in which the column with index c is deleted.

Call(s)

linalg::delCol(A, c)
linalg::delCol(A, c1..c2)
linalg::delCol(A, list)

Parameters

A - an m x n matrix of a domain of category Cat::Matrix
c - the column index: a positive integer <= n
c1..c2 - a range of column indices (positive integers <= n)
list - a list of column indices (positive integers <= n)

Returns

a matrix of a domain of category Cat::Matrix(R), where R is the component ring of A, or the void object of type DOM_NULL.

Related Functions

linalg::col, linalg::delRow, linalg::row

Details

Example 1

We define the following matrix:

>> A := matrix([[1, 2, 3, 4], [5, 6, 7, 8]])
                             +-            -+
                             |  1, 2, 3, 4  |
                             |              |
                             |  5, 6, 7, 8  |
                             +-            -+

and demonstrate the three different input formats for linalg::delCol:

>> linalg::delCol(A, 2)
                               +-         -+
                               |  1, 3, 4  |
                               |           |
                               |  5, 7, 8  |
                               +-         -+
>> linalg::delCol(A, [1, 3])
                                +-      -+
                                |  2, 4  |
                                |        |
                                |  6, 8  |
                                +-      -+
>> linalg::delCol(A, 2..4)
                                  +-   -+
                                  |  1  |
                                  |     |
                                  |  5  |
                                  +-   -+

Example 2

We compute the inverse of the 2x2 matrix:

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

by appending the 2x2 identity matrix to the right side of A and applying the Gauss-Jordan algorithm provided by the function linalg::gaussJordan:

>> B := linalg::gaussJordan(A . MatQ::identity(2))
                          +-                   -+
                          |  1, 0, 2/11,  1/11  |
                          |                     |
                          |  0, 1, 5/22, -3/22  |
                          +-                   -+

We get the inverse of A by deleting the first two columns of the matrix B:

>> AI := linalg::delCol(B, 1..2)
                             +-             -+
                             |  2/11,  1/11  |
                             |               |
                             |  5/22, -3/22  |
                             +-             -+

Finally, we check the result:

>> A * AI, AI * A
                          +-      -+  +-      -+
                          |  1, 0  |  |  1, 0  |
                          |        |, |        |
                          |  0, 1  |  |  0, 1  |
                          +-      -+  +-      -+

Note: The inverse of A can be computed directly by entering 1/A.

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000