ENH: Field: add maxMagSqr op

This commit is contained in:
mattijs
2013-10-14 14:50:44 +01:00
parent 20a3d67c93
commit 8f2e21952b
2 changed files with 67 additions and 0 deletions

View File

@ -358,6 +358,59 @@ Type sum(const UList<Type>& f)
TMP_UNARY_FUNCTION(Type, sum) TMP_UNARY_FUNCTION(Type, sum)
template<class Type>
Type maxMagSqr(const UList<Type>& f)
{
if (f.size())
{
Type Max(f[0]);
TFOR_ALL_S_OP_FUNC_F_S
(
Type,
Max,
=,
maxMagSqrOp<Type>(),
Type,
f,
Type,
Max
)
return Max;
}
else
{
return pTraits<Type>::min;
}
}
TMP_UNARY_FUNCTION(Type, maxMagSqr)
template<class Type>
Type minMagSqr(const UList<Type>& f)
{
if (f.size())
{
Type Min(f[0]);
TFOR_ALL_S_OP_FUNC_F_S
(
Type,
Min,
=,
minMagSqrOp<Type>(),
Type,
f,
Type,
Min
)
return Min;
}
else
{
return pTraits<Type>::max;
}
}
TMP_UNARY_FUNCTION(Type, minMagSqr)
template<class Type> template<class Type>
scalar sumProd(const UList<Type>& f1, const UList<Type>& f2) scalar sumProd(const UList<Type>& f1, const UList<Type>& f2)
@ -488,6 +541,8 @@ TMP_UNARY_FUNCTION(ReturnType, gFunc)
G_UNARY_FUNCTION(Type, gMax, max, max) G_UNARY_FUNCTION(Type, gMax, max, max)
G_UNARY_FUNCTION(Type, gMin, min, min) G_UNARY_FUNCTION(Type, gMin, min, min)
G_UNARY_FUNCTION(Type, gSum, sum, sum) G_UNARY_FUNCTION(Type, gSum, sum, sum)
G_UNARY_FUNCTION(Type, gMaxMagSqr, maxMagSqr, maxMagSqr)
G_UNARY_FUNCTION(Type, gMinMagSqr, minMagSqr, minMagSqr)
G_UNARY_FUNCTION(scalar, gSumSqr, sumSqr, sum) G_UNARY_FUNCTION(scalar, gSumSqr, sumSqr, sum)
G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum) G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum)
G_UNARY_FUNCTION(Type, gSumCmptMag, sumCmptMag, sum) G_UNARY_FUNCTION(Type, gSumCmptMag, sumCmptMag, sum)

View File

@ -171,6 +171,16 @@ Type sum(const UList<Type>& f);
TMP_UNARY_FUNCTION(Type, sum) TMP_UNARY_FUNCTION(Type, sum)
template<class Type>
Type maxMagSqr(const UList<Type>& f);
TMP_UNARY_FUNCTION(Type, maxMagSqr)
template<class Type>
Type minMagSqr(const UList<Type>& f);
TMP_UNARY_FUNCTION(Type, minMagSqr)
template<class Type> template<class Type>
scalar sumProd(const UList<Type>& f1, const UList<Type>& f2); scalar sumProd(const UList<Type>& f1, const UList<Type>& f2);
@ -208,6 +218,8 @@ TMP_UNARY_FUNCTION(ReturnType, gFunc)
G_UNARY_FUNCTION(Type, gMax, max, max) G_UNARY_FUNCTION(Type, gMax, max, max)
G_UNARY_FUNCTION(Type, gMin, min, min) G_UNARY_FUNCTION(Type, gMin, min, min)
G_UNARY_FUNCTION(Type, gSum, sum, sum) G_UNARY_FUNCTION(Type, gSum, sum, sum)
G_UNARY_FUNCTION(Type, gMaxMagSqr, maxMagSqr, maxMagSqr)
G_UNARY_FUNCTION(Type, gMinMagSqr, minMagSqr, minMagSqr)
G_UNARY_FUNCTION(scalar, gSumSqr, sumSqr, sum) G_UNARY_FUNCTION(scalar, gSumSqr, sumSqr, sum)
G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum) G_UNARY_FUNCTION(scalar, gSumMag, sumMag, sum)
G_UNARY_FUNCTION(Type, gSumCmptMag, sumCmptMag, sum) G_UNARY_FUNCTION(Type, gSumCmptMag, sumCmptMag, sum)