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