Commit 7cb9c39b authored by Andrew Heather's avatar Andrew Heather
Browse files
parents c5ccb67f 0bd5bc85
......@@ -27,7 +27,11 @@ int main()
Info<< magSqr(d) << endl;
vector d2(0.5, 0.51, -0.5);
Info<< cmptMax(d2) << " " << cmptSum(d2) << " " << cmptMag(d2) << endl;
Info<< cmptMax(d2) << " "
<< cmptSum(d2) << " "
<< cmptProduct(d2) << " "
<< cmptMag(d2)
<< endl;
Info<< min(d, d2) << endl;
return 0;
}
......@@ -145,6 +145,13 @@ void Foam::stableSort(UList<T>& a, const Cmp& cmp)
}
template<class T>
void Foam::shuffle(UList<T>& a)
{
std::random_shuffle(a.begin(), a.end());
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T>
......
......@@ -344,6 +344,9 @@ void stableSort(UList<T>&);
template<class T, class Cmp>
void stableSort(UList<T>&, const Cmp&);
template<class T>
void shuffle(UList<T>&);
// Reverse the first n elements of the list
template<class T>
inline void reverse(UList<T>&, const label n);
......
......@@ -152,6 +152,12 @@ public:
return ::Foam::mag(max_ - min_);
}
//- The volume of the bound box
scalar volume() const
{
return cmptProduct(span());
}
//- Smallest length/height/width dimension
scalar minDim() const
{
......
......@@ -406,6 +406,17 @@ inline Cmpt cmptAv
return cmptSum(vs)/nCmpt;
}
template<class Form, class Cmpt, int nCmpt>
inline Cmpt cmptProduct
(
const VectorSpace<Form, Cmpt, nCmpt>& vs
)
{
Cmpt product = vs.v_[0];
VectorSpaceOps<nCmpt,1>::SeqOp(product, vs, multiplyEqOp<Cmpt>());
return product;
}
template<class Form, class Cmpt, int nCmpt>
inline Form cmptMag
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment