#define M 3 #define N 3 int main() { /* singular matrix rank(a) == 1 */ array double a[M][N] = {1, 2, 3, 1, 2, 3, 2, 4, 6}; int r = rank(a); array double orth[M][r]; orthonormalbase(a, orth); printf("rank(a) = %d\n", r); printf("orth from orthonormalbase(a, orth) = \n%f\n", orth); printf("transpose(orth)*orth = \n%f\n", transpose(orth)*orth); }
rank(a) = 1 orth from orthonormalbase(a, orth) = -0.408248 -0.408248 -0.816497 transpose(orth)*orth = 1.000000