Linear Algebra and the C Language/a0fm
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00c.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **X_rupper_mR(
double **A,
int n
)
{
int r;
int c;
isquare_mR(A,"rupper_mR;","(A)");
m0_mR(A);
for (r=R1; r<A[R_SIZE][C0]; r++)
for (c=C1; c<A[C_SIZE][C0]; c++)
if(c>=r) A[r][c] = r_I(n);
return(A);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int rc)
{
double **A = rupper_mR(i_mR(rc,rc),9);
clrscrn();
printf(" rupper_mR(): Upper triangular matrix \n\n"
" A[R%d,C%d] :",rsize_R(A),csize_R(A));
p_mR(A,S4,P0,C8);
f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
fun(rp_I(RC8));
while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Upper triangular matrix:
Screen output example:
rupper_mR(): Upper triangular matrix
A[R3,C3] :
-3 -3 -7
+0 +6 +5
+0 +0 -8
Press return to continue
Press X return to stop