Linear Algebra and the C Language/a0ja
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **X_c_D_UC1_mR(
double **D,
double **U
)
{
int r;
int c;
for ( r=R1; r<D[R_SIZE][C0]; r++)
for ( c=C1; c<D[C_SIZE][C0]; c++)
if(r==c)
U[r][C1] = D[r][c];
return(U);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int rc)
{
double **A = rdiag_mR( i_mR(rc,rc),99);
double **AC1 = c_D_UC1_mR(A, i_mR(rc,C1));
clrscrn();
printf(" A[R%d,C%d]:",rsize_R(A),csize_R(A));
p_mR(A, S4,P0,C8);
printf(" AC1[R%d,C%d]:",rsize_R(AC1),csize_R(AC1));
p_mR(AC1, S4,P0,C8);
f_mR(A);
f_mR(AC1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
fun(RC5);
while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Copy a diagonal matrix into a one-column matrix.
Screen output example:
A[R5,C5]:
-3 +0 +0 +0 +0
+0 +48 +0 +0 +0
+0 +0 -44 +0 +0
+0 +0 +0 +63 +0
+0 +0 +0 +0 +44
AC1[R5,C1]:
-3
+48
-44
+63
+44
Press return to continue
Press X return to stop