Inverse of a matrix
Spastic Sam
Posts: 2
Hello,
I wish to take the inverse of a square matrix. Taking the inverse of a 2x2 or a 3x3 matrix is easy as one can use simple formulas of determinants to compute the invesre. I wish to take the inverse of larger matrices (4x4 and larger). This becomes much more difficult as one has to use methods such as the Gauss-Jordan elimination, Gaussian elimination, or LU decomposition. Having the·ability to perform·matrix operations such as this is important to me in selecting a microcontroller to work with. Are there any parallax products where the inverse of a matrix can be computed using a function keyword·in the software? (PBASIC or any other). Are there any plans to add·a matrix inverse function in the future?
Thanks
Spastic Sam.
I wish to take the inverse of a square matrix. Taking the inverse of a 2x2 or a 3x3 matrix is easy as one can use simple formulas of determinants to compute the invesre. I wish to take the inverse of larger matrices (4x4 and larger). This becomes much more difficult as one has to use methods such as the Gauss-Jordan elimination, Gaussian elimination, or LU decomposition. Having the·ability to perform·matrix operations such as this is important to me in selecting a microcontroller to work with. Are there any parallax products where the inverse of a matrix can be computed using a function keyword·in the software? (PBASIC or any other). Are there any plans to add·a matrix inverse function in the future?
Thanks
Spastic Sam.
Comments
To my knowledge, none of the Parallax processors would really be suitable for that kind of heavy number-crunching, they're more for low-level but very predictable processing -- like a robotics platform. Perhaps the SX or Propeller platforms COULD do that, but I don't think there's pre-built assembly for this.
What is your application? Vision processing?
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
I guess I am spoiled with desktop programs like Matlab (or C++) that have a single instruction or function to compute the inverse of a matrix. My application is to perform linear-least squares fitting for a variety of applications including smooth motion planning through desired points, (auto-correlative) prediction of future positioning to minimize delays in image tracking.
Thanks,
Spastic Sam.
The SX may be able to compute this, but data storage/fetching will be an issue (due to the limited memory on a microcontroller)-
The Propeller may be another avenue to consider- having a separate cog do the inversion- but again you need to facilitate the storage of the data...
Sounds like an interesting application- please post updates as you go, would be interested in seeing how it goes...
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
But I don't see any practical way to do it on the Stamp, for reasons of accuracy of integer calculations, memory, and speed. The Stamp is not meant for memory intensive math. The Propeller, maybe, with so much more memory, the larger integers and fixed point, and speed that might even include parallel processing.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
in order due to the memory and speed constraints of the Parallax processors. Depending
on the type of "linear" least-square fitting... if you're looking for something that will fit the
general linear equation, y=mx+b, least-square fitting doesn't need n-order matricies to be
calculated. Maybe the equations at the bottom of this webpage will help:
www.shodor.org/UNChem/math/lls/index.html
Depending on the number of data points and precision desired, you may have to be creative
as to dealing with large numbers w.r.t. sums of squares and the like on a Basic Stamp.
But the equations on the above webpage should be computable for relative small data
sets on a Stamp2 or SX processor. You'll just hafta come "down" a layer of abstraction
and get into more of the "dirt" of implementation especially since the Basic Stamps
don't do floating point.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Rusty-
--
Rusty Haddock = KD4WLZ = rusty@fe2o3.lonestar.org
**Out yonder in the Van Alstyne (TX) Metropolitan Area**
Microsoft is to software what McDonalds is to gourmet cooking
See the application note entitled "Application Note 3 - Calculating Trend Lines" located at:
http://www.micromegacorp.com/appnotes.html
It describes a least-square line fitting algorithm and a Basic Stamp example is included.
Cam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cam Thompson
Micromega Corporation
Either way, you can compute the inverse of a matrix with the BS2, but you have to do it step-by-step. There's no single command that will do it. Even when Matlab does it, it's using several complex instructions on your CPU to compute the answer.
You'll probably need more program memory than the base BS2 (maybe like the BS2e, sx, etc). The sx might be good as it's fast and got program memory. If you need more speed or memory, you might need to go to a PIC or Atmel or something. Just how fast is your sample rate?
Dave