COMP: merge conflict

This commit is contained in:
andy
2010-10-11 17:59:46 +01:00
362 changed files with 7478 additions and 23939 deletions

View File

@ -33,7 +33,50 @@ Foam::Polynomial<PolySize>::Polynomial()
VectorSpace<Polynomial<PolySize>, scalar, PolySize>(),
logActive_(false),
logCoeff_(0.0)
{}
{
for (int i = 0; i < PolySize; ++i)
{
this->v_[i] = 0.0;
}
}
template<int PolySize>
Foam::Polynomial<PolySize>::Polynomial(const scalar coeffs[PolySize])
:
VectorSpace<Polynomial<PolySize>, scalar, PolySize>(),
logActive_(false),
logCoeff_(0.0)
{
for (int i=0; i<PolySize; i++)
{
this->v_[i] = coeffs[i];
}
}
template<int PolySize>
Foam::Polynomial<PolySize>::Polynomial(const UList<scalar>& coeffs)
:
VectorSpace<Polynomial<PolySize>, scalar, PolySize>(),
logActive_(false),
logCoeff_(0.0)
{
if (coeffs.size() != PolySize)
{
FatalErrorIn
(
"Polynomial<PolySize>::Polynomial(const UList<scalar>&)"
) << "Size mismatch: Needed " << PolySize
<< " but got " << coeffs.size()
<< nl << exit(FatalError);
}
for (int i = 0; i < PolySize; ++i)
{
this->v_[i] = coeffs[i];
}
}
template<int PolySize>
@ -110,9 +153,12 @@ Foam::scalar Foam::Polynomial<PolySize>::evaluate(const scalar x) const
{
scalar y = this->v_[0];
for (label i=1; i<PolySize; i++)
// avoid costly pow() in calculation
scalar powX = x;
for (label i=1; i<PolySize; ++i)
{
y += this->v_[i]*pow(x, i);
y += this->v_[i]*powX;
powX *= x;
}
if (logActive_)
@ -179,13 +225,9 @@ Foam::Polynomial<PolySize>::integrateMinus1(const scalar intConstant)
}
newCoeffs[0] = intConstant;
if (PolySize > 0)
for (label i=1; i<PolySize; ++i)
{
for (label i=1; i<PolySize; i++)
{
newCoeffs[i] = this->v_[i]/i;
}
newCoeffs[i] = this->v_[i]/i;
}
return newCoeffs;

View File

@ -29,7 +29,7 @@ Description
poly = logCoeff*log(x) + sum(coeff_[i]*x^i)
where 0 <= i <= n
where 0 \<= i \<= n
- integer powers, starting at zero
- evaluate(x) to evaluate the poly for a given value
@ -51,6 +51,7 @@ SourceFiles
#include "scalar.H"
#include "Ostream.H"
#include "VectorSpace.H"
#include "StaticAssert.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -79,6 +80,9 @@ class Polynomial
:
public VectorSpace<Polynomial<PolySize>, scalar, PolySize>
{
//- Size must be positive (non-zero)
StaticAssert(PolySize > 0);
// Private data
//- Include the log term? - only activated using integrateMinus1()
@ -97,9 +101,15 @@ public:
// Constructors
//- Construct null
//- Construct null, with all coefficients = 0.0
Polynomial();
//- Construct from C-array of coefficients
explicit Polynomial(const scalar coeffs[PolySize]);
//- Construct from a list of coefficients
explicit Polynomial(const UList<scalar>& coeffs);
//- Construct from Istream
Polynomial(Istream& is);