#define M 3 #define N 3 int main() { /* singular matrix rank(a) == 2 */ array double a[M][N] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; 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) = 2 orth from orthonormalbase(a, orth) = -0.214837 0.887231 -0.520587 0.249644 -0.826338 -0.387943 transpose(orth)*orth = 1.000000 -0.000000 -0.000000 1.000000