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/a013

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 : vc_m.h */ /* ------------------------------------ */ /* ------------------------------------ */ double ** c_mR( double **A, double **B ) { int r; int c; for (r=R1; r<A[R_SIZE][C0]; r++) for (c=C1; c<A[C_SIZE][C0]; c++) B[r][c] = A[r][c]; return(B); } /* ------------------------------------ */ /* ------------------------------------ */ double **ca_A_mR( double a[], double **A ) { int r; int c; int i=0; for (r=R1; r<A[R_SIZE][C0]; r++) for (c=C1; c<A[C_SIZE][C0]; c++) A[r][c] = a[i++]; return(A); } /* ------------------------------------ */ /* ------------------------------------ */ double **c_c_mR( double **A, int cA, double **B, int cB ) { int r; for(r=R1; r<A[R_SIZE][C0]; r++) B[r][cB] = A[r][cA]; return(B); } /* ------------------------------------ */ double **c_r_mR( double **A, int rA, double **B, int rB ) { int c; for(c=C1; c<A[C_SIZE][C0]; c++) B[rB][c] = A[rA][c]; return(B); } /* ------------------------------------ */ /* Copy the column cA of A into the row rB of B */ /* ------------------------------------ */ double **c_c_r_mR( double **A, int cA, double **B, int rB ) { int rc; for(rc=RC1; rc<A[R_SIZE][C0]; rc++) B[rB][rc] = A[rc][cA]; return(B); } /* ------------------------------------ */ /* Copy the row Ra of A into the column CB of B */ /* ------------------------------------ */ double **c_r_c_mR( double **A, int rA, double **B, int cB ) { int rc; for(rc=RC1; rc<A[R_SIZE][C0]; rc++) B[rc][cB] = A[rA][rc]; return(B); } /* ------------------------------------ */ /* ------------------------------------ */ double **c_c_D_mR( double **AC, double **AD ) { int r; m0_mR(AD); for(r=R1; r<AC[R_SIZE][C0]; r++) AD[r][r] = AC[r][C1]; return(AD); } /* ------------------------------------ */ double **c_D_c_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); } /* ------------------------------------ */ /* ------------------------------------ */ double **c_s_mR( double s, double **A, int r, int c ) { int Rmax = (A[R_SIZE][C0]-R1); int Cmax = (A[C_SIZE][C0]-C1); if( r<R1 || c<C1 || r> Rmax|| c> Cmax) { printf("\n Error : c_coef_R(); \n\n"); printf("\n R = %d; C = %d; \n",r,c); printf("\n R and C must be : \n"); printf("\n R>=1; C>=1;\n R=<%d; C=<%d;\n", Rmax, Cmax); printf("\n Press return to continue. \n"); fflush(stdout); getchar(); exit(EXIT_FAILURE); } A[r][c] = s; return(A); } /* ------------------------------------ */ /* ------------------------------------ */ double **c_r_reverse_order_mR( double **U, double **V ) { int c; for(c=C1; c<U[C_SIZE][C0]; c++) V[R1][csize_R(V)+C1-c] = U[R1][c]; return(V); } /* ------------------------------------ */ /* ------------------------------------ */ double **c_rU_rA_cn_mR( double **U, int rU, double **A, int rA, int cn ) { int c; for(c=C1; cn<A[C_SIZE][C0]; c++,cn++) A[rA][cn] = U[rU][c]; return(A); } /* ------------------------------------ */ /* ------------------------------------ */ double **c_cV_cA_rn_mR( double **V, int cV, double **A, int cA, int rn ) { int r; for(r=R1; rn<A[R_SIZE][C0]; r++,rn++) A[rn][cA] = V[r][cV]; return(A); } /* ------------------------------------ */ /* ------------------------------------ */ double **c_Uc_r_mR( double **U, int Uc, double **A, int rA ) { int c; for(c=C1; Uc<U[C_SIZE][C0]-C1; c++,Uc++) A[rA][c] = U[R1][Uc]; return(A); } /* ------------------------------------ */ /* ------------------------------------ */ c_mR(); copies matrix A into matrix B. It does not check the size of the matrices. Having this option in place has been a great help to me. ca_A_mR(); copies an array of numbers into a matrix. c_c_mR(); copies a column of A into a column of B. c_r_mR(); copies a row from A into a row from B. c_c_r_mR(); copies a column of A into a row of B.