From Jason Turner

[linalg.helpers.mandates]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpxfeca5n6/{from.md → to.md} +55 -0
tmp/tmpxfeca5n6/{from.md → to.md} RENAMED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Mandates <a id="linalg.helpers.mandates">[[linalg.helpers.mandates]]</a>
2
+
3
+ [*Note 1*: These exposition-only helper functions use the less
4
+ constraining input concepts even for the output arguments, because the
5
+ additional constraint for assignability of elements is not necessary,
6
+ and they are sometimes used in a context where the third argument is an
7
+ input type too. — *end note*]
8
+
9
+ ``` cpp
10
+ template<class MDS1, class MDS2>
11
+ requires(is-mdspan<MDS1> && is-mdspan<MDS2>)
12
+ constexpr
13
+ bool compatible-static-extents(size_t r1, size_t r2) { // exposition only
14
+ return MDS1::static_extent(r1) == dynamic_extent ||
15
+ MDS2::static_extent(r2) == dynamic_extent ||
16
+ MDS1::static_extent(r1) == MDS2::static_extent(r2);
17
+ }
18
+
19
+ template<in-vector In1, in-vector In2, in-vector Out>
20
+ constexpr bool possibly-addable() { // exposition only
21
+ return compatible-static-extents<Out, In1>(0, 0) &&
22
+ compatible-static-extents<Out, In2>(0, 0) &&
23
+ compatible-static-extents<In1, In2>(0, 0);
24
+ }
25
+
26
+ template<in-matrix In1, in-matrix In2, in-matrix Out>
27
+ constexpr bool possibly-addable() { // exposition only
28
+ return compatible-static-extents<Out, In1>(0, 0) &&
29
+ compatible-static-extents<Out, In1>(1, 1) &&
30
+ compatible-static-extents<Out, In2>(0, 0) &&
31
+ compatible-static-extents<Out, In2>(1, 1) &&
32
+ compatible-static-extents<In1, In2>(0, 0) &&
33
+ compatible-static-extents<In1, In2>(1, 1);
34
+ }
35
+
36
+ template<in-matrix InMat, in-vector InVec, in-vector OutVec>
37
+ constexpr bool possibly-multipliable() { // exposition only
38
+ return compatible-static-extents<OutVec, InMat>(0, 0) &&
39
+ compatible-static-extents<InMat, InVec>(1, 0);
40
+ }
41
+
42
+ template<in-vector InVec, in-matrix InMat, in-vector OutVec>
43
+ constexpr bool possibly-multipliable() { // exposition only
44
+ return compatible-static-extents<OutVec, InMat>(0, 1) &&
45
+ compatible-static-extents<InMat, InVec>(0, 0);
46
+ }
47
+
48
+ template<in-matrix InMat1, in-matrix InMat2, in-matrix OutMat>
49
+ constexpr bool possibly-multipliable() { // exposition only
50
+ return compatible-static-extents<OutMat, InMat1>(0, 0) &&
51
+ compatible-static-extents<OutMat, InMat2>(1, 1) &&
52
+ compatible-static-extents<InMat1, InMat2>(1, 0);
53
+ }
54
+ ```
55
+