Hi Maple experts,
I have a seemingly simple procedure that is supposed to create random matrices.
What surprises me is the fact that it takes more CPU time evertime I call it (even in a fresh session). The procedure is as follows:
Feynman_random_rho := proc(N::posint, d::posint:=2)::'Matrix'(complex);
# returns a random N-qudit density matrix where the optional second argument, d,
# specifies the dimension of each subsystem. By default, d=2 is assumed so that
# an N-qubit density matrix is generated.
# The density matrices are uniformly distributed according to the Hilbert-Schmidt
# norm [see Toth, quant-ph/0709.0948].
local rho, temp;
temp := Matrix(d^N, d^N, RandomTools[Generate](distribution(Normal(0, 1)), makeproc=true), datatype=complex);
temp := LinearAlgebra[Add](temp, Matrix(d^N, d^N, RandomTools[Generate](distribution(Normal(0, 1)), makeproc=true), datatype=complex), 1,I);
rho := LinearAlgebra[HermitianTranspose](temp).temp;
Obviously, I use only native Maple commands and do not request any caching/remember tables action. So what can I do to i) speed things up ii) keep the execution time (roughly) constant?
Thanks in advance for any thoughts!