
Excuse me, I sent this message from the wrong email address: On Fri, 14 Aug 2020 at 09:24, Steven D'Aprano <steve@pearwood.info> wrote:
Another big problem with tensors is the covariance and contravariance. Usually in informatic you denote the covariance with the subscript operator, that on paper is written as subscript. Contravariant index on the contrary is a superscript. Not sure how a programming language can easily represent it. Maybe PEP 472 can help here?

On 14/08/20 9:05 pm, Marco Sulla wrote:
I'm not sure the language *should* be representing it. If it does, there might be an expectation that you can supply an index as raised or lowered at your discretion and have it do the right thing automatically. But the "right thing" involves multiplying by a tensor that's a kind of implied global parameter to everything, and in Python we tend to frown on both implicit things and global things. I'm inclined to think that whether an array is a tensor or not isn't a language-level issue, but is a matter of interpretation. Just as a 1D array might represent a vector, or it might not, depending on how its contents are interpreted. -- Greg

Marco Sulla writes:
You're talking about the notation that makes the Einstein summation convention so pleasant? I think summation will have to be an explict operator or function, along a specified axis -- as numpy supports.
Not sure how a programming language can easily represent it.
Do you need to represent it? It seems to me you could have a Tensor class whose constructor takes a bool argument 'contravariant' (default False), and then recommend that users adopt a naming convention to distinguish covariant Tensors from contravariant Tensors. Steve

On 14/08/20 9:05 pm, Marco Sulla wrote:
I'm not sure the language *should* be representing it. If it does, there might be an expectation that you can supply an index as raised or lowered at your discretion and have it do the right thing automatically. But the "right thing" involves multiplying by a tensor that's a kind of implied global parameter to everything, and in Python we tend to frown on both implicit things and global things. I'm inclined to think that whether an array is a tensor or not isn't a language-level issue, but is a matter of interpretation. Just as a 1D array might represent a vector, or it might not, depending on how its contents are interpreted. -- Greg

Marco Sulla writes:
You're talking about the notation that makes the Einstein summation convention so pleasant? I think summation will have to be an explict operator or function, along a specified axis -- as numpy supports.
Not sure how a programming language can easily represent it.
Do you need to represent it? It seems to me you could have a Tensor class whose constructor takes a bool argument 'contravariant' (default False), and then recommend that users adopt a naming convention to distinguish covariant Tensors from contravariant Tensors. Steve
participants (3)
-
Greg Ewing
-
Marco Sulla
-
Stephen J. Turnbull