37 RectangularMatrix<scalar>,
46 SymmetricSquareMatrix<scalar>,
51 SymmetricSquareMatrix<scalar>,
58 DiagonalMatrix<scalar>,
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++)
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++)
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++)
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);
dimensionedScalar sign(const dimensionedScalar &ds)
scalarRectangularMatrix SVDinv(const scalarRectangularMatrix &A, scalar minCondition=0)
Return the inverse of matrix A using SVD.
label n() const
Return the number of columns.
DiagonalMatrix< scalar > scalarDiagonalMatrix
void multiply(FieldField< Field, Type > &f, const FieldField< Field, Type > &f1, const FieldField< Field, scalar > &f2)
errorManipArg< error, int > exit(error &err, const int errNo=1)
addCompoundToRunTimeSelectionTable(List< complex >, complexList)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
defineCompoundTypeName(List< complex >, complexList)
void LUDecompose(scalarSquareMatrix &matrix, labelList &pivotIndices)
LU decompose the matrix with pivoting.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
void size(const label)
Override size to be inconsistent with allocated storage.
dimensionedScalar sqrt(const dimensionedScalar &ds)
label k
Boltzmann constant.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
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.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Singular value decomposition of a rectangular matrix.
errorManip< error > abort(error &err)
SymmetricSquareMatrix< scalar > scalarSymmetricSquareMatrix
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...
label m() const
Return the number of rows.
dimensioned< scalar > mag(const dimensioned< Type > &)
const dimensionedVector & g
SquareMatrix< scalar > scalarSquareMatrix
RectangularMatrix< scalar > scalarRectangularMatrix