linalg::delCol
-- delete matrix
columnslinalg::delCol
(A, c)
returns a copy of the
matrix A in which the column with index c is
deleted.
linalg::delCol(A, c)
linalg::delCol(A, c1..c2)
linalg::delCol(A, list)
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) |
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
.
linalg::col
, linalg::delRow
, linalg::row
linalg::delCol
(A, c1..c2)
deletes those
columns whose indices are in the range c1..c2
. If c2
< c1
then the input matrix A
is returned.linalg::delCol
(A, list)
deletes those
columns whose indices are contained in list
.DOM_NULL
is returned.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 | +- -+
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
.
DOM_NULL
instead of the object
NIL
is returned.