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