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

View File

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

View File

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