88 for (
label i=0; i<m; i++)
90 scalar largestCoeff = 0.0;
92 const scalar* __restrict__ matrixi = matrix[i];
94 for (
label j=0; j<m; j++)
96 if ((temp =
mag(matrixi[j])) > largestCoeff)
102 if (largestCoeff == 0.0)
108 vv[i] = 1.0/largestCoeff;
111 for (
label j=0; j<m; j++)
113 scalar* __restrict__ matrixj = matrix[j];
115 for (
label i=0; i<j; i++)
117 scalar* __restrict__ matrixi = matrix[i];
119 scalar
sum = matrixi[j];
122 sum -= matrixi[
k]*matrix(
k, j);
129 scalar largestCoeff = 0.0;
130 for (
label i=j; i<m; i++)
132 scalar* __restrict__ matrixi = matrix[i];
133 scalar
sum = matrixi[j];
137 sum -= matrixi[
k]*matrix(
k, j);
143 if ((temp = vv[i]*
mag(
sum)) >= largestCoeff)
150 pivotIndices[j] = iMax;
154 scalar* __restrict__ matrixiMax = matrix[iMax];
158 Swap(matrixj[
k], matrixiMax[
k]);
165 if (matrixj[j] == 0.0)
172 scalar rDiag = 1.0/matrixj[j];
174 for (
label i=j+1; i<m; i++)
176 matrix(i, j) *= rDiag;
189 for (
label j=0; j<size; j++)
197 for (
label j=0; j<size; j++)
207 s += matrix(i,
k)*matrix(i, j);
210 s = (matrix(j,
k) -
s)/matrix(
k,
k);
218 d = matrix(j, j) - d;
223 <<
"Matrix is not symmetric positive-definite. Unable to "
228 matrix(j, j) =
sqrt(d);
246 <<
"A and B must have identical inner dimensions but A.n = "
247 <<
A.n() <<
" and B.m = " <<
B.m()
254 <<
"B and C must have identical inner dimensions but B.n = "
255 <<
B.n() <<
" and C.m = " <<
C.m()
261 for (
label i=0; i<
A.m(); i++)
263 for (
label g = 0; g <
C.n(); g++)
265 for (
label l=0; l<
C.m(); l++)
268 for (
label j=0; j<
A.n(); j++)
270 ab +=
A(i, j)*
B(j, l);
272 ans(i, g) +=
C(l, g) * ab;
287 if (
A.n() !=
B.size())
290 <<
"A and B must have identical inner dimensions but A.n = "
291 <<
A.n() <<
" and B.m = " <<
B.size()
295 if (
B.size() !=
C.m())
298 <<
"B and C must have identical inner dimensions but B.n = "
299 <<
B.size() <<
" and C.m = " <<
C.m()
305 for (
label i=0; i<
A.m(); i++)
307 for (
label g=0; g<
C.n(); g++)
309 for (
label l=0; l<
C.m(); l++)
311 ans(i, g) +=
C(l, g) *
A(i, l)*
B[l];
326 if (
A.m() !=
B.size())
329 <<
"A and B must have identical dimensions but A.m = "
330 <<
A.m() <<
" and B.m = " <<
B.size()
334 if (
B.size() !=
C.m())
337 <<
"B and C must have identical dimensions but B.m = "
338 <<
B.size() <<
" and C.m = " <<
C.m()
346 for (
label i=0; i<size; i++)
348 for (
label g=0; g<size; g++)
350 for (
label l=0; l<size; l++)
352 ans(i, g) +=
C(l, g)*
A(i, l)*
B[l];
365 SVD svd(
A, minCondition);
static const Foam::dimensionedScalar A("A", Foam::dimPressure, 611.21)
static const Foam::dimensionedScalar B("B", Foam::dimless, 18.678)
static const Foam::dimensionedScalar C("C", Foam::dimTemperature, 234.5)
Graphite solid properties.
label m() const
Return the number of rows.
Singular value decomposition of a rectangular matrix.
scalarRectangularMatrix VSinvUt() const
Return the matrix product V S^(-1) U^T (the pseudo inverse)
A templated 2D square symmetric matrix of objects of <T>, where the n x n matrix dimension is known a...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensionedScalar sign(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
RectangularMatrix< scalar > scalarRectangularMatrix
defineCompoundTypeName(List< complex >, complexList)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
errorManip< error > abort(error &err)
void LUDecompose(scalarSquareMatrix &matrix, labelList &pivotIndices)
LU decompose the matrix with pivoting.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
scalarRectangularMatrix SVDinv(const scalarRectangularMatrix &A, scalar minCondition=0)
Return the inverse of matrix A using SVD.
SquareMatrix< scalar > scalarSquareMatrix
addCompoundToRunTimeSelectionTable(List< complex >, complexList)
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)