4#ifndef QGENERICMATRIX_H
5#define QGENERICMATRIX_H
7#include <QtGui/qtguiglobal.h>
8#include <QtCore/qmetatype.h>
9#include <QtCore/qdebug.h>
10#include <QtCore/qdatastream.h>
15template <
int N,
int M,
typename T>
43 const T *
data()
const {
return *
m; }
46 template<
int NN,
int MM,
typename TT>
48 template<
int NN,
int MM,
typename TT>
50 template<
int NN,
int M1,
int M2,
typename TT>
52 template<
int NN,
int MM,
typename TT>
54 template<
int NN,
int MM,
typename TT>
56 template<
int NN,
int MM,
typename TT>
58 template<
int NN,
int MM,
typename TT>
64 template <
int NN,
int MM,
typename TT>
67template <
int N,
int M,
typename T>
73template <
int N,
int M,
typename T>
79template <
int N,
int M,
typename T>
82 for (
int col = 0; col < N; ++col)
87template <
int N,
int M,
typename T>
94template <
int N,
int M,
typename T>
101template <
int N,
int M,
typename T>
104 for (
int col = 0; col < N; ++col) {
107 if (
m[col][
row] != 1.0f)
110 if (
m[col][
row] != 0.0f)
118template <
int N,
int M,
typename T>
121 for (
int col = 0; col < N; ++col) {
131template <
int N,
int M,
typename T>
134 for (
int col = 0; col < N; ++col)
139template <
int N,
int M,
typename T>
144 for (
int col = 0; col < N; ++col)
149template <
int N,
int M,
typename T>
153 for (
int col = 0; col < N; ++col)
158template <
int N,
int M,
typename T>
162 for (
int col = 0; col < N; ++col)
167template <
int N,
int M,
typename T>
171 for (
int col = 0; col < N; ++col)
172 m[col][
row] *= factor;
179template <
int N,
int M,
typename T>
183 for (
int col = 0; col < N; ++col) {
190template <
int N,
int M,
typename T>
193 return !(*
this ==
other);
198template <
int N,
int M,
typename T>
202 for (
int col = 0; col < N; ++col)
207template <
int N,
int M,
typename T>
212 for (
int col = 0; col < N; ++col)
217template <
int N,
int M,
typename T>
222 for (
int col = 0; col < N; ++col)
227template <
int N,
int M1,
int M2,
typename T>
232 for (
int col = 0; col < M1; ++col) {
234 for (
int j = 0;
j < N; ++
j)
242template <
int N,
int M,
typename T>
247 for (
int col = 0; col < N; ++col)
252template <
int N,
int M,
typename T>
257 for (
int col = 0; col < N; ++col)
262template <
int N,
int M,
typename T>
267 for (
int col = 0; col < N; ++col)
272template <
int N,
int M,
typename T>
277 for (
int col = 0; col < N; ++col)
282template <
int N,
int M,
typename T>
285 for (
int col = 0; col < N; ++col)
300#ifndef QT_NO_DEBUG_STREAM
302template <
int N,
int M,
typename T>
306 dbg.nospace() <<
"QGenericMatrix<" << N <<
", " <<
M
307 <<
", " << QMetaType::fromType<T>().name()
310 for (
int col = 0; col < N; ++col)
320#ifndef QT_NO_DATASTREAM
322template <
int N,
int M,
typename T>
326 for (
int col = 0; col < N; ++col)
331template <
int N,
int M,
typename T>
336 for (
int col = 0; col < N; ++col) {
\inmodule QtCore\reentrant
The QGenericMatrix class is a template class that represents a NxM transformation matrix with N colum...
bool isIdentity() const
Returns true if this matrix is the identity; false otherwise.
friend QGenericMatrix< NN, MM, TT > operator-(const QGenericMatrix< NN, MM, TT > &matrix)
QGenericMatrix(const T *values)
Constructs a matrix from the given N * M floating-point values.
QGenericMatrix< N, M, T > & operator/=(T divisor)
Divides all elements of this matrix by divisor.
const T * constData() const
Returns a constant pointer to the raw data of this matrix.
T & operator()(int row, int column)
Returns a reference to the element at position (row, column) in this matrix so that the element can b...
bool operator!=(const QGenericMatrix< N, M, T > &other) const
Returns true if this matrix is not identical to other; false otherwise.
friend QGenericMatrix< M1, M2, TT > operator*(const QGenericMatrix< NN, M2, TT > &m1, const QGenericMatrix< M1, NN, TT > &m2)
Returns the product of the NNxM2 matrix m1 and the M1xNN matrix m2 to produce a M1xM2 matrix result.
friend QGenericMatrix< NN, MM, TT > operator*(const QGenericMatrix< NN, MM, TT > &matrix, TT factor)
QGenericMatrix(Qt::Initialization)
void setToIdentity()
Sets this matrix to the identity.
void fill(T value)
Fills all elements of this matrix with value.
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 divisor)
friend class QGenericMatrix
Constructs a NxM identity matrix.
friend QGenericMatrix< NN, MM, TT > operator-(const QGenericMatrix< NN, MM, TT > &m1, const QGenericMatrix< NN, MM, TT > &m2)
const T * data() const
Returns a constant pointer to the raw data of this matrix.
QGenericMatrix< N, M, T > & operator*=(T factor)
Multiplies all elements of this matrix by factor.
bool operator==(const QGenericMatrix< N, M, T > &other) const
Returns true if this matrix is identical to other; false otherwise.
QGenericMatrix< N, M, T > & operator+=(const QGenericMatrix< N, M, T > &other)
Adds the contents of other to this matrix.
void copyDataTo(T *values) const
Retrieves the N * M items in this matrix and copies them to values in row-major order.
QGenericMatrix< M, N, T > transposed() const
Returns this matrix, transposed about its diagonal.
friend QGenericMatrix< NN, MM, TT > operator+(const QGenericMatrix< NN, MM, TT > &m1, const QGenericMatrix< NN, MM, TT > &m2)
const T & operator()(int row, int column) const
Returns a constant reference to the element at position (row, column) in this matrix.
T * data()
Returns a pointer to the raw data of this matrix.
QGenericMatrix< N, M, T > & operator-=(const QGenericMatrix< N, M, T > &other)
Subtracts the contents of other from this matrix.
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
QTextStream & endl(QTextStream &stream)
Writes '\n' to the stream and flushes the stream.
#define QT_WARNING_DISABLE_FLOAT_COMPARE
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
QGenericMatrix< 3, 2, float > QMatrix3x2
QGenericMatrix< 2, 2, float > QMatrix2x2
QGenericMatrix< 4, 2, float > QMatrix4x2
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > operator/(const QGenericMatrix< N, M, T > &matrix, T divisor)
QGenericMatrix< 2, 3, float > QMatrix2x3
QGenericMatrix< 3, 4, float > QMatrix3x4
QGenericMatrix< 2, 4, float > QMatrix2x4
QDebug operator<<(QDebug dbg, const QGenericMatrix< N, M, T > &m)
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > operator+(const QGenericMatrix< N, M, T > &m1, const QGenericMatrix< N, M, T > &m2)
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > operator-(const QGenericMatrix< N, M, T > &m1, const QGenericMatrix< N, M, T > &m2)
QGenericMatrix< 4, 3, float > QMatrix4x3
Q_OUTOFLINE_TEMPLATE QGenericMatrix< M1, M2, T > operator*(const QGenericMatrix< N, M2, T > &m1, const QGenericMatrix< M1, N, T > &m2)
QGenericMatrix< 3, 3, float > QMatrix3x3
QDataStream & operator>>(QDataStream &stream, QGenericMatrix< N, M, T > &matrix)
GLenum GLsizei GLsizei GLint * values
[15]
GLint GLint GLint GLint GLint x
[0]
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLsizei void * row
QTextStreamManipulator qSetFieldWidth(int width)