home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
progm
/
elem-c.zip
/
M_COFACT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1985-05-18
|
4KB
|
26 lines
static char *sccsid = "@(#)m_cofactor.c 4/5/82 (U of Maryland, FLB)";
#include "mat.h"
double
m_cofactor(mat, i, j)
register struct matrix *mat;
register int i, j;
{
register struct matrix *result;
register int row, col, o_row = 0, o_col = 0;
double det;
m_create(result, mat->m_rows - 1, mat->m_cols - 1);
for (row = 0; row < mat->m_rows; row++)
for (col = 0; col < mat->m_cols; col++)
if (row != i && col != j)
m_v(result, o_row++, o_col++) = m_v(mat, row, col);
det = m_determinant(result);
free(result);
return(((i + j) & 01)? -det: det);
}