Jpp 21.0.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JACOUSTICS::JWeight Struct Reference

Auxiliary data structure to unify weights of acoustics data according to the number of pings per emitter. More...

#include <JAcousticsToolkit.hh>

Inheritance diagram for JACOUSTICS::JWeight:
std::map< int, size_t >

Public Member Functions

template<class T >
 JWeight (T __begin, T __end)
 Constructor.
 
double operator() (const int id) const
 Get weight.
 

Static Public Member Functions

static bool getUnify ()
 Get option to unify weights.
 
static void setUnify (const bool unify)
 Set option to unify weights.
 

Static Private Member Functions

static bool & get_unify ()
 Get option to unify weights.
 

Private Attributes

size_t min
 

Detailed Description

Auxiliary data structure to unify weights of acoustics data according to the number of pings per emitter.

The default option is to unify the weights.

Definition at line 54 of file JAcousticsToolkit.hh.

Constructor & Destructor Documentation

◆ JWeight()

template<class T >
JACOUSTICS::JWeight::JWeight ( T __begin,
T __end )
inline

Constructor.

Parameters
__beginbegin of data
__endend of data

Definition at line 64 of file JAcousticsToolkit.hh.

64 :
65 min(std::numeric_limits<size_t>::max())
66 {
67 for (T i = __begin; i != __end; ++i) {
68 (*this)[i->getID()] += 1;
69 }
70
71 for (const_iterator i = this->begin(); i != this->end(); ++i) {
72 if (i->second < min) {
73 min = i->second;
74 }
75 }
76 }

Member Function Documentation

◆ getUnify()

static bool JACOUSTICS::JWeight::getUnify ( )
inlinestatic

Get option to unify weights.

Returns
option

Definition at line 84 of file JAcousticsToolkit.hh.

85 {
86 return get_unify();
87 }
static bool & get_unify()
Get option to unify weights.

◆ setUnify()

static void JACOUSTICS::JWeight::setUnify ( const bool unify)
inlinestatic

Set option to unify weights.

Parameters
unifyoption

Definition at line 95 of file JAcousticsToolkit.hh.

96 {
97 get_unify() = unify;
98 }

◆ operator()()

double JACOUSTICS::JWeight::operator() ( const int id) const
inline

Get weight.

Parameters
ididentifier
Returns
weight

Definition at line 107 of file JAcousticsToolkit.hh.

108 {
109 if (getUnify()) {
110
111 const_iterator p = this->find(id);
112
113 if (p != this->end())
114 return (double) min / (double) p->second;
115 else
116 THROW(JValueOutOfRange, "Invalid identifier " << id);
117
118 } else {
119
120 return 1.0;
121 }
122 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for accessing a value in a collection that is outside of its range.
static bool getUnify()
Get option to unify weights.

◆ get_unify()

static bool & JACOUSTICS::JWeight::get_unify ( )
inlinestaticprivate

Get option to unify weights.

Returns
option

Definition at line 130 of file JAcousticsToolkit.hh.

131 {
132 static bool unify = true;
133
134 return unify;
135 }

Member Data Documentation

◆ min

size_t JACOUSTICS::JWeight::min
private

Definition at line 137 of file JAcousticsToolkit.hh.


The documentation for this struct was generated from the following file: