411 REFERENCE · Wikibooks
Linear Algebra and the C Language/a0p3
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 RC3
/* ------------------------------------ */
int main(void)
{
double V1[RCA*C1] ={
+4,
+3,
-1
};
double V2[RCA*C1] ={
-1,
-1,
+2
};
double V3[RCA*C1] ={
-3,
-4,
+2
};
double **v1 = ca_A_mR(V1, i_mR(RCA,C1));
double **Nv1 = smul_mR(1./norm_R(v1),v1, i_mR(RCA,C1));
double **v2 = ca_A_mR(V2, i_mR(RCA,C1));
double **Nv2 = smul_mR(1./norm_R(v2),v2, i_mR(RCA,C1));
double **v3 = ca_A_mR(V3, i_mR(RCA,C1));
double **Nv3 = smul_mR(1./norm_R(v3),v3, i_mR(RCA,C1));
double **Nvn = i_mR(RCA,RCA);
clrscrn();
printf(" You can choose the values of:\n\n"
" v1: The first vector of the plan ");
P_mR(v1,S3,P0,C6);
printf(" Nv1 = (1/||v1||)v1");
p_mR(Nv1,S3,P12,C6);
printf(" v2: The second vector of the plan");
P_mR(v2,S3,P0,C6);
printf(" Nv2 = (1/||v2||)v2");
p_mR(Nv2,S3,P12,C6);
stop();
clrscrn();
printf(" v3: The vector for the projection");
P_mR(v3,S3,P0,C6);
printf(" Nv3 = (1/||v3||)v3");
p_mR(Nv3,S3,P12,C6);
printf("\n");
c_c_mR(Nv1,C1,Nvn,C1);
c_c_mR(Nv2,C1,Nvn,C2);
c_c_mR(Nv3,C1,Nvn,C3);
printf(" Nvn is the matrix of the eigenvectors of the matrix A. \n\n"
" Copy this code into the files c00b.c and c00c.c\n\n"
" Nv1 Nv2 Nv3:");
P_mR(Nvn,S3,P12,C6);
stop();
f_mR(v1);
f_mR(Nv1);
f_mR(v2);
f_mR(Nv2);
f_mR(v3);
f_mR(Nv3);
f_mR(Nvn);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
You choose the vectors of the plan (V1) and (V2) and the vector for the projection (V3). Next you normalize these vectors and you copy these vectors into the matrix (Nvn). You must copy this matrix, (Nvn), into the files c00b.c and c00c.c
Screen output example:
You can choose the values of:
v1: The first vector of the plan
+4,
+3,
-1
Nv1 = (1/||v1||)v1
+0.784464540553
+0.588348405415
-0.196116135138
v2: The second vector of the plan
-1,
-1,
+2
Nv2 = (1/||v2||)v2
-0.408248290464
-0.408248290464
+0.816496580928
Press return to continue.
v3: The vector for the projection
-3,
-4,
+2
Nv3 = (1/||v3||)v3
-0.557086014531
-0.742781352708
+0.371390676354
Nvn is the matrix of the eigenvectors of the matrix A.
Copy this code into the files c00b.c and c00c.c
Nv1 Nv2 Nv3:
+0.784464540553, -0.408248290464, -0.557086014531,
+0.588348405415, -0.408248290464, -0.742781352708,
-0.196116135138, +0.816496580928, +0.371390676354
Press return to continue.