I am looking for a more effcient method to perform the following analysis. I did my best, but running the following code on my machine takes 9.766s. I need to perform this analysis several times.
ClearAll["Global`*"];
Jfunction =
Compile[{{NOunknownPar, _Integer, 0}, {dt, _Real,
0}, {Kgeneral, _Real, 2}, {Jacob1, _Real, 2}},
Module[{Ident, sj1, sj2, sj3, sf},
Ident = IdentityMatrix[2*NOunknownPar];
sj1 = Ident - (0.5*dt)*Kgeneral; sj2 = Ident + (0.5*dt)*Kgeneral;
sj3 = sj2.Jacob1; sf = LinearSolve[sj1, sj3]; sf],
CompilationTarget -> "C"];
NoVar = 79;
NoRep = 6001;
deltaT = 0.0001;
Jmat = IdentityMatrix[2*NoVar];
KK = ConstantArray[0, NoRep - 1];
Do[KK[[i]] = RandomReal[1, {2*NoVar, 2*NoVar}], {i, NoRep - 1}];
Do[Jmat = Jfunction[NoVar, deltaT, KK[[jJa]], Jmat], {jJa,
NoRep - 1}] // Timing