tesseract++ 0.0.1
N-dimensional tensor library for embedded systems
Loading...
Searching...
No Matches
basic_algebraic_traits.h
Go to the documentation of this file.
1#pragma once
2
3namespace algebra
4{
5 // ===============================
6 // Algebraic trait definition
7 // ===============================
8 template <typename T>
10 {
11 /* Linear structure: meaning (math): A type is a vector space over ℝ if it supports:
12 Addition: v + w
13 Subtraction: v - w
14 Zero element
15 Scalar multiplication: v * s, s * v
16 Distributivity & associativity
17 Examples:
18 ✔ Vector3
19 ✔ TensorND
20 ✔ Quaternion
21 ✔ so(3)
22 ❌ UnitQuaternion
23 ❌ RotationMatrix (SO(3))
24 If vector_space == true, you allow:
25 v1 + v2
26 v1 - v2
27 v * scalar
28 If false → these operations must not compile. Simply use: requires algebraic_traits<T>::vector_space
29 */
30 static constexpr bool vector_space = false;
31
32 // Closed associative multiplication
33 /* Meaning (math): An algebra is a vector space plus a multiplication: 𝐴 × 𝐴 → 𝐴
34 that is:
35 closed
36 associative (usually)
37 bilinear
38 Examples:
39 ✔ Quaternion (Hamilton product)
40 ✔ Matrix
41 ✔ DualQuaternion
42 ✔ Clifford algebra elements
43 ❌ Vector3
44 ❌ so(3)
45 ❌ UnitQuaternion
46 If algebra == true, you allow:
47 a * b // special multiplication (not element-wise)
48 This is where Hamilton product lives.
49 If false → operator* between two entities is illegal.
50 */
51
52 static constexpr bool algebra = false;
53
54 // Lie group structure (composition + inverse)
55 /* Meaning (math): A Lie group is:
56 A group (identity, inverse, closure)
57 Smooth (continuous)
58 NOT a vector space
59 Operations:
60 Composition
61 Inverse
62 Examples:
63 ✔ UnitQuaternion (SO(3))
64 ✔ SE(3)
65 ✔ DualQuaternion (rigid transforms)
66 ❌ Quaternion
67 ❌ TensorND
68 Lie groups:
69 do NOT support addition
70 do NOT support scalar multiplication
71 So this flag disables:
72 q + q
73 q * scalar
74 and enables:
75 q1 * q2 // composition
76 inv(q)
77 */
78 static constexpr bool lie_group = false;
79
80 // Dot / norm / distance
81 /* Meaning (math): A metric space has:
82 a dot product
83 a norm / length
84 distance
85 Examples:
86 ✔ Vector3
87 ✔ Quaternion
88 ✔ so(3)
89 ❌ TensorND (general tensors do not define dot)
90 ❌ UnitQuaternion (distance is on manifold, not linear)
91 If metric == true, you allow:
92 dot(a, b)
93 norm(a)
94 This is NOT an operator — it’s named functions.
95 */
96 static constexpr bool metric = false;
97
98 // Shape-based tensor semantics
99 /* Meaning (math / semantics): This does not mean “tensor algebra”.
100 It means: “This type’s semantics are governed by shape and rank, not algebraic laws.”
101 Examples:
102 ✔ TensorND
103 ✔ Matrix
104 ✔ Image / Volume data
105 ❌ Quaternion
106 ❌ Vector3
107 This flag controls:
108 dimension checks
109 broadcasting rules
110 index-based access
111 slicing semantics
112 It prevents accidental mixing like:
113 TensorND<3,3> + Quaternion // illegal
114 even though both are vector spaces.
115 */
116 static constexpr bool tensor = false;
117 };
118
119 // ===============================
120 // Convenience helpers
121 // ===============================
122 template <typename T>
124
125 template <typename T>
127
128 template <typename T>
130
131 template <typename T>
133
134 template <typename T>
136} // namespace algebra
Definition basic_algebraic_traits.h:4
constexpr bool is_vector_space_v
Definition basic_algebraic_traits.h:123
constexpr bool is_tensor_v
Definition basic_algebraic_traits.h:135
constexpr bool is_metric_v
Definition basic_algebraic_traits.h:132
constexpr bool is_lie_group_v
Definition basic_algebraic_traits.h:129
constexpr bool is_algebra_v
Definition basic_algebraic_traits.h:126
Definition basic_algebraic_traits.h:10
static constexpr bool lie_group
Definition basic_algebraic_traits.h:78
static constexpr bool vector_space
Definition basic_algebraic_traits.h:30
static constexpr bool tensor
Definition basic_algebraic_traits.h:116
static constexpr bool metric
Definition basic_algebraic_traits.h:96