4 ms·
The julia DSL for this is closer to what you want: "M_ij = A_ik * B_kj" reads @einsum M[i,j] := A[i,k] * B[k,j] Or faster with @tensor from https://github
by mcabbott 8y ago
The julia DSL for this is closer to what you want: "M_ij = A_ik * B_kj" reads
@einsum M[i,j] := A[i,k] * B[k,j]
Or faster with @tensor from https://github.com/Jutho/TensorOperations.jl https://github.com/Jutho/TensorOperations.jl & the same notation. I'm not aware of any attempt to distinguish co-vectors; you can have g = Diagonal([-1,1,1,1]) and insert A[i,k]g[k,k′]B[k′,j] and this is handled efficiently.
- BlackFly 8y agoYeah, that's the stuff right there! Well to distinguish covectors you need to define something like a manifold or just any canonical mapping between the tangent and cotangent space and then when you define your first few tensors you define them in the scope of that mapping. There is some generalization to gauge fields where a bijective canonical mapping may not be possible in general, but I never studied that extensively.
- mcabbott 8y agoI guess lots of things distinguish rows & columns which, for complex numbers, you can think of as up & downstairs -- rows are conjugated. But otherwise everybody seems to live in flat space. If you had reason to do so, it would be easy to bolt something onto the front of @tensor etc. which understood say A^[i]_[j] * B^[j,k] . Something similar would not be so hard to do to np.einsum either, just messing with the string... it could take exactly your "email Latex notation". In fact I'm a bit surprised that I can't find someone who's done this, in a few minutes' googling. I did find that opt-einsum has a notation in which the indices at least follow the array: https://optimized-einsum.readthedocs.io/en/latest/input_format.html#interleaved-input https://optimized-einsum.readthedocs.io/en/latest/input_form...
- BlackFly 8y agoFlat space and cartesian coordinates with a couple of known exceptions is the norm (we do use some curvilinear coordinates where some differential geometry methods are not necessary but can be illuminating). You have honestly piqued my curiosity towards Julia. I will need to find an opportunity to dig in.