www.pudn.com > gauss_xxx.rar > gaussmain.cpp
// gauss.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include#include "math.h" bool matrix_reverse(double *m, int n, double *r); void matrix_multiply(double *m1, double *m2, int n, double *r); bool matrix_isIdentity(double *m, int n); bool test(double *m, int n, double *r) { double v; for( int i=0; i 1e-8 )return false; if( i!=j && fabs(v)>1e-8 )return false; } } return true; } int main(int argc, char* argv[]) { double m[16]={21,31,51,61,71,91,33,25,12,17,35,12,10,50,90,11}; double r[16]; double r2[16]; if( !matrix_reverse(m,4,r) ) { printf("BAD!\n"); return 1; } matrix_multiply(m,r,4,r2); if( matrix_isIdentity(r2,4) ) printf("OK!\n"); if( test(m,4,r) )printf("OK!\n"); else printf("NO!\n"); return 0; }