Skip to main content

matrix - MatrixExp[m, v] not always faster than MatrixExp[m].v


For non sparse matrix m, is MatrixExp[m, v] supposed to be faster than MatrixExp[m].v? This seems to be true only if m is purely real or imaginary.


Block[{n = 500},
v = RandomComplex[1. + I, n];
s = RandomReal[{-1., 1.}, {n, n}];
s1 = RandomComplex[1. + I, {n, n}];
]

MatrixExp[s].v; // AbsoluteTiming


{0.12628, Null}


MatrixExp[s, v]; // AbsoluteTiming

{0.0379219, Null}


MatrixExp[s1].v; // AbsoluteTiming

{0.365637, Null}


MatrixExp[s1, v]; // AbsoluteTiming

{5.17002, Null}



MatrixExp[s1, v, Method -> "Krylov"]; // AbsoluteTiming

{4.93712, Null}


MatrixExp[s1, v, Method -> "Pade"]; // AbsoluteTiming

{0.416058, Null}




Comments