home *** CD-ROM | disk | FTP | other *** search
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: LaTeX Document
(document/latex).
Confidence | Program | Detection | Match Type | Support
|
---|
100%
| dexvert
| LaTeX Document (document/latex)
| magic
| Supported |
1%
| dexvert
| Corel 10 Texture (image/corel10Texture)
| ext
| Unsupported |
1%
| dexvert
| Croteam texture file (image/croteamTextureFile)
| ext
| Unsupported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| C++ source text
| default
| |
99%
| file
| LaTeX document text
| default
| |
98%
| file
| LaTeX document, ASCII text, with CRLF line terminators
| default
| |
100%
| checkBytes
| Printable ASCII
| default
| |
100%
| perlTextCheck
| Likely Text (Perl)
| default
| |
100%
| siegfried
| fmt/281 LaTeX (Subdocument)
| default
| |
100%
| detectItEasy
| Format: plain text[CRLF]
| default (weak)
|
|
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 5c 63 68 61 70 74 65 72 | 7b 56 69 72 74 75 61 6c |\chapter|{Virtual|
|00000010| 20 4d 61 74 72 69 63 65 | 73 7d 0d 0a 0d 0a 0d 0a | Matrice|s}......|
|00000020| 49 6e 20 74 68 65 20 76 | 69 72 74 75 61 6c 20 6d |In the v|irtual m|
|00000030| 65 6d 6f 72 79 20 76 65 | 72 73 69 6f 6e 2c 20 74 |emory ve|rsion, t|
|00000040| 68 65 20 76 69 72 74 75 | 61 6c 20 6d 61 74 72 69 |he virtu|al matri|
|00000050| 78 0d 0a 63 6c 73 61 73 | 73 5c 69 6e 64 65 78 7b |x..clsas|s\index{|
|00000060| 56 4d 61 74 72 69 78 20 | 7d 20 69 73 20 64 65 72 |VMatrix |} is der|
|00000070| 69 76 65 64 20 66 72 6f | 6d 20 74 68 65 20 76 69 |ived fro|m the vi|
|00000080| 72 74 75 61 6c 20 76 65 | 63 74 6f 72 2e 20 54 68 |rtual ve|ctor. Th|
|00000090| 75 73 2c 0d 0a 62 65 66 | 6f 72 65 20 74 68 65 20 |us,..bef|ore the |
|000000a0| 56 4d 61 74 72 69 78 20 | 69 73 20 63 6f 6e 73 74 |VMatrix |is const|
|000000b0| 72 75 63 74 65 64 2c 20 | 74 68 65 20 63 6f 6e 73 |ructed, |the cons|
|000000c0| 74 72 75 63 74 6f 72 20 | 66 6f 72 20 61 20 76 64 |tructor |for a vd|
|000000d0| 6f 75 62 0d 0a 69 73 20 | 63 61 6c 6c 65 64 2e 20 |oub..is |called. |
|000000e0| 54 68 65 20 6d 65 6d 62 | 65 72 73 20 6f 66 20 76 |The memb|ers of v|
|000000f0| 64 6f 75 62 20 61 72 65 | 20 70 72 69 76 61 74 65 |doub are| private|
|00000100| 20 74 6f 20 74 68 65 20 | 56 4d 61 74 72 69 78 0d | to the |VMatrix.|
|00000110| 0a 63 6c 61 73 73 2c 20 | 73 6f 20 74 68 65 79 20 |.class, |so they |
|00000120| 61 72 65 20 61 76 61 69 | 6c 61 62 6c 65 20 74 6f |are avai|lable to|
|00000130| 20 74 68 65 20 6d 65 6d | 62 65 72 20 66 75 6e 63 | the mem|ber func|
|00000140| 74 69 6f 6e 73 20 6f 66 | 20 56 4d 61 74 72 69 78 |tions of| VMatrix|
|00000150| 2e 0d 0a 54 68 65 20 6d | 61 74 72 69 78 20 63 6c |...The m|atrix cl|
|00000160| 61 73 73 20 73 74 6f 72 | 65 73 20 69 74 73 20 65 |ass stor|es its e|
|00000170| 6c 65 6d 65 6e 74 73 20 | 69 6e 20 61 20 76 69 72 |lements |in a vir|
|00000180| 74 75 61 6c 20 76 65 63 | 74 6f 72 20 69 6e 20 72 |tual vec|tor in r|
|00000190| 6f 77 0d 0a 6d 61 6a 6f | 72 20 6f 72 64 65 72 2e |ow..majo|r order.|
|000001a0| 20 54 68 61 74 20 69 73 | 2c 20 74 68 65 20 72 6f | That is|, the ro|
|000001b0| 77 73 20 6f 66 20 74 68 | 65 20 6d 61 74 72 69 78 |ws of th|e matrix|
|000001c0| 20 61 72 65 20 73 74 6f | 72 65 64 0d 0a 73 65 71 | are sto|red..seq|
|000001d0| 75 65 6e 74 69 61 6c 6c | 79 20 69 6e 20 74 68 65 |uentiall|y in the|
|000001e0| 20 76 65 63 74 6f 72 2e | 20 41 63 63 65 73 73 20 | vector.| Access |
|000001f0| 61 6e 64 20 73 74 6f 72 | 61 67 65 20 6f 66 20 74 |and stor|age of t|
|00000200| 68 65 20 6d 61 74 72 69 | 78 0d 0a 65 6c 65 6d 65 |he matri|x..eleme|
|00000210| 6e 74 73 20 69 73 20 61 | 63 68 69 65 76 65 64 20 |nts is a|chieved |
|00000220| 74 68 72 6f 75 67 68 20 | 76 64 6f 75 62 3a 3a 6f |through |vdoub::o|
|00000230| 70 65 72 61 74 6f 72 5b | 5d 2e 0d 0a 0d 0a 41 20 |perator[|].....A |
|00000240| 66 75 6c 6c 20 73 65 74 | 20 6f 66 20 66 75 6e 63 |full set| of func|
|00000250| 74 69 6f 6e 73 20 69 73 | 20 63 72 65 61 74 65 64 |tions is| created|
|00000260| 20 66 6f 72 20 74 68 65 | 20 6d 61 74 72 69 78 20 | for the| matrix |
|00000270| 63 6c 61 73 73 2e 0d 0a | 41 73 73 69 67 6e 6d 65 |class...|Assignme|
|00000280| 6e 74 20 6f 66 20 6d 61 | 74 72 69 63 65 73 20 61 |nt of ma|trices a|
|00000290| 6e 64 20 65 6c 65 6d 65 | 6e 74 73 20 69 73 20 64 |nd eleme|nts is d|
|000002a0| 65 76 65 6c 6f 70 65 64 | 2e 20 46 75 6e 63 74 69 |eveloped|. Functi|
|000002b0| 6f 6e 73 0d 0a 61 72 65 | 20 61 6c 73 6f 20 63 72 |ons..are| also cr|
|000002c0| 65 61 74 65 64 20 66 6f | 72 0d 0a 5c 62 65 67 69 |eated fo|r..\begi|
|000002d0| 6e 7b 65 6e 75 6d 65 72 | 61 74 65 7d 0d 0a 20 5c |n{enumer|ate}.. \|
|000002e0| 69 74 65 6d 20 6d 61 6e | 69 70 75 6c 61 74 69 6e |item man|ipulatin|
|000002f0| 67 20 74 68 65 20 6d 61 | 74 72 69 78 20 6e 61 6d |g the ma|trix nam|
|00000300| 65 2c 20 0d 0a 20 5c 69 | 74 65 6d 20 66 6f 72 20 |e, .. \i|tem for |
|00000310| 64 69 73 70 6c 61 79 69 | 6e 67 20 6d 61 74 72 69 |displayi|ng matri|
|00000320| 78 20 69 6e 66 6f 72 6d | 61 74 69 6f 6e 2c 20 0d |x inform|ation, .|
|00000330| 0a 20 5c 69 74 65 6d 20 | 66 6f 72 20 61 72 69 74 |. \item |for arit|
|00000340| 68 6d 65 74 69 63 20 6f | 70 65 72 61 74 69 6f 6e |hmetic o|peration|
|00000350| 73 2c 0d 0a 20 5c 69 74 | 65 6d 20 66 6f 72 20 64 |s,.. \it|em for d|
|00000360| 61 74 61 20 69 6f 2c 20 | 0d 0a 20 5c 69 74 65 6d |ata io, |.. \item|
|00000370| 20 66 6f 72 20 6d 61 74 | 72 69 78 20 66 75 6e 63 | for mat|rix func|
|00000380| 74 69 6f 6e 73 2c 20 0d | 0a 20 5c 69 74 65 6d 20 |tions, .|. \item |
|00000390| 66 6f 72 20 72 65 63 75 | 72 73 69 76 65 20 63 61 |for recu|rsive ca|
|000003a0| 6c 63 75 6c 61 74 69 6f | 6e 73 2c 20 0d 0a 20 5c |lculatio|ns, .. \|
|000003b0| 69 74 65 6d 20 61 6e 64 | 20 6e 65 73 74 65 64 20 |item and| nested |
|000003c0| 66 75 6e 63 74 69 6f 6e | 20 63 61 6c 6c 73 2e 20 |function| calls. |
|000003d0| 20 0d 0a 5c 65 6e 64 7b | 65 6e 75 6d 65 72 61 74 | ..\end{|enumerat|
|000003e0| 65 7d 0d 0a 4d 75 63 68 | 20 6f 66 20 74 68 69 73 |e}..Much| of this|
|000003f0| 20 69 73 20 61 63 63 6f | 6d 70 6c 69 73 68 65 64 | is acco|mplished|
|00000400| 20 75 73 69 6e 67 20 61 | 20 73 74 61 63 6b 20 6f | using a| stack o|
|00000410| 66 20 76 69 72 74 75 61 | 6c 20 6d 61 74 72 69 63 |f virtua|l matric|
|00000420| 65 73 0d 0a 77 68 69 63 | 68 20 77 69 6c 6c 20 62 |es..whic|h will b|
|00000430| 65 20 64 69 73 63 75 73 | 73 65 64 20 69 6e 20 6d |e discus|sed in m|
|00000440| 6f 72 65 20 64 65 74 61 | 69 6c 20 6c 61 74 65 72 |ore deta|il later|
|00000450| 2e 20 46 6f 72 20 6e 6f | 77 2c 20 69 74 20 69 73 |. For no|w, it is|
|00000460| 0d 0a 73 75 66 66 69 63 | 69 65 6e 74 20 74 6f 20 |..suffic|ient to |
|00000470| 73 61 79 20 74 68 61 74 | 20 74 68 65 20 6d 61 74 |say that| the mat|
|00000480| 72 69 78 20 73 74 61 63 | 6b 20 69 73 20 61 20 64 |rix stac|k is a d|
|00000490| 65 72 69 76 65 64 20 63 | 6c 61 73 73 20 6f 66 0d |erived c|lass of.|
|000004a0| 0a 56 4d 61 74 72 69 78 | 2c 20 62 75 74 20 6d 61 |.VMatrix|, but ma|
|000004b0| 6e 79 20 6f 66 20 74 68 | 65 20 70 75 62 6c 69 63 |ny of th|e public|
|000004c0| 20 66 75 6e 63 74 69 6f | 6e 73 20 6f 66 20 74 68 | functio|ns of th|
|000004d0| 65 20 73 74 61 63 6b 20 | 63 6c 61 73 73 20 61 72 |e stack |class ar|
|000004e0| 65 0d 0a 75 73 65 64 20 | 69 6e 20 56 4d 61 74 72 |e..used |in VMatr|
|000004f0| 69 78 2e 20 54 68 75 73 | 20 74 68 65 20 74 77 6f |ix. Thus| the two|
|00000500| 20 63 6c 61 73 73 65 73 | 20 66 6f 72 6d 20 73 6f | classes| form so|
|00000510| 6d 65 74 68 69 6e 67 20 | 6f 66 20 61 0d 0a 73 79 |mething |of a..sy|
|00000520| 6d 62 69 6f 73 69 73 20 | 72 61 74 68 65 72 20 74 |mbiosis |rather t|
|00000530| 68 61 6e 20 61 20 73 74 | 72 69 63 74 20 68 69 65 |han a st|rict hie|
|00000540| 72 61 72 63 68 79 2e 20 | 20 54 68 65 20 73 74 61 |rarchy. | The sta|
|00000550| 63 6b 20 62 61 73 65 20 | 69 73 0d 0a 63 61 6c 6c |ck base |is..call|
|00000560| 65 64 20 44 69 73 70 61 | 74 63 68 5c 69 6e 64 65 |ed Dispa|tch\inde|
|00000570| 78 7b 4d 53 74 61 63 6b | 21 44 69 73 70 61 74 63 |x{MStack|!Dispatc|
|00000580| 68 7d 2c 20 61 6e 64 20 | 61 6c 6c 20 6f 74 68 65 |h}, and |all othe|
|00000590| 72 20 73 74 61 63 6b 0d | 0a 6d 61 74 72 69 63 65 |r stack.|.matrice|
|000005a0| 73 20 61 72 65 20 75 6e | 61 63 63 65 73 73 69 62 |s are un|accessib|
|000005b0| 6c 65 20 74 6f 20 6f 74 | 68 65 72 20 66 75 6e 63 |le to ot|her func|
|000005c0| 74 69 6f 6e 73 2e 0d 0a | 0d 0a 5c 73 65 63 74 69 |tions...|..\secti|
|000005d0| 6f 6e 7b 54 68 65 20 44 | 65 63 6c 61 72 61 74 69 |on{The D|eclarati|
|000005e0| 6f 6e 20 6f 66 20 74 68 | 65 20 56 4d 61 74 72 69 |on of th|e VMatri|
|000005f0| 78 20 43 6c 61 73 73 7d | 0d 0a 0d 0a 54 68 65 20 |x Class}|....The |
|00000600| 76 69 72 74 75 61 6c 20 | 6d 61 74 72 69 78 20 56 |virtual |matrix V|
|00000610| 4d 61 74 72 69 78 20 63 | 6c 61 73 73 20 69 73 20 |Matrix c|lass is |
|00000620| 63 72 65 61 74 65 64 20 | 62 79 20 74 68 65 20 66 |created |by the f|
|00000630| 6f 6c 6c 6f 77 69 6e 67 | 20 64 65 63 6c 61 72 61 |ollowing| declara|
|00000640| 74 69 6f 6e 0d 0a 5c 62 | 65 67 69 6e 7b 76 65 72 |tion..\b|egin{ver|
|00000650| 62 61 74 69 6d 7d 0d 0a | 63 6c 61 73 73 20 56 4d |batim}..|class VM|
|00000660| 61 74 72 69 78 20 3a 20 | 70 72 69 76 61 74 65 20 |atrix : |private |
|00000670| 76 64 6f 75 62 0d 0a 20 | 7b 0d 0a 0d 0a 20 70 72 |vdoub.. |{.... pr|
|00000680| 6f 74 65 63 74 65 64 3a | 0d 0a 20 20 20 75 6e 73 |otected:|.. uns|
|00000690| 69 67 6e 65 64 20 73 69 | 67 6e 61 74 75 72 65 3b |igned si|gnature;|
|000006a0| 0d 0a 20 20 20 6c 6f 6e | 67 20 6d 69 6e 64 65 78 |.. lon|g mindex|
|000006b0| 28 20 69 6e 74 20 69 2c | 20 69 6e 74 20 6a 29 7b |( int i,| int j){|
|000006c0| 0d 0a 20 20 20 20 20 20 | 20 20 72 65 74 75 72 6e |.. | return|
|000006d0| 20 20 20 28 6c 6f 6e 67 | 29 20 28 28 28 6c 6f 6e | (long|) (((lon|
|000006e0| 67 29 28 69 2d 31 29 29 | 2a 28 28 6c 6f 6e 67 29 |g)(i-1))|*((long)|
|000006f0| 63 29 2b 28 28 6c 6f 6e | 67 29 28 6a 2d 31 29 29 |c)+((lon|g)(j-1))|
|00000700| 29 20 3b 20 7d 0d 0a 20 | 20 20 6c 6f 6e 67 20 63 |) ; }.. | long c|
|00000710| 75 72 76 65 63 69 6e 64 | 3b 20 20 20 20 20 20 20 |urvecind|; |
|00000720| 2f 2f 20 63 75 72 72 65 | 6e 74 20 69 6e 64 65 78 |// curre|nt index|
|00000730| 20 66 6f 72 20 76 65 63 | 74 6f 72 0d 0a 20 20 20 | for vec|tor.. |
|00000740| 73 74 72 74 79 70 65 20 | 6e 61 6d 65 3b 0d 0a 20 |strtype |name;.. |
|00000750| 20 20 76 6f 69 64 20 53 | 65 74 75 70 56 65 63 74 | void S|etupVect|
|00000760| 6f 72 73 28 20 69 6e 74 | 20 72 72 3d 31 2c 20 69 |ors( int| rr=1, i|
|00000770| 6e 74 20 63 63 3d 31 20 | 29 3b 0d 0a 20 20 20 76 |nt cc=1 |);.. v|
|00000780| 6f 69 64 20 50 75 72 67 | 65 56 65 63 74 6f 72 73 |oid Purg|eVectors|
|00000790| 28 20 76 6f 69 64 20 29 | 3b 0d 0a 20 20 20 76 6f |( void )|;.. vo|
|000007a0| 69 64 20 52 65 70 6c 61 | 63 65 28 20 56 4d 61 74 |id Repla|ce( VMat|
|000007b0| 72 69 78 20 26 52 4f 70 | 20 29 3b 0d 0a 20 20 20 |rix &ROp| );.. |
|000007c0| 76 6f 69 64 20 4e 65 77 | 52 65 66 65 72 65 6e 63 |void New|Referenc|
|000007d0| 65 28 56 4d 61 74 72 69 | 78 20 26 52 4f 70 20 29 |e(VMatri|x &ROp )|
|000007e0| 3b 0d 0a 0d 0a 20 70 75 | 62 6c 69 63 3a 0d 0a 0d |;.... pu|blic:...|
|000007f0| 0a 20 20 20 64 6f 75 62 | 6c 65 20 4e 72 65 72 72 |. doub|le Nrerr|
|00000800| 6f 72 28 20 63 6f 6e 73 | 74 20 63 68 61 72 20 2a |or( cons|t char *|
|00000810| 65 72 72 6f 72 6d 73 67 | 20 29 3b 0d 0a 20 20 20 |errormsg| );.. |
|00000820| 76 6f 69 64 20 47 61 72 | 62 61 67 65 28 20 63 6f |void Gar|bage( co|
|00000830| 6e 73 74 20 63 68 61 72 | 20 2a 65 72 72 6f 72 6d |nst char| *errorm|
|00000840| 73 67 29 3b 0d 0a 20 20 | 20 76 6f 69 64 20 47 61 |sg);.. | void Ga|
|00000850| 72 62 61 67 65 28 20 76 | 6f 69 64 20 29 7b 20 47 |rbage( v|oid ){ G|
|00000860| 61 72 62 61 67 65 28 22 | 20 22 29 3b 7d 0d 0a 20 |arbage("| ");}.. |
|00000870| 20 20 69 6e 74 20 72 2c | 63 3b 0d 0a 0d 0a 20 20 | int r,|c;.... |
|00000880| 20 64 6f 75 62 6c 65 20 | 6d 28 20 69 6e 74 20 69 | double |m( int i|
|00000890| 2c 20 69 6e 74 20 6a 20 | 29 20 7b 20 20 20 20 20 |, int j |) { |
|000008a0| 20 20 20 20 20 2f 2f 20 | 67 65 74 20 61 20 76 61 | // |get a va|
|000008b0| 6c 75 65 0d 0a 20 20 20 | 20 20 20 20 69 66 28 20 |lue.. | if( |
|000008c0| 69 3c 31 20 7c 7c 20 6a | 3c 31 20 7c 7c 20 69 3e |i<1 || j|<1 || i>|
|000008d0| 72 20 7c 7c 20 6a 3e 63 | 20 29 7b 0d 0a 20 20 20 |r || j>c| ){.. |
|000008e0| 20 20 20 20 63 65 72 72 | 20 3c 3c 20 22 69 6e 64 | cerr| << "ind|
|000008f0| 65 78 20 6f 75 74 20 6f | 66 20 72 61 6e 67 65 5c |ex out o|f range\|
|00000900| 6e 22 3b 0d 0a 20 20 20 | 20 20 20 20 65 78 69 74 |n";.. | exit|
|00000910| 28 31 29 3b 0d 0a 20 20 | 20 20 20 20 20 7d 0d 0a |(1);.. | }..|
|00000920| 20 20 20 20 20 20 20 63 | 75 72 76 65 63 69 6e 64 | c|urvecind|
|00000930| 20 3d 20 6d 69 6e 64 65 | 78 28 69 2c 6a 29 3b 0d | = minde|x(i,j);.|
|00000940| 0a 20 20 20 20 20 20 20 | 72 65 74 75 72 6e 20 76 |. |return v|
|00000950| 28 20 63 75 72 76 65 63 | 69 6e 64 20 29 3b 0d 0a |( curvec|ind );..|
|00000960| 20 20 20 7d 0d 0a 20 20 | 20 56 4d 61 74 72 69 78 | }.. | VMatrix|
|00000970| 26 20 4d 28 20 69 6e 74 | 20 69 2c 20 69 6e 74 20 |& M( int| i, int |
|00000980| 6a 20 29 20 7b 20 2f 2f | 20 6c 6f 61 64 20 63 75 |j ) { //| load cu|
|00000990| 72 72 65 6e 74 20 62 75 | 66 66 65 72 0d 0a 20 20 |rrent bu|ffer.. |
|000009a0| 20 20 20 20 20 20 63 75 | 72 76 65 63 69 6e 64 20 | cu|rvecind |
|000009b0| 3d 20 6d 69 6e 64 65 78 | 28 69 2c 6a 29 3b 0d 0a |= mindex|(i,j);..|
|000009c0| 20 20 20 20 20 20 20 20 | 76 64 6f 75 62 3a 3a 6f | |vdoub::o|
|000009d0| 70 65 72 61 74 6f 72 5b | 5d 28 63 75 72 76 65 63 |perator[|](curvec|
|000009e0| 69 6e 64 29 3b 0d 0a 20 | 20 20 20 20 20 20 20 72 |ind);.. | r|
|000009f0| 65 74 75 72 6e 20 2a 74 | 68 69 73 3b 0d 0a 20 20 |eturn *t|his;.. |
|00000a00| 20 7d 0d 0a 0d 0a 20 20 | 20 56 4d 61 74 72 69 78 | }.... | VMatrix|
|00000a10| 28 20 76 6f 69 64 20 29 | 3b 20 20 20 20 20 20 20 |( void )|; |
|00000a20| 20 20 20 20 20 2f 2f 20 | 63 6f 6e 73 74 72 75 63 | // |construc|
|00000a30| 74 6f 72 73 20 61 6e 64 | 20 64 65 73 74 72 75 63 |tors and| destruc|
|00000a40| 74 6f 72 73 0d 0a 20 20 | 20 56 4d 61 74 72 69 78 |tors.. | VMatrix|
|00000a50| 28 20 63 6f 6e 73 74 20 | 63 68 61 72 20 2a 73 74 |( const |char *st|
|00000a60| 72 2c 20 69 6e 74 20 69 | 2c 20 69 6e 74 20 6a 29 |r, int i|, int j)|
|00000a70| 3b 0d 0a 20 20 20 56 4d | 61 74 72 69 78 28 20 56 |;.. VM|atrix( V|
|00000a80| 4d 61 74 72 69 78 20 26 | 52 4f 70 20 29 3b 0d 0a |Matrix &|ROp );..|
|00000a90| 20 20 20 7e 56 4d 61 74 | 72 69 78 28 20 76 6f 69 | ~VMat|rix( voi|
|00000aa0| 64 20 29 3b 0d 0a 0d 0a | 20 20 20 64 6f 75 62 6c |d );....| doubl|
|00000ab0| 65 20 6f 70 65 72 61 74 | 6f 72 20 3d 20 28 20 64 |e operat|or = ( d|
|00000ac0| 6f 75 62 6c 65 20 64 20 | 29 7b 20 20 20 20 20 2f |ouble d |){ /|
|00000ad0| 2f 20 77 72 69 74 65 20 | 69 6e 20 61 20 76 61 6c |/ write |in a val|
|00000ae0| 75 65 0d 0a 20 20 20 20 | 20 76 64 6f 75 62 3a 3a |ue.. | vdoub::|
|00000af0| 6f 70 65 72 61 74 6f 72 | 5b 5d 28 63 75 72 76 65 |operator|[](curve|
|00000b00| 63 69 6e 64 29 20 3d 20 | 64 3b 0d 0a 20 20 20 20 |cind) = |d;.. |
|00000b10| 20 72 65 74 75 72 6e 20 | 64 3b 0d 0a 20 20 20 7d | return |d;.. }|
|00000b20| 0d 0a 20 20 20 76 6f 69 | 64 20 6f 70 65 72 61 74 |.. voi|d operat|
|00000b30| 6f 72 3d 20 28 56 4d 61 | 74 72 69 78 20 26 52 4f |or= (VMa|trix &RO|
|00000b40| 70 29 3b 0d 0a 0d 0a 20 | 20 20 76 6f 69 64 20 4e |p);.... | void N|
|00000b50| 61 6d 65 69 74 28 20 63 | 6f 6e 73 74 20 63 68 61 |ameit( c|onst cha|
|00000b60| 72 20 2a 73 74 72 20 29 | 20 7b 20 6e 61 6d 65 20 |r *str )| { name |
|00000b70| 3d 20 73 74 72 3b 20 7d | 0d 0a 20 20 20 76 6f 69 |= str; }|.. voi|
|00000b80| 64 20 4e 61 6d 65 69 74 | 28 20 56 4d 61 74 72 69 |d Nameit|( VMatri|
|00000b90| 78 20 26 6d 61 74 20 29 | 7b 20 6e 61 6d 65 20 3d |x &mat )|{ name =|
|00000ba0| 20 6d 61 74 2e 6e 61 6d | 65 3b 20 7d 0d 0a 20 20 | mat.nam|e; }.. |
|00000bb0| 20 76 6f 69 64 20 4e 61 | 6d 65 69 74 28 20 73 74 | void Na|meit( st|
|00000bc0| 72 74 79 70 65 20 6e 65 | 77 6e 61 6d 65 29 7b 20 |rtype ne|wname){ |
|00000bd0| 6e 61 6d 65 20 3d 20 6e | 65 77 6e 61 6d 65 3b 20 |name = n|ewname; |
|00000be0| 7d 0d 0a 20 20 20 73 74 | 72 74 79 70 65 20 47 65 |}.. st|rtype Ge|
|00000bf0| 74 6e 61 6d 65 28 20 56 | 4d 61 74 72 69 78 20 26 |tname( V|Matrix &|
|00000c00| 6d 61 74 29 7b 20 72 65 | 74 75 72 6e 20 6d 61 74 |mat){ re|turn mat|
|00000c10| 2e 6e 61 6d 65 3b 20 7d | 0d 0a 20 20 20 76 6f 69 |.name; }|.. voi|
|00000c20| 64 20 53 68 6f 77 6e 61 | 6d 65 28 20 76 6f 69 64 |d Showna|me( void|
|00000c30| 20 29 7b 20 6e 61 6d 65 | 2e 53 68 6f 77 6e 61 6d | ){ name|.Shownam|
|00000c40| 65 28 29 3b 20 7d 0d 0a | 20 20 20 63 68 61 72 20 |e(); }..| char |
|00000c50| 2a 53 74 72 69 6e 67 41 | 64 64 72 65 73 73 28 20 |*StringA|ddress( |
|00000c60| 76 6f 69 64 20 29 20 7b | 20 72 65 74 75 72 6e 20 |void ) {| return |
|00000c70| 6e 61 6d 65 2e 53 74 72 | 69 6e 67 41 64 64 72 65 |name.Str|ingAddre|
|00000c80| 73 73 28 29 3b 20 7d 0d | 0a 0d 0a 20 20 20 76 6f |ss(); }.|... vo|
|00000c90| 69 64 20 4c 6f 61 64 4d | 61 74 28 76 6f 69 64 29 |id LoadM|at(void)|
|00000ca0| 3b 0d 0a 20 20 20 76 6f | 69 64 20 44 69 73 70 6c |;.. vo|id Displ|
|00000cb0| 61 79 4d 61 74 28 76 6f | 69 64 29 3b 0d 0a 20 20 |ayMat(vo|id);.. |
|00000cc0| 20 76 6f 69 64 20 49 6e | 66 6f 4d 61 74 28 20 76 | void In|foMat( v|
|00000cd0| 6f 69 64 20 29 3b 0d 0a | 20 20 20 76 6f 69 64 20 |oid );..| void |
|00000ce0| 57 72 69 74 65 62 20 28 | 63 68 61 72 20 2a 66 69 |Writeb (|char *fi|
|00000cf0| 64 2c 20 56 4d 61 74 72 | 69 78 20 26 6d 61 74 29 |d, VMatr|ix &mat)|
|00000d00| 3b 0d 0a 0d 0a 20 20 20 | 66 72 69 65 6e 64 20 56 |;.... |friend V|
|00000d10| 4d 61 74 72 69 78 26 20 | 6f 70 65 72 61 74 6f 72 |Matrix& |operator|
|00000d20| 2b 20 28 56 4d 61 74 72 | 69 78 20 26 4c 4f 70 2c |+ (VMatr|ix &LOp,|
|00000d30| 20 56 4d 61 74 72 69 78 | 20 26 52 4f 70 29 3b 0d | VMatrix| &ROp);.|
|00000d40| 0a 20 20 20 66 72 69 65 | 6e 64 20 56 4d 61 74 72 |. frie|nd VMatr|
|00000d50| 69 78 26 20 6f 70 65 72 | 61 74 6f 72 2b 20 28 64 |ix& oper|ator+ (d|
|00000d60| 6f 75 62 6c 65 20 73 63 | 61 6c 61 72 2c 20 56 4d |ouble sc|alar, VM|
|00000d70| 61 74 72 69 78 20 26 52 | 4f 70 29 3b 0d 0a 20 20 |atrix &R|Op);.. |
|00000d80| 20 66 72 69 65 6e 64 20 | 56 4d 61 74 72 69 78 26 | friend |VMatrix&|
|00000d90| 20 6f 70 65 72 61 74 6f | 72 2b 20 28 56 4d 61 74 | operato|r+ (VMat|
|00000da0| 72 69 78 20 26 52 4f 70 | 2c 20 64 6f 75 62 6c 65 |rix &ROp|, double|
|00000db0| 20 73 63 61 6c 61 72 29 | 3b 0d 0a 20 20 20 66 72 | scalar)|;.. fr|
|00000dc0| 69 65 6e 64 20 56 4d 61 | 74 72 69 78 26 20 6f 70 |iend VMa|trix& op|
|00000dd0| 65 72 61 74 6f 72 2d 20 | 28 56 4d 61 74 72 69 78 |erator- |(VMatrix|
|00000de0| 20 26 4c 4f 70 2c 20 56 | 4d 61 74 72 69 78 20 26 | &LOp, V|Matrix &|
|00000df0| 52 4f 70 29 3b 0d 0a 20 | 20 20 66 72 69 65 6e 64 |ROp);.. | friend|
|00000e00| 20 56 4d 61 74 72 69 78 | 26 20 6f 70 65 72 61 74 | VMatrix|& operat|
|00000e10| 6f 72 2d 20 28 64 6f 75 | 62 6c 65 20 73 63 61 6c |or- (dou|ble scal|
|00000e20| 61 72 2c 20 56 4d 61 74 | 72 69 78 20 26 52 4f 70 |ar, VMat|rix &ROp|
|00000e30| 29 3b 0d 0a 20 20 20 66 | 72 69 65 6e 64 20 56 4d |);.. f|riend VM|
|00000e40| 61 74 72 69 78 26 20 6f | 70 65 72 61 74 6f 72 2d |atrix& o|perator-|
|00000e50| 20 28 56 4d 61 74 72 69 | 78 20 26 52 4f 70 2c 20 | (VMatri|x &ROp, |
|00000e60| 64 6f 75 62 6c 65 20 73 | 63 61 6c 61 72 29 3b 0d |double s|calar);.|
|00000e70| 0a 20 20 20 66 72 69 65 | 6e 64 20 56 4d 61 74 72 |. frie|nd VMatr|
|00000e80| 69 78 26 20 6f 70 65 72 | 61 74 6f 72 2d 20 28 56 |ix& oper|ator- (V|
|00000e90| 4d 61 74 72 69 78 20 26 | 52 4f 70 29 3b 0d 0a 20 |Matrix &|ROp);.. |
|00000ea0| 20 20 66 72 69 65 6e 64 | 20 56 4d 61 74 72 69 78 | friend| VMatrix|
|00000eb0| 26 20 6f 70 65 72 61 74 | 6f 72 2a 20 28 56 4d 61 |& operat|or* (VMa|
|00000ec0| 74 72 69 78 20 26 4c 4f | 70 2c 20 56 4d 61 74 72 |trix &LO|p, VMatr|
|00000ed0| 69 78 20 26 52 4f 70 29 | 3b 0d 0a 20 20 20 66 72 |ix &ROp)|;.. fr|
|00000ee0| 69 65 6e 64 20 56 4d 61 | 74 72 69 78 26 20 6f 70 |iend VMa|trix& op|
|00000ef0| 65 72 61 74 6f 72 2a 20 | 28 64 6f 75 62 6c 65 20 |erator* |(double |
|00000f00| 73 63 61 6c 61 72 2c 20 | 56 4d 61 74 72 69 78 20 |scalar, |VMatrix |
|00000f10| 26 52 4f 70 29 3b 0d 0a | 20 20 20 66 72 69 65 6e |&ROp);..| frien|
|00000f20| 64 20 56 4d 61 74 72 69 | 78 26 20 6f 70 65 72 61 |d VMatri|x& opera|
|00000f30| 74 6f 72 2a 20 28 56 4d | 61 74 72 69 78 20 26 52 |tor* (VM|atrix &R|
|00000f40| 4f 70 2c 20 64 6f 75 62 | 6c 65 20 73 63 61 6c 61 |Op, doub|le scala|
|00000f50| 72 29 3b 0d 0a 20 20 20 | 66 72 69 65 6e 64 20 56 |r);.. |friend V|
|00000f60| 4d 61 74 72 69 78 26 20 | 6f 70 65 72 61 74 6f 72 |Matrix& |operator|
|00000f70| 25 20 28 56 4d 61 74 72 | 69 78 20 26 4c 4f 70 2c |% (VMatr|ix &LOp,|
|00000f80| 20 56 4d 61 74 72 69 78 | 20 26 52 4f 70 20 29 3b | VMatrix| &ROp );|
|00000f90| 0d 0a 20 20 20 66 72 69 | 65 6e 64 20 56 4d 61 74 |.. fri|end VMat|
|00000fa0| 72 69 78 26 20 6f 70 65 | 72 61 74 6f 72 2f 20 28 |rix& ope|rator/ (|
|00000fb0| 56 4d 61 74 72 69 78 20 | 26 4c 4f 70 2c 20 56 4d |VMatrix |&LOp, VM|
|00000fc0| 61 74 72 69 78 20 26 52 | 4f 70 29 3b 0d 0a 20 20 |atrix &R|Op);.. |
|00000fd0| 20 66 72 69 65 6e 64 20 | 56 4d 61 74 72 69 78 26 | friend |VMatrix&|
|00000fe0| 20 6f 70 65 72 61 74 6f | 72 2f 20 28 56 4d 61 74 | operato|r/ (VMat|
|00000ff0| 72 69 78 20 26 52 4f 70 | 2c 20 64 6f 75 62 6c 65 |rix &ROp|, double|
|00001000| 20 73 63 61 6c 61 72 29 | 3b 0d 0a 20 20 20 66 72 | scalar)|;.. fr|
|00001010| 69 65 6e 64 20 56 4d 61 | 74 72 69 78 26 20 6f 70 |iend VMa|trix& op|
|00001020| 65 72 61 74 6f 72 2f 20 | 28 64 6f 75 62 6c 65 20 |erator/ |(double |
|00001030| 73 63 61 6c 61 72 2c 20 | 56 4d 61 74 72 69 78 20 |scalar, |VMatrix |
|00001040| 26 52 4f 70 29 3b 0d 0a | 7d 3b 0d 0a 5c 65 6e 64 |&ROp);..|};..\end|
|00001050| 7b 76 65 72 62 61 74 69 | 6d 7d 0d 0a 0d 0a 54 68 |{verbati|m}....Th|
|00001060| 65 20 69 6e 2d 72 61 6d | 20 76 65 72 73 69 6f 6e |e in-ram| version|
|00001070| 20 68 61 73 20 61 20 76 | 65 72 79 20 73 69 6d 69 | has a v|ery simi|
|00001080| 6c 61 72 20 73 74 72 75 | 63 74 75 72 65 2c 20 62 |lar stru|cture, b|
|00001090| 75 74 20 69 73 20 6e 6f | 74 0d 0a 64 65 72 69 76 |ut is no|t..deriv|
|000010a0| 65 64 20 66 72 6f 6d 20 | 61 6e 79 20 6f 74 68 65 |ed from |any othe|
|000010b0| 72 20 63 6c 61 73 73 2e | 20 54 68 65 20 73 79 73 |r class.| The sys|
|000010c0| 74 65 6d 20 73 75 70 70 | 6c 69 65 73 20 64 79 6e |tem supp|lies dyn|
|000010d0| 61 6d 69 63 20 6d 65 6d | 6f 72 79 0d 0a 73 6f 20 |amic mem|ory..so |
|000010e0| 74 68 65 72 65 20 69 73 | 20 6e 6f 20 6e 65 65 64 |there is| no need|
|000010f0| 20 74 6f 20 65 6e 63 61 | 70 73 75 6c 61 74 65 20 | to enca|psulate |
|00001100| 74 68 65 20 6d 65 6d 6f | 72 79 20 6d 61 6e 61 67 |the memo|ry manag|
|00001110| 65 72 20 69 6e 20 61 0d | 0a 73 65 70 61 72 61 74 |er in a.|.separat|
|00001120| 65 20 63 6c 61 73 73 2e | 20 49 6e 20 74 68 65 20 |e class.| In the |
|00001130| 69 6e 2d 72 61 6d 20 76 | 65 72 73 69 6f 6e 2c 20 |in-ram v|ersion, |
|00001140| 6d 61 74 72 69 63 65 73 | 20 61 72 65 20 63 6f 6e |matrices| are con|
|00001150| 73 74 72 75 63 74 65 64 | 0d 0a 66 72 6f 6d 20 76 |structed|..from v|
|00001160| 65 63 74 6f 72 73 20 61 | 6c 6c 6f 63 61 74 65 64 |ectors a|llocated|
|00001170| 20 6f 6e 20 74 68 65 20 | 68 65 61 70 2e 20 54 68 | on the |heap. Th|
|00001180| 65 20 69 6e 2d 2d 72 61 | 6d 20 5c 76 65 72 62 2b |e in--ra|m \verb+|
|00001190| 76 64 6f 75 62 2b 0d 0a | 63 6f 75 6e 74 73 20 74 |vdoub+..|counts t|
|000011a0| 68 65 20 6e 75 6d 62 65 | 72 20 6f 66 20 72 65 66 |he numbe|r of ref|
|000011b0| 65 72 65 6e 63 65 73 20 | 74 6f 20 74 68 65 20 76 |erences |to the v|
|000011c0| 65 63 74 6f 72 2e 20 54 | 68 65 20 76 65 63 74 6f |ector. T|he vecto|
|000011d0| 72 20 69 73 20 6e 6f 74 | 0d 0a 66 72 65 65 64 20 |r is not|..freed |
|000011e0| 75 6e 74 69 6c 20 74 68 | 65 20 6e 75 6d 62 65 72 |until th|e number|
|000011f0| 20 6f 66 20 72 65 66 65 | 72 65 6e 63 65 73 20 69 | of refe|rences i|
|00001200| 73 0d 0a 7a 65 72 6f 2e | 5c 69 6e 64 65 78 7b 56 |s..zero.|\index{V|
|00001210| 4d 61 74 72 69 78 21 49 | 4e 2d 52 41 4d 20 76 64 |Matrix!I|N-RAM vd|
|00001220| 6f 75 62 7d 0d 0a 0d 0a | 0d 0a 5c 73 65 63 74 69 |oub}....|..\secti|
|00001230| 6f 6e 7b 50 72 6f 74 65 | 63 74 65 64 20 50 61 72 |on{Prote|cted Par|
|00001240| 74 73 20 6f 66 20 56 4d | 61 74 72 69 78 7d 0d 0a |ts of VM|atrix}..|
|00001250| 54 68 65 20 70 72 6f 74 | 65 63 74 65 64 20 70 61 |The prot|ected pa|
|00001260| 72 74 20 6f 66 20 56 4d | 61 74 72 69 78 20 6d 75 |rt of VM|atrix mu|
|00001270| 73 74 20 62 65 20 61 63 | 63 65 73 73 69 62 6c 65 |st be ac|cessible|
|00001280| 20 74 6f 20 74 68 65 0d | 0a 6d 61 74 72 69 78 20 | to the.|.matrix |
|00001290| 73 74 61 63 6b 2e 20 54 | 68 65 20 73 69 67 6e 61 |stack. T|he signa|
|000012a0| 74 75 72 65 20 66 75 6e | 63 74 69 6f 6e 73 20 61 |ture fun|ctions a|
|000012b0| 73 20 69 6e 20 74 68 65 | 20 76 6d 6d 20 61 6e 64 |s in the| vmm and|
|000012c0| 0d 0a 76 64 6f 75 62 2e | 20 49 74 20 70 72 6f 76 |..vdoub.| It prov|
|000012d0| 69 64 65 73 20 61 6e 20 | 69 6e 64 69 63 61 74 69 |ides an |indicati|
|000012e0| 6f 6e 20 6f 66 20 68 6f | 77 20 63 6f 72 72 75 70 |on of ho|w corrup|
|000012f0| 74 20 6f 72 20 61 63 74 | 69 76 65 0d 0a 74 68 65 |t or act|ive..the|
|00001300| 20 6d 61 74 72 69 78 20 | 68 61 73 20 62 65 63 6f | matrix |has beco|
|00001310| 6d 65 2e 0d 0a 0d 0a 54 | 68 65 20 66 75 6e 63 74 |me.....T|he funct|
|00001320| 69 6f 6e 20 6d 69 6e 64 | 65 78 28 20 69 6e 74 20 |ion mind|ex( int |
|00001330| 69 2c 20 69 6e 74 20 6a | 29 5c 69 6e 64 65 78 7b |i, int j|)\index{|
|00001340| 56 4d 61 74 72 69 78 21 | 6d 69 6e 64 65 78 28 29 |VMatrix!|mindex()|
|00001350| 7d 0d 0a 63 61 6c 63 75 | 6c 61 74 65 73 20 61 20 |}..calcu|lates a |
|00001360| 76 64 6f 75 62 20 76 65 | 63 74 6f 72 20 69 6e 64 |vdoub ve|ctor ind|
|00001370| 65 78 2e 5c 66 6f 6f 74 | 6e 6f 74 65 7b 20 49 74 |ex.\foot|note{ It|
|00001380| 20 61 70 70 65 61 72 73 | 20 61 20 62 69 74 0d 0a | appears| a bit..|
|00001390| 68 65 61 76 79 20 68 61 | 6e 64 65 64 20 77 69 74 |heavy ha|nded wit|
|000013a0| 68 20 61 6c 6c 20 6f 66 | 20 74 68 65 20 63 61 73 |h all of| the cas|
|000013b0| 74 73 20 74 6f 20 6c 6f | 6e 67 20 69 6e 74 73 2c |ts to lo|ng ints,|
|000013c0| 20 62 75 74 20 74 68 65 | 72 65 0d 0a 77 65 72 65 | but the|re..were|
|000013d0| 20 73 6f 6d 65 20 70 72 | 6f 62 6c 65 6d 73 20 6f | some pr|oblems o|
|000013e0| 66 20 69 6d 70 72 6f 70 | 65 72 20 74 79 70 65 20 |f improp|er type |
|000013f0| 70 72 6f 6d 6f 74 69 6f | 6e 20 65 6e 63 6f 75 6e |promotio|n encoun|
|00001400| 74 65 72 65 64 0d 0a 64 | 75 72 69 6e 67 20 64 65 |tered..d|uring de|
|00001410| 76 65 6c 6f 70 6d 65 6e | 74 2e 7d 20 53 74 72 69 |velopmen|t.} Stri|
|00001420| 70 70 65 64 20 6f 66 20 | 74 68 65 20 63 61 73 74 |pped of |the cast|
|00001430| 73 2c 20 74 68 65 20 66 | 75 6e 63 74 69 6f 6e 20 |s, the f|unction |
|00001440| 69 73 0d 0a 73 69 6d 70 | 6c 79 20 5c 76 65 72 62 |is..simp|ly \verb|
|00001450| 23 20 28 69 2d 31 29 2a | 63 20 2b 20 28 6a 2d 31 |# (i-1)*|c + (j-1|
|00001460| 29 20 23 2c 20 77 68 65 | 72 65 20 69 20 61 6e 64 |) #, whe|re i and|
|00001470| 20 6a 20 61 72 65 20 6d | 61 74 72 69 78 0d 0a 69 | j are m|atrix..i|
|00001480| 6e 64 69 63 65 73 2c 20 | 61 6e 64 20 63 20 69 73 |ndices, |and c is|
|00001490| 20 74 68 65 20 6e 75 6d | 62 65 72 20 6f 66 20 63 | the num|ber of c|
|000014a0| 6f 6c 75 6d 6e 73 20 6f | 66 20 74 68 65 20 6d 61 |olumns o|f the ma|
|000014b0| 74 72 69 78 2e 0d 0a 4d | 61 74 72 69 63 65 73 20 |trix...M|atrices |
|000014c0| 61 72 65 20 69 6e 64 65 | 78 65 64 20 66 72 6f 6d |are inde|xed from|
|000014d0| 20 31 20 74 6f 20 72 2c | 20 61 6e 64 20 31 20 74 | 1 to r,| and 1 t|
|000014e0| 6f 20 63 2c 20 73 6f 20 | 74 68 65 72 65 20 61 72 |o c, so |there ar|
|000014f0| 65 0d 0a 72 2a 63 20 65 | 6c 65 6d 65 6e 74 73 20 |e..r*c e|lements |
|00001500| 69 6e 20 74 68 65 20 63 | 6f 72 72 65 73 70 6f 6e |in the c|orrespon|
|00001510| 64 69 6e 67 20 76 64 6f | 75 62 2e 20 48 6f 77 65 |ding vdo|ub. Howe|
|00001520| 76 65 72 20 74 68 65 20 | 76 64 6f 75 62 0d 0a 69 |ver the |vdoub..i|
|00001530| 6e 64 69 63 65 73 20 72 | 61 6e 67 65 20 66 72 6f |ndices r|ange fro|
|00001540| 6d 20 30 20 74 6f 20 72 | 2a 63 20 2d 20 31 2c 20 |m 0 to r|*c - 1, |
|00001550| 73 6f 20 74 68 65 20 69 | 2d 31 20 61 6e 64 20 6a |so the i|-1 and j|
|00001560| 2d 31 20 66 6f 72 63 65 | 0d 0a 74 68 65 20 6d 69 |-1 force|..the mi|
|00001570| 6e 69 6d 75 6d 20 6d 61 | 74 72 69 78 20 69 6e 64 |nimum ma|trix ind|
|00001580| 69 63 65 73 20 74 6f 20 | 62 65 20 31 2e 20 54 68 |ices to |be 1. Th|
|00001590| 69 73 20 63 61 6c 63 75 | 6c 61 74 69 6f 6e 20 66 |is calcu|lation f|
|000015a0| 6f 72 63 65 73 0d 0a 74 | 68 65 20 6d 61 74 72 69 |orces..t|he matri|
|000015b0| 78 20 74 6f 20 62 65 20 | 69 6e 20 72 6f 77 20 6d |x to be |in row m|
|000015c0| 61 6a 6f 72 20 6f 72 64 | 65 72 2e 20 54 68 65 0d |ajor ord|er. The.|
|000015d0| 0a 63 75 72 76 65 63 69 | 6e 64 5c 69 6e 64 65 78 |.curveci|nd\index|
|000015e0| 7b 56 4d 61 74 72 69 78 | 21 63 75 72 76 65 63 69 |{VMatrix|!curveci|
|000015f0| 6e 64 7d 20 69 73 20 61 | 20 6c 6f 6e 67 20 69 6e |nd} is a| long in|
|00001600| 74 65 67 65 72 0d 0a 63 | 6f 6e 74 61 69 6e 69 6e |teger..c|ontainin|
|00001610| 67 20 74 68 65 20 76 64 | 6f 75 62 20 69 6e 64 65 |g the vd|oub inde|
|00001620| 78 20 6f 66 20 74 68 65 | 20 63 75 72 72 65 6e 74 |x of the| current|
|00001630| 20 6d 61 74 72 69 78 20 | 65 6c 65 6d 65 6e 74 2e | matrix |element.|
|00001640| 0d 0a 0d 0a 54 68 65 20 | 6e 61 6d 65 5c 69 6e 64 |....The |name\ind|
|00001650| 65 78 7b 56 4d 61 74 72 | 69 78 21 6e 61 6d 65 7d |ex{VMatr|ix!name}|
|00001660| 20 69 73 20 61 20 73 74 | 72 69 6e 67 20 74 79 70 | is a st|ring typ|
|00001670| 65 20 77 68 69 63 68 20 | 63 61 6e 20 62 65 0d 0a |e which |can be..|
|00001680| 6d 61 6e 69 70 75 6c 61 | 74 65 64 20 69 6e 20 74 |manipula|ted in t|
|00001690| 68 65 20 6d 61 74 72 69 | 78 20 66 75 6e 63 74 69 |he matri|x functi|
|000016a0| 6f 6e 73 2e 20 54 68 65 | 20 66 75 6e 63 74 69 6f |ons. The| functio|
|000016b0| 6e 73 20 61 72 65 0d 0a | 66 6f 75 6e 64 20 69 6e |ns are..|found in|
|000016c0| 20 74 68 65 20 70 75 62 | 6c 69 63 20 70 61 72 74 | the pub|lic part|
|000016d0| 2c 20 62 75 74 20 61 72 | 65 20 4e 61 6d 65 69 74 |, but ar|e Nameit|
|000016e0| 28 29 2c 20 47 65 74 6e | 61 6d 65 28 29 2c 0d 0a |(), Getn|ame(),..|
|000016f0| 53 68 6f 77 6e 61 6d 65 | 28 29 2c 20 61 6e 64 20 |Showname|(), and |
|00001700| 53 74 72 69 6e 67 41 64 | 64 72 65 73 73 28 29 2e |StringAd|dress().|
|00001710| 0d 0a 0d 0a 54 68 65 20 | 6e 65 78 74 20 74 68 72 |....The |next thr|
|00001720| 65 65 20 66 75 6e 63 74 | 69 6f 6e 73 20 63 6f 6e |ee funct|ions con|
|00001730| 74 72 6f 6c 20 74 68 65 | 20 61 6c 6c 6f 63 61 74 |trol the| allocat|
|00001740| 69 6f 6e 20 6f 66 20 74 | 68 65 0d 0a 76 64 6f 75 |ion of t|he..vdou|
|00001750| 62 20 76 65 63 74 6f 72 | 73 2e 20 52 65 70 6c 61 |b vector|s. Repla|
|00001760| 63 65 28 29 5c 69 6e 64 | 65 78 7b 56 4d 61 74 72 |ce()\ind|ex{VMatr|
|00001770| 69 78 21 52 65 70 6c 61 | 63 65 28 29 7d 20 63 61 |ix!Repla|ce()} ca|
|00001780| 6c 6c 73 0d 0a 50 75 72 | 67 65 56 65 63 74 6f 72 |lls..Pur|geVector|
|00001790| 73 28 29 5c 69 6e 64 65 | 78 7b 56 4d 61 74 72 69 |s()\inde|x{VMatri|
|000017a0| 78 21 50 75 72 67 65 56 | 65 63 74 6f 72 73 28 29 |x!PurgeV|ectors()|
|000017b0| 7d 20 61 6e 64 0d 0a 53 | 65 74 75 70 56 65 63 74 |} and..S|etupVect|
|000017c0| 6f 72 73 28 29 5c 69 6e | 64 65 78 7b 56 4d 61 74 |ors()\in|dex{VMat|
|000017d0| 72 69 78 21 53 65 74 75 | 70 56 65 63 74 6f 72 73 |rix!Setu|pVectors|
|000017e0| 28 29 7d 20 69 66 20 74 | 68 65 20 56 4d 61 74 72 |()} if t|he VMatr|
|000017f0| 69 78 0d 0a 62 65 69 6e | 67 20 72 65 70 6c 61 63 |ix..bein|g replac|
|00001800| 65 64 20 68 61 73 20 64 | 69 66 66 65 72 65 6e 74 |ed has d|ifferent|
|00001810| 20 64 69 6d 65 6e 73 69 | 6f 6e 73 20 74 68 61 6e | dimensi|ons than|
|00001820| 20 74 68 65 20 72 65 70 | 6c 61 63 69 6e 67 0d 0a | the rep|lacing..|
|00001830| 56 4d 61 74 72 69 78 2e | 20 52 65 70 6c 61 63 65 |VMatrix.| Replace|
|00001840| 28 29 20 69 73 20 63 61 | 6c 6c 65 64 20 62 79 20 |() is ca|lled by |
|00001850| 74 68 65 0d 0a 6f 70 65 | 72 61 74 6f 72 3d 28 29 |the..ope|rator=()|
|00001860| 5c 69 6e 64 65 78 7b 56 | 4d 61 74 72 69 78 21 61 |\index{V|Matrix!a|
|00001870| 73 73 69 67 6e 6d 65 6e | 74 7d 2e 20 20 50 75 72 |ssignmen|t}. Pur|
|00001880| 67 65 56 65 63 74 6f 72 | 73 28 29 0d 0a 63 61 6c |geVector|s()..cal|
|00001890| 6c 73 20 76 66 72 65 65 | 28 29 20 74 6f 20 66 72 |ls vfree|() to fr|
|000018a0| 65 65 20 74 68 65 20 68 | 64 72 20 69 6e 20 74 68 |ee the h|dr in th|
|000018b0| 65 20 70 72 6f 74 65 63 | 74 65 64 20 70 61 72 74 |e protec|ted part|
|000018c0| 20 6f 66 0d 0a 76 64 6f | 75 62 2e 20 53 65 74 75 | of..vdo|ub. Setu|
|000018d0| 70 56 65 63 74 6f 72 73 | 28 29 20 63 61 6c 6c 73 |pVectors|() calls|
|000018e0| 20 76 6d 61 6c 6c 6f 63 | 28 29 20 74 6f 20 63 72 | vmalloc|() to cr|
|000018f0| 65 61 74 65 20 61 20 6e | 65 77 20 68 64 72 0d 0a |eate a n|ew hdr..|
|00001900| 66 6f 72 20 76 64 6f 75 | 62 2e 5c 66 6f 6f 74 6e |for vdou|b.\footn|
|00001910| 6f 74 65 7b 20 54 68 69 | 73 20 61 62 69 6c 69 74 |ote{ Thi|s abilit|
|00001920| 79 20 74 6f 20 6f 70 65 | 72 61 74 65 20 6f 6e 20 |y to ope|rate on |
|00001930| 74 68 65 20 68 64 72 20 | 6f 66 0d 0a 76 64 6f 75 |the hdr |of..vdou|
|00001940| 62 20 63 6c 61 72 69 66 | 69 65 64 20 74 68 65 20 |b clarif|ied the |
|00001950| 6d 65 61 6e 69 6e 67 20 | 6f 66 20 69 6e 68 65 72 |meaning |of inher|
|00001960| 69 74 61 6e 63 65 20 66 | 6f 72 20 6d 65 20 73 69 |itance f|or me si|
|00001970| 6e 63 65 20 61 0d 0a 56 | 4d 61 74 72 69 78 20 69 |nce a..V|Matrix i|
|00001980| 73 20 72 65 61 6c 6c 79 | 20 6a 75 73 74 20 61 20 |s really| just a |
|00001990| 76 69 72 74 75 61 6c 20 | 76 65 63 74 6f 72 20 77 |virtual |vector w|
|000019a0| 69 74 68 20 73 6f 6d 65 | 20 65 78 74 72 61 0d 0a |ith some| extra..|
|000019b0| 66 75 6e 63 74 69 6f 6e | 61 6c 69 74 79 2e 20 49 |function|ality. I|
|000019c0| 74 20 61 6c 73 6f 20 73 | 68 6f 77 73 20 77 68 79 |t also s|hows why|
|000019d0| 20 74 68 65 20 68 64 72 | 20 6d 75 73 74 20 62 65 | the hdr| must be|
|000019e0| 20 70 72 6f 74 65 63 74 | 65 64 0d 0a 72 61 74 68 | protect|ed..rath|
|000019f0| 65 72 20 74 68 61 6e 20 | 70 72 69 76 61 74 65 20 |er than |private |
|00001a00| 69 6e 20 76 64 6f 75 62 | 2e 7d 0d 0a 0d 0a 46 6f |in vdoub|.}....Fo|
|00001a10| 72 20 74 68 65 20 69 6e | 2d 72 61 6d 20 76 65 72 |r the in|-ram ver|
|00001a20| 73 69 6f 6e 2c 20 53 65 | 74 75 70 56 65 63 74 6f |sion, Se|tupVecto|
|00001a30| 72 73 28 29 20 61 6c 6c | 6f 63 61 74 65 73 20 72 |rs() all|ocates r|
|00001a40| 2a 63 2b 31 20 65 6c 65 | 6d 65 6e 74 73 0d 0a 6f |*c+1 ele|ments..o|
|00001a50| 6e 20 74 68 65 20 68 65 | 61 70 20 75 73 69 6e 67 |n the he|ap using|
|00001a60| 20 63 61 6c 6c 6f 63 28 | 29 2e 20 54 68 65 20 66 | calloc(|). The f|
|00001a70| 69 72 73 74 20 65 6c 65 | 6d 65 6e 74 20 69 73 20 |irst ele|ment is |
|00001a80| 73 65 74 20 74 6f 0d 0a | 53 49 47 4e 41 54 55 52 |set to..|SIGNATUR|
|00001a90| 45 2c 20 74 68 65 6e 20 | 74 68 65 20 62 61 73 65 |E, then |the base|
|00001aa0| 20 69 73 20 73 68 69 66 | 74 65 64 20 62 79 20 31 | is shif|ted by 1|
|00001ab0| 2e 20 54 68 75 73 2c 20 | 6d 5b 2d 31 5d 20 69 73 |. Thus, |m[-1] is|
|00001ac0| 20 61 20 63 68 65 63 6b | 0d 0a 76 61 6c 75 65 2e | a check|..value.|
|00001ad0| 20 49 66 20 74 68 65 20 | 76 61 6c 75 65 20 69 73 | If the |value is|
|00001ae0| 20 6e 6f 74 20 65 71 75 | 61 6c 20 74 6f 20 53 49 | not equ|al to SI|
|00001af0| 47 4e 41 54 55 52 45 2c | 20 74 68 65 6e 20 74 68 |GNATURE,| then th|
|00001b00| 65 20 6d 61 74 72 69 78 | 0d 0a 68 61 73 20 62 65 |e matrix|..has be|
|00001b10| 65 6e 20 64 65 6c 65 74 | 65 64 20 6f 72 20 63 6c |en delet|ed or cl|
|00001b20| 6f 62 62 65 72 65 64 2e | 0d 0a 0d 0a 54 68 65 20 |obbered.|....The |
|00001b30| 66 75 6e 63 74 69 6f 6e | 20 5c 76 65 72 62 2b 4e |function| \verb+N|
|00001b40| 65 77 52 65 66 65 72 65 | 6e 63 65 28 29 2b 0d 0a |ewRefere|nce()+..|
|00001b50| 5c 69 6e 64 65 78 7b 56 | 4d 61 74 72 69 78 21 4e |\index{V|Matrix!N|
|00001b60| 65 77 52 65 66 65 72 65 | 6e 63 65 28 29 7d 20 69 |ewRefere|nce()} i|
|00001b70| 73 20 75 73 65 64 20 62 | 79 20 74 68 65 20 6d 61 |s used b|y the ma|
|00001b80| 74 72 69 78 20 73 74 61 | 63 6b 20 74 6f 0d 0a 73 |trix sta|ck to..s|
|00001b90| 65 74 20 75 70 20 61 20 | 72 65 66 65 72 65 6e 63 |et up a |referenc|
|00001ba0| 65 20 74 6f 20 61 20 62 | 61 73 65 20 76 65 63 74 |e to a b|ase vect|
|00001bb0| 6f 72 20 69 6e 73 74 65 | 61 64 20 6f 66 20 61 20 |or inste|ad of a |
|00001bc0| 63 6f 70 79 2e 20 49 74 | 20 69 73 0d 0a 70 61 72 |copy. It| is..par|
|00001bd0| 74 20 6f 66 20 74 68 65 | 20 64 65 65 70 20 63 6f |t of the| deep co|
|00001be0| 70 79 20 74 65 63 68 6e | 69 71 75 65 20 75 73 65 |py techn|ique use|
|00001bf0| 64 20 62 79 20 70 75 73 | 68 2e 0d 0a 0d 0a 5c 73 |d by pus|h.....\s|
|00001c00| 65 63 74 69 6f 6e 7b 54 | 68 65 20 50 75 62 6c 69 |ection{T|he Publi|
|00001c10| 63 20 50 61 72 74 20 6f | 66 20 56 4d 61 74 72 69 |c Part o|f VMatri|
|00001c20| 78 7d 0d 0a 0d 0a 5c 73 | 75 62 73 65 63 74 69 6f |x}....\s|ubsectio|
|00001c30| 6e 7b 45 72 72 6f 72 20 | 44 65 74 65 63 74 69 6f |n{Error |Detectio|
|00001c40| 6e 7d 0d 0a 0d 0a 44 6f | 6e 27 74 20 6c 65 74 20 |n}....Do|n't let |
|00001c50| 4f 4f 50 20 66 6f 6f 6c | 20 79 6f 75 2e 20 49 74 |OOP fool| you. It|
|00001c60| 27 73 20 70 6f 69 6e 74 | 65 72 20 7b 5c 65 6d 20 |'s point|er {\em |
|00001c70| 69 6e 74 65 6e 73 69 76 | 65 7d 2e 20 54 68 65 0d |intensiv|e}. The.|
|00001c80| 0a 61 70 70 72 6f 61 63 | 68 20 74 61 6b 65 6e 20 |.approac|h taken |
|00001c90| 68 65 72 65 20 69 73 20 | 74 6f 20 73 74 6f 70 20 |here is |to stop |
|00001ca0| 74 68 65 20 70 72 6f 67 | 72 61 6d 20 61 74 20 74 |the prog|ram at t|
|00001cb0| 68 65 20 73 6c 69 67 68 | 74 65 73 74 0d 0a 70 72 |he sligh|test..pr|
|00001cc0| 6f 62 6c 65 6d 2e 20 54 | 68 69 73 20 63 6f 6e 73 |oblem. T|his cons|
|00001cd0| 65 72 76 61 74 69 76 65 | 20 61 70 70 72 6f 61 63 |ervative| approac|
|00001ce0| 68 20 72 65 73 75 6c 74 | 73 20 66 72 6f 6d 20 73 |h result|s from s|
|00001cf0| 65 76 65 72 61 6c 0d 0a | 79 65 61 72 73 20 65 78 |everal..|years ex|
|00001d00| 70 65 72 69 65 6e 63 65 | 20 77 69 74 68 20 72 6f |perience| with ro|
|00001d10| 67 75 65 20 73 74 72 69 | 6e 67 73 2c 20 64 61 6e |gue stri|ngs, dan|
|00001d20| 67 6c 69 6e 67 20 70 6f | 69 6e 74 65 72 73 20 74 |gling po|inters t|
|00001d30| 6f 0d 0a 66 72 65 65 64 | 20 73 70 61 63 65 2c 20 |o..freed| space, |
|00001d40| 61 6e 64 20 6a 75 6d 70 | 69 6e 67 20 74 6f 20 65 |and jump|ing to e|
|00001d50| 78 65 63 75 74 69 6f 6e | 20 6f 66 20 74 68 65 20 |xecution| of the |
|00001d60| 68 65 61 70 20 62 65 63 | 61 75 73 65 20 61 0d 0a |heap bec|ause a..|
|00001d70| 73 74 72 61 79 20 62 69 | 74 20 6f 66 20 64 61 74 |stray bi|t of dat|
|00001d80| 61 20 6c 61 6e 64 65 64 | 20 69 6e 20 6d 79 20 69 |a landed| in my i|
|00001d90| 6e 74 65 72 72 75 70 74 | 20 76 65 63 74 6f 72 20 |nterrupt| vector |
|00001da0| 74 61 62 6c 65 2e 20 54 | 68 65 73 65 0d 0a 61 72 |table. T|hese..ar|
|00001db0| 65 20 73 6f 6d 65 20 6f | 66 20 74 68 65 20 6c 65 |e some o|f the le|
|00001dc0| 73 73 20 62 65 6e 69 67 | 6e 20 74 68 69 6e 67 73 |ss benig|n things|
|00001dd0| 20 74 68 61 74 20 63 61 | 6e 20 68 61 70 70 65 6e | that ca|n happen|
|00001de0| 20 77 68 65 6e 0d 0a 75 | 73 69 6e 67 20 70 6f 69 | when..u|sing poi|
|00001df0| 6e 74 65 72 73 2e 0d 0a | 0d 0a 54 77 6f 20 65 72 |nters...|..Two er|
|00001e00| 72 6f 72 20 64 65 74 65 | 63 74 69 6f 6e 20 72 6f |ror dete|ction ro|
|00001e10| 75 74 69 6e 65 73 20 61 | 72 65 20 70 72 6f 76 69 |utines a|re provi|
|00001e20| 64 65 64 20 66 6f 72 20 | 61 20 67 72 61 63 65 66 |ded for |a gracef|
|00001e30| 75 6c 0d 0a 65 78 69 74 | 20 66 72 6f 6d 20 74 68 |ul..exit| from th|
|00001e40| 65 20 70 72 6f 67 72 61 | 6d 2e 20 54 68 65 73 65 |e progra|m. These|
|00001e50| 20 72 6f 75 74 69 6e 65 | 73 20 70 72 69 6e 74 20 | routine|s print |
|00001e60| 61 20 6d 65 73 73 61 67 | 65 20 6f 66 0d 0a 77 68 |a messag|e of..wh|
|00001e70| 69 63 68 20 72 6f 75 74 | 69 6e 65 20 77 61 73 20 |ich rout|ine was |
|00001e80| 61 63 74 69 76 65 20 77 | 68 65 6e 20 74 68 65 20 |active w|hen the |
|00001e90| 70 72 6f 67 72 61 6d 20 | 66 61 69 6c 65 64 2e 0d |program |failed..|
|00001ea0| 0a 4e 72 65 72 72 6f 72 | 28 29 5c 69 6e 64 65 78 |.Nrerror|()\index|
|00001eb0| 7b 56 4d 61 74 72 69 78 | 21 4e 72 65 72 72 6f 72 |{VMatrix|!Nrerror|
|00001ec0| 7d 20 70 72 69 6e 74 73 | 20 61 6e 20 65 72 72 6f |} prints| an erro|
|00001ed0| 72 20 6d 65 73 73 61 67 | 65 0d 0a 61 6e 64 20 65 |r messag|e..and e|
|00001ee0| 78 69 74 73 20 74 6f 20 | 74 68 65 20 73 79 73 74 |xits to |the syst|
|00001ef0| 65 6d 20 77 69 74 68 20 | 65 72 72 6f 72 20 63 6f |em with |error co|
|00001f00| 64 65 20 31 2e 20 4e 6f | 74 65 20 74 68 61 74 20 |de 1. No|te that |
|00001f10| 69 74 20 69 73 0d 0a 64 | 65 63 6c 61 72 65 64 20 |it is..d|eclared |
|00001f20| 74 6f 20 72 65 74 75 72 | 6e 20 61 20 64 6f 75 62 |to retur|n a doub|
|00001f30| 6c 65 2e 20 54 68 69 73 | 20 69 73 20 73 6f 20 4e |le. This| is so N|
|00001f40| 72 65 72 72 6f 72 28 29 | 20 63 61 6e 20 62 65 0d |rerror()| can be.|
|00001f50| 0a 70 6c 61 63 65 64 20 | 69 6e 20 74 68 65 20 74 |.placed |in the t|
|00001f60| 65 72 6e 61 72 79 20 6f | 70 65 72 61 74 6f 72 20 |ernary o|perator |
|00001f70| 27 3f 3a 27 20 77 68 65 | 72 65 20 61 20 64 6f 75 |'?:' whe|re a dou|
|00001f80| 62 6c 65 20 69 73 20 74 | 6f 20 62 65 0d 0a 72 65 |ble is t|o be..re|
|00001f90| 74 75 72 6e 65 64 2e 20 | 46 6f 72 20 69 6e 73 74 |turned. |For inst|
|00001fa0| 61 6e 63 65 2c 20 73 75 | 70 70 6f 73 65 20 78 3d |ance, su|ppose x=|
|00001fb0| 20 2d 31 2e 30 2c 20 74 | 68 65 6e 20 74 68 65 20 | -1.0, t|hen the |
|00001fc0| 73 74 61 74 65 6d 65 6e | 74 20 0d 0a 5c 62 65 67 |statemen|t ..\beg|
|00001fd0| 69 6e 7b 76 65 72 62 61 | 74 69 6d 7d 0d 0a 20 20 |in{verba|tim}.. |
|00001fe0| 20 64 6f 75 62 6c 65 20 | 79 20 3d 20 28 20 78 3e | double |y = ( x>|
|00001ff0| 30 20 29 20 3f 20 6c 6f | 67 28 78 29 20 3a 20 4e |0 ) ? lo|g(x) : N|
|00002000| 72 65 72 72 6f 72 28 22 | 4c 4f 47 3a 20 6e 65 67 |rerror("|LOG: neg|
|00002010| 61 74 69 76 65 20 76 61 | 6c 75 65 22 29 3b 0d 0a |ative va|lue");..|
|00002020| 5c 65 6e 64 7b 76 65 72 | 62 61 74 69 6d 7d 0d 0a |\end{ver|batim}..|
|00002030| 77 69 6c 6c 20 63 6f 6d | 70 69 6c 65 20 63 6f 72 |will com|pile cor|
|00002040| 72 65 63 74 6c 79 20 73 | 69 6e 63 65 20 74 68 65 |rectly s|ince the|
|00002050| 20 63 6f 6d 70 69 6c 65 | 72 20 74 68 69 6e 6b 73 | compile|r thinks|
|00002060| 20 4e 72 65 72 72 6f 72 | 28 29 0d 0a 77 69 6c 6c | Nrerror|()..will|
|00002070| 20 72 65 74 75 72 6e 20 | 61 20 64 6f 75 62 6c 65 | return |a double|
|00002080| 2e 20 54 68 65 20 63 6f | 6d 70 69 6c 65 72 20 64 |. The co|mpiler d|
|00002090| 6f 65 73 20 6e 6f 74 20 | 6b 6e 6f 77 20 74 68 61 |oes not |know tha|
|000020a0| 74 20 74 68 65 0d 0a 70 | 72 6f 67 72 61 6d 20 77 |t the..p|rogram w|
|000020b0| 69 6c 6c 20 65 78 69 74 | 20 62 65 66 6f 72 65 20 |ill exit| before |
|000020c0| 74 68 65 20 72 65 74 75 | 72 6e 2e 20 4e 72 65 72 |the retu|rn. Nrer|
|000020d0| 72 6f 72 28 29 20 70 72 | 6f 76 69 64 65 73 20 61 |ror() pr|ovides a|
|000020e0| 0d 0a 73 69 6d 69 6c 61 | 72 20 66 75 6e 63 74 69 |..simila|r functi|
|000020f0| 6f 6e 20 69 6e 20 50 72 | 65 73 73 5c 63 69 74 65 |on in Pr|ess\cite|
|00002100| 7b 50 72 3a 6e 72 63 7d | 20 77 68 69 63 68 20 69 |{Pr:nrc}| which i|
|00002110| 73 20 61 6e 0d 0a 65 78 | 63 65 6c 6c 65 6e 74 20 |s an..ex|cellent |
|00002120| 73 6f 75 72 63 65 20 66 | 6f 72 20 63 6f 64 65 20 |source f|or code |
|00002130| 74 6f 20 74 72 61 6e 73 | 6c 61 74 65 20 74 6f 20 |to trans|late to |
|00002140| 56 4d 61 74 72 69 78 0d | 0a 66 75 6e 63 74 69 6f |VMatrix.|.functio|
|00002150| 6e 73 2e 5c 66 6f 6f 74 | 6e 6f 74 65 7b 49 66 20 |ns.\foot|note{If |
|00002160| 79 6f 75 20 66 6f 72 63 | 65 20 61 20 7a 65 72 6f |you forc|e a zero|
|00002170| 20 64 69 76 69 73 69 6f | 6e 20 69 6e 20 74 68 69 | divisio|n in thi|
|00002180| 73 0d 0a 72 6f 75 74 69 | 6e 65 2c 20 56 41 58 20 |s..routi|ne, VAX |
|00002190| 43 43 20 77 69 6c 6c 20 | 63 61 75 73 65 20 61 20 |CC will |cause a |
|000021a0| 70 72 69 6e 74 20 6f 66 | 20 74 68 65 20 66 75 6e |print of| the fun|
|000021b0| 63 74 69 6f 6e 20 63 61 | 6c 6c 0d 0a 73 65 71 75 |ction ca|ll..sequ|
|000021c0| 65 6e 63 65 20 74 6f 20 | 74 68 65 20 65 72 72 6f |ence to |the erro|
|000021d0| 72 20 6f 75 74 70 75 74 | 20 73 74 72 65 61 6d 7d |r output| stream}|
|000021e0| 0d 0a 0d 0a 54 68 65 72 | 65 20 61 72 65 20 74 77 |....Ther|e are tw|
|000021f0| 6f 20 66 75 6e 63 74 69 | 6f 6e 73 20 63 61 6c 6c |o functi|ons call|
|00002200| 65 64 0d 0a 47 61 72 62 | 61 67 65 28 29 5c 69 6e |ed..Garb|age()\in|
|00002210| 64 65 78 7b 56 4d 61 74 | 72 69 78 21 47 61 72 62 |dex{VMat|rix!Garb|
|00002220| 61 67 65 28 29 7d 2e 20 | 54 68 65 79 20 74 65 73 |age()}. |They tes|
|00002230| 74 20 74 68 65 20 69 6e | 74 65 67 72 69 74 79 0d |t the in|tegrity.|
|00002240| 0a 6f 66 20 74 68 65 20 | 6d 61 74 72 69 78 20 61 |.of the |matrix a|
|00002250| 72 67 75 6d 65 6e 74 73 | 20 69 6e 20 66 75 6e 63 |rguments| in func|
|00002260| 74 69 6f 6e 20 63 61 6c | 6c 73 2e 20 49 74 20 70 |tion cal|ls. It p|
|00002270| 72 69 6e 74 73 20 74 68 | 65 0d 0a 72 6f 75 74 69 |rints th|e..routi|
|00002280| 6e 65 20 77 68 65 72 65 | 20 61 20 67 61 72 62 61 |ne where| a garba|
|00002290| 67 65 20 6d 61 74 72 69 | 78 20 77 61 73 20 66 6f |ge matri|x was fo|
|000022a0| 75 6e 64 2c 20 74 68 65 | 6e 20 63 61 6c 6c 73 0d |und, the|n calls.|
|000022b0| 0a 4e 72 65 72 72 6f 72 | 28 29 2e 20 41 20 67 6f |.Nrerror|(). A go|
|000022c0| 6f 64 20 65 78 61 6d 70 | 6c 65 20 6f 66 20 74 68 |od examp|le of th|
|000022d0| 69 73 20 66 75 6e 63 74 | 69 6f 6e 20 69 73 20 66 |is funct|ion is f|
|000022e0| 6f 75 6e 64 20 69 6e 20 | 74 68 65 0d 0a 61 73 73 |ound in |the..ass|
|000022f0| 69 67 6e 6d 65 6e 74 20 | 66 75 6e 63 74 69 6f 6e |ignment |function|
|00002300| 20 66 6f 72 20 56 4d 61 | 74 72 69 78 3a 0d 0a 5c | for VMa|trix:..\|
|00002310| 62 65 67 69 6e 7b 76 65 | 72 62 61 74 69 6d 7d 0d |begin{ve|rbatim}.|
|00002320| 0a 76 6f 69 64 20 56 4d | 61 74 72 69 78 3a 3a 6f |.void VM|atrix::o|
|00002330| 70 65 72 61 74 6f 72 3d | 20 28 56 4d 61 74 72 69 |perator=| (VMatri|
|00002340| 78 20 26 52 4f 70 29 0d | 0a 7b 0d 0a 20 20 20 47 |x &ROp).|.{.. G|
|00002350| 61 72 62 61 67 65 28 22 | 6f 70 65 72 61 74 6f 72 |arbage("|operator|
|00002360| 20 3d 22 29 3b 0d 0a 20 | 20 20 52 4f 70 2e 47 61 | =");.. | ROp.Ga|
|00002370| 72 62 61 67 65 28 22 6f | 70 65 72 61 74 6f 72 20 |rbage("o|perator |
|00002380| 3d 22 29 3b 0d 0a 20 20 | 20 2e 0d 0a 20 20 20 2e |=");.. | ... .|
|00002390| 0d 0a 20 20 20 2e 0d 0a | 7d 0d 0a 5c 65 6e 64 7b |.. ...|}..\end{|
|000023a0| 76 65 72 62 61 74 69 6d | 7d 0d 0a 46 69 72 73 74 |verbatim|}..First|
|000023b0| 20 74 68 65 20 6d 65 6d | 62 65 72 20 66 75 6e 63 | the mem|ber func|
|000023c0| 74 69 6f 6e 20 6f 66 20 | 74 68 65 20 56 4d 61 74 |tion of |the VMat|
|000023d0| 72 69 78 20 2a 74 68 69 | 73 20 69 73 20 63 61 6c |rix *thi|s is cal|
|000023e0| 6c 65 64 2e 0d 0a 4e 65 | 78 74 20 74 68 65 20 52 |led...Ne|xt the R|
|000023f0| 4f 70 20 6d 65 6d 62 65 | 72 20 66 75 6e 63 74 69 |Op membe|r functi|
|00002400| 6f 6e 20 69 73 20 63 61 | 6c 6c 65 64 2e 20 54 68 |on is ca|lled. Th|
|00002410| 65 20 73 69 67 6e 61 74 | 75 72 65 20 69 73 0d 0a |e signat|ure is..|
|00002420| 63 68 65 63 6b 65 64 20 | 66 6f 72 20 76 61 6c 69 |checked |for vali|
|00002430| 64 69 74 79 2e 20 49 66 | 20 69 74 20 69 73 20 77 |dity. If| it is w|
|00002440| 72 6f 6e 67 2c 20 74 68 | 65 20 70 72 6f 67 72 61 |rong, th|e progra|
|00002450| 6d 20 73 74 6f 70 73 2e | 0d 0a 59 6f 75 20 73 68 |m stops.|..You sh|
|00002460| 6f 75 6c 64 20 6d 61 6b | 65 20 61 20 68 61 62 69 |ould mak|e a habi|
|00002470| 74 20 6f 66 20 63 68 65 | 63 6b 69 6e 67 20 66 6f |t of che|cking fo|
|00002480| 72 20 69 6e 63 6f 6d 69 | 6e 67 20 6d 61 74 72 69 |r incomi|ng matri|
|00002490| 63 65 73 0d 0a 74 68 61 | 74 20 63 6f 75 6c 64 20 |ces..tha|t could |
|000024a0| 63 61 75 73 65 20 74 68 | 65 20 70 72 6f 67 72 61 |cause th|e progra|
|000024b0| 6d 20 74 6f 20 62 6f 6d | 62 20 62 79 20 75 73 69 |m to bom|b by usi|
|000024c0| 6e 67 20 74 68 65 20 47 | 61 72 62 61 67 65 28 29 |ng the G|arbage()|
|000024d0| 0d 0a 66 75 6e 63 74 69 | 6f 6e 73 2e 0d 0a 0d 0a |..functi|ons.....|
|000024e0| 5c 73 75 62 73 65 63 74 | 69 6f 6e 7b 49 6e 64 65 |\subsect|ion{Inde|
|000024f0| 78 69 6e 67 20 61 6e 64 | 20 41 73 73 69 67 6e 69 |xing and| Assigni|
|00002500| 6e 67 20 45 6c 65 6d 65 | 6e 74 73 7d 0d 0a 0d 0a |ng Eleme|nts}....|
|00002510| 54 68 65 20 69 6e 64 65 | 78 69 6e 67 20 72 61 6e |The inde|xing ran|
|00002520| 67 65 20 69 73 20 70 72 | 65 74 74 79 20 73 69 6d |ge is pr|etty sim|
|00002530| 70 6c 65 2e 20 4d 61 74 | 72 69 78 20 65 6c 65 6d |ple. Mat|rix elem|
|00002540| 65 6e 74 73 20 61 72 65 | 0d 0a 69 6e 64 65 78 65 |ents are|..indexe|
|00002550| 64 20 66 72 6f 6d 20 31 | 20 74 6f 20 63 2c 20 61 |d from 1| to c, a|
|00002560| 6e 64 20 66 72 6f 6d 20 | 31 20 74 6f 20 72 2e 20 |nd from |1 to r. |
|00002570| 54 68 65 72 65 20 61 72 | 65 20 73 6f 6d 65 0d 0a |There ar|e some..|
|00002580| 74 72 61 64 65 6f 66 66 | 73 20 68 65 72 65 2e 20 |tradeoff|s here. |
|00002590| 49 20 63 6f 75 6c 64 20 | 6e 6f 74 20 66 69 67 75 |I could |not figu|
|000025a0| 72 65 20 6f 75 74 20 68 | 6f 77 20 74 6f 20 6f 76 |re out h|ow to ov|
|000025b0| 65 72 6c 6f 61 64 20 61 | 0d 0a 64 6f 75 62 6c 65 |erload a|..double|
|000025c0| 20 62 72 61 63 6b 65 74 | 20 6f 70 65 72 61 74 6f | bracket| operato|
|000025d0| 72 2c 20 5b 5d 5b 5d 2c | 20 73 6f 20 49 20 72 65 |r, [][],| so I re|
|000025e0| 73 6f 72 74 65 64 20 74 | 6f 20 61 0d 0a 66 75 6e |sorted t|o a..fun|
|000025f0| 63 74 69 6f 6e 61 6c 20 | 61 70 70 72 6f 61 63 68 |ctional |approach|
|00002600| 20 74 6f 20 69 6e 64 65 | 78 69 6e 67 2e 20 54 77 | to inde|xing. Tw|
|00002610| 6f 20 69 6e 64 65 78 20 | 66 75 6e 63 74 69 6f 6e |o index |function|
|00002620| 73 20 77 65 72 65 0d 0a | 63 72 65 61 74 65 64 2c |s were..|created,|
|00002630| 20 6f 6e 65 20 66 6f 72 | 20 65 61 63 68 20 73 69 | one for| each si|
|00002640| 64 65 20 6f 66 20 61 6e | 20 65 71 75 61 6c 73 20 |de of an| equals |
|00002650| 6f 70 65 72 61 74 6f 72 | 2e 20 54 68 65 0d 0a 6c |operator|. The..l|
|00002660| 69 74 74 6c 65 20 6d 28 | 69 2c 6a 29 20 72 65 74 |ittle m(|i,j) ret|
|00002670| 75 72 6e 73 20 61 20 64 | 6f 75 62 6c 65 2e 20 54 |urns a d|ouble. T|
|00002680| 68 65 20 62 69 67 20 4d | 28 69 2c 6a 29 20 72 65 |he big M|(i,j) re|
|00002690| 74 75 72 6e 73 20 61 0d | 0a 72 65 66 65 72 65 6e |turns a.|.referen|
|000026a0| 63 65 20 74 6f 20 61 20 | 56 4d 61 74 72 69 78 2e |ce to a |VMatrix.|
|000026b0| 20 42 6f 74 68 20 66 75 | 6e 63 74 69 6f 6e 73 20 | Both fu|nctions |
|000026c0| 63 61 6c 6c 20 6d 69 6e | 64 65 78 28 29 20 61 6e |call min|dex() an|
|000026d0| 64 0d 0a 73 65 74 20 63 | 75 72 76 65 63 69 6e 64 |d..set c|urvecind|
|000026e0| 2e 20 20 54 68 65 20 64 | 69 66 66 65 72 65 6e 63 |. The d|ifferenc|
|000026f0| 65 20 62 65 74 77 65 65 | 6e 20 74 68 65 20 74 77 |e betwee|n the tw|
|00002700| 6f 20 6f 70 65 72 61 74 | 6f 72 73 20 69 73 0d 0a |o operat|ors is..|
|00002710| 74 68 61 74 20 6d 28 69 | 2c 6a 29 20 63 61 6c 6c |that m(i|,j) call|
|00002720| 73 20 74 68 65 20 76 64 | 6f 75 62 20 6d 65 6d 62 |s the vd|oub memb|
|00002730| 65 72 20 66 75 6e 63 74 | 69 6f 6e 20 76 28 29 20 |er funct|ion v() |
|00002740| 66 6f 72 0d 0a 72 65 74 | 75 72 6e 69 6e 67 20 61 |for..ret|urning a|
|00002750| 20 6d 61 74 72 69 78 20 | 65 6c 65 6d 65 6e 74 2e | matrix |element.|
|00002760| 20 54 68 65 20 66 75 6e | 63 74 69 6f 6e 20 4d 28 | The fun|ction M(|
|00002770| 69 2c 6a 29 20 63 61 6c | 6c 73 20 74 68 65 0d 0a |i,j) cal|ls the..|
|00002780| 76 64 6f 75 62 20 62 72 | 61 63 6b 65 74 20 6f 70 |vdoub br|acket op|
|00002790| 65 72 61 74 6f 72 73 2e | 20 59 6f 75 20 63 61 6e |erators.| You can|
|000027a0| 20 74 68 69 6e 6b 20 6f | 66 0d 0a 4d 28 69 2c 6a | think o|f..M(i,j|
|000027b0| 29 5c 69 6e 64 65 78 7b | 56 4d 61 74 72 69 78 21 |)\index{|VMatrix!|
|000027c0| 4d 28 29 7d 20 61 6e 64 | 20 6d 28 69 2c 6a 29 5c |M()} and| m(i,j)\|
|000027d0| 69 6e 64 65 78 7b 56 4d | 61 74 72 69 78 21 6d 28 |index{VM|atrix!m(|
|000027e0| 29 7d 20 61 73 0d 0a 73 | 75 72 72 6f 67 61 74 65 |)} as..s|urrogate|
|000027f0| 73 20 66 6f 72 20 76 64 | 6f 75 62 3a 3a 6f 70 65 |s for vd|oub::ope|
|00002800| 72 61 74 6f 72 5b 5d 20 | 61 6e 64 20 74 68 65 20 |rator[] |and the |
|00002810| 76 64 6f 75 62 20 66 75 | 6e 63 74 69 6f 6e 0d 0a |vdoub fu|nction..|
|00002820| 76 28 29 2e 0d 0a 0d 0a | 54 6f 20 61 73 73 69 67 |v().....|To assig|
|00002830| 6e 20 61 6e 20 65 6c 65 | 6d 65 6e 74 20 74 6f 20 |n an ele|ment to |
|00002840| 61 20 6d 61 74 72 69 78 | 2c 20 75 73 65 20 73 74 |a matrix|, use st|
|00002850| 61 74 65 6d 65 6e 74 73 | 20 6c 69 6b 65 0d 0a 5c |atements| like..\|
|00002860| 62 65 67 69 6e 7b 76 65 | 72 62 61 74 69 6d 7d 0d |begin{ve|rbatim}.|
|00002870| 0a 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |. | |
|00002880| 20 4d 41 54 31 2e 4d 28 | 69 2c 6a 29 20 3d 20 4d | MAT1.M(|i,j) = M|
|00002890| 41 54 32 2e 6d 28 69 2c | 6a 29 3b 20 0d 0a 20 20 |AT2.m(i,|j); .. |
|000028a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 4d 41 | | MA|
|000028b0| 54 31 2e 4d 28 69 2c 6a | 29 20 3d 20 61 64 6f 75 |T1.M(i,j|) = adou|
|000028c0| 62 6c 65 3b 0d 0a 20 20 | 20 20 20 20 20 20 20 20 |ble;.. | |
|000028d0| 20 20 20 20 20 20 4d 61 | 74 70 6f 69 6e 74 65 72 | Ma|tpointer|
|000028e0| 31 2d 3e 4d 28 69 2c 6a | 29 20 3d 20 4d 61 74 70 |1->M(i,j|) = Matp|
|000028f0| 6f 69 6e 74 65 72 32 2d | 3e 6d 28 69 2c 6a 29 3b |ointer2-|>m(i,j);|
|00002900| 0d 0a 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |.. | |
|00002910| 20 20 4d 61 74 70 6f 69 | 6e 74 65 72 31 2d 3e 4d | Matpoi|nter1->M|
|00002920| 28 69 2c 6a 29 20 3d 20 | 61 6e 6f 74 68 65 72 5f |(i,j) = |another_|
|00002930| 64 6f 75 62 6c 65 3b 0d | 0a 5c 65 6e 64 7b 76 65 |double;.|.\end{ve|
|00002940| 72 62 61 74 69 6d 7d 0d | 0a 77 68 65 72 65 20 4d |rbatim}.|.where M|
|00002950| 41 54 31 20 61 6e 64 20 | 4d 41 54 32 20 61 72 65 |AT1 and |MAT2 are|
|00002960| 20 76 69 72 74 75 61 6c | 20 6d 61 74 72 69 63 65 | virtual| matrice|
|00002970| 73 2c 20 61 6e 64 20 4d | 61 74 70 6f 69 6e 74 65 |s, and M|atpointe|
|00002980| 72 73 0d 0a 61 72 65 20 | 70 6f 69 6e 74 65 72 73 |rs..are |pointers|
|00002990| 20 74 6f 20 76 69 72 74 | 75 61 6c 20 6d 61 74 72 | to virt|ual matr|
|000029a0| 69 63 65 73 2e 20 54 68 | 65 20 62 61 73 69 63 20 |ices. Th|e basic |
|000029b0| 69 64 65 61 20 61 74 20 | 77 6f 72 6b 0d 0a 68 65 |idea at |work..he|
|000029c0| 72 65 20 69 73 20 74 68 | 61 74 20 61 20 76 69 72 |re is th|at a vir|
|000029d0| 74 75 61 6c 20 6d 61 74 | 72 69 78 20 69 73 20 64 |tual mat|rix is d|
|000029e0| 65 72 69 76 65 64 20 66 | 72 6f 6d 20 74 68 65 20 |erived f|rom the |
|000029f0| 76 69 72 74 75 61 6c 0d | 0a 76 65 63 74 6f 72 2e |virtual.|.vector.|
|00002a00| 20 54 68 65 20 76 65 63 | 74 6f 72 20 66 75 6e 63 | The vec|tor func|
|00002a10| 74 69 6f 6e 73 20 61 72 | 65 20 61 76 61 69 6c 61 |tions ar|e availa|
|00002a20| 62 6c 65 20 74 6f 20 74 | 68 65 20 6d 61 74 72 69 |ble to t|he matri|
|00002a30| 78 0d 0a 63 6c 61 73 73 | 2c 20 61 6e 64 20 73 6f |x..class|, and so|
|00002a40| 20 61 73 73 69 67 6e 6d | 65 6e 74 20 6f 66 20 6d | assignm|ent of m|
|00002a50| 61 74 72 69 78 20 65 6c | 65 6d 65 6e 74 73 20 77 |atrix el|ements w|
|00002a60| 6f 72 6b 73 20 6a 75 73 | 74 20 61 73 0d 0a 69 6e |orks jus|t as..in|
|00002a70| 20 76 69 72 74 75 61 6c | 20 76 65 63 74 6f 72 73 | virtual| vectors|
|00002a80| 2e 20 54 68 65 20 6f 6e | 6c 79 20 64 69 66 66 65 |. The on|ly diffe|
|00002a90| 72 65 6e 63 65 20 69 73 | 20 74 68 61 74 20 74 68 |rence is| that th|
|00002aa0| 65 20 69 6e 64 65 78 0d | 0a 68 61 73 20 74 6f 20 |e index.|.has to |
|00002ab0| 62 65 20 63 61 6c 63 75 | 6c 61 74 65 64 20 62 65 |be calcu|lated be|
|00002ac0| 66 6f 72 65 20 74 68 65 | 20 76 65 63 74 6f 72 20 |fore the| vector |
|00002ad0| 66 75 6e 63 74 69 6f 6e | 73 20 63 61 6e 20 62 65 |function|s can be|
|00002ae0| 0d 0a 63 61 6c 6c 65 64 | 2e 20 54 68 65 20 63 6f |..called|. The co|
|00002af0| 64 65 20 66 6f 72 20 61 | 73 73 69 67 6e 69 6e 67 |de for a|ssigning|
|00002b00| 20 61 6e 20 65 6c 65 6d | 65 6e 74 20 69 73 0d 0a | an elem|ent is..|
|00002b10| 5c 62 65 67 69 6e 7b 76 | 65 72 62 61 74 69 6d 7d |\begin{v|erbatim}|
|00002b20| 0d 0a 20 20 20 64 6f 75 | 62 6c 65 20 6f 70 65 72 |.. dou|ble oper|
|00002b30| 61 74 6f 72 20 3d 20 28 | 20 64 6f 75 62 6c 65 20 |ator = (| double |
|00002b40| 64 20 29 7b 20 20 20 20 | 20 2f 2f 20 77 72 69 74 |d ){ | // writ|
|00002b50| 65 20 69 6e 20 61 20 76 | 61 6c 75 65 0d 0a 20 20 |e in a v|alue.. |
|00002b60| 20 20 20 76 64 6f 75 62 | 3a 3a 6f 70 65 72 61 74 | vdoub|::operat|
|00002b70| 6f 72 5b 5d 28 63 75 72 | 76 65 63 69 6e 64 29 20 |or[](cur|vecind) |
|00002b80| 3d 20 64 3b 0d 0a 20 20 | 20 20 20 72 65 74 75 72 |= d;.. | retur|
|00002b90| 6e 20 64 3b 0d 0a 20 20 | 20 7d 0d 0a 5c 65 6e 64 |n d;.. | }..\end|
|00002ba0| 7b 76 65 72 62 61 74 69 | 6d 7d 0d 0a 54 68 65 20 |{verbati|m}..The |
|00002bb0| 73 63 6f 70 65 20 72 65 | 73 6f 6c 75 74 69 6f 6e |scope re|solution|
|00002bc0| 20 6f 70 65 72 61 74 6f | 72 20 69 73 20 72 65 71 | operato|r is req|
|00002bd0| 75 69 72 65 64 20 74 6f | 20 74 65 6c 6c 20 74 68 |uired to| tell th|
|00002be0| 65 0d 0a 63 6f 6d 70 69 | 6c 65 72 20 74 6f 20 75 |e..compi|ler to u|
|00002bf0| 73 65 20 74 68 65 20 65 | 71 75 61 6c 73 20 6f 70 |se the e|quals op|
|00002c00| 65 72 61 74 6f 72 20 66 | 72 6f 6d 20 74 68 65 20 |erator f|rom the |
|00002c10| 70 61 72 65 6e 74 20 63 | 6c 61 73 73 0d 0a 72 61 |parent c|lass..ra|
|00002c20| 74 68 65 72 20 74 68 61 | 6e 20 74 68 65 20 56 4d |ther tha|n the VM|
|00002c30| 61 74 72 69 78 20 63 6c | 61 73 73 2e 20 0d 0a 0d |atrix cl|ass. ...|
|00002c40| 0a 5c 73 75 62 73 65 63 | 74 69 6f 6e 7b 41 73 73 |.\subsec|tion{Ass|
|00002c50| 69 67 6e 6d 65 6e 74 20 | 6f 66 20 4d 61 74 72 69 |ignment |of Matri|
|00002c60| 63 65 73 7d 0d 0a 0d 0a | 4d 61 74 72 69 78 20 61 |ces}....|Matrix a|
|00002c70| 73 73 69 67 6e 6d 65 6e | 74 20 75 73 65 73 20 73 |ssignmen|t uses s|
|00002c80| 74 61 74 65 6d 65 6e 74 | 73 20 6c 69 6b 65 20 22 |tatement|s like "|
|00002c90| 41 3d 42 3b 22 20 77 68 | 65 72 65 20 41 20 61 6e |A=B;" wh|ere A an|
|00002ca0| 64 20 42 0d 0a 61 72 65 | 20 6d 61 74 72 69 63 65 |d B..are| matrice|
|00002cb0| 73 2e 20 54 68 65 20 6f | 70 65 72 61 74 6f 72 20 |s. The o|perator |
|00002cc0| 69 73 20 74 68 65 20 66 | 75 6e 63 74 69 6f 6e 20 |is the f|unction |
|00002cd0| 67 69 76 65 6e 20 62 79 | 20 74 68 65 20 63 6f 64 |given by| the cod|
|00002ce0| 65 0d 0a 5c 62 65 67 69 | 6e 7b 76 65 72 62 61 74 |e..\begi|n{verbat|
|00002cf0| 69 6d 7d 0d 0a 76 6f 69 | 64 20 56 4d 61 74 72 69 |im}..voi|d VMatri|
|00002d00| 78 3a 3a 6f 70 65 72 61 | 74 6f 72 3d 20 28 56 4d |x::opera|tor= (VM|
|00002d10| 61 74 72 69 78 20 26 52 | 4f 70 29 0d 0a 7b 0d 0a |atrix &R|Op)..{..|
|00002d20| 20 20 20 20 47 61 72 62 | 61 67 65 28 22 6f 70 65 | Garb|age("ope|
|00002d30| 72 61 74 6f 72 20 3d 22 | 29 3b 0d 0a 20 20 20 20 |rator ="|);.. |
|00002d40| 52 4f 70 2e 47 61 72 62 | 61 67 65 28 22 6f 70 65 |ROp.Garb|age("ope|
|00002d50| 72 61 74 6f 72 20 3d 22 | 29 3b 0d 0a 20 20 20 20 |rator ="|);.. |
|00002d60| 52 65 70 6c 61 63 65 28 | 20 52 4f 70 20 29 3b 0d |Replace(| ROp );.|
|00002d70| 0a 20 20 20 20 44 69 73 | 70 61 74 63 68 2d 3e 43 |. Dis|patch->C|
|00002d80| 6c 65 61 6e 73 74 61 63 | 6b 28 29 3b 0d 0a 7d 0d |leanstac|k();..}.|
|00002d90| 0a 5c 65 6e 64 7b 76 65 | 72 62 61 74 69 6d 7d 0d |.\end{ve|rbatim}.|
|00002da0| 0a 54 68 65 20 6f 70 65 | 72 61 6e 64 73 20 61 72 |.The ope|rands ar|
|00002db0| 65 20 63 68 65 63 6b 65 | 64 20 66 6f 72 20 76 61 |e checke|d for va|
|00002dc0| 6c 69 64 69 74 79 2e 20 | 54 68 65 20 6c 65 66 74 |lidity. |The left|
|00002dd0| 20 6f 70 65 72 61 6e 64 | 20 68 61 73 0d 0a 69 74 | operand| has..it|
|00002de0| 73 20 68 65 61 64 65 72 | 20 72 65 70 6c 61 63 65 |s header| replace|
|00002df0| 64 2e 20 54 68 65 6e 2c | 20 61 6e 79 20 69 6e 74 |d. Then,| any int|
|00002e00| 65 72 6d 65 64 69 61 74 | 65 20 73 74 61 63 6b 20 |ermediat|e stack |
|00002e10| 6d 61 74 72 69 63 65 73 | 0d 0a 61 72 65 20 72 65 |matrices|..are re|
|00002e20| 6d 6f 76 65 64 20 66 72 | 6f 6d 20 74 68 65 20 73 |moved fr|om the s|
|00002e30| 74 61 63 6b 2e 0d 0a 0d | 0a 43 6c 65 61 6e 73 74 |tack....|.Cleanst|
|00002e40| 61 63 6b 28 29 20 77 69 | 6c 6c 20 62 65 20 64 69 |ack() wi|ll be di|
|00002e50| 73 63 75 73 73 65 64 20 | 69 6e 20 74 68 65 20 63 |scussed |in the c|
|00002e60| 68 61 70 74 65 72 20 6f | 6e 20 74 68 65 20 6d 61 |hapter o|n the ma|
|00002e70| 74 72 69 78 0d 0a 73 74 | 61 63 6b 2e 20 42 61 73 |trix..st|ack. Bas|
|00002e80| 69 63 61 6c 6c 79 20 69 | 74 20 73 65 72 76 65 73 |ically i|t serves|
|00002e90| 20 74 6f 20 64 69 73 70 | 6f 73 65 20 6f 66 20 74 | to disp|ose of t|
|00002ea0| 68 65 20 69 6e 74 65 72 | 6d 65 64 69 61 74 65 0d |he inter|mediate.|
|00002eb0| 0a 72 65 73 75 6c 74 73 | 20 6f 66 20 61 20 72 65 |.results| of a re|
|00002ec0| 70 65 61 74 65 64 20 63 | 61 6c 63 75 6c 61 74 69 |peated c|alculati|
|00002ed0| 6f 6e 2e 20 53 75 70 70 | 6f 73 65 20 79 6f 75 20 |on. Supp|ose you |
|00002ee0| 75 73 65 20 74 68 65 0d | 0a 73 74 61 74 65 6d 65 |use the.|.stateme|
|00002ef0| 6e 74 20 5c 76 65 72 62 | 23 20 63 3d 61 2b 62 2b |nt \verb|# c=a+b+|
|00002f00| 64 20 23 2e 20 54 68 65 | 20 73 75 6d 20 62 2b 64 |d #. The| sum b+d|
|00002f10| 20 69 73 20 63 61 6c 63 | 75 6c 61 74 65 64 2c 20 | is calc|ulated, |
|00002f20| 74 68 65 6e 0d 0a 61 64 | 64 65 64 20 74 6f 20 61 |then..ad|ded to a|
|00002f30| 2c 20 61 6e 64 20 74 68 | 65 20 72 65 73 75 6c 74 |, and th|e result|
|00002f40| 20 69 73 20 61 73 73 69 | 67 6e 65 64 20 74 6f 20 | is assi|gned to |
|00002f50| 63 2e 20 54 68 65 0d 0a | 69 6e 74 65 72 6d 65 64 |c. The..|intermed|
|00002f60| 69 61 74 65 20 63 61 6c | 63 75 6c 61 74 69 6f 6e |iate cal|culation|
|00002f70| 20 6f 66 20 62 2b 64 20 | 69 73 20 73 74 69 6c 6c | of b+d |is still|
|00002f80| 20 6f 6e 20 74 68 65 20 | 68 65 61 70 20 69 6e 20 | on the |heap in |
|00002f90| 74 68 65 0d 0a 73 74 61 | 63 6b 2e 20 20 43 6c 65 |the..sta|ck. Cle|
|00002fa0| 61 6e 73 74 61 63 6b 28 | 29 5c 69 6e 64 65 78 7b |anstack(|)\index{|
|00002fb0| 4d 53 74 61 63 6b 21 43 | 6c 65 61 6e 73 74 61 63 |MStack!C|leanstac|
|00002fc0| 6b 28 29 7d 20 72 65 6d | 6f 76 65 73 20 62 2b 64 |k()} rem|oves b+d|
|00002fd0| 20 61 6e 64 0d 0a 61 2b | 28 62 2b 64 29 20 66 72 | and..a+|(b+d) fr|
|00002fe0| 6f 6d 20 74 68 65 20 73 | 74 61 63 6b 2e 20 0d 0a |om the s|tack. ..|
|00002ff0| 0d 0a 0d 0a 5c 73 75 62 | 73 65 63 74 69 6f 6e 7b |....\sub|section{|
|00003000| 43 6f 6e 73 74 72 75 63 | 74 6f 72 73 20 61 6e 64 |Construc|tors and|
|00003010| 20 44 65 73 74 72 75 63 | 74 6f 72 73 7d 0d 0a 0d | Destruc|tors}...|
|00003020| 0a 54 68 65 72 65 20 61 | 72 65 20 74 68 72 65 65 |.There a|re three|
|00003030| 20 63 6f 6e 73 74 72 75 | 63 74 6f 72 73 20 66 6f | constru|ctors fo|
|00003040| 72 20 56 4d 61 74 72 69 | 63 65 73 2e 20 54 68 65 |r VMatri|ces. The|
|00003050| 20 64 65 66 61 75 6c 74 | 0d 0a 63 6f 6e 73 74 72 | default|..constr|
|00003060| 75 63 74 6f 72 20 74 61 | 6b 65 73 20 61 20 76 6f |uctor ta|kes a vo|
|00003070| 69 64 20 61 72 67 75 6d | 65 6e 74 2e 20 4e 6f 74 |id argum|ent. Not|
|00003080| 65 20 74 68 61 74 20 73 | 69 6e 63 65 20 61 0d 0a |e that s|ince a..|
|00003090| 56 4d 61 74 72 69 78 20 | 69 73 20 61 20 73 75 62 |VMatrix |is a sub|
|000030a0| 2d 63 6c 61 73 73 20 6f | 66 20 61 20 76 64 6f 75 |-class o|f a vdou|
|000030b0| 62 2c 20 74 68 65 20 76 | 64 6f 75 62 20 63 6f 6e |b, the v|doub con|
|000030c0| 73 74 72 75 63 74 6f 72 | 20 69 73 0d 0a 63 61 6c |structor| is..cal|
|000030d0| 6c 65 64 20 66 69 72 73 | 74 2e 20 54 68 65 20 65 |led firs|t. The e|
|000030e0| 78 74 72 61 20 56 4d 61 | 74 72 69 78 20 65 6c 65 |xtra VMa|trix ele|
|000030f0| 6d 65 6e 74 73 20 61 72 | 65 20 73 75 70 70 6c 69 |ments ar|e suppli|
|00003100| 65 64 20 6e 65 78 74 2e | 0d 0a 54 68 65 20 64 65 |ed next.|..The de|
|00003110| 66 61 75 6c 74 20 63 6f | 6e 73 74 72 75 63 74 6f |fault co|nstructo|
|00003120| 72 5c 69 6e 64 65 78 7b | 56 4d 61 74 72 69 78 21 |r\index{|VMatrix!|
|00003130| 63 6f 6e 73 74 72 75 63 | 74 6f 72 7d 20 73 65 74 |construc|tor} set|
|00003140| 73 20 74 68 65 0d 0a 6e | 61 6d 65 20 74 6f 20 27 |s the..n|ame to '|
|00003150| 74 27 2c 20 61 6e 64 20 | 61 6c 6c 6f 63 61 74 65 |t', and |allocate|
|00003160| 73 20 61 20 31 78 31 20 | 6d 61 74 72 69 78 2e 0d |s a 1x1 |matrix..|
|00003170| 0a 0d 0a 54 68 65 20 73 | 65 63 6f 6e 64 20 66 6f |...The s|econd fo|
|00003180| 72 6d 20 6f 66 20 74 68 | 65 20 63 6f 6e 73 74 72 |rm of th|e constr|
|00003190| 75 63 74 6f 72 20 69 73 | 20 67 69 76 65 6e 20 69 |uctor is| given i|
|000031a0| 6e 20 74 68 65 20 63 6f | 64 65 20 62 65 6c 6f 77 |n the co|de below|
|000031b0| 3a 0d 0a 5c 62 65 67 69 | 6e 7b 76 65 72 62 61 74 |:..\begi|n{verbat|
|000031c0| 69 6d 7d 0d 0a 56 4d 61 | 74 72 69 78 3a 3a 56 4d |im}..VMa|trix::VM|
|000031d0| 61 74 72 69 78 28 20 63 | 6f 6e 73 74 20 63 68 61 |atrix( c|onst cha|
|000031e0| 72 20 2a 73 74 72 2c 20 | 69 6e 74 20 72 72 2c 20 |r *str, |int rr, |
|000031f0| 69 6e 74 20 63 63 29 3a | 0d 0a 20 20 20 20 76 64 |int cc):|.. vd|
|00003200| 6f 75 62 28 20 28 28 6c | 6f 6e 67 20 29 28 28 6c |oub( ((l|ong )((l|
|00003210| 6f 6e 67 29 20 72 72 29 | 2a 28 28 6c 6f 6e 67 29 |ong) rr)|*((long)|
|00003220| 20 63 63 29 29 20 29 0d | 0a 20 20 7b 0d 0a 20 20 | cc)) ).|. {.. |
|00003230| 20 20 72 3d 72 72 3b 0d | 0a 20 20 20 20 63 3d 63 | r=rr;.|. c=c|
|00003240| 63 3b 0d 0a 20 20 20 20 | 63 75 72 76 65 63 69 6e |c;.. |curvecin|
|00003250| 64 20 3d 20 30 3b 0d 0a | 20 20 20 20 4e 61 6d 65 |d = 0;..| Name|
|00003260| 69 74 28 20 73 74 72 20 | 29 3b 0d 0a 20 20 20 20 |it( str |);.. |
|00003270| 73 69 67 6e 61 74 75 72 | 65 20 3d 20 53 49 47 4e |signatur|e = SIGN|
|00003280| 41 54 55 52 45 3b 0d 0a | 20 20 7d 0d 0a 5c 65 6e |ATURE;..| }..\en|
|00003290| 64 7b 76 65 72 62 61 74 | 69 6d 7d 0d 0a 54 68 65 |d{verbat|im}..The|
|000032a0| 20 73 65 63 6f 6e 64 20 | 6c 69 6e 65 20 6f 66 20 | second |line of |
|000032b0| 74 68 69 73 20 63 6f 6e | 73 74 72 75 63 74 6f 72 |this con|structor|
|000032c0| 20 63 61 6c 6c 73 20 74 | 68 65 20 76 64 6f 75 62 | calls t|he vdoub|
|000032d0| 0d 0a 63 6f 6e 73 74 72 | 75 63 74 6f 72 20 77 69 |..constr|uctor wi|
|000032e0| 74 68 20 61 20 64 65 66 | 61 75 6c 74 20 76 65 63 |th a def|ault vec|
|000032f0| 74 6f 72 20 6c 65 6e 67 | 74 68 20 6f 66 20 72 72 |tor leng|th of rr|
|00003300| 2a 63 63 2e 20 54 68 65 | 0d 0a 63 61 73 74 73 20 |*cc. The|..casts |
|00003310| 61 76 6f 69 64 20 74 79 | 70 65 20 70 72 6f 6d 6f |avoid ty|pe promo|
|00003320| 74 69 6f 6e 20 70 72 6f | 62 6c 65 6d 73 2e 20 54 |tion pro|blems. T|
|00003330| 68 65 20 63 6f 6e 73 74 | 72 75 63 74 6f 72 20 73 |he const|ructor s|
|00003340| 65 74 73 0d 0a 74 68 65 | 20 6e 61 6d 65 20 74 6f |ets..the| name to|
|00003350| 20 74 68 65 20 73 75 70 | 70 6c 69 65 64 20 73 74 | the sup|plied st|
|00003360| 72 69 6e 67 2e 20 0d 0a | 0d 0a 54 68 65 20 74 68 |ring. ..|..The th|
|00003370| 69 72 64 20 63 6f 6e 73 | 74 72 75 63 74 6f 72 20 |ird cons|tructor |
|00003380| 69 73 20 61 20 63 6f 70 | 79 20 63 6f 6e 73 74 72 |is a cop|y constr|
|00003390| 75 63 74 6f 72 2e 20 54 | 68 69 73 20 61 6c 6c 6f |uctor. T|his allo|
|000033a0| 77 73 20 0d 0a 73 74 61 | 74 65 6d 65 6e 74 73 20 |ws ..sta|tements |
|000033b0| 6c 69 6b 65 20 5c 76 65 | 72 62 23 56 4d 61 74 72 |like \ve|rb#VMatr|
|000033c0| 69 78 20 63 20 3d 20 62 | 3b 23 20 74 6f 20 62 65 |ix c = b|;# to be|
|000033d0| 20 75 73 65 64 2e 0d 0a | 54 68 69 73 20 63 72 65 | used...|This cre|
|000033e0| 61 74 65 73 20 74 68 65 | 20 6e 65 77 20 6d 61 74 |ates the| new mat|
|000033f0| 72 69 78 20 63 2c 20 61 | 6e 64 20 74 68 65 6e 20 |rix c, a|nd then |
|00003400| 63 6f 70 69 65 73 20 62 | 20 69 6e 74 6f 20 69 74 |copies b| into it|
|00003410| 2e 0d 0a 54 68 65 20 61 | 73 73 69 67 6e 6d 65 6e |...The a|ssignmen|
|00003420| 74 20 6d 61 79 20 61 6c | 73 6f 20 62 65 20 61 20 |t may al|so be a |
|00003430| 66 75 6e 63 74 69 6f 6e | 20 63 61 6c 6c 2c 20 6f |function| call, o|
|00003440| 72 20 72 65 70 65 61 74 | 65 64 0d 0a 6f 70 65 72 |r repeat|ed..oper|
|00003450| 61 74 69 6f 6e 73 2e 20 | 4d 61 74 72 69 78 20 70 |ations. |Matrix p|
|00003460| 6f 69 6e 74 65 72 73 20 | 63 61 6e 20 61 6c 73 6f |ointers |can also|
|00003470| 20 62 65 20 63 72 65 61 | 74 65 64 20 62 79 0d 0a | be crea|ted by..|
|00003480| 66 75 6e 63 74 69 6f 6e | 73 20 73 75 63 68 20 61 |function|s such a|
|00003490| 73 20 5c 76 65 72 62 23 | 20 56 4d 61 74 72 69 78 |s \verb#| VMatrix|
|000034a0| 20 2a 4d 61 74 20 3d 20 | 6e 65 77 20 56 4d 61 74 | *Mat = |new VMat|
|000034b0| 72 69 78 3b 23 2e 0d 0a | 4e 6f 74 65 20 74 68 61 |rix;#...|Note tha|
|000034c0| 74 20 74 68 65 20 63 6f | 70 79 20 63 6f 6e 73 74 |t the co|py const|
|000034d0| 72 75 63 74 6f 72 20 63 | 61 6c 6c 73 20 63 6c 65 |ructor c|alls cle|
|000034e0| 61 6e 73 74 61 63 6b 28 | 29 2c 20 73 6f 0d 0a 74 |anstack(|), so..t|
|000034f0| 68 65 20 73 74 61 63 6b | 20 69 73 20 63 6c 65 61 |he stack| is clea|
|00003500| 72 65 64 20 61 66 74 65 | 72 20 74 68 65 20 63 6f |red afte|r the co|
|00003510| 6e 73 74 72 75 63 74 6f | 72 20 69 73 20 63 61 6c |nstructo|r is cal|
|00003520| 6c 65 64 2e 20 0d 0a 54 | 68 75 73 2c 20 79 6f 75 |led. ..T|hus, you|
|00003530| 20 6d 75 73 74 20 75 73 | 65 20 5c 76 65 72 62 23 | must us|e \verb#|
|00003540| 44 69 73 70 61 74 63 68 | 2d 3e 49 6e 63 6c 65 76 |Dispatch|->Inclev|
|00003550| 65 6c 28 29 23 20 61 6e | 64 0d 0a 5c 76 65 72 62 |el()# an|d..\verb|
|00003560| 23 44 69 73 70 61 74 63 | 68 2d 3e 44 65 63 6c 65 |#Dispatc|h->Decle|
|00003570| 76 65 6c 28 29 23 20 70 | 61 69 72 73 20 69 6e 20 |vel()# p|airs in |
|00003580| 66 75 6e 63 74 69 6f 6e | 73 20 74 68 61 74 20 63 |function|s that c|
|00003590| 61 6c 6c 20 74 68 65 0d | 0a 63 6f 70 79 20 63 6f |all the.|.copy co|
|000035a0| 6e 73 74 72 75 63 74 6f | 72 2e 0d 0a 0d 0a 54 68 |nstructo|r.....Th|
|000035b0| 65 20 64 65 73 74 72 75 | 63 74 6f 72 5c 69 6e 64 |e destru|ctor\ind|
|000035c0| 65 78 7b 56 4d 61 74 72 | 69 78 21 64 65 73 74 72 |ex{VMatr|ix!destr|
|000035d0| 75 63 74 6f 72 7d 20 66 | 69 72 73 74 20 63 61 6c |uctor} f|irst cal|
|000035e0| 6c 73 20 74 68 65 0d 0a | 64 65 73 74 72 75 63 74 |ls the..|destruct|
|000035f0| 6f 72 20 66 6f 72 20 74 | 68 65 20 76 64 6f 75 62 |or for t|he vdoub|
|00003600| 2c 20 72 65 74 75 72 6e | 73 2c 20 61 6e 64 20 73 |, return|s, and s|
|00003610| 65 74 73 20 74 68 65 20 | 73 69 67 6e 61 74 75 72 |ets the |signatur|
|00003620| 65 0d 0a 74 6f 20 7a 65 | 72 6f 2e 0d 0a 0d 0a 5c |e..to ze|ro.....\|
|00003630| 73 75 62 73 65 63 74 69 | 6f 6e 7b 54 68 65 20 4e |subsecti|on{The N|
|00003640| 61 6d 69 6e 67 20 46 75 | 6e 63 74 69 6f 6e 73 7d |aming Fu|nctions}|
|00003650| 0d 0a 0d 0a 54 68 65 20 | 6e 61 6d 69 6e 67 20 66 |....The |naming f|
|00003660| 75 6e 63 74 69 6f 6e 73 | 20 73 74 6f 72 65 20 74 |unctions| store t|
|00003670| 68 65 20 6e 61 6d 65 2c | 20 72 65 74 72 69 65 76 |he name,| retriev|
|00003680| 65 20 74 68 65 20 6e 61 | 6d 65 2c 0d 0a 64 69 73 |e the na|me,..dis|
|00003690| 70 6c 61 79 20 74 68 65 | 20 6e 61 6d 65 2c 20 6f |play the| name, o|
|000036a0| 72 20 72 65 74 75 72 6e | 20 74 68 65 20 61 64 64 |r return| the add|
|000036b0| 72 65 73 73 20 6f 66 20 | 74 68 65 20 6e 61 6d 65 |ress of |the name|
|000036c0| 2e 20 54 68 65 0d 0a 66 | 75 6e 63 74 69 6f 6e 20 |. The..f|unction |
|000036d0| 4e 61 6d 65 69 74 28 29 | 5c 69 6e 64 65 78 7b 56 |Nameit()|\index{V|
|000036e0| 4d 61 74 72 69 78 21 4e | 61 6d 65 69 74 28 29 7d |Matrix!N|ameit()}|
|000036f0| 20 61 63 63 65 70 74 73 | 20 73 74 72 69 6e 67 0d | accepts| string.|
|00003700| 0a 63 6f 6e 73 74 61 6e | 74 73 2c 20 56 4d 61 74 |.constan|ts, VMat|
|00003710| 72 69 78 20 72 65 66 65 | 72 65 6e 63 65 73 2c 20 |rix refe|rences, |
|00003720| 6f 72 20 73 74 72 69 6e | 67 20 6f 62 6a 65 63 74 |or strin|g object|
|00003730| 73 2e 20 54 68 65 0d 0a | 70 72 6f 70 65 72 20 66 |s. The..|proper f|
|00003740| 75 6e 63 74 69 6f 6e 73 | 20 61 72 65 20 63 61 6c |unctions| are cal|
|00003750| 6c 65 64 20 74 6f 20 61 | 73 73 69 67 6e 20 74 68 |led to a|ssign th|
|00003760| 65 20 6e 61 6d 65 20 74 | 6f 20 74 68 65 0d 0a 6d |e name t|o the..m|
|00003770| 61 74 72 69 78 2e 20 0d | 0a 0d 0a 54 68 65 20 66 |atrix. .|...The f|
|00003780| 75 6e 63 74 69 6f 6e 20 | 47 65 74 6e 61 6d 65 28 |unction |Getname(|
|00003790| 29 5c 69 6e 64 65 78 7b | 56 4d 61 74 72 69 78 21 |)\index{|VMatrix!|
|000037a0| 67 65 74 6e 61 6d 65 28 | 29 7d 20 72 65 74 75 72 |getname(|)} retur|
|000037b0| 6e 73 20 61 0d 0a 73 74 | 72 69 6e 67 20 74 79 70 |ns a..st|ring typ|
|000037c0| 65 20 6f 62 6a 65 63 74 | 20 63 6f 6e 74 61 69 6e |e object| contain|
|000037d0| 69 6e 67 20 74 68 65 20 | 6e 61 6d 65 20 6f 66 20 |ing the |name of |
|000037e0| 74 68 65 20 6d 61 74 72 | 69 78 2e 20 54 68 69 73 |the matr|ix. This|
|000037f0| 0d 0a 63 61 6e 20 62 65 | 20 75 73 65 64 20 69 6e |..can be| used in|
|00003800| 20 63 6f 6e 63 61 74 65 | 6e 61 74 69 6f 6e 20 61 | concate|nation a|
|00003810| 6e 64 20 61 73 73 69 67 | 6e 6d 65 6e 74 20 77 69 |nd assig|nment wi|
|00003820| 74 68 20 6f 74 68 65 72 | 0d 0a 73 74 72 69 6e 67 |th other|..string|
|00003830| 73 2e 20 0d 0a 0d 0a 54 | 68 65 20 66 75 6e 63 74 |s. ....T|he funct|
|00003840| 69 6f 6e 20 53 74 72 69 | 6e 67 41 64 64 72 65 73 |ion Stri|ngAddres|
|00003850| 73 28 29 20 72 65 74 75 | 72 6e 73 20 74 68 65 20 |s() retu|rns the |
|00003860| 61 64 64 72 65 73 73 20 | 6f 66 20 74 68 65 0d 0a |address |of the..|
|00003870| 6d 61 74 72 69 78 20 6e | 61 6d 65 2e 20 54 68 69 |matrix n|ame. Thi|
|00003880| 73 20 66 75 6e 63 74 69 | 6f 6e 20 69 73 20 75 73 |s functi|on is us|
|00003890| 65 64 20 69 6e 20 74 68 | 65 20 57 72 69 74 65 62 |ed in th|e Writeb|
|000038a0| 20 61 6e 64 20 57 72 69 | 74 65 61 0d 0a 66 75 6e | and Wri|tea..fun|
|000038b0| 63 74 69 6f 6e 73 20 77 | 68 65 72 65 20 61 6e 20 |ctions w|here an |
|000038c0| 61 64 64 72 65 73 73 20 | 69 73 20 75 73 65 64 2e |address |is used.|
|000038d0| 20 54 68 69 73 20 66 75 | 6e 63 74 69 6f 6e 20 6d | This fu|nction m|
|000038e0| 61 79 20 6e 6f 74 0d 0a | 62 65 20 6f 66 20 6d 75 |ay not..|be of mu|
|000038f0| 63 68 20 75 73 65 20 6f | 74 68 65 72 77 69 73 65 |ch use o|therwise|
|00003900| 2e 20 59 6f 75 20 73 68 | 6f 75 6c 64 20 6e 6f 74 |. You sh|ould not|
|00003910| 20 6d 61 6e 69 70 75 6c | 61 74 65 20 74 68 65 0d | manipul|ate the.|
|00003920| 0a 6e 61 6d 65 20 64 69 | 72 65 63 74 6c 79 2c 20 |.name di|rectly, |
|00003930| 65 76 65 6e 20 74 68 6f | 75 67 68 20 79 6f 75 20 |even tho|ugh you |
|00003940| 6b 6e 6f 77 20 69 74 73 | 20 62 61 73 65 20 61 64 |know its| base ad|
|00003950| 64 72 65 73 73 2e 20 4c | 65 74 0d 0a 74 68 65 20 |dress. L|et..the |
|00003960| 73 74 72 69 6e 67 20 63 | 6c 61 73 73 20 6d 65 6d |string c|lass mem|
|00003970| 62 65 72 20 66 75 6e 63 | 74 69 6f 6e 73 20 64 6f |ber func|tions do|
|00003980| 20 69 74 20 66 6f 72 20 | 79 6f 75 2e 0d 0a 0d 0a | it for |you.....|
|00003990| 5c 73 75 62 73 65 63 74 | 69 6f 6e 7b 4f 74 68 65 |\subsect|ion{Othe|
|000039a0| 72 20 53 65 72 76 69 63 | 65 20 46 75 6e 63 74 69 |r Servic|e Functi|
|000039b0| 6f 6e 73 7d 0d 0a 0d 0a | 53 6f 6d 65 20 6f 74 68 |ons}....|Some oth|
|000039c0| 65 72 20 73 65 72 76 69 | 63 65 20 66 75 6e 63 74 |er servi|ce funct|
|000039d0| 69 6f 6e 73 20 61 72 65 | 20 61 76 61 69 6c 61 62 |ions are| availab|
|000039e0| 6c 65 2e 20 54 68 65 20 | 66 69 72 73 74 20 69 73 |le. The |first is|
|000039f0| 0d 0a 4c 6f 61 64 6d 61 | 74 28 29 5c 69 6e 64 65 |..Loadma|t()\inde|
|00003a00| 78 7b 56 4d 61 74 72 69 | 78 21 4c 6f 61 64 6d 61 |x{VMatri|x!Loadma|
|00003a10| 74 28 29 7d 20 77 68 69 | 63 68 20 61 6c 6c 6f 77 |t()} whi|ch allow|
|00003a20| 73 20 74 68 65 20 75 73 | 65 72 20 74 6f 0d 0a 65 |s the us|er to..e|
|00003a30| 6e 74 65 72 20 61 20 6d | 61 74 72 69 78 20 69 6e |nter a m|atrix in|
|00003a40| 74 65 72 61 63 74 69 76 | 65 6c 79 2e 20 54 6f 20 |teractiv|ely. To |
|00003a50| 75 73 65 20 74 68 69 73 | 20 66 75 6e 63 74 69 6f |use this| functio|
|00003a60| 6e 20 74 6f 20 65 6e 74 | 65 72 0d 0a 74 68 65 20 |n to ent|er..the |
|00003a70| 65 6c 65 6d 65 6e 74 73 | 20 6f 66 20 61 20 6d 61 |elements| of a ma|
|00003a80| 74 72 69 78 2c 20 75 73 | 65 20 63 6f 64 65 20 73 |trix, us|e code s|
|00003a90| 75 63 68 20 61 73 20 5c | 76 65 72 62 23 0d 0a 41 |uch as \|verb#..A|
|00003aa0| 2e 4c 6f 61 64 6d 61 74 | 28 29 23 20 6f 72 20 5c |.Loadmat|()# or \|
|00003ab0| 76 65 72 62 23 20 41 2d | 3e 4c 6f 61 64 6d 61 74 |verb# A-|>Loadmat|
|00003ac0| 28 29 23 2e 20 54 68 65 | 20 70 72 6f 67 72 61 6d |()#. The| program|
|00003ad0| 20 77 69 6c 6c 20 73 74 | 6f 70 0d 0a 61 6e 64 20 | will st|op..and |
|00003ae0| 6c 65 74 20 79 6f 75 20 | 65 6e 74 65 72 20 74 68 |let you |enter th|
|00003af0| 65 20 6d 61 74 72 69 78 | 20 65 6c 65 6d 65 6e 74 |e matrix| element|
|00003b00| 73 20 61 74 20 74 68 65 | 20 74 65 72 6d 69 6e 61 |s at the| termina|
|00003b10| 6c 2e 20 0d 0a 0d 0a 44 | 69 73 70 6c 61 79 4d 61 |l. ....D|isplayMa|
|00003b20| 74 28 29 5c 69 6e 64 65 | 78 7b 56 4d 61 74 72 69 |t()\inde|x{VMatri|
|00003b30| 78 21 44 69 73 70 6c 61 | 79 4d 61 74 28 29 7d 20 |x!Displa|yMat()} |
|00003b40| 61 6e 64 0d 0a 49 6e 66 | 6f 4d 61 74 28 29 5c 69 |and..Inf|oMat()\i|
|00003b50| 6e 64 65 78 7b 56 4d 61 | 74 72 69 78 21 49 6e 66 |ndex{VMa|trix!Inf|
|00003b60| 6f 6d 61 74 28 29 7d 20 | 64 69 73 70 6c 61 79 20 |omat()} |display |
|00003b70| 74 68 65 20 6d 61 74 72 | 69 78 20 61 6e 64 0d 0a |the matr|ix and..|
|00003b80| 74 68 65 20 64 69 6d 65 | 6e 73 69 6f 6e 73 20 6f |the dime|nsions o|
|00003b90| 66 20 74 68 65 20 61 63 | 74 69 76 65 20 6d 61 74 |f the ac|tive mat|
|00003ba0| 72 69 63 65 73 2e 20 59 | 6f 75 20 63 61 6e 20 61 |rices. Y|ou can a|
|00003bb0| 64 64 20 6d 6f 72 65 0d | 0a 63 68 65 63 6b 73 20 |dd more.|.checks |
|00003bc0| 61 73 20 79 6f 75 20 77 | 61 6e 74 2e 20 55 73 65 |as you w|ant. Use|
|00003bd0| 20 74 68 65 20 66 75 6e | 63 74 69 6f 6e 73 0d 0a | the fun|ctions..|
|00003be0| 53 65 74 77 69 64 28 29 | 5c 69 6e 64 65 78 7b 66 |Setwid()|\index{f|
|00003bf0| 75 6e 63 74 69 6f 6e 73 | 21 53 65 74 77 69 64 28 |unctions|!Setwid(|
|00003c00| 29 7d 20 61 6e 64 20 53 | 65 74 64 65 63 28 29 5c |)} and S|etdec()\|
|00003c10| 69 6e 64 65 78 7b 66 75 | 6e 63 74 69 6f 6e 73 21 |index{fu|nctions!|
|00003c20| 53 65 74 64 65 63 28 29 | 7d 20 74 6f 0d 0a 63 6f |Setdec()|} to..co|
|00003c30| 6e 74 72 6f 6c 20 74 68 | 65 20 64 69 73 70 6c 61 |ntrol th|e displa|
|00003c40| 79 65 64 20 77 69 64 74 | 68 20 6f 66 20 74 68 65 |yed widt|h of the|
|00003c50| 20 6e 75 6d 62 65 72 73 | 20 61 6e 64 20 74 68 65 | numbers| and the|
|00003c60| 20 6e 75 6d 62 65 72 0d | 0a 6f 66 20 64 65 63 69 | number.|.of deci|
|00003c70| 6d 61 6c 73 2e 0d 0a 0d | 0a 57 72 69 74 65 62 28 |mals....|.Writeb(|
|00003c80| 63 68 61 72 20 2a 66 69 | 64 2c 20 56 4d 61 74 72 |char *fi|d, VMatr|
|00003c90| 69 78 20 5c 26 6d 61 74 | 29 5c 69 6e 64 65 78 7b |ix \&mat|)\index{|
|00003ca0| 66 75 6e 63 74 69 6f 6e | 73 21 57 72 69 74 65 62 |function|s!Writeb|
|00003cb0| 28 29 7d 20 64 6f 65 73 | 6e 27 74 0d 0a 72 65 61 |()} does|n't..rea|
|00003cc0| 6c 6c 79 20 62 65 6c 6f | 6e 67 20 61 73 20 6d 65 |lly belo|ng as me|
|00003cd0| 6d 62 65 72 20 66 75 6e | 63 74 69 6f 6e 2c 20 62 |mber fun|ction, b|
|00003ce0| 75 74 20 6e 65 65 64 73 | 20 61 63 63 65 73 73 20 |ut needs| access |
|00003cf0| 74 6f 20 73 6f 6d 65 0d | 0a 6f 66 20 74 68 65 20 |to some.|.of the |
|00003d00| 70 72 69 76 61 74 65 20 | 6d 65 6d 62 65 72 73 20 |private |members |
|00003d10| 6f 66 20 74 68 65 20 6d | 61 74 72 69 78 20 63 6c |of the m|atrix cl|
|00003d20| 61 73 73 2e 20 49 74 20 | 77 72 69 74 65 73 20 61 |ass. It |writes a|
|00003d30| 0d 0a 6d 61 74 72 69 78 | 20 74 6f 20 64 69 73 6b |..matrix| to disk|
|00003d40| 20 69 6e 20 61 20 62 69 | 6e 61 72 79 20 66 6f 72 | in a bi|nary for|
|00003d50| 6d 2e 20 49 74 20 77 72 | 69 74 65 73 20 74 68 65 |m. It wr|ites the|
|00003d60| 20 64 61 74 61 20 6f 75 | 74 20 69 6e 0d 0a 62 6c | data ou|t in..bl|
|00003d70| 6f 63 6b 73 2c 20 72 61 | 74 68 65 72 20 74 68 61 |ocks, ra|ther tha|
|00003d80| 6e 20 65 6c 65 6d 65 6e | 74 77 69 73 65 2e 20 54 |n elemen|twise. T|
|00003d90| 68 65 20 66 69 64 20 69 | 73 20 61 20 66 69 6c 65 |he fid i|s a file|
|00003da0| 20 6e 61 6d 65 20 74 6f | 0d 0a 77 72 69 74 65 20 | name to|..write |
|00003db0| 74 6f 2e 0d 0a 0d 0a 5c | 73 65 63 74 69 6f 6e 7b |to.....\|section{|
|00003dc0| 41 72 69 74 68 6d 65 74 | 69 63 20 46 72 69 65 6e |Arithmet|ic Frien|
|00003dd0| 64 20 46 75 6e 63 74 69 | 6f 6e 73 7d 0d 0a 0d 0a |d Functi|ons}....|
|00003de0| 41 64 64 69 74 69 6f 6e | 2c 20 73 75 62 74 72 61 |Addition|, subtra|
|00003df0| 63 74 69 6f 6e 2c 20 75 | 6e 61 72 79 20 6d 69 6e |ction, u|nary min|
|00003e00| 75 73 2c 20 65 6c 65 6d | 65 6e 74 77 69 73 65 0d |us, elem|entwise.|
|00003e10| 0a 6d 75 6c 74 69 70 6c | 69 63 61 74 69 6f 6e 2c |.multipl|ication,|
|00003e20| 20 65 6c 65 6d 65 6e 74 | 77 69 73 65 20 64 69 76 | element|wise div|
|00003e30| 69 73 69 6f 6e 2c 20 61 | 6e 64 20 6d 61 74 72 69 |ision, a|nd matri|
|00003e40| 78 0d 0a 6d 75 6c 74 69 | 70 6c 69 63 61 74 69 6f |x..multi|plicatio|
|00003e50| 6e 20 69 73 20 73 75 70 | 70 6f 72 74 65 64 20 74 |n is sup|ported t|
|00003e60| 68 72 6f 75 67 68 20 66 | 72 69 65 6e 64 0d 0a 66 |hrough f|riend..f|
|00003e70| 75 6e 63 74 69 6f 6e 73 | 5c 69 6e 64 65 78 7b 56 |unctions|\index{V|
|00003e80| 4d 61 74 72 69 78 21 24 | 2b 2c 2d 2c 2a 2c 5c 25 |Matrix!$|+,-,*,\%|
|00003e90| 2c 2f 24 7d 2e 20 54 68 | 65 20 66 75 6e 63 74 69 |,/$}. Th|e functi|
|00003ea0| 6f 6e 73 20 61 6c 6c 6f | 77 0d 0a 73 63 61 6c 61 |ons allo|w..scala|
|00003eb0| 72 20 61 72 67 75 6d 65 | 6e 74 73 20 61 73 20 6c |r argume|nts as l|
|00003ec0| 65 66 74 20 6f 72 20 72 | 69 67 68 74 20 6f 70 65 |eft or r|ight ope|
|00003ed0| 72 61 6e 64 73 2e 20 54 | 68 65 0d 0a 6f 6e 6c 79 |rands. T|he..only|
|00003ee0| 20 75 6e 75 73 75 61 6c | 20 66 65 61 74 75 72 65 | unusual| feature|
|00003ef0| 20 6f 66 20 74 68 65 73 | 65 20 6f 70 65 72 61 74 | of thes|e operat|
|00003f00| 6f 72 73 20 69 73 20 74 | 68 65 20 65 6c 65 6d 65 |ors is t|he eleme|
|00003f10| 6e 74 77 69 73 65 0d 0a | 6d 75 6c 74 69 70 6c 69 |ntwise..|multipli|
|00003f20| 63 61 74 69 6f 6e 20 69 | 73 20 63 61 6c 6c 65 64 |cation i|s called|
|00003f30| 20 75 73 69 6e 67 20 74 | 68 65 20 27 5c 25 27 20 | using t|he '\%' |
|00003f40| 28 61 6d 70 65 72 73 61 | 6e 64 29 0d 0a 6f 70 65 |(ampersa|nd)..ope|
|00003f50| 72 61 74 6f 72 2e 20 54 | 68 65 79 20 61 6c 6c 20 |rator. T|hey all |
|00003f60| 72 65 74 75 72 6e 20 56 | 4d 61 74 72 69 78 20 72 |return V|Matrix r|
|00003f70| 65 66 65 72 65 6e 63 65 | 73 2e 20 53 65 65 0d 0a |eference|s. See..|
|00003f80| 53 68 69 6c 64 74 5c 63 | 69 74 65 7b 73 68 3a 63 |Shildt\c|ite{sh:c|
|00003f90| 2b 2b 7d 20 66 6f 72 20 | 61 6e 20 65 78 70 6c 61 |++} for |an expla|
|00003fa0| 6e 61 74 69 6f 6e 20 6f | 66 20 68 6f 77 20 61 6e |nation o|f how an|
|00003fb0| 64 20 77 68 79 0d 0a 66 | 72 69 65 6e 64 20 66 75 |d why..f|riend fu|
|00003fc0| 6e 63 74 69 6f 6e 73 20 | 61 72 65 20 6e 65 65 64 |nctions |are need|
|00003fd0| 65 64 20 74 6f 20 6f 76 | 65 72 6c 6f 61 64 20 74 |ed to ov|erload t|
|00003fe0| 68 65 73 65 20 66 75 6e | 63 74 69 6f 6e 73 2e 0d |hese fun|ctions..|
|00003ff0| 0a 0d 0a 49 6e 20 67 65 | 6e 65 72 61 6c 2c 20 74 |...In ge|neral, t|
|00004000| 68 65 73 65 20 66 75 6e | 63 74 69 6f 6e 73 20 66 |hese fun|ctions f|
|00004010| 6f 6c 6c 6f 77 20 74 68 | 65 20 73 61 6d 65 20 70 |ollow th|e same p|
|00004020| 72 65 63 65 64 65 6e 63 | 65 20 61 73 0d 0a 74 68 |recedenc|e as..th|
|00004030| 65 20 73 74 61 6e 64 61 | 72 64 20 66 75 6e 63 74 |e standa|rd funct|
|00004040| 69 6f 6e 73 20 6f 6e 20 | 64 6f 75 62 6c 65 73 2e |ions on |doubles.|
|00004050| 20 54 68 65 79 20 61 6c | 73 6f 20 70 72 6f 64 75 | They al|so produ|
|00004060| 63 65 0d 0a 69 6e 74 65 | 72 6d 65 64 69 61 74 65 |ce..inte|rmediate|
|00004070| 20 76 61 6c 75 65 73 20 | 6f 6e 20 74 68 65 20 73 | values |on the s|
|00004080| 74 61 63 6b 2e 20 54 68 | 65 20 63 6f 64 65 20 66 |tack. Th|e code f|
|00004090| 6f 72 20 61 64 64 69 74 | 69 6f 6e 20 69 73 0d 0a |or addit|ion is..|
|000040a0| 67 69 76 65 6e 20 62 79 | 0d 0a 5c 62 65 67 69 6e |given by|..\begin|
|000040b0| 7b 76 65 72 62 61 74 69 | 6d 7d 0d 0a 56 4d 61 74 |{verbati|m}..VMat|
|000040c0| 72 69 78 26 20 6f 70 65 | 72 61 74 6f 72 2b 20 28 |rix& ope|rator+ (|
|000040d0| 56 4d 61 74 72 69 78 20 | 26 4c 4f 70 2c 20 56 4d |VMatrix |&LOp, VM|
|000040e0| 61 74 72 69 78 20 26 52 | 4f 70 29 0d 0a 20 20 7b |atrix &R|Op).. {|
|000040f0| 0d 0a 20 20 20 20 4c 4f | 70 2e 47 61 72 62 61 67 |.. LO|p.Garbag|
|00004100| 65 28 22 6f 70 65 72 61 | 74 6f 72 20 2b 22 29 3b |e("opera|tor +");|
|00004110| 0d 0a 20 20 20 20 52 4f | 70 2e 47 61 72 62 61 67 |.. RO|p.Garbag|
|00004120| 65 28 22 6f 70 65 72 61 | 74 6f 72 20 2b 22 29 3b |e("opera|tor +");|
|00004130| 0d 0a 20 20 20 20 69 66 | 20 28 4c 4f 70 2e 72 3d |.. if| (LOp.r=|
|00004140| 3d 52 4f 70 2e 72 20 26 | 26 20 4c 4f 70 2e 63 3d |=ROp.r &|& LOp.c=|
|00004150| 3d 52 4f 70 2e 63 29 20 | 7b 0d 0a 20 20 20 20 20 |=ROp.c) |{.. |
|00004160| 20 56 4d 61 74 72 69 78 | 20 2a 74 65 6d 70 20 3d | VMatrix| *temp =|
|00004170| 20 6e 65 77 20 56 4d 61 | 74 72 69 78 28 22 28 22 | new VMa|trix("("|
|00004180| 2c 20 4c 4f 70 2e 72 2c | 20 52 4f 70 2e 63 29 3b |, LOp.r,| ROp.c);|
|00004190| 0d 0a 20 20 20 20 20 20 | 66 6f 72 20 28 69 6e 74 |.. |for (int|
|000041a0| 20 69 3d 31 3b 20 69 3c | 3d 4c 4f 70 2e 72 3b 20 | i=1; i<|=LOp.r; |
|000041b0| 2b 2b 69 29 20 7b 0d 0a | 20 20 20 20 20 20 20 20 |++i) {..| |
|000041c0| 20 20 66 6f 72 20 28 69 | 6e 74 20 6a 3d 31 3b 20 | for (i|nt j=1; |
|000041d0| 6a 3c 3d 52 4f 70 2e 63 | 3b 20 2b 2b 6a 29 20 7b |j<=ROp.c|; ++j) {|
|000041e0| 0d 0a 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 |.. | |
|000041f0| 74 65 6d 70 2d 3e 4d 28 | 69 2c 6a 29 20 3d 20 4c |temp->M(|i,j) = L|
|00004200| 4f 70 2e 6d 28 69 2c 6a | 29 20 2b 20 52 4f 70 2e |Op.m(i,j|) + ROp.|
|00004210| 6d 28 69 2c 6a 29 3b 0d | 0a 20 20 20 20 20 20 20 |m(i,j);.|. |
|00004220| 20 20 20 7d 0d 0a 20 20 | 20 20 20 20 7d 0d 0a 20 | }.. | }.. |
|00004230| 20 20 20 20 20 74 65 6d | 70 2d 3e 6e 61 6d 65 20 | tem|p->name |
|00004240| 3d 20 74 65 6d 70 2d 3e | 6e 61 6d 65 2b 4c 4f 70 |= temp->|name+LOp|
|00004250| 2e 6e 61 6d 65 2b 22 2b | 22 2b 52 4f 70 2e 6e 61 |.name+"+|"+ROp.na|
|00004260| 6d 65 2b 22 29 22 3b 0d | 0a 20 20 20 20 20 20 44 |me+")";.|. D|
|00004270| 69 73 70 61 74 63 68 2d | 3e 50 75 73 68 28 2a 74 |ispatch-|>Push(*t|
|00004280| 65 6d 70 29 3b 0d 0a 20 | 20 20 20 20 20 64 65 6c |emp);.. | del|
|00004290| 65 74 65 20 74 65 6d 70 | 3b 0d 0a 20 20 20 20 7d |ete temp|;.. }|
|000042a0| 0d 0a 20 20 65 6c 73 65 | 20 52 4f 70 2e 4e 72 65 |.. else| ROp.Nre|
|000042b0| 72 72 6f 72 28 22 4d 69 | 73 6d 61 74 63 68 65 64 |rror("Mi|smatched|
|000042c0| 20 4d 61 74 72 69 78 20 | 73 69 7a 65 73 20 69 6e | Matrix |sizes in|
|000042d0| 20 61 64 64 69 74 69 6f | 6e 20 66 75 6e 63 74 69 | additio|n functi|
|000042e0| 6f 6e 5c 6e 22 29 3b 0d | 0a 20 20 72 65 74 75 72 |on\n");.|. retur|
|000042f0| 6e 20 44 69 73 70 61 74 | 63 68 2d 3e 52 65 74 75 |n Dispat|ch->Retu|
|00004300| 72 6e 4d 61 74 28 29 3b | 0d 0a 20 20 7d 0d 0a 5c |rnMat();|.. }..\|
|00004310| 65 6e 64 7b 76 65 72 62 | 61 74 69 6d 7d 0d 0a 54 |end{verb|atim}..T|
|00004320| 68 65 20 66 75 6e 63 74 | 69 6f 6e 20 66 69 72 73 |he funct|ion firs|
|00004330| 74 20 63 68 65 63 6b 73 | 20 74 68 65 20 76 61 6c |t checks| the val|
|00004340| 69 64 69 74 79 20 6f 66 | 20 69 74 73 20 6f 70 65 |idity of| its ope|
|00004350| 72 61 6e 64 73 2e 20 49 | 74 0d 0a 61 6c 73 6f 20 |rands. I|t..also |
|00004360| 63 68 65 63 6b 73 20 74 | 68 61 74 20 74 68 65 20 |checks t|hat the |
|00004370| 6d 61 74 72 69 63 65 73 | 20 61 72 65 20 63 6f 6e |matrices| are con|
|00004380| 66 6f 72 6d 61 62 6c 65 | 2e 20 49 66 20 74 68 65 |formable|. If the|
|00004390| 79 20 61 72 65 2c 0d 0a | 61 20 6e 65 77 20 6d 61 |y are,..|a new ma|
|000043a0| 74 72 69 78 20 69 73 20 | 70 75 74 20 6f 6e 20 74 |trix is |put on t|
|000043b0| 68 65 20 68 65 61 70 2e | 20 54 68 65 20 6d 61 74 |he heap.| The mat|
|000043c0| 72 69 63 65 73 20 61 72 | 65 20 73 75 6d 6d 65 64 |rices ar|e summed|
|000043d0| 2e 0d 0a 4e 6f 74 65 20 | 74 68 65 20 75 73 65 20 |...Note |the use |
|000043e0| 6f 66 20 74 68 65 20 6c | 69 74 74 6c 65 20 6d 28 |of the l|ittle m(|
|000043f0| 69 2c 6a 29 20 6f 6e 20 | 74 68 65 20 72 69 67 68 |i,j) on |the righ|
|00004400| 74 20 73 69 64 65 20 6f | 66 20 74 68 65 0d 0a 73 |t side o|f the..s|
|00004410| 75 6d 2c 20 61 6e 64 20 | 74 68 65 20 4d 28 69 2c |um, and |the M(i,|
|00004420| 6a 29 20 6f 6e 20 74 68 | 65 20 6c 65 66 74 2e 20 |j) on th|e left. |
|00004430| 54 68 65 20 6e 61 6d 65 | 20 69 73 20 63 72 65 61 |The name| is crea|
|00004440| 74 65 64 2e 20 54 68 65 | 0d 0a 6d 61 74 72 69 78 |ted. The|..matrix|
|00004450| 20 69 73 20 70 75 73 68 | 65 64 20 6f 6e 74 6f 20 | is push|ed onto |
|00004460| 74 68 65 20 73 74 61 63 | 6b 2c 20 74 68 65 6e 20 |the stac|k, then |
|00004470| 64 65 6c 65 74 65 64 2e | 20 0d 0a 0d 0a 54 68 65 |deleted.| ....The|
|00004480| 20 72 65 66 65 72 65 6e | 63 65 20 72 65 74 75 72 | referen|ce retur|
|00004490| 6e 65 64 20 69 73 20 74 | 68 65 20 6d 61 74 72 69 |ned is t|he matri|
|000044a0| 78 20 70 6f 69 6e 74 65 | 64 20 74 6f 20 62 79 0d |x pointe|d to by.|
|000044b0| 0a 5c 76 65 72 62 23 20 | 44 69 73 70 61 74 63 68 |.\verb# |Dispatch|
|000044c0| 2d 3e 6e 65 78 74 23 2e | 20 54 68 65 20 66 75 6e |->next#.| The fun|
|000044d0| 63 74 69 6f 6e 20 52 65 | 74 75 72 6e 4d 61 74 28 |ction Re|turnMat(|
|000044e0| 29 20 70 61 73 73 65 73 | 20 74 68 65 20 6d 61 74 |) passes| the mat|
|000044f0| 72 69 78 0d 0a 72 65 66 | 65 72 65 6e 63 65 2c 20 |rix..ref|erence, |
|00004500| 61 6e 64 20 64 6f 65 73 | 20 6e 6f 74 20 63 68 61 |and does| not cha|
|00004510| 6e 67 65 20 74 68 65 20 | 66 75 6e 63 74 69 6f 6e |nge the |function|
|00004520| 20 6e 65 73 74 69 6e 67 | 20 6c 65 76 65 6c 2e 0d | nesting| level..|
|00004530| 0a 42 61 73 69 63 61 6c | 6c 79 2c 20 74 68 65 20 |.Basical|ly, the |
|00004540| 6e 65 73 74 69 6e 67 20 | 6c 65 76 65 6c 20 6b 65 |nesting |level ke|
|00004550| 65 70 73 20 74 72 61 63 | 6b 20 6f 66 20 74 68 65 |eps trac|k of the|
|00004560| 20 66 75 6e 63 74 69 6f | 6e 20 64 65 70 74 68 0d | functio|n depth.|
|00004570| 0a 77 68 65 72 65 20 61 | 64 64 69 74 69 6f 6e 20 |.where a|ddition |
|00004580| 77 61 73 20 63 61 6c 6c | 65 64 2e 20 41 6c 73 6f |was call|ed. Also|
|00004590| 2c 20 43 6c 65 61 6e 73 | 74 61 63 6b 28 29 20 75 |, Cleans|tack() u|
|000045a0| 73 65 73 20 74 68 65 20 | 6e 65 73 74 69 6e 67 0d |ses the |nesting.|
|000045b0| 0a 6c 65 76 65 6c 20 74 | 6f 20 64 65 74 65 72 6d |.level t|o determ|
|000045c0| 69 6e 65 20 77 68 69 63 | 68 20 6d 61 74 72 69 63 |ine whic|h matric|
|000045d0| 65 73 20 74 6f 20 73 74 | 72 69 70 20 66 72 6f 6d |es to st|rip from|
|000045e0| 20 74 68 65 20 73 74 61 | 63 6b 2e 0d 0a 53 79 73 | the sta|ck...Sys|
|000045f0| 74 65 6d 20 66 75 6e 63 | 74 69 6f 6e 73 20 73 68 |tem func|tions sh|
|00004600| 6f 75 6c 64 20 75 73 65 | 20 52 65 74 75 72 6e 4d |ould use| ReturnM|
|00004610| 61 74 28 29 20 72 61 74 | 68 65 72 20 74 68 61 6e |at() rat|her than|
|00004620| 20 44 65 63 52 65 74 75 | 72 6e 28 29 2e 0d 0a 44 | DecRetu|rn()...D|
|00004630| 65 63 52 65 74 75 72 6e | 28 29 20 64 65 63 72 65 |ecReturn|() decre|
|00004640| 6d 65 6e 74 73 20 74 68 | 65 20 6e 65 73 74 69 6e |ments th|e nestin|
|00004650| 67 20 6c 65 76 65 6c 2c | 20 74 68 65 6e 20 72 65 |g level,| then re|
|00004660| 74 75 72 6e 73 20 74 68 | 65 0d 0a 63 6f 72 72 65 |turns th|e..corre|
|00004670| 63 74 20 6d 61 74 72 69 | 78 20 72 65 66 65 72 65 |ct matri|x refere|
|00004680| 6e 63 65 2e 20 4d 6f 72 | 65 20 61 62 6f 75 74 20 |nce. Mor|e about |
|00004690| 74 68 69 73 20 69 6e 20 | 74 68 65 20 6e 65 78 74 |this in |the next|
|000046a0| 20 63 68 61 70 74 65 72 | 2e 0d 0a 54 68 65 20 77 | chapter|...The w|
|000046b0| 61 79 20 74 6f 20 74 65 | 6c 6c 20 77 68 65 6e 20 |ay to te|ll when |
|000046c0| 74 6f 20 75 73 65 20 44 | 65 63 52 65 74 75 72 6e |to use D|ecReturn|
|000046d0| 28 29 20 69 73 20 69 66 | 20 79 6f 75 20 65 6e 74 |() is if| you ent|
|000046e0| 65 72 20 74 68 65 0d 0a | 66 75 6e 63 74 69 6f 6e |er the..|function|
|000046f0| 20 61 6e 64 20 63 61 6c | 6c 20 49 6e 63 6c 65 76 | and cal|l Inclev|
|00004700| 65 6c 28 29 2e 20 43 61 | 6c 6c 20 44 65 63 52 65 |el(). Ca|ll DecRe|
|00004710| 74 75 72 6e 28 29 20 69 | 66 20 79 6f 75 20 63 61 |turn() i|f you ca|
|00004720| 6c 6c 65 64 0d 0a 49 6e | 63 6c 65 76 65 6c 28 29 |lled..In|clevel()|
|00004730| 2e 20 55 73 69 6e 67 20 | 74 68 65 20 73 74 61 63 |. Using |the stac|
|00004740| 6b 20 61 6c 6c 6f 77 73 | 20 74 68 65 20 66 75 6e |k allows| the fun|
|00004750| 63 74 69 6f 6e 73 20 74 | 6f 20 62 65 0d 0a 72 65 |ctions t|o be..re|
|00004760| 63 75 72 73 69 76 65 2e | |cursive.| |
+--------+-------------------------+-------------------------+--------+--------+