HDIM  1.0.0
Packages for High Dimensional Linear Regression
test_ista.hpp
1 #ifndef TEST_ISTA_H
2 #define TEST_ISTA_H
3 
4 
5 // C System-Headers
6 //
7 // C++ System headers
8 #include <cmath>
9 // Eigen Headers
10 #include <eigen3/Eigen/Dense>
11 #include <Eigen/IterativeLinearSolvers>
12 // Boost Headers
13 //
14 // SPAMS Headers
15 //
16 // Armadillo Headers
17 //
18 // Project Specific Headers
19 #include "../Generic/debug.hpp"
20 #include "../Generic/generics.hpp"
21 #include "ista.hpp"
22 
23 void TestIsta( unsigned int num_rows, unsigned int num_cols ) {
24 
25  auto X = build_matrix<float>( num_rows, num_cols, &eucl_distance );
26  auto Y = X.col(0);
27  auto W_0 = Eigen::Matrix< float, Eigen::Dynamic, 1 > ( num_rows, 1 );
28  W_0.setZero();
29 
30  float lambda = 1.0;
31 
32  Eigen::Matrix< float, Eigen::Dynamic, 1 > ista_retval = ISTA< float >( X, Y, W_0, 10, 0.1, lambda );
33 
34  std::cout << "ISTA result:\n" << ista_retval.squaredNorm() << std::endl;
35 }
36 
37 void RunIstaTests() {
38 
39  for ( unsigned int k = 200; k <= 2000; k+= 200 ) {
40 
41  std::cout << "Testing ISTA for a " \
42  << k \
43  << "x" \
44  << k \
45  << "Matrix: \n" \
46 // << build_matrix<float>( k, k, &eucl_distance )
47  << std::endl;
48 
49  TestIsta( k, k );
50  }
51 }
52 
53 #endif // TEST_ISTA_H