Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
fredroy committed Dec 5, 2023
1 parent e32c815 commit ae3cf96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
18 changes: 9 additions & 9 deletions Sofa/framework/Type/src/sofa/type/Mat.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,36 +203,36 @@ class Mat : public fixed_array<VecNoInit<C,real>, L>
}

/// Assignment from another matrix
template<typename real2>
template<typename real2>
constexpr void operator=(const Mat<L,C,real2>& m) noexcept
{
std::copy(m.begin(), m.begin()+L, this->begin());
}

/// Assignment from a matrix of different size.
template<Size L2, Size C2>
template<Size L2, Size C2>
constexpr void operator=(const Mat<L2,C2,real>& m) noexcept
{
std::copy(m.begin(), m.begin()+(L>L2?L2:L), this->begin());
}

template<Size L2, Size C2>
template<Size L2, Size C2>
constexpr void getsub(Size L0, Size C0, Mat<L2,C2,real>& m) const noexcept
{
for (Size i=0; i<L2; i++)
for (Size j=0; j<C2; j++)
m[i][j] = this->elems[i+L0][j+C0];
}

template<Size L2, Size C2>
template<Size L2, Size C2>
constexpr void setsub(Size L0, Size C0, const Mat<L2,C2,real>& m) noexcept
{
for (Size i=0; i<L2; i++)
for (Size j=0; j<C2; j++)
this->elems[i+L0][j+C0] = m[i][j];
}

template<Size L2>
template<Size L2>
constexpr void setsub(Size L0, Size C0, const Vec<L2,real>& v) noexcept
{
assert( C0<C );
Expand Down Expand Up @@ -808,7 +808,7 @@ class MatNoInit : public Mat<L,C,real>
{
public:
constexpr MatNoInit() noexcept
: Mat<L,C,real>(NOINIT)
: Mat<L,C,real>(NOINIT)
{
}

Expand All @@ -819,7 +819,7 @@ class MatNoInit : public Mat<L,C,real>
}

/// Assignment from another matrix
template<sofa::Size L2, sofa::Size C2, typename real2>
template<sofa::Size L2, sofa::Size C2, typename real2>
constexpr void operator=(const Mat<L2,C2,real2>& m) noexcept
{
this->Mat<L,C,real>::operator=(m);
Expand Down Expand Up @@ -895,7 +895,7 @@ template<sofa::Size N, class real>
constexpr real trace(const Mat<N,N,real>& m) noexcept
{
real t = m[0][0];
for(sofa::Size i=1 ; i<N ; ++i )
for(sofa::Size i=1 ; i<N ; ++i )
t += m[i][i];
return t;
}
Expand All @@ -905,7 +905,7 @@ template<sofa::Size N, class real>
constexpr Vec<N,real> diagonal(const Mat<N,N,real>& m)
{
Vec<N,real> v(NOINIT);
for(sofa::Size i=0 ; i<N ; ++i )
for(sofa::Size i=0 ; i<N ; ++i )
v[i] = m[i][i];
return v;
}
Expand Down
4 changes: 0 additions & 4 deletions Sofa/framework/Type/src/sofa/type/Vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,16 +593,12 @@ class Vec
// operator[]
constexpr reference operator[](size_type i)
{
#ifndef NDEBUG
assert(i < N && "index in Vec must be smaller than size");
#endif
return elems[i];
}
constexpr const_reference operator[](size_type i) const
{
#ifndef NDEBUG
assert(i < N && "index in Vec must be smaller than size");
#endif
return elems[i];
}

Expand Down

0 comments on commit ae3cf96

Please sign in to comment.