home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
msdos
/
math
/
matrix.arc
/
M_INVERT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1985-01-13
|
4KB
|
26 lines
static char *sccsid = "@(#)m_invert.c 4/7/82 (U of Maryland, FLB)";
#include "mat.h"
struct matrix *
m_invert(mat)
register struct matrix *mat;
{
register struct matrix *result;
register int row, col;
double det;
if((det = m_determinant(mat)) == 0.0) {
printf("m_invert: singular matrix\n");
return(M_NULL);
}
m_create(result, mat->m_cols, mat->m_rows);
for (row = 0; row < mat->m_rows; row++)
for (col = 0; col < mat->m_cols; col++)
m_v(result, col, row) = m_cofactor(mat, row, col) / det;
return(result);
}