7namespace LinearAlgebra {
12 MatrixOf(
unsigned int rows,
unsigned int cols);
13 MatrixOf(
unsigned int rows,
unsigned int cols,
const T *source)
20 if (this->data ==
nullptr)
33 unsigned int matrixSize = this->cols * this->rows;
34 unsigned int resultSize = r->rows * r->cols;
35 if (matrixSize != resultSize) {
39 for (
unsigned int dataIx = 0; dataIx < resultSize; dataIx++)
40 r->data[dataIx] = 0.0f;
49 for (
unsigned int rDataIx = 0; rDataIx < matrixSize; rDataIx++) {
50 unsigned int rowIx = rDataIx / this->rows;
51 unsigned int colIx = rDataIx % this->rows;
52 unsigned int mDataIx = this->cols * colIx + rowIx;
53 r->data[rDataIx] = this->data[mDataIx];
66 T
Get(
unsigned int rowIx,
unsigned int colIx)
const {
67 unsigned int dataIx = rowIx * this->cols + colIx;
68 return this->data[dataIx];
71 void Set(
unsigned int rowIx,
unsigned int colIx, T value) {
72 unsigned int dataIx = rowIx * this->cols + colIx;
73 this->data[dataIx] = value;
77 void Set(
const T *source) {
78 unsigned int matrixSize = this->cols * this->rows;
79 for (
unsigned int dataIx = 0; dataIx < matrixSize; dataIx++)
80 this->data[dataIx] = source[dataIx];
84 void SetRow(
unsigned int rowIx,
const T *source) {
85 unsigned int dataIx = rowIx * this->cols;
86 for (
unsigned int sourceIx = 0; sourceIx < this->cols; dataIx++, sourceIx++)
87 this->data[dataIx] = source[sourceIx];
91 void SetCol(
unsigned int colIx,
const T *source) {
92 unsigned int dataIx = colIx;
93 for (
unsigned int sourceIx = 0; sourceIx < this->cols;
94 dataIx += this->cols, sourceIx++)
95 this->data[dataIx] = source[sourceIx];
99 unsigned int thisMatrixSize = this->cols * this->rows;
100 unsigned int mMatrixSize = m->cols * m->rows;
101 if (mMatrixSize != thisMatrixSize)
104 for (
unsigned int dataIx = 0; dataIx < thisMatrixSize; dataIx++)
105 this->data[dataIx] = m->data[dataIx];
Single precision float matrix.
Definition Matrix.h:10
void Set(const T *source)
Definition Matrix.h:77
MatrixOf(unsigned int rows, unsigned int cols)
void CopyFrom(const MatrixOf< T > *m)
Definition Matrix.h:98
MatrixOf(unsigned int rows, unsigned int cols, const T *source)
Definition Matrix.h:13
~MatrixOf()
Definition Matrix.h:19
void Set(unsigned int rowIx, unsigned int colIx, T value)
Definition Matrix.h:71
Vector3 operator*(const Vector3 v) const
Definition Matrix.cpp:50
void Transpose(MatrixOf< T > *r) const
Transpose with result in matrix m.
Definition Matrix.h:28
void Multiply(const MatrixOf< T > *m, MatrixOf< T > *r) const
Definition Matrix.h:59
unsigned int ColCount() const
Definition Matrix.h:109
T Get(unsigned int rowIx, unsigned int colIx) const
Definition Matrix.h:66
static void Multiply(const MatrixOf< T > *m1, const MatrixOf< T > *m2, MatrixOf< T > *r)
unsigned int RowCount() const
Definition Matrix.h:108
static Vector3 Multiply(const MatrixOf< T > *m, Vector3 v)
void SetRow(unsigned int rowIx, const T *source)
Definition Matrix.h:84
void SetCol(unsigned int colIx, const T *source)
Definition Matrix.h:91
Definition AbsoluteEncoder.h:5
A 3-dimensional vector.
Definition Vector3.h:42