private double PrepareRestart(NativeVector rhs, NativeVector x, int jH) { ConstructCurrentSolution(jH, x); double beta; if (Parameters.ResidualAtRestart == ResidualAtRestart.ComputeTheTrue) { UnsafeNativeMethods.Zcopy(_nloc, x.Ptr, _w.Ptr); CalculateMatrixVectorMult(_w, _r0); NativeVector.Sub(rhs, _r0, _r0); if (Parameters.Preconditioning != Preconditioning.None) { throw new NotImplementedException(); } UnsafeNativeMethods.Zcopy(_nloc, _r0.Ptr, _w.Ptr); beta = CalculateVectorNorm(_w); } else { beta = _hessenberg[_m, _m].Magnitude; for (int j = _m - 1; j >= 0; j--) { _hessenberg[j, _m] = Zero; Zrot(_hessenberg.GetPointer(j, _m), _hessenberg.GetPointer(j + 1, _m), _givensRotCos[j], -_givensRotSin[j]); UnsafeNativeMethods.ZgemvNotTrans(_nloc, _m + 1, One, _krylovBasis.Ptr, _hessenberg.GetColumn(_m), Zero, _w.Ptr); } } return(beta); }
private double ModifiedGramSchmidtIteration(int jH) { double dloo = 0; for (int j = 0; j <= jH; j++) { CalculateDotProduct(_krylovBasis.GetColumn(j), _w.Ptr); var dVi = _dotProducts[0]; _hessenberg[j, jH] += dVi; dloo += Abs(dVi) * Abs(dVi); UnsafeNativeMethods.Zaxpy(_nloc, -dVi, _krylovBasis.GetColumn(j), 1, _w.Ptr, 1); } return(dloo); }