411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0oy
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
__NOTOC__
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA RC2
/* ------------------------------------ */
int main(void)
{
double L[RCA*C1] ={
+4,
-1
};
double V[RCA*C1] ={
-1,
+2
};
double **l = ca_A_mR(L, i_mR(RCA,C1));
double **Nl = smul_mR(1./norm_R(l),l, i_mR(RCA,C1));
double **v = ca_A_mR(V, i_mR(RCA,C1));
double **Nv = smul_mR(1./norm_R(v),v, i_mR(RCA,C1));
double **Nlv = i_mR(RCA,RCA);
clrscrn();
printf(" l: The vector of the line");
P_mR(l,S3,P0,C6);
printf(" Nl = (1/||l||)l");
p_mR(Nl,S3,P12,C6);
printf(" v: The vector for the projection");
P_mR(v,S3,P0,C6);
printf(" Nv = (1/||v||)v");
p_mR(Nv,S3,P12,C6);
printf("\n");
c_c_mR(Nl,C1,Nlv,C1);
c_c_mR(Nv,C1,Nlv,C2);
printf(" Nlv: Copy this matrix into the files c00b.c and c00c.c\n");
P_mR(Nlv,S3,P12,C6);
stop();
f_mR(l);
f_mR(Nl);
f_mR(v);
f_mR(Nv);
f_mR(Nlv);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
You choose the vector of the line (L) and the vector for the projection (V). Next you normalize these vectors and you copy these vectors into the matrix (Nlv). You must copy this matrix, (Nlv), into the files c00b.c and c00c.c
Screen output example:
l: The vector of the line
+4,
-1
Nl = (1/||l||)l
+0.970142500145
-0.242535625036
v: The vector for the projection
-1,
+2
Nv = (1/||v||)v
-0.447213595500
+0.894427191000
Nlv: Copy this matrix into the files c00b.c and c00c.c
+0.970142500145, -0.447213595500,
-0.242535625036, +0.894427191000
Press return to continue.