マトリックス求逆アルゴリズム
/**
* A Ai
*@param A
*@param Ai
*@param size
*@return ,
*/
int InverseMatrix(double **Ai, double **A, int size)
{
int i, j;
double *b, *x;
b = (double*)malloc(sizeof(double)*size);
x = (double*)malloc(sizeof(double)*size);
for (i = 0; i < size; i++)
{
memset(b, 0, sizeof(double)*size);
b[i] = 1;
if (!LinearEquation(A, x, b, size))
{
free(b);
free(x);
return 0;
}
for (j = 0; j < size; j++)
Ai[j][i] = x[j];
}
free(b);
free(x);
return 1;
}