home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
vis-ftp.cs.umass.edu
/
vis-ftp.cs.umass.edu.tar
/
vis-ftp.cs.umass.edu
/
pub
/
Software
/
ASCENDER
/
ascender.tar.Z
/
ascender.tar
/
Triangulate
/
matrixinv2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-02-27
|
582b
|
32 lines
#include "nrutil.h"
void matrixinvert(double ** a, int n) {
/* inverts matrix and returns it in place */
double **y, d, *col;
int i, j, *indx;
indx = ivector(0,n-1);
col = dvector(0,n-1);
y = dmatrix(0,n-1,0,n-1);
ludcmp(a, n, indx, &d);
for (j=0;j<n;j++) {
for (i=0;i<n;i++)
col[i] = 0.0;
col[j] = 1.0;
lubksb(a, n, indx, col);
for (i=0; i < n; i++)
y[i][j] = col[i];
}
for (i=0;i<n;i++)
for (j=0;j<n;j++)
a[i][j] = y[i][j];
free_dmatrix(y,0,n-1,0,n-1);
free_dvector(col,0,n-1);
free_ivector(indx,0,n-1);
}