Gan_Matrix m33A; Gan_SquMatrix33 sm33S, sm33L; double dDetA, dDetS, dDetL; /* set up m33A, sm33S as symmetric and sm33L as lower triangular */ dDetA = gan_mat33_det_q(&m33A); /* macro computing det(A) */ dDetA = gan_mat33_det_s(&m33A); /* function computing det(A) */ dDetS = gan_symmat33_det_q(&sm33S); /* macro computing det(S) */ dDetS = gan_symmat33_det_s(&sm33S); /* function computing det(S) */ dDetL = gan_ltmat33_det_q(&sm33L); /* macro computing det(L) */ dDetL = gan_ltmat33_det_s(&sm33L); /* function computing det(L) */The routines to compute the trace of a square matrix are similar:
Gan_Matrix m33A; Gan_SquMatrix33 sm33S, sm33L; double dTraceA, dTraceS, dTraceL; /* set up m33A, sm33S as symmetric and sm33L as lower triangular */ dTraceA = gan_mat33_trace_q(&m33A); /* macro computing trace(A) */ dTraceA = gan_mat33_trace_s(&m33A); /* function computing trace(A) */ dTraceS = gan_symmat33_trace_q(&sm33S); /* macro computing trace(S) */ dTraceS = gan_symmat33_trace_s(&sm33S); /* function computing trace(S) */ dTraceL = gan_ltmat33_trace_q(&sm33L); /* macro computing trace(L) */ dTraceL = gan_ltmat33_trace_s(&sm33L); /* function computing trace(L) */For all types of fixed size matrix there are also routines to compute the sum of squares of the matrix elements, as well as the Frobenius norm, which is the square-root of the sum of squares. For matrices the routines are
Gan_Matrix34 m34A; double dSumSA, dFNormA; /* ... set up m34A using e.g. gan_mat34_fill_q() ... */ dSumSA = gan_mat34_sumsqr_q(&m34A); /* macro computing sum(A_ij^2) */ dSumSA = gan_mat34_sumsqr_s(&m34A); /* function computing sum(A_ij^2) */ dFNormA = gan_mat34_Fnorm_q(&m34A); /* macro computing sqrt(sum(A_ij^2)) */ dFNormA = gan_mat34_Fnorm_s(&m34A); /* function computing sqrt(sum(A_ij^2)) */There are equivalent routines for other types of matrix.