Assuming your model is solving the problem sequentially for slightly different $\boldsymbol{B}_{i}$:
$$ \boldsymbol{A} \boldsymbol{X}_{i} = \boldsymbol{B}_{i} $$
Since the matrix $\boldsymbol{A}$ is a Positive Definite Matrix, I am not sure your approach, using iterative solver, is the most efficient.
I think that computing the Cholesky Decomposition of the matrix and using it for any solution will be faster.
To backup my assertion I created a simple Julia script.
I created 2 matrices of size 5000x5000
.
I wanted to compare 2 approaches:
- Iterative Approach
Since your matrix is PD the go to method should be based on Conjugate Gradient. Where the solution of the $i$ -th iterations is the starting point of the $i + 1$ -th solution.
- Direct Approach
Since the matrix is PD, one could cache the Cholesky Decomposoiton and use that for each new right hand matrix.
I neglected the overhead of the first solution of each approach.
Let's focus on the steady state.
In Julia, the (2) approach yields:
runTime = @belapsed ($oChol \ $mB) seconds = 2;
resAnalysis = @sprintf("Direct Solver based on Cholesky run time: %0.5f [Sec]", runTime);
println(resAnalysis);
Direct Solver based on Cholesky run time: 1.04546 [Sec]
Namely, each solution takes something similar to 1 [Sec].
To evaluate the iterative approach, I calculated the time to simply multiply $\boldsymbol{A} \boldsymbol{B}$:
runTime = @belapsed ($mA * $mB) seconds = 2;
resAnalysis = @sprintf("Iterative Solver based on Matrix Multiplication run time: %0.5f [Sec]", runTime);
println(resAnalysis);
Iterative Solver based on Matrix Multiplication run time: 1.06335 [Sec]
So it is on the same ballpark, yet the iterative solver will probably require few iterations and each iteration of CG is using 2 multiplications.
So based on this simple evaluation, it is probably better to stick with the Cholesky based solution.
The code is available on my StackExchange Computational Science GitHub Repository (Look at the ComputationalScience\Q44417
folder).