Expression Templates Library (ETL)
outer.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 namespace etl::impl::standard {
16 
23 template <typename A, typename B, typename C>
24 void outer(const A& a, const B& b, C&& c) {
25  for (size_t i = 0; i < etl::dim<0>(c); ++i) {
26  for (size_t j = 0; j < etl::dim<1>(c); ++j) {
27  c(i, j) = a(i) * b(j);
28  }
29  }
30 }
31 
38 template <typename A, typename B, typename C>
39 void batch_outer(const A& lhs, const B& rhs, C&& c) {
40  c = 0;
41 
42  for (size_t b = 0; b < etl::dim<0>(lhs); ++b) {
43  for (size_t i = 0; i < etl::dim<0>(c); ++i) {
44  for (size_t j = 0; j < etl::dim<1>(c); ++j) {
45  c(i, j) += lhs(b, i) * rhs(b, j);
46  }
47  }
48  }
49 }
50 
51 } //end of namespace etl::impl::standard
batch_outer_product_expr< detail::build_type< A >, detail::build_type< B > > batch_outer(A &&a, B &&b)
Batch Outer product multiplication of two matrices.
Definition: batch_outer_product_expr.hpp:333
Definition: prob_pooling.hpp:10
outer_product_expr< detail::build_type< A >, detail::build_type< B > > outer(A &&a, B &&b)
Outer product multiplication of two matrices.
Definition: outer_product_expr.hpp:293