12-14-2007
need help-matrix inverse (awk)
I have few days to complete my awk homework. But I'm stucked. i hope some1 will help me out.
I have to inverse n x n matrix, but I have problems with finding the determinant of the matrix.
I found the algoritm, how to find a determinant of n x n matrix:
http://www.es.ucsc.edu/~eart111/lecture12.pdf
same text here:
a11 a12 a13
a21 a22 a23
a31 a32 a33
= a11(a22a33 − a23a32) − a12(a21a33 − a23a31) + a13(a21a32 − a22a31)
Note the pattern of + and − signs.
The general formula is compact, but tedious to compute. Here it is for an n by n matrix A:
detA = ai1Ci1 + ai2Ci2 + · · · + ainCin
where Cij are referred to as the cofactors and are computed from
Cij = (−1)i+j detMij
The term Mij is known as the ”minor matrix” and is the matrix you get if you eliminate row
i and column j from matrix A. So to find the determinant of e.g. a 4×4 matrix, you end up
calculating a bunch of 3 × 3 matrix determinants (much easier). Obviously you can apply this
technique recursively (probably using a computer).
****************************
Can some1 please write this matrix determinant algoritm into my code or if you have time, complete the full inverse?
I'm reading the matrix from a text file into an array "row"
--------------------
#!/usr/bin/awk -f
BEGIN{}
{
m=1
while (m <= NF){
row[NR,m] = $m
m++
}
}
END{}
-------------------
thank you
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to inverse a matrix given in a file.
The problem is I'm stuck with writing determinant finding algoritm into code.
I found this algoritm about finding determinant of nxn matrix. This is what i need:
Matrices and Determinants
and here:
a11 a12 a13
a21 a22 a23
a31 a32 a33... (0 Replies)
Discussion started by: vesyyr
0 Replies
2. Shell Programming and Scripting
hi there
I'm very new in programing and i've started with awk.
I'm processing 200 data files and I need to do some precessing on them.
The files have 3 columns with N-lines
for each line a have on the first and second value is the same for all the files and only the third is variable. like... (2 Replies)
Discussion started by: philstar
2 Replies
3. Shell Programming and Scripting
Howdy,
I need to convert an association data matrix, currently in a two-column format, into a matrix with numbers indicating the number of associations. I've been looking around for AWK code in the list, but could not find anything. Here's an example of what I want to perform:
original... (10 Replies)
Discussion started by: sramirez
10 Replies
4. Shell Programming and Scripting
Hi everyone
I am very new at awk but think that that might be the best strategy for this. I have a matrix very similar to a correlation matrix and in practical terms I need to convert it into a list containing the values from the matrix (one value per line) with the first field of the line (row... (5 Replies)
Discussion started by: stonemonkey
5 Replies
5. Shell Programming and Scripting
Hi there,
If anyone can help me sorting out this small task would be great. Given a matrix like the following:
100 3 3 3 3 3 ...
200 5 5 5 5 5 ...
400 1 1 1 1 1 ...
500 8 8 8 8 8 ...
900 0 0 0 0... (5 Replies)
Discussion started by: JRodrigoF
5 Replies
6. Shell Programming and Scripting
Hi,
Needs for statistics, doing converting
Here is a sample file
Input :
1|A|17,94
1|B|22,59
1|C|56,93
2|A|63,71
2|C|23,92
5|B|19,49
5|C|67,58
expecting something like that
Output :
1|A|17,94|B|22,59|C|56,93
2|A|63,71|B|0|C|23,92
5|A|0|B|19,49|C|67,58 (11 Replies)
Discussion started by: fastlane3000
11 Replies
7. Shell Programming and Scripting
Hi, every one. I have two files ,one is in matrix like this, one is a list with the same data as the matrix.
AB AE AC AD AA AF
SA 3 4 5 6 4 6
SC 5 7 2 8 4 3
SD 4 6 5 3 8 3
SE 45 ... (5 Replies)
Discussion started by: xshang
5 Replies
8. Shell Programming and Scripting
is it possible to order the following row clusters from ascending to descending. thanx in advance
input
1 2 4 0
1 2 4 0
3 3 3 3
1 5 1 0
1 5 1 0
6 0 0 0
5 1 1 1... (4 Replies)
Discussion started by: quincyjones
4 Replies
9. Shell Programming and Scripting
How can i convert two columns in to o and 1 matrix. thnks
Input
a c1
b c2
c c1
d c3
e c4
output
c1 c2 c3 c4
a 1 0 0 0
b 0 1 0 0
c 1 0 0 0
d 0 0 ... (5 Replies)
Discussion started by: quincyjones
5 Replies
10. Shell Programming and Scripting
input
A1 B1 A2 B2
0 0 1 1
1 0 0 1
0 1 1 0
1 1 1 1
Output
label A1 B1 A2 B2
A1 2 1 1 2
B1 1 2 2 1
A2 1 2 3 2
B2 2 1 2 3
Ex:
The number of times that A1 and B1 row values are both 1 should be printed as output.
The last row of A1 and B1 in the input match by having 1 in both... (4 Replies)
Discussion started by: quincyjones
4 Replies
LEARN ABOUT REDHAT
zhetri
ZHETRI(l) ) ZHETRI(l)
NAME
ZHETRI - compute the inverse of a complex Hermitian indefinite matrix A using the factorization A = U*D*U**H or A = L*D*L**H computed by
ZHETRF
SYNOPSIS
SUBROUTINE ZHETRI( UPLO, N, A, LDA, IPIV, WORK, INFO )
CHARACTER UPLO
INTEGER INFO, LDA, N
INTEGER IPIV( * )
COMPLEX*16 A( LDA, * ), WORK( * )
PURPOSE
ZHETRI computes the inverse of a complex Hermitian indefinite matrix A using the factorization A = U*D*U**H or A = L*D*L**H computed by
ZHETRF.
ARGUMENTS
UPLO (input) CHARACTER*1
Specifies whether the details of the factorization are stored as an upper or lower triangular matrix. = 'U': Upper triangular,
form is A = U*D*U**H;
= 'L': Lower triangular, form is A = L*D*L**H.
N (input) INTEGER
The order of the matrix A. N >= 0.
A (input/output) COMPLEX*16 array, dimension (LDA,N)
On entry, the block diagonal matrix D and the multipliers used to obtain the factor U or L as computed by ZHETRF.
On exit, if INFO = 0, the (Hermitian) inverse of the original matrix. If UPLO = 'U', the upper triangular part of the inverse is
formed and the part of A below the diagonal is not referenced; if UPLO = 'L' the lower triangular part of the inverse is formed and
the part of A above the diagonal is not referenced.
LDA (input) INTEGER
The leading dimension of the array A. LDA >= max(1,N).
IPIV (input) INTEGER array, dimension (N)
Details of the interchanges and the block structure of D as determined by ZHETRF.
WORK (workspace) COMPLEX*16 array, dimension (N)
INFO (output) INTEGER
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
> 0: if INFO = i, D(i,i) = 0; the matrix is singular and its inverse could not be computed.
LAPACK version 3.0 15 June 2000 ZHETRI(l)