Shop OBEX P1 Docs P2 Docs Learn Events
MatrixToolkit — Parallax Forums

MatrixToolkit

stevenmess2004stevenmess2004 Posts: 1,102
edited 2009-05-15 12:50 in Propeller 1
Well, I've pulled out my propeller and finally done some more coding. Here is a matrix toolkit for anyone who wants to use it. It uses either the floatmath or float32 objects which are both single precision floating point objects. It can handle matrixes up to any size that will fit in the memory of the propeller chip and the demo shows an example with a 60x60 matrix that is row-reduced. Since it is only single precision you will get some rounding errors but they should be fairly obvious. In theory you should be able to solve a system of about 60 linear equations with 60 variables. If you add an sd card and partition the matrix then you would only be limited by the processing time.

A few things to be careful of
  • The minv function doesn't check to see if the matrix is actually invertible and could invert a matrix that isn't actually invertible due to several things including rounding errors.
  • The minv function takes to matrixes and turns one into an identity matrix and the other into the inverse of the matrix that got turned into the identity matrix.
  • If you use the FloatString object make sure you check somewhere for NaNs, FloatString just prints them as a number confused.gif, maybe I should fix it.

If I get motivated I may add some more methods or convert it all to assembly. If anyone uses it please let me know how it works for you. Nothing is optimised at the moment so I may look at doing that as well.

Edit: The demo is setup for a proto-board and PAL output, you may need to change it.

Comments

  • simonlsimonl Posts: 866
    edited 2009-05-14 16:04
    I have no idea what this is all about (maths is not my strong point!), but I'm wondering if this is something that might be a good use of one of the multiple Propeller projects that've been touted recently?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheers,
    Simon

    www.norfolkhelicopterclub.com

    “Before you criticize someone, you should walk a mile in their shoes. That way when you criticize them, you are a mile away from them and you have their shoes.” - Jack Handey.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2009-05-15 10:31
    simonl said...
    I have no idea what this is all about (maths is not my strong point!), but I'm wondering if this is something that might be a good use of one of the multiple Propeller projects that've been touted recently?
    The problem is that the propeller isn't really all that good for doing this kind of thing for a couple of reasons
    1. All that fast at floating point calculations. It's pretty good compared to AVR's etc but its probably hopeless compared to an ARM chip with floating point extensions (if such a thing exists)
    2. It doesn't have much memory and doesn't have a really fast memory interface. This could be fixed to a certain extent if you really wanted to with the memory expansion that several people are working on. The problem with that is that their probably going to use a cpld or fpga. If your going to use one of them you may as well use that to do your matrix calculations because it will be a lot faster than the prop.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2009-05-15 12:50
    Okay, here is a new version with a more optimised row reduction routine. Previously it took about two and a half minutes to run through the 60x60 matrix. Now using float32 instead and with the optimisations it only takes about 13 seconds. Now to try for an all assembly version for at least part of it...

    Edit: File now attached
Sign In or Register to comment.