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