annotate hackday/DynamicVector.h @ 52:13194a9dca77 tip

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