Linear Algebra and the C Language/a0gr
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00d.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = rsymmetric_mR( i_mR(r,r),9.);
double **EigsValue = eigs_mR(A, i_mR(r,C1));
clrscrn();
printf(" Copy/Paste into the octave windows \n\n");
p_Octave_mR(A,"a",P0);
printf(" eigs (a,%d)\n",r);
printf(" rank (a)\n\n");
printf(" EigsValue:");
p_mR(EigsValue, S10,P4,C6);
f_mR(A);
f_mR(EigsValue);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R3)+R2);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
The rank of a symmetric matrix is equal to the number of non-zero eigenvalues.
Screen output example:
Copy/Paste into the octave windows
a=[
-5,-8,-8,-5;
-8,-2,+4,-1;
-8,+4,-2,+4;
-5,-1,+4,+7]
eigs (a,4)
rank (a)
EigsValue:
+13.9555
-13.7618
-6.9042
+4.7105
Press return to continue
Press X return to stop