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_COFACT.C
next >
Wrap
C/C++ Source or Header
|
1985-01-13
|
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);
}