diff options
author | simon | 2008-08-19 17:15:04 +0000 |
---|---|---|
committer | simon | 2008-08-19 17:15:04 +0000 |
commit | 31e881dc749d8fc99028db3a09b565f392b382de (patch) | |
tree | 5016ca94f8b7971dd8ac498784f65ef4d6bbb872 /src/matrixOperations | |
parent | b074501da9007198d67b37dd3527eeef2bb51dc8 (diff) | |
download | scilab2c-31e881dc749d8fc99028db3a09b565f392b382de.tar.gz scilab2c-31e881dc749d8fc99028db3a09b565f392b382de.tar.bz2 scilab2c-31e881dc749d8fc99028db3a09b565f392b382de.zip |
added the test , and modify the way the matrix eyes is set up
Diffstat (limited to 'src/matrixOperations')
-rw-r--r-- | src/matrixOperations/eyes/Makefile.am | 16 | ||||
-rw-r--r-- | src/matrixOperations/eyes/Makefile.in | 16 | ||||
-rw-r--r-- | src/matrixOperations/eyes/ceyesa.c | 7 | ||||
-rw-r--r-- | src/matrixOperations/eyes/deyesa.c | 7 | ||||
-rw-r--r-- | src/matrixOperations/eyes/seyesa.c | 7 | ||||
-rw-r--r-- | src/matrixOperations/eyes/testMatrixEyes.c | 169 | ||||
-rw-r--r-- | src/matrixOperations/eyes/zeyesa.c | 7 |
7 files changed, 213 insertions, 16 deletions
diff --git a/src/matrixOperations/eyes/Makefile.am b/src/matrixOperations/eyes/Makefile.am index 1248f722..cfa4df13 100644 --- a/src/matrixOperations/eyes/Makefile.am +++ b/src/matrixOperations/eyes/Makefile.am @@ -33,6 +33,22 @@ check_PROGRAMS = testMatrixEyes check_LDADD = $(top_builddir)/type/libDoubleComplex.la \ $(top_builddir)/type/libFloatComplex.la \ + $(top_builddir)/auxiliaryFunctions/abs/libAbs.la \ + $(top_builddir)/auxiliaryFunctions/sign/libSign.la \ + $(top_builddir)/auxiliaryFunctions/pythag/libPythag.la \ + $(top_builddir)/auxiliaryFunctions/frexp/libFrexp.la \ + $(top_builddir)/elementaryFunctions/sqrt/libSqrt.la \ + $(top_builddir)/elementaryFunctions/exp/libExp.la \ + $(top_builddir)/elementaryFunctions/cos/libCos.la \ + $(top_builddir)/elementaryFunctions/pow/libPow.la \ + $(top_builddir)/elementaryFunctions/log/libLog.la \ + $(top_builddir)/elementaryFunctions/log1p/libLog1p.la \ + $(top_builddir)/elementaryFunctions/lnp1m1/libLnp1m1.la\ + $(top_builddir)/elementaryFunctions/cosh/libCosh.la \ + $(top_builddir)/elementaryFunctions/sin/libSin.la \ + $(top_builddir)/elementaryFunctions/sinh/libSinh.la \ + $(top_builddir)/lib/lapack/libscilapack.la \ + $(top_builddir)/lib/blas/libsciblas.la \ libMatrixEyes.la check_INCLUDES = -I $(top_builddir)/type \ diff --git a/src/matrixOperations/eyes/Makefile.in b/src/matrixOperations/eyes/Makefile.in index 59d897a6..6db166fc 100644 --- a/src/matrixOperations/eyes/Makefile.in +++ b/src/matrixOperations/eyes/Makefile.in @@ -211,6 +211,22 @@ libMatrixEyes_la_SOURCES = $(HEAD) \ check_LDADD = $(top_builddir)/type/libDoubleComplex.la \ $(top_builddir)/type/libFloatComplex.la \ + $(top_builddir)/auxiliaryFunctions/abs/libAbs.la \ + $(top_builddir)/auxiliaryFunctions/sign/libSign.la \ + $(top_builddir)/auxiliaryFunctions/pythag/libPythag.la \ + $(top_builddir)/auxiliaryFunctions/frexp/libFrexp.la \ + $(top_builddir)/elementaryFunctions/sqrt/libSqrt.la \ + $(top_builddir)/elementaryFunctions/exp/libExp.la \ + $(top_builddir)/elementaryFunctions/cos/libCos.la \ + $(top_builddir)/elementaryFunctions/pow/libPow.la \ + $(top_builddir)/elementaryFunctions/log/libLog.la \ + $(top_builddir)/elementaryFunctions/log1p/libLog1p.la \ + $(top_builddir)/elementaryFunctions/lnp1m1/libLnp1m1.la\ + $(top_builddir)/elementaryFunctions/cosh/libCosh.la \ + $(top_builddir)/elementaryFunctions/sin/libSin.la \ + $(top_builddir)/elementaryFunctions/sinh/libSinh.la \ + $(top_builddir)/lib/lapack/libscilapack.la \ + $(top_builddir)/lib/blas/libsciblas.la \ libMatrixEyes.la check_INCLUDES = -I $(top_builddir)/type \ diff --git a/src/matrixOperations/eyes/ceyesa.c b/src/matrixOperations/eyes/ceyesa.c index 4e396f29..7bac26ce 100644 --- a/src/matrixOperations/eyes/ceyesa.c +++ b/src/matrixOperations/eyes/ceyesa.c @@ -14,11 +14,10 @@ void ceyesa(floatComplex *in, int _iRows, int _iCols) { - int i , j ; + int i ; - for ( i = 0 ; i < _iRows ; i++ ) - for ( j = 0 ; j <_iCols ; j++ ) - in[i + j * _iRows] = FloatComplex ( (i==j)?1.0f:0.0f , 0) ; + for ( i = 0 ; i < _iRows*_iCols ; i++ ) + in[i] = FloatComplex ( (i%(_iCols+1) == 0)?1.0f:0.0f , 0) ; } diff --git a/src/matrixOperations/eyes/deyesa.c b/src/matrixOperations/eyes/deyesa.c index 8f45038f..3b794254 100644 --- a/src/matrixOperations/eyes/deyesa.c +++ b/src/matrixOperations/eyes/deyesa.c @@ -14,10 +14,9 @@ void deyesa(double *in, int _iRows, int _iCols) { - int i , j ; + int i ; - for ( i = 0 ; i < _iRows ; i++ ) - for ( j = 0 ; j <_iCols ; j++ ) - in[i + j * _iRows] = (i==j)?1:0 ; + for ( i = 0 ; i < _iRows*_iCols ; i++ ) + in[i] = (i%(_iCols+1) == 0)?1:0 ; } diff --git a/src/matrixOperations/eyes/seyesa.c b/src/matrixOperations/eyes/seyesa.c index 40be50b9..8ed9de64 100644 --- a/src/matrixOperations/eyes/seyesa.c +++ b/src/matrixOperations/eyes/seyesa.c @@ -14,10 +14,9 @@ void seyesa(float* in, int _iRows, int _iCols) { - int i , j ; + int i ; - for ( i = 0 ; i < _iRows ; i++ ) - for ( j = 0 ; j <_iCols ; j++ ) - in[i + j * _iRows] = (i==j)?1.0f:0 ; + for ( i = 0 ; i < _iRows*_iCols ; i++ ) + in[i] = (i%(_iCols+1) == 0)?1.0f:0.0f ; } diff --git a/src/matrixOperations/eyes/testMatrixEyes.c b/src/matrixOperations/eyes/testMatrixEyes.c new file mode 100644 index 00000000..a4e5711b --- /dev/null +++ b/src/matrixOperations/eyes/testMatrixEyes.c @@ -0,0 +1,169 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Allan SIMON + * + * 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 <assert.h> +#include <stdio.h> +#include "matrixEyes.h" +#include <math.h> + +#define LEADDIM 10 + +static void deyesaTest ( void ) +{ + int i = 0 ; + + double result = 0 ; + + double in [LEADDIM*LEADDIM] ; + + deyesa ( in , LEADDIM , LEADDIM ) ; + + for ( i = 0 ; i < LEADDIM*LEADDIM ; i++ ) + { + if ( i%(LEADDIM+1) == 0 ) + result = 1 ; + else + result = 0 ; + + printf ( "\t\t %d in : %e\tresult : %e\tassert : %e \n" , i, in[i] , result , fabs( in[i] - result) / fabs( in[i]) ) ; + + if ( in[i] < 1e-14 && result < 1e-14 ) + assert(1); + else + assert ( fabs ( in[i] - result) / fabs( in[i]) < 1e-14 ) ; + } +} + + +static void seyesaTest ( void ) +{ + int i = 0 ; + + float result = 0 ; + + float in[LEADDIM*LEADDIM] ; + + seyesa ( in , LEADDIM , LEADDIM ) ; + + for ( i = 0 ; i < LEADDIM*LEADDIM ; i++) + { + if ( i%(LEADDIM+1) == 0 ) + result = 1.0f ; + else + result = 0 ; + + printf ( "\t\t %d in : %e\tresult : %e\tassert : %e \n" , i, in[i] , result , fabs( in[i] - result) / fabs( in[i]) ) ; + if ( in[i] < 1e-6 && result < 1e-6 ) + assert(1); + else + assert ( fabs ( in[i] - result) / fabs( in[i]) < 1e-6 ) ; + } +} + + +static void zeyesaTest ( void ) +{ + int i = 0 ; + + doubleComplex result = DoubleComplex ( 0 , 0) ; + + doubleComplex in[LEADDIM*LEADDIM] ; + + zeyesa ( in , LEADDIM , LEADDIM ) ; + + for ( i = 0 ; i < LEADDIM*LEADDIM ; i++ ) + { + if ( i%(LEADDIM+1) == 0 ) + result = DoubleComplex ( 1 , 0 ) ; + else + result = DoubleComplex ( 0 , 0 ) ; + + printf ( "\t\t %d in : %e\tresult : %e \n" , i, zreals( in[i]) , zreals ( result ) ) ; + + if ( zreals( in[i]) < 1e-14 && zreals( result) < 1e-14 ) + assert(1); + else + assert ( fabs ( zreals(in[i]) - zreals(result)) / fabs( zreals(in[i])) < 1e-14 ) ; + + if ( zimags ( in[i]) < 1e-14 ) + assert (1); + else + assert (0); + + } +} + + + + + +static void ceyesaTest ( void ) +{ + int i = 0 ; + + floatComplex result = FloatComplex ( 0 , 0 ) ; + + floatComplex in[LEADDIM*LEADDIM] ; + + ceyesa ( in , LEADDIM , LEADDIM ) ; + + for ( i = 0 ; i < LEADDIM*LEADDIM ; i++) + { + if ( i%(LEADDIM+1) == 0 ) + result = FloatComplex ( 1.0f , 0 ) ; + else + result = FloatComplex ( 0 , 0 ) ; + + printf ( "\t\t %d in : %e\tresult : %e \n" , i, creals( in[i]) , creals ( result ) ) ; + if ( creals( in[i]) < 1e-6 && creals( result) < 1e-6 ) + assert(1); + else + assert ( fabs ( creals(in[i]) - creals(result)) / fabs( creals(in[i])) < 1e-6 ) ; + + if ( cimags ( in[i]) < 1e-6 ) + assert (1); + else + assert (0); + + } +} + + + +static int testExponential(void) { + + printf("\n>>>> Matrix Exponential Tests\n"); + printf("\t>>>> Matrix Double Realt Tests\n"); + deyesaTest(); + + printf("\n\n\t>>>> Matrix Float Realt Tests\n"); + seyesaTest(); + + printf("\n\n\n"); + printf("\t>>>> Matrix Float Complex Tests\n"); + ceyesaTest(); + + printf("\n\n\n"); + printf("\t>>>> Matrix Double Complex Tests\n"); + zeyesaTest(); + + return 0; +} + + + +int main(void) { + assert(testExponential() == 0); + return 0; +} + + diff --git a/src/matrixOperations/eyes/zeyesa.c b/src/matrixOperations/eyes/zeyesa.c index c0f43a23..fcb181ec 100644 --- a/src/matrixOperations/eyes/zeyesa.c +++ b/src/matrixOperations/eyes/zeyesa.c @@ -16,11 +16,10 @@ void zeyesa(doubleComplex *in, int _iRows, int _iCols) { - int i , j ; + int i ; - for ( i = 0 ; i < _iRows ; i++ ) - for ( j = 0 ; j <_iCols ; j++ ) - in[i + j * _iRows] = DoubleComplex ( (i==j)?1:0 , 0) ; + for ( i = 0 ; i < _iRows*_iCols ; i++ ) + in[i] = DoubleComplex ( (i%(_iCols+1) == 0)?1:0 , 0) ; } |