[ANN] TensorAlgebra.jl: Taking covariance seriously

Isn’t conj basis dependent? I.e., i·(1\ 0) + 1·(0\ i) = ie₁ + ie₂, but -i·(1\ 0) + 1·(0\ i) = -ie₁ + ie₂.

There’s an obvious answer in , which has a special basis e_j with a defined phase. That doesn’t work in a general unitary space, when you only have i|ψ〉 + 1|φ〉, |ψ〉 = |1〉, |φ〉 = i|2〉, and 〈1|2〉 = 0.

I’ve thought for a while that it would be interesting to hear differential geometry and quantum mechanics people talk about tensors.

Conjugation of a complex unit (bilinear tensor) is the reversal of the composition of two reflection tensors, a’la Cartan-Dieudonne. Anti-linear maps are expressible with the Grassmann.jl geometric algebra as tensor operators, similar to quaternions but different (odd) rank.

Sure, but the metric itself is also basis dependant.

1 Like

Here are some notes, mostly for my future self when I need to refer back to this :slight_smile:

The tensor Hom adjunction is pretty cool.

Vect_K is a category whose objects are vector spaces over a field K and whose morphisms are linear maps.

Think of two linear maps between vector spaces: F: U\to V and G: U\to V. These can be combined linearly

H = \alpha F + \beta G

to get a new linear map H: U\to V. Therefore, the set of all linear maps U\to V forms a vector space we denote as [U,V]. This vector space is referred to as an internal hom.

Also, the field K itself is a vector space.

Hence, K, U, V and [U,V] are all objects (vector spaces) in Vect_K.

The tensor Hom adjunction says that for any three vector spaces U, V and W, we have

[V\otimes U, W]\cong[V,[U,W]].

If we let L_U: Vect_K\to Vect_K denote a functor given by

V\mapsto V\otimes U

and R_U: Vect_K\to Vect_K denote a functor given by

W\mapsto [U,W],

the tensor Hom adjunction is a little more suggestive

[L_U(V),W] \cong [V,R_U(W)]

and we see that “tensor product with U” and “maps from U” are adjoint (or adjunct).

Given a vector space U, its dual U^* is defined as the internal hom [U,K], i.e. all linear maps from U to K, which as we saw above is also a vector space.

Now consider the tensor Hom adjunction with V = K and W = K. Then we have

[K\otimes U,K] \cong [K, [U,K]] = [K,U^*].

However, K\otimes U \cong U so we can rewrite the tensor Hom adjunction simply as

U^* = [U,K] \cong [K,U^*].

Replacing U with U^* and noting that U^{**}\cong U, we have

U \cong [U^*,K] \cong [K,U].

This says the vector space of maps from U^* to K is equivalent to the vector space of maps from K to U and both vector spaces are equivalent to U.

This :point_up_2:was the final missing piece for me.

So if I summarize,

TensorKit.jl defines a tensor as \tau\in [K,U].

TensorAlgebra.jl defines a tensor as \tau\in [U^*,K].

Since [K,U] and [U^*,K] are equivalent, both packages are mathematically correct, but the choice leads to different implementations.

One advantage of defining tensors as maps U^*\to K is that it seems to be easier to support partial evaluation / currying, which is an important operation for tensor algebra.

I returned here after reading a particular discussion on Zulip on isa(M[1,:],Vector) where you link to this post. While it is true that TensorKit.jl defines a Tensor as an element from [K,U], that’s actually just a specific type constant corresponding to a more general type TensorMap which describes general elements from [U,V] .So that type can certainly also describe maps [U^*,K] .

However, TensorKit.jl can also describe morphisms in other categories than Vect, which have similar properties, (but where currying does not necessarily makes sense).

3 Likes

Actually, currying probably makes sense, I don’t use this word very often so I was a bit confused by its meaning. Rather, the mean reason to consider general morphisms in [U,V] is when you want to decompose a tensor using some linear algebra factorization. In that case, you want to have a clear domain and codomain, in order to apply standard matrix factorization algorithms.

1 Like

Hi @juthohaegeman ,

Please don’t take my slowness to respond as lack of interest. I’m in the middle of something now, but I would much rather be discussing this :slight_smile:

My memory is notoriously bad so I’ll need to review our discussion before asking questions (and potentially repeating myself). I’d love to learn more about the applications you have in mind. Just FYI, TensorAlgebra.jl is just a POC. I sat down and implemented tensors in a way that felt natural to me. Hopefully there can be some shared ideas :+1:

1 Like

How do you generally handle change of basis (or any specification of basis) in tensor spaces? We have a vector bundle/basis/charts design mostly ready in Manifolds.jl and I wonder if it could be somehow integrated with some tensor library. One point that turned out to be important is that, with the exception of some operations on tangent and cotangent space, we can only operate on coefficients of tensors in some basis.

Any recommend source to read about what you’ve been working on @mateuszbaran ?

This is just motivated by some changes to Manifolds.jl I’m working on: Atlases and charts by mateuszbaran · Pull Request #325 · JuliaManifolds/Manifolds.jl · GitHub , which in turn is motivated by me being uncomfortable about the way metrics are handled in Manifolds.jl. This is just basic differential geometry stuff, nothing fancy.

2 Likes