DYT/Tool/OpenSceneGraph-3.6.5/include/libqhullcpp/functionObjects.h

68 lines
1.5 KiB
C
Raw Normal View History

2024-12-24 23:49:36 +00:00
/****************************************************************************
**
** Copyright (c) 2008-2020 C.B. Barber. All rights reserved.
** $Id: //main/2019/qhull/src/libqhullcpp/functionObjects.h#2 $$Change: 2953 $
** $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
**
****************************************************************************/
#ifndef QHFUNCTIONOBJECTS_H
#define QHFUNCTIONOBJECTS_H
#include <stdlib.h>
#include <math.h>
namespace orgQhull {
#//!\name Defined here
//! Sum of absolute values of the elements in a container
class AbsoluteSumOf;
//! Sum of the elements in a container
class SumOf;
//! Sum of squares of the elements in a container
class SumSquaresOf;
#//!\name Class
//! Absolute sum of the elements in a container
class AbsoluteSumOf
{
private:
double sum;
public:
inline AbsoluteSumOf() : sum(0.0) {}
inline void operator()(double v) { sum += fabs(v); }
inline operator double() { return sum; }
};//AbsoluteSumOf
//! Sum of the elements in a container
class SumOf
{
private:
double sum;
public:
inline SumOf() : sum(0.0) {}
inline void operator()(double v) { sum += v; }
inline operator double() { return sum; }
};//SumOf
//! Sum of squares of the elements in a container
class SumSquaresOf
{
private:
double sum;
public:
inline SumSquaresOf() : sum(0.0) {}
inline void operator()(double v) { sum += v*v; }
inline operator double() { return sum; }
};//SumSquaresOf
}//orgQhull
#endif //QHFUNCTIONOBJECTS_H