| TUmatrixInv | TCL UTILITIES USER MANUAL | TUmatrixInv |
|---|
| set |
[TUmatrixInv  |
|
| N | - | Dimension of matrix being inverted |
| A | - | Matrix to be inverted stored row by row in a 1D array. The inverted matrix is returned in this matrix. |
| Off | - | Offset into the input matrix array to the beginning of the matrix to be inverted. Default is 0. |
| M | - | The number of columns of data in the optional result matrix. Default is 0 indicating that there is no result matrix being input. |
| B | - | Result matrix to be used in the formation of the solution matrix to the set of linear equations represented by the input matrix. This stored row by row in a 1D array. The solution matrix is returned in this matrix. Default is no input result matrix. |
| OffR | - | Offset into the result matrix array to the beginning of the result matrix to be used in the solution of the set of linear equations. Default is 0. |
| rV | - | -2 0 pivot element (Singular matrix) |
| -1 No pivot element (Singular matrix) | ||
|   1 Successful inversion |
|A|   &sdot   |X|   =   |B|
It returns the inversion of A in A and X in
B. If the result matrix B is not given as input only
the inversion of A is returned.
# SOLVE the set of equations
#
# 7x + y + 10z = -4
# 1.5x + y + 2z = 7.5
# -.5x + 7y - 3.5z = 1.0
# INPUT matrix
set A(0) 7.0 ; set A(1) 1.0 ; set A(2) 10.0
set A(3) 1.5 ; set A(4) 1.0 ; set A(5) 2.0
set A(6) -.5 ; set A(7) 7.0 ; set A(8) -3.5
# COPY of input matrix
set D(0) 7.0 ; set D(1) 1.0 ; set D(2) 10.0
set D(3) 1.5 ; set D(4) 1.0 ; set D(5) 2.0
set D(6) -.5 ; set D(7) 7.0 ; set D(8) -3.5
# RESULT Matrix
set B(0) -4.0
set B(1) 7.5
set B(2) 1.0
# SOLVE
TUmatrixInv 3 A 0 1 B 0
puts stderr "Inversion: [format "%.1f %.1f %.1f" $A(0) $A(1) $A(2)]"
puts stderr " [format "%.1f %.1f %.1f" $A(3) $A(4) $A(5)]"
puts stderr " [format "%.1f %.1f %.1f" $A(6) $A(7) $A(8)]"
puts stderr "Solution: [format "x = %.1f" $B(0)]"
puts stderr " [format "y = %.1f" $B(1)]"
puts stderr " [format "z = %.1f" $B(2)]"
# CHECK inversion
TUmatrixMath D * A C 3 3 3 3
puts stderr "Inversion Check: [format "%.1f %.1f %.1f" $C(0) $C(1) $C(2)]"
puts stderr " [format "%.1f %.1f %.1f" $C(3) $C(4) $C(5)]"
puts stderr " [format "%.1f %.1f %.1f" $C(6) $C(7) $C(8)]"
# CHECK solutions
set Rx [expr $D(0) * $B(0) + $D(1) * $B(1) + $D(2) * $B(2)]
set Ry [expr $D(3) * $B(0) + $D(4) * $B(1) + $D(5) * $B(2)]
set Rz [expr $D(6) * $B(0) + $D(7) * $B(1) + $D(8) * $B(2)]
puts stderr "Check: [format "x = %5.1f (Should be -4.0)" $Rx]"
puts stderr " [format "y = %5.1f (Should be 7.5)" $Ry]"
puts stderr " [format "z = %5.1f (Should be 4.0)" $Rz]"
> Inversion: 2.1 -8.9 1.0
> -0.5 2.4 -0.1
> -1.3 6.0 -0.7
> Solution: x = -74.3
> y = 19.7
> z = 49.7
> Inversion Check: 1.0 0.0 0.0
> 0.0 1.0 0.0
> -0.0 0.0 1.0
> Check: x = -4.0 (Should be -4.0)
> y = 7.5 (Should be 7.5)
> z = 1.0 (Should be 4.0)
| July 25, 2003 |
|---|