Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Linear Algebra and the C Language/a00s

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

__NOTOC__ Install this file in your working directory. /* ------------------------------------ */ /* Save as : vpfm.h */ /* ------------------------------------ */ double **fp_mR( double **A, char FileName[], char MatrixName[], int er, int dr, int n ) { FILE * fp = fopen(FileName,"a"); int r; int c; int n_c = C1; int n_c_LAST; int n_c_FIRST; fprintf(fp,"%s",MatrixName); while(n_c<A[C_SIZE][C0]) { n_c+=n; n_c_FIRST = n_c-n; if(n_c<A[C_SIZE][C0])n_c_LAST = n_c; else n_c_LAST = A[C_SIZE][C0]; for(r=R1; r<A[R_SIZE][C0]; r++) { fprintf(fp,"\n"); for (c=n_c_FIRST; c<n_c_LAST; c++) fprintf(fp,"%+*.*f ",er,dr,A[r][c]); } fprintf(fp,"\n"); } fprintf(fp,"\n\n"); fclose(fp); return(A); } /* ------------------------------------ */ double **fpE_mR( double **A, char FileName[], char MatrixName[], int er, int dr, int n ) { FILE * fp = fopen(FileName,"a"); int r; int c; int n_c = C1; int n_c_LAST; int n_c_FIRST; fprintf(fp,"%s",MatrixName); while(n_c<A[C_SIZE][C0]) { n_c+=n; n_c_FIRST = n_c-n; if(n_c<A[C_SIZE][C0])n_c_LAST = n_c; else n_c_LAST = A[C_SIZE][C0]; for(r=R1; r<A[R_SIZE][C0]; r++) { fprintf(fp,"\n"); for (c=n_c_FIRST; c<n_c_LAST; c++) fprintf(fp,"%+*.*e ",er,dr,A[r][c]); } fprintf(fp,"\n"); } fprintf(fp,"\n\n"); fclose(fp); return(A); } /* ------------------------------------ */ /* ------------------------------------ */ /* ------------------------------------ */ double **fP_mR( double **A, char FileName[], char MatrixName[], int er, int dr, int n ) { FILE * fp = fopen(FileName,"a"); int r; int c; int n_c = C1; int n_c_LAST; int n_c_FIRST; fprintf(fp,"%s",MatrixName); while(n_c<A[C_SIZE][C0]) { n_c+=n; n_c_FIRST = n_c-n; if(n_c<A[C_SIZE][C0])n_c_LAST = n_c; else n_c_LAST = A[C_SIZE][C0]; for(r=R1; r<A[R_SIZE][C0]; r++) { fprintf(fp,"\n"); for (c=n_c_FIRST; c<n_c_LAST; c++) fprintf(fp,"%+*.*f, ",er,dr,A[r][c]); } fprintf(fp,"\n"); } fprintf(fp,"\n\n"); fclose(fp); return(A); } /* ------------------------------------ */ double **fPE_mR( double **A, char FileName[], char MatrixName[], int er, int dr, int n ) { FILE * fp = fopen(FileName,"a"); int r; int c; int n_c = C1; int n_c_LAST; int n_c_FIRST; fprintf(fp,"%s",MatrixName); while(n_c<A[C_SIZE][C0]) { n_c+=n; n_c_FIRST = n_c-n; if(n_c<A[C_SIZE][C0])n_c_LAST = n_c; else n_c_LAST = A[C_SIZE][C0]; for(r=R1; r<A[R_SIZE][C0]; r++) { fprintf(fp,"\n"); for (c=n_c_FIRST; c<n_c_LAST; c++) fprintf(fp,"%+*.*e, ",er,dr,A[r][c]); } fprintf(fp,"\n"); } fprintf(fp,"\n\n"); fclose(fp); return(A); } /* ------------------------------------ */ /* ------------------------------------ */ fP_mR(); and fPE_mR(); add a comma separating the numbers, instead of a single space, to make it easy to reintroduce a matrix into a C file.