Expression Templates Library (ETL)
expression_builder.hpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c) 2014-2023 Baptiste Wicht
3 // Distributed under the terms of the MIT License.
4 // (See accompanying file LICENSE or copy at
5 // http://opensource.org/licenses/MIT)
6 //=======================================================================
7 
13 #pragma once
14 
15 //Include implementations
16 #include "etl/impl/dot.hpp"
17 #include "etl/impl/sum.hpp"
18 #include "etl/impl/norm.hpp"
19 
23 
24 namespace etl {
25 
26 // Apply an unary expression on an ETL expression (vector,matrix,binary,unary)
27 
33 template <typename E>
34 auto operator-(E&& value) {
35  return detail::unary_helper<E, minus_unary_op>{std::forward<E>(value)};
36 }
37 
43 template <typename E>
44 auto operator+(E&& value) {
45  return detail::unary_helper<E, plus_unary_op>{std::forward<E>(value)};
46 }
47 
53 template <etl_expr E>
54 auto abs(E&& value) {
55  return detail::unary_helper<E, abs_unary_op>{std::forward<E>(value)};
56 }
57 
64 template <etl_expr L, typename R>
65 auto max(L&& lhs, R&& rhs) {
67  return return_type{detail::wrap_scalar(lhs), detail::smart_wrap_scalar<L>(rhs)};
68 }
69 
76 template <etl_expr L, typename R>
77 auto min(L&& lhs, R&& rhs) {
79  return return_type{detail::wrap_scalar(lhs), detail::smart_wrap_scalar<L>(rhs)};
80 }
81 
87 template <etl_expr E>
88 auto floor(E&& value) {
89  return detail::unary_helper<E, floor_unary_op>{std::forward<E>(value)};
90 }
91 
97 template <etl_expr E>
98 auto ceil(E&& value) {
99  return detail::unary_helper<E, ceil_unary_op>{std::forward<E>(value)};
100 }
101 
109 template <etl_expr E, arithmetic T>
110 auto clip(E&& value, T min, T max) {
111  return detail::make_stateful_unary_expr<E, clip_scalar_op<value_t<E>, value_t<E>>>(std::forward<E>(value), value_t<E>(min), value_t<E>(max));
112 }
113 
126 template <etl_expr E, arithmetic T>
127 auto pow(E&& value, T v) {
129 }
130 
137 template <etl_expr E>
138 auto pow_int(E&& value, size_t v) {
140 }
141 
154 template <etl_expr E, arithmetic T>
155 auto pow_precise(E&& value, T v) {
157 }
158 
165 template <etl_expr E, arithmetic T>
166 auto one_if(E&& value, T v) {
168 }
169 
175 template <etl_expr E>
176 auto one_if_max(E&& value) {
178 }
179 
185 template <etl_complex_expr E>
186 auto real(E&& value) {
188 }
189 
195 template <etl_complex_expr E>
196 auto imag(E&& value) {
198 }
199 
205 template <etl_complex_expr E>
206 auto conj(E&& value) {
207  return unary_expr<value_t<E>, detail::build_type<E>, conj_unary_op<value_t<E>>>{std::forward<E>(value)};
208 }
209 
215 template <etl_expr E>
216 auto uniform_noise(E&& value) {
217  return detail::unary_helper<E, uniform_noise_unary_op>{std::forward<E>(value)};
218 }
219 
225 template <etl_expr E, typename G>
226 auto uniform_noise(G& g, E&& value) {
227  return detail::make_stateful_unary_expr<E, uniform_noise_unary_g_op<G, value_t<E>>>(std::forward<E>(value), g);
228 }
229 
235 template <etl_expr E>
236 auto normal_noise(E&& value) {
237  return detail::unary_helper<E, normal_noise_unary_op>{std::forward<E>(value)};
238 }
239 
245 template <etl_expr E, typename G>
246 auto normal_noise(G& g, E&& value) {
247  return detail::make_stateful_unary_expr<E, normal_noise_unary_g_op<G, value_t<E>>>(std::forward<E>(value), g);
248 }
249 
255 template <etl_expr E>
256 auto logistic_noise(E&& value) {
257  return detail::unary_helper<E, logistic_noise_unary_op>{std::forward<E>(value)};
258 }
259 
265 template <etl_expr E, typename G>
266 auto logistic_noise(G& g, E&& value) {
267  return detail::make_stateful_unary_expr<E, logistic_noise_unary_g_op<G, value_t<E>>>(std::forward<E>(value), g);
268 }
269 
275 template <etl_expr E>
276 auto state_logistic_noise(E&& value) {
277  return detail::make_stateful_unary_expr<E, state_logistic_noise_unary_op<value_t<E>>>(std::forward<E>(value));
278 }
279 
285 template <etl_expr E>
286 auto state_logistic_noise(E&& value, const std::shared_ptr<void*> & states) {
287  return detail::make_stateful_unary_expr<E, state_logistic_noise_unary_op<value_t<E>>>(std::forward<E>(value), states);
288 }
289 
295 template <typename G, etl_expr E>
296 auto state_logistic_noise(G& g, E&& value) {
297  return detail::make_stateful_unary_expr<E, state_logistic_noise_unary_g_op<G, value_t<E>>>(std::forward<E>(value), g);
298 }
299 
305 template <etl_expr E, typename G>
306 auto state_logistic_noise(G& g, E&& value, const std::shared_ptr<void*> & states) {
307  return detail::make_stateful_unary_expr<E, state_logistic_noise_unary_g_op<G, value_t<E>>>(std::forward<E>(value), g, states);
308 }
309 
317 template <etl_expr E, arithmetic T>
318 auto ranged_noise(E&& value, T v) {
320 }
321 
322 // Apply a stable transformation
323 
331 template <size_t D1, size_t... D, etl_expr E>
332 auto rep(E&& value) {
333  return unary_expr<value_t<E>, rep_r_transformer<detail::build_type<E>, D1, D...>, transform_op>{rep_r_transformer<detail::build_type<E>, D1, D...>(std::forward<E>(value))};
334 }
335 
343 template <size_t D1, size_t... D, etl_expr E>
344 auto rep_r(E&& value) {
345  return unary_expr<value_t<E>, rep_r_transformer<detail::build_type<E>, D1, D...>, transform_op>{rep_r_transformer<detail::build_type<E>, D1, D...>(std::forward<E>(value))};
346 }
347 
355 template <size_t D1, size_t... D, etl_expr E>
356 auto rep_l(E&& value) {
357  return unary_expr<value_t<E>, rep_l_transformer<detail::build_type<E>, D1, D...>, transform_op>{rep_l_transformer<detail::build_type<E>, D1, D...>(std::forward<E>(value))};
358 }
359 
367 template <typename... D, etl_expr E>
368 auto rep(E&& value, size_t d1, D... d) {
370  dyn_rep_r_transformer<detail::build_type<E>, 1 + sizeof...(D)>(std::forward<E>(value), {{d1, static_cast<size_t>(d)...}})};
371 }
372 
380 template <typename... D, etl_expr E>
381 auto rep_r(E&& value, size_t d1, D... d) {
383  dyn_rep_r_transformer<detail::build_type<E>, 1 + sizeof...(D)>(std::forward<E>(value), {{d1, static_cast<size_t>(d)...}})};
384 }
385 
393 template <typename... D, etl_expr E>
394 auto rep_l(E&& value, size_t d1, D... d) {
396  dyn_rep_l_transformer<detail::build_type<E>, 1 + sizeof...(D)>(std::forward<E>(value), {{d1, static_cast<size_t>(d)...}})};
397 }
398 
407 template <etl_expr E>
408 auto argmax(E&& value) {
409  if constexpr (decay_traits<E>::dimensions() > 1) {
410  return detail::make_transform_expr<E, argmax_transformer>(std::forward<E>(value));
411  } else {
412  return max_index(std::forward<E>(value));
413  }
414 }
415 
424 template <etl_expr E>
425 auto argmin(E&& value) {
426  if constexpr (decay_traits<E>::dimensions() > 1) {
427  return detail::make_transform_expr<E, argmin_transformer>(std::forward<E>(value));
428  } else {
429  return min_index(std::forward<E>(value));
430  }
431 }
432 
440 template <matrix E>
441 auto sum_r(E&& value) {
442  return detail::make_transform_expr<E, sum_r_transformer>(std::forward<E>(value));
443 }
444 
451 template <matrix E>
452 auto sum_l(E&& value) {
453  return detail::make_transform_expr<E, sum_l_transformer>(std::forward<E>(value));
454 }
455 
462 template <matrix E>
463 auto mean_r(E&& value) {
464  return detail::make_transform_expr<E, mean_r_transformer>(std::forward<E>(value));
465 }
466 
473 template <matrix E>
474 auto mean_l(E&& value) {
475  return detail::make_transform_expr<E, mean_l_transformer>(std::forward<E>(value));
476 }
477 
487 template <etl_2d E>
488 auto one_if_max_sub(const E& value) {
489  return detail::make_transform_expr<E, one_if_max_sub_transformer>(value);
490 }
491 
497 template <mat_or_vec E>
498 auto hflip(const E& value) {
499  return detail::make_transform_expr<E, hflip_transformer>(value);
500 }
501 
507 template <mat_or_vec E>
508 auto vflip(const E& value) {
509  return detail::make_transform_expr<E, vflip_transformer>(value);
510 }
511 
517 template <mat_or_vec E>
518 auto fflip(const E& value) {
519  return detail::make_transform_expr<E, fflip_transformer>(value);
520 }
521 
527 template <mat_or_vec E>
528 auto transpose(const E& value) {
530 }
531 
537 template <etl_expr E>
538 auto trans(const E& value) {
539  return transpose(value);
540 }
541 
547 template <etl_expr E>
548 auto conj_transpose(const E& value) {
549  return conj(transpose(value));
550 }
551 
557 template <etl_expr E>
558 auto ctrans(const E& value) {
559  return conj(transpose(value));
560 }
561 
567 template <deep_mat E>
568 auto transpose_front(const E& value) {
570 }
571 
577 template <typename A>
578 value_t<A> norm(const A& a) {
579  return detail::norm_impl::apply(a);
580 }
581 
582 // TODO: Ideally we would like to be able to use a.dot(b) and
583 // a.cross(b). Unfortunately, this would require one of these options:
584 // * A new CRTP class, increasing the compilation time overhead
585 // * Adding the dot template function in each expression
586 
593 template <typename A, typename B>
594 value_t<A> dot(const A& a, const B& b) {
595  validate_expression(a, b);
596  return detail::dot_impl::apply(a, b);
597 }
598 
605 template <etl_1d A, etl_1d B>
606 etl::fast_vector<value_t<A>, 3> cross(const A& a, const B& b) {
607  if constexpr (all_fast<A, B>) {
608  static_assert(etl::decay_traits<A>::size() == 3, "Cross product is only valid for 1D vectors of size 3");
609  static_assert(etl::decay_traits<B>::size() == 3, "Cross product is only valid for 1D vectors of size 3");
610  } else {
611  cpp_assert(etl::decay_traits<A>::size(a) == 3, "Cross product is only valid for 1D vectors of size 3");
612  cpp_assert(etl::decay_traits<B>::size(b) == 3, "Cross product is only valid for 1D vectors of size 3");
613  }
614 
615  return {a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]};
616 }
617 
623 template <etl_expr E>
625  //Reduction force evaluation
626  force(values);
627 
629 }
630 
636 template <etl_expr E>
638  //Reduction force evaluation
639  force(values);
640 
642 }
643 
649 template <etl_expr E>
651  return sum(values) / static_cast<value_t<E>>(etl::size(values));
652 }
653 
659 template <etl_expr E>
661  return asum(values) / static_cast<value_t<E>>(etl::size(values));
662 }
663 
669 template <etl_expr E>
671  auto mean = etl::mean(values);
672 
673  double std = 0.0;
674  for (auto value : values) {
675  std += (value - mean) * (value - mean);
676  }
677 
678  return static_cast<value_t<E>>(std::sqrt(std / static_cast<double>(etl::size(values))));
679 }
680 
689 template <etl_expr E>
691  double std = 0.0;
692  for (auto value : values) {
693  std += (value - mean) * (value - mean);
694  }
695 
696  return static_cast<value_t<E>>(std::sqrt(std / static_cast<double>(etl::size(values))));
697 }
698 
699 namespace detail {
700 
704 template <typename E>
705 using value_return_t =
706  std::conditional_t<decay_traits<E>::is_value,
707  std::conditional_t<std::is_lvalue_reference_v<E>,
708  std::conditional_t<std::is_const_v<std::remove_reference_t<E>>, const value_t<E>&, value_t<E>&>,
709  value_t<E>>,
710  value_t<E>>;
711 
712 } //end of namespace detail
713 
719 template <etl_expr E>
720 size_t max_index(E&& values) {
721  //Reduction force evaluation
722  force(values);
723 
724  size_t m = 0;
725 
726  for (size_t i = 1; i < etl::size(values); ++i) {
727  if (values[i] > values[m]) {
728  m = i;
729  }
730  }
731 
732  return m;
733 }
734 
741 template <etl_expr E>
743  auto m = max_index(values);
744  return values[m];
745 }
746 
752 template <etl_expr E>
753 size_t min_index(E&& values) {
754  //Reduction force evaluation
755  force(values);
756 
757  size_t m = 0;
758 
759  for (size_t i = 1; i < etl::size(values); ++i) {
760  if (values[i] < values[m]) {
761  m = i;
762  }
763  }
764 
765  return m;
766 }
767 
774 template <etl_expr E>
776  auto m = min_index(values);
777  return values[m];
778 }
779 
780 // Generate data
781 
788 template <typename T = double>
789 auto normal_generator(T mean = 0.0, T stddev = 1.0) {
791 }
792 
803 template <typename T = double, typename G>
804 auto normal_generator(G& g, T mean = 0.0, T stddev = 1.0) {
806 }
807 
814 template <typename T = double>
815 auto truncated_normal_generator(T mean = 0.0, T stddev = 1.0) {
817 }
818 
829 template <typename T = double, typename G>
830 auto truncated_normal_generator(G& g, T mean = 0.0, T stddev = 1.0) {
832 }
833 
840 template <typename T = double>
841 auto uniform_generator(T start, T end) {
842  return generator_expr<uniform_generator_op<T>>{start, end};
843 }
844 
855 template <typename T = double, typename G>
856 auto uniform_generator(G& g, T start, T end) {
857  return generator_expr<uniform_generator_g_op<G, T>>{g, start, end};
858 }
859 
865 template <typename T = double>
866 auto sequence_generator(T current = 0) {
868 }
869 
877 template <typename T = float>
878 auto dropout_mask(T probability) {
879  return generator_expr<dropout_mask_generator_op<T>>{probability};
880 }
881 
891 template <typename T = float, typename G>
892 auto dropout_mask(G& g, T probability) {
893  return generator_expr<dropout_mask_generator_g_op<G, T>>{g, probability};
894 }
895 
903 template <typename T = float>
904 auto state_dropout_mask(T probability) {
906 }
907 
917 template <typename T = float, typename G>
918 auto state_dropout_mask(G& g, T probability) {
920 }
921 
929 template <typename T = float>
930 auto inverted_dropout_mask(T probability) {
932 }
933 
943 template <typename T = float, typename G>
944 auto state_inverted_dropout_mask(G& g, T probability) {
946 }
947 
955 template <typename T = float>
956 auto state_inverted_dropout_mask(T probability) {
958 }
959 
969 template <typename T = float, typename G>
970 auto inverted_dropout_mask(G& g, T probability) {
972 }
973 
981 template <etl_expr Expr>
982 decltype(auto) operator*(Expr&& expr) {
983  force(expr);
984  return std::forward<Expr>(expr);
985 }
986 
987 } //end of namespace etl
988 
auto pow(E &&value, T v)
Apply pow(x, v) on each element x of the ETL expression.
Definition: expression_builder.hpp:127
value_t< E > mean(E &&values)
Returns the mean of all the values contained in the given expression.
Definition: expression_builder.hpp:650
auto sum_l(E &&value)
Aggregate (sum) a dimension from the left. This effectively removes the first dimension from the expr...
Definition: expression_builder.hpp:452
auto truncated_normal_generator(T mean=0.0, T stddev=1.0)
Create an expression generating numbers from a truncated normal distribution.
Definition: expression_builder.hpp:815
Unary operation extracting the real part of a complex number.
Definition: real.hpp:19
auto rep_l(E &&value)
Repeats the expression to the left (adds dimension before existing)
Definition: expression_builder.hpp:356
static value_t< E > apply(const E &e)
Apply the functor to e.
Definition: sum.hpp:167
auto max(L &&lhs, R &&rhs)
Create an expression with the max value of lhs or rhs.
Definition: expression_builder.hpp:65
Binary operator to get 1.0 if x equals to rhs value, 0 otherwise.
Definition: one_if.hpp:16
value_t< A > dot(const A &a, const B &b)
Returns the dot product of the two given expressions.
Definition: expression_builder.hpp:594
auto rep_r(E &&value)
Repeats the expression to the right (adds dimension after existing)
Definition: expression_builder.hpp:344
typename wrap_scalar_value_t_impl< T >::type wrap_scalar_value_t
Extract the value type of the given type taking scalar into account.
Definition: expression_helpers.hpp:83
auto one_if(E &&value, T v)
Creates an expression with values of 1 where the ETL expression has a value of v. ...
Definition: expression_builder.hpp:166
auto normal_noise(E &&value)
Add some normal noise (0, 1.0) to the given expression.
Definition: expression_builder.hpp:236
auto mean_r(E &&value)
Aggregate (average) a dimension from the right. This effectively removes the last dimension from the ...
Definition: expression_builder.hpp:463
std::conditional_t< decay_traits< E >::is_value, std::conditional_t< std::is_lvalue_reference_v< E >, std::conditional_t< std::is_const_v< std::remove_reference_t< E > >, const value_t< E > &, value_t< E > & >, value_t< E > >, value_t< E > > value_return_t
Helper to compute the return type for max/min operation.
Definition: expression_builder.hpp:710
values_t< V... > values(V... v)
Create a list of values for initializing a dyn_matrix.
Definition: dyn_base.hpp:67
auto sqrt(E &&value) -> detail::unary_helper< E, sqrt_unary_op >
Apply square root on each value of the given expression.
Definition: function_expression_builder.hpp:24
auto state_dropout_mask(T probability)
Create an expression generating numbers for a dropout mask.
Definition: expression_builder.hpp:904
auto inverted_dropout_mask(T probability)
Create an expression generating numbers for an inverted dropout mask.
Definition: expression_builder.hpp:930
Contains all the operators and functions to build expressions for views.
Binary operator for scalar power.
Definition: pow.hpp:19
D D
The number of dimensions.
Definition: dyn_matrix_view.hpp:24
auto normal_generator(T mean=0.0, T stddev=1.0)
Create an expression generating numbers from a normal distribution.
Definition: expression_builder.hpp:789
auto rep(E &&value)
Repeats the expression to the right (adds dimension after existing)
Definition: expression_builder.hpp:332
Simple unary op for transform operations.
Definition: unary_expr.hpp:56
Binary operator for ranged noise generation.
Definition: ranged_noise.hpp:90
auto ceil(E &&value)
Round up each values of the ETL expression.
Definition: expression_builder.hpp:98
etl::fast_vector< value_t< A >, 3 > cross(const A &a, const B &b)
Returns the dot product of the two given expressions.
Definition: expression_builder.hpp:606
auto logistic_noise(E &&value)
Add some normal noise (0, sigmoid(x)) to the given expression.
Definition: expression_builder.hpp:256
void force(Expr &&expr)
Force the internal evaluation of an expression.
Definition: evaluator.hpp:1292
auto sum_r(E &&value)
Aggregate (sum) a dimension from the right. This effectively removes the last dimension from the expr...
Definition: expression_builder.hpp:441
Contains all the operators and functions to build expressions for wrapping expressions.
auto dropout_mask(T probability)
Create an expression generating numbers for a dropout mask.
Definition: expression_builder.hpp:878
auto conj(E &&value)
Apply the conjugate operation on each complex value of the given expression.
Definition: expression_builder.hpp:206
static value_t< E > apply(const E &e)
Apply the functor to e.
Definition: sum.hpp:129
auto abs(E &&value)
Apply absolute on each value of the given expression.
Definition: expression_builder.hpp:54
auto hflip(const E &value)
Returns the horizontal flipping of the given expression.
Definition: expression_builder.hpp:498
auto one_if_max_sub(const E &value)
Return, for each original position, 1.0 if the value is the max of the sub matrix, 0.0 otherwise.
Definition: expression_builder.hpp:488
Transform (dynamic) that repeats the expression to the right.
Definition: rep_transformers.hpp:235
An unary expression.
Definition: unary_expr.hpp:126
auto transpose(const E &value)
Returns the transpose of the given expression.
Definition: expression_builder.hpp:528
auto uniform_generator(T start, T end)
Create an expression generating numbers from an uniform distribution.
Definition: expression_builder.hpp:841
Transform that repeats the expression to the right.
Definition: rep_transformers.hpp:99
A binary expression.
Definition: binary_expr.hpp:18
Binary operator for scalar power with an integer as the exponent.
Definition: pow.hpp:192
Traits to get information about ETL types.
Definition: tmp.hpp:68
Root namespace for the ETL library.
Definition: adapter.hpp:15
auto state_inverted_dropout_mask(G &g, T probability)
Create an expression generating numbers for an inverted dropout mask using the given custom random en...
Definition: expression_builder.hpp:944
size_t max_index(E &&values)
Returns the index of the maximum element contained in the expression.
Definition: expression_builder.hpp:720
auto operator+(LE &&lhs, RE &&rhs)
Builds an expression representing the addition of lhs and rhs.
Definition: binary_expression_builder.hpp:38
static value_t< A > apply(const A &a)
Apply the functor to a.
Definition: norm.hpp:30
auto argmin(E &&value)
Returns the indices of the minimum values in the first axis of the given matrix. If passed a vector...
Definition: expression_builder.hpp:425
value_t< E > stddev(E &&values)
Returns the standard deviation of all the values contained in the given expression.
Definition: expression_builder.hpp:670
Unary operation extracting the imag part of a complex number.
Definition: imag.hpp:19
std::conditional_t< is_etl_value< T >, const std::decay_t< T > &, std::decay_t< T > > build_type
Helper to build the type for a sub expression.
Definition: expression_helpers.hpp:24
static value_t< A > apply(const A &a, const B &b)
Apply the functor to a and b.
Definition: dot.hpp:121
auto real(E &&value)
Extract the real part of each complex value of the given expression.
Definition: expression_builder.hpp:186
auto ctrans(const E &value)
Returns the conjugate transpose of the given expression.
Definition: expression_builder.hpp:558
auto pow_int(E &&value, size_t v)
Apply pow(x, v) on each element x of the ETL expression.
Definition: expression_builder.hpp:138
auto transpose_front(const E &value)
Returns the transpose of the given expression.
Definition: expression_builder.hpp:568
Binary operator for scalar power with stable precision.
Definition: pow.hpp:142
Unary operation computing the conjugate value of complex number.
Definition: conj.hpp:19
value_t< E > asum(E &&values)
Returns the sum of all the absolute values contained in the given expression.
Definition: expression_builder.hpp:637
auto uniform_noise(E &&value)
Add some uniform noise (0, 1.0) to the given expression.
Definition: expression_builder.hpp:216
auto state_logistic_noise(E &&value)
Add some normal noise (0, sigmoid(x)) to the given expression.
Definition: expression_builder.hpp:276
Matrix with compile-time fixed dimensions.
Definition: fast.hpp:26
auto min(L &&lhs, R &&rhs)
Create an expression with the min value of lhs or rhs.
Definition: expression_builder.hpp:77
auto conj_transpose(const E &value)
Returns the conjugate transpose of the given expression.
Definition: expression_builder.hpp:548
value_t< E > sum(E &&values)
Returns the sum of all the values contained in the given expression.
Definition: expression_builder.hpp:624
A transposition expression for the first layers.
Definition: transpose_front_expr.hpp:22
Transform that repeats the expression to the left.
Definition: rep_transformers.hpp:167
Represents a scalar value.
Definition: concepts_base.hpp:19
auto pow_precise(E &&value, T v)
Apply pow(x, v) on each element x of the ETL expression.
Definition: expression_builder.hpp:155
constexpr size_t size(const E &expr) noexcept
Returns the size of the given ETL expression.
Definition: helpers.hpp:108
auto argmax(E &&value)
Returns the indices of the maximum values in the first axis of the given matrix. If passed a vector...
Definition: expression_builder.hpp:408
Selector for the "sum" reduction implementations.
A transposition expression.
Definition: transpose_expr.hpp:22
Contains all the operators and functions to build binary expressions.
auto one_if_max(E &&value)
Creates an expression with a value of 1 where the max value is and all zeroes other places...
Definition: expression_builder.hpp:176
auto sequence_generator(T current=0)
Create an expression generating numbers from a consecutive sequence.
Definition: expression_builder.hpp:866
auto fflip(const E &value)
Returns the horizontal and vertical flipping of the given expression.
Definition: expression_builder.hpp:518
auto imag(E &&value)
Extract the imag part of each complex value of the given expression.
Definition: expression_builder.hpp:196
auto floor(E &&value)
Round down each values of the ETL expression.
Definition: expression_builder.hpp:88
size_t min_index(E &&values)
Returns the index of the minimum element contained in the expression.
Definition: expression_builder.hpp:753
auto mean_l(E &&value)
Aggregate (average) a dimension from the left. This effectively removes the first dimension from the ...
Definition: expression_builder.hpp:474
typename decay_traits< E >::value_type value_t
Traits to extract the value type out of an ETL type.
Definition: tmp.hpp:81
auto operator-(LE &&lhs, RE &&rhs)
Builds an expression representing the subtraction of lhs and rhs.
Definition: binary_expression_builder.hpp:25
auto vflip(const E &value)
Returns the vertical flipping of the given expression.
Definition: expression_builder.hpp:508
auto trans(const E &value)
Returns the transpose of the given expression.
Definition: expression_builder.hpp:538
Contains all the operators and functions to build expressions representing mathematical functions...
auto ranged_noise(E &&value, T v)
Add some normal noise N(0,1) to x. No noise is added to values equal to zero or to given the value...
Definition: expression_builder.hpp:318
value_t< E > amean(E &&values)
Returns the mean of all the absolute values contained in the given expression.
Definition: expression_builder.hpp:660
auto clip(E &&value, T min, T max)
Clip each values of the ETL expression between min and max.
Definition: expression_builder.hpp:110
A generator expression.
Definition: generator_expr.hpp:27
return_helper< sub_type, decltype(std::declval< sub_type >()[0])> return_type
The type returned by the view.
Definition: dyn_matrix_view.hpp:34
Transform (dynamic) that repeats the expression to the left.
Definition: rep_transformers.hpp:299
value_t< A > norm(const A &a)
Returns euclidean norm of the given expression.
Definition: expression_builder.hpp:578