fix warnign in release mode

This commit is contained in:
Eduardo Bart 2011-12-30 04:52:43 -02:00
parent 08fbedce38
commit f7dd35f0dd
1 changed files with 32 additions and 26 deletions

View File

@ -83,19 +83,18 @@ void Matrix<N,M,T>::setIdentity() {
template<int N, int M, typename T>
bool Matrix<N,M,T>::isIdentity() const {
for(int i=0;i<N;++i) {
for(int j=0;j<M;++j) {
for(int i=0;i<N;++i)
for(int j=0;j<M;++j)
if((i==j && m[i][j] != 1.0f) || (i!=j && m[i][j] != 0.0f))
return false;
}
}
return true;
}
template<int N, int M, typename T>
void Matrix<N,M,T>::fill(T value) {
for(int i=0;i<N*M;++i)
m[0][i] = value;
for(int i=0;i<N;++i)
for(int j=0;j<M;++j)
m[i][j] = value;
}
template<int N, int M, typename T>
@ -111,8 +110,9 @@ template<int N, int M, typename T>
template<typename U>
Matrix<N,M,T>& Matrix<N,M,T>::operator=(const std::initializer_list<U>& values) {
auto it = values.begin();
for(int i=0;i<N*M;++i)
m[0][i] = *(it++);
for(int i=0;i<N;++i)
for(int j=0;j<M;++j)
m[i][j] = *(it++);
return *this;
}
@ -127,37 +127,42 @@ Matrix<N,M,T>& Matrix<N,M,T>::operator=(const U *values) {
template<int N, int M, typename T>
Matrix<N,M,T>& Matrix<N,M,T>::operator+=(const Matrix<N,M,T>& other) {
for(int i=0;i<N*M;++i)
m[0][i] += other.m[0][i];
for(int i=0;i<N;++i)
for(int j=0;j<M;++j)
m[i][j] += other.m[i][j];
return *this;
}
template<int N, int M, typename T>
Matrix<N,M,T>& Matrix<N,M,T>::operator-=(const Matrix<N,M,T>& other) {
for(int i=0;i<N*M;++i)
m[0][i] -= other.m[0][i];
for(int i=0;i<N;++i)
for(int j=0;j<M;++j)
m[i][j] -= other.m[i][j];
return *this;
}
template<int N, int M, typename T>
Matrix<N,M,T>& Matrix<N,M,T>::operator*=(T factor) {
for(int i=0;i<N*M;++i)
m[0][i] *= factor;
for(int i=0;i<N;++i)
for(int j=0;j<M;++j)
m[i][j] *= factor;
return *this;
}
template<int N, int M, typename T>
Matrix<N,M,T>& Matrix<N,M,T>::operator/=(T divisor) {
for(int i=0;i<N*M;++i)
m[0][i] /= divisor;
for(int i=0;i<N;++i)
for(int j=0;j<M;++j)
m[i][j] /= divisor;
return *this;
}
template<int N, int M, typename T>
bool Matrix<N,M,T>::operator==(const Matrix<N,M,T>& other) const
{
for(int i=0;i<N*M;++i)
if(m[0][i] != other.m[0][i])
for(int i=0;i<N;++i)
for(int j=0;j<M;++j)
if(m[i][j] != other.m[i][j])
return false;
return true;
}
@ -165,8 +170,9 @@ bool Matrix<N,M,T>::operator==(const Matrix<N,M,T>& other) const
template<int N, int M, typename T>
bool Matrix<N,M,T>::operator!=(const Matrix<N,M,T>& other) const
{
for(int i=0;i<N*M;++i)
if(m[0][i] != other.m[0][i])
for(int i=0;i<N;++i)
for(int j=0;j<M;++j)
if(m[i][j] != other.m[i][j])
return true;
return false;
}