4 ms·
> × (U+D7) for multiplication Blech; looks like a letter and normalizes cross products. Better to use "·" (U+B7)[0]: alpha = [ cψ·cϕ−cθ·sϕ·sψ, cψ·sϕ+cθ·cϕ·
by a1369209993 5y ago
> × (U+D7) for multiplication
Blech; looks like a letter and normalizes cross products. Better to use "·" (U+B7)[0]:
alpha = [ cψ·cϕ−cθ·sϕ·sψ, cψ·sϕ+cθ·cϕ·sψ, sψ·sθ;
−sψ·cϕ−cθ·sϕ·cψ, −sψ·sϕ+cθ·cϕ·cψ, cψ·sθ;
sθ·sϕ, −sθ·cϕ, cθ];
Minus sign is a nice-to-have, though.
0: Also "∧" (U+2227, wedge), the real other vector product[1], but that doesn't matter for scalar multiplication.
1: http://en.wikipedia.org/wiki/Wedge_product http://en.wikipedia.org/wiki/Wedge_product
- b2gills 5y agoIt would be easy to just make `·` an alias. Then that code would work. my &infix:< · > = &infix:< × >; (After all `×` itself is just an alias of `*` in the source for Rakudo.) If you need more control you can write it out sub infix:< · > (+@vals) is equiv(&[×]) # uses the same precedence level etc. is assoc<chaining> # may not be necessary given previous line { [×] @vals # reduction using infix operator } I made it chaining for the same reason `+` and `×` are chaining. --- I don't know enough about the topic to know how to properly write `∧`. It looks like it may be useful to write it using multis. # I don't know what precedence level it is supposed to be proto infix:< ∧ > (|) is tighter(&[×]) {*} multi infix:< ∧ > ( Numeric $l, Numeric $r, ) { $l × $r } multi infix:< ∧ > ( Vector $l, # need to define this somewhere, or use List/Array Vector $r, ) { … } If it was as simple as just a normal cross product, that would have been easy. [[1,2,3],[4,5,6]] »×« [[10,20,30],[40,50,60]] # [[10,40,90],[160,250,360]] # generate a synthetic `»×«` operator, and give it an alias my &infix:< ∧ > = &infix:< »×« >; [[1,2,3],[4,5,6]] ∧ [[10,20,30],[40,50,60]] # [[10,40,90],[160,250,360]] Of course, I'm fairly confident that is wrong.