VectorSpace: Change template parameter from nCmpt to Ncmpts for consistency with other template classes

This commit is contained in:
Henry Weller 2016-03-10 12:44:53 +00:00
parent 7c692c18d8
commit 2ddcb12c67
3 changed files with 227 additions and 228 deletions

View File

@ -30,44 +30,44 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Form, class Cmpt, Foam::direction nCmpt>
Foam::VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
template<class Form, class Cmpt, Foam::direction Ncmpts>
Foam::VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
(
Istream& is
)
{
// Read beginning of VectorSpace<Cmpt>
is.readBegin("VectorSpace<Form, Cmpt, nCmpt>");
is.readBegin("VectorSpace<Form, Cmpt, Ncmpts>");
for (direction i=0; i<nCmpt; i++)
for (direction i=0; i<Ncmpts; i++)
{
is >> v_[i];
}
// Read end of VectorSpace<Cmpt>
is.readEnd("VectorSpace<Form, Cmpt, nCmpt>");
is.readEnd("VectorSpace<Form, Cmpt, Ncmpts>");
// Check state of Istream
is.check("VectorSpace<Form, Cmpt, nCmpt>::VectorSpace(Istream&)");
is.check("VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace(Istream&)");
}
template<class Form, class Cmpt, Foam::direction nCmpt>
template<class Form, class Cmpt, Foam::direction Ncmpts>
Foam::word Foam::name
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
std::ostringstream buf;
buf << '(';
for (direction i=0; i<nCmpt-1; i++)
for (direction i=0; i<Ncmpts-1; i++)
{
buf << vs.v_[i] << ',';
}
buf << vs.v_[nCmpt-1] << ')';
buf << vs.v_[Ncmpts-1] << ')';
return buf.str();
}
@ -75,41 +75,41 @@ Foam::word Foam::name
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Form, class Cmpt, Foam::direction nCmpt>
template<class Form, class Cmpt, Foam::direction Ncmpts>
Foam::Istream& Foam::operator>>
(
Istream& is,
VectorSpace<Form, Cmpt, nCmpt>& vs
VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
// Read beginning of VectorSpace<Cmpt, nCmpt>
is.readBegin("VectorSpace<Form, Cmpt, nCmpt>");
// Read beginning of VectorSpace<Cmpt, Ncmpts>
is.readBegin("VectorSpace<Form, Cmpt, Ncmpts>");
for (direction i=0; i<nCmpt; i++)
for (direction i=0; i<Ncmpts; i++)
{
is >> vs.v_[i];
}
// Read end of VectorSpace<Cmpt, nCmpt>
is.readEnd("VectorSpace<Form, Cmpt, nCmpt>");
// Read end of VectorSpace<Cmpt, Ncmpts>
is.readEnd("VectorSpace<Form, Cmpt, Ncmpts>");
// Check state of Istream
is.check("operator>>(Istream&, VectorSpace<Form, Cmpt, nCmpt>&)");
is.check("operator>>(Istream&, VectorSpace<Form, Cmpt, Ncmpts>&)");
return is;
}
template<class Form, class Cmpt, Foam::direction nCmpt>
template<class Form, class Cmpt, Foam::direction Ncmpts>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
os << token::BEGIN_LIST << vs.v_[0];
for (direction i=1; i<nCmpt; i++)
for (direction i=1; i<Ncmpts; i++)
{
os << token::SPACE << vs.v_[i];
}
@ -117,7 +117,7 @@ Foam::Ostream& Foam::operator<<
os << token::END_LIST;
// Check state of Ostream
os.check("operator<<(Ostream&, const VectorSpace<Form, Cmpt, nCmpt>&)");
os.check("operator<<(Ostream&, const VectorSpace<Form, Cmpt, Ncmpts>&)");
return os;
}

View File

@ -51,20 +51,20 @@ namespace Foam
// Forward declaration of friend functions and operators
template<class Form, class Cmpt, direction nCmpt> class VectorSpace;
template<class Form, class Cmpt, direction Ncmpts> class VectorSpace;
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
Istream& operator>>
(
Istream&,
VectorSpace<Form, Cmpt, nCmpt>&
VectorSpace<Form, Cmpt, Ncmpts>&
);
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
Ostream& operator<<
(
Ostream&,
const VectorSpace<Form, Cmpt, nCmpt>&
const VectorSpace<Form, Cmpt, Ncmpts>&
);
@ -72,18 +72,17 @@ Ostream& operator<<
Class VectorSpace Declaration
\*---------------------------------------------------------------------------*/
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
class VectorSpace
{
public:
//- The components of this vector space
Cmpt v_[nCmpt];
Cmpt v_[Ncmpts];
//- VectorSpace type
typedef VectorSpace<Form, Cmpt, nCmpt> vsType;
typedef VectorSpace<Form, Cmpt, Ncmpts> vsType;
//- Component type
typedef Cmpt cmptType;
@ -91,11 +90,11 @@ public:
// Member constants
enum
{
dim = 3, //!< Dimensionality of space
nComponents = nCmpt //!< Number of components in this vector space
};
//- Dimensionality of space
static const direction dim = 3;
//- Number of components in this vector space
static const direction nComponents = Ncmpts;
// Static data members
@ -116,23 +115,23 @@ public:
inline VectorSpace();
//- Construct initialized to zero
inline VectorSpace(const Foam::zero);
inline explicit VectorSpace(const Foam::zero);
//- Construct from Istream
VectorSpace(Istream&);
//- Construct as copy
inline VectorSpace(const VectorSpace<Form, Cmpt, nCmpt>&);
inline VectorSpace(const VectorSpace<Form, Cmpt, Ncmpts>&);
//- Construct as copy of another VectorSpace type of the same rank
template<class Form2, class Cmpt2>
inline VectorSpace(const VectorSpace<Form2, Cmpt2, nCmpt>&);
inline VectorSpace(const VectorSpace<Form2, Cmpt2, Ncmpts>&);
// Member Functions
//- Return the number of elements in the VectorSpace = nCmpt.
inline label size() const;
//- Return the number of elements in the VectorSpace = Ncmpts.
inline static direction size();
inline const Cmpt& component(const direction) const;
inline Cmpt& component(const direction);
@ -149,9 +148,9 @@ public:
inline const Cmpt& operator[](const direction) const;
inline Cmpt& operator[](const direction);
inline void operator=(const VectorSpace<Form, Cmpt, nCmpt>&);
inline void operator+=(const VectorSpace<Form, Cmpt, nCmpt>&);
inline void operator-=(const VectorSpace<Form, Cmpt, nCmpt>&);
inline void operator=(const VectorSpace<Form, Cmpt, Ncmpts>&);
inline void operator+=(const VectorSpace<Form, Cmpt, Ncmpts>&);
inline void operator-=(const VectorSpace<Form, Cmpt, Ncmpts>&);
inline void operator=(const Foam::zero);
inline void operator*=(const scalar);
@ -160,16 +159,16 @@ public:
// IOstream Operators
friend Istream& operator>> <Form, Cmpt, nCmpt>
friend Istream& operator>> <Form, Cmpt, Ncmpts>
(
Istream&,
VectorSpace<Form, Cmpt, nCmpt>&
VectorSpace<Form, Cmpt, Ncmpts>&
);
friend Ostream& operator<< <Form, Cmpt, nCmpt>
friend Ostream& operator<< <Form, Cmpt, Ncmpts>
(
Ostream&,
const VectorSpace<Form, Cmpt, nCmpt>&
const VectorSpace<Form, Cmpt, Ncmpts>&
);
};
@ -177,8 +176,8 @@ public:
// * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * * //
//- Return a string representation of a VectorSpace
template<class Form, class Cmpt, direction nCmpt>
word name(const VectorSpace<Form, Cmpt, nCmpt>&);
template<class Form, class Cmpt, direction Ncmpts>
word name(const VectorSpace<Form, Cmpt, Ncmpts>&);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -35,56 +35,56 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Form, class Cmpt, direction nCmpt>
inline VectorSpace<Form, Cmpt, nCmpt>::VectorSpace()
template<class Form, class Cmpt, direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace()
{}
template<class Form, class Cmpt, direction nCmpt>
inline VectorSpace<Form, Cmpt, nCmpt>::VectorSpace(const Foam::zero z)
template<class Form, class Cmpt, direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace(const Foam::zero z)
{
VectorSpaceOps<nCmpt,0>::eqOpS(*this, 0, eqOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, 0, eqOp<Cmpt>());
}
template<class Form, class Cmpt, direction nCmpt>
inline VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
template<class Form, class Cmpt, direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
VectorSpaceOps<nCmpt,0>::eqOp(*this, vs, eqOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOp(*this, vs, eqOp<Cmpt>());
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
template<class Form2, class Cmpt2>
inline VectorSpace<Form, Cmpt, nCmpt>::VectorSpace
inline VectorSpace<Form, Cmpt, Ncmpts>::VectorSpace
(
const VectorSpace<Form2, Cmpt2, nCmpt>& vs
const VectorSpace<Form2, Cmpt2, Ncmpts>& vs
)
{
VectorSpaceOps<nCmpt,0>::eqOp(*this, vs, eqOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOp(*this, vs, eqOp<Cmpt>());
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Form, class Cmpt, direction nCmpt>
inline label VectorSpace<Form, Cmpt, nCmpt>::size() const
template<class Form, class Cmpt, direction Ncmpts>
inline direction VectorSpace<Form, Cmpt, Ncmpts>::size()
{
return nCmpt;
return Ncmpts;
}
template<class Form, class Cmpt, direction nCmpt>
inline const Cmpt& VectorSpace<Form, Cmpt, nCmpt>::component
template<class Form, class Cmpt, direction Ncmpts>
inline const Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::component
(
const direction d
) const
{
#ifdef FULLDEBUG
if (d >= nCmpt)
if (d >= Ncmpts)
{
FatalErrorInFunction
<< "index out of range"
@ -96,14 +96,14 @@ inline const Cmpt& VectorSpace<Form, Cmpt, nCmpt>::component
}
template<class Form, class Cmpt, direction nCmpt>
inline Cmpt& VectorSpace<Form, Cmpt, nCmpt>::component
template<class Form, class Cmpt, direction Ncmpts>
inline Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::component
(
const direction d
)
{
#ifdef FULLDEBUG
if (d >= nCmpt)
if (d >= Ncmpts)
{
FatalErrorInFunction
<< "index out of range"
@ -115,15 +115,15 @@ inline Cmpt& VectorSpace<Form, Cmpt, nCmpt>::component
}
template<class Form, class Cmpt, direction nCmpt>
inline void VectorSpace<Form, Cmpt, nCmpt>::component
template<class Form, class Cmpt, direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::component
(
Cmpt& c,
const direction d
) const
{
#ifdef FULLDEBUG
if (d >= nCmpt)
if (d >= Ncmpts)
{
FatalErrorInFunction
<< "index out of range"
@ -135,15 +135,15 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::component
}
template<class Form, class Cmpt, direction nCmpt>
inline void VectorSpace<Form, Cmpt, nCmpt>::replace
template<class Form, class Cmpt, direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::replace
(
const direction d,
const Cmpt& c
)
{
#ifdef FULLDEBUG
if (d >= nCmpt)
if (d >= Ncmpts)
{
FatalErrorInFunction
<< "index out of range"
@ -155,25 +155,25 @@ inline void VectorSpace<Form, Cmpt, nCmpt>::replace
}
template<class Form, class Cmpt, direction nCmpt>
inline Form VectorSpace<Form, Cmpt, nCmpt>::uniform(const Cmpt& s)
template<class Form, class Cmpt, direction Ncmpts>
inline Form VectorSpace<Form, Cmpt, Ncmpts>::uniform(const Cmpt& s)
{
Form v;
VectorSpaceOps<nCmpt,0>::eqOpS(v, s, eqOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOpS(v, s, eqOp<Cmpt>());
return v;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Form, class Cmpt, direction nCmpt>
inline const Cmpt& VectorSpace<Form, Cmpt, nCmpt>::operator[]
template<class Form, class Cmpt, direction Ncmpts>
inline const Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::operator[]
(
const direction d
) const
{
#ifdef FULLDEBUG
if (d >= nCmpt)
if (d >= Ncmpts)
{
FatalErrorInFunction
<< "index out of range"
@ -185,14 +185,14 @@ inline const Cmpt& VectorSpace<Form, Cmpt, nCmpt>::operator[]
}
template<class Form, class Cmpt, direction nCmpt>
inline Cmpt& VectorSpace<Form, Cmpt, nCmpt>::operator[]
template<class Form, class Cmpt, direction Ncmpts>
inline Cmpt& VectorSpace<Form, Cmpt, Ncmpts>::operator[]
(
const direction d
)
{
#ifdef FULLDEBUG
if (d >= nCmpt)
if (d >= Ncmpts)
{
FatalErrorInFunction
<< "index out of range"
@ -204,69 +204,69 @@ inline Cmpt& VectorSpace<Form, Cmpt, nCmpt>::operator[]
}
template<class Form, class Cmpt, direction nCmpt>
inline void VectorSpace<Form, Cmpt, nCmpt>::operator=
template<class Form, class Cmpt, direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator=
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
VectorSpaceOps<nCmpt,0>::eqOp(*this, vs, eqOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOp(*this, vs, eqOp<Cmpt>());
}
template<class Form, class Cmpt, direction nCmpt>
inline void VectorSpace<Form, Cmpt, nCmpt>::operator+=
template<class Form, class Cmpt, direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator+=
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
VectorSpaceOps<nCmpt,0>::eqOp(*this, vs, plusEqOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOp(*this, vs, plusEqOp<Cmpt>());
}
template<class Form, class Cmpt, direction nCmpt>
inline void VectorSpace<Form, Cmpt, nCmpt>::operator-=
template<class Form, class Cmpt, direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator-=
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
VectorSpaceOps<nCmpt,0>::eqOp(*this, vs, minusEqOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOp(*this, vs, minusEqOp<Cmpt>());
}
template<class Form, class Cmpt, direction nCmpt>
inline void VectorSpace<Form, Cmpt, nCmpt>::operator=(const Foam::zero)
template<class Form, class Cmpt, direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator=(const Foam::zero)
{
VectorSpaceOps<nCmpt,0>::eqOpS(*this, 0, eqOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, 0, eqOp<Cmpt>());
}
template<class Form, class Cmpt, direction nCmpt>
inline void VectorSpace<Form, Cmpt, nCmpt>::operator*=
template<class Form, class Cmpt, direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator*=
(
const scalar s
)
{
VectorSpaceOps<nCmpt,0>::eqOpS(*this, s, multiplyEqOp2<Cmpt, scalar>());
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, s, multiplyEqOp2<Cmpt, scalar>());
}
template<class Form, class Cmpt, direction nCmpt>
inline void VectorSpace<Form, Cmpt, nCmpt>::operator/=
template<class Form, class Cmpt, direction Ncmpts>
inline void VectorSpace<Form, Cmpt, Ncmpts>::operator/=
(
const scalar s
)
{
VectorSpaceOps<nCmpt,0>::eqOpS(*this, s, divideEqOp2<Cmpt, scalar>());
VectorSpaceOps<Ncmpts,0>::eqOpS(*this, s, divideEqOp2<Cmpt, scalar>());
}
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Cmpt& setComponent
(
VectorSpace<Form, Cmpt, nCmpt>& vs,
VectorSpace<Form, Cmpt, Ncmpts>& vs,
const direction d
)
{
@ -274,10 +274,10 @@ inline Cmpt& setComponent
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline const Cmpt& component
(
const VectorSpace<Form, Cmpt, nCmpt>& vs,
const VectorSpace<Form, Cmpt, Ncmpts>& vs,
const direction d
)
{
@ -288,10 +288,10 @@ inline const Cmpt& component
// Powers of a Form
// Equivalent to outer-products between the Form and itself
// Form^0 = 1.0
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline typename powProduct<Form, 0>::type pow
(
const VectorSpace<Form, Cmpt, nCmpt>&,
const VectorSpace<Form, Cmpt, Ncmpts>&,
typename powProduct<Form, 0>::type
= pTraits<typename powProduct<Form, 0>::type>::zero
)
@ -300,10 +300,10 @@ inline typename powProduct<Form, 0>::type pow
}
// Form^1 = Form
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline typename powProduct<Form, 1>::type pow
(
const VectorSpace<Form, Cmpt, nCmpt>& v,
const VectorSpace<Form, Cmpt, Ncmpts>& v,
typename powProduct<Form, 1>::type
= pTraits<typename powProduct<Form, 1>::type>::zero
)
@ -313,10 +313,10 @@ inline typename powProduct<Form, 1>::type pow
// Form^2 = sqr(Form)
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline typename powProduct<Form, 2>::type pow
(
const VectorSpace<Form, Cmpt, nCmpt>& v,
const VectorSpace<Form, Cmpt, Ncmpts>& v,
typename powProduct<Form, 2>::type
= pTraits<typename powProduct<Form, 2>::type>::zero
)
@ -325,184 +325,184 @@ inline typename powProduct<Form, 2>::type pow
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline scalar magSqr
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
scalar ms = magSqr(vs.v_[0]);
VectorSpaceOps<nCmpt,1>::SeqOp(ms, vs, plusEqMagSqrOp2<scalar, Cmpt>());
VectorSpaceOps<Ncmpts,1>::SeqOp(ms, vs, plusEqMagSqrOp2<scalar, Cmpt>());
return ms;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline scalar mag
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
return ::sqrt(magSqr(static_cast<const Form&>(vs)));
}
template<class Form, class Cmpt, direction nCmpt>
inline VectorSpace<Form, Cmpt, nCmpt> cmptMultiply
template<class Form, class Cmpt, direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts> cmptMultiply
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
Form v;
VectorSpaceOps<nCmpt,0>::op(v, vs1, vs2, cmptMultiplyOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::op(v, vs1, vs2, cmptMultiplyOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
inline VectorSpace<Form, Cmpt, nCmpt> cmptPow
template<class Form, class Cmpt, direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts> cmptPow
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
Form v;
VectorSpaceOps<nCmpt,0>::op(v, vs1, vs2, cmptPowOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::op(v, vs1, vs2, cmptPowOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
inline VectorSpace<Form, Cmpt, nCmpt> cmptDivide
template<class Form, class Cmpt, direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts> cmptDivide
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
Form v;
VectorSpaceOps<nCmpt,0>::op(v, vs1, vs2, cmptDivideOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::op(v, vs1, vs2, cmptDivideOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
inline VectorSpace<Form, Cmpt, nCmpt> stabilise
template<class Form, class Cmpt, direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts> stabilise
(
const VectorSpace<Form, Cmpt, nCmpt>& vs,
const VectorSpace<Form, Cmpt, Ncmpts>& vs,
const Cmpt& small
)
{
Form v;
VectorSpaceOps<nCmpt,0>::opVS(v, vs, small, stabiliseOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::opVS(v, vs, small, stabiliseOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Cmpt cmptMax
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
Cmpt cMax = vs.v_[0];
VectorSpaceOps<nCmpt,1>::SeqOp(cMax, vs, maxEqOp<Cmpt>());
VectorSpaceOps<Ncmpts,1>::SeqOp(cMax, vs, maxEqOp<Cmpt>());
return cMax;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Cmpt cmptMin
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
Cmpt cMin = vs.v_[0];
VectorSpaceOps<nCmpt,1>::SeqOp(cMin, vs, minEqOp<Cmpt>());
VectorSpaceOps<Ncmpts,1>::SeqOp(cMin, vs, minEqOp<Cmpt>());
return cMin;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Cmpt cmptSum
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
Cmpt sum = vs.v_[0];
VectorSpaceOps<nCmpt,1>::SeqOp(sum, vs, plusEqOp<Cmpt>());
VectorSpaceOps<Ncmpts,1>::SeqOp(sum, vs, plusEqOp<Cmpt>());
return sum;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Cmpt cmptAv
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
return cmptSum(vs)/nCmpt;
return cmptSum(vs)/Ncmpts;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Cmpt cmptProduct
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
Cmpt product = vs.v_[0];
VectorSpaceOps<nCmpt,1>::SeqOp(product, vs, multiplyEqOp<Cmpt>());
VectorSpaceOps<Ncmpts,1>::SeqOp(product, vs, multiplyEqOp<Cmpt>());
return product;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form cmptMag
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
Form v;
VectorSpaceOps<nCmpt,0>::eqOp(v, vs, eqMagOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOp(v, vs, eqMagOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form max
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
Form v;
VectorSpaceOps<nCmpt,0>::op(v, vs1, vs2, maxOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::op(v, vs1, vs2, maxOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form min
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
Form v;
VectorSpaceOps<nCmpt,0>::op(v, vs1, vs2, minOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::op(v, vs1, vs2, minOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form minMod
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
Form v;
VectorSpaceOps<nCmpt,0>::op(v, vs1, vs2, minModOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::op(v, vs1, vs2, minModOp<Cmpt>());
return v;
}
@ -523,13 +523,13 @@ inline Type dot(const Type& t, const scalar s)
template
<
class Form1, class Cmpt1, direction nCmpt1,
class Form2, class Cmpt2, direction nCmpt2
class Form1, class Cmpt1, direction Ncmpts1,
class Form2, class Cmpt2, direction Ncmpts2
>
inline typename innerProduct<Form1, Form2>::type dot
(
const VectorSpace<Form1, Cmpt1, nCmpt1>& t1,
const VectorSpace<Form2, Cmpt2, nCmpt2>& t2
const VectorSpace<Form1, Cmpt1, Ncmpts1>& t1,
const VectorSpace<Form2, Cmpt2, Ncmpts2>& t2
)
{
return static_cast<const Form1&>(t1) & static_cast<const Form2&>(t2);
@ -538,118 +538,118 @@ inline typename innerProduct<Form1, Form2>::type dot
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form operator-
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
Form v;
VectorSpaceOps<nCmpt,0>::eqOp(v, vs, eqMinusOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::eqOp(v, vs, eqMinusOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form operator+
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
Form v;
VectorSpaceOps<nCmpt,0>::op(v, vs1, vs2, plusOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::op(v, vs1, vs2, plusOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form operator-
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
Form v;
VectorSpaceOps<nCmpt,0>::op(v, vs1, vs2, minusOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::op(v, vs1, vs2, minusOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form operator*
(
scalar s,
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
Form v;
VectorSpaceOps<nCmpt,0>::opSV(v, s, vs, multiplyOp3<Cmpt, scalar, Cmpt>());
VectorSpaceOps<Ncmpts,0>::opSV(v, s, vs, multiplyOp3<Cmpt, scalar, Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form operator*
(
const VectorSpace<Form, Cmpt, nCmpt>& vs,
const VectorSpace<Form, Cmpt, Ncmpts>& vs,
scalar s
)
{
Form v;
VectorSpaceOps<nCmpt,0>::opVS(v, vs, s, multiplyOp3<Cmpt, Cmpt, scalar>());
VectorSpaceOps<Ncmpts,0>::opVS(v, vs, s, multiplyOp3<Cmpt, Cmpt, scalar>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form operator/
(
const VectorSpace<Form, Cmpt, nCmpt>& vs,
const VectorSpace<Form, Cmpt, Ncmpts>& vs,
scalar s
)
{
Form v;
VectorSpaceOps<nCmpt,0>::opVS(v, vs, s, divideOp3<Cmpt, Cmpt, scalar>());
VectorSpaceOps<Ncmpts,0>::opVS(v, vs, s, divideOp3<Cmpt, Cmpt, scalar>());
return v;
}
/*
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form operator/
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
Form v;
VectorSpaceOps<nCmpt,0>::op(v, vs1, vs2, divideOp<Cmpt>());
VectorSpaceOps<Ncmpts,0>::op(v, vs1, vs2, divideOp<Cmpt>());
return v;
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Form operator/
(
scalar s,
const VectorSpace<Form, Cmpt, nCmpt>& vs
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
Form v;
VectorSpaceOps<nCmpt,0>::opSV(v, s, vs, divideOp2<scalar, Cmpt>());
VectorSpaceOps<Ncmpts,0>::opSV(v, s, vs, divideOp2<scalar, Cmpt>());
return v;
}
*/
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline Cmpt operator&&
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
Cmpt ddProd = vs1.v_[0]*vs2.v_[0];
for (direction i=1; i<nCmpt; ++i)
for (direction i=1; i<Ncmpts; ++i)
{
ddProd += vs1.v_[i]*vs2.v_[i];
}
@ -657,15 +657,15 @@ inline Cmpt operator&&
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator==
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
bool eq = true;
for (direction i=0; i<nCmpt; ++i)
for (direction i=0; i<Ncmpts; ++i)
{
if (!(eq &= (equal(vs1.v_[i], vs2.v_[i])))) break;
}
@ -673,26 +673,26 @@ inline bool operator==
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator!=
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
return !(vs1 == vs2);
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator>
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
bool gt = true;
for (direction i=0; i<nCmpt; ++i)
for (direction i=0; i<Ncmpts; ++i)
{
if (!(gt &= vs1.v_[i] > vs2.v_[i])) break;
}
@ -700,15 +700,15 @@ inline bool operator>
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator<
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
bool lt = true;
for (direction i=0; i<nCmpt; ++i)
for (direction i=0; i<Ncmpts; ++i)
{
if (!(lt &= vs1.v_[i] < vs2.v_[i])) break;
}
@ -716,22 +716,22 @@ inline bool operator<
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator>=
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
return !(vs1 < vs2);
}
template<class Form, class Cmpt, direction nCmpt>
template<class Form, class Cmpt, direction Ncmpts>
inline bool operator<=
(
const VectorSpace<Form, Cmpt, nCmpt>& vs1,
const VectorSpace<Form, Cmpt, nCmpt>& vs2
const VectorSpace<Form, Cmpt, Ncmpts>& vs1,
const VectorSpace<Form, Cmpt, Ncmpts>& vs2
)
{
return !(vs1 > vs2);