Embedded Systems Design - June 2008 - (Page 20) programmer’s toolbox Listing 4 Stream I/O until the next column. There’s a reason for that: it’s because I’ll be making three changes to the file structure that should make things easier in the future. I want to com// Stream I/O functions ostream& operator <<(ostream &os, Matrix plete those changes before pressing on with more func&a) tions in the class. { First, note that, in several places, I’ve used calls to the for(size_t i=0; i<a.m; ++i) { functions vClear and vCopy. These functions are found for(size_t j=0; j<a.n; ++j) in the file SimpleVec.cpp. That file was originally written cout << a.p[a.n*i+j] << ‘ ‘; to do low-level vector operations. However, they also cout < >(istream &is, Matrix vAdd and vSub, as well. &a) I could, but I’m not going to. While I don’t absolutely { for(size_t i=0; i > a.p[i]; mSub, and so forth, I also don’t pay much of a penalty to do return is; so. Most of the functions contain only one or two exe} cutable instructions, so it’s not as though I’ll be wasting lots of RAM space. There’s another thing. Although the low-level matrix functions I’ve mentioned will be identical to those for vectors, many others will be decidedly different. These include should probably be deferred to cases where we have spethe generation of scalar matrices, the product algorithms, cific uses, and therefore specific formats, in mind. For the inversion algorithm, and others. hints, you might check the I/O formats used in MATLAB. Accordingly, I’ve decided to write another collection I will call your attention to the indexing construct in of functions parallelling those in operator <<( ). It’s the same as used in function Cell( ). In truth, My shame in admitting the SimpleVec.cpp. I’d call it SimI might have been well-advised to error is well worth it if it pleMat.cpp, except for the next use that function. I blushingly admit change. drives home the point that that I made an error in the indexWith the introduction of Siming—an error that cost me an afterthe indexing math is best pleMat.cpp and its header file, I’m noon or so to find. I had used the to eight be includhidden well down inside up in every files that muststarting to column size parameter instead of ed build. This is software written for the the row parameter, incurring an erget excessive. I’ve done things this ror that only showed up when the way in the past and never had much purpose. matrix was non-square. of a problem, but I can’t say as much There could be no better way to for other users of my software. They make the point. My shame in admitting the error is well tended to have problems collecting up all the needed files. worth it if it drives home the point that the indexing math You might also remember that I didn’t include, in this is best hidden well down inside software written for the month’s effort, any operations that involved both matrices purpose. To sprinkle such code through a main program is and vectors. Since almost everything we do with an invitation to disaster. It only takes one mis-written invector/matrix math involves both types, we’re going to stance to make your life miserable. have to make allowances for those operations, and we should do so very soon. In practice, this means adding refTHINGS TO COME erences to vectors in class Matrix, and possibly the other As usual, I’m uploading the code for the class Matrix and way round as well. To clean things up, I’ve decided to combine all the its test driver, to the web site. Check the test driver for excode—the classes Vector and Matrix, plus the low-level amples of how to use the new functions. I’ve included tests for the stream I/O. However, remem- routines in SimpleVec/SimpleMat, into a single file, plus ber that my usual test approach is silent, in the sense that it its corresponding header file. This will make the file a good gives no output unless something goes wrong. Therefore, in bit larger than I’m comfortable with, but it won’t use much the default form of the test driver, the tests of the I/O funccode space because the individual functions are so tiny. tions are commented out. Look for those changes, coming soon to a magazine You may have noticed that I’ve deferred a lot of items near you. ■ 20 JUNE 2008 | embedded systems design | www.embedded.com http://www.embedded.com
Table of Contents Feed for the Digital Edition of Embedded Systems Design - June 2008 Embedded Systems Design - June 2008 Contents #Include Party Bit Programmer's Toolbox Cover Feature: Virtual Hardware Platforms for Embedded Software Validation Allocating Memory in MATLAB-to-C Code MDD and IDEs: Making the Twain Meet in Embedded Systems Design Avoid a Thrashing Guest Editor Advertising Index Break Points Marketplace Embedded Systems Design - June 2008 Embedded Systems Design - June 2008 - Embedded Systems Design - June 2008 (Page Cover1) Embedded Systems Design - June 2008 - Embedded Systems Design - June 2008 (Page Cover2) Embedded Systems Design - June 2008 - Embedded Systems Design - June 2008 (Page 1) Embedded Systems Design - June 2008 - Embedded Systems Design - June 2008 (Page 2) Embedded Systems Design - June 2008 - Contents (Page 3) Embedded Systems Design - June 2008 - Contents (Page 4) Embedded Systems Design - June 2008 - Contents (Page 5) Embedded Systems Design - June 2008 - Contents (Page 6) Embedded Systems Design - June 2008 - #Include (Page 7) Embedded Systems Design - June 2008 - #Include (Page 8) Embedded Systems Design - June 2008 - #Include (Page 9) Embedded Systems Design - June 2008 - Party Bit (Page 10) Embedded Systems Design - June 2008 - Party Bit (Page 11) Embedded Systems Design - June 2008 - Party Bit (Page 12) Embedded Systems Design - June 2008 - Party Bit (Page 13) Embedded Systems Design - June 2008 - Programmer's Toolbox (Page 14) Embedded Systems Design - June 2008 - Programmer's Toolbox (Page 15) Embedded Systems Design - June 2008 - Programmer's Toolbox (Page 16) Embedded Systems Design - June 2008 - Programmer's Toolbox (Page 17) Embedded Systems Design - June 2008 - Programmer's Toolbox (Page 18) Embedded Systems Design - June 2008 - Programmer's Toolbox (Page 19) Embedded Systems Design - June 2008 - Programmer's Toolbox (Page 20) Embedded Systems Design - June 2008 - Programmer's Toolbox (Page 21) Embedded Systems Design - June 2008 - Cover Feature: Virtual Hardware Platforms for Embedded Software Validation (Page 22) Embedded Systems Design - June 2008 - Cover Feature: Virtual Hardware Platforms for Embedded Software Validation (Page 23) Embedded Systems Design - June 2008 - Cover Feature: Virtual Hardware Platforms for Embedded Software Validation (Page 24) Embedded Systems Design - June 2008 - Cover Feature: Virtual Hardware Platforms for Embedded Software Validation (Page 25) Embedded Systems Design - June 2008 - Cover Feature: Virtual Hardware Platforms for Embedded Software Validation (Page 26) Embedded Systems Design - June 2008 - Cover Feature: Virtual Hardware Platforms for Embedded Software Validation (Page 27) Embedded Systems Design - June 2008 - Cover Feature: Virtual Hardware Platforms for Embedded Software Validation (Page 28) Embedded Systems Design - June 2008 - Cover Feature: Virtual Hardware Platforms for Embedded Software Validation (Page 29) Embedded Systems Design - June 2008 - Allocating Memory in MATLAB-to-C Code (Page 30) Embedded Systems Design - June 2008 - Allocating Memory in MATLAB-to-C Code (Page 31) Embedded Systems Design - June 2008 - Allocating Memory in MATLAB-to-C Code (Page 32) Embedded Systems Design - June 2008 - Allocating Memory in MATLAB-to-C Code (Page 33) Embedded Systems Design - June 2008 - Allocating Memory in MATLAB-to-C Code (Page 34) Embedded Systems Design - June 2008 - Allocating Memory in MATLAB-to-C Code (Page 35) Embedded Systems Design - June 2008 - Allocating Memory in MATLAB-to-C Code (Page 36) Embedded Systems Design - June 2008 - MDD and IDEs: Making the Twain Meet in Embedded Systems Design (Page 37) Embedded Systems Design - June 2008 - MDD and IDEs: Making the Twain Meet in Embedded Systems Design (Page 38) Embedded Systems Design - June 2008 - MDD and IDEs: Making the Twain Meet in Embedded Systems Design (Page 39) Embedded Systems Design - June 2008 - MDD and IDEs: Making the Twain Meet in Embedded Systems Design (Page 40) Embedded Systems Design - June 2008 - MDD and IDEs: Making the Twain Meet in Embedded Systems Design (Page 41) Embedded Systems Design - June 2008 - MDD and IDEs: Making the Twain Meet in Embedded Systems Design (Page 42) Embedded Systems Design - June 2008 - MDD and IDEs: Making the Twain Meet in Embedded Systems Design (Page 43) Embedded Systems Design - June 2008 - MDD and IDEs: Making the Twain Meet in Embedded Systems Design (Page 44) Embedded Systems Design - June 2008 - Avoid a Thrashing (Page 45) Embedded Systems Design - June 2008 - Avoid a Thrashing (Page 46) Embedded Systems Design - June 2008 - Avoid a Thrashing (Page 47) Embedded Systems Design - June 2008 - Guest Editor (Page 48) Embedded Systems Design - June 2008 - Guest Editor (Page 49) Embedded Systems Design - June 2008 - Guest Editor (Page 50) Embedded Systems Design - June 2008 - Guest Editor (Page 51) Embedded Systems Design - June 2008 - Advertising Index (Page 52) Embedded Systems Design - June 2008 - Break Points (Page 53) Embedded Systems Design - June 2008 - Break Points (Page 54) Embedded Systems Design - June 2008 - Marketplace (Page 55) Embedded Systems Design - June 2008 - Marketplace (Page 56) Embedded Systems Design - June 2008 - Marketplace (Page Cover3) Embedded Systems Design - June 2008 - Marketplace (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.