The logarithm of a tensor

I want to take the logarithm of a tensor, what do I do

Do you mean element by element? How do you define the operation?
What does your input look like?

Let’s say I have A tensor of third order ,then,I want to know how to calculate e^A or log(A)

I believe this is because tensor multiplication is not defined, unlike a square matrix (where the matrix multiplication is defined)


Have a look at my tensor package

It supports expnentiation and log of arbitrary tensors, although the fully general log method is not as well implemented as the exp method yet.

It uses a Clifford algebra representation for tensors.


If you want element-wise operations, those are written as log.(A) and exp.(A) in Julia.


I don’t mean element by element

I can’t find a logarithm operation in this package

It’s not clear to me what you mean by the log of a tensor. Logs are defined when you have an algebra, ie you can square a tensor. I imagine you mean that you contract A*B with the two last indices of A and the two first of B? If that is the case then you can get your log by reshaping your tensor as a matrix (with reshape) and reshaping back.

It’s in there in src/composite.jl

Tensor multiplication is actually defined, if you use the Clifford product to multiply the tensors representation. The logarithm can be defined in terms of a series expansion with Clifford multiplication. In this case, using qlog:

Base.log(t::T) where T<:TensorAlgebra = qlog((t-1)/(t+1))
Base.log1p(t::T) where T<:TensorAlgebra = qlog(t/(t+2))

After first applying a transformation to the input. However, this method can diverge with some input.

In the Grassmann.jl package, there are several options, including an approximate but faster log_fast along with the slightly more robust Base.log with qlog.