Skip to content

Commit

Permalink
Revert "Add INLINE define to force inline function"
Browse files Browse the repository at this point in the history
  • Loading branch information
pjessesco authored Feb 27, 2024
1 parent 1fedbe4 commit cd23675
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 43 deletions.
4 changes: 2 additions & 2 deletions include/Peanut/impl/binary_expr/matrix_div_scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type>(x.elem(r, c)) / static_cast<Float>(y);
}

static constexpr Index Row = E::Row;
static constexpr Index Col = E::Col;

INLINE auto eval() const {
inline auto eval() const {
return Matrix<Type, Row, Col>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/binary_expr/matrix_emult.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/binary_expr/matrix_mult.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<Type, Row, Col>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/binary_expr/matrix_mult_scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type>(x.elem(r, c)) * static_cast<Type>(y);
}

static constexpr Index Row = E::Row;
static constexpr Index Col = E::Col;

INLINE auto eval() const {
inline auto eval() const {
return Matrix<Type, Row, Col>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/binary_expr/matrix_subtract.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/binary_expr/matrix_sum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col>(*this);
}

Expand Down
2 changes: 0 additions & 2 deletions include/Peanut/impl/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@

// Dependencies headers

#define INLINE __attribute__((always_inline)) inline

namespace Peanut {
using Index = unsigned int;
using Float = float;
Expand Down
22 changes: 11 additions & 11 deletions include/Peanut/impl/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const E&>(*this).elem(r, c);
}
};
Expand Down Expand Up @@ -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];
}

Expand All @@ -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];
}

Expand Down Expand Up @@ -294,7 +294,7 @@ namespace Peanut {
* method even though it is not a method of `MatrixExpr`.
* @return Evaluated matrix
*/
INLINE Matrix<Type, Row, Col> eval() const{
inline Matrix<Type, Row, Col> eval() const{
return Matrix<Type, Row, Col>(*this);
}

Expand All @@ -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];
}
Expand All @@ -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];
}
Expand All @@ -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<Row*Col;i++){
ret += (vec.m_data.d1[i] * m_data.d1[i]);
Expand All @@ -341,7 +341,7 @@ namespace Peanut {
* (i.e., Row==1 or Col==1)
* @return Float l2 distance of the vector.
*/
Float length() const requires (Row==1) || (Col==1){
inline Float length() const requires (Row==1) || (Col==1){
T ret = t_0;
for(int i=0;i<Row*Col;i++){
ret += (m_data.d1[i] * m_data.d1[i]);
Expand All @@ -354,7 +354,7 @@ namespace Peanut {
* (i.e., Row==1 or Col==1)
* @return Normalized Float matrix(vector).
*/
Matrix<Float, Row, Col> normalize() const requires (Row==1) || (Col==1){
inline Matrix<Float, Row, Col> normalize() const requires (Row==1) || (Col==1){
Matrix<Float, Row, Col> ret;
const Float len = length();
for(int i=0;i<Row*Col;i++){
Expand All @@ -368,7 +368,7 @@ namespace Peanut {
* (i.e., Row==1 or Col==1)
* @return Max element in the vector.
*/
T max() const requires (Row==1) || (Col==1){
inline T max() const requires (Row==1) || (Col==1){
return *std::max_element(m_data.d1.begin(), m_data.d1.end());
}

Expand All @@ -377,7 +377,7 @@ namespace Peanut {
* (i.e., Row==1 or Col==1)
* @return Min element in the vector.
*/
T min() const requires (Row==1) || (Col==1){
inline T min() const requires (Row==1) || (Col==1){
return *std::min_element(m_data.d1.begin(), m_data.d1.end());
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/unary_expr/adjugate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col> eval() const {
inline Matrix<Type, Row, Col> eval() const {
return mat_eval;
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/unary_expr/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col> eval() const {
inline Matrix<Type, Row, Col> eval() const {
return Matrix<Type, Row, Col>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/unary_expr/cast.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(x.elem(r, c));
}

static constexpr Index Row = E::Row;
static constexpr Index Col = E::Col;

INLINE Matrix<Type, Row, Col> eval() const {
inline Matrix<Type, Row, Col> eval() const {
return Matrix<Type, Row, Col>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/unary_expr/cofactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col> eval() const {
inline Matrix<Type, Row, Col> eval() const {
return mat_eval;
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/unary_expr/inverse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col> eval() const {
inline Matrix<Type, Row, Col> eval() const {
return Matrix<Type, Row, Col>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/unary_expr/minor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col> eval() const {
inline Matrix<Type, Row, Col> eval() const {
return mat_eval;
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/unary_expr/negation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col> eval() const {
inline Matrix<Type, Row, Col> eval() const {
return Matrix<Type, Row, Col>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/unary_expr/submatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col> eval() const {
inline Matrix<Type, Row, Col> eval() const {
return Matrix<Type, Row, Col>(*this);
}

Expand Down
4 changes: 2 additions & 2 deletions include/Peanut/impl/unary_expr/transpose.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type, Row, Col> eval() const {
inline Matrix<Type, Row, Col> eval() const {
return Matrix<Type, Row, Col>(*this);
}

Expand Down

0 comments on commit cd23675

Please sign in to comment.