Embedded Systems Design - August 2008 - (Page 13) ⎡ s 0 0⎤ ⎥ ⎢ S = ⎢0 s 0 ⎥ ⎢0 0 s ⎥ ⎦ ⎣ Like the scalar inverse, the inverse of a matrix has the property: (1) XX -1 = X -1X = I (6) In SimpleMat, I’m providing two such functions. Function mSet(s) builds the scalar matrix with s’s down the diagonal. Function mUnit performs the same function, with s equal to 1. Note that all scalar matrices are square, so only one size parameter is needed. The functions mAdd and mSub are logical extensions of their vector counterparts. Not so with the next two functions, which have no counterparts in the vector functions. We’ve talked about the matrix product before. Remember the “pour row into column” mnemonic that I gave last time? I won’t bother to rehash the algorithm here. Function mMult takes two matrices as arguments and yields a matrix result. Note carefully that in this case, the output argument cannot be either of the input arguments. That output argument gets built one element at a time, and that process would corrupt the input matrices. When you multiply matrices, the dimensions are critically important. If you think back to the “pour rows into columns” mnemonic, you’ll see that the number of columns in the first argument matrix must match the number of rows in the second. If the first matrix is, say, m×k, the second matrix must be k by something. For an easy mnemonic, write: where I is the unit matrix of appropriate size. That term “appropriate size” is important. Now, take another look at Equation 6. The unit matrix is, by definition, square. What’s more, the operations XX-1and X-1X only make sense if the inner indices are equal. That is, the matrix X must also be square. Otherwise it cannot have an inverse. The rule of equal dimensions also limits how we can use the inverse. While the inverse matrix must be square, the matrix it multiplies need not be. Unlike the case in Equation 3, we can only multiply the inverse in the way that makes sense, dimensionally. Consider the classic matrix form of the linear algebra problem: Ax = y (7) We know that A is square (else the system has no solution). Let’s say that it’s n×n. Then x and y must both be column vectors, dimensioned n×1. In that case, the product yA-1 makes no sense at all—the dimensions don’t line up. The solution only makes sense if we write: x = A −1 y (8) (m × k ) ⋅ ( k × n ) ⇒ (m × n ) (2) In a sense, the two middle dimensions “cancel” each other. In general, whenever we multiply matrices, we must take care that the dimensions match up. In a way, the function mMult “enforces” this rule, by simply assuming it. In the spirit of the Fortranish, low-level functions of SimpleVec and SimpleMat, no error checking is done. If you violate the rule, mMult will happily give you a product you didn’t expect. It can also overwrite your code. Caveat emptor. The next function, mInv, is even more interesting. The mathematical entity called vector has no division operator, and the matrix entity doesn’t, either. But it has the next best thing: an inversion operator. Consider the nature of the inverse operation for scalars. By definition, x-1 has the property that: xx −1 = x −1 x = 1 (3) For this scalar case, the inverse is clearly: x −1 = 1 x (4) From this definition, we can write things like: y = x −1 y = yx −1 x (5) www.embedded.com | embedded systems design | AUGUST 2008 13 http://www.lxdinc.com http://www.lxdinc.com http://www.embedded.com
Table of Contents Feed for the Digital Edition of Embedded Systems Design - August 2008 Embedded Systems Design - August 2008 Contents Number Include Parity Bit Programmer's Toolbox Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications Wanted: Industry Standards for Benchmarking Embedded VMM Hypervisors Achieving Cache Coherence in a MIPS32 Multicore Design Memory Allocation in C Advertising Index Break Points Marketplace Embedded Systems Design - August 2008 Embedded Systems Design - August 2008 - Embedded Systems Design - August 2008 (Page Cover1) Embedded Systems Design - August 2008 - Embedded Systems Design - August 2008 (Page Cover2) Embedded Systems Design - August 2008 - Embedded Systems Design - August 2008 (Page 1) Embedded Systems Design - August 2008 - Embedded Systems Design - August 2008 (Page 2) Embedded Systems Design - August 2008 - Contents (Page 3) Embedded Systems Design - August 2008 - Contents (Page 4) Embedded Systems Design - August 2008 - Number Include (Page 5) Embedded Systems Design - August 2008 - Number Include (Page 6) Embedded Systems Design - August 2008 - Number Include (Page 7) Embedded Systems Design - August 2008 - Number Include (Page 8) Embedded Systems Design - August 2008 - Parity Bit (Page 9) Embedded Systems Design - August 2008 - Parity Bit (Page 10) Embedded Systems Design - August 2008 - Programmer's Toolbox (Page 11) Embedded Systems Design - August 2008 - Programmer's Toolbox (Page 12) Embedded Systems Design - August 2008 - Programmer's Toolbox (Page 13) Embedded Systems Design - August 2008 - Programmer's Toolbox (Page 14) Embedded Systems Design - August 2008 - Programmer's Toolbox (Page 15) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 16) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 17) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 18) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 19) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 20) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 21) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 22) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 23) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 24) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 25) Embedded Systems Design - August 2008 - Cover Feature: Virtualization for Embedded X86 Multiprocessor Applications (Page 26) Embedded Systems Design - August 2008 - Wanted: Industry Standards for Benchmarking Embedded VMM Hypervisors (Page 27) Embedded Systems Design - August 2008 - Wanted: Industry Standards for Benchmarking Embedded VMM Hypervisors (Page 28) Embedded Systems Design - August 2008 - Wanted: Industry Standards for Benchmarking Embedded VMM Hypervisors (Page 29) Embedded Systems Design - August 2008 - Achieving Cache Coherence in a MIPS32 Multicore Design (Page 30) Embedded Systems Design - August 2008 - Achieving Cache Coherence in a MIPS32 Multicore Design (Page 31) Embedded Systems Design - August 2008 - Achieving Cache Coherence in a MIPS32 Multicore Design (Page 32) Embedded Systems Design - August 2008 - Achieving Cache Coherence in a MIPS32 Multicore Design (Page 33) Embedded Systems Design - August 2008 - Achieving Cache Coherence in a MIPS32 Multicore Design (Page 34) Embedded Systems Design - August 2008 - Memory Allocation in C (Page 35) Embedded Systems Design - August 2008 - Memory Allocation in C (Page 36) Embedded Systems Design - August 2008 - Memory Allocation in C (Page 37) Embedded Systems Design - August 2008 - Memory Allocation in C (Page 38) Embedded Systems Design - August 2008 - Memory Allocation in C (Page 39) Embedded Systems Design - August 2008 - Memory Allocation in C (Page 40) Embedded Systems Design - August 2008 - Memory Allocation in C (Page 41) Embedded Systems Design - August 2008 - Memory Allocation in C (Page 42) Embedded Systems Design - August 2008 - Advertising Index (Page 43) Embedded Systems Design - August 2008 - Advertising Index (Page 44) Embedded Systems Design - August 2008 - Break Points (Page 45) Embedded Systems Design - August 2008 - Break Points (Page 46) Embedded Systems Design - August 2008 - Marketplace (Page 47) Embedded Systems Design - August 2008 - Marketplace (Page 48) Embedded Systems Design - August 2008 - Marketplace (Page Cover3) Embedded Systems Design - August 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.