Linear Algebra and the C Language/a05u
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
int main(void)
{
double u_T[R1*C3] = { 4, 2, 5};
double v_T[R1*C3] = { 3, 4, 1};
double **U_T = ca_A_mR(u_T, i_mR(R1,C3));
double **V_T = ca_A_mR(v_T, i_mR(R1,C3));
double **UxV_T = UxV_mR(U_T,V_T, i_mR(R1,C3));
double **U = transpose_mR(U_T, i_mR(R3, C1));
double **V = transpose_mR(V_T, i_mR(R3, C1));
double **UxV = transpose_mR(UxV_T, i_mR(R3, C1));
clrscrn();
printf(" u_t:");
p_mR(U_T, S4, P0, C6);
printf(" v_t:");
p_mR(V_T, S4, P0, C6);
printf(" uxv_t:");
p_mR(UxV_T, S4, P0, C6);
printf(" ||u x v||**2 == %+.4f\n"
" ||u||**2 ||v||**2 - (u.v)**2 == %+.4f\n\n",
pow(norm_R(UxV),2),
pow(norm_R(U),2) * pow(norm_R(V),2) - pow(dot_R(U,V),2) );
stop();
f_mR(U_T);
f_mR(V_T);
f_mR(UxV_T);
f_mR(U);
f_mR(V);
f_mR(UxV);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
||u x v||**2 == ||u||**2 ||v||**2 - (u.v)**2
Screen output example:
u_t :
+4 +2 +5
v_t :
+3 +4 +1
uxv_t :
-18 +11 +10
||u x v||**2 == +545.0000
||u||**2 ||v||**2 - (u.v)**2 == +545.0000
Press return to continue.