On Monday, November 3, 2014 5:10:11 PM UTC+1, Jamie Titus wrote:
>
> I think I understand the intended structure of the tensor.tensor module a
> bit more now. A lot of the things I have fooled around with are quick hacks
> that don't really fit the use of each class (i.e., just returning a TensMul
> from a covariant derivative function). A quick question - why is it true
> that TensAdd objects are not supposed to support index order? Is this a
> function of the other algorithms like canonicalization that I'm not as
> interested in?
>
If you have an expression like A(i, j) + B(j, i) - what is the index order?
[i, j] or [j, i]? It exposes a set of free (i.e. uncontracted) indices, {i,
j}. The single terms of the addition have an order, [i, j] and [j, i]
respectively.
>
> I'd like to ask more generally what use a tensor is if the indices are
> unordered, but I suppose that just reveals my ignorance as a novice
> physicist - I think of Tensors in a pretty concrete matrix-based way, and
> when I'm not thinking of them as matrices, I'm thinking of them as
> functions, which requires an argument order.
>
A tensor expression may not have a clear order. When you think of tensors
as multidimensional arrays, you have to pick an index order, so in A(i, j)
+ B(j, i) you may pick the order [i, j], transpose the matrix of B's
components and add it to A. It currently fails to transpose, this is the
bug you reported. If you picked [j, i] instead of [i, j], you would operate
on the transpose.
> I will take your advice and look more at sympy.diffgeom for the time being
> - do you know if it's possible to implement mixed tensors there? Perhaps it
> would be easier to build a TensorArray class that provides an interface
> more like sympy.tensor.tensor while using the implementation of
> sympy.diffgeom.
>
Yes, I tried to draft a TensorArray some months ago, but then ran out of
time. In *sympy.diffgeom* there is a wedge product, which makes sense only
on differential forms, which transform covariantly.
Anyways, creating a TensorArray is the fastest approach to GR. I would
devise it something like
class TensorArray(Expr):
def __new__(cls, ndarray, shape, valence, coord_sys=None):
return Expr.__new__(ndarray, shape, coord_sys)
def numpy_to_TensorArray(ndarr, valence, coord_sys=None):
...
> Thank you for taking the time to explain everything about the structure of
> the module.
>
You're welcome.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/0dd10ff9-e7bc-46e3-8306-347a9276b3ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.