andrew@0: /* andrew@0: * DynamicVector.h andrew@0: * midiCannamReader andrew@0: * andrew@0: * Created by Andrew on 18/07/2011. andrew@0: * Copyright 2011 QMUL. All rights reserved. andrew@0: * andrew@0: */ andrew@0: andrew@0: //OPTIMIZE CONSTRAINED VECTOR andrew@0: andrew@0: #include "stdlib.h" andrew@0: #include "ofMain.h" andrew@0: #include "ofxWindowRegion.h" andrew@0: andrew@0: #ifndef _DYNAMIC_VECTOR andrew@0: #define _DYNAMIC_VECTOR andrew@0: #define GAUSSIAN_LOOKUP_LENGTH 1000000 andrew@0: andrew@0: class DynamicVector{ andrew@0: public: andrew@0: DynamicVector(); andrew@0: andrew@0: void createVector(int len); andrew@0: void renormalise(); andrew@0: void translateDistribution(int translationIndex); andrew@0: typedef std::vector DoubleVector; andrew@0: DoubleVector array; andrew@0: double getMaximum(); andrew@4: int getMAPestimate(); andrew@0: double getIntegratedEstimate(); andrew@0: double getLookupIndex(const int& i, const double& mean, const double& StdDev); andrew@0: void addGaussianShapeByLookupTable(double& mean, double& StdDev, double factor); andrew@0: double gaussianLookupTable[GAUSSIAN_LOOKUP_LENGTH]; andrew@0: double gaussianLookupMean, gaussianLookupStdDev; andrew@0: double integratedEstimate; andrew@0: void updateIntegratedEstimate(); andrew@0: void updateLimitedIntegratedEstimate(); andrew@0: andrew@0: void drawVector(const int& minIndex, const int& maxIndex); andrew@0: void drawVector(const int& minIndex, const int& maxIndex, ofxWindowRegion window); andrew@0: andrew@0: void drawConstrainedVector(const int& minIndex, const int& maxIndex, const int& minScreenIndex, const int& maxScreenIndex); andrew@6: void drawConstrainedVector(const int& minIndex, const int& maxIndex, const int& minScreenIndex, const int& maxScreenIndex, const ofxWindowRegion& window); andrew@0: andrew@0: void addConstant(const double& value); andrew@0: void addGaussianShape(const double& mean, const double& stddev, double factor); andrew@2: andrew@2: void addGaussianShapeFromRealTime(const double& actualTime, const double& StdDev, double factor); andrew@2: andrew@2: andrew@15: andrew@0: void addTriangularShape(double mean, double width, double factor); andrew@0: void addToIndex(const int& index, const double& constant); andrew@0: andrew@0: void doProduct(DynamicVector& arrayOne, DynamicVector& arrayTwo); andrew@0: andrew@0: double getIndexInRealTerms(const int& index); andrew@0: double getRealTermsAsIndex(double value); andrew@0: double getValueAtMillis(const double& millis); andrew@15: double millisToVectorUnits(const double& millis); andrew@0: andrew@0: void printArray(); andrew@0: void zero(); andrew@0: andrew@0: void copyFromDynamicVector(const DynamicVector& dynamicVec); andrew@0: andrew@0: //variables andrew@0: int length, arraySize; andrew@0: double maximumValue; andrew@0: int MAPestimate; andrew@0: andrew@0: double offset; andrew@0: double scalar;//each array point is this much of the quantity andrew@0: //i.e. array[index] contributes to (offset + scalar*index) in real terms andrew@0: andrew@0: }; andrew@0: andrew@0: #endif