Make max/minCoeff templated on index type
See merge request oss/rotgen!23
This commit is contained in:
commit
e7cf89a903
12 changed files with 157 additions and 18 deletions
|
|
@ -195,6 +195,29 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto minCoeff() const { return parent::minCoeff(); }
|
||||
auto maxCoeff() const { return parent::maxCoeff(); }
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<std::integral IndexType>
|
||||
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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -181,6 +181,29 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto minCoeff() const { return parent::minCoeff(); }
|
||||
auto maxCoeff() const { return parent::maxCoeff(); }
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<std::integral IndexType>
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -175,6 +175,29 @@ namespace rotgen
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto minCoeff() const { return parent::minCoeff(); }
|
||||
auto maxCoeff() const { return parent::maxCoeff(); }
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<std::integral IndexType>
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<std::integral IndexType>
|
||||
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(); }
|
||||
|
||||
|
|
|
|||
|
|
@ -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<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<std::integral IndexType>
|
||||
auto maxCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
auto result = parent::maxCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<int P> value_type lpNorm() const
|
||||
{
|
||||
static_assert(P == 1 || P == 2 || P == Infinity);
|
||||
|
|
|
|||
|
|
@ -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<std::integral IndexType>
|
||||
auto minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
Index r,c;
|
||||
auto result = parent::minCoeff(&r, &c);
|
||||
*row = r;
|
||||
*col = c;
|
||||
return result;
|
||||
}
|
||||
|
||||
template<std::integral IndexType>
|
||||
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());
|
||||
|
|
|
|||
|
|
@ -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<std::integral IndexType>
|
||||
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<std::integral IndexType>
|
||||
auto minCoeff(concepts::entity auto const& arg, IndexType* row, IndexType* col)
|
||||
{
|
||||
return arg.minCoeff(row, col);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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); });
|
||||
|
|
|
|||
|
|
@ -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(); }
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue