36 int IIR::reset(
const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic> &Bin,
const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic> &Ain){
38 if (!(Ain.row(0).array()==1.0).all())
40 if (Ain.cols()!=Bin.cols())
44 int maxRows=std::max(
B.rows(),
A.rows());
45 mem=Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic>::Zero(maxRows,
A.cols());
49 int IIR::setMem(
const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic> &memIn){
50 if (
mem.cols()!=memIn.cols())
52 if (
mem.rows()!=memIn.rows())
59 if (
mem.rows()!=iir.
mem.rows())
61 unsigned int ch=std::min(
mem.cols(), iir.
mem.cols());
62 mem.block(0,0,
mem.rows(),ch)=iir.
mem.block(0,0,
mem.rows(),ch);
66 int IIR::process(
const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> &
x, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>
const &
y){
67 if (x.cols()!=
A.cols()){
68 printf(
"Input channel count %lld mismatch to filter channel count %lld", (
long long)x.cols(), (
long long)
A.cols());
71 if (y.cols()!=
A.cols()){
72 printf(
"Output channel count %lld mismatch to filter channel count %lld", (
long long)y.cols(), (
long long)
A.cols());
75 if (x.rows()!=y.rows()){
76 printf(
"Input sample count %lld not equal to output sample count %lld", (
long long)x.rows(), (
long long)y.rows());
80 if (y.rows() !=
yTemp.rows() && y.cols() !=
yTemp.cols())
81 yTemp.resize(y.rows(), y.cols());
83 for (
int i=0; i<x.rows(); i++){
85 mem.row(0)=-(
A*
mem.block(0, 0,
A.rows(),
A.cols())).colwise().sum();
86 yTemp.row(i)=(
B*
mem.block(0, 0,
B.rows(),
B.cols())).colwise().sum();
87 for (
int j=
mem.rows()-1; j>0; j--)
91 const_cast< Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>&
>(
y)=
yTemp;
95 int IIR::process(
const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> &
x, Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>
const &
y,
96 const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic> &BStep,
const Eigen::Array<double, Eigen::Dynamic, Eigen::Dynamic> &AStep){
97 if (x.cols()!=
A.cols()){
98 printf(
"Input channel count %lld mismatch to filter channel count %lld", (
long long)x.cols(), (
long long)
A.cols());
101 if (y.cols()!=
A.cols()){
102 printf(
"Output channel count %lld mismatch to filter channel count %lld", (
long long)y.cols(), (
long long)
A.cols());
105 if (x.rows()!=y.rows()){
106 printf(
"Input sample count %lld not equal to output sample count %lld", (
long long)x.rows(), (
long long)y.rows());
110 if ((BStep.cols()!=
B.cols()) || (AStep.cols()!=
A.cols()) || (
B.cols()!=
A.cols())){
111 printf(
"BStep or AStep channel count (%lld, %lld) mismatch to filter channel count %lld", (
long long)BStep.cols(), (
long long)AStep.cols(), (
long long)
A.cols());
115 if ((BStep.rows()!=
B.rows()) || (AStep.rows()!=
A.rows())){
116 printf(
"BStep order %lld not equal to B order %lld", (
long long)BStep.rows(), (
long long)
B.rows());
117 printf(
"OR AStep order %lld not equal to A order %lld", (
long long)AStep.rows(), (
long long)
A.rows());
121 if (y.rows() !=
yTemp.rows() && y.cols() !=
yTemp.cols())
122 yTemp.resize(y.rows(), y.cols());
124 for (
int i=0; i<x.rows(); i++){
125 mem.row(0)=-x.row(i);
126 mem.row(0)=-(
A*
mem.block(0, 0,
A.rows(),
A.cols())).colwise().sum();
127 yTemp.row(i)=(
B*
mem.block(0, 0,
B.rows(),
B.cols())).colwise().sum();
128 for (
int j=
mem.rows()-1; j>0; j--)
134 const_cast< Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>&
>(
y)=
yTemp;
int setMem(const Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > &memIn)
virtual int evaluateError(int errorNum)
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > A
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > B
#define IIR_CH_CNT_ERROR
Channel count mismatch error.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > yTemp
Eigen::Array< double, Eigen::Dynamic, Eigen::Dynamic > mem
#define IIR_A0_ERROR
Error when feedback coefficient A0 is not = 1.
#define IIR_N_CNT_ERROR
Channel count mismatch error.
int process(const Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > &x, Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > const &y)