example.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include <Eigen/Dense>
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <igl/sort.h>
  5. #include <igl/unique.h>
  6. #include <igl/get_seconds.h>
  7. #include <igl/colon.h>
  8. #include <igl/slice.h>
  9. #include <igl/sortrows.h>
  10. #include <igl/readDMAT.h>
  11. #include <igl/writeDMAT.h>
  12. int main(int argc, char * argv[])
  13. {
  14. using namespace Eigen;
  15. using namespace std;
  16. using namespace igl;
  17. //MatrixXd X;
  18. //if(!readDMAT("X.dmat",X))
  19. //{
  20. // X = MatrixXd::Random(766443,2);
  21. // for(int x = 0;x<X.size();x++)
  22. // {
  23. // X(x) = floor(X(x)*680);
  24. // }
  25. //}
  26. MatrixXd X(4,2);
  27. //X << 1,2,1,2,1,1,2,2;
  28. X << 1,3,2,4,6,1,7,2;
  29. cout<<X<<endl<<endl;
  30. typedef MatrixXi::Scalar Scalar;
  31. bool ascending = false;
  32. const int dim = 2;
  33. double t;
  34. //#define NUM_RUNS 100
  35. // MatrixXd Y;
  36. // MatrixXi IX;
  37. // t = get_seconds();
  38. // for(int r = 0;r<NUM_RUNS;r++)
  39. // sort(X,dim,ascending,Y,IX);
  40. // cout<<(get_seconds()-t)/(double)NUM_RUNS<<endl;
  41. // //cout<<Y<<endl<<endl;
  42. // //cout<<IX<<endl<<endl;
  43. // MatrixXd Y2;
  44. // MatrixXi IX2;
  45. // t = get_seconds();
  46. // for(int r = 0;r<NUM_RUNS;r++)
  47. // sort2(X,dim,ascending,Y2,IX2);
  48. // cout<<(get_seconds()-t)/(double)NUM_RUNS<<endl;
  49. // //cout<<Y2<<endl<<endl;
  50. // //cout<<IX2<<endl<<endl;
  51. #define NUM_RUNS 1
  52. MatrixXd Y;
  53. VectorXi IA,IC;
  54. t = get_seconds();
  55. for(int r = 0;r<NUM_RUNS;r++)
  56. unique_rows(X,Y,IA,IC);
  57. cout<<(get_seconds()-t)/(double)NUM_RUNS<<endl;
  58. t = get_seconds();
  59. for(int r = 0;r<NUM_RUNS;r++)
  60. sortrows(X,true,Y,IC);
  61. cout<<(get_seconds()-t)/(double)NUM_RUNS<<endl;
  62. writeDMAT("X.dmat",X,true);
  63. writeDMAT("Y.dmat",Y,true);
  64. writeDMAT("IC.dmat",IC,true);
  65. //cout<<Y<<endl<<endl;
  66. //cout<<IA<<endl<<endl;
  67. //cout<<IC<<endl<<endl;
  68. cout<<Y.rows()<<endl;
  69. }