diff --git a/src/basics/matrix.hh b/src/basics/matrix.hh index 84c53a2..aa09535 100644 --- a/src/basics/matrix.hh +++ b/src/basics/matrix.hh @@ -21,7 +21,7 @@ namespace basics { * number of rows. `M` is the number of columns. If `M` is not specified, the * matrix will be square. */ -template +template struct Matrix { /** Construct an N x M matrix of zeros. */ @@ -44,19 +44,19 @@ struct Matrix bool operator!=(const Matrix& rhs); /** Value accessor. Get the ij'th item. */ - Double& operator(uint i, uint j); + Double& operator()(UInt i, UInt j); /** Scalar multiplication */ Matrix operator*(const Double& rhs) const; /** Matrix multiplication */ - template + template Matrix operator*(Matrix rhs) const; /** Get the underlying C array */ const Double* CArray() const; -private: +protected: /** The matrix data, stored in row-major format. */ Double mData[N * M]; }; @@ -66,14 +66,14 @@ typedef Matrix<4> Matrix4; /** Scalar multiplication, scalar factor on the left. */ -template +template Matrix operator*(const Double& lhs, const Matrix& rhs); /* * charles::basics::Matrix<>::Matrix -- */ -template +template Matrix::Matrix() : mData() { } @@ -82,7 +82,7 @@ Matrix::Matrix() /* * charles::basics::Matrix<>::Matrix -- */ -template +template Matrix::Matrix(const Double data[N*M]) { memcpy(mData, data, sizeof(Double) * N * M); @@ -92,7 +92,7 @@ Matrix::Matrix(const Double data[N*M]) /* * charles::basics::Matrix<>::Matrix -- */ -template +template Matrix::Matrix(const Matrix& rhs) : Matrix(rhs.mData) { } @@ -101,7 +101,7 @@ Matrix::Matrix(const Matrix& rhs) /* * charles::basics::Matrix<>::operator= -- */ -template +template Matrix& Matrix::operator=(const Matrix& rhs) { @@ -113,12 +113,13 @@ Matrix::operator=(const Matrix& rhs) /* * charles::basics::Matrix<>::operator== -- */ -template +template bool Matrix::operator==(const Matrix& rhs) const { for (int i = 0; i < N*M; i++) { + /* TODO: Use NearlyEqual. */ if (mData[i] != rhs.mData[i]) { return false; } @@ -130,7 +131,7 @@ Matrix::operator==(const Matrix& rhs) /* * charles::basics::Matrix<>::operator!= -- */ -template +template bool Matrix::operator!=(const Matrix& rhs) const @@ -142,7 +143,7 @@ Matrix::operator!=(const Matrix& rhs) /* * charles::basics::Matrix<>::Zero -- */ -template +template Matrix Matrix::Zero() { @@ -155,7 +156,7 @@ Matrix::Zero() /* * charles::basics::Matrix<>::Identity -- */ -template +template Matrix Matrix::Identity() { @@ -176,9 +177,9 @@ Matrix::Identity() /* * charles::basics::Matrix<>::operator() -- */ -template +template Double& -Matrix::operator()(uint i, uint j) +Matrix::operator()(UInt i, UInt j) { assert(i < N && j < M); return mData[i * N + j]; @@ -188,7 +189,7 @@ Matrix::operator()(uint i, uint j) /* * charles::basics::Matrix<>::operator* -- */ -template +template Matrix Matrix::operator*(const Double& rhs) const @@ -204,8 +205,8 @@ Matrix::operator*(const Double& rhs) /* * charles::basics::Matrix<>::operator* -- */ -template -template +template +template Matrix Matrix::operator*(Matrix rhs) const @@ -228,7 +229,7 @@ Matrix::operator*(Matrix rhs) /* * charles::basics::Matrix<>::CArray -- */ -template +template const Double* Matrix::CArray() const @@ -240,7 +241,7 @@ Matrix::CArray() /* * charles::basics::operator* -- */ -template +template Matrix operator*(const Double& lhs, const Matrix& rhs) diff --git a/src/basics/types.hh b/src/basics/types.hh index 68fb85a..e847353 100644 --- a/src/basics/types.hh +++ b/src/basics/types.hh @@ -13,8 +13,7 @@ typedef double Double; - -typedef unsigned int uint; +typedef unsigned int UInt; typedef std::vector DoubleVector; typedef DoubleVector TVector;