Move Zero() and Identity() definitions to the right place
This commit is contained in:
parent
2cadffd7d4
commit
9474153736
1 changed files with 30 additions and 34 deletions
|
@ -70,6 +70,36 @@ template<UInt N, UInt M>
|
|||
Matrix<N,M> operator*(const Double& lhs, const Matrix<N,M>& rhs);
|
||||
|
||||
|
||||
/*
|
||||
* charles::basics::Matrix<>::Zero --
|
||||
*/
|
||||
template<UInt N, UInt M>
|
||||
/* static */ Matrix<N,M>
|
||||
Matrix<N,M>::Zero()
|
||||
{
|
||||
Matrix<N,M> m;
|
||||
bzero(m.mData, sizeof(Double) * N * M);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* charles::basics::Matrix<>::Identity --
|
||||
*/
|
||||
template<UInt N, UInt M>
|
||||
/* static */ Matrix<N,M>
|
||||
Matrix<N,M>::Identity()
|
||||
{
|
||||
static_assert(N == M, "Identity matrices must be square.");
|
||||
|
||||
auto m = Matrix<N,M>::Zero();
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
m(i,i) = 1.0;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* charles::basics::Matrix<>::Matrix --
|
||||
*/
|
||||
|
@ -140,40 +170,6 @@ Matrix<N,M>::operator!=(const Matrix<N,M>& rhs)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* charles::basics::Matrix<>::Zero --
|
||||
*/
|
||||
template<UInt N, UInt M>
|
||||
Matrix<N,M>
|
||||
Matrix<N,M>::Zero()
|
||||
{
|
||||
Matrix<N,M> m;
|
||||
bzero(m.mData, sizeof(Double) * N * M);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* charles::basics::Matrix<>::Identity --
|
||||
*/
|
||||
template<UInt N, UInt M>
|
||||
Matrix<N,M>
|
||||
Matrix<N,M>::Identity()
|
||||
{
|
||||
static_assert(N == M, "Identity matrices must be square.");
|
||||
|
||||
auto m = Matrix<N,M>::Zero();
|
||||
for (int i = 0; i < N; i++) {
|
||||
for (int j = 0; j < M; j++) {
|
||||
if (i == j) {
|
||||
m(i,j) = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* charles::basics::Matrix<>::operator() --
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue