Commit 7ea94bac authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libpsdxx [WP]: provide LogIndex to reverse log-scale

parent 87885748
......@@ -43,6 +43,21 @@ namespace psd {
namespace helper {
/*! Class function to return index on logarithmic scale
*/
class LogIndex
{
public:
LogIndex(const double& f0,
const double& f1,
const double& f2);
double operator()(const double& f);
private:
double Mn_per_decade;
double Mc;
double Mdf;
}; // class LogIndex
} // namespace helper
} // namespace psd
......
......@@ -34,11 +34,34 @@
"PSDXX_LOG_INDEX_CC V1.0"
#include <psdxx/helper.h>
#include <psdxx/error.h>
namespace psd {
namespace helper {
LogIndex::LogIndex(const double& f0,
const double& f1,
const double& f2)
{
PSDXX_assert(f1>f0, "frequency values must increase");
PSDXX_assert(f2>f1, "frequency values must increase");
Mdf=f0;
double logfac=(f2-f1)/(f1-f0);
Mn_per_decade=std::log(10.)/std::log(logfac);
Mc=(f1-f0)/(f0*(logfac-1.));
} // LogIndex::LogIndex(const double& f0,
// const double& f1,
// const double& f2)
/* ---------------------------------------------------------------------- */
double LogIndex::operator()(const double& f)
{
double l =Mn_per_decade*std::log(1.+((f/Mdf)-1.)/Mc)/std::log(10.);
} // double LogIndex::operator()(const double& f)
} // namespace helper
} // namespace psd
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment