Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

DataSource

 

class DataSource

 

Some classes need sources of data for drawing, data analysis and statistics. However data series can be defined in different containers like C arrays, U++ containers or even data grids like ArrayCtrl and GridCtrl.

 

DataSource abstracts many sources of data, like:

 

Data series

They are series of data with a number of columns (parameters) and rows (every parameter set case). For example:

 

X

Y

Z

Temperature

1.1

45

-34

22

3.5

23

12

25

2.4

78

112

24

 

Explicit equation

A function y = f(x1, x2, ...) where y is the dependent variable and x1, x2 are the independent variables.

Examples are:

    

    y = 4x + 3z

    y = 3*x^2 + 2*x - 1

 

Parametric equation

(From Wikipedia) A parametric equation of a curve is a representation of it through equations expressing the coordinates of the points of the curve as functions of a variable called parameter. For example,

 

    x = cos(t)

    y = sin(t)

 

is a parametric equation for the unit circle, where t is the parameter.

 

These equations are useful to represent closed functions as circles, spirals and even epitrochoids.

 

DataSource classes can be used to interface data sources and containers and can be subclassed to be embedded in other classes like ExplicitEquation.

 

Examples of DataSource classes are CArray and VectorY .

 

 

Constructor Detail


 

DataSource()

Default constructor where the data is defined as data series by default.

 

Public Member List


 

virtual double y(int64 id)

Returns the first parameter of the data series id th value.

 


 

virtual double x(int64 id)

Returns the second parameter of the data series id th value.

 


 

virtual double xn(int n, int64 id)

Returns the n th parameter of the data series id th value.

 


 

virtual double y(double t)

Returns the first parameter of the parametric equation with independent value t.

 


 

virtual double x(double t)

Returns the second parameter of the parametric equation with independent value t.

 


 

virtual double xn(int n, double t)

Returns the n th parameter of the parametric equation with independent value t.

 


 

virtual double f(double x)

Returns the value of the explicit equation based on the independent value x.

 


 

virtual double f(Vector<doublexn)

Returns the value of the explicit equation based on the independent value set xn.

 


 

template <class Rangevoid Copy(Getdatafun getdata, Range &out)

Copies data series getdata into an Upp::Vector<>, Eigen::VectorXd or a std::vector<> out.

 


 

virtual int64 GetCount()

Returns the number of values in a data series or a parametric equation.

 


 

bool IsParam()

Returns true if the data source is a parametric equation.

 


 

bool IsExplicit()

Returns true if the data source is a explicit equation.

 

Public Functions

template <class Ttypename T::PlainObject Convolution(const Eigen::MatrixBase<T>& orig, const Eigen::MatrixBase<T>& kernel, const double factor = 1)

Applies on orig the convolution kernel, multiplying factor on each value of the convolution result.

 


 

template <class Ttypename T::PlainObject Convolution2D(const Eigen::MatrixBase<T>& orig, const Eigen::MatrixBase<T>& kernel, const double factor = 1)

Applies on orig the 2D convolution kernel, multiplying factor on each value of the convolution result.

 


 

bool SavitzkyGolay_CheckParams(int nleft, int nright, int deg, int der)

Returns true if Savitzsky-Golay filter arguments are correct. They are:

nleft: Number of leftward data points

nright: Number of rightward data points

deg: Order of the smoothing polynomial

der: Order of the derivative. 0 means smoothed function, 1 means smoothed first derivative, ...

Valid arguments have to comply with nleft >= 0 && nright >= 0 && der <= deg && nleft + nright >= deg.

 


 

VectorXd SavitzkyGolay_Coeff(int nleft, int nright, int deg, int der)

Savitzky–Golay is a digital filter applied by convolution of successive sub-sets of adjacent data points with a low-degree polynomial by the method of linear least squares. When the data points are equally spaced, an analytical solution to the least-squares equations can be found, in the form of a single set of "convolution coefficients", to give estimates of the smoothed signal, (or derivatives of the smoothed signal) at the central point of each sub-set. The method, was popularized by Abraham Savitzky and Marcel J. E. Golay in 1964. This function obtains the filter coefficients, and has to be applied just once for any dataset, as the coefficients do not depend on data but in the conditions defined by arguments. Arguments are explained in SavitzkyGolay_CheckParams(). Filter has to be appplied using Convolution() on input data.

 

References: Savitzky–Golay filter (Wikipedia), Savitzky, A.; Golay, M.J.E. (1964). "Smoothing and Differentiation of Data by Simplified Least Squares Procedures". Analytical Chemistry. 36 (8): 1627–39, Numerical Recipes in C, Second Edition (1992), Schafer, R.W. What Is a Savitzky-Golay Filter?, IEEE Signal Processing Magazine [116] (2011).

 

Do you want to contribute?