42 #ifndef QGENERICMATRIX_H
43 #define QGENERICMATRIX_H
55 template <
int N,
int M, typename T>
61 explicit QGenericMatrix(
const T *
values);
63 const T& operator()(
int row,
int column)
const;
64 T& operator()(
int row,
int column);
66 bool isIdentity()
const;
80 void copyDataTo(T *values)
const;
83 const T *
data()
const {
return *m; }
86 #if !defined(Q_NO_TEMPLATE_FRIENDS)
87 template<
int NN,
int MM,
typename TT>
89 template<
int NN,
int MM,
typename TT>
91 template<
int NN,
int M1,
int M2,
typename TT>
93 template<
int NN,
int MM,
typename TT>
95 template<
int NN,
int MM,
typename TT>
97 template<
int NN,
int MM,
typename TT>
99 template<
int NN,
int MM,
typename TT>
106 QGenericMatrix(
int) {}
108 #if !defined(Q_NO_TEMPLATE_FRIENDS)
109 template <
int NN,
int MM,
typename TT>
110 friend class QGenericMatrix;
114 template <
int N,
int M,
typename T>
120 template <
int N,
int M,
typename T>
123 for (
int col = 0; col < N; ++col)
125 m[col][
row] = other.m[col][
row];
128 template <
int N,
int M,
typename T>
131 for (
int col = 0; col < N; ++col)
133 m[col][
row] = values[
row * N + col];
136 template <
int N,
int M,
typename T>
143 template <
int N,
int M,
typename T>
150 template <
int N,
int M,
typename T>
153 for (
int col = 0; col < N; ++col) {
156 if (m[col][
row] != 1.0
f)
159 if (m[col][
row] != 0.0
f)
167 template <
int N,
int M,
typename T>
170 for (
int col = 0; col < N; ++col) {
180 template <
int N,
int M,
typename T>
183 for (
int col = 0; col < N; ++col)
188 template <
int N,
int M,
typename T>
193 for (
int col = 0; col < N; ++col)
194 result.m[
row][col] = m[col][
row];
198 template <
int N,
int M,
typename T>
202 for (
int col = 0; col < N; ++col)
203 m[col][
row] += other.m[col][
row];
207 template <
int N,
int M,
typename T>
211 for (
int col = 0; col < N; ++col)
212 m[col][
row] -= other.m[col][
row];
216 template <
int N,
int M,
typename T>
220 for (
int col = 0; col < N; ++col)
221 m[col][
row] *= factor;
225 template <
int N,
int M,
typename T>
229 for (
int col = 0; col < N; ++col) {
230 if (m[col][
row] != other.m[col][
row])
236 template <
int N,
int M,
typename T>
240 for (
int col = 0; col < N; ++col) {
241 if (m[col][
row] != other.m[col][
row])
247 template <
int N,
int M,
typename T>
251 for (
int col = 0; col < N; ++col)
252 m[col][
row] /= divisor;
256 template <
int N,
int M,
typename T>
261 for (
int col = 0; col < N; ++col)
262 result.m[col][
row] = m1.m[col][
row] + m2.m[col][
row];
266 template <
int N,
int M,
typename T>
271 for (
int col = 0; col < N; ++col)
272 result.m[col][
row] = m1.m[col][
row] - m2.m[col][
row];
276 template <
int N,
int M1,
int M2,
typename T>
281 for (
int col = 0; col < M1; ++col) {
283 for (
int j = 0; j < N; ++j)
284 sum += m1.m[j][
row] * m2.m[col][j];
285 result.m[col][
row] = sum;
291 template <
int N,
int M,
typename T>
296 for (
int col = 0; col < N; ++col)
297 result.m[col][
row] = -matrix.m[col][
row];
301 template <
int N,
int M,
typename T>
306 for (
int col = 0; col < N; ++col)
307 result.m[col][
row] = matrix.m[col][
row] * factor;
311 template <
int N,
int M,
typename T>
316 for (
int col = 0; col < N; ++col)
317 result.m[col][
row] = matrix.m[col][
row] * factor;
321 template <
int N,
int M,
typename T>
326 for (
int col = 0; col < N; ++col)
327 result.m[col][
row] = matrix.m[col][
row] / divisor;
331 template <
int N,
int M,
typename T>
334 for (
int col = 0; col < N; ++col)
336 values[
row * N + col] = T(m[col][
row]);
349 #ifndef QT_NO_DEBUG_STREAM
351 template <
int N,
int M,
typename T>
352 QDebug operator<<(QDebug dbg, const QGenericMatrix<N, M, T> &m)
354 dbg.
nospace() <<
"QGenericMatrix<" << N <<
", " << M
358 for (
int col = 0; col < N; ++col)
368 #ifndef QT_NO_DATASTREAM
370 template <
int N,
int M,
typename T>
374 for (
int col = 0; col < N; ++col)
379 template <
int N,
int M,
typename T>
384 for (
int col = 0; col < N; ++col) {
QGenericMatrix< N, M, T > & operator*=(T factor)
bool operator==(const QGenericMatrix< N, M, T > &other) const
QGenericMatrix< 2, 4, qreal > QMatrix2x4
QByteArray & operator+=(QByteArray &a, const QStringBuilder< A, B > &b)
QGenericMatrix< M, N, T > transposed() const
QGenericMatrix< 3, 4, qreal > QMatrix3x4
QGenericMatrix< 3, 3, qreal > QMatrix3x3
const T & operator()(int row, int column) const
void copyDataTo(T *values) const
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > operator-(const QGenericMatrix< N, M, T > &m1, const QGenericMatrix< N, M, T > &m2)
QGenericMatrix< N, M, T > & operator+=(const QGenericMatrix< N, M, T > &other)
QDataStream & operator>>(QDataStream &stream, QGenericMatrix< N, M, T > &matrix)
QGenericMatrix< 2, 2, qreal > QMatrix2x2
bool operator==(const Attribute &cA, const AttributeInstance< type > &cB)
This operator compares the two attributes and NOT their values.
QGenericMatrix< 4, 3, qreal > QMatrix4x3
GLenum GLenum GLvoid * row
#define QT_BEGIN_NAMESPACE
bool operator!=(const QGenericMatrix< N, M, T > &other) const
QGenericMatrix< 3, 2, qreal > QMatrix3x2
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > operator/(const QGenericMatrix< N, M, T > &matrix, T divisor)
bool operator!=(const QByteArray &a1, const QByteArray &a2)
GLsizei const GLfloat * value
GLenum GLenum GLvoid GLvoid * column
GLuint const GLchar * name
Q_OUTOFLINE_TEMPLATE QGenericMatrix< N, M, T > operator+(const QGenericMatrix< N, M, T > &m1, const QGenericMatrix< N, M, T > &m2)
QGenericMatrix< 2, 3, qreal > QMatrix2x3
QGenericMatrix< 4, 2, qreal > QMatrix4x2
GLboolean GLenum GLenum GLvoid * values
GLXDrawable int64_t int64_t divisor
QTextStreamManipulator qSetFieldWidth(int width)
QGenericMatrix< N, M, T > & operator/=(T divisor)
const T * constData() const
Q_OUTOFLINE_TEMPLATE QGenericMatrix< M1, M2, T > operator*(const QGenericMatrix< N, M2, T > &m1, const QGenericMatrix< M1, N, T > &m2)
QGenericMatrix< N, M, T > & operator-=(const QGenericMatrix< N, M, T > &other)
Q_CORE_EXPORT QTextStream & endl(QTextStream &s)