34 const double& frequency )
36 std::map< double, double >::const_iterator it2 = sRFs.find( frequency );
38 if( it2 == sRFs.end() )
40 it2 = sRFs.upper_bound( frequency );
42 if( ( it2 == sRFs.begin() ) || ( it2 == sRFs.end() ) )
48 std::map< double, double >::const_iterator it1 = it2;
51 double dist1 = frequency - it1->first;
52 assert( dist1 > 0.0 );
53 double dist2 = it2->first - frequency;
54 assert( dist2 > 0.0 );
57 ( it1->second * dist2 )
59 ( it2->second * dist1 )
71 double getSRFArea(
const std::map< double, double >& sRFs )
73 double returnValue = 0.0;
75 std::map< double, double >::const_iterator it = sRFs.begin();
76 std::map< double, double >::const_iterator itPrev;
77 const std::map< double, double >::const_iterator itEnd = sRFs.end();
81 if( it == sRFs.begin() )
87 returnValue += std::abs( it->second - itPrev->second ) *
88 ( it->first - itPrev->first ) / 2.0;
89 returnValue += ( it->first - itPrev->first ) *
90 std::min( it->second, itPrev->second );
102 const std::map< double, double >& sRF2,
103 std::map< double, double >& intersectionSRF )
107 std::map< double, double >::const_iterator it = intersectionSRF.begin();
108 const std::map< double, double >::const_iterator itEnd = intersectionSRF.end();
112 intersectionSRF[ it->first ] =
123 const std::map< double, double >& sRF2,
124 std::map< double, double >& unionSRF )
128 std::map< double, double >::const_iterator it1 = sRF1.begin();
129 const std::map< double, double >::const_iterator it1End = sRF1.end();
131 while( it1 != it1End )
133 unionSRF[ it1->first ] =
Spectral Response Functions.
void getIntersectionSRF(const std::map< double, double > &sRF1, const std::map< double, double > &sRF2, std::map< double, double > &intersectionSRF)
Return the intersetction SRF.
void getUnionSRF(const std::map< double, double > &sRF1, const std::map< double, double > &sRF2, std::map< double, double > &unionSRF)
Return the union SRF.
double interpolateSRF(const std::map< double, double > &sRFs, const double &frequency)
Return a SRF interpolated from the given SRFs.
double getSRFArea(const std::map< double, double > &sRFs)
Return the SRF area.