Shadowrun: Awakened 29 September 2011 - Build 871
Public Types | Public Member Functions | Protected Attributes | Static Protected Attributes
cat::Matrix< ROWS, COLS, Scalar > Class Template Reference

#include <Matrix.hpp>

List of all members.

Public Types

typedef Matrix< ROWS, COLS,
Scalar > 
mytype

Public Member Functions

void loadIdentity ()
void loadZero ()
 Matrix (const mytype &u)
 Matrix ()
Scalar & operator() (int ii)
const Scalar & operator() (int ii) const
Scalar & operator() (int row, int col)
const Scalar & operator() (int row, int col) const
template<int OTHER_COLS>
Matrix< ROWS, OTHER_COLS, Scalar > operator* (const Matrix< COLS, OTHER_COLS, Scalar > &u)
mytypeoperator*= (Scalar u)
mytypeoperator+= (const mytype &u)
mytypeoperator-= (const mytype &u)
mytypeoperator/= (Scalar u)
mytypeoperator= (const mytype &u)

Protected Attributes

Scalar _elements [ROWS *COLS]

Static Protected Attributes

static const int ELEMENTS = ROWS * COLS

Detailed Description

template<int ROWS, int COLS, class Scalar>
class cat::Matrix< ROWS, COLS, Scalar >

Definition at line 56 of file Matrix.hpp.


Member Typedef Documentation

template<int ROWS, int COLS, class Scalar>
typedef Matrix<ROWS, COLS, Scalar> cat::Matrix< ROWS, COLS, Scalar >::mytype

Definition at line 64 of file Matrix.hpp.


Constructor & Destructor Documentation

template<int ROWS, int COLS, class Scalar>
cat::Matrix< ROWS, COLS, Scalar >::Matrix ( ) [inline]

Definition at line 67 of file Matrix.hpp.

    {
    }
template<int ROWS, int COLS, class Scalar>
cat::Matrix< ROWS, COLS, Scalar >::Matrix ( const mytype u) [inline]

Definition at line 72 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements.

    {
        memcpy(_elements, u._elements, sizeof(_elements));
    }

Member Function Documentation

template<int ROWS, int COLS, class Scalar>
void cat::Matrix< ROWS, COLS, Scalar >::loadIdentity ( ) [inline]

Definition at line 90 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements.

    {
        OBJCLR(_elements);

        // Write a 1 along the diagonal
        for (int ii = 0; ii < ROWS && ii < COLS; ++ii)
        {
            _elements[ii * ROWS + ii] = static_cast<Scalar>( 1 );
        }
    }
template<int ROWS, int COLS, class Scalar>
void cat::Matrix< ROWS, COLS, Scalar >::loadZero ( ) [inline]

Definition at line 84 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements.

    {
        OBJCLR(_elements);
    }
template<int ROWS, int COLS, class Scalar>
Scalar& cat::Matrix< ROWS, COLS, Scalar >::operator() ( int  row,
int  col 
) [inline]

Definition at line 158 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements.

{ return _elements[col * ROWS + row]; }
template<int ROWS, int COLS, class Scalar>
Scalar& cat::Matrix< ROWS, COLS, Scalar >::operator() ( int  ii) [inline]

Definition at line 155 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements.

{ return _elements[ii]; }
template<int ROWS, int COLS, class Scalar>
const Scalar& cat::Matrix< ROWS, COLS, Scalar >::operator() ( int  ii) const [inline]

Definition at line 156 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements.

{ return _elements[ii]; }
template<int ROWS, int COLS, class Scalar>
const Scalar& cat::Matrix< ROWS, COLS, Scalar >::operator() ( int  row,
int  col 
) const [inline]

Definition at line 159 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements.

{ return _elements[col * ROWS + row]; }
template<int ROWS, int COLS, class Scalar>
template<int OTHER_COLS>
Matrix<ROWS, OTHER_COLS, Scalar> cat::Matrix< ROWS, COLS, Scalar >::operator* ( const Matrix< COLS, OTHER_COLS, Scalar > &  u) [inline]

Definition at line 127 of file Matrix.hpp.

    {
        Matrix<ROWS, OTHER_COLS, Scalar> result;

        // For each row of the matrix product,
        for (int r = 0; r < ROWS; ++r)
        {
            // For each column of the matrix product,
            for (int c = 0; c < OTHER_COLS; ++c)
            {
                Scalar x = static_cast<Scalar>( 0 );

                // For each row of the right operand (u),
                for (int ii = 0; ii < COLS; ++ii)
                {
                    // Accumulate sum of products
                    x += (*this)(r, ii) * u(ii, c);
                }

                // Write the sum
                result(r, c) = x;
            }
        }

        return result;
    }
template<int ROWS, int COLS, class Scalar>
mytype& cat::Matrix< ROWS, COLS, Scalar >::operator*= ( Scalar  u) [inline]

Definition at line 114 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements, and FOR_EACH_ELEMENT.

    {
        FOR_EACH_ELEMENT(ii) _elements[ii] *= u;
    }
template<int ROWS, int COLS, class Scalar>
mytype& cat::Matrix< ROWS, COLS, Scalar >::operator+= ( const mytype u) [inline]

Definition at line 102 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements, and FOR_EACH_ELEMENT.

    {
        FOR_EACH_ELEMENT(ii) _elements[ii] += u._elements[ii];
    }
template<int ROWS, int COLS, class Scalar>
mytype& cat::Matrix< ROWS, COLS, Scalar >::operator-= ( const mytype u) [inline]

Definition at line 108 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements, and FOR_EACH_ELEMENT.

    {
        FOR_EACH_ELEMENT(ii) _elements[ii] -= u._elements[ii];
    }
template<int ROWS, int COLS, class Scalar>
mytype& cat::Matrix< ROWS, COLS, Scalar >::operator/= ( Scalar  u) [inline]

Definition at line 120 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements, and FOR_EACH_ELEMENT.

    {
        FOR_EACH_ELEMENT(ii) _elements[ii] /= u;
    }
template<int ROWS, int COLS, class Scalar>
mytype& cat::Matrix< ROWS, COLS, Scalar >::operator= ( const mytype u) [inline]

Definition at line 78 of file Matrix.hpp.

References cat::Matrix< ROWS, COLS, Scalar >::_elements.

    {
        memcpy(_elements, u._elements, sizeof(_elements));
    }

Member Data Documentation

template<int ROWS, int COLS, class Scalar>
Scalar cat::Matrix< ROWS, COLS, Scalar >::_elements[ROWS *COLS] [protected]
template<int ROWS, int COLS, class Scalar>
const int cat::Matrix< ROWS, COLS, Scalar >::ELEMENTS = ROWS * COLS [static, protected]

Definition at line 59 of file Matrix.hpp.


The documentation for this class was generated from the following file:

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net