Linear Algebra and the C Language/a00r
Install this file in your working directory.
/* ------------------------------------ */
/* Save as : vpm.h */
/* ------------------------------------ */
double **p_mR(
double **A, // R3xC8
int er,
int dr,
int n_cMAX // C3
)
{
int r;
int c;
int c_LAST;
int c_FIRST;
int THE_LAST_c_TO_WRITE = C1;
// C1 < C9
while(THE_LAST_c_TO_WRITE < A[C_SIZE][C0])
{
c_FIRST = THE_LAST_c_TO_WRITE; //C1
THE_LAST_c_TO_WRITE += n_cMAX; //C1+C3=C4
// C4 < C9
if(THE_LAST_c_TO_WRITE < A[C_SIZE][C0])
c_LAST = THE_LAST_c_TO_WRITE; //C4
else // C9
c_LAST = A[C_SIZE][C0];
// R1<R4
for(r=R1; r<A[R_SIZE][C0]; r++)
{
printf("\n");
// C1<C9
for (c=c_FIRST; c<c_LAST; c++)
// Rr Rc
printf("%+*.*f ",er,dr,A[r][c]);
}
printf("\n");
}
printf("\n");
return(A);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **pE_mR(
double **A, // R3xC8
int er,
int dr,
int n_cMAX // C3
)
{
int r;
int c;
int c_LAST;
int c_FIRST;
int THE_LAST_c_TO_WRITE = C1;
// C1 < C9
while(THE_LAST_c_TO_WRITE < A[C_SIZE][C0])
{
c_FIRST = THE_LAST_c_TO_WRITE; //C1
THE_LAST_c_TO_WRITE += n_cMAX; //C1+C3=C4
// C4 < C9
if(THE_LAST_c_TO_WRITE < A[C_SIZE][C0])
c_LAST = THE_LAST_c_TO_WRITE; //C4
else // C9
c_LAST = A[C_SIZE][C0];
// R1<R4
for(r=R1; r<A[R_SIZE][C0]; r++)
{
printf("\n");
// C1<C9
for (c=c_FIRST; c<c_LAST; c++)
// Rr Rc
printf("%+*.*e ",er,dr,A[r][c]);
}
printf("\n");
}
printf("\n");
return(A);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **P_mR(
double **A, // R3xC8
int er,
int dr,
int n_cMAX // C3
)
{
int r;
int c;
int c_LAST;
int c_FIRST;
int THE_LAST_c_TO_WRITE = C1;
// C1 < C9
while(THE_LAST_c_TO_WRITE < A[C_SIZE][C0])
{
c_FIRST = THE_LAST_c_TO_WRITE; //C1
THE_LAST_c_TO_WRITE += n_cMAX; //C1+C3=C4
// C4 < C9
if(THE_LAST_c_TO_WRITE < A[C_SIZE][C0])
c_LAST = THE_LAST_c_TO_WRITE; //C4
else // C9
c_LAST = A[C_SIZE][C0];
// R1<R4
for(r=R1; r<A[R_SIZE][C0]; r++)
{
printf("\n");
// C1<C9
for (c=c_FIRST; c<c_LAST; c++)
// Rr Rc
printf("%+*.*f, ",er,dr,A[r][c]);
}
printf("\b\b \n");
}
printf("\n");
return(A);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **PE_mR(
double **A, // R3xC8
int er,
int dr,
int n_cMAX // C3
)
{
int r;
int c;
int c_LAST;
int c_FIRST;
int THE_LAST_c_TO_WRITE = C1;
// C1 < C9
while(THE_LAST_c_TO_WRITE < A[C_SIZE][C0])
{
c_FIRST = THE_LAST_c_TO_WRITE; //C1
THE_LAST_c_TO_WRITE += n_cMAX; //C1+C3=C4
// C4 < C9
if(THE_LAST_c_TO_WRITE < A[C_SIZE][C0])
c_LAST = THE_LAST_c_TO_WRITE; //C4
else // C9
c_LAST = A[C_SIZE][C0];
// R1<R4
for(r=R1; r<A[R_SIZE][C0]; r++)
{
printf("\n");
// C1<C9
for (c=c_FIRST; c<c_LAST; c++)
// Rr Rc
printf("%+*.*e, ",er,dr,A[r][c]);
}
printf("\b\b \n");
}
printf("\n");
return(A);
}
/* ------------------------------------ */
/* ------------------------------------ */
P_mR(); and PE_mR(); add a comma separating the numbers, instead of a single space, to make it easy to reintroduce a matrix into a C file.