1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00
sdrangel/wdsp/snba.hpp

223 lines
5.5 KiB
C++
Raw Normal View History

2024-06-16 05:31:13 -04:00
/* snb.h
This file is part of a program that implements a Software-Defined Radio.
Copyright (C) 2015, 2016 Warren Pratt, NR0V
Copyright (C) 2024 Edouard Griffiths, F4EXB Adapted to SDRangel
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
The author can be reached by email at
warren@wpratt.com
*/
#ifndef wdsp_snba_h
#define wdsp_snba_h
2024-08-03 05:05:12 -04:00
#include <vector>
#include "export.h"
2024-07-02 18:52:16 -04:00
namespace WDSP{
2024-06-16 05:31:13 -04:00
class RESAMPLE;
2024-08-03 05:05:12 -04:00
class WDSP_API SNBA
2024-06-16 05:31:13 -04:00
{
public:
int run;
2024-06-24 21:50:48 -04:00
float* in;
float* out;
2024-06-16 05:31:13 -04:00
int inrate;
int internalrate;
int bsize;
int xsize;
int ovrlp;
int incr;
int iasize;
int iainidx;
int iaoutidx;
2024-08-03 05:05:12 -04:00
std::vector<double> inaccum;
std::vector<double> xbase;
2024-07-02 19:03:49 -04:00
double* xaux;
2024-06-16 05:31:13 -04:00
int nsamps;
int oasize;
int oainidx;
int oaoutidx;
int init_oaoutidx;
2024-08-03 05:05:12 -04:00
std::vector<double> outaccum;
2024-06-16 05:31:13 -04:00
int resamprun;
int isize;
RESAMPLE *inresamp;
RESAMPLE *outresamp;
2024-08-10 17:46:47 -04:00
std::vector<float> inbuff;
std::vector<float> outbuff;
double out_low_cut;
double out_high_cut;
2024-08-03 05:05:12 -04:00
static const int MAXIMP = 256;
2024-08-03 05:05:12 -04:00
struct Exec
2024-06-16 05:31:13 -04:00
{
int asize;
2024-08-03 05:05:12 -04:00
std::vector<double> a;
std::vector<double> v;
std::vector<int> detout;
std::vector<double> savex;
std::vector<double> xHout;
std::vector<int> unfixed;
2024-06-16 05:31:13 -04:00
int npasses;
2024-08-03 05:05:12 -04:00
Exec(int xsize, int _asize, int _npasses);
void fluxh();
};
Exec exec;
struct Det
2024-06-16 05:31:13 -04:00
{
2024-07-02 18:52:16 -04:00
double k1;
double k2;
2024-06-16 05:31:13 -04:00
int b;
int pre;
int post;
2024-08-03 05:05:12 -04:00
std::vector<double> vp;
std::vector<double> vpwr;
Det(
int xsize,
double k1,
double k2,
int b,
int pre,
int post
);
void flush();
};
Det sdet;
struct Scan
2024-06-16 05:31:13 -04:00
{
2024-07-02 18:52:16 -04:00
double pmultmin;
2024-08-03 05:05:12 -04:00
};
Scan scan;
struct Wrk
2024-06-16 05:31:13 -04:00
{
int xHat_a1rows_max;
int xHat_a2cols_max;
2024-08-03 05:05:12 -04:00
std::vector<double> xHat_r;
std::vector<double> xHat_ATAI;
std::vector<double> xHat_A1;
std::vector<double> xHat_A2;
std::vector<double> xHat_P1;
std::vector<double> xHat_P2;
std::vector<double> trI_y;
std::vector<double> trI_v;
std::vector<double> dR_z;
std::vector<double> asolve_r;
std::vector<double> asolve_z;
Wrk(
int xsize,
int asize
);
void flush();
};
Wrk wrk;
2024-06-16 05:31:13 -04:00
SNBA(
2024-06-16 05:31:13 -04:00
int run,
2024-06-24 21:50:48 -04:00
float* in,
float* out,
2024-06-16 05:31:13 -04:00
int inrate,
int internalrate,
int bsize,
int ovrlp,
int xsize,
int asize,
int npasses,
2024-07-02 18:52:16 -04:00
double k1,
double k2,
2024-06-16 05:31:13 -04:00
int b,
int pre,
int post,
2024-07-02 18:52:16 -04:00
double pmultmin,
double out_low_cut,
double out_high_cut
2024-06-16 05:31:13 -04:00
);
2024-08-10 17:46:47 -04:00
SNBA(const SNBA&) = delete;
SNBA& operator=(const SNBA& other) = delete;
~SNBA();
void flush();
void execute();
void setBuffers(float* in, float* out);
void setSamplerate(int rate);
void setSize(int size);
// Public Properties
void setOvrlp(int ovrlp);
void setAsize(int size);
void setNpasses(int npasses);
void setK1(double k1);
void setK2(double k2);
void setBridge(int bridge);
void setPresamps(int presamps);
void setPostsamps(int postsamps);
void setPmultmin(double pmultmin);
void setOutputBandwidth(double flow, double fhigh);
2024-06-16 05:31:13 -04:00
private:
void calc();
void decalc();
2024-08-03 05:05:12 -04:00
static void ATAc0 (int n, int nr, std::vector<double>& A, std::vector<double>& r);
static void multA1TA2(std::vector<double>& a1, std::vector<double>& a2, int m, int n, int q, std::vector<double>& c);
static void multXKE(std::vector<double>& a, const double* xk, int m, int q, int p, std::vector<double>& vout);
static void multAv(std::vector<double>& a, std::vector<double>& v, int m, int q, std::vector<double>& vout);
2024-06-16 05:31:13 -04:00
static void xHat(
int xusize,
int asize,
2024-08-03 05:05:12 -04:00
const double* xk,
std::vector<double>& a,
std::vector<double>& xout,
std::vector<double>& r,
std::vector<double>& ATAI,
std::vector<double>& A1,
std::vector<double>& A2,
std::vector<double>& P1,
std::vector<double>& P2,
std::vector<double>& trI_y,
std::vector<double>& trI_v,
std::vector<double>& dR_z
2024-06-16 05:31:13 -04:00
);
2024-08-03 05:05:12 -04:00
static void invf(int xsize, int asize, std::vector<double>& a, const double* x, std::vector<double>& v);
2024-06-16 05:31:13 -04:00
static int scanFrame(
int xsize,
int pval,
2024-07-02 18:52:16 -04:00
double pmultmin,
2024-08-03 05:05:12 -04:00
std::vector<int>& det,
std::array<int, MAXIMP>& bimp,
std::array<int, MAXIMP>& limp,
std::array<int, MAXIMP>& befimp,
std::array<int, MAXIMP>& aftimp,
std::array<int, MAXIMP>& p_opt,
2024-06-16 05:31:13 -04:00
int* next
);
2024-08-03 05:05:12 -04:00
void det(int asize, std::vector<double>& v, std::vector<int>& detout);
void execFrame(double* x);
2024-06-16 05:31:13 -04:00
};
2024-07-02 18:52:16 -04:00
} // namespace
2024-06-16 05:31:13 -04:00
#endif
2024-07-02 18:52:16 -04:00