Linear Algebra and the C Language/a00u


Install this file in your working directory.

/* ------------------------------------ */
/*  Save as :   vpoctave.h              */
/* ------------------------------------ */ 
void p_Octave_mR(
double  **A,
char name[],
int      Pn
)
{
 int r;
 int c;

 printf(" %s=[\n",name);

 for(r=R1; r<A[R_SIZE][C0];    r++)
  {
   for (c=C1; c<A[C_SIZE][C0]; c++)
     printf("%+.*f,",Pn,A[r][c]);

   if((r+1)<A[R_SIZE][C0]) printf("\b;\n");
   else                    printf("\b]\n\n");
  }
}
/* ------------------------------------ */   
/* ------------------------------------ */ 
/* ------------------------------------ */ 
void pE_Octave_mR(
double  **A,
char name[],
int      Pn
)
{
 int r;
 int c;

 printf(" %s=[\n",name);

 for(r=R1; r<A[R_SIZE][C0];    r++)
  {
   for (c=C1; c<A[C_SIZE][C0]; c++)
     printf("%+.*e,",Pn,A[r][c]);

   if((r+1)<A[R_SIZE][C0]) printf("\b;\n");
   else                    printf("\b]\n\n");
  }
}
/* ------------------------------------ */
/* ------------------------------------ */ 
void pAi_Octave_mR(
double  **A,
char name[],
int       i,
int       Pn
)
{
 int r;
 int c;

 printf(" %s%d=[\n",name,i);

 for(r=R1; r<A[R_SIZE][C0];    r++)
  {
   for (c=C1; c<A[C_SIZE][C0]; c++)
     printf("%+.*f,",Pn,A[r][c]);

   if((r+1)<A[R_SIZE][C0]) printf("\b;\n");
   else                    printf("\b]\n\n");
  }
}
/* ------------------------------------ */
/* ------------------------------------ */ 
void pEAi_Octave_mR(
double  **A,
char name[],
int       i,
int       Pn
)
{
 int r;
 int c;

 printf(" %s%d=[\n",name,i);

 for(r=R1; r<A[R_SIZE][C0];    r++)
  {
   for (c=C1; c<A[C_SIZE][C0]; c++)
     printf("%+.*e,",Pn,A[r][c]);

   if((r+1)<A[R_SIZE][C0]) printf("\b;\n");
   else                    printf("\b]\n\n");
  }
}
/* ------------------------------------ */   
/* ------------------------------------ */

The pAi_Octave_mR(); function allows you to introduce an index (0,1,...) when working with matrix arrays.