Jpp  18.4.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
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. More...
 
double operator() (const int id) const
 Get weight. More...
 

Static Public Member Functions

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

Static Private Member Functions

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

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 36 of file JAcousticsToolkit.hh.

Constructor & Destructor Documentation

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

Constructor.

Parameters
__beginbegin of data
__endend of data

Definition at line 46 of file JAcousticsToolkit.hh.

46  :
47  min(std::numeric_limits<size_t>::max())
48  {
49  for (T i = __begin; i != __end; ++i) {
50  (*this)[i->getID()] += 1;
51  }
52 
53  for (const_iterator i = this->begin(); i != this->end(); ++i) {
54  if (i->second < min) {
55  min = i->second;
56  }
57  }
58  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T

Member Function Documentation

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

Get option to unify weights.

Returns
option

Definition at line 66 of file JAcousticsToolkit.hh.

67  {
68  return get_unify();
69  }
static bool & get_unify()
Get option to unify weights.
static void JACOUSTICS::JWeight::setUnify ( const bool  unify)
inlinestatic

Set option to unify weights.

Parameters
unifyoption

Definition at line 77 of file JAcousticsToolkit.hh.

78  {
79  get_unify() = unify;
80  }
static bool & get_unify()
Get option to unify weights.
double JACOUSTICS::JWeight::operator() ( const int  id) const
inline

Get weight.

Parameters
ididentifier
Returns
weight

Definition at line 89 of file JAcousticsToolkit.hh.

90  {
91  if (getUnify()) {
92 
93  const_iterator p = this->find(id);
94 
95  if (p != this->end())
96  return (double) min / (double) p->second;
97  else
98  THROW(JValueOutOfRange, "Invalid identifier " << id);
99 
100  } else {
101 
102  return 1.0;
103  }
104  }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:178
static bool getUnify()
Get option to unify weights.
static bool& JACOUSTICS::JWeight::get_unify ( )
inlinestaticprivate

Get option to unify weights.

Returns
option

Definition at line 112 of file JAcousticsToolkit.hh.

113  {
114  static bool unify = true;
115 
116  return unify;
117  }

Member Data Documentation

size_t JACOUSTICS::JWeight::min
private

Definition at line 119 of file JAcousticsToolkit.hh.


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