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

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

__NOTOC__ Install and compile these files in your working directory. thumb|Reflection about the x-axis /* ------------------------------------ */ /* Save as : c001.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ 1, 0, 0, -1 }; double u[R2*C5] ={ 1, 2, 2, 1, 1, 1, 1, 2, 2, 1 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Reflection about the x-axis : \n"); printf("\n | 1 0 | "); printf("\n v = | | u "); printf("\n | 0 -1 | \n\n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P0,C6); G_points2D_mR(i_WGnuplot(-3,3,-3,3), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Reflection about the y-axis /* ------------------------------------ */ /* Save as : c002.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ -1, 0, 0, 1 }; double u[R2*C5] ={ 1, 2, 2, 1, 1, 1, 1, 2, 2, 1 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Reflection about the y-axis : \n"); printf("\n | -1 0 | "); printf("\n v = | | u "); printf("\n | 0 1 | \n\n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P0,C6); G_points2D_mR(i_WGnuplot(-3,3,-3,3), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Reflection about the line y = x /* ------------------------------------ */ /* Save as : c003.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ 0, 1, 1, 0 }; double u[R2*C5] ={ 1, 1, -1, -1, 1, 2, 3, 3, 2, 2 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Reflection about the line y = x : \n"); printf("\n | 0 1 | "); printf("\n v = | | u "); printf("\n | 1 0 | \n\n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P0,C6); G_points2D_mR(i_WGnuplot(-5,5,-5,5), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Orthogonal projection on the x-axis /* ------------------------------------ */ /* Save as : c004.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ 1, 0, 0, 0 }; double u[R2*C5] ={ 1, 2, 2, 1, 1, 1, 1, 2, 2, 1 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Orthogonal projection on the x-axis : \n"); printf("\n | 1 0 | "); printf("\n v = | | u "); printf("\n | 0 0 | \n\n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P0,C6); G_points2D_mR(i_WGnuplot(-.5,2.5,-.5,2.5), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Orthogonal projection on the y-axis /* ------------------------------------ */ /* Save as : c005.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ 0, 0, 0, 1 }; double u[R2*C5] ={ 1, 2, 2, 1, 1, 1, 1, 2, 2, 1 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Orthogonal projection on the y-axis : \n"); printf("\n | 0 0 | "); printf("\n v = | | u "); printf("\n | 0 1 | \n\n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P0,C6); G_points2D_mR(i_WGnuplot(-1,3,-1,3), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Dilatation /* ------------------------------------ */ /* Save as : c006.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ 2, 0, 0, 2 }; double u[R2*C5] ={ 0, 1, 1, 0, 0, 0, 0, 1, 1, 0 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Dilation : \n"); printf("\n | 2 0 | "); printf("\n v = | | u "); printf("\n | 0 2 | \n\n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P0,C6); G_points2D_mR(i_WGnuplot(-1,3,-1,3), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Contraction /* ------------------------------------ */ /* Save as : c007.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ .5, 0, 0, .5 }; double u[R2*C5] ={ 0, 1, 1, 0, 0, 0, 0, 1, 1, 0 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Contraction : \n"); printf("\n | .5 0 | "); printf("\n v = | | u "); printf("\n | 0 .5 | \n\n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P3,C6); G_points2D_mR(i_WGnuplot(-.5,1.5,-.5,1.5), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Shear in the x-direction with factor k (right) /* ------------------------------------ */ /* Save as : c008.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ 1, 2, 0, 1 }; double u[R2*C5] ={ 0, 1, 1, 0, 0, 0, 0, 1, 1, 0 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Shear in the x-direction with factor k (right):\n"); printf("\n | 1 2 | "); printf("\n v = | | u "); printf("\n | 0 1 | \n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P3,C6); G_points2D_mR(i_WGnuplot(-.5,3.5,-.5,3.5), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Shear in the x-direction with factor k (left) /* ------------------------------------ */ /* Save as : c0009.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ 1, -2, 0, 1 }; double u[R2*C5] ={ 0, 1, 1, 0, 0, 0, 0, 1, 1, 0 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Shear in the x-direction with factor k (left) :\n"); printf("\n | 1 -2 | "); printf("\n v[n] = | | u[n] "); printf("\n | 0 1 | \n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P3,C6); G_points2D_mR(i_WGnuplot(-2.5,1.5,-1.5,2.5), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Shear in the y-direction with factor k (up) /* ------------------------------------ */ /* Save as : c010.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ 1, 0, 2, 1 }; double u[R2*C5] ={ 0, 1, 1, 0, 0, 0, 0, 1, 1, 0 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Shear in the y-direction with factor k (up) : \n"); printf("\n | 1 0 | "); printf("\n v = | | u "); printf("\n | 2 1 | \n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P3,C6); G_points2D_mR(i_WGnuplot(-.5,3.4,-.5,3.5), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Shear in the x-direction with factor k (down) /* ------------------------------------ */ /* Save as : c011.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ int main(void) { double t[R2*C2] ={ 1, 0, -2, 1 }; double u[R2*C5] ={ 0, 1, 1, 0, 0, 0, 0, 1, 1, 0 }; double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = ca_A_mR(t,i_mR(R2,C2)); double **V = i_mR(R2,C5); clrscrn(); printf("\n Shear in the x-direction with factor k (down): \n"); printf("\n | 1 0 | "); printf("\n v = | | u "); printf("\n | -2 1 | \n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P3,C6); G_points2D_mR(i_WGnuplot(-2,2,-2.5,1.5), U,V); f_mR(U); f_mR(V); f_mR(T); stop(); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ thumb|Rotation /* ------------------------------------ */ /* Save as : c012.c */ /* ------------------------------------ */ #include "v_a.h" #include "dstrct.h" #include "dg_uv.h" /* ------------------------------------ */ void fun(void) { double u[R2*C5] ={ 0, 1, 1, 0, 0, 0, 0, 1, 1, 0 }; double alpha = rp_I(360); double **U = ca_A_mR(u,i_mR(R2,C5)); double **T = rot2D_mR( i_mR(R2,C2),PI/180.*alpha); double **V = i_mR(R2,C5); clrscrn(); printf("\n Rotation (%.f degree) : \n",alpha); printf("\n | cos(alpha) -sin(alpha) | "); printf("\n v = | | u "); printf("\n | sin(alpha) cos(alpha) | \n"); printf(" U: "); p_mR(U,S5,P0,C6); mul_mR(T,U,V); printf(" V: "); p_mR(V,S5,P3,C6); G_points2D_mR(i_WGnuplot(-2,2,-2,2), U,V); f_mR(U); f_mR(V); f_mR(T); } /* ------------------------------------ */ int main(void) { do { fun(); fflush(stdout); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */