30 const arma::vec &t_abscissa,
31 arma::cx_mat &f_signal,
32 arma::vec &f_abscissa,
37 arma::rowvec new_row = {df(0)};
38 df.insert_rows(0, new_row);
42 df.transform([](
double val){
return 1.0/val;});
45 f_abscissa = arma::linspace(1, df.n_rows+1, df.n_rows) % df;
48 if (f_abscissa.n_rows > n)
49 f_abscissa = f_abscissa.rows(0, n-1);
50 if (f_abscissa.n_rows < n){
51 double last_df = df(df.n_rows - 1);
52 double last_abs = f_abscissa(f_abscissa.n_rows - 1);
53 arma::uword rows_to_add = n - f_abscissa.n_rows;
54 arma::vec abs_end = arma::linspace(last_abs + last_df,
55 last_abs + (rows_to_add*last_df),
57 f_abscissa = arma::join_vert(f_abscissa, abs_end);
61 f_signal = arma::fft(t_signal, n);
73 const arma::vec f_abscissa,
74 arma::cx_mat &t_signal,
75 arma::vec &t_abscissa,
81 arma::rowvec new_row = {dt(0)};
82 dt.insert_rows(0, new_row);
86 dt.transform([](
double val){
return 1.0/val;});
89 t_abscissa = arma::linspace(1, dt.n_rows+1, dt.n_rows) % dt;
94 if (t_abscissa.n_rows > n)
95 t_abscissa = t_abscissa.rows(0, n-1);
96 if (t_abscissa.n_rows < n){
97 double last_dt = dt(dt.n_rows - 1);
98 double last_abs = t_abscissa(t_abscissa.n_rows - 1);
99 arma::uword rows_to_add = n - t_abscissa.n_rows;
100 arma::vec abs_end = arma::linspace(last_abs + last_dt,
101 last_abs + (rows_to_add*last_dt),
103 t_abscissa = arma::join_vert(t_abscissa, abs_end);
105 t_signal = arma::ifft(f_signal, n);
120 const arma::vec &abscissa,
121 const std::string &weight,
125 if (weight ==
"gaus"){
126 double coef = -1 * std::pow(param, 2.0);
127 weights = (coef * arma::pow(abscissa, 2.0)) / 2;
129 else if (weight ==
"exp"){
130 weights = arma::exp(-1*param*abscissa);
133 throw std::runtime_error(
"Unsupported value of weight");
135 arma::mat weighted_signal(signal.n_rows, signal.n_cols);
136 for (arma::uword i = 0; i < signal.n_cols; ++i)
137 weighted_signal.col(i) = signal.col(i) % weights;
138 return weighted_signal;
151 const arma::vec &abscissa,
152 const double &starting_offset,
153 const double &ending_offset,
159 double out_coef = 1.0/(abscissa.n_rows - 1);
162 double coef = arma::datum::pi * (starting_offset - ending_offset);
165 arma::vec offset = arma::datum::pi * starting_offset * arma::ones(abscissa.n_rows);
166 weights = arma::pow(arma::sin(out_coef*(offset+(coef*abscissa))), power);
168 arma::mat weighted_signal(signal.n_rows, signal.n_cols);
169 for (arma::uword i = 0; i < signal.n_cols; ++i)
170 weighted_signal.col(i) = signal.col(i) % weights;
171 return weighted_signal;
T diff(const T &X, arma::uword deriv_order=1)
Vespucci::Math::diff.