Vespucci  1.0.0
accessory.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright (C) 2014-2016 Wright State University - All Rights Reserved
3  Daniel P. Foose - Maintainer/Lead Developer
4 
5  This file is part of Vespucci.
6 
7  Vespucci is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Vespucci is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Vespucci. If not, see <http://www.gnu.org/licenses/>.
19 *******************************************************************************/
20 #ifndef ACCESSORY_H
21 #define ACCESSORY_H
22 #include <mlpack/core.hpp>
24 #include "Global/libvespucci.h"
25 namespace Vespucci
26 {
27  namespace Math
28  {
29  //general Math functions
30 
31  VESPUCCI_EXPORT arma::uword LocalMaximum(const arma::vec &X, double &value);
32  VESPUCCI_EXPORT arma::uword LocalMaximum(const arma::vec &dX, const arma::vec &d2X, double &value);
33  VESPUCCI_EXPORT arma::uword LocalMaximum(const arma::vec &X, const arma::vec &dX, const arma::vec &d2X, double &value);
34 
35  VESPUCCI_EXPORT arma::uword LocalMinimum(const arma::mat &X, double &value);
36  VESPUCCI_EXPORT arma::uword LocalMinimum(const arma::vec &dX, const arma::vec &d2X, double &value);
37  VESPUCCI_EXPORT arma::uword LocalMinimum(const arma::vec &X, const arma::vec &dX, const arma::mat &d2X, double &value);
38 
39 
40  VESPUCCI_EXPORT arma::sp_mat LocalMaxima(const arma::mat &X);
41  VESPUCCI_EXPORT arma::sp_mat LocalMaxima(const arma::mat &X, const arma::mat &dX, const arma::mat &d2X);
42 
43  VESPUCCI_EXPORT arma::sp_mat LocalMinima(const arma::mat &X);
44  VESPUCCI_EXPORT arma::sp_mat LocalMinima(const arma::mat &X, const arma::mat &dX, const arma::mat &d2X);
45 
46  VESPUCCI_EXPORT arma::sp_mat LocalMinimaWindow(const arma::mat &X, const int window_size);
47  VESPUCCI_EXPORT arma::sp_mat LocalMaximaWindow(const arma::mat &X, const int window_size);
48 
49  VESPUCCI_EXPORT arma::sp_mat LocalMinimaCWT(arma::mat coefs, arma::uvec scales, arma::uword min_window_size, double amplitude_threshold);
50  VESPUCCI_EXPORT arma::sp_mat LocalMaximaCWT(arma::mat coefs, arma::uvec scales, arma::uword min_window_size);
51 
52  VESPUCCI_EXPORT double quantile(arma::vec &data, double probs);
53 
54  VESPUCCI_EXPORT arma::vec ExtendToNextPow(arma::vec X, arma::uword n);
55  VESPUCCI_EXPORT arma::uword NextPow(arma::uword number, arma::uword power);
56 
57  VESPUCCI_EXPORT arma::mat spdiags(arma::mat B, arma::ivec d, arma::uword m, arma::uword n);
58  VESPUCCI_EXPORT arma::mat orth(arma::mat X); //this is implemented better in mlpack
59 
60 
61  VESPUCCI_EXPORT arma::uword min(arma::uword a, arma::uword b);
62  VESPUCCI_EXPORT arma::uword max(arma::uword a, arma::uword b);
63 
64  VESPUCCI_EXPORT void position(arma::uword index,
65  arma::uword n_rows, arma::uword n_cols,
66  arma::uword &i, arma::uword &j);
67  VESPUCCI_EXPORT arma::umat to_row_column(arma::uvec indices, arma::uword n_rows, arma::uword n_cols);
68 
69  VESPUCCI_EXPORT double RecalculateAverage(double new_value, double old_average, double old_count);
70  VESPUCCI_EXPORT double RecalculateStdDev(double new_value, double old_mean, double old_stddev, double old_count);
71 
72  VESPUCCI_EXPORT arma::umat GetClosestValues(arma::vec query, arma::vec target, const arma::uword k=5);
73 
74  VESPUCCI_EXPORT double CalcPoly(const double x, const arma::vec &coefs);
75 
76  VESPUCCI_EXPORT arma::vec RepresentativeSpectrum(const arma::mat &spectra, arma::uword &index, std::string metric_name="euclidean", std::string center="centroid");
77 
78 
79  //Abscissa transforms
80  VESPUCCI_EXPORT arma::vec WavelengthToFrequency(const arma::vec &x, double freq_factor, double wl_factor);
81  VESPUCCI_EXPORT arma::vec FrequencyToWavelength(const arma::vec &x, double wl_factor, double freq_factor);
82  VESPUCCI_EXPORT arma::vec FrequencyToEnergy(const arma::vec &x, double energy_factor, double freq_factor);
83  VESPUCCI_EXPORT arma::vec EnergyToFrequency(const arma::vec &x, double freq_factor, double energy_factor);
84  VESPUCCI_EXPORT arma::vec WavenumberToFrequency(const arma::vec &x, double freq_factor, double wn_factor);
85  VESPUCCI_EXPORT arma::vec FrequencyToWavenumber(const arma::vec &x, double wn_factor, double freq_factor);
86  VESPUCCI_EXPORT arma::vec WavenumberToWavelength(const arma::vec &x, double wn_factor, double wl_factor);
87  VESPUCCI_EXPORT arma::vec WavelengthToWavenumber(const arma::vec &x, double wl_factor, double wn_factor);
88  VESPUCCI_EXPORT arma::vec WavelengthToEnergy(const arma::vec &x, double energy_factor, double wl_factor);
89  VESPUCCI_EXPORT arma::vec EnergyToWavelength(const arma::vec &x, double wl_factor, double energy_factor);
90  VESPUCCI_EXPORT arma::vec EnergyToWavenumber(const arma::vec &x, double wn_factor, double energy_factor);
91  VESPUCCI_EXPORT arma::vec WavenumberToEnergy(const arma::vec &x, double energy_factor, double wn_factor);
92 
93 
94  VESPUCCI_EXPORT bool AreEqual(const arma::vec &a, const arma::vec &b);
95 
96  VESPUCCI_EXPORT bool IsMonotonic(const arma::vec &x);
97  VESPUCCI_EXPORT bool IsIncreasing(const arma::vec &x);
98 
99  VESPUCCI_EXPORT arma::cx_vec cx_zeros(arma::uword n);
100  VESPUCCI_EXPORT arma::cx_mat cx_zeros(arma::uword m, arma::uword n);
101 
102  VESPUCCI_EXPORT arma::uword ClosestIndex(double value, const arma::vec &vector);
103  VESPUCCI_EXPORT arma::uvec Intersection(arma::uvec &x, arma::uvec &y);
104 
105  VESPUCCI_EXPORT double CalculateRSquared(const arma::vec &data,
106  const arma::vec &fit,
107  arma::vec &residuals);
108  VESPUCCI_EXPORT arma::mat SafeRows(const arma::mat &x,
109  arma::uword a,
110  arma::uword b);
111  }
112 }
113 
114 
115 #endif //ACCESSORY_H
VESPUCCI_EXPORT arma::vec WavenumberToWavelength(const arma::vec &x, double wn_factor, double wl_factor)
Vespucci::Math::WavenumberToWavelength.
Definition: accessory.cpp:701
VESPUCCI_EXPORT arma::mat orth(arma::mat X)
orth Returns an orthonormal basis of the range space of A
Definition: accessory.cpp:208
VESPUCCI_EXPORT arma::vec WavelengthToEnergy(const arma::vec &x, double energy_factor, double wl_factor)
Vespucci::Math::WavelengthToEnergy.
Definition: accessory.cpp:731
VESPUCCI_EXPORT arma::vec EnergyToWavelength(const arma::vec &x, double wl_factor, double energy_factor)
Vespucci::Math::EnergyToWavelength.
Definition: accessory.cpp:746
VESPUCCI_EXPORT bool IsMonotonic(const arma::vec &x)
IsMonotonic.
Definition: accessory.cpp:877
VESPUCCI_EXPORT arma::sp_mat LocalMaximaWindow(const arma::mat &X, const int window_size)
Vespucci::Math::LocalMaximaWindow "Cleans" local maximum by window search to remove extraneous values...
Definition: accessory.cpp:830
VESPUCCI_EXPORT arma::vec ExtendToNextPow(arma::vec X, arma::uword n)
Definition: accessory.cpp:259
VESPUCCI_EXPORT bool AreEqual(const arma::vec &a, const arma::vec &b)
AreEqual.
Definition: accessory.cpp:858
VESPUCCI_EXPORT double RecalculateAverage(double new_value, double old_average, double old_count)
Vespucci::Math::RecalculateAverage Recalculate the average value when a new value is added to a list ...
Definition: accessory.cpp:535
VESPUCCI_EXPORT arma::uword max(arma::uword a, arma::uword b)
Vespucci::Math::max.
Definition: accessory.cpp:237
VESPUCCI_EXPORT arma::sp_mat LocalMinimaCWT(arma::mat coefs, arma::uvec scales, arma::uword min_window_size, double amplitude_threshold)
VESPUCCI_EXPORT arma::vec EnergyToFrequency(const arma::vec &x, double freq_factor, double energy_factor)
Vespucci::Math::EnergyToFrequency.
Definition: accessory.cpp:657
VESPUCCI_EXPORT arma::vec RepresentativeSpectrum(const arma::mat &spectra, arma::uword &index, std::string metric_name="euclidean", std::string center="centroid")
Vespucci::Math::RepresentativeSpectrum.
Definition: accessory.cpp:953
VESPUCCI_EXPORT arma::vec WavenumberToEnergy(const arma::vec &x, double energy_factor, double wn_factor)
Vespucci::Math::WavenumberToEnergy.
Definition: accessory.cpp:773
VESPUCCI_EXPORT double CalculateRSquared(const arma::vec &data, const arma::vec &fit, arma::vec &residuals)
Vespucci::Math::CalculateRSquared.
Definition: accessory.cpp:1008
VESPUCCI_EXPORT arma::vec WavelengthToFrequency(const arma::vec &x, double freq_factor, double wl_factor)
Vespucci::Math::WavelengthToFrequency.
Definition: accessory.cpp:614
VESPUCCI_EXPORT void position(arma::uword index, arma::uword n_rows, arma::uword n_cols, arma::uword &i, arma::uword &j)
Vespucci::Math::position Find row and column numbers for index.
Definition: accessory.cpp:469
VESPUCCI_EXPORT arma::uword LocalMinimum(const arma::mat &X, double &value)
Vespucci::Math::LocalMinimum.
Definition: accessory.cpp:77
VESPUCCI_EXPORT arma::mat spdiags(arma::mat B, arma::ivec d, arma::uword m, arma::uword n)
spdiags analgous to the Octave/arma::matLAB function A = spdiags(B, d, m, n).
Definition: accessory.cpp:137
VESPUCCI_EXPORT arma::uword LocalMaximum(const arma::vec &X, double &value)
Vespucci::Math::LocalMaximum.
Definition: accessory.cpp:30
VESPUCCI_EXPORT arma::uvec Intersection(arma::uvec &x, arma::uvec &y)
Vespucci::Math::Intersection.
Definition: accessory.cpp:990
VESPUCCI_EXPORT double RecalculateStdDev(double new_value, double old_mean, double old_stddev, double old_count)
Vespucci::Math::RecalculateStdDev Recalculate a standard deviation when a new value is added to a lis...
Definition: accessory.cpp:552
VESPUCCI_EXPORT arma::sp_mat LocalMinima(const arma::mat &X)
Vespucci::Math::LocalMinima.
Definition: accessory.cpp:378
VESPUCCI_EXPORT bool IsIncreasing(const arma::vec &x)
IsIncreasing.
Definition: accessory.cpp:894
VESPUCCI_EXPORT arma::mat SafeRows(const arma::mat &x, arma::uword a, arma::uword b)
Vespucci::Math::SafeRows.
Definition: accessory.cpp:1030
VESPUCCI_EXPORT arma::sp_mat LocalMaxima(const arma::mat &X)
Vespucci::Math::LocalMaxima.
Definition: accessory.cpp:294
VESPUCCI_EXPORT arma::vec FrequencyToEnergy(const arma::vec &x, double energy_factor, double freq_factor)
Vespucci::Math::FrequencyToEnergy.
Definition: accessory.cpp:643
VESPUCCI_EXPORT arma::vec FrequencyToWavenumber(const arma::vec &x, double wn_factor, double freq_factor)
Vespucci::Math::FrequencyToWavenumber.
Definition: accessory.cpp:686
VESPUCCI_EXPORT arma::uword min(arma::uword a, arma::uword b)
Vespucci::Math::min.
Definition: accessory.cpp:249
VESPUCCI_EXPORT arma::sp_mat LocalMinimaWindow(const arma::mat &X, const int window_size)
Vespucci::Math::LocalMinimaWindow.
Definition: accessory.cpp:801
VESPUCCI_EXPORT double CalcPoly(const double x, const arma::vec &coefs)
Vespucci::Math::CalcPoly Calculate the value of a polynomial at particular point. ...
Definition: accessory.cpp:599
#define VESPUCCI_EXPORT
Definition: libvespucci.h:7
VESPUCCI_EXPORT arma::vec EnergyToWavenumber(const arma::vec &x, double wn_factor, double energy_factor)
Vespucci::Math::EnergyToWavenumber.
Definition: accessory.cpp:760
VESPUCCI_EXPORT arma::sp_mat LocalMaximaCWT(arma::mat coefs, arma::uvec scales, arma::uword min_window_size)
Definition: accessory.cpp:780
VESPUCCI_EXPORT arma::uword ClosestIndex(double value, const arma::vec &vector)
Vespucci::Math::ClosestIndex.
Definition: accessory.cpp:932
VESPUCCI_EXPORT arma::uword NextPow(arma::uword number, arma::uword power)
Definition: accessory.cpp:281
VESPUCCI_EXPORT arma::umat GetClosestValues(arma::vec query, arma::vec target, const arma::uword k=5)
Vespucci::Math::GetClosestValues.
Definition: accessory.cpp:576
VESPUCCI_EXPORT arma::vec WavelengthToWavenumber(const arma::vec &x, double wl_factor, double wn_factor)
Vespucci::Math::WavelengthToWavenumber.
Definition: accessory.cpp:716
VESPUCCI_EXPORT double quantile(arma::vec &data, double probs)
Definition: accessory.cpp:503
VESPUCCI_EXPORT arma::cx_vec cx_zeros(arma::uword n)
Vespucci::Math::cx_zeros.
Definition: accessory.cpp:921
VESPUCCI_EXPORT arma::umat to_row_column(arma::uvec indices, arma::uword n_rows, arma::uword n_cols)
Definition: accessory.cpp:488
A namespace for "global" functions, including math functions.
VESPUCCI_EXPORT arma::vec FrequencyToWavelength(const arma::vec &x, double wl_factor, double freq_factor)
Vespucci::Math::FrequencyToWavelength.
Definition: accessory.cpp:629
VESPUCCI_EXPORT arma::vec WavenumberToFrequency(const arma::vec &x, double freq_factor, double wn_factor)
Vespucci::Math::WavenumberToFrequency.
Definition: accessory.cpp:671