30 template<
class MatrixType>
39 template<
class MatrixType>
42 const label m = M.m();
61 for (
label bi=
k; bi<m; bi++)
63 alpha +=
sqr(R_(bi,
k));
76 for (
label bi=k+1; bi<m; bi++)
79 rSumSqrUk +=
sqr(uk[bi]);
81 rSumSqrUk = 2/rSumSqrUk;
84 for (
label bi=k; bi<m; bi++)
86 for (
label bj=k; bj<m; bj++)
88 Qk(bi, bj) = -rSumSqrUk*uk[bi]*uk[bj];
94 for (
label bi=k; bi<m; bi++)
96 for (
label bk=k; bk<
n; bk++)
99 for (
label bj=k; bj<
n; bj++)
101 Rk(bi, bk) += Qk(bi, bj)*R_(bj, bk);
111 for (
label bi=k; bi<m; bi++)
113 for (
label bj=k; bj<
n; bj++)
115 R_(bi, bj) = -Rk(bi, bj);
117 for (
label bj=k; bj<m; bj++)
119 Q_(bi, bj) = -Q_(bi, bj);
126 for (
label bi=k; bi<m; bi++)
128 for (
label bj=k; bj<
n; bj++)
130 R_(bi, bj) = Rk(bi, bj);
136 for (
label bi=0; bi<m; bi++)
138 for (
label bk=k; bk<m; bk++)
141 for (
label bj=k; bj<m; bj++)
143 Rk(bi, bk) += Q_(bi, bj)*Qk(bj, bk);
147 for (
label bi=0; bi<m; bi++)
149 for (
label bj=k; bj<
n; bj++)
151 Q_(bi, bj) = Rk(bi, bj);
158 template<
class MatrixType>
166 for (
int i=n-1; i>=0; i--)
170 for (
label j=i+1; j<
n; j++)
172 sum -= x[j]*R_(i, j);
175 if (
mag(R_(i, i)) < small)
178 <<
"Back-substitution failed due to small diagonal" 187 template<
class MatrixType>
194 const label m = Q_.m();
197 for (
label i=0; i<m; i++)
200 for (
label j=0; j<m; j++)
202 x[i] += Q_(j, i)*source[j];
210 template<
class MatrixType>
226 template<
class MatrixType>
230 const label m = Q_.m();
235 for (
label i=0; i<m; i++)
237 for (
label j=0; j<m; j++)
242 inv.
block(m, 1, 0, i) =
x;
MatrixType::cmptType cmptType
void solve(Field< cmptType > &x, const Field< cmptType > &source) const
Solve the linear system with the given source.
Class templated on matrix type to perform the QR decomposition using Householder reflections on a squ...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
void decompose(const MatrixType &M)
Decompose given matrix.
T & ref() const
Return non-const reference or generate a fatal error.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
volScalarField alpha(IOobject("alpha", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
dimensionedScalar sqrt(const dimensionedScalar &ds)
label k
Boltzmann constant.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
static const Identity< scalar > I
Pre-declare SubField and related Field type.
errorManip< error > abort(error &err)
ConstMatrixBlock< mType > block(const label m, const label n, const label mStart, const label nStart) const
QRMatrix()
Construct null.
dimensioned< scalar > mag(const dimensioned< Type > &)
A class for managing temporary objects.
QMatrixType inv() const
Return the inverse of a square matrix.