GSL计算逆矩阵

void GetInverse(gsl_matrix *A, gsl_matrix *inverse)
{
	int n = A->size1;
	gsl_matrix *tmpA = gsl_matrix_alloc(n, n);
	gsl_matrix_memcpy(tmpA, A);
	gsl_permutation *p = gsl_permutation_alloc(n);
	int sign = 0;
	gsl_linalg_LU_decomp(tmpA, p, &sign);
	inverse = gsl_matrix_alloc(n, n);
	gsl_linalg_LU_invert(tmpA, p, inverse);
	gsl_permutation_free(p);
	gsl_matrix_free(tmpA);
}


你可能感兴趣的:(Matrix,permutation)