Linear Algebra and the C Language/a0dv
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RA R3
#define CA C6
/* ------------------------------------ */
int main(void)
{
double a[RA*CA]={
-4.00,+9.00,-1.00,-9.00,-6.00,-3.00,
-4.00,+7.00,-4.00,+9.00,+9.00,+6.00,
-7.00,+2.00,+5.00,+4.00,-2.00,-9.00
};
double **A = ca_A_mR(a, i_mR(RA,CA));
double **A_T = transpose_mR(A, i_mR(CA,RA));
double **S = svds_mR(A_T, i_mR(RA,C1));
double **U = svd_U_Cn_mR(A, i_mR(RA,RA));
double **V = svd_V_Cn_mR(A, i_mR(CA,CA));
clrscrn();
printf(" Copy/Paste into the octave windows \n\n\n");
p_Octave_mR(A,"A",P2);
printf(" [U, S, V] =svd (A,10)\n\n\n");
stop();
clrscrn();
printf(" U :");
p_mR(U,S5,P5,C10);
printf(" S :");
p_mR(S,S5,P5,C10);
printf(" V:");
p_mR(V,S5,P5,C10);
stop();
f_mR(A);
f_mR(A_T);
f_mR(S);
f_mR(U);
f_mR(V);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
Copy/Paste into the octave windows
A=[
-4.00,+9.00,-1.00,-9.00,-6.00,-3.00;
-4.00,+7.00,-4.00,+9.00,+9.00,+6.00;
-7.00,+2.00,+5.00,+4.00,-2.00,-9.00]
[U, S, V] =svd (A,10)
Press return to continue.
U :
-0.58163 +0.50652 -0.63651
+0.77927 +0.57139 -0.25738
-0.23333 +0.64572 +0.72705
S :
+18.31497
+14.18190
+12.05967
V:
+0.04601 -0.62274 +0.12553 +0.00000 +0.76495 +0.00000
-0.01345 +0.69454 +0.50384 +0.17733 +0.45480 -0.07301
-0.20214 +0.03078 -0.43959 +0.85555 -0.00000 -0.00000
+0.61779 +0.22329 -0.52409 -0.07778 +0.24339 -0.46523
+0.59896 +0.05725 -0.00402 +0.00000 +0.00000 +0.78731
+0.46522 -0.27519 +0.51231 +0.48014 -0.38572 -0.39795
Press return to continue.