{VERSION 5 0 "SGI MIPS UNIX" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier " 1 10 0 0 255 1 0 0 0 0 0 1 3 0 3 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 2" 3 4 1 {CSTYLE "" -1 -1 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 8 2 0 0 0 0 0 0 -1 0 }{PSTYLE "" 2 6 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 2 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Outpu t" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 3 "" 0 "" {TEXT -1 27 "Arrays and Tables in Mapl e" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 354 "Maple has sequences, lists, sets, and functions for basic data-structures. In addition, it has t wo other data-structures called arrays and tables. Arrays are used by Maple to represent vectors and matrices. Tables are used almost excl usively as a programming tool - for writing certain programs in an eff icient way. Maplke tables are ``hash'' tables." }}}{EXCHG {PARA 4 "" 0 "" {TEXT -1 22 "One-dimensional Arrays" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "A one-dimenisional array is created with the command \+ " }{TEXT 256 13 "Array( m..n )" }{TEXT -1 9 " where " }{XPPEDIT 18 0 "m <= n;" "6#1%\"mG%\"nG" }{TEXT -1 83 " are integers. In Maple, a \+ vector is represented as a one-dimensional array where " }{XPPEDIT 18 0 "m = 1;" "6#/%\"mG\"\"\"" }{TEXT -1 15 " . For example" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 17 "v := Array(1..4);" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#>%\"vG-%'RTABLEG6$\"*#Hv " 0 "" {MPLTEXT 1 0 21 "v[1] := 3; v[2] := 4;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"vG6# \"\"\"\"\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"vG6#\"\"#\"\"%" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 42 "Notice that the entries of v have changed." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 44 "You can access the e ntries using subscripts." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 " v;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'RTABLEG6$\"*#Hv " 0 "" {MPLTEXT 1 0 5 "v[1]; " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"$" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 5 "v[2];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"%" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 54 "You may fill the entries of an arr ay using a for loop." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 52 "u : = Array(1..4);\nfor i from 1 to 4 do u[i] := i od;" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>%\"uG-%'RTABLEG6$\"*/p$=F-%'VECTORG6#7&\"\"!F-F-F-" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"uG6#\"\"\"F'" }}{PARA 11 "" 1 " " {XPPMATH 20 "6#>&%\"uG6#\"\"#F'" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#> &%\"uG6#\"\"$F'" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"uG6#\"\"%F'" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "u;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'RTABLEG6$\"*/p$=F-%'VECTORG6#7&\"\"\"\"\"#\"\"$\"\"% " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 73 "And you can do arithmetic wit h them, e.g. vector addition and dot product" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 4 "u+v;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'RTABLE G6$\"*/x$=F-%'VECTORG6#7&\"\"%\"\"'\"\"$F+" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 4 "u.v;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'RTABLEG6$ \"*C!Q=F-%'VECTORG6#7&\"\"$\"\")\"\"!F-" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 373 "Now, when you store a value in an array, or access a val ue in an array, the time it takes is constant independent of the size \+ of the array. Lists do not have these properties. To access the ith \+ value of a list is constant time but to change a value in a list requi res making a copy of the list, therefore, the time it takes will be pr oportional to the length of the list." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 98 "Finally, often you will want to convert a vector to a lis t and vice versa. You may do this thusly" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 21 "L := convert(v,list);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"LG7&\"\"$\"\"%\"\"!F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "A := Array(1..4,L);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG- %'RTABLEG6$\"*W$Q=F-%'VECTORG6#7&\"\"$\"\"%\"\"!F/" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 48 "They display the same but they are not the same. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "lprint(A);" }}{PARA 6 " " 1 "" {TEXT -1 96 "Array(1 .. 4,\{(1) = 3, (2) = 4\},datatype = anyth ing,storage = rectangular,order = Fortran_order)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "lprint(L);" }}{PARA 6 "" 1 "" {TEXT -1 12 "[3 , 4, 0, 0]" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 54 "One dimensional arr ays do not need to be indexed from " }{XPPEDIT 18 0 "m = 1;" "6#/%\"mG \"\"\"" }{TEXT -1 10 " . Often " }{XPPEDIT 18 0 "m = 0;" "6#/%\"mG\" \"!" }{TEXT -1 16 " will be useful." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 58 "a := Array(0..3); \nfor i from 0 to 3 do a[i] := i+1 \+ od;\na;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"aG-%'RTABLEG6$\"*%QQ=F- %&ArrayG6';\"\"!\"\"$<\"/%)datatypeG%)anythingG/%(storageG%,rectangula rG/%&orderG%.Fortran_orderG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"aG 6#\"\"!\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"aG6#\"\"\"\"\"# " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"aG6#\"\"#\"\"$" }}{PARA 11 " " 1 "" {XPPMATH 20 "6#>&%\"aG6#\"\"$\"\"%" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#-%'RTABLEG6$\"*%QQ=F-%&ArrayG6';\"\"!\"\"$<&/6#F+\"\"\" /6#F0\"\"#/6#F3F,/6#F,\"\"%/%)datatypeG%)anythingG/%(storageG%,rectang ularG/%&orderG%.Fortran_orderG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "Implementing a 1-dimensional Cellular Automaton using Arrays." }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 152 "We can use an array to store the \+ state of a 1-dimensional cellular automaton. We will need two arrays \+ actually, one to store the current state at time " }{XPPEDIT 18 0 "t; " "6#%\"tG" }{TEXT -1 48 ", and one in which to compute the state at t ime " }{XPPEDIT 18 0 "t+1;" "6#,&%\"tG\"\"\"F%F%" }{TEXT -1 41 " . Fo r example, suppose we have at time " }{XPPEDIT 18 0 "t;" "6#%\"tG" } {TEXT -1 28 " the following state vector " }{XPPEDIT 18 0 "St;" "6#%#S tG" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 78 "bit : = rand(0..1):\nSt := Array(1..6):\nfor i from 1 to 6 do St[i] := bit() od;\n" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%#StG6#\"\"\"F'" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%#StG6#\"\"#\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%#StG6#\"\"$\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #>&%#StG6#\"\"%\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%#StG6#\"\" &\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%#StG6#\"\"'\"\"!" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "St;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'RTABLEG6$\"*W&Q=F-%'VECTORG6#7(\"\"\"\"\"!F+F+F,F," }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 88 "Now suppose our update function is the following and we use cyclic boundary connections." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 68 "f := proc(a,b,c) if b=1 then 0 elif a=1 or c=1 then 1 else 0 fi end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "Stp1 := Array(1..6): " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 126 "Stp1[1] := f(St[6],St[1],St[2]);\nfor i from 2 to 5 \+ do Stp1[i] := f(St[i-1],St[i],St[i+1]) od;\nStp1[6] := f(St[5],St[6],S t[1]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%%Stp1G6#\"\"\"\"\"!" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>&%%Stp1G6#\"\"#\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%%Stp1G6#\"\"$\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%%Stp1G6#\"\"%\"\"!" }}{PARA 11 "" 1 "" {XPPMATH 20 " 6#>&%%Stp1G6#\"\"&\"\"\"" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%%Stp1G6 #\"\"'\"\"\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "Stp1;" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#-%'RTABLEG6$\"*C'Q=F-%'VECTORG6#7(\"\" !\"\"\"F+F+F,F," }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 107 "Now here is a n implementation of a one-dimensional cellular automaton. I am going \+ to index the array from " }{XPPEDIT 18 0 "0;" "6#\"\"!" }{TEXT -1 4 " \+ to " }{XPPEDIT 18 0 "n-1;" "6#,&%\"nG\"\"\"F%!\"\"" }{TEXT -1 18 " in stead of 1 to " }{XPPEDIT 18 0 "n;" "6#%\"nG" }{TEXT -1 48 " so that I can use modular arithmetic to handle " }{TEXT -1 52 "the boundary con ditions more elegantly. For example" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "6 mod 6;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"\"!" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 144 "The code also interchanges x and \+ y so that we only use two arrays and not a new one each time. Here is how you interchange two values in Maple." }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 20 "St,Stp1 := Stp1, St;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>6$%#StG%%Stp1G6$-%'RTABLEG6$\"*C'Q=F-%'VECTORG6#7(\"\"!\"\"\"F0 F0F1F1-F)6$\"*W&Q=F-F-6#7(F1F0F1F1F0F0" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 325 "run1dca := proc(f::procedure,S0::list(numeric),m::po sint)\nlocal n,S,x,y,k,i;\n n := nops(S0);\n S := [S0];\n x := A rray(0..n-1,S0);\n y := Array(0..n-1);\n for k to m do\n for i from 0 to n-1 do y[i] := f(x[i-1 mod n],x[i],x[i+1 mod n]) od; \n \+ S := [op(S),convert(y,list)];\n x,y := y,x;\n od;\n S\n end:\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "d := 0.2;" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"dG$\"\"#!\"\"" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 34 "f := (a,b,c) -> a*d+b*(1-2*d)+c*d;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"fGf*6%%\"aG%\"bG%\"cG6\"6$%)operatorG%&a rrowGF*,(*&9$\"\"\"%\"dGF1F1*&9%F1,&F1F1*&\"\"#F1F2F1!\"\"F1F1*&9&F1F2 F1F1F*F*F*" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "R := run1dca( f,[0$7,1.0,0$7],14);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%\"RG7171\"\" !F'F'F'F'F'F'$\"#5!\"\"F'F'F'F'F'F'F'71$F'F'F,F,F,F,F,$\"#?!\"#$\"#gF/ F-F,F,F,F,F,F,71F,F,F,F,F,$\"#S!\"$$\"$S#F5$\"$S%F5F6F3F,F,F,F,F,71F,F ,F,F,$\"#!)!\"%$\"$?(F=$\"%+CF=$\"%+OF=F@F>F;F,F,F,F,71F,F,F,$\"$g\"! \"&$\"%?>FG$\"%!G*FG$\"&SI#FG$\"&+7$FGFLFJFHFEF,F,F,71F,F,$\"$?$!\"'$ \"%+[FS$\"&+/$FS$\"'+c5FS$\"'+#>#FS$\"'g$z#FSFZFXFVFTFQF,F,71F,$\"$S'! \"($\"&?:\"F[o$\"&S-*F[o$\"'+KSF[o$\"(+G8\"F[o$\"(?^3#F[o$\"(gHb#F[oFd oFboF`oF^oF\\oFinF,71$\"%!G\"!\")$\"&!)o#F[p$\"'!)3DF[p$\"(!)3P\"F[p$ \"(!Gl[F[p$\")SMx6F[p$\")SA))>F[p$\")S#eO#F[pFfpFdpFbpF`pF^pF\\pFio71$ \"&+S'!\"*$\"'+cmF]q$\"(+3I%F]q$\")+wX=F]q$\")?.[bF]q$\"*!oN,7F]q$\"*+ o:!>F]q$\"*+%y9AF]qFhqFfqFdqFbqF`qF^qF[q71$\"(+K%=!#5$\")+Ks7F_r$\")+7 0kF_r$\"*SyII#F_r$\"*![o+hF_r$\"+?$)377F_r$\"+g*oT#=F_r$\"++w\\*3#F_rF jrFhrFfrFdrFbrF`rF]r71$\")+?>S!#6$\"*+!G\"3#Fas$\"*!Gp.()Fas$\"++k3IFF as$\"++K?XlFas$\"+![+T@\"F_r$\"+g&=[v\"F_r$\"+WhO$)>F_rF\\tFjsFhsFfsFd sFbsF_s71$\"*+?zP(!#7$\"+g0*)pIFct$\"+[W')46Fas$\"+Oj;@JFas$\"+g,M,pFa s$\"+k!G.@\"F_r$\"+hWQ#p\"F_r$\"+5r%>*=F_rF^uF\\uFjtFhtFftFdtFat71$\"+ 7<@/7Fct$\"+K;A4UFct$\"+Z(\\:N\"Fas$\"+C2%\\Z$Fas$\"+\"\\$p&=(Fas$\"+M 0q-7F_r$\"+7d)ej\"F_r$\"+]?77=F_rF_vF]vF[vFiuFguFeuFcu71$\"+'p8_!=Fct$ \"+:[ZpaFct$\"+EC5!f\"Fas$\"+\"38Cz$Fas$\"+3`!=T(Fas$\"+L8^#>\"F_r$\"+ Wf\\%e\"F_r$\"+9viT#=Fas$\"+'RHe2%Fas$\"+n%)e!f(Fas$\"+&4U1=\"F_r$\"+O`_P:F_r$ \"+')[xy;F_rFaxF_xF]xF[xFiwFgwFew" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plots[listdensityplot](R);" }}}{EXCHG {PARA 3 "" 0 " " {TEXT -1 23 "Two-dimensional Arrays." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 56 "A two-dimenisional array is created with the command \+ " }{TEXT 257 19 "Array( k..l, m..n )" }{TEXT -1 10 " where " } {XPPEDIT 18 0 "k <= l,m <= n;" "6$1%\"kG%\"lG1%\"mG%\"nG" }{TEXT -1 84 " are integers. In Maple, a matrix is represented as a two-dimens ional array where " }{XPPEDIT 18 0 "k = 1,m = 1;" "6$/%\"kG\"\"\"/%\"m GF%" }{TEXT -1 15 ". For example\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "A := Array(1..3,1..3);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"AG-%'RTABLEG6$\"*gzio#-%'MATRIXG6#7%7%\"\"!F.F.F-F-" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 140 "Values are stored in the array an d accessed from the array in the same way as for one-dimensional array s except there is a double subscript." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 49 "A[1,1] := 2; for i from 2 to 3 do A[1,i] := i od;" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"AG6$\"\"\"F'\"\"#" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"AG6$\"\"\"\"\"#F(" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"AG6$\"\"\"\"\"$F(" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "A;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'RTABLEG6$\"*g zio#-%'MATRIXG6#7%7%\"\"#F,\"\"$7%\"\"!F/F/F." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 70 "A list of lists may be converted to a matrix and vice \+ versa as follows" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "L := [[ 1,2],[2,3]];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"LG7$7$\"\"\"\"\"#7 $F(\"\"$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "B := Array(L); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"BG-%'RTABLEG6$\"*g,xo#-%'MATRI XG6#7$7$\"\"\"\"\"#7$F/\"\"$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "M := convert(B,listlist);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>% \"MG7$7$\"\"\"\"\"#7$F(\"\"$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 505 " Now, once difference (very significant) between lists and vectors (one -dimensional arrays) and lists of lists and matrices (two-dimensional arrays) is that Maple keeps only one copy of a list with equal values , but there may be more than one copy of an Array with equal values. \+ Secondly, assigning new values to an array is quick, but assigning new values to a list is slow; it requires making a copy of the list. Thu s, the lists L and M above are the same list. The matrix C is a diffe rent copy of B." }}}{EXCHG {PARA 3 "" 0 "" {TEXT -1 15 "Tables in Mapl e" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 33 "You may create a table as fo llows" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "T := table();" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"TG-%&TABLEG6#7\"" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 280 "Tables are very much like arrays. The only di fference functionally is that in arrays you are restricted to a fixed \+ number of integer indices (subscripts) which must be in the prescribed range. In a table you may use any number of and any kind of value fo r an index. For example" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "T[sin] := cos;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"TG6#%$sinG%$co sG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "T[ \{[1,0,0],[1,0,1] \} ] := \{[0,0,0],[0,0,1]\};" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"T G6#<$7%\"\"\"\"\"!F*7%F)F*F)<$7%F*F*F*7%F*F*F)" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 22 "T[ H, H, O ] := water;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"TG6%%\"HGF'%\"OG%&waterG" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 376 "In the first assignment, the index is a symbol, sin, a nd it's corresponding entry in the table is also a symbol, cos. The s econd example has a set of two lists (representing a cycle) as an inde x and a set of two lists as the corresponding entry (representing the \+ transcient states in the basin of attraction for this cycle). The las t example has three indices for an index. " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 343 "The key property about tables is that you can store an ( index,entry) pair in a table in constant time, no matter how large the number of (index,entry) pairs are in the table. Secondly, for a give n index, you can lookup the table to see if it has a corresponding ent ry in constant time, and you can access that entry in constant time. \+ Example" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "assigned( T[H,H, O] );" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%%trueG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "assigned( T[C,O,O] );" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%&falseG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "T [sin];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%$cosG" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 97 "Thirdly, you can change and entry or remove an (in dex,entry) pair from a table in constant time." }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 29 "T[sin] := tan; # change entry" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"TG6#%$sinG%$tanG" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 7 "T[sin];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%$tanG" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "T[H,H,O] := evaln( T[H,H,O ] ); # remove entry" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"TG6%%\"HGF '%\"OGF$" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "T[H,H,O];" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#&%\"TG6%%\"HGF&%\"OG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 22 "Here is another table." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "T := table();" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #>%\"TG-%&TABLEG6#7\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 51 "T[ 1,1] := 1; T[1,0] := 0; T[0,1] := 0; T[0,0] := 0;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"TG6$\"\"\"F'F'" }}{PARA 11 "" 1 "" {XPPMATH 20 "6# >&%\"TG6$\"\"\"\"\"!F(" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"TG6$\" \"!\"\"\"F'" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"TG6$\"\"!F'F'" }}} {EXCHG {PARA 4 "" 0 "" {TEXT -1 34 "Getting Information out of tables. " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 69 "What are all the table indice s? What are all the entries in a table?" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "[indices(T)];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7&7$ \"\"\"\"\"!7$F%F%7$F&F%7$F&F&" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "[entries(T)];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7&7#\"\"!7#\"\" \"F$F$" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 136 "Maple's tables are has h-tables where the hash function is a function of the address of where the index object(s) are stored in memory. " }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 676 "Where would you use a table? To compute the basins of attraction for a network, the first time we are iterating we will fin d a cycle (of period >= 1). The next time we iterate and come to a cy cle and we will want to know if we have come to the same cycle. If we index a table by the cycle, represented as a Maple set of lists (corr esponding to the states in the cycle) and store as the table entry the set of states which are in that basin of attraction but not on the cy cle, then we can determine the basins of attraction quite efficiently. For example, if the first run to a cycle is [ [0,0,0], [1,0,0], [0,0 ,1],[1,0,0] ] then the cycle is \{[1,0,0],[0,0,1]\} and we store" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "BA[ \{[1,0,0],[0,0,1]\} ] := \{ [0,0,0] \};" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%#BAG6#<$7%\"\"\" \"\"!F*7%F*F*F)<#7%F*F*F*" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 74 "Supp ose now we start at state [1,1,1] and suppose we run to the same cycle " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "X := [ [1,1,1], [0,0,1] , [1,0,0], [0,0,1] ];" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"XG7&7%\" \"\"F'F'7%\"\"!F)F'7%F'F)F)F(" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 31 " We determine that the cycle is " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "C := \{ [0,0,1], [1,0,0] \}; " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"CG<$7%\"\"\"\"\"!F(7%F(F(F'" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 141 "which, notice, Maple has sorted into the same order as the pre vious cycle. Now we test whether we have come to a cycle we have seen before. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "assigned( BA[C ] );" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%%trueG" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 120 "We have, so we include the transcient states from t he second run in the basin of attraction corresponding to that cycle. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "T := \{ [1,1,1] \};" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"TG<#7%\"\"\"F'F'" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "BA[ C ] := BA[ C ] union T ;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%#BAG6#<$7%\"\"\"\"\"!F*7%F*F*F)<$7%F*F*F*7%F )F)F)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "95 0 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }{RTABLE_HANDLES 271775292 271836904 271837704 271838024 271838344 271838384 271838544 271838624 268627960 268770160 }{RTABLE M7R0 I6RTABLE_SAVE/271775292X*%)anythingG6"6"[gl!!%!!!"%"%""$""%""!F)F& } {RTABLE M7R0 I6RTABLE_SAVE/271836904X*%)anythingG6"6"[gl!!%!!!"%"%"""""#""$""%F& } {RTABLE M7R0 I6RTABLE_SAVE/271837704X*%)anythingG6"6"[gl!!%!!!"%"%""%""'""$F'F& } {RTABLE M7R0 I6RTABLE_SAVE/271838024X*%)anythingG6"6"[gl!!%!!!"%"%""$"")""!F)F& } {RTABLE M7R0 I6RTABLE_SAVE/271838344X*%)anythingG6"6"[gl!!%!!!"%"%""$""%""!F)F& } {RTABLE M7R0 I6RTABLE_SAVE/271838384X*%)anythingG6"6"[gl!!%!!!"%!$"""""#""$""%F& } {RTABLE M7R0 I6RTABLE_SAVE/271838544X*%)anythingG6"6"[gl!!%!!!"'"'"""""!F'F'F(F(F& } {RTABLE M7R0 I6RTABLE_SAVE/271838624X*%)anythingG6"6"[gl!!%!!!"'"'""!"""F'F'F(F(F& } {RTABLE M7R0 I6RTABLE_SAVE/268627960X,%)anythingG6"6"[gl!!%!!!#*"$"$""#""!F(F'F(F(""$F(F(F& } {RTABLE M7R0 I6RTABLE_SAVE/268770160X,%)anythingG6"6"[gl!!%!!!#%"#"#"""""#F(""$F& }