Qt 4.8
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 >
 The QGenericMatrix class is a template class that represents a NxM transformation matrix with N columns and M rows. More...
 

Typedefs

typedef QGenericMatrix< 2, 2, qrealQMatrix2x2
 
typedef QGenericMatrix< 2, 3, qrealQMatrix2x3
 
typedef QGenericMatrix< 2, 4, qrealQMatrix2x4
 
typedef QGenericMatrix< 3, 2, qrealQMatrix3x2
 
typedef QGenericMatrix< 3, 3, qrealQMatrix3x3
 
typedef QGenericMatrix< 3, 4, qrealQMatrix3x4
 
typedef QGenericMatrix< 4, 2, qrealQMatrix4x2
 
typedef QGenericMatrix< 4, 3, qrealQMatrix4x3
 

Functions

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* (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 > &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 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/ (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 >
QDataStreamoperator<< (QDataStream &stream, const QGenericMatrix< N, M, T > &matrix)
 
template<int N, int M, typename T >
QDataStreamoperator>> (QDataStream &stream, QGenericMatrix< N, M, T > &matrix)
 

Typedef Documentation

◆ QMatrix2x2

typedef QGenericMatrix<2, 2, qreal> QMatrix2x2
related

Definition at line 340 of file qgenericmatrix.h.

◆ QMatrix2x3

typedef QGenericMatrix<2, 3, qreal> QMatrix2x3
related

Definition at line 341 of file qgenericmatrix.h.

◆ QMatrix2x4

typedef QGenericMatrix<2, 4, qreal> QMatrix2x4
related

Definition at line 342 of file qgenericmatrix.h.

◆ QMatrix3x2

typedef QGenericMatrix<3, 2, qreal> QMatrix3x2
related

Definition at line 343 of file qgenericmatrix.h.

◆ QMatrix3x3

typedef QGenericMatrix<3, 3, qreal> QMatrix3x3
related

Definition at line 344 of file qgenericmatrix.h.

◆ QMatrix3x4

typedef QGenericMatrix<3, 4, qreal> QMatrix3x4
related

Definition at line 345 of file qgenericmatrix.h.

◆ QMatrix4x2

typedef QGenericMatrix<4, 2, qreal> QMatrix4x2
related

Definition at line 346 of file qgenericmatrix.h.

◆ QMatrix4x3

typedef QGenericMatrix<4, 3, qreal> QMatrix4x3
related

Definition at line 347 of file qgenericmatrix.h.

Function Documentation

◆ operator*() [1/3]

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 
)
related

Definition at line 277 of file qgenericmatrix.h.

278 {
279  QGenericMatrix<M1, M2, T> result(1);
280  for (int row = 0; row < M2; ++row) {
281  for (int col = 0; col < M1; ++col) {
282  T sum(0.0f);
283  for (int j = 0; j < N; ++j)
284  sum += m1.m[j][row] * m2.m[col][j];
285  result.m[col][row] = sum;
286  }
287  }
288  return result;
289 }
The QGenericMatrix class is a template class that represents a NxM transformation matrix with N colum...

◆ operator*() [2/3]

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator* ( factor,
const QGenericMatrix< N, M, T > &  matrix 
)
related

Definition at line 302 of file qgenericmatrix.h.

303 {
304  QGenericMatrix<N, M, T> result(1);
305  for (int row = 0; row < M; ++row)
306  for (int col = 0; col < N; ++col)
307  result.m[col][row] = matrix.m[col][row] * factor;
308  return result;
309 }
The QGenericMatrix class is a template class that represents a NxM transformation matrix with N colum...
#define M(row, col)

◆ operator*() [3/3]

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator* ( const QGenericMatrix< N, M, T > &  matrix,
factor 
)
related

Definition at line 312 of file qgenericmatrix.h.

313 {
314  QGenericMatrix<N, M, T> result(1);
315  for (int row = 0; row < M; ++row)
316  for (int col = 0; col < N; ++col)
317  result.m[col][row] = matrix.m[col][row] * factor;
318  return result;
319 }
The QGenericMatrix class is a template class that represents a NxM transformation matrix with N colum...
#define M(row, col)

◆ operator+()

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 
)
related

Definition at line 257 of file qgenericmatrix.h.

258 {
259  QGenericMatrix<N, M, T> result(1);
260  for (int row = 0; row < M; ++row)
261  for (int col = 0; col < N; ++col)
262  result.m[col][row] = m1.m[col][row] + m2.m[col][row];
263  return result;
264 }
The QGenericMatrix class is a template class that represents a NxM transformation matrix with N colum...
#define M(row, col)

◆ operator-() [1/2]

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 
)
related

Definition at line 267 of file qgenericmatrix.h.

268 {
269  QGenericMatrix<N, M, T> result(1);
270  for (int row = 0; row < M; ++row)
271  for (int col = 0; col < N; ++col)
272  result.m[col][row] = m1.m[col][row] - m2.m[col][row];
273  return result;
274 }
The QGenericMatrix class is a template class that represents a NxM transformation matrix with N colum...
#define M(row, col)

◆ operator-() [2/2]

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator- ( const QGenericMatrix< N, M, T > &  matrix)
related

Definition at line 292 of file qgenericmatrix.h.

293 {
294  QGenericMatrix<N, M, T> result(1);
295  for (int row = 0; row < M; ++row)
296  for (int col = 0; col < N; ++col)
297  result.m[col][row] = -matrix.m[col][row];
298  return result;
299 }
The QGenericMatrix class is a template class that represents a NxM transformation matrix with N colum...
#define M(row, col)

◆ operator/()

template<int N, int M, typename T >
Q_OUTOFLINE_TEMPLATE QGenericMatrix<N, M, T> operator/ ( const QGenericMatrix< N, M, T > &  matrix,
divisor 
)
related

Definition at line 322 of file qgenericmatrix.h.

323 {
324  QGenericMatrix<N, M, T> result(1);
325  for (int row = 0; row < M; ++row)
326  for (int col = 0; col < N; ++col)
327  result.m[col][row] = matrix.m[col][row] / divisor;
328  return result;
329 }
The QGenericMatrix class is a template class that represents a NxM transformation matrix with N colum...
#define M(row, col)

◆ operator<<() [1/2]

template<int N, int M, typename T >
QDebug operator<< ( QDebug  dbg,
const QGenericMatrix< N, M, T > &  m 
)

Definition at line 352 of file qgenericmatrix.h.

353 {
354  dbg.nospace() << "QGenericMatrix<" << N << ", " << M
355  << ", " << QTypeInfo<T>::name()
356  << ">(" << endl << qSetFieldWidth(10);
357  for (int row = 0; row < M; ++row) {
358  for (int col = 0; col < N; ++col)
359  dbg << m(row, col);
360  dbg << endl;
361  }
362  dbg << qSetFieldWidth(0) << ')';
363  return dbg.space();
364 }
QTextStream & endl(QTextStream &stream)
Writes &#39; &#39; to the stream and flushes the stream.
QDebug & nospace()
Clears the stream&#39;s internal flag that records whether the last character was a space and returns a r...
Definition: qdebug.h:92
QTextStreamManipulator qSetFieldWidth(int width)
Equivalent to QTextStream::setFieldWidth(width).
Definition: qtextstream.h:329
#define M(row, col)
const char * name
QDebug & space()
Writes a space character to the debug stream and returns a reference to the stream.
Definition: qdebug.h:91

◆ operator<<() [2/2]

template<int N, int M, typename T >
QDataStream& operator<< ( QDataStream stream,
const QGenericMatrix< N, M, T > &  matrix 
)
related

Definition at line 371 of file qgenericmatrix.h.

372 {
373  for (int row = 0; row < M; ++row)
374  for (int col = 0; col < N; ++col)
375  stream << double(matrix(row, col));
376  return stream;
377 }
#define M(row, col)
static FILE * stream

◆ operator>>()

template<int N, int M, typename T >
QDataStream& operator>> ( QDataStream stream,
QGenericMatrix< N, M, T > &  matrix 
)
related

Definition at line 380 of file qgenericmatrix.h.

381 {
382  double x;
383  for (int row = 0; row < M; ++row) {
384  for (int col = 0; col < N; ++col) {
385  stream >> x;
386  matrix(row, col) = T(x);
387  }
388  }
389  return stream;
390 }
#define M(row, col)
static FILE * stream