diff options
author | mutantturkey <mutantturke@gmail.com> | 2012-06-14 18:34:23 -0400 |
---|---|---|
committer | mutantturkey <mutantturke@gmail.com> | 2012-06-14 18:34:23 -0400 |
commit | 53b73dec4d6e71899d183335509591b7c89a419b (patch) | |
tree | 256e96682ba4ce1bcb1aa86d228a212a0193197b /fly-tools/misc/test.cpp | |
parent | bc2747f47bc2153642da518ea8afa7f5b4859819 (diff) |
pushing the fly-tools into this repository
Diffstat (limited to 'fly-tools/misc/test.cpp')
-rw-r--r-- | fly-tools/misc/test.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/fly-tools/misc/test.cpp b/fly-tools/misc/test.cpp new file mode 100644 index 0000000..a709482 --- /dev/null +++ b/fly-tools/misc/test.cpp @@ -0,0 +1,92 @@ +#include<iostream> +#include<vector> + +using namespace std; + +void largestIncreasingPositiveDotProductSeq(vector<double> velocityDirs, int &startIndex, int &endIndex) { + + int positiveVelSeqSize = 0; + int flag = false; + int maxSeqSize = 0; + int st = 0; + for (int j=0; j<velocityDirs.size()-1; j++) { + double prevVel = velocityDirs[j]; + double currVel = velocityDirs[j+1]; + + double dotProd = prevVel*currVel; + + if( dotProd > 0 && flag == false) { + st = j; + positiveVelSeqSize++; + flag = true; + cout << "In first if positiveSize "<<positiveVelSeqSize<<endl; + + } else if (dotProd > 0 && flag == true) { + positiveVelSeqSize++; + cout << "In second if positive "<<positiveVelSeqSize<<endl; + } else { + positiveVelSeqSize = 0; + flag = false; + cout << "Else\n"; + + } + + if (positiveVelSeqSize > maxSeqSize) { + maxSeqSize = positiveVelSeqSize; + startIndex = st; + endIndex = st+positiveVelSeqSize; + cout << "maxseq updated \npositiveSize "<<positiveVelSeqSize<<endl; + cout << "st "<<startIndex<<endl; + cout << "end "<<endIndex<<endl; + } + + + + } + +} + +int main () { + + vector<double> test(4); + test[0]=0; + test[1]=7; + test[2]=0; + test[3]=7; + /*test[4]=5; + test[5]=2; + test[6]=-3; + test[7]=-4; + test[8]=2; + test[9]=3; + */ + int st; + int endIndex; + + largestIncreasingPositiveDotProductSeq(test,st, endIndex ); + for (int i=st; i<=endIndex; i++) { + cout << test[i]<<endl; + } + cout << st << endl; + cout << endIndex<<endl; + + /*cout << "index"<<endl; + int size = 0; + int i; + int end = 14; + st = 0; + int c; + for (i=end; i>=st; i=i-5) { + c = i; + cout << c << endl; + size++; + } + if ((c-st) != 0) { + cout <<"additional " <<st<<endl; + size++; + } + cout << "last i "<<i; + cout << "size = "; + cout << size <<endl; + */ +} |