mp-units
mp-units copied to clipboard
Implement simple vector and tensor types
Added
Types
- cartesian_vector<T> — fixed 3D vector
- cartesian_tensor<T,R,C> — matrix/tensor with R,C ∈ [1..3]
Vector ops (a,b : cartesian_vector ; s : scalar)
- a + b — elementwise addition
- a - b — elementwise subtraction
- a % b — elementwise modulo (% for integral, fmod for floating)
- a * s, s * a — scalar multiply
- a / s — scalar divide
- a ⋅ b (scalar_product, alias dot) — dot product → scalar
- a × b (vector_product, alias cross) — cross product → vector
- |a| (magnitude, norm) — Euclidean length (floating reps only)
- a/|a| (unit) — unit vector (floating reps only)
Tensor ops (A,B : cartesian_tensor<R,C> ; M:N, matching dims; s: scalar)
- A + B, A - B — elementwise
- A % B — elementwise modulo (% / fmod as above)
- A * s, s * A, A / s — scalar scale
- A · x (matvec) — 3×3 tensor–vector product → vector
- A · B (matmul) — matrix multiply (R×K)*(K×C) → (R×C)
- A : B (double_contraction) — scalar (sum of elementwise products)
- a ⊗ b (outer_numeric) — vector outer product → 3×3 tensor
Hi! Thank you so much! I'll start reading and implementing changes - thank you and sorry in advance for any problems! :)
@mpusz could you help me fix the pipeline? I tried in some many ways and I have no idea how to fix it :c
I am currently on vacation in Hawaii, so I don't have much time to look into it. I will check it out when I am back.