mp-units icon indicating copy to clipboard operation
mp-units copied to clipboard

Implement simple vector and tensor types

Open Jullija opened this issue 2 months ago • 3 comments

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

Jullija avatar Oct 26 '25 14:10 Jullija

Hi! Thank you so much! I'll start reading and implementing changes - thank you and sorry in advance for any problems! :)

Jullija avatar Oct 26 '25 18:10 Jullija

@mpusz could you help me fix the pipeline? I tried in some many ways and I have no idea how to fix it :c

Jullija avatar Nov 11 '25 07:11 Jullija

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.

mpusz avatar Nov 12 '25 17:11 mpusz