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

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 : vbm.h */ /* ------------------------------------ */ /* ------------------------------------ */ double **add_mR( double **A, double **B, double **AplsB ) { int r; int c; dif_sizes_mR(A,B, "add_mR();","(A or B)"); dif_sizes_mR(A,AplsB,"add_mR();","(AplsB)"); for ( r=R1; r<A[R_SIZE][C0]; r++) for ( c=C1; c<A[C_SIZE][C0]; c++) AplsB[r][c] = A[r][c] + B[r][c]; return(AplsB); } /* ------------------------------------ */ double **sub_mR( double **A, double **B, double **AmnsB ) { int r; int c; dif_sizes_mR(A,B, "sub_mR();","(A or B)"); dif_sizes_mR(A,AmnsB,"sub_mR();","(AmnsB)"); for ( r=R1; r<A[R_SIZE][C0]; r++) for ( c=C1; c<A[C_SIZE][C0]; c++) AmnsB[r][c] = A[r][c] - (B[r][c]); return(AmnsB); } /* ------------------------------------ */ /* ------------------------------------ */ double **mul_mR( double **A, double **B, double **AB ) { int i; int j; int k; canImul_mR(A,B,AB,"mul_mR();","(A or B or AB)"); for(k=R1; k<A[R_SIZE][C0]; k++) /* Work on the rows k */ for(j=C1; j<B[C_SIZE][C0]; j++) /* Work on the cols j */ { AB[k][j] = 0; for(i=C1; i<A[C_SIZE][C0]; i++) /* Compute AB(k,j) */ AB[k][j] += A[k][i] * B[i][j]; } return(AB); } /* ------------------------------------ */ /* ------------------------------------ */ double **smul_mR( double s, double **A, double **sA ) { int r; int c; dif_sizes_mR(A,sA,"smul_mR();","(A or sA)"); for ( r=R1; r<A[R_SIZE][C0]; r++) for ( c=C1; c<A[C_SIZE][C0]; c++) sA[r][c] = s * A[r][c]; return(sA); } /* ------------------------------------ */ double **smul_c1_mR( double s, int c1, double **A ) { int r; for(r=R1; r<A[R_SIZE][C0]; r++) A[r][c1] = s * A[r][c1]; return(A); } /* ------------------------------------ */ /* ------------------------------------ */ double **pow_mR( int n, double **A, double **A_n ) { int i; double **T = i_RC_mR(A[R_SIZE][C0],A[C_SIZE][C0]); isquare_mR(A, "pow_mR();","(A)"); dif_sizes_mR(A,A_n,"pow_mR();","(A or A_n)"); c_mR(A,A_n); if(!n) eye_mR(A_n); else for(i = n ; --i ; ) { mul_mR(A_n,A,T); c_mR(T,A_n); } f_mR(T); return(A_n); } /* ------------------------------------ */ /* ------------------------------------ */