int main() { array double complex v[3] = {1,2,3}; int n = 3, k; array double complex a[n][n]; a = cdiagonalmatrix(v); printf("cdiagonal matrix a =\n%f\n", a); k = 0; a = cdiagonalmatrix(v,k); printf("cdiagonalmatrix(a, 0) =\n%f\n", a); k = 1; array double a2[n+abs(k)][n+abs(k)]; a2 = cdiagonalmatrix(v,k); printf("cdiagonalmatrix(a2, 1) =\n%f\n", a2); k = -1; array double a3[n+abs(k)][n+abs(k)]; a3 = cdiagonalmatrix(v,k); printf("cdiagonalmatrix(a3, -1) =\n%f\n", a3); }
cdiagonal matrix a = complex(1.000000,0.000000) complex(0.000000,0.000000) complex(0.000000,0.000000) complex(0.000000,0.000000) complex(2.000000,0.000000) complex(0.000000,0.000000) complex(0.000000,0.000000) complex(0.000000,0.000000) complex(3.000000,0.000000) cdiagonalmatrix(a, 0) = complex(1.000000,0.000000) complex(0.000000,0.000000) complex(0.000000,0.000000) complex(0.000000,0.000000) complex(2.000000,0.000000) complex(0.000000,0.000000) complex(0.000000,0.000000) complex(0.000000,0.000000) complex(3.000000,0.000000) cdiagonalmatrix(a2, 1) = 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 2.000000 0.000000 0.000000 0.000000 0.000000 3.000000 0.000000 0.000000 0.000000 0.000000 cdiagonalmatrix(a3, -1) = 0.000000 0.000000 0.000000 0.000000 1.000000 0.000000 0.000000 0.000000 0.000000 2.000000 0.000000 0.000000 0.000000 0.000000 3.000000 0.000000