HDIM  1.0.0
Packages for High Dimensional Linear Regression
perf_fos.hpp
1 #ifndef PERF_FOS_H
2 #define PERF_FOS_H
3 
4 // C System-Headers
5 //
6 // C++ System headers
7 #include <cmath>
8 // Eigen Headers
9 #include <eigen3/Eigen/Dense>
10 // Boost Headers
11 //
12 // SPAMS Headers
13 //
14 // Armadillo Headers
15 //
16 // Project Specific Headers
17 #include "fos.hpp"
18 #include "x_fos.hpp"
19 
20 namespace hdim {
21 
22 template < typename T >
23 std::vector< T > PerfFOS() {
24 
25  std::cout << "Timing FOS for data type: " << get_type_name<T>() << std::endl;
26 
27  std::string data_set_path = "/home/bephillips2/Desktop/Hanger Bay 1/Academia/HDIM/test_data.csv";
28 
29  Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > raw_data = CSV2Eigen< T >( data_set_path );
30 
31  std::cout << "Imported an m = " << raw_data.rows() << " by n = " << raw_data.cols() << " Matrix." << std::endl;
32 
33  std::vector < T > timing_results;
34 
35  for( unsigned int k = 200; k <= 2000 ; k += 200 ) {
36 
37  std::cout << "Testing FOS for a " \
38  << k \
39  << "x" \
40  << k \
41  << "Matrix: \n" \
42  << std::endl;
43 
44  Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > X = raw_data.block( 0, 1, k, k );
45  Eigen::Matrix< T, Eigen::Dynamic, 1 > Y = raw_data.block( 0, 0, k, 1 );
46 
47  FOS< T > algo_fos ( X, Y );
48 
49  auto start = std::chrono::high_resolution_clock::now();
50 
51  algo_fos.Algorithm();
52 
53  auto end = std::chrono::high_resolution_clock::now();
54  std::chrono::duration<double, std::milli> ms = end - start;
55  auto time_taken = ms.count();
56 
57  std::cout << "FOS took " << time_taken << " ms." << std::endl;
58 
59  timing_results.push_back( time_taken );
60  }
61 
62  return timing_results;
63 }
64 
65 namespace experimental {
66 
67 template < typename T >
68 std::vector< T > PerfX_FOS( SolverType s_type ) {
69 
70  std::cout << "Timing FOS for data type: " << get_type_name<T>() << std::endl;
71 
72  std::string data_set_path = "/home/bephillips2/Desktop/Hanger Bay 1/Academia/HDIM/test_data.csv";
73 
74  Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > raw_data = CSV2Eigen< T >( data_set_path );
75 // Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > raw_data = Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic >::Random( 2000, 2001 );
76 
77  std::cout << "Imported an m = " << raw_data.rows() << " by n = " << raw_data.cols() << " Matrix." << std::endl;
78 
79  std::vector < T > timing_results;
80 
81  for( unsigned int k = 200; k <= 2000 ; k += 200 ) {
82 
83  std::cout << "Testing FOS for a " \
84  << k \
85  << "x" \
86  << k \
87  << "Matrix: \n" \
88  << std::endl;
89 
90  Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > X = raw_data.block( 0, 1, k, k );
91  Eigen::Matrix< T, Eigen::Dynamic, 1 > Y = raw_data.block( 0, 0, k, 1 );
92 
93  X_FOS< T > algo_fos;
94 
95  auto start = std::chrono::high_resolution_clock::now();
96 
97  algo_fos( X, Y, s_type );
98 
99  auto end = std::chrono::high_resolution_clock::now();
100  std::chrono::duration<double, std::milli> ms = end - start;
101  auto time_taken = ms.count();
102 
103  std::cout << "FOS took " << time_taken << " ms." << std::endl;
104 
105  timing_results.push_back( time_taken );
106  }
107 
108  return timing_results;
109 }
110 
111 }
112 
113 }
114 
115 #endif // PERF_FOS_H
Definition: fos.hpp:18