Tatooine
same_dimensions.h
Go to the documentation of this file.
1#ifndef TATOOINE_TENSOR_OPERATIONS_SAME_DIMENSIONS_H
2#define TATOOINE_TENSOR_OPERATIONS_SAME_DIMENSIONS_H
3//==============================================================================
6//==============================================================================
7namespace tatooine {
8//==============================================================================
9template <static_tensor A, static_tensor B>
10auto constexpr same_dimensions() {
11 if constexpr (tensor_rank<A> != tensor_rank<B>) {
12 return false;
13 } else {
14 for (std::size_t i = 0; i < tensor_rank<A>; ++i) {
15 if (tensor_dimensions<A>[i] != tensor_dimensions<B>[i]) {
16 return false;
17 }
18 }
19 return true;
20 }
21}
22//------------------------------------------------------------------------------
23auto constexpr same_dimensions(static_tensor auto const& A,
24 static_tensor auto const& B) {
25 if constexpr (A.rank() != B.rank()) {
26 return false;
27 } else {
28 for (std::size_t i = 0; i < A.rank(); ++i) {
29 if (A.dimension(i) != B.dimension(i)) {
30 return false;
31 }
32 }
33 return true;
34 }
35}
36//==============================================================================
37} // namespace tatooine
38//==============================================================================
39#endif
Definition: tensor_concepts.h:20
Definition: algorithm.h:6
auto constexpr same_dimensions()
Definition: same_dimensions.h:10