From 9c574dbc25126c00e1dce319629c8fe2cbb21454 Mon Sep 17 00:00:00 2001 From: GuyPozner Date: Tue, 24 Jul 2018 10:48:27 +0300 Subject: [PATCH 1/3] garbage --- chapters/FFT/res/FT_example.png | Bin 107199 -> 107196 bytes chapters/FFT/res/butterfly_diagram.png | Bin 75578 -> 75576 bytes chapters/FFT/res/fft.png | Bin 5034 -> 5033 bytes chapters/FFT/res/radix-2screen.jpg | Bin 51991 -> 51983 bytes chapters/FFT/res/radix-2screen_positive.jpg | Bin 51776 -> 51769 bytes chapters/FFT/res/radix-8screen.jpg | Bin 251044 -> 251037 bytes chapters/FFT/res/sinusoid.png | Bin 7862 -> 7861 bytes .../huffman/res/huffman_tree.png | Bin 238590 -> 238588 bytes .../euler/res/error.png | Bin 8736 -> 8735 bytes .../euler/res/instability.png | Bin 10680 -> 10679 bytes chapters/euclidean_algorithm/res/modulus.png | Bin 46635 -> 46634 bytes .../euclidean_algorithm/res/subtraction.png | Bin 49773 -> 49772 bytes .../code/c/gaussian_elimination | Bin 0 -> 9482 bytes .../code/c/gaussian_elimination.c | 60 ++++++++++++++++++ .../Contents/Info.plist | 20 ++++++ .../Resources/DWARF/gaussian_elimination | Bin 0 -> 10154 bytes chapters/monte_carlo/res/13311.png | Bin 181137 -> 181133 bytes chapters/monte_carlo/res/195583.png | Bin 157538 -> 157534 bytes chapters/monte_carlo/res/31.png | Bin 40185 -> 40182 bytes chapters/monte_carlo/res/monte_carlo.gif | Bin 1672908 -> 1672892 bytes chapters/monte_carlo/res/square_circle.png | Bin 6926 -> 6925 bytes .../verlet/code/labview/verlet_labview.png | Bin 40437 -> 40436 bytes .../verlet/code/scratch/verlet_scratch.png | Bin 656739 -> 656733 bytes .../building_blocks/nand.jpg | Bin 77969 -> 77967 bytes .../building_blocks/nor.jpg | Bin 86903 -> 86902 bytes .../building_blocks/not.jpg | Bin 43029 -> 43028 bytes .../principles_of_code/building_blocks/or.jpg | Bin 86337 -> 86335 bytes .../building_blocks/xor.jpg | Bin 95936 -> 95933 bytes chapters/principles_of_code/clone.png | Bin 431068 -> 431065 bytes chapters/principles_of_code/fork.png | Bin 369136 -> 369130 bytes .../principles_of_code/notation/cplot.png | Bin 5484 -> 5483 bytes chapters/taylor/function_sum.png | Bin 6901 -> 6900 bytes .../code/scratch/scratch_tree.png | Bin 671540 -> 671531 bytes chapters/tree_traversal/res/3-tree.png | Bin 90504 -> 90502 bytes chapters/tree_traversal/res/BFS_simple.png | Bin 192972 -> 192969 bytes chapters/tree_traversal/res/DFS_in.png | Bin 140517 -> 140516 bytes chapters/tree_traversal/res/DFS_post.png | Bin 193206 -> 193204 bytes chapters/tree_traversal/res/DFS_pre.png | Bin 193064 -> 193062 bytes chapters/tree_traversal/res/binary_tree.png | Bin 67664 -> 67663 bytes 39 files changed, 80 insertions(+) create mode 100755 chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination create mode 100644 chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.c create mode 100644 chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Info.plist create mode 100644 chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Resources/DWARF/gaussian_elimination diff --git a/chapters/FFT/res/FT_example.png b/chapters/FFT/res/FT_example.png index d4f0a86d16c963cb8ab6c359e244eeb92bc1b21f..9e9640d7117efe7d95304341cbdf8984a44ac8be 100644 GIT binary patch delta 30 mcmdmglx@#ZHkQr+Klet~t*nfXlDEG|W}Kk0y|RbVO$-3Sp$pys delta 35 pcmdmUlx_b}HrCDnKX=|nmaQy|kCGXAw?9i}oS*@u%X%2y!~p8@3;_TD diff --git a/chapters/FFT/res/butterfly_diagram.png b/chapters/FFT/res/butterfly_diagram.png index cf995b162936f756d3a1ae40a87f884893dadb6d..dd34a1fde4a9d9e9f974be929c95f3c85c4eddb2 100644 GIT binary patch delta 20 ccmdmWj%CL=7M9KcKlhESUGp|in766}0AJq;dH?_b delta 23 fcmdmSj%C+57S_%HKX=}ZEM4;$c{lgXTh##oav%wl diff --git a/chapters/FFT/res/fft.png b/chapters/FFT/res/fft.png index d0ae3d9f5f597a0f11fab008986208d4380ae239..b0457e320430031d22b348491878180560941654 100644 GIT binary patch delta 13 UcmZ3bzEYi~Gr-S%BkNLO03lBVf&c&j delta 14 VcmZ3fzDk|7Gr-TCcO%PEVE`nl1djj! diff --git a/chapters/FFT/res/radix-2screen.jpg b/chapters/FFT/res/radix-2screen.jpg index 5e48db254a9d6c2d67376cf7cc1521e8afd3119c..5a43b46db371c85c9731ac6a546d369a50b27cb3 100644 GIT binary patch delta 72 zcmbO}jk$js^M<5ycCNoxO@cL|lX)9dH}{vHV%i*4wVM$lTK{lZ4d)vuTFO0<$xTN*l9&q{1c2 CG86p( delta 69 zcmdlvh55h~<_#N47s!6a$b@G9F)y;)v+-yLJni^paAl2V;l@Um# Tw4G!EQo5a9(m<+w$stt$gqIk# diff --git a/chapters/FFT/res/radix-8screen.jpg b/chapters/FFT/res/radix-8screen.jpg index 1d5cf65a2fa8337aa2c3497a7429caaa04905e83..51311d9e46532e0fc2e0071114308bc391d9ff0f 100644 GIT binary patch delta 54 zcmZ3ol7H?>{tYFXn@crCwr=ja$85a4Pmpl|@AL&?OnTd6z<-2eap delta 14 VcmdmLyUmuhGr-TCcO%P2IRGdW1nK|) diff --git a/chapters/data_compression/huffman/res/huffman_tree.png b/chapters/data_compression/huffman/res/huffman_tree.png index e0795cdd92d86770cd9befbb56a5f3c3c69ac0bd..bd48821471cd4b52f1ff9a686d212b1086800e63 100644 GIT binary patch delta 30 mcmex&obS(ZK9Cm%e zttMABtcxhlW=z0&zw~^6^$^{^x!T4AMs5u0uw|l~^K@`DT^VbSr>(@pp!+;M42W=} zp&D%?o3KL8Q|Zi5YRP1e=RrXz-o0XkiA{$l5wDUT#pB^%R0}3C$R2O2i02al2#Zt= zOHF=iDxHkPhsAh%ydxssJ))nmm8xQ+gL5?zPgM$NkEe-vwB|&FtLkT%ms-v<@e`4F zfJfq?1g!RW7i{qe+jCk928H%X7YfdKZ%==Zr3d?g*1_Btc1imLdst^0#`$of@|3ra z*F=Mf5TE=_qV=?5&f`&@8jB4jqFhTSYw~Ln`H5}I2wVLrp0$pgN0onz=MnKdA|b-o zc=WvHo}(d^bGm=u!Dpo2edZbS+Uf>Ow2}@Lh~nsV)e&Q@_&v~0x|cDkO%tS!p%Zm^ z!H^o{1SGAcp5q3_9)jMF<^lrV4ZROcME%5+?>exU8d@#2!+&|LnbH3Cf^nRgKa)!O zqmdzhU@RH{CRzigIle!3PPz1M=lkz%I{S{N*+0DzHk6LB74);kL}USN#zTYmlGl)r2+U9&hnxyH6>uux zRKTgg|Fr@Ga_(n2yWo{`7xPkC?=H{3 zM%~%Zyn|Ol?)ANl>G>d+T&6rDEzs<8e*AhqQ_lYGlGUr%+*^0fzs6{H;@<17l&bm%5jkEB)jT1Wa z(wtt>x%rdGbnuFM{RE|A*0ZX<*#%9WlnV0Xs+$;ckv>_-`Oa5RQ8~X$&SkI@J|Jf~ zcU8{)Dd)bDbJBG2WqsKAbaD3P;^HMLzdSi!C_a5lU*Pk=xvN;>7ol|gaS;ox_vfUy zi{BYTPQio$dzX6NERG|ToL{v}pL#hhwY=vq_i1|1?YNA6p$%Rs(o9o}Z8snm+y2(u zTWA^EKl$K~5Iu(%+rEUH3X^gE7d(ELUK8hkAdMD${#$6?wsv1f$cuN*6>R|;X`#~N z0(2X)Nyug)R}1M8a;=bFAzQmC$+ci2tE4i}C*GZq#Pn&Eh;;h&uoCaE&0s-GifJ(A zqvBKBlS1|hY4$tPsen@frvgp|oC-J|R6c1Rz`V+t<2M_DLDSIR2xT4Ty6u9gFA zBy~d3crtM!#k651lS)ODI1ff6u}EA=M-p+Ci7Amddx^dQX<#J}nu!O{6xN{mW-XeZ z@I^_0efF!@_C`O|$V^?itj{7pSuK)l5 literal 0 HcmV?d00001 diff --git a/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.c b/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.c new file mode 100644 index 000000000..9ba180421 --- /dev/null +++ b/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.c @@ -0,0 +1,60 @@ +#include + + + +#define n_rows 3 +#define n_cols 3 + +/*Prints a matrix in a nice way*/ +void print_matrix(double matrix[n_rows][n_cols]){ + int i; + int j; + for(i = 0; i < n_rows; i++){ + for(j = 0; j < n_cols; j++) + printf(" %0.1f ", matrix[i][j]); + printf("\n"); + } +} + +int find_col_max_ind(double matrix[n_rows][n_cols], int column){ + int i; + int max_ind = 0; + int max = matrix[0][column - 1]; + + for(i = 1; i < n_rows; i++){ + if(matrix[i][column - 1] > max){ + max = matrix[i][column - 1]; + max_ind = i; + } + } + return max_ind; +} + +void swap_rows(double matrix[n_rows][n_cols], int row_ind1, int row_ind2){ + double tmp; + int i; + + for(i = 0; i < n_cols; i++){ + tmp = matrix[row_ind1][i]; + matrix[row_ind1][i] = matrix[row_ind2][i]; + matrix[row_ind2][i] = tmp; + } +} + +void gaussian_elimination(double matrix[n_rows][n_cols]){ +} + +int main(){ + double matrix[n_rows][n_cols] = {{1, 2, 3}, + {4, 5, 6}, + {7, 8, 9}}; + + print_matrix(matrix); + printf("\n%d", find_col_max_ind(matrix, 1)); + swap_rows(matrix, 0, 2); + printf("\n"); + print_matrix(matrix); + + return 0; +} + diff --git a/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Info.plist b/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Info.plist new file mode 100644 index 000000000..2eb4924d6 --- /dev/null +++ b/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleIdentifier + com.apple.xcode.dsym.gaussian_elimination + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + dSYM + CFBundleSignature + ???? + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Resources/DWARF/gaussian_elimination b/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Resources/DWARF/gaussian_elimination new file mode 100644 index 0000000000000000000000000000000000000000..380d0e288c3f0b00d8afec037f6b3fd9c8c424c6 GIT binary patch literal 10154 zcmeHN|8EpU6rbJgY`1si`VFB_HCL=q`Eu7HieRbM0Jar`@TFE1hrPSy?wb3S+dU|R z2*HFH@dv6g1jPtQ0zokRCNY5+fA9wq;twW<@S~!?k;so|BEB~}bKTosg+E~DGW+Je znfbgoZ{}@oX6NU>@BQ0Ih@uffLXe?MZsS9wE})%|Z%=$}-njU}HXYs0oJ!1$8lr{ws3jL8Uk>xS!Sfbtu%UvnWU*jRJJ63; z5_mZ0GS&D`3I%1XQrMp@q*%7Fw+J#n-nBY-ew)0IxK3Vz31n>j(2gNb4XlqxtrJ}H zm@zSyE>4efc09vv&Y!X`GB}@Jp0PrX*$488Vvd!Z@(lY7VV`#yd;24v*N=?l%>Tpd z6nGe`GI{YZF65fS`sp~`H1g&f8`h7=7>oM+CJeleogg6&_bcaIoNJ&6{QuU_wv9px zq|b*Fb*nBR03;-6UlJbI~LY>@SFpsnRpKc-bw-U@G|^4YiA34jH*BkbASGmBwDEbW7r6PNhs4`E0>-vc&>{>MT4(`?!tDKKiIt1{r#IoCGf0640uKZp2s{vY zAn-uofxrWS2LcZS9tb=Tcp&h=>>l_OHuWl50Sy%8pU50|D!9#utdM$J@)-a6KuD7+ zcl-;f5xP!Wbcd>=v`J6XRw!ztn!T6K)3u008+5~=UHX?)(@$vjxURK0bm13N)lX1G z->vGP6X4{5gVwH4J@hSYu0Z!u`qThz9-#VBYUqPfiO!YWrSqX;fIfYcJ~>XIX$Zt~ z^}DodfQAOBag;{%b+j2;sL*xccCN5Ve-G$@s=7+$DTNkQU=(+x0vtsnTD?Gj8?1)H zd?O~9ab8}i@2n0$V965_ZJ9!q&<9e5JSfp(3T+ChD>|rZ^w2h=8~T5*8|(hKqHDv( zue!E2Mv1O%+^bTsEd_Jne)h%>c1wY)IRlvh!Hgr6n;@J%8(9qf>P;XSg$jPG0?i3t zE11?}LlvB~kmEp8#Y!S)kx!s#XAfHV9Sb{-wEDNE`k9KTxf`uiHj8z9z99zczvU~BGD9O>=HhkG<9kcp_QhC2&7IqH;@bA zP=PD`fLs_kxHjT3T^aikYdWx|iqU}>z&XEE>kxw@&J~EcJ6QLG;4;4c4X+mWoTm>3w>;ckXgqHy^8a*|lo+xd~vyl#}MOx=~ zMcR~h9VR6P!gl@DPA#%F{Bn57f>+??fkufc1S1^)xvGYx{w^aO*h#MyyTZmEqD2P7 zVYo(Mv=9VqQWPYiZs1mfIE*dA;X!`UUlO6+Z^3zm2Eg;jIN3G$NHkZ$sBx# zU$LfdWvnmu{F>Ox=jsLzy#3-kZRi>2UyI}Gi^)pfDmZq0Yq>aKC81#E(#3Mt$>dj< z$aE4mR7a*YBV^pA? zcK{rc;^AsP5rvh+$(QO5%zYzZ?2EXs#{BU1p<$SBeyIvCR>6HKo=~QUDS zUCKE^ct}EdLhyWV5x!AL1wOVQzn?Lo}nkcs2J zZ;!sS?m^#?55rqQmWKR3WDEw>hau8K$k=HIM@leMP>kUN;<;a4Nuf9@#29uUKHs~R P`%@Z)Juvy5jE4LNQ06LP literal 0 HcmV?d00001 diff --git a/chapters/monte_carlo/res/13311.png b/chapters/monte_carlo/res/13311.png index 41d4b46adf8512b9a8665ded7cbd2ba3d97c9ba6..adb19185c9f4a038a9ae3d196b32b51a6ca6a857 100644 GIT binary patch delta 40 wcmbQ(&fVM2&C(g*=f08kyhZa>i}tG)jN7kTFtrJ7kMU-jY_$DDEz?3*07NVhCIA2c delta 47 zcmeBe=bqTk&Dt5@=gzy4<-7$WZ}Vk~_RAKG+b>%%wFxouZjbb4nrsB5-_$ZKbOiv0 Cz7S9V diff --git a/chapters/monte_carlo/res/195583.png b/chapters/monte_carlo/res/195583.png index 44b5537924ed50715b33e086f721c3498da16e01..3aab35ab5cbf1792648d385284ddfdf8f1fa4213 100644 GIT binary patch delta 32 ocmaEKj`Q9*PL|F9KlhESv$k(uus!k8cBU@In3V1D?--dY0slb`ssI20 delta 39 ucmcb2j`PtuPS(x%dI{F delta 30 lcmeyilj-M9Cf3dXKX=}ZEIw_Fyqg2sR`LU>pHu&`0RX(^3=RMQ diff --git a/chapters/monte_carlo/res/monte_carlo.gif b/chapters/monte_carlo/res/monte_carlo.gif index 2ff21b0088df998d217b763fdc3a389de45ab99c..f4c041c872e88b58a47000b71fce5b6096219e1f 100644 GIT binary patch delta 171 zcmX@po3^Jnt)Ydng{g(Pg=Gut)};1rNvuH32E^>!w7;Vh49oL+a4#)yHBWHR*!ePtRCO=pzT{5_;U2NE3N12Woh5AnQ!}s&HNkv zwkI(O^zLu}a8Lk<1%X&-`-g+VQ~bBL3X1Fz+U}$xlApMJQ>)0F6Yc(fqTBub#Fpr^ Tf2k4!VsRjr*#4zT@&-2mB!o&L delta 219 zcmdnfn|7u*t)Ydng{g(Pg=Gut)+9#W_N_^*K+Fcj?Ax~{am3x_;pGy1=K6lYwbR@T zH>T$YGI_OUIB;&yaNv3!$H==qcs^JAR-nFHA>7+JmpXhc6Kd~h`K=zX=F(4KPVu|ffsw8i40|0D2 BQe6N5 diff --git a/chapters/monte_carlo/res/square_circle.png b/chapters/monte_carlo/res/square_circle.png index b33428ecb78de24fc8894e4f270b32569a271ef3..95aea8560612694ed58ab986bce4439187f0153e 100644 GIT binary patch delta 13 UcmeA(>osHP4DfT`$jT`V03OK$)Bpeg delta 14 VcmeA*>oa5R4DfU3-N?cz4FDnu1K|Jw diff --git a/chapters/physics_solvers/verlet/code/labview/verlet_labview.png b/chapters/physics_solvers/verlet/code/labview/verlet_labview.png index 8005a677643cccb1afadd2ee4d1065bce0251f0a..16c24913c8a150aa2a6d215dde148490f7205cd7 100644 GIT binary patch delta 15 Xcmeymo9WALCYH_sKlhESALar8J8lOV delta 16 Ycmeyeo9XLrCf3dXKX=}ZEFb0q06>WcCIA2c diff --git a/chapters/physics_solvers/verlet/code/scratch/verlet_scratch.png b/chapters/physics_solvers/verlet/code/scratch/verlet_scratch.png index fd54372c45439e3106c09f85b7f9130c46dcbc26..2d967081f85f03b2f9dbc300e50e87e3dbb69fab 100644 GIT binary patch delta 84 zcmaFdrE#}QgQYXT&%Kd#D=Xu9Yc{UMQk?5Nr*AA`lxhEN%?QLy+rL{g`^;!}xxx&@ lEI`b<-Q^0K=&bgrJofETc^ng1w!bdo5I(#8zddKlQ2=WLAEB-zCA3DV*(2!@AhX!9KvUT^iO-vl%oK|IUq;? diff --git a/chapters/principles_of_code/building_blocks/nand.jpg b/chapters/principles_of_code/building_blocks/nand.jpg index cce882a96511fbf3b4fd2a24bc8b13fe3a71e24d..a5ccfb591b6d17fda7be96d324c1e1ec9edf1f3c 100644 GIT binary patch delta 19 bcmbREkfr}2%Z9_5n~!92xotkb{!jw|Wx5J# delta 23 ecmeBw$TIOE%Z9_5jJ%rnLm07Q@mRsaA1 diff --git a/chapters/principles_of_code/building_blocks/not.jpg b/chapters/principles_of_code/building_blocks/not.jpg index a7602ce02f99f7998fbc1ec4ac4201a1c3651301..6cd5f362466e729b3b5ca10d8ce1c0a5121051a8 100644 GIT binary patch delta 14 WcmbPwfoaMGrVY1wH{ap4oCN?iR|eGp delta 16 YcmbPofobXmrVY1w8F@F~=Czy!06uXB;s5{u diff --git a/chapters/principles_of_code/building_blocks/or.jpg b/chapters/principles_of_code/building_blocks/or.jpg index 13b8189ed61b61d8deabe6e9001b3fae76540ce6..e86eb5ffba074cbe3fd1a9ef505918515fc4615f 100644 GIT binary patch delta 23 fcmX@Oh;{!W)(ur6o2x~xNjC=>Y!5PEe6Iiid*lg@ delta 27 jcmdnLi1pwi)(ur6jJ%txM6O9Q@-_z;Y!5JCe6Iiik;@6C diff --git a/chapters/principles_of_code/building_blocks/xor.jpg b/chapters/principles_of_code/building_blocks/xor.jpg index 76813fa05da86e2aab64c39ff92638c404a79f37..9ffacb7fdb6c297f9cb0f31c54d09e4706bc6419 100644 GIT binary patch delta 28 kcmX@`mUZu2)(tO(Hop>@$GEvu>$A?iA K1h-KX1)q(Sh!>>* delta 63 zcmaELSnR`LG1kriKX=}ZEc*Kxc{dyH`@NHqce`E%;~ftm&2^CRRW~DV`xhUk?O%MD S!;b^m-Xbj9y+v5(_W}SUBNy2K diff --git a/chapters/principles_of_code/notation/cplot.png b/chapters/principles_of_code/notation/cplot.png index 9a779ac8334c20eaea75a620b4919ef4574e7cb9..9693b2ccdf5a6a5d5c49cff402eae5f6fa84f87f 100644 GIT binary patch delta 13 UcmaE(^;(OiGr-S%BWt=S04GNT&;S4c delta 14 VcmaE@^+t=eGr-TCcOy%>C;%%f1l<4t diff --git a/chapters/taylor/function_sum.png b/chapters/taylor/function_sum.png index 5f7c16a3f16eb2fc30aac2e394eac997b8c04d16..ecbea2d08ded3aff8bbab04b4a706dd6e84d9f27 100644 GIT binary patch delta 13 Ucmexr`o)x`Gr-S%BkKn#04gX2h5!Hn delta 14 Vcmexj`qh-RGr-TCcO%OODF7}s1(N^( diff --git a/chapters/tree_traversal/code/scratch/scratch_tree.png b/chapters/tree_traversal/code/scratch/scratch_tree.png index a0288cfdd91f0dc08d7550a3cc4d09b08a25c4b3..54fc441bd1389d3250e09f3081adf08a880ecbd9 100644 GIT binary patch delta 89 zcmdn;Ph<5z4VKOTKlhES2lO`|)A!rbEc&Ef^a&#nGi?`r!hGCw`(0fY`K0#0{Vd!6 r_Olu~Z`Z%f$}wrXMJk&-PkTfm8xXStF~|0ZLQbvv?ad!JH~Ikp*2N_b delta 106 zcmZ4ePh-nJ4c5*8KX=}ZEC=)%c{d-?_uInA+br~?UFZoT5HoETdcu6%laY7(O&WJhk=s8;GEQd)0D&?JcmMzZ delta 27 jcmZoW%-V67m9;a#&z*N8%j-x+-sbm_+uuhrPG<)IlAQ{V diff --git a/chapters/tree_traversal/res/BFS_simple.png b/chapters/tree_traversal/res/BFS_simple.png index 50b16f461792c5b7474180761a32a25dd8bcbe56..44997a292d799de2cc64749a580924011843720d 100644 GIT binary patch delta 30 ocmV+(0O9}4;|s~-3j~Q!PDgOV delta 35 qcmX^4nET9QZr08KKX=|nmaQy|o7OS%Zr`?!QQ Date: Tue, 24 Jul 2018 10:57:29 +0300 Subject: [PATCH 2/3] master sync --- .../code/c/gaussian_elimination | Bin 9482 -> 0 bytes .../code/c/gaussian_elimination.c | 60 ------------------ .../Contents/Info.plist | 20 ------ .../Resources/DWARF/gaussian_elimination | Bin 10154 -> 0 bytes 4 files changed, 80 deletions(-) delete mode 100755 chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination delete mode 100644 chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.c delete mode 100644 chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Info.plist delete mode 100644 chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Resources/DWARF/gaussian_elimination diff --git a/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination b/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination deleted file mode 100755 index 9553c18f56521d33043a68e74391bec223948e7e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9482 zcmeHNU2GIp6uxUK76i97#H@m_REkJow*?9%5p7LJ2L-IqCI(Y4)7jnb(*2q2540x5 z$_mM{X{Cm%e zttMABtcxhlW=z0&zw~^6^$^{^x!T4AMs5u0uw|l~^K@`DT^VbSr>(@pp!+;M42W=} zp&D%?o3KL8Q|Zi5YRP1e=RrXz-o0XkiA{$l5wDUT#pB^%R0}3C$R2O2i02al2#Zt= zOHF=iDxHkPhsAh%ydxssJ))nmm8xQ+gL5?zPgM$NkEe-vwB|&FtLkT%ms-v<@e`4F zfJfq?1g!RW7i{qe+jCk928H%X7YfdKZ%==Zr3d?g*1_Btc1imLdst^0#`$of@|3ra z*F=Mf5TE=_qV=?5&f`&@8jB4jqFhTSYw~Ln`H5}I2wVLrp0$pgN0onz=MnKdA|b-o zc=WvHo}(d^bGm=u!Dpo2edZbS+Uf>Ow2}@Lh~nsV)e&Q@_&v~0x|cDkO%tS!p%Zm^ z!H^o{1SGAcp5q3_9)jMF<^lrV4ZROcME%5+?>exU8d@#2!+&|LnbH3Cf^nRgKa)!O zqmdzhU@RH{CRzigIle!3PPz1M=lkz%I{S{N*+0DzHk6LB74);kL}USN#zTYmlGl)r2+U9&hnxyH6>uux zRKTgg|Fr@Ga_(n2yWo{`7xPkC?=H{3 zM%~%Zyn|Ol?)ANl>G>d+T&6rDEzs<8e*AhqQ_lYGlGUr%+*^0fzs6{H;@<17l&bm%5jkEB)jT1Wa z(wtt>x%rdGbnuFM{RE|A*0ZX<*#%9WlnV0Xs+$;ckv>_-`Oa5RQ8~X$&SkI@J|Jf~ zcU8{)Dd)bDbJBG2WqsKAbaD3P;^HMLzdSi!C_a5lU*Pk=xvN;>7ol|gaS;ox_vfUy zi{BYTPQio$dzX6NERG|ToL{v}pL#hhwY=vq_i1|1?YNA6p$%Rs(o9o}Z8snm+y2(u zTWA^EKl$K~5Iu(%+rEUH3X^gE7d(ELUK8hkAdMD${#$6?wsv1f$cuN*6>R|;X`#~N z0(2X)Nyug)R}1M8a;=bFAzQmC$+ci2tE4i}C*GZq#Pn&Eh;;h&uoCaE&0s-GifJ(A zqvBKBlS1|hY4$tPsen@frvgp|oC-J|R6c1Rz`V+t<2M_DLDSIR2xT4Ty6u9gFA zBy~d3crtM!#k651lS)ODI1ff6u}EA=M-p+Ci7Amddx^dQX<#J}nu!O{6xN{mW-XeZ z@I^_0efF!@_C`O|$V^?itj{7pSuK)l5 diff --git a/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.c b/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.c deleted file mode 100644 index 9ba180421..000000000 --- a/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.c +++ /dev/null @@ -1,60 +0,0 @@ -#include - - - -#define n_rows 3 -#define n_cols 3 - -/*Prints a matrix in a nice way*/ -void print_matrix(double matrix[n_rows][n_cols]){ - int i; - int j; - for(i = 0; i < n_rows; i++){ - for(j = 0; j < n_cols; j++) - printf(" %0.1f ", matrix[i][j]); - printf("\n"); - } -} - -int find_col_max_ind(double matrix[n_rows][n_cols], int column){ - int i; - int max_ind = 0; - int max = matrix[0][column - 1]; - - for(i = 1; i < n_rows; i++){ - if(matrix[i][column - 1] > max){ - max = matrix[i][column - 1]; - max_ind = i; - } - } - return max_ind; -} - -void swap_rows(double matrix[n_rows][n_cols], int row_ind1, int row_ind2){ - double tmp; - int i; - - for(i = 0; i < n_cols; i++){ - tmp = matrix[row_ind1][i]; - matrix[row_ind1][i] = matrix[row_ind2][i]; - matrix[row_ind2][i] = tmp; - } -} - -void gaussian_elimination(double matrix[n_rows][n_cols]){ -} - -int main(){ - double matrix[n_rows][n_cols] = {{1, 2, 3}, - {4, 5, 6}, - {7, 8, 9}}; - - print_matrix(matrix); - printf("\n%d", find_col_max_ind(matrix, 1)); - swap_rows(matrix, 0, 2); - printf("\n"); - print_matrix(matrix); - - return 0; -} - diff --git a/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Info.plist b/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Info.plist deleted file mode 100644 index 2eb4924d6..000000000 --- a/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Info.plist +++ /dev/null @@ -1,20 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleIdentifier - com.apple.xcode.dsym.gaussian_elimination - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - dSYM - CFBundleSignature - ???? - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - - diff --git a/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Resources/DWARF/gaussian_elimination b/chapters/matrix_methods/gaussian_elimination/code/c/gaussian_elimination.dSYM/Contents/Resources/DWARF/gaussian_elimination deleted file mode 100644 index 380d0e288c3f0b00d8afec037f6b3fd9c8c424c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10154 zcmeHN|8EpU6rbJgY`1si`VFB_HCL=q`Eu7HieRbM0Jar`@TFE1hrPSy?wb3S+dU|R z2*HFH@dv6g1jPtQ0zokRCNY5+fA9wq;twW<@S~!?k;so|BEB~}bKTosg+E~DGW+Je znfbgoZ{}@oX6NU>@BQ0Ih@uffLXe?MZsS9wE})%|Z%=$}-njU}HXYs0oJ!1$8lr{ws3jL8Uk>xS!Sfbtu%UvnWU*jRJJ63; z5_mZ0GS&D`3I%1XQrMp@q*%7Fw+J#n-nBY-ew)0IxK3Vz31n>j(2gNb4XlqxtrJ}H zm@zSyE>4efc09vv&Y!X`GB}@Jp0PrX*$488Vvd!Z@(lY7VV`#yd;24v*N=?l%>Tpd z6nGe`GI{YZF65fS`sp~`H1g&f8`h7=7>oM+CJeleogg6&_bcaIoNJ&6{QuU_wv9px zq|b*Fb*nBR03;-6UlJbI~LY>@SFpsnRpKc-bw-U@G|^4YiA34jH*BkbASGmBwDEbW7r6PNhs4`E0>-vc&>{>MT4(`?!tDKKiIt1{r#IoCGf0640uKZp2s{vY zAn-uofxrWS2LcZS9tb=Tcp&h=>>l_OHuWl50Sy%8pU50|D!9#utdM$J@)-a6KuD7+ zcl-;f5xP!Wbcd>=v`J6XRw!ztn!T6K)3u008+5~=UHX?)(@$vjxURK0bm13N)lX1G z->vGP6X4{5gVwH4J@hSYu0Z!u`qThz9-#VBYUqPfiO!YWrSqX;fIfYcJ~>XIX$Zt~ z^}DodfQAOBag;{%b+j2;sL*xccCN5Ve-G$@s=7+$DTNkQU=(+x0vtsnTD?Gj8?1)H zd?O~9ab8}i@2n0$V965_ZJ9!q&<9e5JSfp(3T+ChD>|rZ^w2h=8~T5*8|(hKqHDv( zue!E2Mv1O%+^bTsEd_Jne)h%>c1wY)IRlvh!Hgr6n;@J%8(9qf>P;XSg$jPG0?i3t zE11?}LlvB~kmEp8#Y!S)kx!s#XAfHV9Sb{-wEDNE`k9KTxf`uiHj8z9z99zczvU~BGD9O>=HhkG<9kcp_QhC2&7IqH;@bA zP=PD`fLs_kxHjT3T^aikYdWx|iqU}>z&XEE>kxw@&J~EcJ6QLG;4;4c4X+mWoTm>3w>;ckXgqHy^8a*|lo+xd~vyl#}MOx=~ zMcR~h9VR6P!gl@DPA#%F{Bn57f>+??fkufc1S1^)xvGYx{w^aO*h#MyyTZmEqD2P7 zVYo(Mv=9VqQWPYiZs1mfIE*dA;X!`UUlO6+Z^3zm2Eg;jIN3G$NHkZ$sBx# zU$LfdWvnmu{F>Ox=jsLzy#3-kZRi>2UyI}Gi^)pfDmZq0Yq>aKC81#E(#3Mt$>dj< z$aE4mR7a*YBV^pA? zcK{rc;^AsP5rvh+$(QO5%zYzZ?2EXs#{BU1p<$SBeyIvCR>6HKo=~QUDS zUCKE^ct}EdLhyWV5x!AL1wOVQzn?Lo}nkcs2J zZ;!sS?m^#?55rqQmWKR3WDEw>hau8K$k=HIM@leMP>kUN;<;a4Nuf9@#29uUKHs~R P`%@Z)Juvy5jE4LNQ06LP From a80cadac06985d4ef549f1753aa45a5f1d2b65f7 Mon Sep 17 00:00:00 2001 From: GuyPozner Date: Tue, 24 Jul 2018 12:46:28 +0300 Subject: [PATCH 3/3] trying to fix binary files issue --- .../code/python/monte_carlo.py | 35 +++++++++++++++++++ .../monte_carlo_integration.md | 4 +++ 2 files changed, 39 insertions(+) create mode 100644 contents/monte_carlo_integration/code/python/monte_carlo.py diff --git a/contents/monte_carlo_integration/code/python/monte_carlo.py b/contents/monte_carlo_integration/code/python/monte_carlo.py new file mode 100644 index 000000000..041839dc2 --- /dev/null +++ b/contents/monte_carlo_integration/code/python/monte_carlo.py @@ -0,0 +1,35 @@ +import math +import random + + +def in_circle(x, y, radius = 1): + """Return True if the point is in the circle and False otherwise.""" + return (x*x + y*y) < radius*radius + +def monte_carlo(n_samples, radius = 1): + """Return the estimate of pi using the monte carlo algorithm.""" + in_circle_count = 0 + for i in range(n_samples): + + # Sample x, y from the uniform distribution + x = random.uniform(0, radius) + y = random.uniform(0, radius) + + # Count the number of points inside the circle + if(in_circle(x, y, radius)): + in_circle_count += 1 + + # Since we've generated points in upper left quadrant ([0,radius], [0, radius]) + # We need to multiply the number of points by 4 + pi_estimate = 4 * in_circle_count / (n_samples) + + return pi_estimate + +if __name__ == '__main__': + + pi_estimate = monte_carlo(100000) + percent_error = 100*abs(math.pi - pi_estimate)/math.pi + + print("The estimate of pi is: {:.3f}".format(pi_estimate)) + print("The percent error is: {:.3f}".format(percent_error)) + diff --git a/contents/monte_carlo_integration/monte_carlo_integration.md b/contents/monte_carlo_integration/monte_carlo_integration.md index 84a158e92..68fa04d22 100644 --- a/contents/monte_carlo_integration/monte_carlo_integration.md +++ b/contents/monte_carlo_integration/monte_carlo_integration.md @@ -59,6 +59,8 @@ each point is tested to see whether it's in the circle or not: [import:13-15, lang:"java"](code/java/MonteCarlo.java) {% sample lang="swift" %} [import:15-17 lang:"swift"](code/swift/monte_carlo.swift) +{% sample lang="py" %} +[import:5-7 lang:"python"](code/python/monte_carlo.py) {% endmethod %} If it's in the circle, we increase an internal count by one, and in the end, @@ -112,6 +114,8 @@ Feel free to submit your version via pull request, and thanks for reading! [import, lang:"java"](code/java/MonteCarlo.java) {% sample lang="swift" %} [import, lang:"swift"](code/swift/monte_carlo.swift) +{% sample lang="py" %} +[import, lang:"python"](code/python/monte_carlo.py) {% endmethod %}