This section of the archives stores flipcode's complete Developer Toolbox collection, featuring a variety of mini-articles and source code contributions from our readers.

| Massively Parameterized Matrix Class Submitted by

It's almost been a month since the last matrix class submission. It's time to do something about that. This is a matrix class I have been working on lately. It has three major fairly unusual features (actually it's more like two major and one minor). 1. It minimizes the use of temporary objects by delaying the evaluation of expressions until the final assignment by using closure objects.

    matrix<3 A, B, C;
    A = B * C; // no temporaries

2. It generates code that evaluates expressions where you only have to look at a single position in the involved matrices at a time automatically. The generated code never uses a temporary.

    vector<3 v, u, w;
    float a, b;
    v = (u * a + w * b) / (a + b); // vector interpolation, no temporaries

3. operator* is used for both matrix multiplication, scalar product and vector product.

    A = B * C; // matrix multiplication
    v = u * w; // vector product
    a = u * w; // scalar product

I hope somebody finds this useful, or at least interesting. For more information see the index.html and README files.

Download Associated File: cpse_math_matrix.tar.gz (14,446 bytes)

The zip file viewer built into the Developer Toolbox made use of the zlib library, as well as the zlibdll source additions.

Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.