andrew@33
|
1 /*
|
andrew@33
|
2 * DynamicVector.h
|
andrew@33
|
3 * midiCannamReader
|
andrew@33
|
4 *
|
andrew@33
|
5 * Created by Andrew on 18/07/2011.
|
andrew@33
|
6 * Copyright 2011 QMUL. All rights reserved.
|
andrew@33
|
7 *
|
andrew@33
|
8 */
|
andrew@33
|
9
|
andrew@33
|
10 //OPTIMIZE CONSTRAINED VECTOR
|
andrew@33
|
11
|
andrew@33
|
12 #include "stdlib.h"
|
andrew@33
|
13 #include "ofMain.h"
|
andrew@33
|
14
|
andrew@33
|
15 #ifndef _DYNAMIC_VECTOR
|
andrew@33
|
16 #define _DYNAMIC_VECTOR
|
andrew@33
|
17 #define GAUSSIAN_LOOKUP_LENGTH 1000000
|
andrew@33
|
18
|
andrew@33
|
19 class DynamicVector{
|
andrew@33
|
20 public:
|
andrew@33
|
21 DynamicVector();
|
andrew@33
|
22
|
andrew@33
|
23 void createVector(int len);
|
andrew@33
|
24 void renormalise();
|
andrew@33
|
25 void translateDistribution(int translationIndex);
|
andrew@33
|
26 typedef std::vector<double> DoubleVector;
|
andrew@33
|
27 DoubleVector array;
|
andrew@33
|
28 double getMaximum();
|
andrew@46
|
29 int getMAPestimate();
|
andrew@46
|
30
|
andrew@33
|
31 double getIntegratedEstimate();
|
andrew@33
|
32 double getLookupIndex(const int& i, const double& mean, const double& StdDev);
|
andrew@33
|
33 void addGaussianShapeByLookupTable(double& mean, double& StdDev, double factor);
|
andrew@33
|
34 double gaussianLookupTable[GAUSSIAN_LOOKUP_LENGTH];
|
andrew@33
|
35 double gaussianLookupMean, gaussianLookupStdDev;
|
andrew@33
|
36 double integratedEstimate;
|
andrew@33
|
37 void updateIntegratedEstimate();
|
andrew@33
|
38 void updateLimitedIntegratedEstimate();
|
andrew@33
|
39
|
andrew@33
|
40 void drawVector(const int& minIndex, const int& maxIndex);
|
andrew@33
|
41 void drawConstrainedVector(const int& minIndex, const int& maxIndex, const int& minScreenIndex, const int& maxScreenIndex);
|
andrew@33
|
42
|
andrew@33
|
43 void addConstant(const double& value);
|
andrew@33
|
44 void addGaussianShape(const double& mean, const double& stddev, double factor);
|
andrew@44
|
45 void addGaussianShapeFromRealTime(const double& actualTime, const double& StdDev, double factor);
|
andrew@44
|
46
|
andrew@33
|
47 void addTriangularShape(double mean, double width, double factor);
|
andrew@33
|
48 void addToIndex(const int& index, const double& constant);
|
andrew@33
|
49
|
andrew@33
|
50 void doProduct(DynamicVector& arrayOne, DynamicVector& arrayTwo);
|
andrew@33
|
51
|
andrew@33
|
52 double getIndexInRealTerms(const int& index);
|
andrew@33
|
53 double getRealTermsAsIndex(double value);
|
andrew@33
|
54 double getValueAtMillis(const double& millis);
|
andrew@46
|
55 double millisToVectorUnits(const double& millis);
|
andrew@33
|
56
|
andrew@33
|
57 void printArray();
|
andrew@33
|
58 void zero();
|
andrew@33
|
59
|
andrew@33
|
60 void copyFromDynamicVector(const DynamicVector& dynamicVec);
|
andrew@33
|
61
|
andrew@33
|
62 //variables
|
andrew@33
|
63 int length, arraySize;
|
andrew@33
|
64 double maximumValue;
|
andrew@33
|
65 int MAPestimate;
|
andrew@33
|
66
|
andrew@33
|
67 double offset;
|
andrew@33
|
68 double scalar;//each array point is this much of the quantity
|
andrew@33
|
69 //i.e. array[index] contributes to (offset + scalar*index) in real terms
|
andrew@33
|
70
|
andrew@33
|
71 };
|
andrew@33
|
72
|
andrew@33
|
73 #endif
|