diff --git a/include/rotgen/dynamic/block.hpp b/include/rotgen/dynamic/block.hpp index 02ae9a6..89145e8 100644 --- a/include/rotgen/dynamic/block.hpp +++ b/include/rotgen/dynamic/block.hpp @@ -195,6 +195,29 @@ namespace rotgen return *this; } + auto minCoeff() const { return parent::minCoeff(); } + auto maxCoeff() const { return parent::maxCoeff(); } + + template + auto minCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::minCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + + template + auto maxCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::maxCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + static concrete_type Zero() requires (Rows != -1 && Cols != -1) { diff --git a/include/rotgen/dynamic/map.hpp b/include/rotgen/dynamic/map.hpp index 6db4423..d176476 100644 --- a/include/rotgen/dynamic/map.hpp +++ b/include/rotgen/dynamic/map.hpp @@ -181,6 +181,29 @@ namespace rotgen return *this; } + auto minCoeff() const { return parent::minCoeff(); } + auto maxCoeff() const { return parent::maxCoeff(); } + + template + auto minCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::minCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + + template + auto maxCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::maxCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + static auto Zero() requires( requires {Ref::Zero();} ) { return Ref::Zero(); diff --git a/include/rotgen/dynamic/matrix.hpp b/include/rotgen/dynamic/matrix.hpp index e2a1877..6827284 100644 --- a/include/rotgen/dynamic/matrix.hpp +++ b/include/rotgen/dynamic/matrix.hpp @@ -175,6 +175,29 @@ namespace rotgen return *this; } + auto minCoeff() const { return parent::minCoeff(); } + auto maxCoeff() const { return parent::maxCoeff(); } + + template + auto minCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::minCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + + template + auto maxCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::maxCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + static matrix Ones() requires (Rows != -1 && Cols != -1) { return parent::Ones(Rows, Cols); diff --git a/include/rotgen/fixed/block.hpp b/include/rotgen/fixed/block.hpp index 6173680..3d86509 100644 --- a/include/rotgen/fixed/block.hpp +++ b/include/rotgen/fixed/block.hpp @@ -345,13 +345,35 @@ namespace rotgen using parent::prod; using parent::mean; using parent::trace; - using parent::maxCoeff; - using parent::minCoeff; using parent::squaredNorm; using parent::norm; using parent::sum; using parent::data; + + auto minCoeff() const { return parent::minCoeff(); } + auto maxCoeff() const { return parent::maxCoeff(); } + + template + auto minCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::minCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + + template + auto maxCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::maxCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + Index startRow() const { return base().startRow(); } Index startCol() const { return base().startCol(); } diff --git a/include/rotgen/fixed/map.hpp b/include/rotgen/fixed/map.hpp index aa8e42b..68443cf 100644 --- a/include/rotgen/fixed/map.hpp +++ b/include/rotgen/fixed/map.hpp @@ -268,11 +268,33 @@ namespace rotgen using parent::mean; using parent::prod; using parent::trace; - using parent::maxCoeff; - using parent::minCoeff; using parent::norm; using parent::squaredNorm; + + auto minCoeff() const { return parent::minCoeff(); } + auto maxCoeff() const { return parent::maxCoeff(); } + + template + auto minCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::minCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + + template + auto maxCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::maxCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + template value_type lpNorm() const { static_assert(P == 1 || P == 2 || P == Infinity); diff --git a/include/rotgen/fixed/matrix.hpp b/include/rotgen/fixed/matrix.hpp index 932fabe..3ed4997 100644 --- a/include/rotgen/fixed/matrix.hpp +++ b/include/rotgen/fixed/matrix.hpp @@ -289,13 +289,35 @@ namespace rotgen using parent::prod; using parent::mean; using parent::trace; - using parent::maxCoeff; - using parent::minCoeff; using parent::squaredNorm; using parent::norm; using parent::sum; using parent::data; + + auto minCoeff() const { return parent::minCoeff(); } + auto maxCoeff() const { return parent::maxCoeff(); } + + template + auto minCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::minCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + + template + auto maxCoeff(IndexType* row, IndexType* col) const + { + Index r,c; + auto result = parent::maxCoeff(&r, &c); + *row = r; + *col = c; + return result; + } + matrix& setOnes() { *this = parent::Ones(rows(),cols()); diff --git a/include/rotgen/functions.hpp b/include/rotgen/functions.hpp index 5126cfd..9854f3f 100644 --- a/include/rotgen/functions.hpp +++ b/include/rotgen/functions.hpp @@ -60,11 +60,15 @@ namespace rotgen } auto minCoeff(concepts::entity auto const& arg) { return arg.minCoeff(); } - auto maxCoeff(concepts::entity auto const& arg, Index* row, Index* col) + + template + auto maxCoeff(concepts::entity auto const& arg, IndexType* row, IndexType* col) { return arg.maxCoeff(row, col); } - auto minCoeff(concepts::entity auto const& arg, Index* row, Index* col) + + template + auto minCoeff(concepts::entity auto const& arg, IndexType* row, IndexType* col) { return arg.minCoeff(row, col); } diff --git a/include/rotgen/impl/block_model.hpp b/include/rotgen/impl/block_model.hpp index 395c847..e07222c 100644 --- a/include/rotgen/impl/block_model.hpp +++ b/include/rotgen/impl/block_model.hpp @@ -66,8 +66,8 @@ class ROTGEN_EXPORT CLASSNAME TYPE trace() const; TYPE maxCoeff() const; TYPE minCoeff() const; - TYPE maxCoeff(std::ptrdiff_t* row, std::ptrdiff_t* col) const; - TYPE minCoeff(std::ptrdiff_t* row, std::ptrdiff_t* col) const; + TYPE maxCoeff(Index* row, Index* col) const; + TYPE minCoeff(Index* row, Index* col) const; TYPE squaredNorm() const; TYPE norm() const; diff --git a/include/rotgen/impl/matrix_model.hpp b/include/rotgen/impl/matrix_model.hpp index 7912c8d..d841e7c 100644 --- a/include/rotgen/impl/matrix_model.hpp +++ b/include/rotgen/impl/matrix_model.hpp @@ -53,8 +53,8 @@ class ROTGEN_EXPORT CLASSNAME TYPE trace() const; TYPE maxCoeff() const; TYPE minCoeff() const; - TYPE maxCoeff(std::ptrdiff_t* row, std::ptrdiff_t* col) const; - TYPE minCoeff(std::ptrdiff_t* row, std::ptrdiff_t* col) const; + TYPE maxCoeff(Index* row, Index* col) const; + TYPE minCoeff(Index* row, Index* col) const; TYPE squaredNorm() const; TYPE norm() const; diff --git a/src/block_model.cpp b/src/block_model.cpp index 9d6d136..5def410 100644 --- a/src/block_model.cpp +++ b/src/block_model.cpp @@ -331,14 +331,14 @@ struct CLASSNAME::payload return val; } - TYPE CLASSNAME::minCoeff(std::ptrdiff_t* row, std::ptrdiff_t* col) const + TYPE CLASSNAME::minCoeff(Index* row, Index* col) const { TYPE val{}; storage_->apply([&](const auto& blk) { val = blk.minCoeff(row, col); }); return val; } - TYPE CLASSNAME::maxCoeff(std::ptrdiff_t* row, std::ptrdiff_t* col) const + TYPE CLASSNAME::maxCoeff(Index* row, Index* col) const { TYPE val{}; storage_->apply([&](const auto& blk) { val = blk.maxCoeff(row, col); }); diff --git a/src/matrix_model.cpp b/src/matrix_model.cpp index 2c832d7..c3fd6c7 100644 --- a/src/matrix_model.cpp +++ b/src/matrix_model.cpp @@ -143,8 +143,8 @@ TYPE CLASSNAME::trace() const { return storage_->data.trace(); } TYPE CLASSNAME::minCoeff() const { return storage_->data.minCoeff(); } TYPE CLASSNAME::maxCoeff() const { return storage_->data.maxCoeff(); } -TYPE CLASSNAME::minCoeff(std::ptrdiff_t* row, std::ptrdiff_t* col) const { return storage_->data.minCoeff(row, col); } -TYPE CLASSNAME::maxCoeff(std::ptrdiff_t* row, std::ptrdiff_t* col) const { return storage_->data.maxCoeff(row, col); } +TYPE CLASSNAME::minCoeff(Index* row, Index* col) const { return storage_->data.minCoeff(row, col); } +TYPE CLASSNAME::maxCoeff(Index* row, Index* col) const { return storage_->data.maxCoeff(row, col); } TYPE CLASSNAME::squaredNorm() const { return storage_->data.squaredNorm(); } TYPE CLASSNAME::norm() const { return storage_->data.norm(); } diff --git a/test/unit/common/arithmetic.hpp b/test/unit/common/arithmetic.hpp index 292104a..937d3a1 100644 --- a/test/unit/common/arithmetic.hpp +++ b/test/unit/common/arithmetic.hpp @@ -100,7 +100,7 @@ namespace rotgen::tests TTS_EQUAL(maxCoeff(input) , ref.maxCoeff()); { - rotgen::Index row, col, ref_row, ref_col; + int row, col, ref_row, ref_col; TTS_EQUAL(input.minCoeff(&row, &col), ref.minCoeff(&ref_row, &ref_col)); TTS_EQUAL(row, ref_row); @@ -112,7 +112,7 @@ namespace rotgen::tests } { - rotgen::Index row, col, ref_row, ref_col; + int row, col, ref_row, ref_col; TTS_EQUAL(minCoeff(input,&row, &col), ref.minCoeff(&ref_row, &ref_col)); TTS_EQUAL(row, ref_row);