Jpp 20.0.0-rc.9-29-gccc23c492-D
the software that should make you happy
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type > Struct Template Reference

Auxiliary data structure with extended functionality of hash-map. More...

#include <JModel.hh>

Inheritance diagram for JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >:

Public Types

typedef JHashMap< key_type, value_type, evaluator_type > hashmap_type
 

Public Member Functions

size_t getN (const JMODEL::JOption_t option) const
 Get number of fit parameters.
 
size_t getIndex (const key_type key, double value_type::*p, const JMODEL::JOption_t option) const
 Get index of parameter.
 
double getParameter (const size_t index, const JMODEL::JOption_t option) const
 Get read access to fit parameter value at given index in buffer.
 
double & getParameter (const size_t index, const JMODEL::JOption_t option)
 Get read/write access to fit parameter value at given index in buffer.
 
void evaluate (value_type &(value_type::*f1)())
 Evaluate arithmetic operation.
 
void evaluate (const hash_map &buffer, value_type &(value_type::*f1)(const value_type &))
 Evaluate arithmetic operation.
 
void evaluate (value_type &(value_type::*f1)(const double), const double factor)
 Evaluate arithmetic operation.
 
bool equals (const hash_map &buffer) const
 Check equality of hash map.
 
bool equals (const hash_map &buffer, const double precision) const
 Check equality of has map.
 

Detailed Description

template<class key_type, class value_type, class evaluator_type = JHashEvaluator>
struct JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >

Auxiliary data structure with extended functionality of hash-map.

Definition at line 809 of file JAcoustics/JModel.hh.

Member Typedef Documentation

◆ hashmap_type

template<class key_type , class value_type , class evaluator_type = JHashEvaluator>
typedef JHashMap<key_type, value_type, evaluator_type> JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >::hashmap_type

Definition at line 812 of file JAcoustics/JModel.hh.

Member Function Documentation

◆ getN()

template<class key_type , class value_type , class evaluator_type = JHashEvaluator>
size_t JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >::getN ( const JMODEL::JOption_t option) const
inline

Get number of fit parameters.

Parameters
optionoption
Returns
number of parameters

Definition at line 820 of file JAcoustics/JModel.hh.

821 {
822 return this->size() * value_type::getN(option);
823 }
JMODEL::JOption_t option

◆ getIndex()

template<class key_type , class value_type , class evaluator_type = JHashEvaluator>
size_t JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >::getIndex ( const key_type key,
double value_type::* p,
const JMODEL::JOption_t option ) const
inline

Get index of parameter.

Parameters
keykey
ppointer to data member
optionoption
Returns
index

Definition at line 834 of file JAcoustics/JModel.hh.

835 {
836 value_type* __p__ = NULL;
837
838 if (this->has(key))
839 return static_cast<const hashmap_type&>(*this).getIndex(key) * value_type::getN(option) + ((double*) &(__p__->*p) - (double*) __p__);
840 else
841 THROW(JValueOutOfRange, "Invalid key " << key);
842 }
JHashMap< key_type, value_type, evaluator_type > hashmap_type

◆ getParameter() [1/2]

template<class key_type , class value_type , class evaluator_type = JHashEvaluator>
double JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >::getParameter ( const size_t index,
const JMODEL::JOption_t option ) const
inline

Get read access to fit parameter value at given index in buffer.

Parameters
indexindex
optionoption
Returns
value

Definition at line 852 of file JAcoustics/JModel.hh.

853 {
854 const size_t pos = index / value_type::getN(option); // position of element in buffer
855 const size_t offset = index % value_type::getN(option); // offset of parameter in element
856
857 const value_type& value = this->data()[pos].second; // value of element at given position
858
859 return ((const double*) &value)[offset]; // parameter at given offset
860 }

◆ getParameter() [2/2]

template<class key_type , class value_type , class evaluator_type = JHashEvaluator>
double & JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >::getParameter ( const size_t index,
const JMODEL::JOption_t option )
inline

Get read/write access to fit parameter value at given index in buffer.

Parameters
indexindex
optionoption
Returns
value

Definition at line 870 of file JAcoustics/JModel.hh.

871 {
872 const size_t pos = index / value_type::getN(option); // position of element in buffer
873 const size_t offset = index % value_type::getN(option); // offset of parameter in element
874
875 value_type& value = this->data()[pos].second; // value of element at given position
876
877 return ((double*) &value)[offset]; // parameter at given offset
878 }

◆ evaluate() [1/3]

template<class key_type , class value_type , class evaluator_type = JHashEvaluator>
void JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >::evaluate ( value_type &(value_type::*)() f1)
inline

Evaluate arithmetic operation.

Parameters
f1operation

Definition at line 886 of file JAcoustics/JModel.hh.

887 {
888 for (typename hashmap_type::iterator i = this->begin(); i != this->end(); ++i) {
889 (i->second.*f1)();
890 }
891 }

◆ evaluate() [2/3]

template<class key_type , class value_type , class evaluator_type = JHashEvaluator>
void JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >::evaluate ( const hash_map< key_type, value_type, evaluator_type > & buffer,
value_type &(value_type::*)(const value_type &) f1 )
inline

Evaluate arithmetic operation.

Parameters
bufferbuffer
f1operation

Definition at line 900 of file JAcoustics/JModel.hh.

901 {
902 for (typename hashmap_type::const_iterator i = buffer.begin(); i != buffer.end(); ++i) {
903 ((*this)[i->first].*f1)(i->second);
904 }
905 }

◆ evaluate() [3/3]

template<class key_type , class value_type , class evaluator_type = JHashEvaluator>
void JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >::evaluate ( value_type &(value_type::*)(const double) f1,
const double factor )
inline

Evaluate arithmetic operation.

Parameters
f1operation
factorfactor

Definition at line 914 of file JAcoustics/JModel.hh.

915 {
916 for (typename hashmap_type::iterator i = this->begin(); i != this->end(); ++i) {
917 (i->second.*f1)(factor);
918 }
919 }

◆ equals() [1/2]

template<class key_type , class value_type , class evaluator_type = JHashEvaluator>
bool JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >::equals ( const hash_map< key_type, value_type, evaluator_type > & buffer) const
inline

Check equality of hash map.

Parameters
bufferbuffer
Returns
true if hash map is equal; else false

Definition at line 928 of file JAcoustics/JModel.hh.

929 {
930 for (typename hashmap_type::const_iterator
931 p = this->begin(),
932 q = buffer.begin(); ; ++p, ++q) {
933
934 if (p != this->end() && q != buffer.end()) {
935
936 if (p->first != q->first || p->second != q->second) {
937 return false;
938 }
939
940 } else if (p == this->end() && q == buffer.end()) {
941
942 return true;
943
944 } else {
945
946 return false;
947 }
948 }
949 }

◆ equals() [2/2]

template<class key_type , class value_type , class evaluator_type = JHashEvaluator>
bool JACOUSTICS::JModel::hash_map< key_type, value_type, evaluator_type >::equals ( const hash_map< key_type, value_type, evaluator_type > & buffer,
const double precision ) const
inline

Check equality of has map.

Parameters
bufferbuffer
precisionprecision
Returns
true if hash map is equal; else false

Definition at line 959 of file JAcoustics/JModel.hh.

960 {
961 for (typename hashmap_type::const_iterator
962 p = this->begin(),
963 q = buffer.begin(); ; ++p, ++q) {
964
965 if (p != this->end() && q != buffer.end()) {
966
967 if (p->first != q->first || !p->second.equals(q->second, precision)) {
968 return false;
969 }
970
971 } else if (p == this->end() && q == buffer.end()) {
972
973 return true;
974
975 } else {
976
977 return false;
978 }
979 }
980 }

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