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

- File List
- File Members

Classes | Typedefs | Functions

# qgenericmatrix.h File Reference

`#include <QtCore/qmetatype.h>`
`#include <QtCore/qdebug.h>`
`#include <QtCore/qdatastream.h>`

Go to the source code of this file.

## Classes
class | QGenericMatrix< N, M, T >
## Typedefs
typedef QGenericMatrix < 2, 2, qreal > | QMatrix2x2
typedef QGenericMatrix < 2, 3, qreal > | QMatrix2x3
typedef QGenericMatrix < 2, 4, qreal > | QMatrix2x4
typedef QGenericMatrix < 3, 2, qreal > | QMatrix3x2
typedef QGenericMatrix < 3, 3, qreal > | QMatrix3x3
typedef QGenericMatrix < 3, 4, qreal > | QMatrix3x4
typedef QGenericMatrix < 4, 2, qreal > | QMatrix4x2
typedef QGenericMatrix < 4, 3, qreal > | QMatrix4x3
## Functions
template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > | operator+ (const QGenericMatrix< N, M, T > &m1, const QGenericMatrix< N, M, T > &m2)
template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > | operator- (const QGenericMatrix< N, M, T > &m1, const QGenericMatrix< N, M, T > &m2)
template<int N, int M1, int M2, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< M1, M2, T > | operator* (const QGenericMatrix< N, M2, T > &m1, const QGenericMatrix< M1, N, T > &m2)
template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > | operator- (const QGenericMatrix< N, M, T > &matrix)
template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > | operator* (T factor, const QGenericMatrix< N, M, T > &matrix)
template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > | operator* (const QGenericMatrix< N, M, T > &matrix, T factor)
template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > | operator/ (const QGenericMatrix< N, M, T > &matrix, T divisor)
template<int N, int M, typename T >
QDebug | operator<< (QDebug dbg, const QGenericMatrix< N, M, T > &m)
template<int N, int M, typename T >
QDataStream & | operator<< (QDataStream &stream, const QGenericMatrix< N, M, T > &matrix)
template<int N, int M, typename T >
QDataStream & | operator>> (QDataStream &stream, QGenericMatrix< N, M, T > &matrix)

## Typedef Documentation

typedef QGenericMatrix<2, 2, qreal> QMatrix2x2

Search for all occurrences

Definition at line 328 of file qgenericmatrix.h.

typedef QGenericMatrix<2, 3, qreal> QMatrix2x3

Search for all occurrences

Definition at line 329 of file qgenericmatrix.h.

typedef QGenericMatrix<2, 4, qreal> QMatrix2x4

Search for all occurrences

Definition at line 330 of file qgenericmatrix.h.

typedef QGenericMatrix<3, 2, qreal> QMatrix3x2

Search for all occurrences

Definition at line 331 of file qgenericmatrix.h.

typedef QGenericMatrix<3, 3, qreal> QMatrix3x3

Search for all occurrences

Definition at line 332 of file qgenericmatrix.h.

typedef QGenericMatrix<3, 4, qreal> QMatrix3x4

Search for all occurrences

Definition at line 333 of file qgenericmatrix.h.

typedef QGenericMatrix<4, 2, qreal> QMatrix4x2

Search for all occurrences

Definition at line 334 of file qgenericmatrix.h.

typedef QGenericMatrix<4, 3, qreal> QMatrix4x3

Search for all occurrences

Definition at line 335 of file qgenericmatrix.h.

## Function Documentation

Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator+ | ( | const QGenericMatrix< N, M, T > & | m1,
|  | const QGenericMatrix< N, M, T > & | m2
| ) |  |

Definition at line 251 of file qgenericmatrix.h.

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

Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator- | ( | const QGenericMatrix< N, M, T > & | m1,
|  | const QGenericMatrix< N, M, T > & | m2
| ) |  |

Definition at line 260 of file qgenericmatrix.h.

    {
        QGenericMatrix<N, M, T> result(1);
        for (int index = 0; index < N * M; ++index)
            result.m[0][index] = m1.m[0][index] - m2.m[0][index];
        return result;
    }

Q_OUTOFLINE_TEMPLATE QGenericMatrix<M1, M2, T> operator* | ( | const QGenericMatrix< N, M2, T > & | m1,
|  | const QGenericMatrix< M1, N, T > & | m2
| ) |  |

Definition at line 269 of file qgenericmatrix.h.

    {
        QGenericMatrix<M1, M2, T> result(1);
        for (int row = 0; row < M2; ++row) {
            for (int col = 0; col < M1; ++col) {
                T sum(0.0f);
                for (int j = 0; j < N; ++j)
                    sum += m1.m[j][row] * m2.m[col][j];
                result.m[col][row] = sum;
            }
        }
        return result;
    }

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

Definition at line 284 of file qgenericmatrix.h.

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

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

Definition at line 293 of file qgenericmatrix.h.

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

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

Definition at line 302 of file qgenericmatrix.h.

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

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

Definition at line 311 of file qgenericmatrix.h.

    {
        QGenericMatrix<N, M, T> result(1);
        for (int index = 0; index < N * M; ++index)
            result.m[0][index] = matrix.m[0][index] / divisor;
        return result;
    }

QDebug operator<< | ( | QDebug | dbg,
|  | const QGenericMatrix< N, M, T > & | m
| ) |  |

Definition at line 340 of file qgenericmatrix.h.

    {
        dbg.nospace() << "QGenericMatrix<" << N << ", " << M
            << ", " << QTypeInfo<T>::name()
            << ">(" << endl << qSetFieldWidth(10);
        for (int row = 0; row < M; ++row) {
            for (int col = 0; col < N; ++col)
                dbg << m(row, col);
            dbg << endl;
        }
        dbg << qSetFieldWidth(0) << ')';
        return dbg.space();
    }

QDataStream& operator<< | ( | QDataStream & | stream,
|  | const QGenericMatrix< N, M, T > & | matrix
| ) |  |

Definition at line 359 of file qgenericmatrix.h.

    {
        for (int row = 0; row < M; ++row)
            for (int col = 0; col < N; ++col)
                stream << double(matrix(row, col));
        return stream;
    }

QDataStream& operator>> | ( | QDataStream & | stream,
|  | QGenericMatrix< N, M, T > & | matrix
| ) |  |

Definition at line 368 of file qgenericmatrix.h.

    {
        double x;
        for (int row = 0; row < M; ++row) {
            for (int col = 0; col < N; ++col) {
                stream >> x;
                matrix(row, col) = T(x);
            }
        }
        return stream;
    }