Exp() of nonsquare matrix

Hi,

I ran into an issue on exp() of a matrix.
Here is a minimal reproducible example, and I’m using Julia 1.0.3:

using LinearAlgebra
exp(Matrix(1.0I, 2, 1))

The error I got is:

DimensionMismatch("matrix is not square: dimensions are (2, 1)")

I checked the source code, in both exp and exp!, it first checks whether the input matrix is square or not.
However, Matlab does support exp of nonsquare matrix.
Any idea? Any help is appreciated.

It’s because matlab calculates the elementwise exponential when you call exp on a matrix. To get that in Julia, do exp.(M), notice the dot ..

Julia calculates the matrix exponential when you ask for exp(m::Matrix)

5 Likes

Thanks!

The dot is very powerful in julia and can be applied to any function, including operators. See broadcasting for documentation.

1 Like