16 #include "etl/impl/dot.hpp" 18 #include "etl/impl/norm.hpp" 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)};
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)};
109 template <etl_expr E, arithmetic T>
126 template <etl_expr E, arithmetic T>
127 auto pow(E&& value, T v) {
137 template <etl_expr E>
154 template <etl_expr E, arithmetic T>
165 template <etl_expr E, arithmetic T>
175 template <etl_expr E>
185 template <etl_complex_expr E>
195 template <etl_complex_expr E>
205 template <etl_complex_expr E>
215 template <etl_expr E>
225 template <etl_expr E,
typename G>
227 return detail::make_stateful_unary_expr<E, uniform_noise_unary_g_op<G, value_t<E>>>(std::forward<E>(value), g);
235 template <etl_expr E>
245 template <etl_expr E,
typename G>
247 return detail::make_stateful_unary_expr<E, normal_noise_unary_g_op<G, value_t<E>>>(std::forward<E>(value), g);
255 template <etl_expr E>
265 template <etl_expr E,
typename G>
267 return detail::make_stateful_unary_expr<E, logistic_noise_unary_g_op<G, value_t<E>>>(std::forward<E>(value), g);
275 template <etl_expr E>
277 return detail::make_stateful_unary_expr<E, state_logistic_noise_unary_op<value_t<E>>>(std::forward<E>(value));
285 template <etl_expr E>
287 return detail::make_stateful_unary_expr<E, state_logistic_noise_unary_op<value_t<E>>>(std::forward<E>(value), states);
295 template <
typename G, etl_expr E>
297 return detail::make_stateful_unary_expr<E, state_logistic_noise_unary_g_op<G, value_t<E>>>(std::forward<E>(value), g);
305 template <etl_expr E,
typename G>
307 return detail::make_stateful_unary_expr<E, state_logistic_noise_unary_g_op<G, value_t<E>>>(std::forward<E>(value), g, states);
317 template <etl_expr E, arithmetic T>
331 template <
size_t D1,
size_t...
D, etl_expr E>
343 template <
size_t D1,
size_t...
D, etl_expr E>
355 template <
size_t D1,
size_t...
D, etl_expr E>
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)...}})};
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)...}})};
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)...}})};
407 template <etl_expr E>
410 return detail::make_transform_expr<E, argmax_transformer>(std::forward<E>(value));
412 return max_index(std::forward<E>(value));
424 template <etl_expr E>
427 return detail::make_transform_expr<E, argmin_transformer>(std::forward<E>(value));
429 return min_index(std::forward<E>(value));
442 return detail::make_transform_expr<E, sum_r_transformer>(std::forward<E>(value));
453 return detail::make_transform_expr<E, sum_l_transformer>(std::forward<E>(value));
464 return detail::make_transform_expr<E, mean_r_transformer>(std::forward<E>(value));
475 return detail::make_transform_expr<E, mean_l_transformer>(std::forward<E>(value));
489 return detail::make_transform_expr<E, one_if_max_sub_transformer>(value);
497 template <mat_or_vec E>
499 return detail::make_transform_expr<E, hflip_transformer>(value);
507 template <mat_or_vec E>
509 return detail::make_transform_expr<E, vflip_transformer>(value);
517 template <mat_or_vec E>
519 return detail::make_transform_expr<E, fflip_transformer>(value);
527 template <mat_or_vec E>
537 template <etl_expr E>
547 template <etl_expr E>
557 template <etl_expr E>
567 template <deep_mat E>
577 template <
typename A>
593 template <
typename A,
typename B>
595 validate_expression(a, b);
605 template <etl_1d A, etl_1d B>
607 if constexpr (all_fast<A, B>) {
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]};
623 template <etl_expr E>
636 template <etl_expr E>
649 template <etl_expr E>
659 template <etl_expr E>
669 template <etl_expr E>
674 for (
auto value :
values) {
675 std += (value -
mean) * (value -
mean);
689 template <etl_expr E>
692 for (
auto value :
values) {
693 std += (value -
mean) * (value - mean);
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>&>,
719 template <etl_expr E>
741 template <etl_expr E>
752 template <etl_expr E>
774 template <etl_expr E>
788 template <
typename T =
double>
803 template <
typename T =
double,
typename G>
814 template <
typename T =
double>
829 template <
typename T =
double,
typename G>
840 template <
typename T =
double>
855 template <
typename T =
double,
typename G>
865 template <
typename T =
double>
877 template <
typename T =
float>
891 template <
typename T =
float,
typename G>
903 template <
typename T =
float>
917 template <
typename T =
float,
typename G>
929 template <
typename T =
float>
943 template <
typename T =
float,
typename G>
955 template <
typename T =
float>
969 template <
typename T =
float,
typename G>
981 template <etl_expr Expr>
982 decltype(
auto) operator*(Expr&& expr) {
984 return std::forward<Expr>(expr);
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
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
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
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
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
value_t< A > norm(const A &a)
Returns euclidean norm of the given expression.
Definition: expression_builder.hpp:578