// To compute the determinant of a k by k matrix where A[i, j] // is located at b + i*s + j. // k > 0 // the matrix is corrupted. typedef double R; R det(R * b, int k, int s){ if(k==1) return *b; for(int j=0; j #include int c = 0; void tst(int n, R m[n][n], R a) { R b = det(&(m[0][0]), n, n); if(fabs(a-b)> 1e-12) printf("fail %d %e\n", c, b); ++c;} int main(){ {R a[][2] = {{0, 0}, {0, 0}}; tst(2, a, 0);} {R a[][2] = {{0, 0}, {1, 0}}; tst(2, a, 0);} {R a[][2] = {{0, 1}, {1, 0}}; tst(2, a, -1);} {R a[][2] = {{0, 1}, {0, 2}}; tst(2, a, 0);} {R a[][3] = {{1, 3, -2}, {3, -4, 2}, {2, 3, -4}}; tst(3, a, 24);}} #endif