Registered Member
|
Hello,
I'd like to create some classes to deal with Lorentz vectors (the "natural" language for special relativity). They're basically vectors on R⁴, with a so-called minkowskian metric η = diag(1, -1, -1, -1). One can "transpose" a vector using the metric, vᵗ = ηv. Then, the "square" of a vector is defined as v² = vᵗv = vηv (1). Component-wise, the square looks like (a b c d)² = a² - b² - c² - d² (2). I wonder how to compute transposed vectors (and square) efficiently (using Eigen of course). I can find two easy ways: computing the product as in (1) or using the components directly as in (2). Thanks Louis |
Moderator
|
There is currently no easy way to avoid the product by 1,-1,-1,-1, and both (1) and (2) will produce the exact same assembly, as verified using the following code:
sqNorm_v* produces: (using clang+AVX2)
In theory, the following should be more efficient:
but the compiler seems to fail to implement w.x() = -w.x(); as a simple vxorpd without register spilling. |
Registered Member
|
Thank you ggael, playing with Eigen is gonna be fun.
|
Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot]