C

GenericMatrix Struct

template <int M, int N, typename T> struct Qul::PlatformInterface::GenericMatrix

The GenericMatrix class is a template class representing a matrix. More...

Header: #include <platforminterface/genericmatrix.h>
Since: Qt Quick Ultralite (Platform) 1.7
Inherited By:

Qul::PlatformInterface::Transform

This struct was introduced in Qt Quick Ultralite (Platform) 1.7.

Public Types

enum Initialization { Uninitialized, ZeroInitialized, Identity }

Public Functions

GenericMatrix(const T *values)
GenericMatrix(Qul::PlatformInterface::GenericMatrix::Initialization initialization)
GenericMatrix()
const T *data() const
T *data()
bool isIdentity() const
void setToIdentity()
bool operator!=(const GenericMatrix<M, N, T> &other = M) const
const T &operator()(int row, int column) const
T &operator()(int row, int column)
GenericMatrix<M, N, T> &operator*=(T factor)
GenericMatrix<M, N, T> &operator*=(const GenericMatrix<M, N, T> &other = M)
GenericMatrix<M, N, T> &operator+=(const GenericMatrix<M, N, T> &other = M)
bool operator==(const GenericMatrix<M, N, T> &other = M) const
GenericMatrix<M, N, T2> operator*(T1 factor, const GenericMatrix<M, N, T2> &matrix = M)
GenericMatrix<M, N2, T> operator*(const GenericMatrix<M, N1, T> &m1 = M, const GenericMatrix<N1, N2, T> &m2 = N1)
GenericMatrix<M, N, T> operator+(const GenericMatrix<M, N, T> &m1 = M, const GenericMatrix<M, N, T> &m2 = M)

Detailed Description

The GenericMatrix class is a template class representing a matrix. For square matrices, few additinal methods are provided by template specialization.

The GenericMatrix template has three parameters:

MNumber of columns.
NNumber of rows.
TElement type that is visible to users of the class.

The T must be:

  • Trivially copyable.
  • Default constructible.
  • Integer constructible.

Examples:

using Qul::PlatformInterface::GenericMatrix;

// Specializes a square matrix.
using Matrix5x5 = GenericMatrix<5, 5, float>;
Matrix5x5 m(Matrix5x5::Identity);
m.isIdentity();

// Specializes a rectangular matrix.
using Matrix2x3 = GenericMatrix<2, 3, float>;
Matrix2x3 m2(Matrix2x3::Uninitialized);

Member Type Documentation

enum GenericMatrix::Initialization

This enum type is used for matrix initialization policy.

ConstantValueDescription
Qul::PlatformInterface::GenericMatrix::Uninitialized0Constructs a matrix without initializing the contents.
Qul::PlatformInterface::GenericMatrix::ZeroInitialized1Matrix content is zero initialized.
Qul::PlatformInterface::GenericMatrix::Identity2Matrix content is set to the identity matrix. This enum is available only for square matrices.

Member Function Documentation

GenericMatrix::GenericMatrix(const T *values)

Constructs a matrix from the given M * N values. The contents of the values array are assumed to be in row-major order.

GenericMatrix::GenericMatrix(Qul::PlatformInterface::GenericMatrix::Initialization initialization)

Constructs matrix and sets values according to initialization policy.

GenericMatrix::GenericMatrix()

Constructs matrix with zero-initialized values.

const T *GenericMatrix::data() const

Returns a constant pointer to the raw data of this matrix.

T *GenericMatrix::data()

Returns a pointer to the raw data of this matrix.

bool GenericMatrix::isIdentity() const

Returns true if this matrix is the identity, returns false otherwise.

Note: This method is available only for square matrices.

See also setToIdentity().

void GenericMatrix::setToIdentity()

Sets this matrix to the identity.

Note: This method is available only for square matrices.

See also isIdentity().

bool GenericMatrix::operator!=(const GenericMatrix<M, N, T> &other = M) const

Returns true if this matrix is not identical to other, returns false otherwise.

const T &GenericMatrix::operator()(int row, int column) const

Returns a constant reference to the element at position (row, column) in this matrix.

T &GenericMatrix::operator()(int row, int column)

Returns a reference to the element at position (row, column) in this matrix, so that the element can be assigned to.

GenericMatrix<M, N, T> &GenericMatrix::operator*=(T factor)

Multiplies all elements of this matrix by scalar factor.

GenericMatrix<M, N, T> &GenericMatrix::operator*=(const GenericMatrix<M, N, T> &other = M)

Multiplies all elements of this matrix with other matrix.

Note: This method is available only for square matrices.

GenericMatrix<M, N, T> &GenericMatrix::operator+=(const GenericMatrix<M, N, T> &other = M)

Adds the contents of other to this matrix.

bool GenericMatrix::operator==(const GenericMatrix<M, N, T> &other = M) const

Returns true if this matrix is identical to other, returns false otherwise.

Related Non-Members

template <int M, int N, typename T1, typename T2> GenericMatrix<M, N, T2> operator*(T1 factor, const GenericMatrix<M, N, T2> &matrix = M)

Returns the result of multiplying all elements of matrix by scalar factor.

template <int M, int N1, int N2, typename T> GenericMatrix<M, N2, T> operator*(const GenericMatrix<M, N1, T> &m1 = M, const GenericMatrix<N1, N2, T> &m2 = N1)

Returns the result of multiplying all elements of m1 and m2.

template <int M, int N, typename T> GenericMatrix<M, N, T> operator+(const GenericMatrix<M, N, T> &m1 = M, const GenericMatrix<M, N, T> &m2 = M)

Returns the sum of m1 and m2.

Available under certain Qt licenses.
Find out more.