signal.h (2014-04-30 15:38:09 -0400, (build fd32605))
Go to the documentation of this file.
1 //-----------------------------------------------------------------------//
2 // Copyright (c) AccelerEyes LLC. All rights reserved. //
3 // See http://www.accelereyes.com/eula for details. //
4 // This software is distributed WITHOUT ANY WARRANTY; without even //
5 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
6 // PURPOSE. See the above copyright notices for more information. //
7 //-----------------------------------------------------------------------//
8 
9 #pragma once
10 
11 #include "defines.h"
12 #include "dims.h"
13 #include "constants.h"
14 
261 namespace af {
262  class array;
263  class dim4;
264 
280  AFAPI array fft(const array&, int pad=-1);
281 
292  AFAPI array fft2(const array&, int nx=-1, int ny=-1);
293 
301  AFAPI array fft3(const array&, const dim4& dims=dim4(0));
302 
315  AFAPI array ifft(const array&, int pad=-1);
316 
328  AFAPI array ifft2(const array&, int nx=-1, int ny=-1);
329 
338  AFAPI array ifft3(const array&, const dim4& dims=dim4(0));
339 
359  AFAPI array fir(int nb, const float* h_b, const array& x);
360 
370  AFAPI array fir(const array& b, const array& x);
371 
392  AFAPI array iir(int nb, const float* h_b, int na, const float* h_a, const array& x);
393 
400  AFAPI array iir(const array& b, const array& a, const array& x);
401 
421  AFAPI array convolve(const array& f1,
422  const array& f2,
423  const array& signal,
424  bool expand = false);
425 
436  template<typename ty> array convolve(unsigned n1,
437  const ty *h_f1,
438  unsigned n2,
439  const ty *h_f2,
440  const array& signal,
441  bool expand = false);
442 
458  AFAPI array convolve(const array& signal, const array& filter, bool expand = false);
459 
460 
480  template<typename ty> array convolve(const array& signal,
481  unsigned ndims,
482  unsigned *dims,
483  const ty *h_kernel,
484  bool expand = false);
485 
507  AFAPI array approx1(const array& Y,
508  const array& Xi,
509  char method='L',
510  float offgrid=af::NaN);
511 
522  AFAPI array approx2(const array& Z,
523  const array& Xi,
524  const array& Yi,
525  char method='L',
526  float offgrid=af::NaN);
527 
531 }
532 
533 #ifdef __cplusplus
534 extern "C" {
535 #endif
536 
556  AFAPI afError af_fft_S(dim3 dim_O, cfloat *d_O,
558  dim3 dim_I, const float *d_I,
559  unsigned batch, int dim, int direction);
561  AFAPI afError af_fft_C(dim3 dim_O, cfloat *d_O,
562  dim3 dim_I, const cfloat *d_I,
563  unsigned batch, int dim, int direction);
565  AFAPI afError af_fft_D(dim3 dim_O, cdouble *d_O,
566  dim3 dim_I, const double *d_I,
567  unsigned batch, int dim, int direction);
569  AFAPI afError af_fft_Z(dim3 dim_O, cdouble *d_O,
570  dim3 dim_I, const cdouble *d_I,
571  unsigned batch, int dim, int direction);
572 
585  AFAPI afError af_fft2_S(unsigned xo, unsigned yo, cfloat *d_O,
587  unsigned xi, unsigned yi, const float *d_I,
588  unsigned batch, int direction);
590  AFAPI afError af_fft2_C(unsigned xo, unsigned yo, cfloat *d_O,
591  unsigned xi, unsigned yi,
592  const cfloat *d_I,
593  unsigned batch, int direction);
595  AFAPI afError af_fft2_D(unsigned xo, unsigned yo, cdouble *d_O,
596  unsigned xi, unsigned yi, const double *d_I,
597  unsigned batch, int direction);
599  AFAPI afError af_fft2_Z(unsigned xo, unsigned yo, cdouble *d_O,
600  unsigned xi, unsigned yi,
601  const cdouble *d_I,
602  unsigned batch, int direction);
603 
613  AFAPI afError af_fft3_S(dim3 dims_O, cfloat *d_O,
615  dim3 dims_I, const float *d_I,
616  unsigned batch, int direction);
618  AFAPI afError af_fft3_C(dim3 dims_O, cfloat *d_O,
619  dim3 dims_I, const cfloat *d_I,
620  unsigned batch, int direction);
622  AFAPI afError af_fft3_D(dim3 dims_O, cdouble *d_O,
623  dim3 dims_I, const double *d_I,
624  unsigned batch, int direction);
626  AFAPI afError af_fft3_Z(dim3 dims_O, cdouble *d_O,
627  dim3 dims_I, const cdouble *d_I,
628  unsigned batch, int direction);
629 
645  AFAPI afError af_fft_setplans(int max_plans);
648 
650  AFAPI afError af_fft_clear(void);
651 
653  AFAPI void af_fft_info(void);
654 
681  AFAPI afError af_filter1D_S(float *d_out,
683  unsigned len_in, const float *d_in,
684  unsigned len_a , const float *h_a,
685  unsigned len_b , const float *h_b,
686  const float *d_init, float *d_final,
687  unsigned Nin, unsigned Ninit);
690  unsigned len_in, const cfloat *d_in,
691  unsigned len_a , const float *h_a,
692  unsigned len_b , const float *h_b,
693  const cfloat *d_init, cfloat *d_final,
694  unsigned Nin, unsigned Ninit);
696  AFAPI afError af_filter1D_D(double *d_out,
697  unsigned len_in, const double *d_in,
698  unsigned len_a , const double *h_a,
699  unsigned len_b , const double *h_b,
700  const double *d_init, double *d_final,
701  unsigned Nin, unsigned Ninit);
704  unsigned len_in, const cdouble *d_in,
705  unsigned len_a , const double *h_a,
706  unsigned len_b , const double *h_b,
707  const cdouble *d_init, cdouble *d_final,
708  unsigned Nin, unsigned Ninit);
709 
734  AFAPI afError af_conv_SS(float *d_out,
736  unsigned ni, const float *d_in, unsigned batchi,
737  unsigned nf, const float *d_filt, unsigned batchf,
738  bool expand);
741  unsigned ni, const cfloat *d_in, unsigned batchi,
742  unsigned nf, const float *d_filt, unsigned batchf,
743  bool expand);
746  unsigned ni, const cfloat *d_in, unsigned batchi,
747  unsigned nf, const cfloat *d_filt, unsigned batchf,
748  bool expand);
750  AFAPI afError af_conv_DD(double *d_out,
751  unsigned ni, const double *d_in, unsigned batchi,
752  unsigned nf, const double *d_filt, unsigned batchf,
753  bool expand);
756  unsigned ni, const cdouble *d_in, unsigned batchi,
757  unsigned nf, const double *d_filt, unsigned batchf,
758  bool expand);
761  unsigned ni, const cdouble *d_in, unsigned batchi,
762  unsigned nf, const cdouble *d_filt, unsigned batchf,
763  bool expand);
776  AFAPI afError af_conv2_SS(float *d_out,
778  unsigned mi, unsigned ni, const float *d_in, unsigned batch_in,
779  unsigned mf, unsigned nf, const float *d_filt, unsigned batch_filt,
780  bool expand);
783  unsigned mi, unsigned ni, const cfloat *d_in, unsigned batch_in,
784  unsigned mf, unsigned nf, const float *d_filt, unsigned batch_filt,
785  bool expand);
788  unsigned mi, unsigned ni, const cfloat *d_in, unsigned batch_in,
789  unsigned mf, unsigned nf, const cfloat *d_filt, unsigned batch_filt,
790  bool expand);
792  AFAPI afError af_conv2_DD(double *d_out,
793  unsigned mi, unsigned ni, const double *d_in, unsigned batch_in,
794  unsigned mf, unsigned nf, const double *d_filt, unsigned batch_filt,
795  bool expand);
798  unsigned mi, unsigned ni, const cdouble *d_in, unsigned batch_in,
799  unsigned mf, unsigned nf, const double *d_filt, unsigned batch_filt,
800  bool expand);
803  unsigned mi, unsigned ni, const cdouble *d_in, unsigned batch_in,
804  unsigned mf, unsigned nf, const cdouble *d_filt, unsigned batch_filt,
805  bool expand);
806 
820  AFAPI afError af_convn_SS(float *d_out,
822  unsigned ndimsi, unsigned *dimsi,
823  const float *d_in, unsigned batchi,
824  unsigned ndimsf, unsigned *dimsf,
825  const float *d_filt, unsigned batchf,
826  bool expand);
829  unsigned ndimsi, unsigned *dimsi,
830  const cfloat *d_in, unsigned batchi,
831  unsigned ndimsf, unsigned *dimsf,
832  const float *d_filt, unsigned batchf,
833  bool expand);
836  unsigned ndimsi, unsigned *dimsi,
837  const cfloat *d_in, unsigned batchi,
838  unsigned ndimsf, unsigned *dimsf,
839  const cfloat *d_filt, unsigned batchf,
840  bool expand);
842  AFAPI afError af_convn_DD(double *d_out,
843  unsigned ndimsi, unsigned *dimsi,
844  const double *d_in, unsigned batchi,
845  unsigned ndimsf, unsigned *dimsf,
846  const double *d_filt, unsigned batchf,
847  bool expand);
850  unsigned ndimsi, unsigned *dimsi,
851  const cdouble *d_in, unsigned batchi,
852  unsigned ndimsf, unsigned *dimsf,
853  const double *d_filt, unsigned batchf,
854  bool expand);
857  unsigned ndimsi, unsigned *dimsi,
858  const cdouble *d_in, unsigned batchi,
859  unsigned ndimsf, unsigned *dimsf,
860  const cdouble *d_filt, unsigned batchf,
861  bool expand);
862 
877  AFAPI afError af_convh_SS(float *d_out,
879  unsigned ndimsi, unsigned *dimsi,
880  const float *d_in, unsigned batchi,
881  unsigned ndimsf, unsigned *dimsf,
882  const float *h_filt, unsigned batchf,
883  bool expand);
886  unsigned ndimsi, unsigned *dimsi,
887  const cfloat *d_in, unsigned batchi,
888  unsigned ndimsf, unsigned *dimsf,
889  const float *h_filt, unsigned batchf,
890  bool expand);
892  AFAPI afError af_convh_DD(double *d_out,
893  unsigned ndimsi, unsigned *dimsi,
894  const double *d_in, unsigned batchi,
895  unsigned ndimsf, unsigned *dimsf,
896  const double *h_filt, unsigned batchf,
897  bool expand);
900  unsigned ndimsi, unsigned *dimsi,
901  const cdouble *d_in, unsigned batchi,
902  unsigned ndimsf, unsigned *dimsf,
903  const double *h_filt, unsigned batchf,
904  bool expand);
929  AFAPI afError af_scale2D_S(float *d_ZI,
931  unsigned md,
932  unsigned nd,
933  const float *d_Z,
934  int factor,
935  char method);
936 
937  AFAPI afError af_scale2D_D(double *d_ZI,
938  unsigned md,
939  unsigned nd,
940  const double *d_Z,
941  int factor,
942  char method);
943 
945  unsigned md,
946  unsigned nd,
947  const cfloat *d_Z,
948  int factor,
949  char method);
950 
952  unsigned md,
953  unsigned nd,
954  const cdouble *d_Z,
955  int factor,
956  char method);
957 
959  AFAPI afError af_scale2D_c(char *d_ZI,
960  unsigned md,
961  unsigned nd,
962  const char *d_Z,
963  int factor,
964  char method);
965 
978 #define APPROX(ty, tx, T) \
979  AFAPI afError af_approx1_##T(ty *d_YI, \
980  unsigned n, \
981  const ty *d_Y , unsigned batch_Y, \
982  unsigned ni, \
983  const tx *d_XI, unsigned batch_XI, \
984  char method, float offgrid)
985 
1000  APPROX(float,float,S);
1001  APPROX(double,double,D);
1002  APPROX(cfloat,float,C);
1003  APPROX(cdouble,double,Z);
1004 
1005 #undef APPROX
1006 
1007 
1008 #define APPROX(tz, ti, T) \
1009  AFAPI afError af_approx2_##T(tz *d_ZI, \
1010  unsigned nx, unsigned ny, \
1011  const tz *d_Z, unsigned batch_Z, \
1012  unsigned ni, \
1013  const ti *d_XI, unsigned batch_XI, \
1014  const ti *d_YI, unsigned batch_YI, \
1015  char method, float offgrid)
1016 
1034  APPROX(float, float, S);
1035  APPROX(double,double, D);
1036  APPROX(cfloat, float, C);
1037  APPROX(cdouble, double, Z);
1038 
1039 #undef APPROX
1040 
1044 #ifdef __cplusplus
1045 } // end namespace af
1046 #endif
afError af_fft2_S(unsigned xo, unsigned yo, cfloat *d_O, unsigned xi, unsigned yi, const float *d_I, unsigned batch, int direction)
Single precision, two dimensional fft.
afError af_conv2_ZZ(cdouble *d_out, unsigned mi, unsigned ni, const cdouble *d_in, unsigned batch_in, unsigned mf, unsigned nf, const cdouble *d_filt, unsigned batch_filt, bool expand)
Double precision, complex input, complex filter, two dimensional convolution.
afError af_fft_S(dim3 dim_O, cfloat *d_O, dim3 dim_I, const float *d_I, unsigned batch, int dim, int direction)
Single precision, One dimensional fft along dimension.
afError af_scale2D_Z(cdouble *d_ZI, unsigned md, unsigned nd, const cdouble *d_Z, int factor, char method)
array iir(int nb, const float *h_b, int na, const float *h_a, const array &x)
afError af_conv_CC(cfloat *d_out, unsigned ni, const cfloat *d_in, unsigned batchi, unsigned nf, const cfloat *d_filt, unsigned batchf, bool expand)
Float precision, complex input, complex filter, one dimensional convolution.
array fir(int nb, const float *h_b, const array &x)
afError af_convn_ZD(cdouble *d_out, unsigned ndimsi, unsigned *dimsi, const cdouble *d_in, unsigned batchi, unsigned ndimsf, unsigned *dimsf, const double *d_filt, unsigned batchf, bool expand)
Double precision, complex input, real filter, multi-dimensional convolution.
afError af_scale2D_C(cfloat *d_ZI, unsigned md, unsigned nd, const cfloat *d_Z, int factor, char method)
afError af_conv2_ZD(cdouble *d_out, unsigned mi, unsigned ni, const cdouble *d_in, unsigned batch_in, unsigned mf, unsigned nf, const double *d_filt, unsigned batch_filt, bool expand)
Double precision, complex input, real filter, two dimensional convolution.
afError af_conv2_DD(double *d_out, unsigned mi, unsigned ni, const double *d_in, unsigned batch_in, unsigned mf, unsigned nf, const double *d_filt, unsigned batch_filt, bool expand)
Double precision, real input, real filter, two dimensional convolution.
afError af_fft_C(dim3 dim_O, cfloat *d_O, dim3 dim_I, const cfloat *d_I, unsigned batch, int dim, int direction)
Complex, Single precision, One dimensional fft along dimension.
afError af_filter1D_D(double *d_out, unsigned len_in, const double *d_in, unsigned len_a, const double *h_a, unsigned len_b, const double *h_b, const double *d_init, double *d_final, unsigned Nin, unsigned Ninit)
Double-precision, Transposed direct form II filtering.
afError af_fft_clear(void)
Clear the fft plan cache.
array fft2(const array &, int nx=-1, int ny=-1)
Fast Fourier Transform in two dimensions.
afError af_fft3_S(dim3 dims_O, cfloat *d_O, dim3 dims_I, const float *d_I, unsigned batch, int direction)
Single precision, multi-dimensional fft.
afError
Definition: defines.h:10
afError af_convh_DD(double *d_out, unsigned ndimsi, unsigned *dimsi, const double *d_in, unsigned batchi, unsigned ndimsf, unsigned *dimsf, const double *h_filt, unsigned batchf, bool expand)
Double precision, real input, real filter, multi-dimensional convolution.
cuDoubleComplex cdouble
Definition: defines.h:109
afError af_convh_CS(cfloat *d_out, unsigned ndimsi, unsigned *dimsi, const cfloat *d_in, unsigned batchi, unsigned ndimsf, unsigned *dimsf, const float *h_filt, unsigned batchf, bool expand)
Single precision, complex input, real filter, multi-dimensional convolution.
afError af_conv_SS(float *d_out, unsigned ni, const float *d_in, unsigned batchi, unsigned nf, const float *d_filt, unsigned batchf, bool expand)
Single precision, real input, real filter, one dimensional convolution.
const double NaN
representation for not-a-number
afError af_scale2D_S(float *d_ZI, unsigned md, unsigned nd, const float *d_Z, int factor, char method)
Rescale a Matrix.
afError af_convn_CS(cfloat *d_out, unsigned ndimsi, unsigned *dimsi, const cfloat *d_in, unsigned batchi, unsigned ndimsf, unsigned *dimsf, const float *d_filt, unsigned batchf, bool expand)
Single precision, complex input, real filter, multi-dimensional convolution.
afError af_fft_Z(dim3 dim_O, cdouble *d_O, dim3 dim_I, const cdouble *d_I, unsigned batch, int dim, int direction)
Complex, Double precision, One dimensional fft along dimension.
afError af_conv2_CS(cfloat *d_out, unsigned mi, unsigned ni, const cfloat *d_in, unsigned batch_in, unsigned mf, unsigned nf, const float *d_filt, unsigned batch_filt, bool expand)
Single precision, complex input, real filter, two dimensional convolution.
afError af_fft2_Z(unsigned xo, unsigned yo, cdouble *d_O, unsigned xi, unsigned yi, const cdouble *d_I, unsigned batch, int direction)
Complex, Double precision, two dimensional fft.
afError af_conv_CS(cfloat *d_out, unsigned ni, const cfloat *d_in, unsigned batchi, unsigned nf, const float *d_filt, unsigned batchf, bool expand)
Single precision, complex input, real filter, one dimensional convolution.
afError af_filter1D_S(float *d_out, unsigned len_in, const float *d_in, unsigned len_a, const float *h_a, unsigned len_b, const float *h_b, const float *d_init, float *d_final, unsigned Nin, unsigned Ninit)
afError af_conv2_SS(float *d_out, unsigned mi, unsigned ni, const float *d_in, unsigned batch_in, unsigned mf, unsigned nf, const float *d_filt, unsigned batch_filt, bool expand)
array ifft3(const array &, const dim4 &dims=dim4(0))
Inverse Fast Fourier Transform in three dimensions.
afError af_convn_CC(cfloat *d_out, unsigned ndimsi, unsigned *dimsi, const cfloat *d_in, unsigned batchi, unsigned ndimsf, unsigned *dimsf, const cfloat *d_filt, unsigned batchf, bool expand)
Single precision, complex input, complex filter, multi-dimensional convolution.
afError af_convh_SS(float *d_out, unsigned ndimsi, unsigned *dimsi, const float *d_in, unsigned batchi, unsigned ndimsf, unsigned *dimsf, const float *h_filt, unsigned batchf, bool expand)
Single precision, real input, real filter, multi-dimensional convolution.
#define AFAPI
Definition: defines.h:45
array approx1(const array &Y, const array &Xi, char method='L', float offgrid=af::NaN)
Interpolation in one dimension (1D).
afError af_convn_DD(double *d_out, unsigned ndimsi, unsigned *dimsi, const double *d_in, unsigned batchi, unsigned ndimsf, unsigned *dimsf, const double *d_filt, unsigned batchf, bool expand)
Double precision, real input, real filter, multi-dimensional convolution.
array ifft2(const array &, int nx=-1, int ny=-1)
Inverse Fast Fourier Transform in two dimensions.
afError af_convn_SS(float *d_out, unsigned ndimsi, unsigned *dimsi, const float *d_in, unsigned batchi, unsigned ndimsf, unsigned *dimsf, const float *d_filt, unsigned batchf, bool expand)
Single precision, real input, real filter, multi-dimensional convolution.
void af_fft_info(void)
Print status of fft plan cache.
array fft(const array &, int pad=-1)
Fast Fourier Transform in one dimension.
afError af_fft2_C(unsigned xo, unsigned yo, cfloat *d_O, unsigned xi, unsigned yi, const cfloat *d_I, unsigned batch, int direction)
Complex, Single precision, two dimensional fft.
afError af_filter1D_C(cfloat *d_out, unsigned len_in, const cfloat *d_in, unsigned len_a, const float *h_a, unsigned len_b, const float *h_b, const cfloat *d_init, cfloat *d_final, unsigned Nin, unsigned Ninit)
Complex, single-precision, Transposed direct form II filtering.
afError af_conv_DD(double *d_out, unsigned ni, const double *d_in, unsigned batchi, unsigned nf, const double *d_filt, unsigned batchf, bool expand)
Single precision, real input, real filter, one dimensional convolution.
afError af_fft3_Z(dim3 dims_O, cdouble *d_O, dim3 dims_I, const cdouble *d_I, unsigned batch, int direction)
Complex, Double precision, multi-dimensional fft.
afError af_convn_ZZ(cdouble *d_out, unsigned ndimsi, unsigned *dimsi, const cdouble *d_in, unsigned batchi, unsigned ndimsf, unsigned *dimsf, const cdouble *d_filt, unsigned batchf, bool expand)
Double precision, complex input, complex filter, multi-dimensional convolution.
array approx2(const array &Z, const array &Xi, const array &Yi, char method='L', float offgrid=af::NaN)
Interpolation in two dimensions (2D): z=f(x,y)
afError af_conv_ZD(cdouble *d_out, unsigned ni, const cdouble *d_in, unsigned batchi, unsigned nf, const double *d_filt, unsigned batchf, bool expand)
Double precision, complex input, real filter, one dimensional convolution.
array filter(const array &image, const array &kernel)
Image Filtering.
afError af_filter1D_Z(cdouble *d_out, unsigned len_in, const cdouble *d_in, unsigned len_a, const double *h_a, unsigned len_b, const double *h_b, const cdouble *d_init, cdouble *d_final, unsigned Nin, unsigned Ninit)
Complex, single-precision, Transposed direct form II filtering.
afError af_conv_ZZ(cdouble *d_out, unsigned ni, const cdouble *d_in, unsigned batchi, unsigned nf, const cdouble *d_filt, unsigned batchf, bool expand)
Double precision, complex input, complex filter, one dimensional convolution.
array convolve(const array &f1, const array &f2, const array &signal, bool expand=false)
Separable convolution (2D) with device arrays.
cuFloatComplex cfloat
Definition: defines.h:108
afError af_conv2_CC(cfloat *d_out, unsigned mi, unsigned ni, const cfloat *d_in, unsigned batch_in, unsigned mf, unsigned nf, const cfloat *d_filt, unsigned batch_filt, bool expand)
Single precision, complex input, complex filter, two dimensional convolution.
afError af_fft_D(dim3 dim_O, cdouble *d_O, dim3 dim_I, const double *d_I, unsigned batch, int dim, int direction)
Double precision, One dimensional fft along dimension.
afError af_fft3_C(dim3 dims_O, cfloat *d_O, dim3 dims_I, const cfloat *d_I, unsigned batch, int direction)
Complex, Single precision, multi-dimensional fft.
afError af_fft2_D(unsigned xo, unsigned yo, cdouble *d_O, unsigned xi, unsigned yi, const double *d_I, unsigned batch, int direction)
Double precision, two dimensional fft.
afError af_scale2D_D(double *d_ZI, unsigned md, unsigned nd, const double *d_Z, int factor, char method)
afError af_fft_setplans(int max_plans)
Set the cache size for CUfft plans.
afError af_convh_ZD(cdouble *d_out, unsigned ndimsi, unsigned *dimsi, const cdouble *d_in, unsigned batchi, unsigned ndimsf, unsigned *dimsf, const double *h_filt, unsigned batchf, bool expand)
Double precision, complex input, real filter, multi-dimensional convolution.
afError af_scale2D_c(char *d_ZI, unsigned md, unsigned nd, const char *d_Z, int factor, char method)
Character (8-bit) rescale.
array fft3(const array &, const dim4 &dims=dim4(0))
Fast Fourier Transform in three dimensions.
afError af_fft3_D(dim3 dims_O, cdouble *d_O, dim3 dims_I, const double *d_I, unsigned batch, int direction)
Double precision, multi-dimensional fft.
array ifft(const array &, int pad=-1)
Inverse Fast Fourier Transform in one dimension.