funcy  1.6.1
concepts.h
1 #pragma once
2 
3 #include <concepts>
4 #include <type_traits>
5 
6 namespace funcy::linalg
7 {
8  namespace detail
9  {
17  template < class Matrix >
18  struct NumberOfRows : std::integral_constant< int, -1 >
19  {
20  };
21 
27  template < class Matrix >
28  struct NumberOfColumns : std::integral_constant< int, -1 >
29  {
30  };
31 
37  template < class >
38  struct GetTransposed;
40  } // namespace detail
41 
47  template < class V >
49 
53  template < class M >
56  ConstantSize< M > );
57 
59 
62  template < class T >
63  concept Matrix = (
64  requires( T t ) { { t[ 0 ][ 0 ] }; } ||
65  requires( T t ) { { t( 0, 0 ) }; } ) &&
66  (
67  requires( std::decay_t< T > t ) { { t *= 2.0 }; } ||
68  requires( std::decay_t< T > t ) { { t = 2.0 * t }; } ) &&
69  std::copy_constructible< T >;
70 
74  template < class T >
75  concept Vector = (
76  requires( T t ) { { t[ 0 ] }; } || requires( T t ) { { t( 0 ) }; } ) &&
77  (
78  requires( std::decay_t< T > t ) { { t *= 2.0 }; } ||
79  requires( std::decay_t< T > t ) { { t = 2.0 * t }; } ) &&
80  std::copy_constructible< T >;
82 
83 } // namespace funcy::linalg
concept Matrix
clang-format off
Definition: concepts.h:63
concept ConstantSize
Constant-size matrix concept.
Definition: concepts.h:48
Get number of rows for constant size matrices.
Definition: concepts.h:18
Functionality from linear algebra such as (modified) principal and mixed matrix invariants.
Get number of columns for constant size matrices.
Definition: concepts.h:28
concept Vector
Vector concept.
Definition: concepts.h:75
concept SquareMatrix
Constant-size square matrix concept.
Definition: concepts.h:54
Get transposed of constant-size matrix.
Definition: concepts.h:38