Commit 1ec47384 authored by Henry Weller's avatar Henry Weller
Browse files

src/OpenFOAM/matrices: Reformatted for-loops consistently

parent a08adf25
......@@ -33,9 +33,9 @@ void Foam::LLTMatrix<Type>::decompose()
SquareMatrix<Type>& LLT = *this;
const label m = LLT.m();
for (label i = 0; i < m; i++)
for (label i=0; i<m; i++)
{
for (label j = 0; j < m; j++)
for (label j=0; j<m; j++)
{
if (j > i)
{
......@@ -45,7 +45,7 @@ void Foam::LLTMatrix<Type>::decompose()
Type sum = LLT(i, j);
for (label k = 0; k < j; k++)
for (label k=0; k<j; k++)
{
sum -= LLT(i, k)*LLT(j, k);
}
......@@ -93,11 +93,11 @@ void Foam::LLTMatrix<Type>::solve
const SquareMatrix<Type>& LLT = *this;
const label m = LLT.m();
for (label i = 0; i < m; i++)
for (label i=0; i<m; i++)
{
Type sum = source[i];
for (label j = 0; j < i; j++)
for (label j=0; j<i; j++)
{
sum = sum - LLT(i, j)*x[j];
}
......@@ -105,11 +105,11 @@ void Foam::LLTMatrix<Type>::solve
x[i] = sum/LLT(i, i);
}
for (int i = m - 1; i >= 0; i--)
for (int i=m - 1; i >= 0; i--)
{
Type sum = x[i];
for (label j = i + 1; j < m; j++)
for (label j=i + 1; j<m; j++)
{
sum = sum - LLT(j, i)*x[j];
}
......
......@@ -168,7 +168,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& M)
{
uniform = true;
for (label i=0; i< mn; i++)
for (label i=0; i<mn; i++)
{
if (v[i] != v[0])
{
......@@ -197,7 +197,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& M)
label k = 0;
// loop over rows
for (label i=0; i< M.m(); i++)
for (label i=0; i<M.m(); i++)
{
os << token::BEGIN_LIST;
......@@ -222,7 +222,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const Matrix<Form, Type>& M)
label k = 0;
// loop over rows
for (label i=0; i< M.m(); i++)
for (label i=0; i<M.m(); i++)
{
os << nl << token::BEGIN_LIST;
......
......@@ -86,7 +86,7 @@ inline Foam::RectangularMatrix<Type>::RectangularMatrix
:
Matrix<RectangularMatrix<Type>, Type>(n, n, Zero)
{
for (label i = 0; i < n; i++)
for (label i=0; i<n; i++)
{
this->operator()(i, i) = I;
}
......
......@@ -37,7 +37,7 @@ Foam::scalar Foam::detDecomposed
{
Type diagProduct = pTraits<Type>::one;
for (label i = 0; i < matrix.m(); i++)
for (label i=0; i<matrix.m(); i++)
{
diagProduct *= matrix(i, i);
}
......
......@@ -101,7 +101,7 @@ inline Foam::SquareMatrix<Type>::SquareMatrix
:
Matrix<SquareMatrix<Type>, Type>(n, n, Zero)
{
for (label i = 0; i < n; i++)
for (label i=0; i<n; i++)
{
this->operator()(i, i) = I;
}
......
......@@ -37,15 +37,15 @@ Foam::SymmetricSquareMatrix<Type> Foam::invDecomposed
SymmetricSquareMatrix<Type> inv(n, Zero);
for (label i = 0; i < n; i++)
for (label i=0; i<n; i++)
{
inv(i, i) = 1.0/matrix(i, i);
for (label j = 0; j < i; j++)
for (label j=0; j<i; j++)
{
Type sum = Zero;
for (label k = j; k < i; k++)
for (label k=j; k<i; k++)
{
sum -= matrix(i, k)*inv(k, j);
}
......@@ -56,11 +56,11 @@ Foam::SymmetricSquareMatrix<Type> Foam::invDecomposed
SymmetricSquareMatrix<Type> result(n, Zero);
for (label k = 0; k < n; k++)
for (label k=0; k<n; k++)
{
for (label i = 0; i <= k; i++)
for (label i=0; i <= k; i++)
{
for (label j = 0; j <= k; j++)
for (label j=0; j <= k; j++)
{
result(i, j) += inv(k, i)*inv(k, j);
}
......@@ -89,7 +89,7 @@ Type Foam::detDecomposed(const SymmetricSquareMatrix<Type>& matrix)
{
Type diagProduct = pTraits<Type>::one;
for (label i = 0; i < matrix.m(); i++)
for (label i=0; i<matrix.m(); i++)
{
diagProduct *= matrix(i, i);
}
......
......@@ -59,7 +59,7 @@ inline Foam::SymmetricSquareMatrix<Type>::SymmetricSquareMatrix
:
Matrix<SymmetricSquareMatrix<Type>, Type>(n, n, Zero)
{
for (label i = 0; i < n; i++)
for (label i=0; i<n; i++)
{
this->operator()(i, i) = pTraits<Type>::one;
}
......
......@@ -227,7 +227,7 @@ Foam::label Foam::lduAddressing::triIndex(const label a, const label b) const
const labelUList& neighbour = upperAddr();
for (label i = startLabel; i < endLabel; i++)
for (label i=startLabel; i<endLabel; i++)
{
if (neighbour[i] == nbr)
{
......
......@@ -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
......@@ -124,7 +124,7 @@ void Foam::lduMatrix::updateMatrixInterfaces
// Try and consume interfaces as they become available
bool allUpdated = false;
for (label i = 0; i < UPstream::nPollProcInterfaces; i++)
for (label i=0; i<UPstream::nPollProcInterfaces; i++)
{
allUpdated = true;
......
......@@ -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
......@@ -640,7 +640,7 @@ void Foam::GAMGAgglomeration::combineLevels(const label curLevel)
// {
// vals[0] = myVal;
//
// for (label i = 1; i < procIDs.size(); i++)
// for (label i=1; i<procIDs.size(); i++)
// {
// label& slaveVal = vals[i];
// IPstream::read
......
......@@ -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
......@@ -656,7 +656,7 @@ bool Foam::GAMGAgglomeration::checkRestriction
labelList& newCoarse = coarseToNewCoarse[coarseI];
newCoarse.setSize(masters.size());
newCoarse[0] = coarseI;
for (label i = 1; i < newCoarse.size(); i++)
for (label i=1; i<newCoarse.size(); i++)
{
newCoarse[i] = nNewCoarse++;
}
......
......@@ -44,7 +44,7 @@ void Foam::GAMGAgglomeration::gatherList
allVals.setSize(procIDs.size());
allVals[0] = myVal;
for (label i = 1; i < procIDs.size(); i++)
for (label i=1; i<procIDs.size(); i++)
{
IPstream fromSlave
(
......
......@@ -48,9 +48,9 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
scalar scale = 0;
scalar s = 0;
scalar anorm = 0;
label l = 0;
label l=0;
for (label i = 0; i < Un; i++)
for (label i=0; i<Un; i++)
{
l = i+2;
rv1[i] = scale*g;
......@@ -58,14 +58,14 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
if (i < Um)
{
for (label k = i; k < Um; k++)
for (label k=i; k<Um; k++)
{
scale += mag(U_(k, i));
}
if (scale != 0)
{
for (label k = i; k < Um; 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 < Un; j++)
for (label j=l-1; j<Un; j++)
{
s = 0;
for (label k = i; k < Um; k++)
for (label k=i; k<Um; k++)
{
s += U_(k, i)*U_(k, j);
}
f = s/h;
for (label k = i; k < A.m(); k++)
for (label k=i; k<A.m(); k++)
{
U_(k, j) += f*U_(k, i);
}
}
for (label k = i; k < Um; k++)
for (label k=i; k<Um; k++)
{
U_(k, i) *= scale;
}
......@@ -104,14 +104,14 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
if (i+1 <= Um && i != Un)
{
for (label k = l-1; k < Un; k++)
for (label k=l-1; k<Un; k++)
{
scale += mag(U_(i, k));
}
if (scale != 0)
{
for (label k=l-1; k < Un; 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 < Un; k++)
for (label k=l-1; k<Un; k++)
{
rv1[k] = U_(i, k)/h;
}
for (label j = l-1; j < Um; j++)
for (label j=l-1; j<Um; j++)
{
s = 0;
for (label k = l-1; k < Un; k++)
for (label k=l-1; k<Un; k++)
{
s += U_(j, k)*U_(i, k);
}
for (label k = l-1; k < Un; k++)
for (label k=l-1; k<Un; k++)
{
U_(j, k) += s*rv1[k];
}
}
for (label k = l-1; k < Un; 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 = Un-1; i >= 0; i--)
for (label i=Un-1; i >= 0; i--)
{
if (i < Un-1)
{
if (g != 0)
{
for (label j = l; j < Un; j++)
for (label j=l; j<Un; j++)
{
V_(j, i) = (U_(i, j)/U_(i, l))/g;
}
for (label j=l; j < Un; j++)
for (label j=l; j<Un; j++)
{
s = 0;
for (label k = l; k < Un; k++)
for (label k=l; k<Un; k++)
{
s += U_(i, k)*V_(k, j);
}
for (label k = l; k < Un; k++)
for (label k=l; k<Un; k++)
{
V_(k, j) += s*V_(k, i);
}
}
}
for (label j = l; j < Un;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(Un, Um) - 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 < Un; 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 < Un; j++)
for (label j=l; j<Un; j++)
{
s = 0;
for (label k = l; k < Um; 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 < Um; k++)
for (label k=i; k<Um; k++)
{
U_(k, j) += f*U_(k, i);
}
}
for (label j = i; j < Um; j++)
for (label j=i; j<Um; j++)
{
U_(j, i) *= g;
}
}
else
{
for (label j = i; j < Um; j++)
for (label j=i; j<Um; j++)
{
U_(j, i) = 0.0;
}
......@@ -233,7 +233,7 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
++U_(i, i);
}
for (label k = Un-1; k >= 0; k--)
for (label k=Un-1; k >= 0; k--)
{
for (label its = 0; its < 35; its++)
{
......@@ -255,7 +255,7 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
{
scalar c = 0.0;
s = 1.0;
for (label i = l; i < k+1; i++)
for (label i=l; i<k+1; i++)
{
scalar f = s*rv1[i];
rv1[i] = c*rv1[i];
......@@ -269,7 +269,7 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
c = g*h;
s = -f*h;
for (label j = 0; j < Um; j++)
for (label j=0; j<Um; j++)
{
scalar y = U_[j][mn];
scalar z = U_(j, i);
......@@ -287,7 +287,7 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
{
S_[k] = -z;
for (label j = 0; j < Un; j++) V_(j, k) = -V_(j, k);
for (label j=0; j<Un; j++) V_(j, k) = -V_(j, k);
}
break;
}
......@@ -309,9 +309,9 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
scalar c = 1.0;
s = 1.0;
for (label j = l; j <= mn; j++)
for (label j=l; j <= mn; j++)
{
label i = j + 1;
label i=j + 1;
g = rv1[i];
y = S_[i];
h = s*g;
......@@ -379,9 +379,9 @@ Foam::SVD::SVD(const scalarRectangularMatrix& A, const scalar minCondition)
multiply(SVDA, U_, S_, transpose(V_));
scalar maxDiff = 0;
scalar diff = 0;
for (label i = 0; i < A.m(); i++)
for (label i=0; i<A.m(); i++)
{
for (label j = 0; j < A.n(); j++)
for (label j=0; j<A.n(); j++)
{
diff = mag(A(i, j) - SVDA(i, j));
if (diff > maxDiff) maxDiff = diff;
......
......@@ -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
......@@ -62,7 +62,7 @@ inline Foam::label Foam::SVD::nZeros() const
inline Foam::scalar Foam::SVD::minNonZeroS() const
{
scalar minS = S_[0];
for (label i = 1; i < S_.size(); i++)
for (label i=1; i<S_.size(); i++)
{
scalar s = S_[i];
if (s > VSMALL && s < minS) minS = s;
......
......@@ -151,23 +151,23 @@ void Foam::LUDecompose(scalarSymmetricSquareMatrix& matrix)
label size = matrix.m();
// Set upper triangular parts to zero.
for (label j = 0; j < size; j++)
for (label j=0; j<size; j++)
{
for (label k = j + 1; k < size; k++)
for (label k=j + 1; k<size; k++)
{
matrix(j, k) = 0.0;
}
}
for (label j = 0; j < size; j++)
for (label j=0; j<size; j++)
{
scalar d = 0.0;
for (label k = 0; k < j; k++)
for (label k=0; k<j; k++)
{
scalar s = 0.0;
for (label i = 0; i < k; i++)
for (label i=0; i<k; i++)
{
s += matrix(i, k)*matrix(i, j);
}
......@@ -223,14 +223,14 @@ void Foam::multiply
ans = scalarRectangularMatrix(A.m(), C.n(), scalar(0));
for (label i = 0; i < A.m(); i++)
for (label i=0; i<A.m(); i++)
{
for (label g = 0; g < C.n(); g++)
{
for (label l = 0; l < C.m(); l++)
for (label l=0; l<C.m(); l++)
{
scalar ab = 0;
for (label j = 0; j < A.n(); j++)
for (label j=0; j<A.n(); j++)
{
ab += A(i, j)*B(j, l);
}
......@@ -267,11 +267,11 @@ void Foam::multiply
ans = scalarRectangularMatrix(A.m(), C.n(), scalar(0));
for (label i = 0; i < A.m(); i++)
for (label i=0; i<A.m(); i++)
{
for (label g = 0; g < C.n(); g++)
{
for (label l = 0; l < C.m(); l++)
for (label l=0; l<C.m(); l++)
{
ans(i, g) += C(l, g) * A(i, l)*B[l];
}
......
......@@ -251,11 +251,11 @@ void Foam::multiply
ans = Matrix<Form, Type>(A.m(), B.n(), scalar(0));