summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimon2009-08-24 10:07:20 +0000
committersimon2009-08-24 10:07:20 +0000
commit1480d3bdd424ea9f3af3702573fd5d6d60f0bb16 (patch)
treedfdb6c165aa0f4d1363f03aa7f668c3ef247ae0d
parent52563febd5b3700de00369d85cb32a031bdc1617 (diff)
downloadscilab2c-1480d3bdd424ea9f3af3702573fd5d6d60f0bb16.tar.gz
scilab2c-1480d3bdd424ea9f3af3702573fd5d6d60f0bb16.tar.bz2
scilab2c-1480d3bdd424ea9f3af3702573fd5d6d60f0bb16.zip
Added mixed type functions for right division , they are only convenient functions
-rw-r--r--src/c/matrixOperations/division/crdivcsv.c25
-rw-r--r--src/c/matrixOperations/division/crdivscv.c25
-rw-r--r--src/c/matrixOperations/division/crdivv.c24
-rw-r--r--src/c/matrixOperations/division/dldivma.c12
-rw-r--r--src/c/matrixOperations/division/drdivv.c24
-rw-r--r--src/c/matrixOperations/division/sldivma.c4
-rw-r--r--src/c/matrixOperations/division/srdivma.c2
-rw-r--r--src/c/matrixOperations/division/srdivv.c24
-rw-r--r--src/c/matrixOperations/division/testMatrixLDivision.c31
-rw-r--r--src/c/matrixOperations/division/testMatrixRDivision.c23
-rw-r--r--src/c/matrixOperations/division/zrdivdzv.c25
-rw-r--r--src/c/matrixOperations/division/zrdivv.c23
-rw-r--r--src/c/matrixOperations/division/zrdivzdv.c25
13 files changed, 250 insertions, 17 deletions
diff --git a/src/c/matrixOperations/division/crdivcsv.c b/src/c/matrixOperations/division/crdivcsv.c
new file mode 100644
index 00000000..2b98ee1c
--- /dev/null
+++ b/src/c/matrixOperations/division/crdivcsv.c
@@ -0,0 +1,25 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - 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 <malloc.h>
+#include "zeros.h"
+#include "matrixDivision.h"
+
+floatComplex crdivcsv (floatComplex* in1,float* in2, int size)
+ {
+ float* ZEROS;
+ ZEROS=malloc((unsigned int)(size*sizeof(float)));
+ szerosa(ZEROS,size , 1);
+
+ return crdivv(in1 , FloatComplexMatrix(in2,ZEROS,size),size );
+ }
diff --git a/src/c/matrixOperations/division/crdivscv.c b/src/c/matrixOperations/division/crdivscv.c
new file mode 100644
index 00000000..2e059b80
--- /dev/null
+++ b/src/c/matrixOperations/division/crdivscv.c
@@ -0,0 +1,25 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - 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 <malloc.h>
+#include "zeros.h"
+#include "matrixDivision.h"
+
+floatComplex crdivscv (float* in1, floatComplex* in2, int size)
+ {
+ float* ZEROS;
+ ZEROS=malloc((unsigned int)(size*sizeof(float)));
+ szerosa(ZEROS,size , 1);
+
+ return crdivv(FloatComplexMatrix(in1,ZEROS,size), in2 , size );
+ }
diff --git a/src/c/matrixOperations/division/crdivv.c b/src/c/matrixOperations/division/crdivv.c
new file mode 100644
index 00000000..db7a81cb
--- /dev/null
+++ b/src/c/matrixOperations/division/crdivv.c
@@ -0,0 +1,24 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - 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 "matrixDivision.h"
+
+floatComplex crdivv(floatComplex *in1, floatComplex *in2, int size){
+
+ floatComplex out[1] ={ FloatComplex (0.0f , 0.0f)};
+ crdivma ( in1,1 ,size ,in2 , 1 , size , out );
+
+ return out[0] ;
+}
+
+
diff --git a/src/c/matrixOperations/division/dldivma.c b/src/c/matrixOperations/division/dldivma.c
index e69b86ef..aaeb5758 100644
--- a/src/c/matrixOperations/division/dldivma.c
+++ b/src/c/matrixOperations/division/dldivma.c
@@ -47,11 +47,11 @@ void dldivma (double* in1, int lines1, int columns1 ,
iWork = max(4 * columns1, max(min(lines1, columns1) + 3 * lines1 + 1, 2 * min(lines1, columns1) + columns2));
-
+ lines2 = 0 ;
/* Array allocations*/
pAf = (double*)malloc(sizeof(double) * (unsigned int) lines1 * (unsigned int) columns1);
- pXb = (double*)malloc(sizeof(double) * (unsigned int) max(lines1,columns1) * (unsigned int) columns1);
+ pXb = (double*)malloc(sizeof(double) * (unsigned int) max(lines1,columns1) * (unsigned int) columns2);
pRank = (int*)malloc(sizeof(int));
pIpiv = (int*)malloc(sizeof(int) *(unsigned int) columns1);
@@ -65,7 +65,8 @@ void dldivma (double* in1, int lines1, int columns1 ,
dblEps = getRelativeMachinePrecision() ;
dblAnorm = dlange_(&cNorm, &lines1, &columns1, in1, &lines1, pDwork);
-
+ printf ("initial variable \n");
+ printf ("dblAnorm : %e\n" ,dblAnorm );
if(lines1 == columns1)
{
cNorm = 'F';
@@ -90,12 +91,13 @@ void dldivma (double* in1, int lines1, int columns1 ,
if(iExit == 0)
{
dblRcond = sqrt(dblEps);
+printf ("dblRcond : %e\n" ,dblRcond );
cNorm = 'F';
iMax = max(lines1, columns1);
- C2F(dlacpy)(&cNorm, &lines1, &columns2, in2, &lines2, pXb, &iMax);
+ C2F(dlacpy)(&cNorm, &lines1, &columns2, in2, &lines1, pXb, &iMax);
memset(pJpvt, 0x00,(unsigned int) sizeof(int) * (unsigned int) columns1);
C2F(dgelsy)( &lines1, &columns1, &columns2, in1, &lines1, pXb, &iMax,
- pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo);
+ pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo);
if(iInfo == 0)
{
diff --git a/src/c/matrixOperations/division/drdivv.c b/src/c/matrixOperations/division/drdivv.c
new file mode 100644
index 00000000..c6c2bf60
--- /dev/null
+++ b/src/c/matrixOperations/division/drdivv.c
@@ -0,0 +1,24 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - 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 "matrixDivision.h"
+
+double drdivv(double *in1, double *in2, int size){
+
+ double out[1] = { 0.0} ;
+ drdivma ( in1,1 ,size ,in2 , 1 , size , out );
+
+ return out[0] ;
+}
+
+
diff --git a/src/c/matrixOperations/division/sldivma.c b/src/c/matrixOperations/division/sldivma.c
index 86312823..0629bd07 100644
--- a/src/c/matrixOperations/division/sldivma.c
+++ b/src/c/matrixOperations/division/sldivma.c
@@ -16,7 +16,7 @@
#include <string.h>
#include <stdio.h>
void sldivma ( float* in1, int lines1, int columns1 ,
- float* in2, int lines2, int columns2 ,
+ float* in2, int lines2, int columns2 ,
float* out ){
int i = 0 ;
@@ -45,7 +45,7 @@ void sldivma ( float* in1, int lines1, int columns1 ,
for ( i = 0 ; i < lines2 * columns2 ; i ++ )
{
dblin2[i] = (double) in2[i] ;
- }
+ }
dldivma( dblin1 , lines1 , columns1 , dblin2 , lines2 , columns2 , dblout );
diff --git a/src/c/matrixOperations/division/srdivma.c b/src/c/matrixOperations/division/srdivma.c
index b5773870..b1c8f31f 100644
--- a/src/c/matrixOperations/division/srdivma.c
+++ b/src/c/matrixOperations/division/srdivma.c
@@ -49,7 +49,7 @@ void srdivma ( float* in1, int lines1, int columns1 ,
dblin2[i] = (double) in2[i] ;
}
- drdivma( dblin1 , lines1 , columns1 , dblin2 , lines2 , columns2 , dblout );
+ drdivma( dblin1 , lines1 , columns1 , dblin2 , lines2 , columns2 , dblout );
for ( i = 0 ; i < min(lines2,columns2) * lines1 ; i++ )
diff --git a/src/c/matrixOperations/division/srdivv.c b/src/c/matrixOperations/division/srdivv.c
new file mode 100644
index 00000000..023e06fa
--- /dev/null
+++ b/src/c/matrixOperations/division/srdivv.c
@@ -0,0 +1,24 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - 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 "matrixDivision.h"
+
+float srdivv(float *in1, float *in2, int size){
+
+ float out[1] = {0.0f} ;
+ srdivma ( in1,1 ,size ,in2 , 1 , size , out );
+
+ return out[0] ;
+}
+
+
diff --git a/src/c/matrixOperations/division/testMatrixLDivision.c b/src/c/matrixOperations/division/testMatrixLDivision.c
index feae48c3..7254cf46 100644
--- a/src/c/matrixOperations/division/testMatrixLDivision.c
+++ b/src/c/matrixOperations/division/testMatrixLDivision.c
@@ -302,9 +302,7 @@ static void cldivmaTest (void )
float tin2[] = { 1.0f , 2.0f};
- /* float tin1[] = { 4.0f , 3.0f , 8.0f , 9.0f } ;
- float tin2[] = { 1.0f , 3.0f , 2.0f , 4.0f } ;
- */
+
floatComplex* in1 ;
floatComplex* in2 ;
floatComplex* out ;
@@ -317,11 +315,6 @@ static void cldivmaTest (void )
Result[0] = FloatComplex ( 0 , 0 );
Result[1] = FloatComplex ( 0.5f , 0 );
- /*
- Result[0] = FloatComplex ( -1.25f , 0 );
- Result[1] = FloatComplex ( 0.75f , 0 );
- Result[2] = FloatComplex ( -1.16666666f , 0 );
- Result[3] = FloatComplex ( 0.833333333333f , 0 );*/
cldivma ( in1 , ZLINES , ZCOLUMNS1 , in2 ,ZLINES , ZCOLUMNS2 , out) ;
@@ -411,6 +404,23 @@ static void zldivmaTest (void )
+static void mytest (void ){
+ double in1[2] = { 1 , 4 } ;
+ double in2[3] = { 1 , 2 , 3 };
+ double out[6] = { 0 , 0 , 0 , 0 ,0 , 0 } ;
+
+ int i = 0 ;
+
+ dldivma ( in1 , 1, 2, in2 , 1, 3 , out );
+
+ for ( i = 0 ; i <6; i++)
+ {
+printf ( "\t\t %d out : %20.15e\t\n" , i , out[i] ) ;
+
+ }
+
+}
+
static int testLDivma (void) {
printf ("&&&& WARNING , TESTS FOR COMPLEX ARE STILL WRONG &&&&&&\n\n" ) ;
@@ -418,6 +428,11 @@ static int testLDivma (void) {
printf("***** Left Tests ****\n");
printf("*********************\n");
+
+
+ printf("\n\n\n\t>>> MY TEST Tests\n");
+ mytest () ;
+
printf("\n\t>>>>Float real Tests\n");
sldivmaTest();
diff --git a/src/c/matrixOperations/division/testMatrixRDivision.c b/src/c/matrixOperations/division/testMatrixRDivision.c
index 5e724a01..242d5189 100644
--- a/src/c/matrixOperations/division/testMatrixRDivision.c
+++ b/src/c/matrixOperations/division/testMatrixRDivision.c
@@ -456,12 +456,33 @@ static void zrdivmaTest ( void ){
free(out);
}
+
+
+static void mytest (void ){
+ double in1[16] = { 1 , 5 , 9 , 13 } ;
+ double in2[16] = { 2 , 6 , 10 } ;
+
+ double out[16] = { 0 } ;
+
+ int i = 0 ;
+
+ drdivma ( in1 , 1 , 4 , in2 ,1, 3 , out );
+
+ for ( i = 0 ; i <1; i++)
+ {
+printf ( "\t\t %d out : %20.15e\t\n" , i , out[i] ) ;
+
+ }
+
+}
+
+
static int testRDivma (void) {
printf("\n\n\n\n**********************\n");
printf("***** Right Tests ****\n");
printf("**********************\n");
-
+ mytest ( );
printf("\n\t>>>> Float real Tests\n");
sdivmaTest();
diff --git a/src/c/matrixOperations/division/zrdivdzv.c b/src/c/matrixOperations/division/zrdivdzv.c
new file mode 100644
index 00000000..0bb44dd7
--- /dev/null
+++ b/src/c/matrixOperations/division/zrdivdzv.c
@@ -0,0 +1,25 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - 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 <malloc.h>
+#include "zeros.h"
+#include "matrixDivision.h"
+
+doubleComplex zrdivdzv (double* in1, doubleComplex* in2, int size)
+ {
+ double* ZEROS;
+ ZEROS=malloc((unsigned int)(size*sizeof(double)));
+ dzerosa(ZEROS,size , 1);
+
+ return zrdivv(DoubleComplexMatrix(in1,ZEROS,size), in2 , size );
+ }
diff --git a/src/c/matrixOperations/division/zrdivv.c b/src/c/matrixOperations/division/zrdivv.c
new file mode 100644
index 00000000..406b7a2b
--- /dev/null
+++ b/src/c/matrixOperations/division/zrdivv.c
@@ -0,0 +1,23 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - 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 "division.h"
+
+doubleComplex zrdivv(doubleComplex *in1, doubleComplex *in2, int size){
+
+ doubleComplex out[1] ={ DoubleComplex (0.0 , 0.0) };
+ zrdivma ( in1,1 ,size ,in2 , 1 , size , out );
+
+ return out[0] ;
+}
+
diff --git a/src/c/matrixOperations/division/zrdivzdv.c b/src/c/matrixOperations/division/zrdivzdv.c
new file mode 100644
index 00000000..028702a4
--- /dev/null
+++ b/src/c/matrixOperations/division/zrdivzdv.c
@@ -0,0 +1,25 @@
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008-2009 - 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 <malloc.h>
+#include "zeros.h"
+#include "matrixDivision.h"
+
+doubleComplex zrdivzdv (doubleComplex* in1,double* in2, int size)
+ {
+ double* ZEROS;
+ ZEROS=malloc((unsigned int)(size*sizeof(double)));
+ dzerosa(ZEROS,size , 1);
+
+ return zrdivv(in1 , DoubleComplexMatrix(in2,ZEROS,size),size );
+ }