Repository navigation
Expand file tree
/
Copy pathvector_handler.hpp
More file actions
executable file
·74 lines (57 loc) · 2.06 KB
/
Copy pathvector_handler.hpp
File metadata and controls
executable file
·74 lines (57 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef VECTOR_HANDLER_CLASS_HPP
#define VECTOR_HANDLER_CLASS_HPP
#include <fftw3.h>
#include <math.h>
#include <stdio.h>
class VectorHandler{
int dim;
double dimCoeff;
public:
/* multiply two vectors componentwise and save result in the third
* one */
static void multiplyVecs(const double *f, const double *g, double *fg,
int size);
/* multiply square matrix and vector: b = A * x */
static void multiplyMatVec(double *A, double *x, double *b, int n);
/* shift vector left (not rolling) */
static void shiftLeft(double *f, int size, int shft);
/* copies vector to another storage */
static void copy(double *dst, const double *src, int count);
/* store vector into the file as list of pair 'x f(x)' */
static void storeVector(const double *f, const char *path, int size,
double step, double origin, int accurancy);
static double weight(int i, int n, double step)
{
return i == 0 || i == n - 1 ? step / 2 : step;
}
VectorHandler() : dim(1) { dimCoeff = 2.0; }
VectorHandler(int dim) : dim(dim)
{
dimCoeff = dim == 1 ? 2.0 : dim == 2 ? 2.0 * M_PI : 4.0 * M_PI;
}
const int getDimension() const { return dim; }
/* get integral dot product */
double getDot(const double *f, const double *g, int size, double step,
double origin) const;
/* return integral norm of vecor */
double getIntNorm(const double *f, int size, double step,
double origin) const;
/* return dispersion of vector using it as probability density */
double getDispersion(const double *f, int size, double step,
double origin) const;
/* return kurtosis of vector using it as probability density,
* with expected value equals 0
*/
double getKurtosis(const double *f, int size, double step,
double origin) const;
private:
/* TODO: make jacobian more logical and faster */
double jacobian(double x) const
{
return
dim == 1 ? 1.0 :
dim == 2 ? x :
x * x;
}
};
#endif