diff options
author | siddhu8990 | 2016-03-02 14:32:06 +0530 |
---|---|---|
committer | siddhu8990 | 2016-03-02 14:32:06 +0530 |
commit | 070c6a83075034f4322faf84b1c4623da314a2e9 (patch) | |
tree | 4d1b2aa9ef7847620bd0e34a01957e9a05499923 /2.3-1/src | |
parent | b31a4a5f8a03f516d6ec21efb31f9892cb46f9f3 (diff) | |
parent | ec6d011ec9b0e656f3c0d122fcba0c1d01e8cb32 (diff) | |
download | Scilab2C-070c6a83075034f4322faf84b1c4623da314a2e9.tar.gz Scilab2C-070c6a83075034f4322faf84b1c4623da314a2e9.tar.bz2 Scilab2C-070c6a83075034f4322faf84b1c4623da314a2e9.zip |
Merged with linspace and logspace
Diffstat (limited to '2.3-1/src')
84 files changed, 3886 insertions, 53 deletions
diff --git a/2.3-1/src/c/auxiliaryFunctions/rand/dranda.c b/2.3-1/src/c/auxiliaryFunctions/rand/dranda.c index f4678279..3defc264 100644 --- a/2.3-1/src/c/auxiliaryFunctions/rand/dranda.c +++ b/2.3-1/src/c/auxiliaryFunctions/rand/dranda.c @@ -16,5 +16,5 @@ void dranda(double *out, int size) { int i = 0; for (i = 0 ; i < size ; ++i) { out[i] = drands(); - } + } } diff --git a/2.3-1/src/c/auxiliaryFunctions/rand/drands.c b/2.3-1/src/c/auxiliaryFunctions/rand/drands.c index 9b7c4cf4..658cd0b0 100644 --- a/2.3-1/src/c/auxiliaryFunctions/rand/drands.c +++ b/2.3-1/src/c/auxiliaryFunctions/rand/drands.c @@ -34,37 +34,60 @@ double drands(void) { if (m2==0){ /* if first entry, compute machine integer word length */ - while (m>m2){ + while (m>m2){ m2=m; m=itwo*m2; + } + halfm = m2; - - /* compute multiplier and increment for linear congruential method */ + + /* compute multiplier and increment for linear congruential method */ ia = 8*(int)(halfm*atan(1.0)/8.0) + 5; - ic = 2*(int)(halfm*(0.5-sqrt(3.0)/6.0)) + 1; - mic = (m2 - ic) + m2; - - /* s is the scale factor for converting to floating point */ + + ic = 2*(int)(halfm*(0.5-sqrt(3.0)/6.0)) + 1; + + mic = (m2 - ic) + m2; + + /* s is the scale factor for converting to floating point */ s = 0.5/halfm; + + } /* compute next random number */ iy = iy*ia; + + /* the following statement is for computers which do not allow integer overflow on addition */ - if (iy > mic) iy = (iy - m2) - m2; + if (iy > mic) + { + iy = (iy - m2) - m2; + + } iy = iy + ic; /* the following statement is for computers where the word length for addition is greater than for multiplication */ - if (iy/2 > m2) iy = (iy - m2) - m2; + if (iy/2 > m2) + { + iy = (iy - m2) - m2; + + } /* the following statement is for computers where integer overflow affects the sign bit */ - if (iy < 0) iy = (iy + m2) + m2; + if (iy < 0) + { + iy = (iy + m2) + m2; + + + } + + return (double)iy*s; } diff --git a/2.3-1/src/c/elementaryFunctions/includes/linspace.h b/2.3-1/src/c/elementaryFunctions/includes/linspace.h new file mode 100644 index 00000000..837d839d --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/includes/linspace.h @@ -0,0 +1,36 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * + * 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 + * + */ + +#ifndef __LINSPACE_H__ +#define __LINSPACE_H__ + +#include "dynlib_elementaryfunctions.h" +#ifdef __cplusplus +extern "C" { +#endif + + +EXTERN_ELEMFUNCT void dlinspaces(double low_limit,double up_limit,double range_num, double* out); + +EXTERN_ELEMFUNCT void dlinspacea(double *low_limit,int row,double *up_limit,double range_num, double* out); + + + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* !__LINSPACE_H__ */ + diff --git a/2.3-1/src/c/elementaryFunctions/includes/logspace.h b/2.3-1/src/c/elementaryFunctions/includes/logspace.h new file mode 100644 index 00000000..1f73402b --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/includes/logspace.h @@ -0,0 +1,24 @@ +/* +SCilab2C FOSSEE IIT Bombay + */ + +#ifndef __LOGSPACE_H__ +#define __LOGSPACE_H__ + +#include "dynlib_elementaryfunctions.h" +#ifdef __cplusplus +extern "C" { +#endif + + +EXTERN_ELEMFUNCT void dlogspaces(double low_limit,double up_limit,double range_num, double* out); + +EXTERN_ELEMFUNCT void dlogspacea(double *low_limit,int row,double *up_limit,double range_num, double* out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* !__LOGSPACE_H__ */ + diff --git a/2.3-1/src/c/elementaryFunctions/interfaces/int_linspace.h b/2.3-1/src/c/elementaryFunctions/interfaces/int_linspace.h new file mode 100644 index 00000000..4e60b15b --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/interfaces/int_linspace.h @@ -0,0 +1,10 @@ +/* Scilab2C FOSSEE IITB */ + +#ifndef __INT_LINSPACE_H__ +#define __INT_LINSPACE_H__ + +#define d0d0d0linspaced2(in1,in2,in3,out) dlinspaces(in1,in2,in3,out) + +#define d2d2d0linspaced2(in1,size1,in2,size2,in3,out) dlinspacea(in1,size1[0],in2,in3,out) + +#endif diff --git a/2.3-1/src/c/elementaryFunctions/interfaces/int_logspace.h b/2.3-1/src/c/elementaryFunctions/interfaces/int_logspace.h new file mode 100644 index 00000000..34e325ac --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/interfaces/int_logspace.h @@ -0,0 +1,10 @@ +/* Scilab2C FOSSEE IITB */ + +#ifndef __INT_LOGSPACE_H__ +#define __INT_LOGSPACE_H__ + +#define d0d0d0logspaced2(in1,in2,in3,out) dlogspaces(in1,in2,in3,out) + +#define d2d2d0logspaced2(in1,size1,in2,size2,in3,out) dlogspacea(in1,size1[0],in2,in3,out) + +#endif diff --git a/2.3-1/src/c/elementaryFunctions/linspace/dlinspacea.c b/2.3-1/src/c/elementaryFunctions/linspace/dlinspacea.c new file mode 100644 index 00000000..f67968d6 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/linspace/dlinspacea.c @@ -0,0 +1,39 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + +#include "linspace.h" +void dlinspacea(double *low_limit,int _row,double *up_limit,double range_num,double *out) +{ + int i,j,k; + double temp; + float step_iterate[_row]; // for each row the spacing between two values is different. + for(i=0;i<_row;i++) + { + + step_iterate[i] = (up_limit[i]-low_limit[i])/(range_num-1); + + } + for(j=0;j < _row;j++) + { + out[j] = low_limit[j]; // For every row first element is the first value of low_limit array + temp = low_limit[j]; + for(k=1;k < (double)range_num;k++ ) + { + out[(_row*k)+j] = temp + step_iterate[j]; /* Output matrix positions for 3 X 5 matrix are [0 3 6 9 12;1 4 7 10 13;2 5 8 11 14] so (_row*k)+j) used*/ + temp = out[(_row*k)+j]; + if(k == (double)range_num-1 ) + { + out[(_row*k)+j] = (double)up_limit[j]; // Last value of output is equal to first value of up_limit array + } + + } + + + } + + + + +} + diff --git a/2.3-1/src/c/elementaryFunctions/linspace/dlinspacea.c~ b/2.3-1/src/c/elementaryFunctions/linspace/dlinspacea.c~ new file mode 100644 index 00000000..f67968d6 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/linspace/dlinspacea.c~ @@ -0,0 +1,39 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + +#include "linspace.h" +void dlinspacea(double *low_limit,int _row,double *up_limit,double range_num,double *out) +{ + int i,j,k; + double temp; + float step_iterate[_row]; // for each row the spacing between two values is different. + for(i=0;i<_row;i++) + { + + step_iterate[i] = (up_limit[i]-low_limit[i])/(range_num-1); + + } + for(j=0;j < _row;j++) + { + out[j] = low_limit[j]; // For every row first element is the first value of low_limit array + temp = low_limit[j]; + for(k=1;k < (double)range_num;k++ ) + { + out[(_row*k)+j] = temp + step_iterate[j]; /* Output matrix positions for 3 X 5 matrix are [0 3 6 9 12;1 4 7 10 13;2 5 8 11 14] so (_row*k)+j) used*/ + temp = out[(_row*k)+j]; + if(k == (double)range_num-1 ) + { + out[(_row*k)+j] = (double)up_limit[j]; // Last value of output is equal to first value of up_limit array + } + + } + + + } + + + + +} + diff --git a/2.3-1/src/c/elementaryFunctions/linspace/dlinspaces.c b/2.3-1/src/c/elementaryFunctions/linspace/dlinspaces.c new file mode 100644 index 00000000..82b88e34 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/linspace/dlinspaces.c @@ -0,0 +1,25 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + +#include "linspace.h" +void dlinspaces(double low_limit,double up_limit,double range_num,double *out) +{ + int j; + double temp = low_limit; + float step_iterate = (up_limit-low_limit)/(range_num-1); + out[0] = low_limit; //First value of output is equal to low_limit value + for(j=1; j<(double)range_num; j++) + { + out[j] = temp + step_iterate; + temp = out[j]; + if(j == (double)range_num-1 ) + { + out[j] = (double)up_limit; // Last value of output is equal to up_limit value + } + } + + + +} + diff --git a/2.3-1/src/c/elementaryFunctions/linspace/dlinspaces.c~ b/2.3-1/src/c/elementaryFunctions/linspace/dlinspaces.c~ new file mode 100644 index 00000000..82b88e34 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/linspace/dlinspaces.c~ @@ -0,0 +1,25 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + +#include "linspace.h" +void dlinspaces(double low_limit,double up_limit,double range_num,double *out) +{ + int j; + double temp = low_limit; + float step_iterate = (up_limit-low_limit)/(range_num-1); + out[0] = low_limit; //First value of output is equal to low_limit value + for(j=1; j<(double)range_num; j++) + { + out[j] = temp + step_iterate; + temp = out[j]; + if(j == (double)range_num-1 ) + { + out[j] = (double)up_limit; // Last value of output is equal to up_limit value + } + } + + + +} + diff --git a/2.3-1/src/c/elementaryFunctions/linspace/u8linspacea.c~ b/2.3-1/src/c/elementaryFunctions/linspace/u8linspacea.c~ new file mode 100644 index 00000000..2e623fa6 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/linspace/u8linspacea.c~ @@ -0,0 +1,39 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + +#include "linspace.h" +void u8linspacea(uint8 *low_limit,int _row,uint8 *up_limit,double range_num,uint8 *out) +{ + int i,j,k; + uint8 temp; + float step_iterate[_row]; // for each row the spacing between two values is different. + for(i=0;i<_row;i++) + { + + step_iterate[i] = (up_limit[i]-low_limit[i])/(range_num-1); + + } + for(j=0;j < _row;j++) + { + out[j] = low_limit[j]; // For every row first element is the first value of low_limit array + temp = low_limit[j]; + for(k=1;k < (double)range_num;k++ ) + { + out[(_row*k)+j] = temp + step_iterate[j]; /* Output matrix positions for 3 X 5 matrix are [0 3 6 9 12;1 4 7 10 13;2 5 8 11 14] so (_row*k)+j) used*/ + temp = out[(_row*k)+j]; + if(k == (double)range_num-1 ) + { + out[(_row*k)+j] = (uint8)up_limit[j]; // Last value of output is equal to first value of up_limit array + } + + } + + + } + + + + +} + diff --git a/2.3-1/src/c/elementaryFunctions/linspace/u8linspaces.c~ b/2.3-1/src/c/elementaryFunctions/linspace/u8linspaces.c~ new file mode 100644 index 00000000..0320a276 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/linspace/u8linspaces.c~ @@ -0,0 +1,25 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + +#include "linspace.h" +void u8linspaces(uint8 low_limit,uint8 up_limit,double range_num,uint8 *out) +{ + int j; + uint8 temp = low_limit; + float step_iterate = (up_limit-low_limit)/(range_num-1); + out[0] = low_limit; //First value of output is equal to low_limit value + for(j=1; j<(double)range_num; j++) + { + out[j] = temp + step_iterate; + temp = out[j]; + if(j == (double)range_num-1 ) + { + out[j] = (uint8)up_limit; // Last value of output is equal to up_limit value + } + } + + + +} + diff --git a/2.3-1/src/c/elementaryFunctions/logspace/dlogspacea.c b/2.3-1/src/c/elementaryFunctions/logspace/dlogspacea.c new file mode 100644 index 00000000..f8b283c6 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/logspace/dlogspacea.c @@ -0,0 +1,40 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + +#include "logspace.h" +#include<math.h> +void dlogspacea(double *low_limit,int _row,double *up_limit,double range_num,double *out) +{ + int i,j,k; + double temp; + double step_iterate[_row]; // for each row the spacing between two values is different. + for(i=0;i<_row;i++) + { + step_iterate[i] = pow(10,((up_limit[i]-low_limit[i])/(range_num-1))); + + + } + for(j=0;j < _row;j++) + { + out[j] = pow(10,low_limit[j]); // For every row first element is equal to 10 raise to the first value of low_limit array + temp = out[j]; + for(k=1;k < (double)range_num;k++ ) + { + out[(_row*k)+j] = temp*step_iterate[j]; /* Output matrix positions for 3 X 5 matrix are [0 3 6 9 12;1 4 7 10 13;2 5 8 11 14] so (_row*k)+j) used*/ + temp = out[(_row*k)+j]; + if(k == (double)range_num-1 ) + { + out[(_row*k)+j] = pow(10,((double)up_limit[j])); // For every row Last value of output is equal to 10 raise to first value of up_limit array + } + + } + + + } + + + + +} + diff --git a/2.3-1/src/c/elementaryFunctions/logspace/dlogspaces.c b/2.3-1/src/c/elementaryFunctions/logspace/dlogspaces.c new file mode 100644 index 00000000..7970321b --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/logspace/dlogspaces.c @@ -0,0 +1,26 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + +#include "logspace.h" +#include<math.h> +void dlogspaces(double low_limit,double up_limit,double range_num,double *out) +{ + int j; + double temp = pow(10,low_limit); + double step_iterate = pow(10,((up_limit-low_limit)/(range_num-1))); + out[0] = pow(10,low_limit); //First value of output is equal to low_limit value + for(j=1; j<(double)range_num; j++) + { + out[j] = temp*step_iterate; + temp = out[j]; + if(j == (double)range_num-1 ) + { + out[j] = pow(10,((double)up_limit)); // Last value of output is equal to up_limit value + } + } + + + +} + diff --git a/2.3-1/src/c/matrixOperations/determ/i16determa.c b/2.3-1/src/c/matrixOperations/determ/i16determa.c new file mode 100644 index 00000000..a1184553 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/determ/i16determa.c @@ -0,0 +1,92 @@ +/* + * 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 <stdlib.h> +#ifndef WITHOUT_LAPACK +#include "lapack.h" +#endif +#include "determ.h" +#include "lapack.h" + +int16 i16determa(int16 * in, int size){ +#ifndef WITHOUT_LAPACK + int i=0, info=0; + int16 out=0; + int16 *inCopy=NULL; + int* tmp=NULL; + + /*Calculation of the determinant*/ + switch (size){ + case 2 : out = in[0]*in[3]-in[1]*in[2]; + break; + case 3 : /*regle de Sarrus*/ + out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7] + -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6]; + break; + default : + + /*Copy the input matrix*/ + inCopy=(int16*)malloc((unsigned int)(size*size)*sizeof(int16)); + for (i=0;i<size*size;i++) inCopy[i]=in[i]; + + tmp=(int*)malloc((unsigned int)size*sizeof(int)); + dgetrf_(&size, &size, inCopy, &size, tmp, &info); + out=1; + for (i=0;i<size;i++){ + if (tmp[i]!=i+1) out=-out; + out=inCopy[i*(size+1)]*out; + } + free(tmp); + free(inCopy); + break; + } + +#else + int i=0, j=0, k=0; + int16 out=0, pivot=0; + int16 *inCopy=NULL; + + /*Calculation of the determinant*/ + switch (size){ + case 2 : out = in[0]*in[3]-in[1]*in[2]; + break; + case 3 : /*regle de Sarrus*/ + out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7] + -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6]; + break; + default : + + /*Copy the input matrix*/ + inCopy=malloc((unsigned int)(size*size)*sizeof(int16)); + for (i=0;i<size*size;i++) inCopy[i]=in[i]; + + for (i=0;i<size;i++){ + for (j=i+1;j<size;j++){ + pivot = inCopy[i*size+j]/inCopy[i*size+i]; + for (k=0;k<size-i;k++){ + inCopy[i*size+j+k*size]-=pivot*inCopy[i*size+i+k*size]; + } + } + } + out=1; + for (i=0;i<size;i++){ + out *= inCopy[i*size+i]; + } + free(inCopy); + break; + + } +#endif + + + return out; +} diff --git a/2.3-1/src/c/matrixOperations/determ/i8determa.c b/2.3-1/src/c/matrixOperations/determ/i8determa.c new file mode 100644 index 00000000..9693fe67 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/determ/i8determa.c @@ -0,0 +1,92 @@ +/* + * 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 <stdlib.h> +#ifndef WITHOUT_LAPACK +#include "lapack.h" +#endif +#include "determ.h" +#include "lapack.h" + +int8 i8determa(int8 * in, int size){ +#ifndef WITHOUT_LAPACK + int i=0, info=0; + int8 out=0; + int8 *inCopy=NULL; + int* tmp=NULL; + + /*Calculation of the determinant*/ + switch (size){ + case 2 : out = in[0]*in[3]-in[1]*in[2]; + break; + case 3 : /*regle de Sarrus*/ + out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7] + -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6]; + break; + default : + + /*Copy the input matrix*/ + inCopy=(int8*)malloc((unsigned int)(size*size)*sizeof(int8)); + for (i=0;i<size*size;i++) inCopy[i]=in[i]; + + tmp=(int*)malloc((unsigned int)size*sizeof(int)); + dgetrf_(&size, &size, inCopy, &size, tmp, &info); + out=1; + for (i=0;i<size;i++){ + if (tmp[i]!=i+1) out=-out; + out=inCopy[i*(size+1)]*out; + } + free(tmp); + free(inCopy); + break; + } + +#else + int i=0, j=0, k=0; + int8 out=0, pivot=0; + int8 *inCopy=NULL; + + /*Calculation of the determinant*/ + switch (size){ + case 2 : out = in[0]*in[3]-in[1]*in[2]; + break; + case 3 : /*regle de Sarrus*/ + out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7] + -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6]; + break; + default : + + /*Copy the input matrix*/ + inCopy=malloc((unsigned int)(size*size)*sizeof(int8)); + for (i=0;i<size*size;i++) inCopy[i]=in[i]; + + for (i=0;i<size;i++){ + for (j=i+1;j<size;j++){ + pivot = inCopy[i*size+j]/inCopy[i*size+i]; + for (k=0;k<size-i;k++){ + inCopy[i*size+j+k*size]-=pivot*inCopy[i*size+i+k*size]; + } + } + } + out=1; + for (i=0;i<size;i++){ + out *= inCopy[i*size+i]; + } + free(inCopy); + break; + + } +#endif + + + return out; +} diff --git a/2.3-1/src/c/matrixOperations/determ/u16determa.c b/2.3-1/src/c/matrixOperations/determ/u16determa.c new file mode 100644 index 00000000..480d1ed3 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/determ/u16determa.c @@ -0,0 +1,92 @@ +/* + * 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 <stdlib.h> +#ifndef WITHOUT_LAPACK +#include "lapack.h" +#endif +#include "determ.h" +#include "lapack.h" + +uint16 u16determa(uint16 * in, int size){ +#ifndef WITHOUT_LAPACK + int i=0, info=0; + uint16 out=0; + uint16 *inCopy=NULL; + int* tmp=NULL; + + /*Calculation of the determinant*/ + switch (size){ + case 2 : out = in[0]*in[3]-in[1]*in[2]; + break; + case 3 : /*regle de Sarrus*/ + out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7] + -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6]; + break; + default : + + /*Copy the input matrix*/ + inCopy=(uint16*)malloc((unsigned int)(size*size)*sizeof(uint16)); + for (i=0;i<size*size;i++) inCopy[i]=in[i]; + + tmp=(int*)malloc((unsigned int)size*sizeof(int)); + dgetrf_(&size, &size, inCopy, &size, tmp, &info); + out=1; + for (i=0;i<size;i++){ + if (tmp[i]!=i+1) out=-out; + out=inCopy[i*(size+1)]*out; + } + free(tmp); + free(inCopy); + break; + } + +#else + int i=0, j=0, k=0; + uint16 out=0, pivot=0; + uint16 *inCopy=NULL; + + /*Calculation of the determinant*/ + switch (size){ + case 2 : out = in[0]*in[3]-in[1]*in[2]; + break; + case 3 : /*regle de Sarrus*/ + out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7] + -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6]; + break; + default : + + /*Copy the input matrix*/ + inCopy=malloc((unsigned int)(size*size)*sizeof(uint16)); + for (i=0;i<size*size;i++) inCopy[i]=in[i]; + + for (i=0;i<size;i++){ + for (j=i+1;j<size;j++){ + pivot = inCopy[i*size+j]/inCopy[i*size+i]; + for (k=0;k<size-i;k++){ + inCopy[i*size+j+k*size]-=pivot*inCopy[i*size+i+k*size]; + } + } + } + out=1; + for (i=0;i<size;i++){ + out *= inCopy[i*size+i]; + } + free(inCopy); + break; + + } +#endif + + + return out; +} diff --git a/2.3-1/src/c/matrixOperations/determ/u8determa.c b/2.3-1/src/c/matrixOperations/determ/u8determa.c new file mode 100644 index 00000000..3fb18d54 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/determ/u8determa.c @@ -0,0 +1,92 @@ +/* + * 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 <stdlib.h> +#ifndef WITHOUT_LAPACK +#include "lapack.h" +#endif +#include "determ.h" +#include "lapack.h" + +uint8 u8determa(uint8 * in, int size){ +#ifndef WITHOUT_LAPACK + int i=0, info=0; + uint8 out=0; + uint8 *inCopy=NULL; + int* tmp=NULL; + + /*Calculation of the determinant*/ + switch (size){ + case 2 : out = in[0]*in[3]-in[1]*in[2]; + break; + case 3 : /*regle de Sarrus*/ + out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7] + -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6]; + break; + default : + + /*Copy the input matrix*/ + inCopy=(uint8*)malloc((unsigned int)(size*size)*sizeof(uint8)); + for (i=0;i<size*size;i++) inCopy[i]=in[i]; + + tmp=(int*)malloc((unsigned int)size*sizeof(int)); + dgetrf_(&size, &size, inCopy, &size, tmp, &info); + out=1; + for (i=0;i<size;i++){ + if (tmp[i]!=i+1) out=-out; + out=inCopy[i*(size+1)]*out; + } + free(tmp); + free(inCopy); + break; + } + +#else + int i=0, j=0, k=0; + uint8 out=0, pivot=0; + uint8 *inCopy=NULL; + + /*Calculation of the determinant*/ + switch (size){ + case 2 : out = in[0]*in[3]-in[1]*in[2]; + break; + case 3 : /*regle de Sarrus*/ + out = in[0]*in[4]*in[8]+in[1]*in[5]*in[6]+in[2]*in[3]*in[7] + -in[0]*in[5]*in[7]-in[1]*in[3]*in[8]-in[2]*in[4]*in[6]; + break; + default : + + /*Copy the input matrix*/ + inCopy=malloc((unsigned int)(size*size)*sizeof(uint8)); + for (i=0;i<size*size;i++) inCopy[i]=in[i]; + + for (i=0;i<size;i++){ + for (j=i+1;j<size;j++){ + pivot = inCopy[i*size+j]/inCopy[i*size+i]; + for (k=0;k<size-i;k++){ + inCopy[i*size+j+k*size]-=pivot*inCopy[i*size+i+k*size]; + } + } + } + out=1; + for (i=0;i<size;i++){ + out *= inCopy[i*size+i]; + } + free(inCopy); + break; + + } +#endif + + + return out; +} diff --git a/2.3-1/src/c/matrixOperations/diag/ddiaga.c b/2.3-1/src/c/matrixOperations/diag/ddiaga.c new file mode 100644 index 00000000..26363ef9 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/ddiaga.c @@ -0,0 +1,40 @@ +/* + * 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 "diag.h" +#include<stdlib.h> // Used for Absolute value of insert_post +void ddiaga(double in, int size,int insert_post,double *out) +{ + + int i; + + for(i=0;i < ((size+abs(insert_post))*(size+abs(insert_post)));i++) + { + out[i] = 0; + + } + + if(insert_post < 0) + { + + out[abs(insert_post)] = in; + + } + else + { + + out[(size + insert_post)*insert_post] = in; + + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/ddiagexa.c b/2.3-1/src/c/matrixOperations/diag/ddiagexa.c new file mode 100644 index 00000000..191c1311 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/ddiagexa.c @@ -0,0 +1,130 @@ +/* + * 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 "diag.h" +void ddiagexa(double *in, int _row,int _column,int extract_post,double *out) +{ + + + int j; + if(_row == _column) + { + if(extract_post <= 0) + { + for ( j = 0 ; j < _column ; j++ ) + { + + + out[j] = in[((_column+1)*j)-extract_post] ; + + } + } + else + { + for ( j = extract_post ; j < _column ; j++ ) + { + + + out[j-extract_post] = in[((_column+1)*j)-extract_post] ; + + } + } + + } + else if(_row > _column) + { + + if(extract_post >=0) + { + + for(j = extract_post; j < _column;j++) + { + + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + + } + else + { + + if((abs(extract_post) <= (_row - _column))) + { + for(j = 0; j < _column ; j++) + { + out[j] = in[((_row+1)*j)-extract_post]; + + } + } + else + { + + for(j=0; j < (_row + extract_post);j++) + { + + out[j] = in[((_row+1)*j)-extract_post]; + + } + + + + } + + } + + } + else if (_row < _column) + { + + if(extract_post > 0) + { + if((extract_post <= (_column - _row))) + { + for(j=extract_post;j < _column;j++) + { + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + } + else + { + for(j=extract_post;j < _column;j++) + { + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + } + + } + else + { + + + for(j=0;j < (_row+extract_post);j++) + { + + out[j] = in[((_row+1)*j)-extract_post]; + + + + } + + + + } + + + } + + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/ddiagexs.c b/2.3-1/src/c/matrixOperations/diag/ddiagexs.c new file mode 100644 index 00000000..fb007b52 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/ddiagexs.c @@ -0,0 +1,53 @@ +/* + * 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 "diag.h" +double ddiagexs(double *in, int _row,int _column,int extract_post) +{ + + if(_row == _column) + { + + if(extract_post < 0) + { + + return in[_row-1] ; + } + else + { + + return in[(_row)*(_row-1)] ; + + } + } + + else + { + + if(extract_post < 0) + { + + return in[_row-1]; + + } + else + { + return in[(_row)*(_column-1)]; + + } + + + + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/ddiagina.c b/2.3-1/src/c/matrixOperations/diag/ddiagina.c new file mode 100644 index 00000000..c4093b2d --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/ddiagina.c @@ -0,0 +1,59 @@ +/* + * 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 "diag.h" +#include<stdlib.h> // Used for Absolute value of insert_post +void ddiagina(double *in, int _row,int _column,int insert_post,double *out) +{ + + int i, j; + if(_row == 1) + { + _column = _column; + + } + else + { + _column = _row; + + } + + for(i=0;i < ((_column+abs(insert_post))*(_column+abs(insert_post)));i++) + { + out[i] = 0; + + } + + if(insert_post < 0) + { + for ( j = 0 ; j < _column ; j++ ) + { + + + + out[((_column+abs(insert_post))*j)+abs(insert_post)+j] = in[j]; + } + + } + else + { + for ( j = insert_post ; j < _column+insert_post ; j++ ) + { + + + out[((_column+insert_post)*j)-insert_post+j] = in[j-insert_post] ; + + } + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/ddiagins.c b/2.3-1/src/c/matrixOperations/diag/ddiagins.c new file mode 100644 index 00000000..d1fc527a --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/ddiagins.c @@ -0,0 +1,37 @@ +/* + * 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 "diag.h" +void ddiagins(double *in, int size,double *out) +{ + + int i, j; + for ( i = 0 ; i < size ; i++ ) + { + for ( j = 0 ; j < size ; j++ ) + { + if(i==j) + { + out[(size+1)*i] = in[i] ; + /* Because to replace the diagonal element with input matrix, (_coulmn+1)*i gives the diagonal postion for m*n matrix + i.e if 3*3 matrix then diagonal postion will be 0,4,6 and for 4*4 matrix diagonal postion will be 0,5,10,15 */ + + + } + + } + } + + + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/ddiags.c b/2.3-1/src/c/matrixOperations/diag/ddiags.c new file mode 100644 index 00000000..b43e5d63 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/ddiags.c @@ -0,0 +1,20 @@ +/* + * 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 "diag.h" +double ddiags(double in) +{ + + return in; + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i16diaga.c b/2.3-1/src/c/matrixOperations/diag/i16diaga.c new file mode 100644 index 00000000..29f92907 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i16diaga.c @@ -0,0 +1,40 @@ +/* + * 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 "diag.h" +#include<stdlib.h> // Used for Absolute value of insert_post +void i16diaga(int16 in, int size,int insert_post,int16 *out) +{ + + int i; + + for(i=0;i < ((size+abs(insert_post))*(size+abs(insert_post)));i++) + { + out[i] = 0; + + } + + if(insert_post < 0) + { + + out[abs(insert_post)] = in; + + } + else + { + + out[(size + insert_post)*insert_post] = in; + + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i16diagexa.c b/2.3-1/src/c/matrixOperations/diag/i16diagexa.c new file mode 100644 index 00000000..7e85c916 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i16diagexa.c @@ -0,0 +1,130 @@ +/* + * 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 "diag.h" +void i16diagexa(int16 *in, int _row,int _column,int extract_post,int16 *out) +{ + + + int j; + if(_row == _column) + { + if(extract_post <= 0) + { + for ( j = 0 ; j < _column ; j++ ) + { + + + out[j] = in[((_column+1)*j)-extract_post] ; + + } + } + else + { + for ( j = extract_post ; j < _column ; j++ ) + { + + + out[j-extract_post] = in[((_column+1)*j)-extract_post] ; + + } + } + + } + else if(_row > _column) + { + + if(extract_post >=0) + { + + for(j = extract_post; j < _column;j++) + { + + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + + } + else + { + + if((abs(extract_post) <= (_row - _column))) + { + for(j = 0; j < _column ; j++) + { + out[j] = in[((_row+1)*j)-extract_post]; + + } + } + else + { + + for(j=0; j < (_row + extract_post);j++) + { + + out[j] = in[((_row+1)*j)-extract_post]; + + } + + + + } + + } + + } + else if (_row < _column) + { + + if(extract_post > 0) + { + if((extract_post <= (_column - _row))) + { + for(j=extract_post;j < _column;j++) + { + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + } + else + { + for(j=extract_post;j < _column;j++) + { + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + } + + } + else + { + + + for(j=0;j < (_row+extract_post);j++) + { + + out[j] = in[((_row+1)*j)-extract_post]; + + + + } + + + + } + + + } + + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i16diagexs.c b/2.3-1/src/c/matrixOperations/diag/i16diagexs.c new file mode 100644 index 00000000..87536ce1 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i16diagexs.c @@ -0,0 +1,53 @@ +/* + * 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 "diag.h" +int16 i16diagexs(int16 *in, int _row,int _column,int extract_post) +{ + + if(_row == _column) + { + + if(extract_post < 0) + { + + return in[_row-1] ; + } + else + { + + return in[(_row)*(_row-1)] ; + + } + } + + else + { + + if(extract_post < 0) + { + + return in[_row-1]; + + } + else + { + return in[(_row)*(_column-1)]; + + } + + + + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i16diagina.c b/2.3-1/src/c/matrixOperations/diag/i16diagina.c new file mode 100644 index 00000000..518f627c --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i16diagina.c @@ -0,0 +1,58 @@ +/* + * 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 "diag.h" +#include<stdlib.h> // Used for Absolute value of insert_post +void i16diagina(int16 *in, int _row,int _column,int insert_post,int16 *out) +{ + int i, j; + if(_row == 1) + { + _column = _column; + + } + else + { + _column = _row; + + } + + for(i=0;i < ((_column+abs(insert_post))*(_column+abs(insert_post)));i++) + { + out[i] = 0; + + } + + if(insert_post < 0) + { + for ( j = 0 ; j < _column ; j++ ) + { + + + + out[((_column+abs(insert_post))*j)+abs(insert_post)+j] = in[j]; + } + + } + else + { + for ( j = insert_post ; j < _column+insert_post ; j++ ) + { + + + out[((_column+insert_post)*j)-insert_post+j] = in[j-insert_post] ; + + } + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i16diagins.c b/2.3-1/src/c/matrixOperations/diag/i16diagins.c new file mode 100644 index 00000000..f0d46eb9 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i16diagins.c @@ -0,0 +1,37 @@ +/* + * 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 "diag.h" +void i16diagins(int16 *in, int size,int16 *out) +{ + + int i, j; + for ( i = 0 ; i < size ; i++ ) + { + for ( j = 0 ; j < size ; j++ ) + { + if(i==j) + { + out[(size+1)*i] = in[i] ; + /* Because to replace the diagonal element with input matrix, (_coulmn+1)*i gives the diagonal postion for m*n matrix + i.e if 3*3 matrix then diagonal postion will be 0,4,6 and for 4*4 matrix diagonal postion will be 0,5,10,15 */ + + + } + + } + } + + + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i16diags.c b/2.3-1/src/c/matrixOperations/diag/i16diags.c new file mode 100644 index 00000000..b08657f5 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i16diags.c @@ -0,0 +1,20 @@ +/* + * 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 "diag.h" +int16 i16diags(int16 in) +{ + + return in; + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i8diaga.c b/2.3-1/src/c/matrixOperations/diag/i8diaga.c new file mode 100644 index 00000000..c41ec9df --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i8diaga.c @@ -0,0 +1,40 @@ +/* + * 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 "diag.h" +#include<stdlib.h> // Used for Absolute value of insert_post +void i8diaga(int8 in, int size,int insert_post,int8 *out) +{ + + int i; + + for(i=0;i < ((size+abs(insert_post))*(size+abs(insert_post)));i++) + { + out[i] = 0; + + } + + if(insert_post < 0) + { + + out[abs(insert_post)] = in; + + } + else + { + + out[(size + insert_post)*insert_post] = in; + + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i8diagexa.c b/2.3-1/src/c/matrixOperations/diag/i8diagexa.c new file mode 100644 index 00000000..56fab854 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i8diagexa.c @@ -0,0 +1,130 @@ +/* + * 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 "diag.h" +void i8diagexa(int8 *in, int _row,int _column,int extract_post,int8 *out) +{ + + + int j; + if(_row == _column) + { + if(extract_post <= 0) + { + for ( j = 0 ; j < _column ; j++ ) + { + + + out[j] = in[((_column+1)*j)-extract_post] ; + + } + } + else + { + for ( j = extract_post ; j < _column ; j++ ) + { + + + out[j-extract_post] = in[((_column+1)*j)-extract_post] ; + + } + } + + } + else if(_row > _column) + { + + if(extract_post >=0) + { + + for(j = extract_post; j < _column;j++) + { + + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + + } + else + { + + if((abs(extract_post) <= (_row - _column))) + { + for(j = 0; j < _column ; j++) + { + out[j] = in[((_row+1)*j)-extract_post]; + + } + } + else + { + + for(j=0; j < (_row + extract_post);j++) + { + + out[j] = in[((_row+1)*j)-extract_post]; + + } + + + + } + + } + + } + else if (_row < _column) + { + + if(extract_post > 0) + { + if((extract_post <= (_column - _row))) + { + for(j=extract_post;j < _column;j++) + { + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + } + else + { + for(j=extract_post;j < _column;j++) + { + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + } + + } + else + { + + + for(j=0;j < (_row+extract_post);j++) + { + + out[j] = in[((_row+1)*j)-extract_post]; + + + + } + + + + } + + + } + + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i8diagexs.c b/2.3-1/src/c/matrixOperations/diag/i8diagexs.c new file mode 100644 index 00000000..6aa76049 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i8diagexs.c @@ -0,0 +1,53 @@ +/* + * 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 "diag.h" +int8 i8diagexs(int8 *in, int _row,int _column,int extract_post) +{ + + if(_row == _column) + { + + if(extract_post < 0) + { + + return in[_row-1] ; + } + else + { + + return in[(_row)*(_row-1)] ; + + } + } + + else + { + + if(extract_post < 0) + { + + return in[_row-1]; + + } + else + { + return in[(_row)*(_column-1)]; + + } + + + + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i8diagina.c b/2.3-1/src/c/matrixOperations/diag/i8diagina.c new file mode 100644 index 00000000..77a7e074 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i8diagina.c @@ -0,0 +1,58 @@ +/* + * 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 "diag.h" +#include<stdlib.h> // Used for Absolute value of insert_post +void i8diagina(int8 *in, int _row,int _column,int insert_post,int8 *out) +{ + int i, j; + if(_row == 1) + { + _column = _column; + + } + else + { + _column = _row; + + } + + for(i=0;i < ((_column+abs(insert_post))*(_column+abs(insert_post)));i++) + { + out[i] = 0; + + } + + if(insert_post < 0) + { + for ( j = 0 ; j < _column ; j++ ) + { + + + + out[((_column+abs(insert_post))*j)+abs(insert_post)+j] = in[j]; + } + + } + else + { + for ( j = insert_post ; j < _column+insert_post ; j++ ) + { + + + out[((_column+insert_post)*j)-insert_post+j] = in[j-insert_post] ; + + } + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i8diagins.c b/2.3-1/src/c/matrixOperations/diag/i8diagins.c new file mode 100644 index 00000000..adb7eb96 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i8diagins.c @@ -0,0 +1,37 @@ +/* + * 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 "diag.h" +void i8diagins(int8 *in, int size,int8 *out) +{ + + int i, j; + for ( i = 0 ; i < size ; i++ ) + { + for ( j = 0 ; j < size ; j++ ) + { + if(i==j) + { + out[(size+1)*i] = in[i] ; + /* Because to replace the diagonal element with input matrix, (_coulmn+1)*i gives the diagonal postion for m*n matrix + i.e if 3*3 matrix then diagonal postion will be 0,4,6 and for 4*4 matrix diagonal postion will be 0,5,10,15 */ + + + } + + } + } + + + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/i8diags.c b/2.3-1/src/c/matrixOperations/diag/i8diags.c new file mode 100644 index 00000000..d4e44894 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/i8diags.c @@ -0,0 +1,20 @@ +/* + * 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 "diag.h" +int8 i8diags(int8 in) +{ + + return in; + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u16diaga.c b/2.3-1/src/c/matrixOperations/diag/u16diaga.c new file mode 100644 index 00000000..90a10536 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u16diaga.c @@ -0,0 +1,40 @@ +/* + * 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 "diag.h" +#include<stdlib.h> // Used for Absolute value of insert_post +void u16diaga(uint16 in, int size,int insert_post,uint16 *out) +{ + + int i; + + for(i=0;i < ((size+abs(insert_post))*(size+abs(insert_post)));i++) + { + out[i] = 0; + + } + + if(insert_post < 0) + { + + out[abs(insert_post)] = in; + + } + else + { + + out[(size + insert_post)*insert_post] = in; + + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u16diagexa.c b/2.3-1/src/c/matrixOperations/diag/u16diagexa.c new file mode 100644 index 00000000..da2088c5 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u16diagexa.c @@ -0,0 +1,130 @@ +/* + * 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 "diag.h" +void u16diagexa(uint16 *in, int _row,int _column,int extract_post,uint16 *out) +{ + + + int j; + if(_row == _column) + { + if(extract_post <= 0) + { + for ( j = 0 ; j < _column ; j++ ) + { + + + out[j] = in[((_column+1)*j)-extract_post] ; + + } + } + else + { + for ( j = extract_post ; j < _column ; j++ ) + { + + + out[j-extract_post] = in[((_column+1)*j)-extract_post] ; + + } + } + + } + else if(_row > _column) + { + + if(extract_post >=0) + { + + for(j = extract_post; j < _column;j++) + { + + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + + } + else + { + + if((abs(extract_post) <= (_row - _column))) + { + for(j = 0; j < _column ; j++) + { + out[j] = in[((_row+1)*j)-extract_post]; + + } + } + else + { + + for(j=0; j < (_row + extract_post);j++) + { + + out[j] = in[((_row+1)*j)-extract_post]; + + } + + + + } + + } + + } + else if (_row < _column) + { + + if(extract_post > 0) + { + if((extract_post <= (_column - _row))) + { + for(j=extract_post;j < _column;j++) + { + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + } + else + { + for(j=extract_post;j < _column;j++) + { + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + } + + } + else + { + + + for(j=0;j < (_row+extract_post);j++) + { + + out[j] = in[((_row+1)*j)-extract_post]; + + + + } + + + + } + + + } + + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u16diagexs.c b/2.3-1/src/c/matrixOperations/diag/u16diagexs.c new file mode 100644 index 00000000..c32849e6 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u16diagexs.c @@ -0,0 +1,53 @@ +/* + * 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 "diag.h" +uint16 u16diagexs(uint16 *in, int _row,int _column,int extract_post) +{ + + if(_row == _column) + { + + if(extract_post < 0) + { + + return in[_row-1] ; + } + else + { + + return in[(_row)*(_row-1)] ; + + } + } + + else + { + + if(extract_post < 0) + { + + return in[_row-1]; + + } + else + { + return in[(_row)*(_column-1)]; + + } + + + + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u16diagina.c b/2.3-1/src/c/matrixOperations/diag/u16diagina.c new file mode 100644 index 00000000..f5dc6f99 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u16diagina.c @@ -0,0 +1,58 @@ +/* + * 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 "diag.h" +#include<stdlib.h> // Used for Absolute value of insert_post +void u16diagina(uint16 *in, int _row,int _column,int insert_post,uint16 *out) +{ + int i, j; + if(_row == 1) + { + _column = _column; + + } + else + { + _column = _row; + + } + + for(i=0;i < ((_column+abs(insert_post))*(_column+abs(insert_post)));i++) + { + out[i] = 0; + + } + + if(insert_post < 0) + { + for ( j = 0 ; j < _column ; j++ ) + { + + + + out[((_column+abs(insert_post))*j)+abs(insert_post)+j] = in[j]; + } + + } + else + { + for ( j = insert_post ; j < _column+insert_post ; j++ ) + { + + + out[((_column+insert_post)*j)-insert_post+j] = in[j-insert_post] ; + + } + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u16diagins.c b/2.3-1/src/c/matrixOperations/diag/u16diagins.c new file mode 100644 index 00000000..84cfcb29 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u16diagins.c @@ -0,0 +1,37 @@ +/* + * 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 "diag.h" +void u16diagins(uint16 *in, int size,uint16 *out) +{ + + int i, j; + for ( i = 0 ; i < size ; i++ ) + { + for ( j = 0 ; j < size ; j++ ) + { + if(i==j) + { + out[(size+1)*i] = in[i] ; + /* Because to replace the diagonal element with input matrix, (_coulmn+1)*i gives the diagonal postion for m*n matrix + i.e if 3*3 matrix then diagonal postion will be 0,4,6 and for 4*4 matrix diagonal postion will be 0,5,10,15 */ + + + } + + } + } + + + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u16diags.c b/2.3-1/src/c/matrixOperations/diag/u16diags.c new file mode 100644 index 00000000..0f463b09 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u16diags.c @@ -0,0 +1,20 @@ +/* + * 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 "diag.h" +uint16 u16diags(uint16 in) +{ + + return in; + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u8diaga.c b/2.3-1/src/c/matrixOperations/diag/u8diaga.c new file mode 100644 index 00000000..05a03ba2 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u8diaga.c @@ -0,0 +1,40 @@ +/* + * 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 "diag.h" +#include<stdlib.h> // Used for Absolute value of insert_post +void u8diaga(uint8 in, int size,int insert_post,uint8 *out) +{ + + int i; + + for(i=0;i < ((size+abs(insert_post))*(size+abs(insert_post)));i++) + { + out[i] = 0; + + } + + if(insert_post < 0) + { + + out[abs(insert_post)] = in; + + } + else + { + + out[(size + insert_post)*insert_post] = in; + + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u8diagexa.c b/2.3-1/src/c/matrixOperations/diag/u8diagexa.c new file mode 100644 index 00000000..258e10b0 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u8diagexa.c @@ -0,0 +1,130 @@ +/* + * 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 "diag.h" +void u8diagexa(uint8 *in, int _row,int _column,int extract_post,uint8 *out) +{ + + + int j; + if(_row == _column) + { + if(extract_post <= 0) + { + for ( j = 0 ; j < _column ; j++ ) + { + + + out[j] = in[((_column+1)*j)-extract_post] ; + + } + } + else + { + for ( j = extract_post ; j < _column ; j++ ) + { + + + out[j-extract_post] = in[((_column+1)*j)-extract_post] ; + + } + } + + } + else if(_row > _column) + { + + if(extract_post >=0) + { + + for(j = extract_post; j < _column;j++) + { + + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + + } + else + { + + if((abs(extract_post) <= (_row - _column))) + { + for(j = 0; j < _column ; j++) + { + out[j] = in[((_row+1)*j)-extract_post]; + + } + } + else + { + + for(j=0; j < (_row + extract_post);j++) + { + + out[j] = in[((_row+1)*j)-extract_post]; + + } + + + + } + + } + + } + else if (_row < _column) + { + + if(extract_post > 0) + { + if((extract_post <= (_column - _row))) + { + for(j=extract_post;j < _column;j++) + { + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + } + else + { + for(j=extract_post;j < _column;j++) + { + out[j-extract_post] = in[((_row+1)*j)-extract_post]; + } + + } + + } + else + { + + + for(j=0;j < (_row+extract_post);j++) + { + + out[j] = in[((_row+1)*j)-extract_post]; + + + + } + + + + } + + + } + + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u8diagexs.c b/2.3-1/src/c/matrixOperations/diag/u8diagexs.c new file mode 100644 index 00000000..fbb2ef3f --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u8diagexs.c @@ -0,0 +1,53 @@ +/* + * 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 "diag.h" +uint8 u8diagexs(uint8 *in, int _row,int _column,int extract_post) +{ + + if(_row == _column) + { + + if(extract_post < 0) + { + + return in[_row-1] ; + } + else + { + + return in[(_row)*(_row-1)] ; + + } + } + + else + { + + if(extract_post < 0) + { + + return in[_row-1]; + + } + else + { + return in[(_row)*(_column-1)]; + + } + + + + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u8diagina.c b/2.3-1/src/c/matrixOperations/diag/u8diagina.c new file mode 100644 index 00000000..bea24655 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u8diagina.c @@ -0,0 +1,58 @@ +/* + * 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 "diag.h" +#include<stdlib.h> // Used for Absolute value of insert_post +void u8diagina(uint8 *in, int _row,int _column,int insert_post,uint8 *out) +{ + int i, j; + if(_row == 1) + { + _column = _column; + + } + else + { + _column = _row; + + } + + for(i=0;i < ((_column+abs(insert_post))*(_column+abs(insert_post)));i++) + { + out[i] = 0; + + } + + if(insert_post < 0) + { + for ( j = 0 ; j < _column ; j++ ) + { + + + + out[((_column+abs(insert_post))*j)+abs(insert_post)+j] = in[j]; + } + + } + else + { + for ( j = insert_post ; j < _column+insert_post ; j++ ) + { + + + out[((_column+insert_post)*j)-insert_post+j] = in[j-insert_post] ; + + } + } + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u8diagins.c b/2.3-1/src/c/matrixOperations/diag/u8diagins.c new file mode 100644 index 00000000..f2765952 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u8diagins.c @@ -0,0 +1,37 @@ +/* + * 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 "diag.h" +void u8diagins(uint8 *in, int size,uint8 *out) +{ + + int i, j; + for ( i = 0 ; i < size ; i++ ) + { + for ( j = 0 ; j < size ; j++ ) + { + if(i==j) + { + out[(size+1)*i] = in[i] ; + /* Because to replace the diagonal element with input matrix, (_coulmn+1)*i gives the diagonal postion for m*n matrix + i.e if 3*3 matrix then diagonal postion will be 0,4,6 and for 4*4 matrix diagonal postion will be 0,5,10,15 */ + + + } + + } + } + + + +} + diff --git a/2.3-1/src/c/matrixOperations/diag/u8diags.c b/2.3-1/src/c/matrixOperations/diag/u8diags.c new file mode 100644 index 00000000..97d2e515 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/diag/u8diags.c @@ -0,0 +1,20 @@ +/* + * 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 "diag.h" +uint8 u8diags(uint8 in) +{ + + return in; + +} + diff --git a/2.3-1/src/c/matrixOperations/division/i16ldivma.c b/2.3-1/src/c/matrixOperations/division/i16ldivma.c new file mode 100644 index 00000000..e5a134d0 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/i16ldivma.c @@ -0,0 +1,111 @@ +/* + * 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 <stdlib.h> +#include <string.h> +#include "matrixDivision.h" +#include "lapack.h" + +void i16ldivma (int16* in1, int lines1, int columns1 , + int16* in2, int lines2, int columns2 , + int16* out ){ + + + char cNorm = 0; + int iExit = 0; + + /*temporary variables*/ + int iWork = 0; + int iInfo = 0; + int iMax = 0; + int16 dblRcond = 0; + + int16 dblEps = 0; + int16 dblAnorm = 0; + + int16 *pAf = NULL; + int16 *pXb = NULL; + int16 *pDwork = NULL; + + int *pRank = NULL; + int *pIpiv = NULL; + int *pJpvt = NULL; + int *pIwork = NULL; + + iWork = max(4 * columns1, max(min(lines1, columns1) + 3 * lines1 + 1, 2 * min(lines1, columns1) + columns2)); + + + lines2 = 0 ; + + /* Array allocations*/ + pAf = (int16*)malloc(sizeof(int16) * (unsigned int) lines1 * (unsigned int) columns1); + pXb = (int16*)malloc(sizeof(int16) * (unsigned int) max(lines1,columns1) * (unsigned int) columns2); + + pRank = (int*)malloc(sizeof(int)); + pIpiv = (int*)malloc(sizeof(int) *(unsigned int) columns1); + pJpvt = (int*)malloc(sizeof(int) *(unsigned int) columns1); + pIwork = (int*)malloc(sizeof(int) *(unsigned int) columns1); + + + + cNorm = '1'; + pDwork = (int16*)malloc(sizeof(int16) *(unsigned int)iWork); + dblEps = getRelativeMachinePrecision() ; + + dblAnorm = dlange_(&cNorm, &lines1, &columns1, in1, &lines1, pDwork); + if(lines1 == columns1) + { + cNorm = 'F'; + dlacpy_(&cNorm, &columns1, &columns1, in1, &columns1, pAf, &columns1); + dgetrf_(&columns1, &columns1, pAf, &columns1, pIpiv, &iInfo); + if(iInfo == 0) + { + cNorm = '1'; + C2F(dgecon)(&cNorm, &columns1, pAf, &columns1, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo); + if(dblRcond > sqrt(dblEps)) + { + cNorm = 'N'; + C2F(dgetrs)(&cNorm, &columns1, &columns2, pAf, &columns1, pIpiv, in2, &columns1, &iInfo); + cNorm = 'F'; + C2F(dlacpy)(&cNorm, &columns1, &columns2, in2, &columns1, out, &columns1); + iExit = 1; + } + } + + } + + if(iExit == 0) + { + dblRcond = sqrt(dblEps); + cNorm = 'F'; + iMax = max(lines1, columns1); + 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); + + if(iInfo == 0) + { + + cNorm = 'F'; + C2F(dlacpy)(&cNorm, &columns1, &columns2, pXb, &iMax, out, &columns1); + } + } + + free(pAf); + free(pXb); + free(pRank); + free(pIpiv); + free(pJpvt); + free(pIwork); + free(pDwork); +} diff --git a/2.3-1/src/c/matrixOperations/division/i16rdivma.c b/2.3-1/src/c/matrixOperations/division/i16rdivma.c new file mode 100644 index 00000000..21f6cc94 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/i16rdivma.c @@ -0,0 +1,129 @@ +/* + * 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 <stdlib.h> +#include <string.h> +#include "matrixDivision.h" +#include "lapack.h" + +void i16rdivma ( int16 * in1, int lines1, int columns1, + int16 * in2, int lines2, int columns2, + int16 * out){ + + char cNorm = 0; + int iExit = 0; + + /*temporary variables*/ + int iWork = 0; + int iInfo = 0; + int iMax = 0; + int16 dblRcond = 0; + + int16 dblEps = 0; + int16 dblAnorm = 0; + + int16 *pAf = NULL; + int16 *pAt = NULL; + int16 *pBt = NULL; + int16 *pDwork = NULL; + + int *pRank = NULL; + int *pIpiv = NULL; + int *pJpvt = NULL; + int *pIwork = NULL; + + iWork = max(4 * columns2, max(min(lines2, columns2) + 3 * lines2 + 1, 2 * min(lines2, columns2) + lines1)); + + + /* Array allocations*/ + pAf = (int16*)malloc(sizeof(int16) * (unsigned int)columns2 * (unsigned int)lines2); + pAt = (int16*)malloc(sizeof(int16) * (unsigned int)columns2 *(unsigned int) lines2); + pBt = (int16*)malloc(sizeof(int16) * (unsigned int)max(lines2,columns2) * (unsigned int)lines1); + + pRank = (int*)malloc(sizeof(int)); + pIpiv = (int*)malloc(sizeof(int) * (unsigned int)columns2); + pJpvt = (int*)malloc(sizeof(int) * (unsigned int)lines2); + pIwork = (int*)malloc(sizeof(int) * (unsigned int)columns2); + + + cNorm = '1'; + pDwork = (int16*)malloc(sizeof(int16) * (unsigned int)iWork); + dblEps = getRelativeMachinePrecision() ; + dblAnorm = dlange_(&cNorm, &lines2, &columns1, in2, &lines2, pDwork); + + /*tranpose A and B*/ + + dtransposea(in2, lines2, columns2, pAt); + dtransposea(in1, lines1, columns2, pBt); + + if(lines2 == columns2) + { + cNorm = 'F'; + dlacpy_(&cNorm, &columns2, &columns2, pAt, &columns2, pAf, &columns2); + dgetrf_(&columns2, &columns2, pAf, &columns2, pIpiv, &iInfo); + if(iInfo == 0) + { + cNorm = '1'; + dgecon_(&cNorm, &columns2, pAf, &columns2, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo); + if(dblRcond > sqrt(dblEps)) + { + cNorm = 'N'; + dgetrs_(&cNorm, &columns2, &lines1, pAf, &columns2, pIpiv, pBt, &columns2, &iInfo); + dtransposea(pBt, columns2, lines1, out); + iExit = 1; + } + } + + } + + if(iExit == 0) + { + dblRcond = sqrt(dblEps); + cNorm = 'F'; + iMax = max(lines2, columns2); + memset(pJpvt, 0x00, (unsigned int)sizeof(int) * (unsigned int)lines2); + dgelsy_(&columns2, &lines2, &lines1, pAt, &columns2, pBt, &iMax, + pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo); + + if(iInfo == 0) + { + + + /* TransposeRealMatrix(pBt, lines1, lines2, out, Max(lines1,columns1), lines2);*/ + + /*Mega caca de la mort qui tue des ours a mains nues + mais je ne sais pas comment le rendre "beau" :(*/ + { + int i,j,ij,ji; + for(j = 0 ; j < lines2 ; j++) + { + for(i = 0 ; i < lines1 ; i++) + { + ij = i + j * lines1; + ji = j + i * max(lines2, columns2); + out[ij] = pBt[ji]; + } + } + } + } + } + + free(pAf); + free(pAt); + free(pBt); + free(pRank); + free(pIpiv); + free(pJpvt); + free(pIwork); + free(pDwork); + +} + diff --git a/2.3-1/src/c/matrixOperations/division/i16rdivv.c b/2.3-1/src/c/matrixOperations/division/i16rdivv.c new file mode 100644 index 00000000..72d3bd60 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/i16rdivv.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" + +int16 i16rdivv(int16 *in1, int16 *in2, int size){ + + int16 out[1] = { 0.0} ; + i16rdivma ( in1,1 ,size ,in2 , 1 , size , out ); + + return out[0] ; +} + + diff --git a/2.3-1/src/c/matrixOperations/division/i8ldivma.c b/2.3-1/src/c/matrixOperations/division/i8ldivma.c new file mode 100644 index 00000000..85271c6b --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/i8ldivma.c @@ -0,0 +1,111 @@ +/* + * 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 <stdlib.h> +#include <string.h> +#include "matrixDivision.h" +#include "lapack.h" + +void i8ldivma (int8* in1, int lines1, int columns1 , + int8* in2, int lines2, int columns2 , + int8* out ){ + + + char cNorm = 0; + int iExit = 0; + + /*temporary variables*/ + int iWork = 0; + int iInfo = 0; + int iMax = 0; + int8 dblRcond = 0; + + int8 dblEps = 0; + int8 dblAnorm = 0; + + int8 *pAf = NULL; + int8 *pXb = NULL; + int8 *pDwork = NULL; + + int *pRank = NULL; + int *pIpiv = NULL; + int *pJpvt = NULL; + int *pIwork = NULL; + + iWork = max(4 * columns1, max(min(lines1, columns1) + 3 * lines1 + 1, 2 * min(lines1, columns1) + columns2)); + + + lines2 = 0 ; + + /* Array allocations*/ + pAf = (int8*)malloc(sizeof(int8) * (unsigned int) lines1 * (unsigned int) columns1); + pXb = (int8*)malloc(sizeof(int8) * (unsigned int) max(lines1,columns1) * (unsigned int) columns2); + + pRank = (int*)malloc(sizeof(int)); + pIpiv = (int*)malloc(sizeof(int) *(unsigned int) columns1); + pJpvt = (int*)malloc(sizeof(int) *(unsigned int) columns1); + pIwork = (int*)malloc(sizeof(int) *(unsigned int) columns1); + + + + cNorm = '1'; + pDwork = (int8*)malloc(sizeof(int8) *(unsigned int)iWork); + dblEps = getRelativeMachinePrecision() ; + + dblAnorm = dlange_(&cNorm, &lines1, &columns1, in1, &lines1, pDwork); + if(lines1 == columns1) + { + cNorm = 'F'; + dlacpy_(&cNorm, &columns1, &columns1, in1, &columns1, pAf, &columns1); + dgetrf_(&columns1, &columns1, pAf, &columns1, pIpiv, &iInfo); + if(iInfo == 0) + { + cNorm = '1'; + C2F(dgecon)(&cNorm, &columns1, pAf, &columns1, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo); + if(dblRcond > sqrt(dblEps)) + { + cNorm = 'N'; + C2F(dgetrs)(&cNorm, &columns1, &columns2, pAf, &columns1, pIpiv, in2, &columns1, &iInfo); + cNorm = 'F'; + C2F(dlacpy)(&cNorm, &columns1, &columns2, in2, &columns1, out, &columns1); + iExit = 1; + } + } + + } + + if(iExit == 0) + { + dblRcond = sqrt(dblEps); + cNorm = 'F'; + iMax = max(lines1, columns1); + 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); + + if(iInfo == 0) + { + + cNorm = 'F'; + C2F(dlacpy)(&cNorm, &columns1, &columns2, pXb, &iMax, out, &columns1); + } + } + + free(pAf); + free(pXb); + free(pRank); + free(pIpiv); + free(pJpvt); + free(pIwork); + free(pDwork); +} diff --git a/2.3-1/src/c/matrixOperations/division/i8rdivma.c b/2.3-1/src/c/matrixOperations/division/i8rdivma.c new file mode 100644 index 00000000..5095d9c6 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/i8rdivma.c @@ -0,0 +1,129 @@ +/* + * 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 <stdlib.h> +#include <string.h> +#include "matrixDivision.h" +#include "lapack.h" + +void i8rdivma ( int8 * in1, int lines1, int columns1, + int8 * in2, int lines2, int columns2, + int8 * out){ + + char cNorm = 0; + int iExit = 0; + + /*temporary variables*/ + int iWork = 0; + int iInfo = 0; + int iMax = 0; + int8 dblRcond = 0; + + int8 dblEps = 0; + int8 dblAnorm = 0; + + int8 *pAf = NULL; + int8 *pAt = NULL; + int8 *pBt = NULL; + int8 *pDwork = NULL; + + int *pRank = NULL; + int *pIpiv = NULL; + int *pJpvt = NULL; + int *pIwork = NULL; + + iWork = max(4 * columns2, max(min(lines2, columns2) + 3 * lines2 + 1, 2 * min(lines2, columns2) + lines1)); + + + /* Array allocations*/ + pAf = (int8*)malloc(sizeof(int8) * (unsigned int)columns2 * (unsigned int)lines2); + pAt = (int8*)malloc(sizeof(int8) * (unsigned int)columns2 *(unsigned int) lines2); + pBt = (int8*)malloc(sizeof(int8) * (unsigned int)max(lines2,columns2) * (unsigned int)lines1); + + pRank = (int*)malloc(sizeof(int)); + pIpiv = (int*)malloc(sizeof(int) * (unsigned int)columns2); + pJpvt = (int*)malloc(sizeof(int) * (unsigned int)lines2); + pIwork = (int*)malloc(sizeof(int) * (unsigned int)columns2); + + + cNorm = '1'; + pDwork = (int8*)malloc(sizeof(int8) * (unsigned int)iWork); + dblEps = getRelativeMachinePrecision() ; + dblAnorm = dlange_(&cNorm, &lines2, &columns1, in2, &lines2, pDwork); + + /*tranpose A and B*/ + + dtransposea(in2, lines2, columns2, pAt); + dtransposea(in1, lines1, columns2, pBt); + + if(lines2 == columns2) + { + cNorm = 'F'; + dlacpy_(&cNorm, &columns2, &columns2, pAt, &columns2, pAf, &columns2); + dgetrf_(&columns2, &columns2, pAf, &columns2, pIpiv, &iInfo); + if(iInfo == 0) + { + cNorm = '1'; + dgecon_(&cNorm, &columns2, pAf, &columns2, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo); + if(dblRcond > sqrt(dblEps)) + { + cNorm = 'N'; + dgetrs_(&cNorm, &columns2, &lines1, pAf, &columns2, pIpiv, pBt, &columns2, &iInfo); + dtransposea(pBt, columns2, lines1, out); + iExit = 1; + } + } + + } + + if(iExit == 0) + { + dblRcond = sqrt(dblEps); + cNorm = 'F'; + iMax = max(lines2, columns2); + memset(pJpvt, 0x00, (unsigned int)sizeof(int) * (unsigned int)lines2); + dgelsy_(&columns2, &lines2, &lines1, pAt, &columns2, pBt, &iMax, + pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo); + + if(iInfo == 0) + { + + + /* TransposeRealMatrix(pBt, lines1, lines2, out, Max(lines1,columns1), lines2);*/ + + /*Mega caca de la mort qui tue des ours a mains nues + mais je ne sais pas comment le rendre "beau" :(*/ + { + int i,j,ij,ji; + for(j = 0 ; j < lines2 ; j++) + { + for(i = 0 ; i < lines1 ; i++) + { + ij = i + j * lines1; + ji = j + i * max(lines2, columns2); + out[ij] = pBt[ji]; + } + } + } + } + } + + free(pAf); + free(pAt); + free(pBt); + free(pRank); + free(pIpiv); + free(pJpvt); + free(pIwork); + free(pDwork); + +} + diff --git a/2.3-1/src/c/matrixOperations/division/i8rdivv.c b/2.3-1/src/c/matrixOperations/division/i8rdivv.c new file mode 100644 index 00000000..04c6c49e --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/i8rdivv.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" + +int8 i8rdivv(int8 *in1, int8 *in2, int size){ + + int8 out[1] = { 0.0} ; + i8rdivma ( in1,1 ,size ,in2 , 1 , size , out ); + + return out[0] ; +} + + diff --git a/2.3-1/src/c/matrixOperations/division/u16ldivma.c b/2.3-1/src/c/matrixOperations/division/u16ldivma.c new file mode 100644 index 00000000..fde268fe --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/u16ldivma.c @@ -0,0 +1,111 @@ +/* + * 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 <stdlib.h> +#include <string.h> +#include "matrixDivision.h" +#include "lapack.h" + +void u16ldivma (uint16* in1, int lines1, int columns1 , + uint16* in2, int lines2, int columns2 , + uint16* out ){ + + + char cNorm = 0; + int iExit = 0; + + /*temporary variables*/ + int iWork = 0; + int iInfo = 0; + int iMax = 0; + uint16 dblRcond = 0; + + uint16 dblEps = 0; + uint16 dblAnorm = 0; + + uint16 *pAf = NULL; + uint16 *pXb = NULL; + uint16 *pDwork = NULL; + + int *pRank = NULL; + int *pIpiv = NULL; + int *pJpvt = NULL; + int *pIwork = NULL; + + iWork = max(4 * columns1, max(min(lines1, columns1) + 3 * lines1 + 1, 2 * min(lines1, columns1) + columns2)); + + + lines2 = 0 ; + + /* Array allocations*/ + pAf = (uint16*)malloc(sizeof(uint16) * (unsigned int) lines1 * (unsigned int) columns1); + pXb = (uint16*)malloc(sizeof(uint16) * (unsigned int) max(lines1,columns1) * (unsigned int) columns2); + + pRank = (int*)malloc(sizeof(int)); + pIpiv = (int*)malloc(sizeof(int) *(unsigned int) columns1); + pJpvt = (int*)malloc(sizeof(int) *(unsigned int) columns1); + pIwork = (int*)malloc(sizeof(int) *(unsigned int) columns1); + + + + cNorm = '1'; + pDwork = (uint16*)malloc(sizeof(uint16) *(unsigned int)iWork); + dblEps = getRelativeMachinePrecision() ; + + dblAnorm = dlange_(&cNorm, &lines1, &columns1, in1, &lines1, pDwork); + if(lines1 == columns1) + { + cNorm = 'F'; + dlacpy_(&cNorm, &columns1, &columns1, in1, &columns1, pAf, &columns1); + dgetrf_(&columns1, &columns1, pAf, &columns1, pIpiv, &iInfo); + if(iInfo == 0) + { + cNorm = '1'; + C2F(dgecon)(&cNorm, &columns1, pAf, &columns1, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo); + if(dblRcond > sqrt(dblEps)) + { + cNorm = 'N'; + C2F(dgetrs)(&cNorm, &columns1, &columns2, pAf, &columns1, pIpiv, in2, &columns1, &iInfo); + cNorm = 'F'; + C2F(dlacpy)(&cNorm, &columns1, &columns2, in2, &columns1, out, &columns1); + iExit = 1; + } + } + + } + + if(iExit == 0) + { + dblRcond = sqrt(dblEps); + cNorm = 'F'; + iMax = max(lines1, columns1); + 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); + + if(iInfo == 0) + { + + cNorm = 'F'; + C2F(dlacpy)(&cNorm, &columns1, &columns2, pXb, &iMax, out, &columns1); + } + } + + free(pAf); + free(pXb); + free(pRank); + free(pIpiv); + free(pJpvt); + free(pIwork); + free(pDwork); +} diff --git a/2.3-1/src/c/matrixOperations/division/u16rdivma.c b/2.3-1/src/c/matrixOperations/division/u16rdivma.c new file mode 100644 index 00000000..a77db453 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/u16rdivma.c @@ -0,0 +1,129 @@ +/* + * 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 <stdlib.h> +#include <string.h> +#include "matrixDivision.h" +#include "lapack.h" + +void u16rdivma ( uint16 * in1, int lines1, int columns1, + uint16 * in2, int lines2, int columns2, + uint16 * out){ + + char cNorm = 0; + int iExit = 0; + + /*temporary variables*/ + int iWork = 0; + int iInfo = 0; + int iMax = 0; + uint16 dblRcond = 0; + + uint16 dblEps = 0; + uint16 dblAnorm = 0; + + uint16 *pAf = NULL; + uint16 *pAt = NULL; + uint16 *pBt = NULL; + uint16 *pDwork = NULL; + + int *pRank = NULL; + int *pIpiv = NULL; + int *pJpvt = NULL; + int *pIwork = NULL; + + iWork = max(4 * columns2, max(min(lines2, columns2) + 3 * lines2 + 1, 2 * min(lines2, columns2) + lines1)); + + + /* Array allocations*/ + pAf = (uint16*)malloc(sizeof(uint16) * (unsigned int)columns2 * (unsigned int)lines2); + pAt = (uint16*)malloc(sizeof(uint16) * (unsigned int)columns2 *(unsigned int) lines2); + pBt = (uint16*)malloc(sizeof(uint16) * (unsigned int)max(lines2,columns2) * (unsigned int)lines1); + + pRank = (int*)malloc(sizeof(int)); + pIpiv = (int*)malloc(sizeof(int) * (unsigned int)columns2); + pJpvt = (int*)malloc(sizeof(int) * (unsigned int)lines2); + pIwork = (int*)malloc(sizeof(int) * (unsigned int)columns2); + + + cNorm = '1'; + pDwork = (uint16*)malloc(sizeof(uint16) * (unsigned int)iWork); + dblEps = getRelativeMachinePrecision() ; + dblAnorm = dlange_(&cNorm, &lines2, &columns1, in2, &lines2, pDwork); + + /*tranpose A and B*/ + + dtransposea(in2, lines2, columns2, pAt); + dtransposea(in1, lines1, columns2, pBt); + + if(lines2 == columns2) + { + cNorm = 'F'; + dlacpy_(&cNorm, &columns2, &columns2, pAt, &columns2, pAf, &columns2); + dgetrf_(&columns2, &columns2, pAf, &columns2, pIpiv, &iInfo); + if(iInfo == 0) + { + cNorm = '1'; + dgecon_(&cNorm, &columns2, pAf, &columns2, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo); + if(dblRcond > sqrt(dblEps)) + { + cNorm = 'N'; + dgetrs_(&cNorm, &columns2, &lines1, pAf, &columns2, pIpiv, pBt, &columns2, &iInfo); + dtransposea(pBt, columns2, lines1, out); + iExit = 1; + } + } + + } + + if(iExit == 0) + { + dblRcond = sqrt(dblEps); + cNorm = 'F'; + iMax = max(lines2, columns2); + memset(pJpvt, 0x00, (unsigned int)sizeof(int) * (unsigned int)lines2); + dgelsy_(&columns2, &lines2, &lines1, pAt, &columns2, pBt, &iMax, + pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo); + + if(iInfo == 0) + { + + + /* TransposeRealMatrix(pBt, lines1, lines2, out, Max(lines1,columns1), lines2);*/ + + /*Mega caca de la mort qui tue des ours a mains nues + mais je ne sais pas comment le rendre "beau" :(*/ + { + int i,j,ij,ji; + for(j = 0 ; j < lines2 ; j++) + { + for(i = 0 ; i < lines1 ; i++) + { + ij = i + j * lines1; + ji = j + i * max(lines2, columns2); + out[ij] = pBt[ji]; + } + } + } + } + } + + free(pAf); + free(pAt); + free(pBt); + free(pRank); + free(pIpiv); + free(pJpvt); + free(pIwork); + free(pDwork); + +} + diff --git a/2.3-1/src/c/matrixOperations/division/u16rdivv.c b/2.3-1/src/c/matrixOperations/division/u16rdivv.c new file mode 100644 index 00000000..9fc292c7 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/u16rdivv.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" + +uint16 u16rdivv(uint16 *in1, uint16 *in2, int size){ + + uint16 out[1] = { 0.0} ; + u16rdivma ( in1,1 ,size ,in2 , 1 , size , out ); + + return out[0] ; +} + + diff --git a/2.3-1/src/c/matrixOperations/division/u8ldivma.c b/2.3-1/src/c/matrixOperations/division/u8ldivma.c new file mode 100644 index 00000000..a046fb41 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/u8ldivma.c @@ -0,0 +1,111 @@ +/* + * 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 <stdlib.h> +#include <string.h> +#include "matrixDivision.h" +#include "lapack.h" + +void u8ldivma (uint8* in1, int lines1, int columns1 , + uint8* in2, int lines2, int columns2 , + uint8* out ){ + + + char cNorm = 0; + int iExit = 0; + + /*temporary variables*/ + int iWork = 0; + int iInfo = 0; + int iMax = 0; + uint8 dblRcond = 0; + + uint8 dblEps = 0; + uint8 dblAnorm = 0; + + uint8 *pAf = NULL; + uint8 *pXb = NULL; + uint8 *pDwork = NULL; + + int *pRank = NULL; + int *pIpiv = NULL; + int *pJpvt = NULL; + int *pIwork = NULL; + + iWork = max(4 * columns1, max(min(lines1, columns1) + 3 * lines1 + 1, 2 * min(lines1, columns1) + columns2)); + + + lines2 = 0 ; + + /* Array allocations*/ + pAf = (uint8*)malloc(sizeof(uint8) * (unsigned int) lines1 * (unsigned int) columns1); + pXb = (uint8*)malloc(sizeof(uint8) * (unsigned int) max(lines1,columns1) * (unsigned int) columns2); + + pRank = (int*)malloc(sizeof(int)); + pIpiv = (int*)malloc(sizeof(int) *(unsigned int) columns1); + pJpvt = (int*)malloc(sizeof(int) *(unsigned int) columns1); + pIwork = (int*)malloc(sizeof(int) *(unsigned int) columns1); + + + + cNorm = '1'; + pDwork = (uint8*)malloc(sizeof(uint8) *(unsigned int)iWork); + dblEps = getRelativeMachinePrecision() ; + + dblAnorm = dlange_(&cNorm, &lines1, &columns1, in1, &lines1, pDwork); + if(lines1 == columns1) + { + cNorm = 'F'; + dlacpy_(&cNorm, &columns1, &columns1, in1, &columns1, pAf, &columns1); + dgetrf_(&columns1, &columns1, pAf, &columns1, pIpiv, &iInfo); + if(iInfo == 0) + { + cNorm = '1'; + C2F(dgecon)(&cNorm, &columns1, pAf, &columns1, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo); + if(dblRcond > sqrt(dblEps)) + { + cNorm = 'N'; + C2F(dgetrs)(&cNorm, &columns1, &columns2, pAf, &columns1, pIpiv, in2, &columns1, &iInfo); + cNorm = 'F'; + C2F(dlacpy)(&cNorm, &columns1, &columns2, in2, &columns1, out, &columns1); + iExit = 1; + } + } + + } + + if(iExit == 0) + { + dblRcond = sqrt(dblEps); + cNorm = 'F'; + iMax = max(lines1, columns1); + 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); + + if(iInfo == 0) + { + + cNorm = 'F'; + C2F(dlacpy)(&cNorm, &columns1, &columns2, pXb, &iMax, out, &columns1); + } + } + + free(pAf); + free(pXb); + free(pRank); + free(pIpiv); + free(pJpvt); + free(pIwork); + free(pDwork); +} diff --git a/2.3-1/src/c/matrixOperations/division/u8rdivma.c b/2.3-1/src/c/matrixOperations/division/u8rdivma.c new file mode 100644 index 00000000..478f6ac9 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/u8rdivma.c @@ -0,0 +1,129 @@ +/* + * 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 <stdlib.h> +#include <string.h> +#include "matrixDivision.h" +#include "lapack.h" + +void u8rdivma ( uint8 * in1, int lines1, int columns1, + uint8 * in2, int lines2, int columns2, + uint8 * out){ + + char cNorm = 0; + int iExit = 0; + + /*temporary variables*/ + int iWork = 0; + int iInfo = 0; + int iMax = 0; + uint8 dblRcond = 0; + + uint8 dblEps = 0; + uint8 dblAnorm = 0; + + uint8 *pAf = NULL; + uint8 *pAt = NULL; + uint8 *pBt = NULL; + uint8 *pDwork = NULL; + + int *pRank = NULL; + int *pIpiv = NULL; + int *pJpvt = NULL; + int *pIwork = NULL; + + iWork = max(4 * columns2, max(min(lines2, columns2) + 3 * lines2 + 1, 2 * min(lines2, columns2) + lines1)); + + + /* Array allocations*/ + pAf = (uint8*)malloc(sizeof(uint8) * (unsigned int)columns2 * (unsigned int)lines2); + pAt = (uint8*)malloc(sizeof(uint8) * (unsigned int)columns2 *(unsigned int) lines2); + pBt = (uint8*)malloc(sizeof(uint8) * (unsigned int)max(lines2,columns2) * (unsigned int)lines1); + + pRank = (int*)malloc(sizeof(int)); + pIpiv = (int*)malloc(sizeof(int) * (unsigned int)columns2); + pJpvt = (int*)malloc(sizeof(int) * (unsigned int)lines2); + pIwork = (int*)malloc(sizeof(int) * (unsigned int)columns2); + + + cNorm = '1'; + pDwork = (uint8*)malloc(sizeof(uint8) * (unsigned int)iWork); + dblEps = getRelativeMachinePrecision() ; + dblAnorm = dlange_(&cNorm, &lines2, &columns1, in2, &lines2, pDwork); + + /*tranpose A and B*/ + + dtransposea(in2, lines2, columns2, pAt); + dtransposea(in1, lines1, columns2, pBt); + + if(lines2 == columns2) + { + cNorm = 'F'; + dlacpy_(&cNorm, &columns2, &columns2, pAt, &columns2, pAf, &columns2); + dgetrf_(&columns2, &columns2, pAf, &columns2, pIpiv, &iInfo); + if(iInfo == 0) + { + cNorm = '1'; + dgecon_(&cNorm, &columns2, pAf, &columns2, &dblAnorm, &dblRcond, pDwork, pIwork, &iInfo); + if(dblRcond > sqrt(dblEps)) + { + cNorm = 'N'; + dgetrs_(&cNorm, &columns2, &lines1, pAf, &columns2, pIpiv, pBt, &columns2, &iInfo); + dtransposea(pBt, columns2, lines1, out); + iExit = 1; + } + } + + } + + if(iExit == 0) + { + dblRcond = sqrt(dblEps); + cNorm = 'F'; + iMax = max(lines2, columns2); + memset(pJpvt, 0x00, (unsigned int)sizeof(int) * (unsigned int)lines2); + dgelsy_(&columns2, &lines2, &lines1, pAt, &columns2, pBt, &iMax, + pJpvt, &dblRcond, &pRank[0], pDwork, &iWork, &iInfo); + + if(iInfo == 0) + { + + + /* TransposeRealMatrix(pBt, lines1, lines2, out, Max(lines1,columns1), lines2);*/ + + /*Mega caca de la mort qui tue des ours a mains nues + mais je ne sais pas comment le rendre "beau" :(*/ + { + int i,j,ij,ji; + for(j = 0 ; j < lines2 ; j++) + { + for(i = 0 ; i < lines1 ; i++) + { + ij = i + j * lines1; + ji = j + i * max(lines2, columns2); + out[ij] = pBt[ji]; + } + } + } + } + } + + free(pAf); + free(pAt); + free(pBt); + free(pRank); + free(pIpiv); + free(pJpvt); + free(pIwork); + free(pDwork); + +} + diff --git a/2.3-1/src/c/matrixOperations/division/u8rdivv.c b/2.3-1/src/c/matrixOperations/division/u8rdivv.c new file mode 100644 index 00000000..53ef809d --- /dev/null +++ b/2.3-1/src/c/matrixOperations/division/u8rdivv.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" + +uint8 u8rdivv(uint8 *in1, uint8 *in2, int size){ + + uint8 out[1] = { 0.0} ; + u8rdivma ( in1,1 ,size ,in2 , 1 , size , out ); + + return out[0] ; +} + + diff --git a/2.3-1/src/c/matrixOperations/includes/diag.h b/2.3-1/src/c/matrixOperations/includes/diag.h new file mode 100644 index 00000000..24c167af --- /dev/null +++ b/2.3-1/src/c/matrixOperations/includes/diag.h @@ -0,0 +1,96 @@ +/* + * 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 + * + */ + +#ifndef __DIAG_H__ +#define __DIAG_H__ + +#include "dynlib_matrixoperations.h" +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +EXTERN_MATOPS double ddiags(double in ); + +EXTERN_MATOPS void ddiaga(double in, int size,int insert_post,double *out); + +EXTERN_MATOPS void ddiagina(double *in, int _row,int _column,int insert_post,double *out); + +EXTERN_MATOPS void ddiagins(double* in, int size, double* out ); + +EXTERN_MATOPS void ddiagexa(double* in,int row,int column,int insert_pos,double* out); + +EXTERN_MATOPS double ddiagexs(double* in,int row,int column,int extract_pos); + +EXTERN_MATOPS uint8 u8diags(uint8 in ); + +EXTERN_MATOPS void u8diaga(uint8 in, int size,int insert_post,uint8 *out); + +EXTERN_MATOPS void u8diagina(uint8 *in, int _row,int _column,int insert_post,uint8 *out); + +EXTERN_MATOPS void u8diagins(uint8* in, int size, uint8* out ); + +EXTERN_MATOPS void u8diagexa(uint8* in,int row,int column,int insert_pos,uint8* out); + +EXTERN_MATOPS uint8 u8diagexs(uint8* in,int row,int column,int extract_pos); + +EXTERN_MATOPS uint16 u16diags(uint16 in ); + +EXTERN_MATOPS void u16diaga(uint16 in, int size,int insert_post,uint16 *out); + +EXTERN_MATOPS void u16diagina(uint16 *in, int _row,int _column,int insert_post,uint16 *out); + +EXTERN_MATOPS void u16diagins(uint16* in, int size, uint16* out ); + +EXTERN_MATOPS void u16diagexa(uint16* in,int row,int column,int insert_pos,uint16* out); + +EXTERN_MATOPS uint16 u16diagexs(uint16* in,int row,int column,int extract_pos); + +EXTERN_MATOPS int8 i8diags(int8 in ); + +EXTERN_MATOPS void i8diaga(int8 in, int size,int insert_post,int8 *out); + +EXTERN_MATOPS void i8diagina(int8 *in, int _row,int _column,int insert_post,int8 *out); + +EXTERN_MATOPS void i8diagins(int8* in, int size, int8* out ); + +EXTERN_MATOPS void i8diagexa(int8* in,int row,int column,int insert_pos,int8* out); + +EXTERN_MATOPS int8 i8diagexs(int8* in,int row,int column,int extract_pos); + +EXTERN_MATOPS int16 i16diags(int16 in ); + +EXTERN_MATOPS void i16diaga(int16 in, int size,int insert_post,int16 *out); + +EXTERN_MATOPS void i16diagina(int16 *in, int _row,int _column,int insert_post,int16 *out); + +EXTERN_MATOPS void i16diagins(int16* in, int size, int16* out ); + +EXTERN_MATOPS void i16diagexa(int16* in,int row,int column,int insert_pos,int16* out); + +EXTERN_MATOPS int16 i16diagexs(int16* in,int row,int column,int extract_pos); + + + + + + + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* !__DIAG_H__ */ + diff --git a/2.3-1/src/c/matrixOperations/interfaces/int_diag.h b/2.3-1/src/c/matrixOperations/interfaces/int_diag.h new file mode 100644 index 00000000..4d6553c5 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/interfaces/int_diag.h @@ -0,0 +1,87 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * + * 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 + * + */ + +/* THIS IS AN AUTOMATICALLY GENERATED FILE : DO NOT EDIT BY HAND. */ + +#ifndef __INT_DIAG_H__ +#define __INT_DIAG_H__ + + + +#define d0diagd0(in1) ddiags(in1) + +#define d0d0diagd0(in1,in2) ddiags(in1) + +#define d0d0diagd2(in1,in2,out) ddiaga(in1,1,in2,out) + +#define d2diagd2(in1,size,out) if(size[0] != size[1]) { (size[0]==1) ? ddiagins(in1,size[1],out) : ddiagins(in1,size[0],out); } else {ddiagexa(in1,size[0],size[1],0,out) ;} + +#define d2d0diagd2(in1,size,in2,out) if((size[0] != 1) && (size[1] != 1) ) { ddiagexa(in1,size[0],size[1],in2,out); } else { if(in2 != 0) {ddiagina(in1,size[0],size[1],in2,out);} else { (size[0] == 1) ? ddiagins(in1,size[1],out) : ddiagins(in1,size[0],out); };} + +#define d2d0diagd0(in1,size,in2) ddiagexs(in1,size[0],size[1],in2) + + + +#define u80diagu80(in1) u8diags(in1) + +#define u80d0diagu80(in1,in2) u8diags(in1) + +#define u80d0diagu82(in1,in2,out) u8diaga(in1,1,in2,out) + +#define u82diagu82(in1,size,out) if(size[0] != size[1]) { (size[0]==1) ? u8diagins(in1,size[1],out) : u8diagins(in1,size[0],out); } else {u8diagexa(in1,size[0],size[1],0,out) ;} + +#define u82d0diagu82(in1,size,in2,out) if((size[0] != 1) && (size[1] != 1) ) { u8diagexa(in1,size[0],size[1],in2,out); } else { if(in2 != 0) {u8diagina(in1,size[0],size[1],in2,out);} else { (size[0] == 1) ? u8diagins(in1,size[1],out) : u8diagins(in1,size[0],out); };} + +#define u82d0diagu80(in1,size,in2) u8diagexs(in1,size[0],size[1],in2) + +#define u160diagu160(in1) u16diags(in1) + +#define u160d0diagu160(in1,in2) u16diags(in1) + +#define u160d0diagu162(in1,in2,out) u16diaga(in1,1,in2,out) + +#define u162diagu162(in1,size,out) if(size[0] != size[1]) { (size[0]==1) ? u16diagins(in1,size[1],out) : u16diagins(in1,size[0],out); } else {u16diagexa(in1,size[0],size[1],0,out) ;} + +#define u162d0diagu162(in1,size,in2,out) if((size[0] != 1) && (size[1] != 1) ) { u16diagexa(in1,size[0],size[1],in2,out); } else { if(in2 != 0) {u16diagina(in1,size[0],size[1],in2,out);} else { (size[0] == 1) ? u16diagins(in1,size[1],out) : u16diagins(in1,size[0],out); };} + +#define u162d0diagu160(in1,size,in2) u16diagexs(in1,size[0],size[1],in2) + + + +#define i80diagi80(in1) i8diags(in1) + +#define i80d0diagi80(in1,in2) i8diags(in1) + +#define i80d0diagi82(in1,in2,out) i8diaga(in1,1,in2,out) + +#define i82diagi82(in1,size,out) if(size[0] != size[1]) { (size[0]==1) ? i8diagins(in1,size[1],out) : i8diagins(in1,size[0],out); } else {i8diagexa(in1,size[0],size[1],0,out) ;} + +#define i82d0diagi82(in1,size,in2,out) if((size[0] != 1) && (size[1] != 1) ) { i8diagexa(in1,size[0],size[1],in2,out); } else { if(in2 != 0) {i8diagina(in1,size[0],size[1],in2,out);} else { (size[0] == 1) ? i8diagins(in1,size[1],out) : i8diagins(in1,size[0],out); };} + +#define i82d0diagi80(in1,size,in2) i8diagexs(in1,size[0],size[1],in2) + +#define i160diagi160(in1) i16diags(in1) + +#define i160d0diagi160(in1,in2) i16diags(in1) + +#define i160d0diagi162(in1,in2,out) i16diaga(in1,1,in2,out) + + +#define i162diagi162(in1,size,out) if(size[0] != size[1]) { (size[0]==1) ? i16diagins(in1,size[1],out) : i16diagins(in1,size[0],out); } else {i16diagexa(in1,size[0],size[1],0,out) ;} + +#define i162d0diagi162(in1,size,in2,out) if((size[0] != 1) && (size[1] != 1) ) { i16diagexa(in1,size[0],size[1],in2,out); } else { if(in2 != 0) {i16diagina(in1,size[0],size[1],in2,out);} else { (size[0] == 1) ? i16diagins(in1,size[1],out) : i16diagins(in1,size[0],out); };} + +#define i162d0diagi160(in1,size,in2) i16diagexs(in1,size[0],size[1],in2) + + + +#endif /* !__INT_DIAG_H__ */ diff --git a/2.3-1/src/c/operations/interfaces/int_OpLogOr.h b/2.3-1/src/c/operations/interfaces/int_OpLogOr.h index 5618ff63..c7acb51d 100644 --- a/2.3-1/src/c/operations/interfaces/int_OpLogOr.h +++ b/2.3-1/src/c/operations/interfaces/int_OpLogOr.h @@ -95,28 +95,28 @@ /*scalar or matrix */ #define s0s2OpLogOrs2(in1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float(in1 != 0.2f || in2[i] != 0.2f);} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float(in1 != 0.0 || in2[i] != 0.0);} #define d0d2OpLogOrd2(in1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double(in1 != 0.2 || in2[i] != 0.2);} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double(in1 != 0.0 || in2[i] != 0.0);} #define c0c2OpLogOrs2(in1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float((creals(in1) != 0.2f || cimags(in1) != 0.2f) || (creals(in2[i]) != 0.2f || cimags(in2[i])));} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float((creals(in1) != 0.0 || cimags(in1) != 0.0) || (creals(in2[i]) != 0.0 || cimags(in2[i])));} #define s0c2OpLogOrs2(in1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float(in1 != 0.2f && (creals(in2[i]) != 0.2f || cimags(in2[i])));} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float(in1 != 0.0 && (creals(in2[i]) != 0.0 || cimags(in2[i])));} #define c0s2OpLogOrs2(in1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float((creals(in1) != 0.2f || cimags(in1) != 0.2f) && in2[i] != 0.2f);} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float((creals(in1) != 0.0 || cimags(in1) != 0.0) && in2[i] != 0.0);} #define z0z2OpLogOrd2(in1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double((zreals(in1) != 0.2 || zimags(in1) != 0.2) && (zreals(in2[i]) != 0.2 || zimags(in2[i])));} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double((zreals(in1) != 0.0 || zimags(in1) != 0.0) && (zreals(in2[i]) != 0.0 || zimags(in2[i])));} #define d0z2OpLogOrd2(in1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double(in1 != 0.2 && (zreals(in2[i]) != 0.2 || zimags(in2[i])));} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double(in1 != 0.0 && (zreals(in2[i]) != 0.0 || zimags(in2[i])));} #define z0d2OpLogOrd2(in1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double((zreals(in1) != 0.2 || zimags(in1) != 0.2) && in2[i] != 0.2);} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double((zreals(in1) != 0.0 || zimags(in1) != 0.0) && in2[i] != 0.0);} #define u80u82OpLogOru82(in1, in2, size2, out) {int i = 0 ;\ for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Uint8(in1 != 0 || in2[i] != 0);} @@ -133,28 +133,28 @@ /*matrix or matrix */ #define s2s2OpLogOrs2(in1, size1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float(in1[i] != 0.2f || in2[i] != 0.2f);} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float(in1[i] != 0.0 || in2[i] != 0.0);} #define d2d2OpLogOrd2(in1, size1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double(in1[i] != 0.2 || in2[i] != 0.2);} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double(in1[i] != 0.0 || in2[i] != 0.0);} #define c2c2OpLogOrs2(in1, size1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float((creals(in1[i]) != 0.2f || cimags(in1[i]) != 0.2f) || (creals(in2[i]) != 0.2f || cimags(in2[i])));} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float((creals(in1[i]) != 0.0 || cimags(in1[i]) != 0.0) || (creals(in2[i]) != 0.0 || cimags(in2[i])));} #define s2c2OpLogOrs2(in1, size1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float(in1[i] != 0.2f && (creals(in2[i]) != 0.2f || cimags(in2[i])));} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float(in1[i] != 0.0 && (creals(in2[i]) != 0.0 || cimags(in2[i])));} #define c2s2OpLogOrs2(in1, size1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float((creals(in1[i]) != 0.2f || cimags(in1[i]) != 0.2f) && in2[i] != 0.2f);} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Float((creals(in1[i]) != 0.0 || cimags(in1[i]) != 0.0) && in2[i] != 0.0);} #define z2z2OpLogOrd2(in1, size1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double((zreals(in1[i]) != 0.2 || zimags(in1[i]) != 0.2) && (zreals(in2[i]) != 0.2 || zimags(in2[i])));} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double((zreals(in1[i]) != 0.0 || zimags(in1[i]) != 0.0) && (zreals(in2[i]) != 0.0 || zimags(in2[i])));} #define d2z2OpLogOrd2(in1, size1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double(in1[i] != 0.2 && (zreals(in2[i]) != 0.2 || zimags(in2[i])));} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double(in1[i] != 0.0 && (zreals(in2[i]) != 0.0 || zimags(in2[i])));} #define z2d2OpLogOrd2(in1, size1, in2, size2, out) {int i = 0 ;\ - for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double((zreals(in1[i]) != 0.2 || zimags(in1[i]) != 0.2) && in2[i] != 0.2);} + for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Double((zreals(in1[i]) != 0.0 || zimags(in1[i]) != 0.0) && in2[i] != 0.0);} #define u82u82OpLogOru82(in1, size1, in2, size2, out) {int i = 0 ;\ for (i = 0 ; i < size2[0]*size2[1] ; i++ ) out[i] = Bool2Uint8(in1[i] != 0 || in2[i] != 0);} diff --git a/2.3-1/src/c/scilab-arduino/cmd_analog_in/u8cmd_analog_ins.c b/2.3-1/src/c/scilab-arduino/cmd_analog_in/u8cmd_analog_ins.c index ebfad618..29e6c0f7 100644 --- a/2.3-1/src/c/scilab-arduino/cmd_analog_in/u8cmd_analog_ins.c +++ b/2.3-1/src/c/scilab-arduino/cmd_analog_in/u8cmd_analog_ins.c @@ -11,6 +11,7 @@ */ #include "cmd_analog_in.h" +#include "Arduino.h" uint16 u8cmd_analog_ins(uint8 board_no, uint8 pin) { diff --git a/2.3-1/src/c/scilab-arduino/cmd_analog_out/u8cmd_analog_outs.c b/2.3-1/src/c/scilab-arduino/cmd_analog_out/u8cmd_analog_outs.c index 94d51f6f..aa7dac06 100644 --- a/2.3-1/src/c/scilab-arduino/cmd_analog_out/u8cmd_analog_outs.c +++ b/2.3-1/src/c/scilab-arduino/cmd_analog_out/u8cmd_analog_outs.c @@ -11,6 +11,7 @@ */ #include "cmd_analog_out.h" +#include "Arduino.h" uint8 u8cmd_analog_outs(uint8 board_no, uint8 pin, uint8 value) { diff --git a/2.3-1/src/c/scilab-arduino/cmd_dcmotor_run/u8cmd_dcmotor_runs.c b/2.3-1/src/c/scilab-arduino/cmd_dcmotor_run/u8cmd_dcmotor_runs.c index 93905c94..07798aba 100644 --- a/2.3-1/src/c/scilab-arduino/cmd_dcmotor_run/u8cmd_dcmotor_runs.c +++ b/2.3-1/src/c/scilab-arduino/cmd_dcmotor_run/u8cmd_dcmotor_runs.c @@ -11,6 +11,7 @@ */ #include "cmd_dcmotor_run.h" +#include "Arduino.h" uint8 u8cmd_dcmotor_runs(uint8 board_no, uint8 motor_no, int16 duty) { diff --git a/2.3-1/src/c/scilab-arduino/cmd_dcmotor_setup/u8cmd_dcmotor_setups.c b/2.3-1/src/c/scilab-arduino/cmd_dcmotor_setup/u8cmd_dcmotor_setups.c index 30b4b9b3..d1d0fea8 100644 --- a/2.3-1/src/c/scilab-arduino/cmd_dcmotor_setup/u8cmd_dcmotor_setups.c +++ b/2.3-1/src/c/scilab-arduino/cmd_dcmotor_setup/u8cmd_dcmotor_setups.c @@ -11,6 +11,7 @@ */ #include "cmd_dcmotor_setup.h" +#include "Arduino.h" uint8 dcm_pin_1[4], dcm_pin_2[4], dcm_mode[4]; @@ -18,7 +19,7 @@ uint8 u8cmd_dcmotor_setups(uint8 board_no, uint8 driver_type, uint8 motor_no,\ uint8 pin_1, uint8 pin_2) { dcm_pin_1[motor_no] = pin_1; - dcm_pin_2[motor_no] = pin_2; + dcm_pin_2[motor_no] = pin_2; dcm_mode[motor_no] = driver_type; //Initialise pins diff --git a/2.3-1/src/c/scilab-arduino/cmd_digital_in/u8cmd_digital_ins.c b/2.3-1/src/c/scilab-arduino/cmd_digital_in/u8cmd_digital_ins.c index 1d0036a4..129db1a9 100644 --- a/2.3-1/src/c/scilab-arduino/cmd_digital_in/u8cmd_digital_ins.c +++ b/2.3-1/src/c/scilab-arduino/cmd_digital_in/u8cmd_digital_ins.c @@ -11,6 +11,7 @@ */ #include "cmd_digital_in.h" +#include "Arduino.h" uint8 u8cmd_digital_ins(uint8 board_no, uint8 pin) { diff --git a/2.3-1/src/c/scilab-arduino/cmd_servo_attach/u8cmd_servo_attach.cpp b/2.3-1/src/c/scilab-arduino/cmd_servo_attach/u8cmd_servo_attach.cpp new file mode 100644 index 00000000..a89363ba --- /dev/null +++ b/2.3-1/src/c/scilab-arduino/cmd_servo_attach/u8cmd_servo_attach.cpp @@ -0,0 +1,26 @@ +/* + Scilab2C FOSSEE IIT BOMBAY + */ + +#include "cmd_servo_attach.h" +#include "Arduino.h" +#include<Servo.h> +Servo servo1,servo2; +uint8 u8cmd_servo_attach(uint8 h,uint8 servo_no) +{ + // h -> Board no. reserve for future use + // servo_no -> pin no.(9 and 10). + if(servo_no == 1) + { + servo1.attach(9); + servo1.write(0); + } + else + { + servo2.attach(10); + servo2.write(0); + } + + return 0; +} + diff --git a/2.3-1/src/c/scilab-arduino/cmd_servo_detach/u8cmd_servo_detach.cpp b/2.3-1/src/c/scilab-arduino/cmd_servo_detach/u8cmd_servo_detach.cpp new file mode 100644 index 00000000..95faf4cd --- /dev/null +++ b/2.3-1/src/c/scilab-arduino/cmd_servo_detach/u8cmd_servo_detach.cpp @@ -0,0 +1,24 @@ +/* + Scilab2C FOSSEE IIT BOMBAY + */ +#include "cmd_servo_detach.h" +#include "Arduino.h" +#include<Servo.h> +Servo servo1,servo2; +uint8 u8cmd_servo_detach(uint8 h,uint8 servo_no) +{ + // h -> Board no. reserve for future use + // servo_no -> pin no.(9 and 10). + if(servo_no == 1) + { + servo1.detach(); + } + + else + { + servo2.detach(); + } + + return 0; +} + diff --git a/2.3-1/src/c/scilab-arduino/cmd_servo_move/u8cmd_servo_move.cpp b/2.3-1/src/c/scilab-arduino/cmd_servo_move/u8cmd_servo_move.cpp new file mode 100644 index 00000000..e8874766 --- /dev/null +++ b/2.3-1/src/c/scilab-arduino/cmd_servo_move/u8cmd_servo_move.cpp @@ -0,0 +1,27 @@ +/* + Scilab2C FOSSEE IIT BOMBAY + */ + +#include "cmd_servo_move.h" +#include "Arduino.h" +#include<Servo.h> +Servo servo1,servo2; +uint8 u8cmd_servo_move(uint8 h,uint8 servo_no,uint8 val) +{ + // h -> Board no. reserve for future use + // servo_no -> pin no.(9 and 10). + //val -> 0 to 180 angle of rotation + if (val>=0 && val<=180) + { + if (servo_no==1) + { + servo1.write(val); + } + else if (servo_no==2) + { + servo2.write(val); + } + } + return 0; +} + diff --git a/2.3-1/src/c/scilab-arduino/includes/cmd_analog_in.h b/2.3-1/src/c/scilab-arduino/includes/cmd_analog_in.h index 4478fb09..5361fe80 100644 --- a/2.3-1/src/c/scilab-arduino/includes/cmd_analog_in.h +++ b/2.3-1/src/c/scilab-arduino/includes/cmd_analog_in.h @@ -15,7 +15,6 @@ #define __CMD_ANALOG_IN_H__ #include "types.h" -#include "Arduino.h" #ifdef __cplusplus extern "C" { diff --git a/2.3-1/src/c/scilab-arduino/includes/cmd_analog_out.h b/2.3-1/src/c/scilab-arduino/includes/cmd_analog_out.h index e75c5a66..a0da68e1 100644 --- a/2.3-1/src/c/scilab-arduino/includes/cmd_analog_out.h +++ b/2.3-1/src/c/scilab-arduino/includes/cmd_analog_out.h @@ -15,8 +15,6 @@ #define __CMD_ANALOG_OUT_H__ #include "types.h" -#include "Arduino.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/2.3-1/src/c/scilab-arduino/includes/cmd_dcmotor_run.h b/2.3-1/src/c/scilab-arduino/includes/cmd_dcmotor_run.h index 7631761b..82df60ad 100644 --- a/2.3-1/src/c/scilab-arduino/includes/cmd_dcmotor_run.h +++ b/2.3-1/src/c/scilab-arduino/includes/cmd_dcmotor_run.h @@ -15,7 +15,6 @@ #define __CMD_DCMOTOR_RUN_H__ #include "types.h" -#include "Arduino.h" #ifdef __cplusplus extern "C" { diff --git a/2.3-1/src/c/scilab-arduino/includes/cmd_dcmotor_setup.h b/2.3-1/src/c/scilab-arduino/includes/cmd_dcmotor_setup.h index 94f5a161..66fa04e9 100644 --- a/2.3-1/src/c/scilab-arduino/includes/cmd_dcmotor_setup.h +++ b/2.3-1/src/c/scilab-arduino/includes/cmd_dcmotor_setup.h @@ -15,7 +15,6 @@ #define __CMD_DCMOTOR_SETUP_H__ #include "types.h" -#include "Arduino.h" #ifdef __cplusplus extern "C" { diff --git a/2.3-1/src/c/scilab-arduino/includes/cmd_digital_in.h b/2.3-1/src/c/scilab-arduino/includes/cmd_digital_in.h index 9e809aa4..96fd24bb 100644 --- a/2.3-1/src/c/scilab-arduino/includes/cmd_digital_in.h +++ b/2.3-1/src/c/scilab-arduino/includes/cmd_digital_in.h @@ -15,7 +15,6 @@ #define __CMD_DIGITAL_IN_H__ #include "types.h" -#include "Arduino.h" #ifdef __cplusplus extern "C" { diff --git a/2.3-1/src/c/scilab-arduino/includes/cmd_digital_out.h b/2.3-1/src/c/scilab-arduino/includes/cmd_digital_out.h index 49739b0c..ee459d18 100644 --- a/2.3-1/src/c/scilab-arduino/includes/cmd_digital_out.h +++ b/2.3-1/src/c/scilab-arduino/includes/cmd_digital_out.h @@ -15,7 +15,6 @@ #define __CMD_DIGITAL_OUT_H__ #include "types.h" -#include "Arduino.h" #ifdef __cplusplus extern "C" { diff --git a/2.3-1/src/c/scilab-arduino/includes/cmd_servo_attach.h b/2.3-1/src/c/scilab-arduino/includes/cmd_servo_attach.h new file mode 100644 index 00000000..5dd3ed6b --- /dev/null +++ b/2.3-1/src/c/scilab-arduino/includes/cmd_servo_attach.h @@ -0,0 +1,23 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + + +#ifndef __CMD_SERVO_ATTACH_H__ +#define __CMD_SERVO_ATTACH_H__ + +#include "types.h" +//#include <Servo.h> +#ifdef __cplusplus +extern "C" { +#endif + +extern Servo servo1,servo2; + +uint8 u8cmd_servo_attach(uint8 h, uint8 servo_no ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __CMD_DCMOTOR_SETUP_H__ */ diff --git a/2.3-1/src/c/scilab-arduino/includes/cmd_servo_detach.h b/2.3-1/src/c/scilab-arduino/includes/cmd_servo_detach.h new file mode 100644 index 00000000..ce74d62d --- /dev/null +++ b/2.3-1/src/c/scilab-arduino/includes/cmd_servo_detach.h @@ -0,0 +1,24 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + + +#ifndef __CMD_SERVO_DETACH_H__ +#define __CMD_SERVO_DETACH_H__ + +#include "types.h" +//#include<Servo.h> + +#ifdef __cplusplus +extern "C" { +#endif + +extern Servo servo1,servo2; + +uint8 u8cmd_servo_detach(uint8 h, uint8 servo_no ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __CMD_DCMOTOR_SETUP_H__ */ diff --git a/2.3-1/src/c/scilab-arduino/includes/cmd_servo_move.h b/2.3-1/src/c/scilab-arduino/includes/cmd_servo_move.h new file mode 100644 index 00000000..9013d3cc --- /dev/null +++ b/2.3-1/src/c/scilab-arduino/includes/cmd_servo_move.h @@ -0,0 +1,24 @@ +/* + Scilab2C FOSSEE IIT Bombay + */ + + +#ifndef __CMD_SERVO_MOVE_H__ +#define __CMD_SERVO_MOVE_H__ + +#include "types.h" +//#include<Servo.h> + +#ifdef __cplusplus +extern "C" { +#endif + +extern Servo servo1,servo2; + +uint8 u8cmd_servo_move(uint8 h, uint8 servo_no,uint8 val); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __CMD_DCMOTOR_SETUP_H__ */ diff --git a/2.3-1/src/c/scilab-arduino/includes/sleep.h b/2.3-1/src/c/scilab-arduino/includes/sleep.h index cde27164..4c8cbc29 100644 --- a/2.3-1/src/c/scilab-arduino/includes/sleep.h +++ b/2.3-1/src/c/scilab-arduino/includes/sleep.h @@ -15,8 +15,6 @@ #define __SLEEP_H__ #include "types.h" -#include "Arduino.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/2.3-1/src/c/scilab-arduino/interfaces/int_cmd_analog_out.h b/2.3-1/src/c/scilab-arduino/interfaces/int_cmd_analog_out.h index 09f5c6ea..ead26acd 100644 --- a/2.3-1/src/c/scilab-arduino/interfaces/int_cmd_analog_out.h +++ b/2.3-1/src/c/scilab-arduino/interfaces/int_cmd_analog_out.h @@ -23,6 +23,9 @@ extern "C" { #define d0d0d0cmd_analog_outu80(in1,in2,in3) u8cmd_analog_outs((uint8)in1,\ (uint8)in2,(uint8)in3) +#define d0d0u80cmd_analog_outu80(in1,in2,in3) u8cmd_analog_outs((uint8)in1,\ + (uint8)in2,(uint8)in3) + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/2.3-1/src/c/scilab-arduino/interfaces/int_cmd_servo.h b/2.3-1/src/c/scilab-arduino/interfaces/int_cmd_servo.h new file mode 100644 index 00000000..d99a0444 --- /dev/null +++ b/2.3-1/src/c/scilab-arduino/interfaces/int_cmd_servo.h @@ -0,0 +1,27 @@ +/* + Scilab2C FOSSEE IIT BOMBAY + */ + + +#ifndef __INT_CMD_SERVO_H__ +#define __INT_CMD_SERVO_H__ + +#include "types.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#define d0d0cmd_servo_attachu80(in1,in2) u8cmd_servo_attach((uint8)in1,(uint8)in2); + +#define d0d0cmd_servo_detachu80(in1,in2) u8cmd_servo_detach((uint8)in1,(uint8)in2); + +#define d0d0d0cmd_servo_moveu80(in1,in2,in3) u8cmd_servo_move((uint8)in1,(uint8)in2,(uint8)in3); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* __INT_CMD_DCMOTOR_H__ */ diff --git a/2.3-1/src/c/string/interfaces/int_string.h b/2.3-1/src/c/string/interfaces/int_string.h index e90f1f98..7cea7799 100644 --- a/2.3-1/src/c/string/interfaces/int_string.h +++ b/2.3-1/src/c/string/interfaces/int_string.h @@ -17,36 +17,36 @@ #include <stdio.h> -#define s0string(in,out) sstrings(in,out) +#define s0stringg0(in,out) sstrings(in,out) -#define d0string(in,out) dstrings(in,out) +#define d0stringg0(in,out) dstrings(in,out) -#define c0string(in,out) cstrings(in,out) +#define c0stringg0(in,out) cstrings(in,out) -#define z0string(in,out) zstrings(in,out) +#define z0stringg0(in,out) zstrings(in,out) -#define u80string(in,out) u8strings(in,out) +#define u80stringg0(in,out) u8strings(in,out) -#define i80string(in,out) i8strings(in,out) +#define i80stringg0(in,out) i8strings(in,out) -#define u160string(in,out) u16strings(in,out) +#define u160stringg0(in,out) u16strings(in,out) -#define i160string(in,out) i16strings(in,out) +#define i160stringg0(in,out) i16strings(in,out) -#define s2string(in,size,out) sstringa(in,size[0]*size[1],out) +#define s2stringg2(in,size,out) sstringa(in,size[0]*size[1],out) -#define d2string(in,size,out) dstringa(in,size[0]*size[1],out) +#define d2stringg2(in,size,out) dstringa(in,size[0]*size[1],out) -#define c2string(in,size,out) cstringa(in,size[0]*size[1],out) +#define c2stringg2(in,size,out) cstringa(in,size[0]*size[1],out) -#define z2string(in,size,out) zstringa(in,size[0]*size[1],out) +#define z2stringg2(in,size,out) zstringa(in,size[0]*size[1],out) -#define u82string(in,size,out) u8stringa(in,size[0]*size[1],out) +#define u82stringg2(in,size,out) u8stringa(in,size[0]*size[1],out) -#define i82string(in,size,out) i8stringa(in,size[0]*size[1],out) +#define i82stringg2(in,size,out) i8stringa(in,size[0]*size[1],out) -#define u162string(in,size,out) u16stringa(in,size[0]*size[1],out) +#define u162stringg2(in,size,out) u16stringa(in,size[0]*size[1],out) -#define i162string(in,size,out) i16stringa(in,size[0]*size[1],out) +#define i162stringg2(in,size,out) i16stringa(in,size[0]*size[1],out) #endif /* __INT_STRING_H__ */ |