26 strcpy(
m_name,
"Undefined");
30 std::size_t
count = 0;
32 for (std::size_t i = 0; i <
size(); ++i) {
33 const ScalarType& val =
at(i);
42 ScalarType* variance)
const {
43 double _mean = 0.0, _std2 = 0.0;
44 std::size_t
count = 0;
46 for (std::size_t i = 0; i <
size(); ++i) {
47 const ScalarType& val =
at(i);
50 _std2 +=
static_cast<double>(val) * val;
57 mean =
static_cast<ScalarType
>(_mean);
61 *variance =
static_cast<ScalarType
>(_std2);
74 }
catch (
const std::bad_alloc&) {
82 bool initNewElements ,
83 ScalarType valueForNewElements ) {
86 resize(
count, valueForNewElements);
89 }
catch (
const std::bad_alloc&) {
A simple scalar field (to be associated to a point cloud)
std::size_t countValidValues() const
Returns the number of valid values in this scalar field.
void computeMeanAndVariance(ScalarType &mean, ScalarType *variance=nullptr) const
char m_name[256]
Scalar field name.
bool reserveSafe(std::size_t count)
Reserves memory (no exception thrown)
ScalarField(const char *name=nullptr)
Default constructor.
void setName(const char *name)
Sets scalar field name.
bool resizeSafe(std::size_t count, bool initNewElements=false, ScalarType valueForNewElements=0)
Resizes memory (no exception thrown)
static bool ValidValue(ScalarType value)
Returns whether a scalar value is valid or not.
__host__ __device__ int2 abs(int2 v)
Generic file read and write utility for python interface.