-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75586cb
commit 0a0fd9d
Showing
9 changed files
with
115 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
using namespace std; | ||
|
||
namespace mabcb7 | ||
{ | ||
using namespace std; | ||
|
||
typedef struct line { | ||
/* | ||
struct line { | ||
int x; | ||
int y; | ||
std::vector<float> points; | ||
} Line; | ||
*/ | ||
//typedef std::map<std::pair<float,float>, vector<float>> line; | ||
|
||
std::vector<mabcb7::Line> parseFile(const std::string filename); | ||
|
||
} | ||
|
||
//std::multimap<std::pair<float,float>, vector<float>> mapa; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "csvparse.cpp" | ||
#include "hw2.hpp" | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
if (argc != 2) | ||
{ | ||
std::cout << "Error incorrect command line arguments. USAGE: ./csvparse <path to file>" << std::endl; | ||
return 0; | ||
} | ||
|
||
line_map mapa = parseFile(argv[1]); | ||
line_map::iterator itr = mapa.begin(); | ||
std::vector<float> svector {9, 8, 7, 6, 5, 4, 3, 2, 1}; | ||
std::vector<result> results; | ||
|
||
std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now(); | ||
|
||
for (itr; itr !=mapa.end(); ++itr) | ||
{ | ||
results = (circularSubvectorMatch(svector, itr->second, 9, itr->first)); | ||
} | ||
|
||
sort(results.begin(), results.end()); | ||
results.resize(10); | ||
|
||
std::chrono::high_resolution_clock::time_point stop = std::chrono::high_resolution_clock::now(); | ||
std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double> >(stop - start); | ||
|
||
std::cout << "Swinging through once took: " << time_span.count() << " seconds." << std::endl; | ||
|
||
std::vector<result>::iterator it = results.begin(); | ||
|
||
for (it; it != results.end(); ++ it) | ||
{ | ||
cout << it->coord.first << ", " << it->coord.second << " " << it->offset << " " << it->distance << std::endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <math.h> | ||
|
||
struct result | ||
{ | ||
std::pair<float,float> coord; | ||
int offset; | ||
float distance; | ||
|
||
bool operator < (const result& str) const | ||
{ | ||
return (distance < str.distance); | ||
} | ||
}; | ||
|
||
std::vector<result> circularSubvectorMatch(std::vector<float> svector, std::vector<float> cir, int n, std::pair<float, float> coord) | ||
{ | ||
int i; | ||
int sizeOfSearch = svector.size(); | ||
int sizeOfCircle = cir.size(); | ||
|
||
int offset; | ||
result temp; | ||
std::vector<result> results; | ||
temp.coord = coord; | ||
|
||
for (offset = 0; offset < sizeOfCircle; offset += 5) | ||
{ | ||
for (i = offset; i < offset + n; i++) | ||
{ | ||
temp.distance += fabs(svector[i % sizeOfSearch] - cir[i % sizeOfCircle]); | ||
//cout << i << " " << offset << ": " << temp.distance << " += | " << svector[i % sizeOfSearch] << " - " << cir[i % sizeOfCircle] << " | " << std::endl; | ||
} | ||
|
||
temp.offset = offset; | ||
results.push_back(temp); | ||
|
||
} | ||
|
||
std::sort(results.begin(), results.end()); | ||
results.resize(10); | ||
return results; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.