46 finalP = MatrixFactory2::BuildCopy(rcpFromRef(P0));
51 "For now, solving Hessenberg system works only for a single iteration");
53 SC one = Teuchos::ScalarTraits<SC>::one(), zero = Teuchos::ScalarTraits<SC>::zero();
55 RCP<const Matrix> A = rcpFromRef(Aref);
62 ArrayRCP<const SC> D(A->getLocalNumRows(), one);
68 RCP<Matrix> X = rcp_const_cast<Matrix>(rcpFromRef(P0)), tmpAP, newV;
69 std::vector<RCP<Matrix> > V(
nIts_ + 1);
72 RCP<CrsMatrix> T_ = CrsMatrixFactory::Build(C.
GetPattern());
73 T_->fillComplete(P0.getDomainMap(), P0.getRangeMap());
74 RCP<Matrix> T = rcp(
new CrsMatrixWrap(T_));
80 tmpAP = MatrixMatrix::Multiply(*A,
false, *X,
false, mmfancy,
true ,
true );
83 V[0] = MatrixFactory2::BuildCopy(T);
88 V[0]->scale(-one / rho);
92 std::vector<SC> c(
nIts_ + 1, 0.0);
93 std::vector<SC> s(
nIts_ + 1, 0.0);
94 std::vector<SC> g(
nIts_ + 1, 0.0);
97#define I(i, j) ((i) + (j) * (nIts_ + 1))
98 for (
size_t i = 0; i <
nIts_; i++) {
100 tmpAP = MatrixMatrix::Multiply(*A,
false, *V[i],
false, mmfancy,
true ,
true );
103 V[i + 1] = MatrixFactory2::BuildCopy(T);
107 for (
size_t j = 0; j <= i; j++) {
111#ifndef TWO_ARG_MATRIX_ADD
112 newV = Teuchos::null;
113 MatrixMatrix::TwoMatrixAdd(*V[j],
false, -h[
I(j, i)], *V[i + 1],
false, one, newV, mmfancy);
114 newV->fillComplete(V[i + 1]->getDomainMap(), V[i + 1]->getRangeMap());
125 MatrixMatrix::TwoMatrixAdd(*V[j],
false, -h[
I(j, i)], *V[i + 1], one);
144 if (h[
I(i + 1, i)] != zero) {
146 V[i + 1]->scale(one / h[
I(i + 1, i)]);
150 givapp(&c[0], &s[0], &h[
I(0, i)], i);
152 SC nu = sqrt(h[
I(i, i)] * h[
I(i, i)] + h[
I(i + 1, i)] * h[
I(i + 1, i)]);
154 c[i] = h[
I(i, i)] / nu;
155 s[i] = -h[
I(i + 1, i)] / nu;
156 h[
I(i, i)] = c[i] * h[
I(i, i)] - s[i] * h[
I(i + 1, i)];
157 h[
I(i + 1, i)] = zero;
159 givapp(&c[i], &s[i], &g[i], 1);
165 std::vector<SC> y(
nIts_);
167 y[0] = g[0] / h[
I(0, 0)];
172 for (
size_t i = 0; i <
nIts_; i++) {
173#ifndef TWO_ARG_MATRIX_ADD
174 newV = Teuchos::null;
175 MatrixMatrix::TwoMatrixAdd(*V[i],
false, y[i], *finalP,
false, one, newV, mmfancy);
176 newV->fillComplete(finalP->getDomainMap(), finalP->getRangeMap());
179 MatrixMatrix::TwoMatrixAdd(*V[i],
false, y[i], *finalP, one);
static Scalar Frobenius(const Xpetra::Matrix< Scalar, DefaultLocalOrdinal, DefaultGlobalOrdinal, DefaultNode > &A, const Xpetra::Matrix< Scalar, DefaultLocalOrdinal, DefaultGlobalOrdinal, DefaultNode > &B)
static void MyOldScaleMatrix(Xpetra::Matrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > &Op, const Teuchos::ArrayRCP< const Scalar > &scalingVector, bool doInverse=true, bool doFillComplete=true, bool doOptimizeStorage=true)