Open nilsvu opened 2 years ago
@macedo22 @nilsdeppe any thoughts on this?
@nilsleiffischer My first thought is that this sounds like a really nice use case, but I'm not sure if it's too soon to add this. I've been doing some benchmarking of different tensor equations written with TensorExpression
s vs for loops lately, and for many equations, TEs are faster, but I've been seeing TEs run slower than loops for inner products when > 1 index is being summed over, and it gets worse with more indices to sum over. So, I would expect expressions like the ones you've shown where 2 or more indices are being summed over to be slower than with loops. Given that I imagine these functions are used in multiple places, I'm not sure it's wise to release TE inner products into the wild just yet. I can benchmark specific coordinate transformation cases like these, if that's something you and/or @nilsdeppe think is worth me doing. I just generated a bunch of benchmark cases involving inner products, and I plan to profile them with perf
starting this week in order to try to understand why some of these inner products are slower with TEs.
@nilsdeppe What are your thoughts?
I think it's easier to just use TEs directly. Otherwise you have to make various assumptions about what people will want, etc. and that will cause us to have to implement several copies of the function, all to replace something that will be roughly as long as the TE itself.
Whoops, I jumped the gun thinking about runtime before implementation. Even though TEs could provide some amount of generalization for this, I agree with Nils that we would still need to implement multiple functions for different transformations and that it would be easier to use TEs directly wherever needed.
Feature request:
I think it would be quite useful to have a function that applies a coordinate transformation to a tensor component, or to all components. Some specialized functions were implemented in
PointwiseFunctions/GeneralRelativity/Transform.hpp
, but they currently only work for atnsr::ii
and for the first index of atnsr::ijj
. My suggestions is to generalize these functions, possibly using tensor expressions, so they support expressions like these:Perhaps the answer to this issue is just to use a tensor-expression contraction, or maybe we can add tensor-expression functions to make these coordinate transformation even easier.