Kstars

math_tools.h File Reference
#include <Eigen/Dense>
#include <unsupported/Eigen/FFT>
#include <limits>
#include <vector>
#include <stdexcept>
#include <cstdint>
#include <cmath>
Include dependency graph for tools/math_tools.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define M_PI   3.14159265358979323846
 
#define MINIMAL_THETA   1e-7
 

Functions

Eigen::MatrixXd math_tools::box_muller (const Eigen::VectorXd &vRand)
 
std::pair< Eigen::VectorXd, Eigen::VectorXd > math_tools::compute_spectrum (Eigen::VectorXd &data, int N)
 
Eigen::MatrixXd math_tools::generate_normal_random_matrix (const size_t n, const size_t m)
 
Eigen::MatrixXd math_tools::generate_uniform_random_matrix_0_1 (const size_t n, const size_t m)
 
Eigen::VectorXd math_tools::hamming_window (int N)
 
bool math_tools::isInf (double x)
 
bool math_tools::isNaN (double x)
 
Eigen::MatrixXd math_tools::squareDistance (const Eigen::MatrixXd &a)
 
Eigen::MatrixXd math_tools::squareDistance (const Eigen::MatrixXd &a, const Eigen::MatrixXd &b)
 
double math_tools::stdandard_deviation (Eigen::VectorXd &input)
 

Variables

static const double math_tools::NaN = std::numeric_limits<double>::quiet_NaN()
 

Detailed Description

Provides mathematical tools needed for the Gaussian process toolbox.

Date
2014-2017
Author
Edgar D. Klenske edgar.nosp@m..kle.nosp@m.nske@.nosp@m.tueb.nosp@m.ingen.nosp@m..mpg.nosp@m..de
Stephan Wenninger steph.nosp@m.an.w.nosp@m.ennin.nosp@m.ger@.nosp@m.tuebi.nosp@m.ngen.nosp@m..mpg..nosp@m.de
Raffi Enficiaud raffi.nosp@m..enf.nosp@m.iciau.nosp@m.d@tu.nosp@m.ebing.nosp@m.en.m.nosp@m.pg.de

Definition in file tools/math_tools.h.

Macro Definition Documentation

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 35 of file tools/math_tools.h.

◆ MINIMAL_THETA

#define MINIMAL_THETA   1e-7

Definition at line 23 of file tools/math_tools.h.

Function Documentation

◆ box_muller()

Eigen::MatrixXd math_tools::box_muller ( const Eigen::VectorXd & vRand)

Apply the Box-Muller transform, which transforms uniform random samples to Gaussian distributed random samples.

Definition at line 109 of file src/math_tools.cpp.

◆ compute_spectrum()

std::pair< Eigen::VectorXd, Eigen::VectorXd > math_tools::compute_spectrum ( Eigen::VectorXd & data,
int N = 0 )

Calculates the spectrum of a data vector.

Does pre-and postprocessing:

  • The data is zero-padded until the desired resolution is reached.
  • ditfft2 is called to compute the FFT.
  • The frequencies from the padding are removed.
  • The constant coefficient is removed.
  • A list of frequencies is generated.

Definition at line 151 of file src/math_tools.cpp.

◆ generate_normal_random_matrix()

Eigen::MatrixXd math_tools::generate_normal_random_matrix ( const size_t n,
const size_t m )

Generates normal random samples. First it gets some uniform random samples and then uses the Box-Muller transform to get normal samples out of it

Definition at line 138 of file src/math_tools.cpp.

◆ generate_uniform_random_matrix_0_1()

Eigen::MatrixXd math_tools::generate_uniform_random_matrix_0_1 ( const size_t n,
const size_t m )

Generates a uniformly distributed random matrix of values between 0 and 1.

Definition at line 95 of file src/math_tools.cpp.

◆ hamming_window()

Eigen::VectorXd math_tools::hamming_window ( int N)

Computes a Hamming window (used to reduce spectral leakage of subsequent DFT).

Definition at line 187 of file src/math_tools.cpp.

◆ isInf()

bool math_tools::isInf ( double x)
inline

Checks if a double is infinite via std::numeric_limits<double> functions.

Taken from: http://bytes.com/topic/c/answers/588254-how-check-double-inf-nan#post2309761

Definition at line 107 of file src/math_tools.h.

◆ isNaN()

bool math_tools::isNaN ( double x)
inline

Checks if a value is NaN by comparing it with itself.

The rationale is that NaN is the only value that does not evaluate to true when comparing it with itself. Taken from: http://stackoverflow.com/questions/3437085/check-nan-number http://stackoverflow.com/questions/570669/checking-if-a-double-or-float-is-nan-in-c

Definition at line 94 of file src/math_tools.h.

◆ squareDistance() [1/2]

Eigen::MatrixXd math_tools::squareDistance ( const Eigen::MatrixXd & a)

Single-input version of squaredDistance. For single inputs, it is assumed that the pairwise distance matrix should be computed between the passed vector itself.

Definition at line 90 of file src/math_tools.cpp.

◆ squareDistance() [2/2]

Eigen::MatrixXd math_tools::squareDistance ( const Eigen::MatrixXd & a,
const Eigen::MatrixXd & b )

The squareDistance is the pairwise distance between all points of the passed vectors. I.e. it generates a symmetric matrix when two vectors are passed.

The first dimension (rows) is the dimensionality of the input space, the second dimension (columns) is the number of datapoints. The number of rows must be identical.

Parameters
aa Matrix of size Dxn
ba Matrix of size Dxm
Returns
a Matrix of size nxm containing all pairwise squared distances

Definition at line 28 of file src/math_tools.cpp.

◆ stdandard_deviation()

double math_tools::stdandard_deviation ( Eigen::VectorXd & input)

Computes the standard deviation of a vector... which is not part of Eigen.

Definition at line 198 of file src/math_tools.cpp.

Variable Documentation

◆ NaN

const double math_tools::NaN = std::numeric_limits<double>::quiet_NaN()
static

Definition at line 99 of file tools/math_tools.h.

This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.