SigPack - the C++ signal processing library
parser.cpp
Go to the documentation of this file.
1 
64 #include "sigpack.h"
65 using namespace arma;
66 using namespace sp;
67 int main()
68 {
69  // Set defaults
70  rowvec def_vec = randu<rowvec>(10);
71  cx_vec def_vec_cx = randu<cx_vec>(10);
72  mat def_mat = randu<mat>(5, 5);
73  cx_mat def_matx = randu<cx_mat>(5, 5);
74  Col<int> def_vec_int;
75  def_vec_int << 1 << 2 << 3 << 4;
76 
77  // Create parser
78  parser testpar("test.par");
79 
80  rowvec x = testpar.getRow("x", def_vec); // Row vector
81  cx_vec y = testpar.getCxCol("y", def_vec_cx); // Col vector complex
82  mat A = testpar.getMat("A", def_mat); // Mat
83  cx_mat B = testpar.getCxMat("B", def_matx); // Mat complex
84  std::string my_text = testpar.getString("my_text", "DEFAULT"); // String
85  int N = testpar.getParam<int>("N", 125000); // Int
86  double pi_val = testpar.getParam<double>("pi_val", 3.1); // Double
87  Col<int> Z = testpar.getCol("Z", def_vec_int); // Col integer - false test
88 
89  std::cout << "my_text= " << my_text << std::endl;
90  std::cout << "N= " << N << std::endl;
91  std::cout << "pi_val= " << pi_val << std::endl;
92  std::cout << "x= \n" << x << std::endl;
93  std::cout << "y= \n" << y << std::endl;
94  std::cout << "A= \n" << A << std::endl;
95  std::cout << "B= \n" << B << std::endl;
96  std::cout << "Z= \n" << Z << std::endl;
97 
98  return 0;
99 }
T getParam(const std::string key, const T def_val)
Generic type get function.
Definition: parser.h:168
arma::cx_mat getCxMat(const std::string key, const arma::cx_mat def_val)
cx_mat type get function.
Definition: parser.h:357
std::string getString(const std::string key, const std::string def_val)
String type get function.
Definition: parser.h:188
Definition: base.h:7
arma::cx_vec getCxCol(const std::string key, const arma::cx_vec def_val)
cx_vec type get function.
Definition: parser.h:233
arma::Mat< T > getMat(const std::string key, const arma::Mat< T > def_val)
Mat type get function.
Definition: parser.h:315
A parser class.
Definition: parser.h:20
int main()
Definition: parser.cpp:67
arma::Col< T > getCol(const std::string key, const arma::Col< T > def_val)
Col type get function.
Definition: parser.h:205
arma::Row< T > getRow(const std::string key, const arma::Row< T > def_val)
Row type get function.
Definition: parser.h:260