annotate src/DynamicVector.h @ 4:4a8e6a6cd224

optimised draw function in dynamic vector class. Added Gaussian lookup but not yet used.
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Fri, 19 Aug 2011 15:53:04 +0100
parents 5581023e0de4
children 75dcd1308658
rev   line source
andrew@0 1 /*
andrew@0 2 * DynamicVector.h
andrew@0 3 * midiCannamReader
andrew@0 4 *
andrew@0 5 * Created by Andrew on 18/07/2011.
andrew@0 6 * Copyright 2011 QMUL. All rights reserved.
andrew@0 7 *
andrew@0 8 */
andrew@0 9
andrew@0 10 //OPTIMIZE CONSTRAINED VECTOR
andrew@0 11
andrew@0 12 #include "stdlib.h"
andrew@0 13 #include "ofMain.h"
andrew@0 14
andrew@0 15 #ifndef _DYNAMIC_VECTOR
andrew@0 16 #define _DYNAMIC_VECTOR
andrew@4 17 #define GAUSSIAN_LOOKUP_LENGTH 1000000
andrew@0 18
andrew@0 19 class DynamicVector{
andrew@0 20 public:
andrew@0 21 DynamicVector();
andrew@0 22
andrew@0 23 void createVector(int len);
andrew@0 24 void renormalise();
andrew@0 25 void translateDistribution(int translationIndex);
andrew@0 26 typedef std::vector<double> DoubleVector;
andrew@0 27 DoubleVector array;
andrew@0 28 double getMaximum();
andrew@2 29 double getIntegratedEstimate();
andrew@4 30 double getLookupIndex(const int& i, const double& mean, const double& StdDev);
andrew@4 31 void addGaussianShapeByLookupTable(double& mean, double& StdDev, double& factor);
andrew@4 32 double gaussianLookupTable[GAUSSIAN_LOOKUP_LENGTH];
andrew@4 33 double gaussianLookupMean, gaussianLookupStdDev;
andrew@4 34
andrew@2 35
andrew@0 36 void drawVector(const int& minIndex, const int& maxIndex);
andrew@0 37 void drawConstrainedVector(const int& minIndex, const int& maxIndex, const int& minScreenIndex, const int& maxScreenIndex);
andrew@0 38
andrew@0 39 void addConstant(double value);
andrew@0 40 void addGaussianShape(double mean, double stddev, double factor);
andrew@2 41 void addTriangularShape(double mean, double width, double factor);
andrew@0 42 void addToIndex(int index, double constant);
andrew@0 43
andrew@0 44 void doProduct(DynamicVector& arrayOne, DynamicVector& arrayTwo);
andrew@0 45
andrew@0 46 double getIndexInRealTerms(const int& index);
andrew@0 47 double getRealTermsAsIndex(double value);
andrew@1 48 double getValueAtMillis(const double& millis);
andrew@0 49
andrew@0 50 void printArray();
andrew@0 51 void zero();
andrew@0 52
andrew@0 53 void copyFromDynamicVector(const DynamicVector& dynamicVec);
andrew@0 54
andrew@0 55 //variables
andrew@0 56 int length, arraySize;
andrew@0 57 double maximumValue;
andrew@0 58 int MAPestimate;
andrew@0 59
andrew@0 60 double offset;
andrew@0 61 double scalar;//each array point is this much of the quantity
andrew@0 62 //i.e. array[index] contributes to (offset + scalar*index) in real terms
andrew@0 63
andrew@0 64 };
andrew@0 65
andrew@0 66 #endif