diff options
author | torset | 2008-12-22 09:01:17 +0000 |
---|---|---|
committer | torset | 2008-12-22 09:01:17 +0000 |
commit | f078539597de7a54d982984635ee6cdbe36fe138 (patch) | |
tree | 80c7026547a535b96b04c1e8847e1d73fcac864a /src/signalProcessing/hilbert/testHilbert.c | |
parent | 92a94f77a9d6a31d2423e85f74547eca45d89425 (diff) | |
download | scilab2c-f078539597de7a54d982984635ee6cdbe36fe138.tar.gz scilab2c-f078539597de7a54d982984635ee6cdbe36fe138.tar.bz2 scilab2c-f078539597de7a54d982984635ee6cdbe36fe138.zip |
Add hilbert (failed but I don't know why)
Diffstat (limited to 'src/signalProcessing/hilbert/testHilbert.c')
-rw-r--r-- | src/signalProcessing/hilbert/testHilbert.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/signalProcessing/hilbert/testHilbert.c b/src/signalProcessing/hilbert/testHilbert.c new file mode 100644 index 00000000..98c4f803 --- /dev/null +++ b/src/signalProcessing/hilbert/testHilbert.c @@ -0,0 +1,70 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008 - INRIA - Arnaud TORSET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + + + +#include <stdio.h> +#include <assert.h> +#include <math.h> +#include "hilbert.h" + + +static void dhilbertaTest(void){ + int i; + double in[16]={1, 2, 3, 4, 5,6,7,8,9, 10,11,12,13,14,15,16}; + /*double resR[4]={1,2,3,4}; + double resI[4]={1,-1,-1,1};*/ + doubleComplex *out; + + out = malloc((uint)9*sizeof(doubleComplex)); + dhilberta(in, 1, 9, out); + + for (i=0;i<9;i++){ + printf("%f+%f *i\n",zreals (out[i]),zimags(out[i])); + /*assert( (fabs(zreals(out[i])-resR[i]) / fabs(zreals(out[i])) )<1e-16); + assert( (fabs(zimags(out[i])-resI[i]) / fabs(zimags(out[i])) )<1e-16);*/ + } + +} + +static void shilbertaTest(void){ + int i; + float in[4]={1.0f, 2.0f, 3.0f, 4.0f}; + /*float resR[4]={1.0f,2.0f,3.0f,4.0f}; + float resI[4]={1.0f,-1.0f,-1.0f,1.0f}; */ + floatComplex out[4]; + + + shilberta(in, 1, 4, out); + + for (i=0;i<4;i++){ + printf("%f+%f *i\n",creals (out[i]),cimags(out[i])); + /*assert( (fabs(creals(out[i])-resR[i]) / fabs(creals(out[i])) )<1e-6); + assert( (fabs(cimags(out[i])-resI[i]) / fabs(cimags(out[i])) )<1e-6);*/ + } +} + +static int hilbertTest(void){ + dhilbertaTest(); + shilbertaTest(); + return 0; +} + + +int main (void){ + assert(hilbertTest()==0); + return 0; +} + + + + |