From Jason Turner

[linalg.helpers.precond]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpaunvmznk/{from.md → to.md} +37 -0
tmp/tmpaunvmznk/{from.md → to.md} RENAMED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Preconditions <a id="linalg.helpers.precond">[[linalg.helpers.precond]]</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
+ constexpr bool addable( // exposition only
11
+ const in-vector auto& in1, const in-vector auto& in2, const in-vector auto& out) {
12
+ return out.extent(0) == in1.extent(0) && out.extent(0) == in2.extent(0);
13
+ }
14
+
15
+ constexpr bool addable( // exposition only
16
+ const in-matrix auto& in1, const in-matrix auto& in2, const in-matrix auto& out) {
17
+ return out.extent(0) == in1.extent(0) && out.extent(1) == in1.extent(1) &&
18
+ out.extent(0) == in2.extent(0) && out.extent(1) == in2.extent(1);
19
+ }
20
+
21
+ constexpr bool multipliable( // exposition only
22
+ const in-matrix auto& in_mat, const in-vector auto& in_vec, const in-vector auto& out_vec) {
23
+ return out_vec.extent(0) == in_mat.extent(0) && in_mat.extent(1) == in_vec.extent(0);
24
+ }
25
+
26
+ constexpr bool multipliable( // exposition only
27
+ const in-vector auto& in_vec, const in-matrix auto& in_mat, const in-vector auto& out_vec) {
28
+ return out_vec.extent(0) == in_mat.extent(1) && in_mat.extent(0) == in_vec.extent(0);
29
+ }
30
+
31
+ constexpr bool multipliable( // exposition only
32
+ const in-matrix auto& in_mat1, const in-matrix auto& in_mat2, const in-matrix auto& out_mat) {
33
+ return out_mat.extent(0) == in_mat1.extent(0) && out_mat.extent(1) == in_mat2.extent(1) &&
34
+ in_mat1.extent(1) == in_mat2.extent(0);
35
+ }
36
+ ```
37
+