25typedef Eigen::Array<bool,Eigen::Dynamic,1>
ArrayXb;
26using Eigen::ArrayBase;
46 template<Brush::NodeType N>
49 template<
typename T1,
typename... Tn>
50 inline auto operator()(
const T1& t1, Tn... tn) {
return t1; }
56 template<
typename T1,
typename T2>
65 template<
typename T1,
typename T2>
66 inline auto operator()(
const T1& t1,
const T2& t2) {
return t1 - t2; }
72 template<
typename T1,
typename T2>
73 inline auto operator()(
const T1& t1,
const T2& t2) {
return t1 * t2 ;}
79 template<
typename T1,
typename T2>
80 inline auto operator()(
const T1& t1,
const T2& t2) {
return t1 / t2 ; }
88 template<
typename T1,
typename T2,
typename... Tn>
89 inline auto operator()(
const T1& t1,
const T2& t2, Tn... tn) {
return fmin(t1, t2, tn ...); }
92 inline auto operator()(
const T& t) {
return t.rowwise().minCoeff(); }
102 template<
typename T1,
typename T2,
typename... Tn>
103 inline auto operator()(
const T1& t1,
const T2& t2, Tn... tn) {
return fmax(t1, t2, tn ...); }
106 inline auto operator()(
const T& t) {
return t.rowwise().maxCoeff(); }
118 inline auto operator()(
const T& t) {
return t.rowwise().mean(); }
132 template<
typename Derived>
133 typename Derived::Scalar
median( Eigen::DenseBase<Derived>& d ){
134 auto r { d.reshaped() };
135 std::sort(
r.begin(),
r.end() );
136 return r.size() % 2 == 0 ?
137 r.segment( (
r.size()-2)/2, 2 ).mean() :
141 template<
typename Derived>
142 typename Derived::Scalar
median(
const Eigen::DenseBase<Derived>& d ){
143 typename Derived::PlainObject m { d.replicate(1,1) };
147 template<
typename Derived,
typename T=Derived::Scalar>
149 Eigen::Array<T,-1,1> tmp(t.rows());
150 std::transform(t.rowwise().begin(), t.rowwise().end(),
152 [&](
const auto& i){return this->median(i);}
165 inline auto operator()(
const T& t) {
return t.rowwise().prod(); }
176 inline auto operator()(
const T& t) {
return t.rowwise().sum(); }
179 return (t.rowwise().count().cast <
float> ());
224 for (
int i = 0; i < t.rows(); ++i)
225 t.row(i).maxCoeff(&idx(i));
233 template<
typename T1,
typename T2>
234 inline auto operator()(
const T1& t1,
const T2& t2) {
return t1.pow(t2); }
248 inline auto operator()(
const T& t) {
return float(1.0) / (float(1.0) + (-t).exp()) ; }
367 inline auto operator()(
const T& t) {
return t.abs().sqrt(); }
380 template<
typename T1,
typename T2>
381 inline auto operator()(
const T1& t1,
const T2& t2) {
return t1.before(t2); }
387 template<
typename T1,
typename T2>
388 inline auto operator()(
const T1& t1,
const T2& t2) {
return t1.after(t2); }
394 template<
typename T1,
typename T2>
395 inline auto operator()(
const T1& t1,
const T2& t2) {
return t1.during(t2); }
401 template<
typename T1,
typename T2>
402 inline auto operator()(
const T1& t1,
const T2& t2,
const T2& t3) {
return t2; }
408 constexpr auto Stack = [](
auto m,
auto... ms) {
409 return ((Array<T,-1,-1>(m.rows(),1+
sizeof...(ms))<<m),...,ms).finished();
415 template <
typename T>
416 inline auto softmax(
const ArrayBase<T> &t)
const
418 auto tMinusMax = t.rowwise() - t.colwise().maxCoeff();
419 return tMinusMax.rowwise() - tMinusMax.exp().colwise().sum().log();
422 template <
typename T>
441 inline auto operator()(
const ArrayBase<T>& t1,
const ArrayBase<T>& t2) {
444 template<
typename T>
requires same_as<typename T::Scalar, bJet>
445 inline auto operator()(
const ArrayBase<T>& t1,
const ArrayBase<T>& t2) {
464 inline auto operator()(
const ArrayBase<T>& t1,
const ArrayBase<T>& t2) {
467 template<
typename T>
requires same_as<typename T::Scalar, bJet>
468 inline auto operator()(
const ArrayBase<T>& t1,
const ArrayBase<T>& t2) {
481 template<
typename T>
requires same_as<typename T::Scalar, bJet>
483 auto trues = ArrayXb::Constant(t.size(),
true);
Eigen::Array< bool, Eigen::Dynamic, 1 > ArrayXb
TimeSeries< float > TimeSeriesf
namespace containing various utility functions
vector< T > softmax(const vector< T > &w)
return the softmax transformation of a vector.
Scalar median(const T &v)
calculate median
< nsga2 selection operator for getting the front
constexpr auto Stack
Stacks Eigen arrays into a 2d-array, where each array is a column.
Eigen::Array< bool, Eigen::Dynamic, Eigen::Dynamic > ArrayXXb
Eigen::Array< int, Eigen::Dynamic, 1 > ArrayXi
Stores time series data and implements operators over it.
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T1 &t1, const T2 &t2)
auto operator()(const T1 &t1, const T2 &t2)
auto operator()(const ArrayBase< T > &t1, const ArrayBase< T > &t2)
auto operator()(const ArrayBase< T > &t1, const ArrayBase< T > &t2)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T1 &t1, const T2 &t2)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(ArrayXXb t)
auto operator()(const TimeSeries< T > &t)
auto operator()(const T1 &t1, const T2 &t2)
auto operator()(const T1 &t1, const T2 &t2)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T1 &t1, const T2 &t2, Tn... tn)
auto operator()(const T &t)
auto operator()(const TimeSeries< T > &t)
auto operator()(const T &t)
auto operator()(const TimeSeries< T > &t)
auto operator()(const T &t)
auto operator()(const TimeSeries< T > &t)
auto operator()(const T1 &t1, const T2 &t2, Tn... tn)
auto operator()(const T1 &t1, const T2 &t2)
auto operator()(const ArrayBase< T > &t)
auto operator()(const ArrayBase< T > &t)
auto operator()(const T &t)
auto operator()(const ArrayBase< T > &t1, const ArrayBase< T > &t2)
auto operator()(const ArrayBase< T > &t1, const ArrayBase< T > &t2)
auto operator()(const T1 &t1, const T2 &t2)
auto operator()(const TimeSeries< T > &t)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const ArrayBase< T > &t)
auto softmax(const ArrayBase< T > &t) const
auto operator()(const T1 &t1, const T2 &t2, const T2 &t3)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T1 &t1, const T2 &t2)
auto operator()(const TimeSeries< T > &t)
auto operator()(const T &t)
auto operator()(ArrayXXb t)
auto operator()(const T &t)
auto operator()(const T &t)
auto operator()(const T1 &t1, Tn... tn)