5 #ifndef LODESTAR_MINMAXIDXBLOCK_HPP
6 #define LODESTAR_MINMAXIDXBLOCK_HPP
8 #include <Lodestar/blocks/Block.hpp>
9 #include <Lodestar/aux/TemplateTools.hpp>
11 #include <Eigen/Dense>
27 #define OUTPUT_MINMAXIDXBLOCK() \
28 typename ::std::conditional<ls::aux::TemplateTraits::BinaryOperators::parseMatrixLike<TInput>::value, typename ls::aux::TemplateTraits::BinaryOperators::parseMatrixLike<TInput>::scalar, TInput>::type
30 template<
typename TInput, MinMaxIdxBlockOperator TOps>
34 ::std::tuple<int, int, OUTPUT_MINMAXIDXBLOCK()>,
41 ::std::tuple<int, int, OUTPUT_MINMAXIDXBLOCK()>,
46 static_assert(InputTrait::value,
"Input must be matrix-like; otherwise same value would be returned.");
57 using OutputType = OUTPUT_MINMAXIDXBLOCK();
67 typename ::std::enable_if<TTOps == Min>::type * =
nullptr>
70 this->equation = [](Base &b) ->
void {
71 static Eigen::Index minRow, minCol;
73 b.template o<2>() = b.template i<0>().object.minCoeff(&minRow, &minCol);
74 b.template o<0>() = minRow;
75 b.template o<1>() = minCol;
80 typename ::std::enable_if<TTOps == Max>::type * =
nullptr>
83 this->equation = [](Base &b) ->
void {
84 static Eigen::Index maxRow, maxCol;
86 b.template o<2>() = b.template i<0>().object.maxCoeff(&maxRow, &maxCol);
87 b.template o<0>() = maxRow;
88 b.template o<1>() = maxCol;
94 template<
typename TInput, std::MinMaxIdxBlockOperator TOps>
111 static const ::std::array<::std::string, kIns>
inTypes;
112 static const ::std::array<::std::string, kOuts>
outTypes;
113 static const ::std::array<::std::string, kPars>
parTypes;
118 template<
typename TInput, std::MinMaxIdxBlockOperator TOps>
120 {demangle(
typeid(TInput).name())};
122 template<
typename TInput, std::MinMaxIdxBlockOperator TOps>
123 const ::std::array<::std::string, BlockTraits<std::MinMaxIdxBlock<TInput, TOps>>::kOuts> BlockTraits<std::MinMaxIdxBlock<TInput, TOps>>::outTypes =
124 {
"int",
"int", demangle(
typeid(
typename std::MinMaxIdxBlock<TInput, TOps>::OutputType).name())};
126 template<
typename TInput, std::MinMaxIdxBlockOperator TOps>
127 const ::std::array<::std::string, BlockTraits<std::MinMaxIdxBlock<TInput, TOps>>::kPars> BlockTraits<std::MinMaxIdxBlock<TInput, TOps>>::parTypes =
130 template<
typename TInput, std::MinMaxIdxBlockOperator TOps>
131 const ::std::array<::std::string, 2> BlockTraits<std::MinMaxIdxBlock<TInput, TOps>>::templateTypes =
132 {demangle(
typeid(TInput).name()), demangle(
typeid(TOps).name())};
137 #endif //LODESTAR_MINMAXIDXBLOCK_HPP