Ok, so I have several, multi-dimensional numpy arrays of sympy objects (expressions). For example:
A = array([[1.0*cos(z0)**2 + 1.0, 1.0*cos(z0)],
[1.0*cos(z0), 1.00000000000000]], dtype=object)
and so on.
What I would like to do is multiply several of these arrays using einsum, since I already have the syntax for that from a numerical calculation I was doing earlier. The problem is, when I try to do something like
einsum('ik,jkim,j', A, B, C)
I get a type error:
TypeError: invalid data type for einsum
Sure, so a quick search on Google shows me einsum probably can't do this, but no reason as to why. In particular, calling the numpy.dot() and numpy.tensordot() functions on those arrays works like a charm. I could use tensordot to do what I need, but my brain hurts when I think about having to replace fifty or so Einsten summations like the one above (where the order of the indeces is very important) with nested tensordot calls. Even more nightmarish is the though of having to debug that code and hunt for that one misplaced index swap.
Long story short, does anyone know why tensordot works with objects but einsum will not? Any suggestions towards a workaround? If not, any suggestions as to how I would go about writing my own wrapper to nested tensordot calls that is somewhat similar to the einsum notation (numbers instead of letters are fine)?