34 #if defined (HAVE_CONFIG_H)
68 if (
norm ==
static_cast<T
> (0.0))
69 error (
"filter: the first element of A must be nonzero");
72 if (dim < 0 || dim > x_dims.
ndims ())
73 error (
"filter: DIM must be a valid dimension");
80 if (si_len != ab_len - 1)
81 error (
"filter: first dimension of SI must be of length max (length (a), length (b)) - 1");
84 error (
"filter: dimensionality of SI and X must agree");
88 if (si_dims(i) != x_dims(i-1))
89 error (
"filter: dimensionality of SI and X must agree");
93 if (si_dims(i) != x_dims(i))
94 error (
"filter: dimensionality of SI and X must agree");
100 if (
norm !=
static_cast<T
> (1.0))
106 if (a_len <= 1 && si_len <= 0)
114 for (
int i = 0; i < dim; i++)
115 x_stride *= x_dims(i);
124 : num + (num / x_stride) * x_stride * (x_len - 1);
169 const T *pb = b.
data ();
170 const T *px =
x.data ();
175 const T *pa = a.
data ();
184 i++, idx += x_stride)
186 py[idx] =
psi[0] + pb[0] * px[idx];
193 ? lo + num_inner : num_execs-1;
197 psi[j] =
psi[j+1] - pa[j+1] * py[idx] + pb[j+1] * px[idx];
202 psi[iidx] = pb[si_len] * px[idx] - pa[si_len] * py[idx];
212 i++, idx += x_stride)
214 py[idx] =
psi[0] + pb[0] * px[idx];
221 ? lo + num_inner : num_execs-1;
225 psi[j] =
psi[j+1] + pb[j+1] * px[idx];
230 psi[si_len-1] = pb[si_len] * px[idx];
238 template <
typename T>
246 else if (dim > x_dims.
ndims ())
247 error (
"filter: DIM must be a valid dimension");
254 for (
int i = dim; i > 0; i--)
255 si_dims(i) = si_dims(i-1);
260 return filter (b, a,
x, si, dim);
366 int nargin = args.length ();
368 if (nargin < 3 || nargin > 5)
376 dim = args(4).nint_value () - 1;
377 if (dim < 0 || dim >= x_dims.
ndims ())
378 error (
"filter: DIM must be a valid dimension");
385 const char *a_b_errmsg =
"filter: A and B must be vectors";
386 const char *x_si_errmsg =
"filter: X and SI must be arrays";
388 bool isfloat = (args(0).is_single_type ()
389 || args(1).is_single_type ()
390 || args(2).is_single_type ()
391 || (nargin >= 4 && args(3).is_single_type ()));
393 if (args(0).iscomplex ()
394 || args(1).iscomplex ()
395 || args(2).iscomplex ()
396 || (nargin >= 4 && args(3).iscomplex ()))
406 if (nargin == 3 || args(3).isempty ())
414 for (
int i = dim; i > 0; i--)
415 si_dims(i) = si_dims(i-1);
422 si = args(3).xfloat_complex_array_value (x_si_errmsg);
430 retval =
ovl (y, si);
441 if (nargin == 3 || args(3).isempty ())
449 for (
int i = dim; i > 0; i--)
450 si_dims(i) = si_dims(i-1);
457 si = args(3).xcomplex_array_value (x_si_errmsg);
465 retval =
ovl (y, si);
479 if (nargin == 3 || args(3).isempty ())
487 for (
int i = dim; i > 0; i--)
488 si_dims(i) = si_dims(i-1);
495 si = args(3).xfloat_array_value (x_si_errmsg);
503 retval =
ovl (y, si);
510 NDArray x = args(2).xarray_value (x_si_errmsg);
514 if (nargin == 3 || args(3).isempty ())
522 for (
int i = dim; i > 0; i--)
523 si_dims(i) = si_dims(i-1);
530 si = args(3).xarray_value (x_si_errmsg);
538 retval =
ovl (y, si);
653 OCTAVE_END_NAMESPACE(
octave)
T * fortran_vec()
Size of the specified dimension.
bool isvector() const
Size of the specified dimension.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
const T * data() const
Size of the specified dimension.
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
octave_idx_type numel() const
Number of elements in the array.
Template for N-dimensional array classes with like-type math operators.
MArray< T > reshape(const dim_vector &new_dims) const
Vector representing the dimensions (size) of an Array.
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
octave_idx_type ndims() const
Number of dimensions.
int first_non_singleton(int def=0) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void() error(const char *fmt,...)
MArray< T > filter(MArray< T > &b, MArray< T > &a, MArray< T > &x, MArray< T > &si, int dim=0)
double norm(const ColumnVector &v)
F77_RET_T const F77_DBLE * x
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.