Improved matrix access
This commit is contained in:
parent
bc79111c07
commit
7f0363ed7b
@ -52,6 +52,13 @@ Matrix1 Matrix1::Slice(int start, int stop) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float& Matrix1::operator()(int ix) const {
|
||||||
|
return data[ix];
|
||||||
|
}
|
||||||
|
float& Matrix1::operator()(int ix) {
|
||||||
|
return data[ix];
|
||||||
|
}
|
||||||
|
|
||||||
// Matrix1
|
// Matrix1
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
@ -147,6 +154,14 @@ Matrix2 Matrix2::Zero(int nRows, int nCols) {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float& Matrix2::operator()(int row, int col) const {
|
||||||
|
return data[row + this->nCols + col];
|
||||||
|
}
|
||||||
|
float& Matrix2::operator()(int row, int col) {
|
||||||
|
return data[row + this->nCols + col];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Matrix2::Clear() {
|
void Matrix2::Clear() {
|
||||||
for (int ix = 0; ix < this->nValues; ix++)
|
for (int ix = 0; ix < this->nValues; ix++)
|
||||||
this->data[ix] = 0;
|
this->data[ix] = 0;
|
||||||
|
@ -21,6 +21,9 @@ class Matrix1 {
|
|||||||
static Matrix1 FromQuaternion(Quaternion q);
|
static Matrix1 FromQuaternion(Quaternion q);
|
||||||
Quaternion ToQuaternion();
|
Quaternion ToQuaternion();
|
||||||
|
|
||||||
|
const float& operator()(int ix) const;
|
||||||
|
float& operator()(int ix);
|
||||||
|
|
||||||
Matrix1 Slice(int start, int stop);
|
Matrix1 Slice(int start, int stop);
|
||||||
|
|
||||||
void Set(unsigned int start, unsigned int stop, float value) {
|
void Set(unsigned int start, unsigned int stop, float value) {
|
||||||
@ -66,6 +69,9 @@ class Matrix2 {
|
|||||||
static Matrix2 Zero(int nRows, int nCols);
|
static Matrix2 Zero(int nRows, int nCols);
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
const float& operator()(int row, int col) const;
|
||||||
|
float& operator()(int row, int col);
|
||||||
|
|
||||||
static Matrix2 Identity(int size);
|
static Matrix2 Identity(int size);
|
||||||
|
|
||||||
static Matrix2 Diagonal(float f, int size);
|
static Matrix2 Diagonal(float f, int size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user