From 97489df33dc77fbd53bd31e815b72727c01c227d Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Thu, 10 Mar 2016 22:53:09 +0000 Subject: [PATCH] Matrix: Switch n() and m() so that now m() = number of rows and n() = number of columns For consistency with current references and other numerics libraries --- src/OpenFOAM/dimensionSet/dimensionSets.C | 6 +- .../matrices/DiagonalMatrix/DiagonalMatrix.C | 4 +- .../matrices/LUscalarMatrix/LUscalarMatrix.C | 14 +-- .../LUscalarMatrix/LUscalarMatrixTemplates.C | 4 +- src/OpenFOAM/matrices/Matrix/Matrix.C | 114 +++++++++--------- src/OpenFOAM/matrices/Matrix/Matrix.H | 4 +- src/OpenFOAM/matrices/Matrix/MatrixI.H | 4 +- src/OpenFOAM/matrices/Matrix/MatrixIO.C | 38 +++--- .../matrices/SquareMatrix/SquareMatrix.C | 8 +- .../SymmetricSquareMatrix.C | 8 +- .../matrices/scalarMatrices/SVD/SVD.C | 113 ++++++++--------- .../matrices/scalarMatrices/SVD/SVD.H | 3 +- .../matrices/scalarMatrices/scalarMatrices.C | 64 +++++----- .../scalarMatrices/scalarMatricesTemplates.C | 50 ++++---- .../matrices/simpleMatrix/simpleMatrix.C | 4 +- .../CentredFitSnGrad/CentredFitSnGradData.C | 6 +- .../schemes/FitData/FitData.C | 8 +- .../radiationModels/viewFactor/viewFactor.C | 2 +- 18 files changed, 227 insertions(+), 227 deletions(-) diff --git a/src/OpenFOAM/dimensionSet/dimensionSets.C b/src/OpenFOAM/dimensionSet/dimensionSets.C index 2a76260c57..85ccde6947 100644 --- a/src/OpenFOAM/dimensionSet/dimensionSets.C +++ b/src/OpenFOAM/dimensionSet/dimensionSets.C @@ -234,17 +234,17 @@ Foam::dimensionSets::dimensionSets valid_ = true; // Determine conversion from basic units to write units - for (label rowI = 0; rowI < conversion_.n(); rowI++) + for (label rowI = 0; rowI < conversion_.m(); rowI++) { scalar* row = conversion_[rowI]; - for (label columnI = 0; columnI < conversion_.m(); columnI++) + for (label columnI = 0; columnI < conversion_.n(); columnI++) { const dimensionedScalar& dSet = units_[columnI]; row[columnI] = dSet.dimensions()[rowI]; } } - conversionPivots_.setSize(conversion_.n()); + conversionPivots_.setSize(conversion_.m()); LUDecompose(conversion_, conversionPivots_); } } diff --git a/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C b/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C index d6bc7f7b71..69844cd403 100644 --- a/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C +++ b/src/OpenFOAM/matrices/DiagonalMatrix/DiagonalMatrix.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,7 +38,7 @@ template template Foam::DiagonalMatrix::DiagonalMatrix(const Matrix& a) : - List(min(a.n(), a.m())) + List(min(a.m(), a.n())) { forAll(*this, i) { diff --git a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C index b5e37d441b..dc68209202 100644 --- a/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C +++ b/src/OpenFOAM/matrices/LUscalarMatrix/LUscalarMatrix.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,7 @@ Foam::LUscalarMatrix::LUscalarMatrix(const scalarSquareMatrix& matrix) : scalarSquareMatrix(matrix), comm_(Pstream::worldComm), - pivotIndices_(n()) + pivotIndices_(m()) { LUDecompose(*this, pivotIndices_); } @@ -144,8 +144,8 @@ Foam::LUscalarMatrix::LUscalarMatrix if (Pstream::master(comm_)) { - label nRows = n(); - label nColumns = m(); + label nRows = m(); + label nColumns = n(); if (debug) { @@ -180,7 +180,7 @@ Foam::LUscalarMatrix::LUscalarMatrix Pout<< endl; } - pivotIndices_.setSize(n()); + pivotIndices_.setSize(m()); LUDecompose(*this, pivotIndices_); } } @@ -387,10 +387,10 @@ void Foam::LUscalarMatrix::convert void Foam::LUscalarMatrix::printDiagonalDominance() const { - for (label i=0; i& sourceSol) const { if (Pstream::parRun()) { - Field completeSourceSol(n()); + Field completeSourceSol(m()); if (Pstream::master(comm_)) { diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.C b/src/OpenFOAM/matrices/Matrix/Matrix.C index d06cef41e6..39761e49da 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.C +++ b/src/OpenFOAM/matrices/Matrix/Matrix.C @@ -96,9 +96,9 @@ Foam::Matrix::Matrix(const label n, const label m, const Type& a) { Type* v = v_[0]; - label nm = nRows_*nCols_; + label mn = nRows_*nCols_; - for (label i=0; i::Matrix(const Matrix& a) Type* v = v_[0]; const Type* av = a.v_[0]; - label nm = nRows_*nCols_; - for (label i=0; i Form Foam::Matrix::T() const { const Matrix& A = *this; - Form At(m(), n()); + Form At(n(), m()); - for (label i=0; i::operator=(const Type& t) { Type* v = v_[0]; - label nm = nRows_*nCols_; - for (label i=0; i::operator=(const Matrix& a) if (this == &a) { FatalErrorInFunction - << "attempted assignment to self" + << "attempted assigmnent to self" << abort(FatalError); } @@ -217,8 +217,8 @@ void Foam::Matrix::operator=(const Matrix& a) Type* v = v_[0]; const Type* av = a.v_[0]; - label nm = nRows_*nCols_; - for (label i=0; i::operator=(const Matrix& a) template const Type& Foam::max(const Matrix& a) { - label nm = a.n()*a.m(); + label mn = a.m()*a.n(); - if (nm) + if (mn) { label curMaxI = 0; const Type* v = a[0]; - for (label i=1; i v[curMaxI]) { @@ -263,14 +263,14 @@ const Type& Foam::max(const Matrix& a) template const Type& Foam::min(const Matrix& a) { - label nm = a.n()*a.m(); + label mn = a.m()*a.n(); - if (nm) + if (mn) { label curMinI = 0; const Type* v = a[0]; - for (label i=1; i& a) template Form Foam::operator-(const Matrix& a) { - Form na(a.n(), a.m()); + Form na(a.m(), a.n()); - if (a.n() && a.m()) + if (a.m() && a.n()) { Type* nav = na[0]; const Type* av = a[0]; - label nm = a.n()*a.m(); - for (label i=0; i& a) template Form Foam::operator+(const Matrix& a, const Matrix& b) { - if (a.n() != b.n()) - { - FatalErrorInFunction - << "attempted add matrices with different number of rows: " - << a.n() << ", " << b.n() - << abort(FatalError); - } - if (a.m() != b.m()) { FatalErrorInFunction - << "attempted add matrices with different number of columns: " + << "attempted add matrices with different number of rows: " << a.m() << ", " << b.m() << abort(FatalError); } - Form ab(a.n(), a.m()); + if (a.n() != b.n()) + { + FatalErrorInFunction + << "attempted add matrices with different number of columns: " + << a.n() << ", " << b.n() + << abort(FatalError); + } + + Form ab(a.m(), a.n()); Type* abv = ab[0]; const Type* av = a[0]; const Type* bv = b[0]; - label nm = a.n()*a.m(); - for (label i=0; i& a, const Matrix& b) template Form Foam::operator-(const Matrix& a, const Matrix& b) { - if (a.n() != b.n()) - { - FatalErrorInFunction - << "attempted add matrices with different number of rows: " - << a.n() << ", " << b.n() - << abort(FatalError); - } - if (a.m() != b.m()) { FatalErrorInFunction - << "attempted add matrices with different number of columns: " + << "attempted add matrices with different number of rows: " << a.m() << ", " << b.m() << abort(FatalError); } - Form ab(a.n(), a.m()); + if (a.n() != b.n()) + { + FatalErrorInFunction + << "attempted add matrices with different number of columns: " + << a.n() << ", " << b.n() + << abort(FatalError); + } + + Form ab(a.m(), a.n()); Type* abv = ab[0]; const Type* av = a[0]; const Type* bv = b[0]; - label nm = a.n()*a.m(); - for (label i=0; i& a, const Matrix& b) template Form Foam::operator*(const scalar s, const Matrix& a) { - Form sa(a.n(), a.m()); + Form sa(a.m(), a.n()); - if (a.n() && a.m()) + if (a.m() && a.n()) { Type* sav = sa[0]; const Type* av = a[0]; - label nm = a.n()*a.m(); - for (label i=0; i& a) template Form Foam::operator*(const Matrix& a, const Matrix& b) { - if (a.m() != b.n()) + if (a.n() != b.m()) { FatalErrorInFunction << "attempted to multiply incompatible matrices:" << nl - << "Matrix A : " << a.n() << " rows, " << a.m() << " columns" << nl - << "Matrix B : " << b.n() << " rows, " << b.m() << " columns" << nl + << "Matrix A : " << a.m() << " rows, " << a.n() << " columns" << nl + << "Matrix B : " << b.m() << " rows, " << b.n() << " columns" << nl << "In order to multiply matrices, columns of A must equal " << "rows of B" << abort(FatalError); } - Form ab(a.n(), b.m(), scalar(0)); + Form ab(a.m(), b.n(), scalar(0)); - for (label i = 0; i < ab.n(); i++) + for (label i = 0; i < ab.m(); i++) { - for (label j = 0; j < ab.m(); j++) + for (label j = 0; j < ab.n(); j++) { - for (label l = 0; l < b.n(); l++) + for (label l = 0; l < b.m(); l++) { ab[i][j] += a[i][l]*b[l][j]; } diff --git a/src/OpenFOAM/matrices/Matrix/Matrix.H b/src/OpenFOAM/matrices/Matrix/Matrix.H index 87652bdd6b..49bf41fc6f 100644 --- a/src/OpenFOAM/matrices/Matrix/Matrix.H +++ b/src/OpenFOAM/matrices/Matrix/Matrix.H @@ -125,10 +125,10 @@ public: // Access //- Return the number of rows - inline label n() const; + inline label m() const; //- Return the number of columns - inline label m() const; + inline label n() const; //- Return the number of elements in matrix (n*m) inline label size() const; diff --git a/src/OpenFOAM/matrices/Matrix/MatrixI.H b/src/OpenFOAM/matrices/Matrix/MatrixI.H index 5286b98f42..fbfd446281 100644 --- a/src/OpenFOAM/matrices/Matrix/MatrixI.H +++ b/src/OpenFOAM/matrices/Matrix/MatrixI.H @@ -53,14 +53,14 @@ inline const Foam::Matrix& Foam::Matrix::null() //- Return the number of rows template -inline Foam::label Foam::Matrix::n() const +inline Foam::label Foam::Matrix::m() const { return nRows_; } template -inline Foam::label Foam::Matrix::m() const +inline Foam::label Foam::Matrix::n() const { return nCols_; } diff --git a/src/OpenFOAM/matrices/Matrix/MatrixIO.C b/src/OpenFOAM/matrices/Matrix/MatrixIO.C index 60df684937..edf2c54b22 100644 --- a/src/OpenFOAM/matrices/Matrix/MatrixIO.C +++ b/src/OpenFOAM/matrices/Matrix/MatrixIO.C @@ -62,7 +62,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix& M) M.nRows_ = firstToken.labelToken(); M.nCols_ = readLabel(is); - label nm = M.nRows_*M.nCols_; + label mn = M.nRows_*M.nCols_; // Read list contents depending on data format if (is.format() == IOstream::ASCII || !contiguous()) @@ -70,7 +70,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix& M) // Read beginning of contents char listDelimiter = is.readBeginList("Matrix"); - if (nm) + if (mn) { M.allocate(); Type* v = M.v_[0]; @@ -80,11 +80,11 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix& M) label k = 0; // loop over rows - for (label i=0; i> v[k++]; @@ -109,7 +109,7 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix& M) "reading the single entry" ); - for (label i=0; i>(Istream& is, Matrix& M) } else { - if (nm) + if (mn) { M.allocate(); Type* v = M.v_[0]; - is.read(reinterpret_cast(v), nm*sizeof(Type)); + is.read(reinterpret_cast(v), mn*sizeof(Type)); is.fatalCheck ( @@ -151,24 +151,24 @@ Foam::Istream& Foam::operator>>(Istream& is, Matrix& M) template Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix& M) { - label nm = M.nRows_*M.nCols_; + label mn = M.nRows_*M.nCols_; - os << M.n() << token::SPACE << M.m(); + os << M.m() << token::SPACE << M.n(); // Write list contents depending on data format if (os.format() == IOstream::ASCII || !contiguous()) { - if (nm) + if (mn) { bool uniform = false; const Type* v = M.v_[0]; - if (nm > 1 && contiguous()) + if (mn > 1 && contiguous()) { uniform = true; - for (label i=0; i< nm; i++) + for (label i=0; i< mn; i++) { if (v[i] != v[0]) { @@ -189,7 +189,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix& M) // Write end of contents delimiter os << token::END_BLOCK; } - else if (nm < 10 && contiguous()) + else if (mn < 10 && contiguous()) { // Write size of list and start contents delimiter os << token::BEGIN_LIST; @@ -197,12 +197,12 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix& M) label k = 0; // loop over rows - for (label i=0; i< M.n(); i++) + for (label i=0; i< M.m(); i++) { os << token::BEGIN_LIST; // Write row - for (label j=0; j< M.m(); j++) + for (label j=0; j< M.n(); j++) { if (j > 0) os << token::SPACE; os << v[k++]; @@ -222,12 +222,12 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix& M) label k = 0; // loop over rows - for (label i=0; i< M.n(); i++) + for (label i=0; i< M.m(); i++) { os << nl << token::BEGIN_LIST; // Write row - for (label j=0; j< M.m(); j++) + for (label j=0; j< M.n(); j++) { os << nl << v[k++]; } @@ -246,9 +246,9 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix& M) } else { - if (nm) + if (mn) { - os.write(reinterpret_cast(M.v_[0]), nm*sizeof(Type)); + os.write(reinterpret_cast(M.v_[0]), mn*sizeof(Type)); } } diff --git a/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.C b/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.C index 439257fcb6..e8e7dd0e8c 100644 --- a/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.C +++ b/src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,7 +37,7 @@ Foam::scalar Foam::detDecomposed { scalar diagProduct = 1.0; - for (label i = 0; i < matrix.n(); ++i) + for (label i = 0; i < matrix.m(); ++i) { diagProduct *= matrix[i][i]; } @@ -51,7 +51,7 @@ Foam::scalar Foam::det(const SquareMatrix& matrix) { SquareMatrix matrixTmp = matrix; - labelList pivotIndices(matrix.n()); + labelList pivotIndices(matrix.m()); label sign; LUDecompose(matrixTmp, pivotIndices, sign); @@ -62,7 +62,7 @@ Foam::scalar Foam::det(const SquareMatrix& matrix) template Foam::scalar Foam::det(SquareMatrix& matrix) { - labelList pivotIndices(matrix.n()); + labelList pivotIndices(matrix.m()); label sign; LUDecompose(matrix, pivotIndices, sign); diff --git a/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.C b/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.C index bb6bea65c7..1ab99b1240 100644 --- a/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.C +++ b/src/OpenFOAM/matrices/SymmetricSquareMatrix/SymmetricSquareMatrix.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,9 +33,9 @@ Foam::SymmetricSquareMatrix Foam::invDecomposed const SymmetricSquareMatrix& matrix ) { - SymmetricSquareMatrix inv(matrix.n(), matrix.n(), 0.0); + SymmetricSquareMatrix inv(matrix.m(), matrix.m(), 0.0); - for (label i = 0; i < matrix.n(); ++i) + for (label i = 0; i < matrix.m(); ++i) { inv[i][i] = 1.0/matrix[i][i]; @@ -75,7 +75,7 @@ Foam::scalar Foam::detDecomposed(const SymmetricSquareMatrix& matrix) { scalar diagProduct = 1.0; - for (label i = 0; i < matrix.n(); ++i) + for (label i = 0; i < matrix.m(); ++i) { diagProduct *= matrix[i][i]; } diff --git a/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.C b/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.C index 3b3092f3a6..bbe1e21483 100644 --- a/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.C +++ b/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,39 +33,39 @@ License Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) : U_(A), - V_(A.m(), A.m()), - S_(A.m()), - VSinvUt_(A.m(), A.n()), + V_(A.n(), A.n()), + S_(A.n()), + VSinvUt_(A.n(), A.m()), nZeros_(0) { // SVDcomp to find U_, V_ and S_ - the singular values - const label Um = U_.m(); const label Un = U_.n(); + const label Um = U_.m(); - scalarList rv1(Um); + scalarList rv1(Un); scalar g = 0; scalar scale = 0; scalar s = 0; scalar anorm = 0; label l = 0; - for (label i = 0; i < Um; i++) + for (label i = 0; i < Un; i++) { l = i+2; rv1[i] = scale*g; g = s = scale = 0; - if (i < Un) + if (i < Um) { - for (label k = i; k < Un; k++) + for (label k = i; k < Um; k++) { scale += mag(U_[k][i]); } if (scale != 0) { - for (label k = i; k < Un; k++) + for (label k = i; k < Um; k++) { U_[k][i] /= scale; s += U_[k][i]*U_[k][i]; @@ -76,22 +76,22 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) scalar h = f*g - s; U_[i][i] = f - g; - for (label j = l-1; j < Um; j++) + for (label j = l-1; j < Un; j++) { s = 0; - for (label k = i; k < Un; k++) + for (label k = i; k < Um; k++) { s += U_[k][i]*U_[k][j]; } f = s/h; - for (label k = i; k < A.n(); k++) + for (label k = i; k < A.m(); k++) { U_[k][j] += f*U_[k][i]; } } - for (label k = i; k < Un; k++) + for (label k = i; k < Um; k++) { U_[k][i] *= scale; } @@ -102,16 +102,16 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) g = s = scale = 0; - if (i+1 <= Un && i != Um) + if (i+1 <= Um && i != Un) { - for (label k = l-1; k < Um; k++) + for (label k = l-1; k < Un; k++) { scale += mag(U_[i][k]); } if (scale != 0) { - for (label k=l-1; k < Um; k++) + for (label k=l-1; k < Un; k++) { U_[i][k] /= scale; s += U_[i][k]*U_[i][k]; @@ -122,25 +122,25 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) scalar h = f*g - s; U_[i][l-1] = f - g; - for (label k = l-1; k < Um; k++) + for (label k = l-1; k < Un; k++) { rv1[k] = U_[i][k]/h; } - for (label j = l-1; j < Un; j++) + for (label j = l-1; j < Um; j++) { s = 0; - for (label k = l-1; k < Um; k++) + for (label k = l-1; k < Un; k++) { s += U_[j][k]*U_[i][k]; } - for (label k = l-1; k < Um; k++) + for (label k = l-1; k < Un; k++) { U_[j][k] += s*rv1[k]; } } - for (label k = l-1; k < Um; k++) + for (label k = l-1; k < Un; k++) { U_[i][k] *= scale; } @@ -150,33 +150,33 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) anorm = max(anorm, mag(S_[i]) + mag(rv1[i])); } - for (label i = Um-1; i >= 0; i--) + for (label i = Un-1; i >= 0; i--) { - if (i < Um-1) + if (i < Un-1) { if (g != 0) { - for (label j = l; j < Um; j++) + for (label j = l; j < Un; j++) { V_[j][i] = (U_[i][j]/U_[i][l])/g; } - for (label j=l; j < Um; j++) + for (label j=l; j < Un; j++) { s = 0; - for (label k = l; k < Um; k++) + for (label k = l; k < Un; k++) { s += U_[i][k]*V_[k][j]; } - for (label k = l; k < Um; k++) + for (label k = l; k < Un; k++) { V_[k][j] += s*V_[k][i]; } } } - for (label j = l; j < Um;j++) + for (label j = l; j < Un;j++) { V_[i][j] = V_[j][i] = 0.0; } @@ -187,12 +187,12 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) l = i; } - for (label i = min(Um, Un) - 1; i >= 0; i--) + for (label i = min(Un, Um) - 1; i >= 0; i--) { l = i+1; g = S_[i]; - for (label j = l; j < Um; j++) + for (label j = l; j < Un; j++) { U_[i][j] = 0.0; } @@ -201,30 +201,30 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) { g = 1.0/g; - for (label j = l; j < Um; j++) + for (label j = l; j < Un; j++) { s = 0; - for (label k = l; k < Un; k++) + for (label k = l; k < Um; k++) { s += U_[k][i]*U_[k][j]; } scalar f = (s/U_[i][i])*g; - for (label k = i; k < Un; k++) + for (label k = i; k < Um; k++) { U_[k][j] += f*U_[k][i]; } } - for (label j = i; j < Un; j++) + for (label j = i; j < Um; j++) { U_[j][i] *= g; } } else { - for (label j = i; j < Un; j++) + for (label j = i; j < Um; j++) { U_[j][i] = 0.0; } @@ -233,22 +233,22 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) ++U_[i][i]; } - for (label k = Um-1; k >= 0; k--) + for (label k = Un-1; k >= 0; k--) { for (label its = 0; its < 35; its++) { bool flag = true; - label nm; + label mn; for (l = k; l >= 0; l--) { - nm = l-1; + mn = l-1; if (mag(rv1[l]) + anorm == anorm) { flag = false; break; } - if (mag(S_[nm]) + anorm == anorm) break; + if (mag(S_[mn]) + anorm == anorm) break; } if (flag) @@ -269,11 +269,11 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) c = g*h; s = -f*h; - for (label j = 0; j < Un; j++) + for (label j = 0; j < Um; j++) { - scalar y = U_[j][nm]; + scalar y = U_[j][mn]; scalar z = U_[j][i]; - U_[j][nm] = y*c + z*s; + U_[j][mn] = y*c + z*s; U_[j][i] = z*c - y*s; } } @@ -287,21 +287,21 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) { S_[k] = -z; - for (label j = 0; j < Um; j++) V_[j][k] = -V_[j][k]; + for (label j = 0; j < Un; j++) V_[j][k] = -V_[j][k]; } break; } if (its == 34) { WarningInFunction - << "no convergence in 35 SVD iterations" + << "No convergence in 35 SVD iterations" << endl; } scalar x = S_[l]; - nm = k-1; - scalar y = S_[nm]; - g = rv1[nm]; + mn = k-1; + scalar y = S_[mn]; + g = rv1[mn]; scalar h = rv1[k]; scalar f = ((y - z)*(y + z) + (g - h)*(g + h))/(2.0*h*y); g = sqrtSumSqr(f, scalar(1)); @@ -309,7 +309,7 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) scalar c = 1.0; s = 1.0; - for (label j = l; j <= nm; j++) + for (label j = l; j <= mn; j++) { label i = j + 1; g = rv1[i]; @@ -325,7 +325,7 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) h = y*s; y *= c; - for (label jj = 0; jj < Um; jj++) + for (label jj = 0; jj < Un; jj++) { x = V_[jj][j]; z = V_[jj][i]; @@ -344,7 +344,7 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) f = c*g + s*y; x = c*y - s*g; - for (label jj=0; jj < Un; jj++) + for (label jj=0; jj < Um; jj++) { y = U_[jj][j]; z = U_[jj][i]; @@ -358,7 +358,7 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) } } - // zero singular values that are less than minCondition*maxS + // Zero singular values that are less than minCondition*maxS const scalar minS = minCondition*S_[findMax(S_)]; forAll(S_, i) { @@ -370,17 +370,18 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition) } } - // now multiply out to find the pseudo inverse of A, VSinvUt_ + // Now multiply out to find the pseudo inverse of A, VSinvUt_ multiply(VSinvUt_, V_, inv(S_), U_.T()); // test SVD - /*scalarRectangularMatrix SVDA(A.n(), A.m()); + /* + scalarRectangularMatrix SVDA(A.m(), A.n()); multiply(SVDA, U_, S_, transpose(V_)); scalar maxDiff = 0; scalar diff = 0; - for (label i = 0; i < A.n(); i++) + for (label i = 0; i < A.m(); i++) { - for (label j = 0; j < A.m(); j++) + for (label j = 0; j < A.n(); j++) { diff = mag(A[i][j] - SVDA[i][j]); if (diff > maxDiff) maxDiff = diff; diff --git a/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.H b/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.H index d1e38c9082..2f4a9dcb19 100644 --- a/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.H +++ b/src/OpenFOAM/matrices/scalarMatrices/SVD/SVD.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,7 +45,6 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - /*---------------------------------------------------------------------------*\ Class SVD Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.C b/src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.C index 46f4a3ee1d..46e972f729 100644 --- a/src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.C +++ b/src/OpenFOAM/matrices/scalarMatrices/scalarMatrices.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,17 +46,17 @@ void Foam::LUDecompose label& sign ) { - label n = matrix.n(); - scalar vv[n]; + label m = matrix.m(); + scalar vv[m]; sign = 1; - for (label i=0; i largestCoeff) { @@ -73,7 +73,7 @@ void Foam::LUDecompose vv[i] = 1.0/largestCoeff; } - for (label j=0; j=i; k--) + for (label k=m-1; k>=i; k--) { tmpMatrix[j][k] -= tmpMatrix[i][k]*tmpMatrix[j][i]/tmpMatrix[i][i]; @@ -87,11 +87,11 @@ void Foam::solve } // Back-substitution - for (label j=n-1; j>=0; j--) + for (label j=m-1; j>=0; j--) { Type ntempvec = pTraits::zero; - for (label k=j+1; k& sourceSol ) { - label n = luMatrix.n(); + label m = luMatrix.m(); label ii = 0; - for (label i=0; i=0; i--) + for (label i=m-1; i>=0; i--) { Type sum = sourceSol[i]; const scalar* __restrict__ luMatrixi = luMatrix[i]; - for (label j=i+1; j& sourceSol ) { - label n = luMatrix.n(); + label m = luMatrix.m(); label ii = 0; - for (label i=0; i=0; i--) + for (label i=m-1; i>=0; i--) { Type sum = sourceSol[i]; const scalar* __restrict__ luMatrixi = luMatrix[i]; - for (label j=i+1; j& sourceSol ) { - labelList pivotIndices(matrix.n()); + labelList pivotIndices(matrix.m()); LUDecompose(matrix, pivotIndices); LUBacksubstitute(matrix, pivotIndices, sourceSol); } @@ -243,21 +243,21 @@ void Foam::multiply const Matrix& B ) { - if (A.m() != B.n()) + if (A.n() != B.m()) { FatalErrorInFunction - << "A and B must have identical inner dimensions but A.m = " - << A.m() << " and B.n = " << B.n() + << "A and B must have identical inner dimensions but A.n = " + << A.n() << " and B.m = " << B.m() << abort(FatalError); } - ans = Matrix(A.n(), B.m(), scalar(0)); + ans = Matrix(A.m(), B.n(), scalar(0)); - for (label i = 0; i < A.n(); i++) + for (label i = 0; i < A.m(); i++) { - for (label j = 0; j < B.m(); j++) + for (label j = 0; j < B.n(); j++) { - for (label l = 0; l < B.n(); l++) + for (label l = 0; l < B.m(); l++) { ans[i][j] += A[i][l]*B[l][j]; } diff --git a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C index 727db535d5..960ba0d563 100644 --- a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C +++ b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -106,7 +106,7 @@ void Foam::simpleMatrix::operator=(const simpleMatrix& m) << abort(FatalError); } - if (n() != m.n()) + if (m() != m.m()) { FatalErrorInFunction << "Different size matrices" diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/CentredFitSnGrad/CentredFitSnGradData.C b/src/finiteVolume/finiteVolume/snGradSchemes/CentredFitSnGrad/CentredFitSnGradData.C index 96f5c8745c..8820a78e6c 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/CentredFitSnGrad/CentredFitSnGradData.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/CentredFitSnGrad/CentredFitSnGradData.C @@ -120,7 +120,7 @@ void Foam::CentredFitSnGradData::calcFit } // Additional weighting for constant and linear terms - for (label i = 0; i < B.n(); i++) + for (label i = 0; i < B.m(); i++) { B[i][0] *= wts[0]; B[i][1] *= wts[0]; @@ -172,13 +172,13 @@ void Foam::CentredFitSnGradData::calcFit wts[0] *= 10; wts[1] *= 10; - for (label j = 0; j < B.m(); j++) + for (label j = 0; j < B.n(); j++) { B[0][j] *= 10; B[1][j] *= 10; } - for (label i = 0; i < B.n(); i++) + for (label i = 0; i < B.m(); i++) { B[i][0] *= 10; B[i][1] *= 10; diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/FitData/FitData.C b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/FitData/FitData.C index ba213d0d08..bc86903cbc 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/schemes/FitData/FitData.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/schemes/FitData/FitData.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -194,7 +194,7 @@ void Foam::FitData::calcFit } // Additional weighting for constant and linear terms - for (label i = 0; i < B.n(); i++) + for (label i = 0; i < B.m(); i++) { B[i][0] *= wts[0]; B[i][1] *= wts[0]; @@ -267,13 +267,13 @@ void Foam::FitData::calcFit wts[1] *= 10; } - for (label j = 0; j < B.m(); j++) + for (label j = 0; j < B.n(); j++) { B[0][j] *= 10; B[1][j] *= 10; } - for (label i = 0; i < B.n(); i++) + for (label i = 0; i < B.m(); i++) { B[i][0] *= 10; B[i][1] *= 10; diff --git a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C index 56dd573370..71e34ab46d 100644 --- a/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C +++ b/src/thermophysicalModels/radiation/radiationModels/viewFactor/viewFactor.C @@ -232,7 +232,7 @@ void Foam::radiation::viewFactor::initialise() ) ); - pivotIndices_.setSize(CLU_().n()); + pivotIndices_.setSize(CLU_().m()); } } }