Code is completely ported (I think)
This commit is contained in:
parent
7f0363ed7b
commit
fb64bca385
@ -52,6 +52,12 @@ Matrix1 Matrix1::Slice(int start, int stop) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void Matrix1::UpdateSlice(int start, int stop, const Matrix1& m) const {
|
||||
for (int ix = start; ix < stop; ix++) {
|
||||
this->data[ix] = m.data[ix - start];
|
||||
}
|
||||
}
|
||||
|
||||
const float& Matrix1::operator()(int ix) const {
|
||||
return data[ix];
|
||||
}
|
||||
@ -76,7 +82,7 @@ Matrix2::Matrix2(int nRows, int nCols) : nRows(nRows), nCols(nCols) {
|
||||
}
|
||||
}
|
||||
|
||||
Matrix2::Matrix2(float* data, int nRows, int nCols)
|
||||
Matrix2::Matrix2(int nRows, int nCols, float* data)
|
||||
: nRows(nRows), nCols(nCols), data(data) {
|
||||
this->nValues = nRows * nCols;
|
||||
this->externalData = true;
|
||||
@ -161,7 +167,6 @@ float& Matrix2::operator()(int row, int col) {
|
||||
return data[row + this->nCols + col];
|
||||
}
|
||||
|
||||
|
||||
void Matrix2::Clear() {
|
||||
for (int ix = 0; ix < this->nValues; ix++)
|
||||
this->data[ix] = 0;
|
||||
@ -311,6 +316,10 @@ Matrix2 Matrix2::Slice(int rowStart, int rowStop, int colStart, int colStop) {
|
||||
return r;
|
||||
}
|
||||
|
||||
void Matrix2::UpdateSlice(int rowStart, int rowStop, const Matrix2& m) const {
|
||||
UpdateSlice(rowStart, rowStop, 0, this->nCols, m);
|
||||
}
|
||||
|
||||
void Matrix2::UpdateSlice(int rowStart,
|
||||
int rowStop,
|
||||
int colStart,
|
||||
|
@ -25,6 +25,7 @@ class Matrix1 {
|
||||
float& operator()(int ix);
|
||||
|
||||
Matrix1 Slice(int start, int stop);
|
||||
void UpdateSlice(int start, int stop, const Matrix1& m) const;
|
||||
|
||||
void Set(unsigned int start, unsigned int stop, float value) {
|
||||
if (stop > this->size)
|
||||
@ -58,7 +59,7 @@ class Matrix2 {
|
||||
|
||||
Matrix2();
|
||||
Matrix2(int nRows, int nCols);
|
||||
Matrix2(float* data, int nRows, int nCols);
|
||||
Matrix2(int nRows, int nCols, float* data);
|
||||
Matrix2(const Matrix2& m);
|
||||
Matrix2& operator=(const Matrix2& other);
|
||||
|
||||
@ -135,6 +136,7 @@ class Matrix2 {
|
||||
|
||||
Matrix2 Slice(int rawStart, int rowStop, int colStart, int colStop);
|
||||
|
||||
void UpdateSlice(int rowStart, int rowStop, const Matrix2& m) const;
|
||||
void UpdateSlice(int rowStart,
|
||||
int rowStop,
|
||||
int colStart,
|
||||
|
Loading…
x
Reference in New Issue
Block a user