Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raise the identity matrix to a power

Tags:

matrix

julia

Is it possible to raise the identity matrix to a power? I get an error if I try using the ^ operator.

x = [2 0 ; 0 2]
x^2 # this works fine
(2I)^2 #throws MethodError: no method matching ^(::UniformScaling{Int64}, ::Int64)

Note: I know that I could simply do (2^2)I, but there are cases where this cannot be done (e.g. when a matrix is passed to a function which raises the matrix).

like image 589
Andrea Nardi Avatar asked Dec 02 '19 19:12

Andrea Nardi


1 Answers

It's just a missing method for UniformScaling objects. It would be great if you could open an issue about it so that it can be added in a future release.

like image 125
StefanKarpinski Avatar answered Nov 06 '22 12:11

StefanKarpinski