- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Friends

# QGenericMatrix< N, M, T > Class Template Reference

Search for all occurrences

## Detailed Description

### template<int N, int M, typename T>
class QGenericMatrix< N, M, T >

Definition at line 56 of file qgenericmatrix.h.

`#include <qgenericmatrix.h>`

List of all members.

## Public Member Functions
| QGenericMatrix ()
| QGenericMatrix (const QGenericMatrix< N, M, T > &other)
| QGenericMatrix (const T *values)
const T & | operator() (int row, int column) const
T & | operator() (int row, int column)
bool | isIdentity () const
void | setToIdentity ()
void | fill (T value)
QGenericMatrix< M, N, T > | transposed () const
QGenericMatrix< N, M, T > & | operator+= (const QGenericMatrix< N, M, T > &other)
QGenericMatrix< N, M, T > & | operator-= (const QGenericMatrix< N, M, T > &other)
QGenericMatrix< N, M, T > & | operator*= (T factor)
QGenericMatrix< N, M, T > & | operator/= (T divisor)
bool | operator== (const QGenericMatrix< N, M, T > &other) const
bool | operator!= (const QGenericMatrix< N, M, T > &other) const
void | copyDataTo (T *values) const
T * | data ()
const T * | data () const
const T * | constData () const
## Friends
class | QGenericMatrix
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > | operator+ (const QGenericMatrix< NN, MM, TT > &m1, const QGenericMatrix< NN, MM, TT > &m2)
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > | operator- (const QGenericMatrix< NN, MM, TT > &m1, const QGenericMatrix< NN, MM, TT > &m2)
template<int NN, int M1, int M2, typename TT >
QGenericMatrix< M1, M2, TT > | operator* (const QGenericMatrix< NN, M2, TT > &m1, const QGenericMatrix< M1, NN, TT > &m2)
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > | operator- (const QGenericMatrix< NN, MM, TT > &matrix)
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > | operator* (TT factor, const QGenericMatrix< NN, MM, TT > &matrix)
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > | operator* (const QGenericMatrix< NN, MM, TT > &matrix, TT factor)
template<int NN, int MM, typename TT >
QGenericMatrix< NN, MM, TT > | operator/ (const QGenericMatrix< NN, MM, TT > &matrix, TT divisor)

## Constructor & Destructor Documentation

QGenericMatrix | ( |  | ) |

Q_INLINE_TEMPLATE QGenericMatrix | ( | const QGenericMatrix< N, M, T > & | other | ) |

Definition at line 121 of file qgenericmatrix.h.

    {
        for (int col = 0; col < N; ++col)
            for (int row = 0; row < M; ++row)
                m[col][row] = other.m[col][row];
    }

Q_OUTOFLINE_TEMPLATE QGenericMatrix | ( | const T * | values | ) | `[explicit]`

Definition at line 129 of file qgenericmatrix.h.

    {
        for (int col = 0; col < N; ++col)
            for (int row = 0; row < M; ++row)
                m[col][row] = values[row * N + col];
    }

## Member Function Documentation

Q_INLINE_TEMPLATE const T & operator() | ( | int | row,
|  | int | column
| ) |  | const

Definition at line 137 of file qgenericmatrix.h.

    {
        Q_ASSERT(row >= 0 && row < M && column >= 0 && column < N);
        return m[column][row];
    }

Q_INLINE_TEMPLATE T & operator() | ( | int | row,
|  | int | column
| ) |  |

Definition at line 144 of file qgenericmatrix.h.

    {
        Q_ASSERT(row >= 0 && row < M && column >= 0 && column < N);
        return m[column][row];
    }

Q_OUTOFLINE_TEMPLATE bool isIdentity | ( |  | ) | const

Search for all occurrences

Definition at line 151 of file qgenericmatrix.h.

    {
        for (int col = 0; col < N; ++col) {
            for (int row = 0; row < M; ++row) {
                if (row == col) {
                    if (m[col][row] != 1.0f)
                        return false;
                } else {
                    if (m[col][row] != 0.0f)
                        return false;
                }
            }
        }
        return true;
    }

Q_OUTOFLINE_TEMPLATE void setToIdentity | ( |  | ) |

Search for all occurrences

Definition at line 168 of file qgenericmatrix.h.

    {
        for (int col = 0; col < N; ++col) {
            for (int row = 0; row < M; ++row) {
                if (row == col)
                    m[col][row] = 1.0f;
                else
                    m[col][row] = 0.0f;
            }
        }
    }

Q_OUTOFLINE_TEMPLATE void fill | ( | T | value | ) |

Search for all occurrences

Definition at line 181 of file qgenericmatrix.h.

    {
        for (int col = 0; col < N; ++col)
            for (int row = 0; row < M; ++row)
                m[col][row] = value;
    }

Q_OUTOFLINE_TEMPLATE QGenericMatrix< M, N, T > transposed | ( |  | ) | const

Search for all occurrences

Definition at line 189 of file qgenericmatrix.h.

    {
        QGenericMatrix<M, N, T> result(1);
        for (int row = 0; row < M; ++row)
            for (int col = 0; col < N; ++col)
                result.m[row][col] = m[col][row];
        return result;
    }

Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > & operator+= | ( | const QGenericMatrix< N, M, T > & | other | ) |

Definition at line 199 of file qgenericmatrix.h.

    {
        for (int index = 0; index < N * M; ++index)
            m[0][index] += other.m[0][index];
        return *this;
    }

Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > & operator-= | ( | const QGenericMatrix< N, M, T > & | other | ) |

Definition at line 207 of file qgenericmatrix.h.

    {
        for (int index = 0; index < N * M; ++index)
            m[0][index] -= other.m[0][index];
        return *this;
    }

Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > & operator*= | ( | T | factor | ) |

Definition at line 215 of file qgenericmatrix.h.

    {
        for (int index = 0; index < N * M; ++index)
            m[0][index] *= factor;
        return *this;
    }

Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > & operator/= | ( | T | divisor | ) |

Definition at line 243 of file qgenericmatrix.h.

    {
        for (int index = 0; index < N * M; ++index)
            m[0][index] /= divisor;
        return *this;
    }

Q_OUTOFLINE_TEMPLATE bool operator== | ( | const QGenericMatrix< N, M, T > & | other | ) | const

Definition at line 223 of file qgenericmatrix.h.

    {
        for (int index = 0; index < N * M; ++index) {
            if (m[0][index] != other.m[0][index])
                return false;
        }
        return true;
    }

Q_OUTOFLINE_TEMPLATE bool operator!= | ( | const QGenericMatrix< N, M, T > & | other | ) | const

Definition at line 233 of file qgenericmatrix.h.

    {
        for (int index = 0; index < N * M; ++index) {
            if (m[0][index] != other.m[0][index])
                return true;
        }
        return false;
    }

Q_OUTOFLINE_TEMPLATE void copyDataTo | ( | T * | values | ) | const

Search for all occurrences

Definition at line 320 of file qgenericmatrix.h.

    {
        for (int col = 0; col < N; ++col)
            for (int row = 0; row < M; ++row)
                values[row * N + col] = T(m[col][row]);
    }

T* data | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 82 of file qgenericmatrix.h.

    { return m[0]; }

const T* data | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 83 of file qgenericmatrix.h.

    { return m[0]; }

const T* constData | ( |  | ) | const `[inline]`

Search for all occurrences

Definition at line 84 of file qgenericmatrix.h.

    { return m[0]; }

## Friends And Related Function Documentation

Q_INLINE_TEMPLATE QGenericMatrix `[friend]`

Definition at line 110 of file qgenericmatrix.h.

QGenericMatrix<NN, MM, TT> operator+ | ( | const QGenericMatrix< NN, MM, TT > & | m1,
|  | const QGenericMatrix< NN, MM, TT > & | m2
| ) |  | `[friend]`

QGenericMatrix<NN, MM, TT> operator- | ( | const QGenericMatrix< NN, MM, TT > & | m1,
|  | const QGenericMatrix< NN, MM, TT > & | m2
| ) |  | `[friend]`

QGenericMatrix<M1, M2, TT> operator* | ( | const QGenericMatrix< NN, M2, TT > & | m1,
|  | const QGenericMatrix< M1, NN, TT > & | m2
| ) |  | `[friend]`

QGenericMatrix<NN, MM, TT> operator- | ( | const QGenericMatrix< NN, MM, TT > & | matrix | ) | `[friend]`

QGenericMatrix<NN, MM, TT> operator* | ( | TT | factor,
|  | const QGenericMatrix< NN, MM, TT > & | matrix
| ) |  | `[friend]`

QGenericMatrix<NN, MM, TT> operator* | ( | const QGenericMatrix< NN, MM, TT > & | matrix,
|  | TT | factor
| ) |  | `[friend]`

QGenericMatrix<NN, MM, TT> operator/ | ( | const QGenericMatrix< NN, MM, TT > & | matrix,
|  | TT | divisor
| ) |  | `[friend]`

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

- QtGui/qgenericmatrix.h