diff --git a/include/Peanut/impl/binary_expr/matrix_div_scalar.h b/include/Peanut/impl/binary_expr/matrix_div_scalar.h index c802339..87ec1e4 100644 --- a/include/Peanut/impl/binary_expr/matrix_div_scalar.h +++ b/include/Peanut/impl/binary_expr/matrix_div_scalar.h @@ -51,14 +51,14 @@ namespace Peanut::Impl { } // Static polymorphism implementation of MatrixExpr - INLINE Float elem(Index r, Index c) const { + inline Float elem(Index r, Index c) const { return static_cast(x.elem(r, c)) / static_cast(y); } static constexpr Index Row = E::Row; static constexpr Index Col = E::Col; - INLINE auto eval() const { + inline auto eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/binary_expr/matrix_emult.h b/include/Peanut/impl/binary_expr/matrix_emult.h index 853c0aa..7bf90ae 100644 --- a/include/Peanut/impl/binary_expr/matrix_emult.h +++ b/include/Peanut/impl/binary_expr/matrix_emult.h @@ -46,14 +46,14 @@ namespace Peanut::Impl { MatrixEMult(const E1 &x, const E2 &y) : x{x}, y{y} {} // Static polymorphism implementation of MatrixExpr - INLINE auto elem(Index r, Index c) const { + inline auto elem(Index r, Index c) const { return x.elem(r, c) * y.elem(r, c); } static constexpr Index Row = E1::Row; static constexpr Index Col = E1::Col; - INLINE auto eval() const { + inline auto eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/binary_expr/matrix_mult.h b/include/Peanut/impl/binary_expr/matrix_mult.h index dd44e91..5e0a0f9 100644 --- a/include/Peanut/impl/binary_expr/matrix_mult.h +++ b/include/Peanut/impl/binary_expr/matrix_mult.h @@ -47,7 +47,7 @@ namespace Peanut::Impl { MatrixMult(const E1 &_x, const E2 &_y) : x_eval{_x}, y_eval{_y} {} // Static polymorphism implementation of MatrixExpr - INLINE auto elem(Index r, Index c) const { + inline auto elem(Index r, Index c) const { auto ret = x_eval.elem(r, 0) * y_eval.elem(0, c); for (Index i = 1; i < E1::Col; i++) { ret += x_eval.elem(r, i) * y_eval.elem(i, c); @@ -58,7 +58,7 @@ namespace Peanut::Impl { static constexpr Index Row = E1::Row; static constexpr Index Col = E2::Col; - INLINE auto eval() const { + inline auto eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/binary_expr/matrix_mult_scalar.h b/include/Peanut/impl/binary_expr/matrix_mult_scalar.h index 86e1dab..665817f 100644 --- a/include/Peanut/impl/binary_expr/matrix_mult_scalar.h +++ b/include/Peanut/impl/binary_expr/matrix_mult_scalar.h @@ -47,14 +47,14 @@ namespace Peanut::Impl { MatrixMultScalar(const E &x, T y) : x{x}, y{y} {} // Static polymorphism implementation of MatrixExpr - INLINE Type elem(Index r, Index c) const { + inline Type elem(Index r, Index c) const { return static_cast(x.elem(r, c)) * static_cast(y); } static constexpr Index Row = E::Row; static constexpr Index Col = E::Col; - INLINE auto eval() const { + inline auto eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/binary_expr/matrix_subtract.h b/include/Peanut/impl/binary_expr/matrix_subtract.h index d23d83d..81946f3 100644 --- a/include/Peanut/impl/binary_expr/matrix_subtract.h +++ b/include/Peanut/impl/binary_expr/matrix_subtract.h @@ -45,14 +45,14 @@ namespace Peanut::Impl { MatrixSubtract(const E1 &x, const E2 &y) : x{x}, y{y} {} // Static polymorphism implementation of MatrixExpr - INLINE auto elem(Index r, Index c) const { + inline auto elem(Index r, Index c) const { return x.elem(r, c) - y.elem(r, c); } static constexpr Index Row = E1::Row; static constexpr Index Col = E1::Col; - INLINE auto eval() const { + inline auto eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/binary_expr/matrix_sum.h b/include/Peanut/impl/binary_expr/matrix_sum.h index d1b4625..a8a12f2 100644 --- a/include/Peanut/impl/binary_expr/matrix_sum.h +++ b/include/Peanut/impl/binary_expr/matrix_sum.h @@ -45,14 +45,14 @@ namespace Peanut::Impl { MatrixSum(const E1 &x, const E2 &y) : x{x}, y{y} {} // Static polymorphism implementation of MatrixExpr - INLINE auto elem(Index r, Index c) const { + inline auto elem(Index r, Index c) const { return x.elem(r, c) + y.elem(r, c); } static constexpr Index Row = E1::Row; static constexpr Index Col = E1::Col; - INLINE auto eval() const { + inline auto eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/common.h b/include/Peanut/impl/common.h index 4542fa2..d8f4615 100644 --- a/include/Peanut/impl/common.h +++ b/include/Peanut/impl/common.h @@ -34,8 +34,6 @@ // Dependencies headers -#define INLINE __attribute__((always_inline)) inline - namespace Peanut { using Index = unsigned int; using Float = float; diff --git a/include/Peanut/impl/matrix.h b/include/Peanut/impl/matrix.h index 571d210..44b88a7 100644 --- a/include/Peanut/impl/matrix.h +++ b/include/Peanut/impl/matrix.h @@ -66,7 +66,7 @@ namespace Peanut { * @param c C index. * @return Rvalue of an element in \p r 'th Row and \p c 'th column. */ - INLINE auto elem(Index r, Index c) const{ + inline auto elem(Index r, Index c) const{ return static_cast(*this).elem(r, c); } }; @@ -228,7 +228,7 @@ namespace Peanut { * @param c Column index. * @return Rvalue of an element in \p r 'th Row and \p c 'th column. */ - INLINE T elem(Index r, Index c) const{ + inline T elem(Index r, Index c) const{ return m_data.d2[r][c]; } @@ -240,7 +240,7 @@ namespace Peanut { * @param c Column index. * @return Reference of an element in \p r 'th Row and \p c 'th column. */ - INLINE T& elem(Index r, Index c) { + inline T& elem(Index r, Index c) { return m_data.d2[r][c]; } @@ -294,7 +294,7 @@ namespace Peanut { * method even though it is not a method of `MatrixExpr`. * @return Evaluated matrix */ - INLINE Matrix eval() const{ + inline Matrix eval() const{ return Matrix(*this); } @@ -306,7 +306,7 @@ namespace Peanut { * @param i Index * @return \p T type i'th element data. */ - INLINE T operator[](Index i) const + inline T operator[](Index i) const requires (Row==1) || (Col==1){ return m_data.d1[i]; } @@ -317,7 +317,7 @@ namespace Peanut { * @param i Index * @return Reference of i'th element. */ - INLINE T& operator[](Index i) + inline T& operator[](Index i) requires (Row==1) || (Col==1){ return m_data.d1[i]; } @@ -328,7 +328,7 @@ namespace Peanut { * @param vec Equal-type matrix(vector). * @return T type dot product result. */ - T dot(const Matrix &vec) const requires (Row==1) || (Col==1){ + inline T dot(const Matrix &vec) const requires (Row==1) || (Col==1){ T ret = t_0; for(int i=0;i normalize() const requires (Row==1) || (Col==1){ + inline Matrix normalize() const requires (Row==1) || (Col==1){ Matrix ret; const Float len = length(); for(int i=0;i eval() const { + inline Matrix eval() const { return mat_eval; } diff --git a/include/Peanut/impl/unary_expr/block.h b/include/Peanut/impl/unary_expr/block.h index 756bb7b..e876cff 100644 --- a/include/Peanut/impl/unary_expr/block.h +++ b/include/Peanut/impl/unary_expr/block.h @@ -48,14 +48,14 @@ namespace Peanut::Impl { MatrixBlock(const E &x) : x{x} {} // Static polymorphism implementation of MatrixExpr - INLINE auto elem(Index r, Index c) const { + inline auto elem(Index r, Index c) const { return x.elem(row_start + r, col_start + c); } static constexpr Index Row = row_size; static constexpr Index Col = col_size; - INLINE Matrix eval() const { + inline Matrix eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/unary_expr/cast.h b/include/Peanut/impl/unary_expr/cast.h index 3177d2d..cab41cc 100644 --- a/include/Peanut/impl/unary_expr/cast.h +++ b/include/Peanut/impl/unary_expr/cast.h @@ -44,14 +44,14 @@ namespace Peanut::Impl { MatrixCastType(const E &x) : x{x} {} // Static polymorphism implementation of MatrixExpr - INLINE T elem(Index r, Index c) const { + inline T elem(Index r, Index c) const { return static_cast(x.elem(r, c)); } static constexpr Index Row = E::Row; static constexpr Index Col = E::Col; - INLINE Matrix eval() const { + inline Matrix eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/unary_expr/cofactor.h b/include/Peanut/impl/unary_expr/cofactor.h index 77f93e4..09efa0c 100644 --- a/include/Peanut/impl/unary_expr/cofactor.h +++ b/include/Peanut/impl/unary_expr/cofactor.h @@ -59,14 +59,14 @@ namespace Peanut::Impl { } // Static polymorphism implementation of MatrixExpr - INLINE auto elem(Index r, Index c) const { + inline auto elem(Index r, Index c) const { return mat_eval.elem(r, c); } static constexpr Index Row = E::Row; static constexpr Index Col = E::Col; - INLINE Matrix eval() const { + inline Matrix eval() const { return mat_eval; } diff --git a/include/Peanut/impl/unary_expr/inverse.h b/include/Peanut/impl/unary_expr/inverse.h index ddf6ccb..3557dc5 100644 --- a/include/Peanut/impl/unary_expr/inverse.h +++ b/include/Peanut/impl/unary_expr/inverse.h @@ -52,14 +52,14 @@ namespace Peanut::Impl { } // Static polymorphism implementation of MatrixExpr - INLINE Float elem(Index r, Index c) const { + inline Float elem(Index r, Index c) const { return invdet * cofactor_eval.elem(c, r); } static constexpr Index Row = E::Row; static constexpr Index Col = E::Col; - INLINE Matrix eval() const { + inline Matrix eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/unary_expr/minor.h b/include/Peanut/impl/unary_expr/minor.h index 233ff5a..42afdb0 100644 --- a/include/Peanut/impl/unary_expr/minor.h +++ b/include/Peanut/impl/unary_expr/minor.h @@ -51,14 +51,14 @@ namespace Peanut::Impl { } // Static polymorphism implementation of MatrixExpr - INLINE auto elem(Index r, Index c) const { + inline auto elem(Index r, Index c) const { return mat_eval.elem(r, c); } static constexpr Index Row = E::Row; static constexpr Index Col = E::Col; - INLINE Matrix eval() const { + inline Matrix eval() const { return mat_eval; } diff --git a/include/Peanut/impl/unary_expr/negation.h b/include/Peanut/impl/unary_expr/negation.h index b7e721f..18acd74 100644 --- a/include/Peanut/impl/unary_expr/negation.h +++ b/include/Peanut/impl/unary_expr/negation.h @@ -44,14 +44,14 @@ namespace Peanut::Impl { MatrixNegation(const E &x) : x{x} {} // Static polymorphism implementation of MatrixExpr - INLINE auto elem(Index r, Index c) const { + inline auto elem(Index r, Index c) const { return -x.elem(r, c); } static constexpr Index Row = E::Row; static constexpr Index Col = E::Col; - INLINE Matrix eval() const { + inline Matrix eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/unary_expr/submatrix.h b/include/Peanut/impl/unary_expr/submatrix.h index 031a3c3..8cb25a6 100644 --- a/include/Peanut/impl/unary_expr/submatrix.h +++ b/include/Peanut/impl/unary_expr/submatrix.h @@ -47,14 +47,14 @@ namespace Peanut::Impl { MatrixSub(const E &x) : x{x} {} // Static polymorphism implementation of MatrixExpr - INLINE auto elem(Index r, Index c) const { + inline auto elem(Index r, Index c) const { return x.elem(r < row_ex ? r : r + 1, c < col_ex ? c : c + 1); } static constexpr Index Row = E::Row - 1; static constexpr Index Col = E::Col - 1; - INLINE Matrix eval() const { + inline Matrix eval() const { return Matrix(*this); } diff --git a/include/Peanut/impl/unary_expr/transpose.h b/include/Peanut/impl/unary_expr/transpose.h index f993f8b..a9ffc23 100644 --- a/include/Peanut/impl/unary_expr/transpose.h +++ b/include/Peanut/impl/unary_expr/transpose.h @@ -44,14 +44,14 @@ namespace Peanut::Impl { MatrixTranspose(const E &x) : x{x} {} // Static polymorphism implementation of MatrixExpr - INLINE auto elem(Index r, Index c) const { + inline auto elem(Index r, Index c) const { return x.elem(c, r); } static constexpr Index Row = E::Col; static constexpr Index Col = E::Row; - INLINE Matrix eval() const { + inline Matrix eval() const { return Matrix(*this); }