uint –> UInt

This commit is contained in:
Eryn Wells 2014-08-08 21:12:06 -07:00
parent 3b713856db
commit bfd3b8cbce
2 changed files with 22 additions and 22 deletions

View file

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

View file

@ -13,8 +13,7 @@
typedef double Double; typedef double Double;
typedef unsigned int UInt;
typedef unsigned int uint;
typedef std::vector<Double> DoubleVector; typedef std::vector<Double> DoubleVector;
typedef DoubleVector TVector; typedef DoubleVector TVector;