diff options
Diffstat (limited to '2.3-1/src/c')
33 files changed, 1018 insertions, 9 deletions
diff --git a/2.3-1/src/c/elementaryFunctions/includes/isequal.h b/2.3-1/src/c/elementaryFunctions/includes/isequal.h new file mode 100644 index 00000000..d22a8047 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/includes/isequal.h @@ -0,0 +1,38 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +#ifndef __ISEQUAL_H__ +#define __ISEQUAL_H__ +#include "types.h" +#include "doubleComplex.h" +#include "floatComplex.h" +#include "uint16.h" + +#ifdef __cplusplus +extern "C" { +#endif + +char disequals(double inp1, double inp2); +char disequala(double* inp1, int size1r, int size1c, double* inp2, int size2r, int size2c); +char sisequals(float inp1, float inp2); +char sisequala(float* inp1, int size1r, int size1c, float* inp2, int size2r, int size2c); +char zisequals(doubleComplex inp1, doubleComplex inp2); +char zisequala(doubleComplex* inp1, int size1r, int size1c, doubleComplex* inp2, int size2r, int size2c); +char u16isequals(uint16 inp1, uint16 inp2); +char u16isequala(uint16* inp1, int size1r, int size1c, uint16* inp2, int size2r, int size2c); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__ISEQUAL_H__*/ diff --git a/2.3-1/src/c/elementaryFunctions/interfaces/int_isequal.h b/2.3-1/src/c/elementaryFunctions/interfaces/int_isequal.h new file mode 100644 index 00000000..d22ab65d --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/interfaces/int_isequal.h @@ -0,0 +1,35 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_ISEQUAL_H__ +#define __INT_ISEQUAL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define d0d0isequalg0(in1,in2) disequals(in1,in2) +#define d2d2isequalg0(in1, s1, in2, s2) disequala(in1, s1[0], s1[1], in2, s2[0], s2[1]) +#define s0s0isequalg0(in1,in2) sisequals(in1,in2) +#define s2s2isequalg0(in1, s1, in2, s2) sisequala(in1, s1[0], s1[1], in2, s2[0], s2[1]) +#define z0z0isequalg0(in1,in2) zisequals(in1,in2) +#define z2z2isequalg0(in1, s1, in2, s2) zisequala(in1, s1[0], s1[1], in2, s2[0], s2[1]) +#define u160u160isequalg0(in1,in2) u16isequals(in1,in2) +#define u162u162isequalg0(in1, s1, in2, s2) u16isequala(in1, s1[0], s1[1], in2, s2[0], s2[1]) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_ISEQUAL_H__*/ diff --git a/2.3-1/src/c/elementaryFunctions/isequal/disequala.c b/2.3-1/src/c/elementaryFunctions/isequal/disequala.c new file mode 100644 index 00000000..8781ac7b --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isequal/disequala.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <isreal.h> + +char disequala(double* inp1, int size1r, int size1c, double* inp2, int size2r, int size2c) +{ + if ((size1r != size2r) && (size1c != size2c)) + return 'F'; + else + { + int i, f = 0; + for (i = 0; i<size1r*size1c; i++) + { + if (inp1[i] != inp2[i]) + { + f = 1; + break; + } + } + + if (f == 1) + return 'F'; + else + return 'T'; + } +} + diff --git a/2.3-1/src/c/elementaryFunctions/isequal/disequals.c b/2.3-1/src/c/elementaryFunctions/isequal/disequals.c new file mode 100644 index 00000000..319c3308 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isequal/disequals.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <isreal.h> + +char disequals(double inp1, double inp2) +{ + if (inp1 == inp2) + return 'T'; + else + return 'F'; +} + diff --git a/2.3-1/src/c/elementaryFunctions/isequal/sisequala.c b/2.3-1/src/c/elementaryFunctions/isequal/sisequala.c new file mode 100644 index 00000000..2634efd5 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isequal/sisequala.c @@ -0,0 +1,39 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <isreal.h> + +char sisequala(float* inp1, int size1r, int size1c, float* inp2, int size2r, int size2c) +{ + if ((size1r != size2r) && (size1c != size2c)) + return 'F'; + else + { + int i, f = 0; + for (i = 0; i<size1r*size1c; i++) + { + if (inp1[i] != inp2[i]) + { + f = 1; + break; + } + } + + if (f == 1) + return 'F'; + else + return 'T'; + } +} + diff --git a/2.3-1/src/c/elementaryFunctions/isequal/sisequals.c b/2.3-1/src/c/elementaryFunctions/isequal/sisequals.c new file mode 100644 index 00000000..66bef36d --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isequal/sisequals.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <isreal.h> + +char sisequals(float inp1, float inp2) +{ + if (inp1 == inp2) + return 'T'; + else + return 'F'; +} + diff --git a/2.3-1/src/c/elementaryFunctions/isequal/u16isequala.c b/2.3-1/src/c/elementaryFunctions/isequal/u16isequala.c new file mode 100644 index 00000000..62de1e86 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isequal/u16isequala.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <isreal.h> +#include "uint16.h" + +char u16isequala(uint16* inp1, int size1r, int size1c, uint16* inp2, int size2r, int size2c) +{ + if ((size1r != size2r) && (size1c != size2c)) + return 'F'; + else + { + int i, f = 0; + for (i = 0; i<size1r*size1c; i++) + { + if (inp1[i] != inp2[i]) + { + f = 1; + break; + } + } + + if (f == 1) + return 'F'; + else + return 'T'; + } +} + diff --git a/2.3-1/src/c/elementaryFunctions/isequal/u16isequals.c b/2.3-1/src/c/elementaryFunctions/isequal/u16isequals.c new file mode 100644 index 00000000..4f797d40 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isequal/u16isequals.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <isreal.h> +#include "uint16.h" + +char u16isequals(uint16 inp1, uint16 inp2) +{ + if (inp1 == inp2) + return 'T'; + else + return 'F'; +} + diff --git a/2.3-1/src/c/elementaryFunctions/isequal/zisequala.c b/2.3-1/src/c/elementaryFunctions/isequal/zisequala.c new file mode 100644 index 00000000..13d241fe --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isequal/zisequala.c @@ -0,0 +1,40 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <isreal.h> +#include "doubleComplex.h" + +char zisequala(doubleComplex* inp1, int size1r, int size1c, doubleComplex* inp2, int size2r, int size2c) +{ + if ((size1r != size2r) && (size1c != size2c)) + return 'F'; + else + { + int i, f = 0; + for (i = 0; i<size1r*size1c; i++) + { + if (!(zisequals(inp1[i],inp2[i]))) + { + f = 1; + break; + } + } + + if (f == 1) + return 'F'; + else + return 'T'; + } +} + diff --git a/2.3-1/src/c/elementaryFunctions/isequal/zisequals.c b/2.3-1/src/c/elementaryFunctions/isequal/zisequals.c new file mode 100644 index 00000000..6914dc87 --- /dev/null +++ b/2.3-1/src/c/elementaryFunctions/isequal/zisequals.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <isreal.h> +#include "doubleComplex.h" + +char zisequals(doubleComplex inp1, doubleComplex inp2) +{ + if ((zreals(inp1) == zreals(inp2)) && (zimags(inp1) == zimags(inp2))) + return 'T'; + else + return 'F'; +} + diff --git a/2.3-1/src/c/matrixOperations/cross/ccrossa.c b/2.3-1/src/c/matrixOperations/cross/ccrossa.c new file mode 100644 index 00000000..5f74bb36 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/cross/ccrossa.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "floatComplex.h" +#include "stdlib.h" +#include "string.h" +#include "cat.h" + +void ccrossa (floatComplex* inp1, int size1_r, int size1_c, floatComplex* inp2, int size2_r, int size2_c ,floatComplex* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/2.3-1/src/c/matrixOperations/cross/dcrossa.c b/2.3-1/src/c/matrixOperations/cross/dcrossa.c new file mode 100644 index 00000000..203ec24b --- /dev/null +++ b/2.3-1/src/c/matrixOperations/cross/dcrossa.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> + +void dcrossa (double* inp1, int size1_r, int size1_c, double* inp2, int size2_r, int size2_c ,double* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/2.3-1/src/c/matrixOperations/cross/i16crossa.c b/2.3-1/src/c/matrixOperations/cross/i16crossa.c new file mode 100644 index 00000000..91cdb7f0 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/cross/i16crossa.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "int16.h" + +void i16crossa (int16* inp1, int size1_r, int size1_c, int16* inp2, int size2_r, int size2_c ,int16* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/2.3-1/src/c/matrixOperations/cross/i8crossa.c b/2.3-1/src/c/matrixOperations/cross/i8crossa.c new file mode 100644 index 00000000..adfbd534 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/cross/i8crossa.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "int8.h" + +void i8crossa (int8* inp1, int size1_r, int size1_c, int8* inp2, int size2_r, int size2_c ,int8* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/2.3-1/src/c/matrixOperations/cross/scrossa.c b/2.3-1/src/c/matrixOperations/cross/scrossa.c new file mode 100644 index 00000000..414b85a4 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/cross/scrossa.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> + +void scrossa (float* inp1, int size1_r, int size1_c, float* inp2, int size2_r, int size2_c ,float* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/2.3-1/src/c/matrixOperations/cross/u16crossa.c b/2.3-1/src/c/matrixOperations/cross/u16crossa.c new file mode 100644 index 00000000..e0a32bcc --- /dev/null +++ b/2.3-1/src/c/matrixOperations/cross/u16crossa.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "uint16.h" + +void u16crossa (uint16* inp1, int size1_r, int size1_c, uint16* inp2, int size2_r, int size2_c ,uint16* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/2.3-1/src/c/matrixOperations/cross/u8crossa.c b/2.3-1/src/c/matrixOperations/cross/u8crossa.c new file mode 100644 index 00000000..7a8b857f --- /dev/null +++ b/2.3-1/src/c/matrixOperations/cross/u8crossa.c @@ -0,0 +1,34 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "uint8.h" + +void u8crossa (uint8* inp1, int size1_r, int size1_c, uint8* inp2, int size2_r, int size2_c ,uint8* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/2.3-1/src/c/matrixOperations/cross/zcrossa.c b/2.3-1/src/c/matrixOperations/cross/zcrossa.c new file mode 100644 index 00000000..85a19607 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/cross/zcrossa.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <stdlib.h> +#include <cross.h> +#include "doubleComplex.h" +#include "stdlib.h" +#include "string.h" +#include "cat.h" + +void zcrossa (doubleComplex* inp1, int size1_r, int size1_c, doubleComplex* inp2, int size2_r, int size2_c ,doubleComplex* oup) +{ + int i,j; + + if (size1_c == 3 && size1_r == 1) // Calculating the cross product for a 1X3 Matrix + { + oup[0] = inp1[1]*inp2[2] - inp1[2]*inp2[1]; + oup[1] = inp1[2]*inp2[0] - inp1[0]*inp2[2]; + oup[2] = inp1[0]*inp2[1] - inp1[1]*inp2[0]; + printf("%lf ", oup[0]); + printf("%lf ", oup[1]); + printf("%lf \n", oup[2]); + } + else // Calculating the cross product for a 3XN Matrix + { + for(i = 0; i < size1_r; i++) + { + for(j = 0; j < size1_c; j = j+3) + { + oup[j+(i*size1_r)] = inp1[(j+1)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)] - inp1[(j+2)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)]; + oup[(j+1)+(i*size1_r)] = inp1[(j+2)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)] - inp1[(j+0)+(i*size1_r)] * inp2[(j+2)+(i*size1_r)]; + oup[(j+2)+(i*size1_r)] = inp1[(j+0)+(i*size1_r)] * inp2[(j+1)+(i*size1_r)] - inp1[(j+1)+(i*size1_r)] * inp2[(j+0)+(i*size1_r)]; + + } + } + + } +} + diff --git a/2.3-1/src/c/matrixOperations/includes/cross.h b/2.3-1/src/c/matrixOperations/includes/cross.h new file mode 100644 index 00000000..0abd0019 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/includes/cross.h @@ -0,0 +1,37 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +#ifndef __CROSS_H__ +#define __CROSS_H__ +#include "types.h" +#include "doubleComplex.h" +#include "floatComplex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void dcrossa (double* inp1, int size1_r, int size1_c, double* inp2, int size2_r, int size2_c ,double* oup); +void zcrossa (doubleComplex* inp1, int size1_r, int size1_c, doubleComplex* inp2, int size2_r, int size2_c ,doubleComplex* oup); +void ccrossa (floatComplex* inp1, int size1_r, int size1_c, floatComplex* inp2, int size2_r, int size2_c ,floatComplex* oup); +void scrossa (float* inp1, int size1_r, int size1_c, float* inp2, int size2_r, int size2_c ,float* oup); +void u8crossa (uint8* inp1, int size1_r, int size1_c, uint8* inp2, int size2_r, int size2_c ,uint8* oup); +void u16crossa (uint16* inp1, int size1_r, int size1_c, uint16* inp2, int size2_r, int size2_c ,uint16* oup); +void i8crossa (int8* inp1, int size1_r, int size1_c, int8* inp2, int size2_r, int size2_c ,int8* oup); +void i16crossa (int16* inp1, int size1_r, int size1_c, int16* inp2, int size2_r, int size2_c ,int16* oup); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__CROSS_H__*/ diff --git a/2.3-1/src/c/matrixOperations/interfaces/int_cross.h b/2.3-1/src/c/matrixOperations/interfaces/int_cross.h new file mode 100644 index 00000000..8f4e7824 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/interfaces/int_cross.h @@ -0,0 +1,35 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_CROSS_H__ +#define __INT_CROSS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define d2d2crossd2(in1,size1,in2,size2,out) dcrossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define z2z2crossz2(in1,size1,in2,size2,out) zcrossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define c2c2crossc2(in1,size1,in2,size2,out) ccrossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define s2s2crosss2(in1,size1,in2,size2,out) scrossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define u82u82crossu82(in1,size1,in2,size2,out) u8crossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define i82i82crossi82(in1,size1,in2,size2,out) i8crossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define u162u162crossu162(in1,size1,in2,size2,out) u16crossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) +#define i162i162crossi162(in1,size1,in2,size2,out) i16crossa(in1,size1[0],size1[1],in2,size2[0],size2[1],out) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_CROSS_H__*/ diff --git a/2.3-1/src/c/specialFunctions/erf/derfa.c b/2.3-1/src/c/specialFunctions/erf/derfa.c new file mode 100644 index 00000000..972d7437 --- /dev/null +++ b/2.3-1/src/c/specialFunctions/erf/derfa.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erf.h" + +void derfa(double* inp1, int sizer, int sizec,double* out) +{ + for (int i = 0; i < sizer*sizec; i++) + { + out[i] = erf(inp1[i]); + } +} + diff --git a/2.3-1/src/c/specialFunctions/erf/derfs.c b/2.3-1/src/c/specialFunctions/erf/derfs.c new file mode 100644 index 00000000..22b5d642 --- /dev/null +++ b/2.3-1/src/c/specialFunctions/erf/derfs.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erf.h" + +double derfs(double inp1) +{ + return erf(inp1); +} + diff --git a/2.3-1/src/c/specialFunctions/erf/serfa.c b/2.3-1/src/c/specialFunctions/erf/serfa.c new file mode 100644 index 00000000..0db4a7b2 --- /dev/null +++ b/2.3-1/src/c/specialFunctions/erf/serfa.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erf.h" + +void serfa(float* inp1, int sizer, int sizec,float* out) +{ + for (int i = 0; i < sizer*sizec; i++) + { + out[i] = erf(inp1[i]); + } +} + diff --git a/2.3-1/src/c/specialFunctions/erf/serfs.c b/2.3-1/src/c/specialFunctions/erf/serfs.c new file mode 100644 index 00000000..66638a15 --- /dev/null +++ b/2.3-1/src/c/specialFunctions/erf/serfs.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erf.h" + +float serfs(float inp1) +{ + return erf(inp1); +} + diff --git a/2.3-1/src/c/specialFunctions/erfc/derfca.c b/2.3-1/src/c/specialFunctions/erfc/derfca.c new file mode 100644 index 00000000..85c92efb --- /dev/null +++ b/2.3-1/src/c/specialFunctions/erfc/derfca.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erfc.h" + +void derfca(double* inp1, int sizer, int sizec, double* out) +{ + for (int i = 0; i < sizer*sizec; i++) + { + out[i] = derfcs(inp1[i]); + } +} + diff --git a/2.3-1/src/c/specialFunctions/erfc/derfcs.c b/2.3-1/src/c/specialFunctions/erfc/derfcs.c new file mode 100644 index 00000000..31c98463 --- /dev/null +++ b/2.3-1/src/c/specialFunctions/erfc/derfcs.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erfc.h" + +double derfcs(double inp1) +{ + return (1-erf(inp1)); +} + diff --git a/2.3-1/src/c/specialFunctions/erfc/serfca.c b/2.3-1/src/c/specialFunctions/erfc/serfca.c new file mode 100644 index 00000000..469c5a16 --- /dev/null +++ b/2.3-1/src/c/specialFunctions/erfc/serfca.c @@ -0,0 +1,25 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erfc.h" + +void serfca(float* inp1, int sizer, int sizec, float* out) +{ + for (int i = 0; i < sizer*sizec; i++) + { + out[i] = serfcs(inp1[i]); + } +} + diff --git a/2.3-1/src/c/specialFunctions/erfc/serfcs.c b/2.3-1/src/c/specialFunctions/erfc/serfcs.c new file mode 100644 index 00000000..3f93a807 --- /dev/null +++ b/2.3-1/src/c/specialFunctions/erfc/serfcs.c @@ -0,0 +1,22 @@ +/* Copyright (C) 2016 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include "erfc.h" + +float serfcs(float inp1) +{ + return (1-erf(inp1)); +} + diff --git a/2.3-1/src/c/specialFunctions/includes/erf.h b/2.3-1/src/c/specialFunctions/includes/erf.h new file mode 100644 index 00000000..86bb15d7 --- /dev/null +++ b/2.3-1/src/c/specialFunctions/includes/erf.h @@ -0,0 +1,35 @@ +/* + * 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 + * + */ + +#ifndef __ERF_H__ +#define __ERF_H__ +#include "types.h" +#include "floatComplex.h" +#include "doubleComplex.h" +#include "uint8.h" +#include "uint16.h" +#include "int16.h" + +#ifdef __cplusplus +extern "C" { +#endif + +double derfs(double inp1); +float serfs(float inp1); +void derfa(double* inp1, int sizer, int sizec,double* out); +void serfa(float* inp1, int sizer, int sizec,float* out); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__ERF_H__*/ diff --git a/2.3-1/src/c/specialFunctions/includes/erfc.h b/2.3-1/src/c/specialFunctions/includes/erfc.h new file mode 100644 index 00000000..77847ab5 --- /dev/null +++ b/2.3-1/src/c/specialFunctions/includes/erfc.h @@ -0,0 +1,36 @@ +/* + * 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 + * + */ + +#ifndef __ERFC_H__ +#define __ERFC_H__ +#include "types.h" +#include "floatComplex.h" +#include "doubleComplex.h" +#include "uint8.h" +#include "uint16.h" +#include "int16.h" + +#ifdef __cplusplus +extern "C" { +#endif + +double derfcs(double inp1); +void derfca(double* inp1, int sizer, int sizec,double* out); +float serfcs(float inp1); +void serfca(float* inp1, int sizer, int sizec, float* out); + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__ERFC_H__*/ diff --git a/2.3-1/src/c/specialFunctions/interfaces/int_erf.h b/2.3-1/src/c/specialFunctions/interfaces/int_erf.h new file mode 100644 index 00000000..87f11f9a --- /dev/null +++ b/2.3-1/src/c/specialFunctions/interfaces/int_erf.h @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_ERF_H__ +#define __INT_ERF_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define d0erfd0(in1) derfs(in1) +#define s0erfs0(in1) serfs(in1) +#define d2erfd2(in1,size,out) derfa(in1,size[0],size[1],out) +#define s2erfs2(in1,size,out) serfa(in1,size[0],size[1],out) + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_ERF_H__*/ diff --git a/2.3-1/src/c/specialFunctions/interfaces/int_erfc.h b/2.3-1/src/c/specialFunctions/interfaces/int_erfc.h new file mode 100644 index 00000000..64ae0fa8 --- /dev/null +++ b/2.3-1/src/c/specialFunctions/interfaces/int_erfc.h @@ -0,0 +1,32 @@ +/* Copyright (C) 2017 - IIT Bombay - FOSSEE + + 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 + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_ERFC_H__ +#define __INT_ERFC_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + + +#define d0erfcd0(in1) derfcs(in1) +#define s0erfcs0(in1) serfcs(in1) +#define d2erfcd2(in1,size,out) derfca(in1,size[0],size[1],out) +#define s2erfcs2(in1,size,out) serfca(in1,size[0],size[1],out) + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_ERFC_H__*/ diff --git a/2.3-1/src/c/string/strcspn/gstrcspna.c b/2.3-1/src/c/string/strcspn/gstrcspna.c index 2c83c724..91de8af7 100644 --- a/2.3-1/src/c/string/strcspn/gstrcspna.c +++ b/2.3-1/src/c/string/strcspn/gstrcspna.c @@ -14,19 +14,28 @@ #include "strcspn.h" uint8 gstrcspna(char *str1,int size1,char *str2,int size2) { - int ind,i,j; - for(i=0;i<=size2;i++) + uint8 ind=size1+1; + int l,m; + for(m=0;m<size2;m++) { - for(j=0;j<=size1;j++) - { - if(str2[i]==str1[j]) + int tp; + for(l=0;l<size1;l++) { - ind=j; - break; + if(str2[m]==str1[l]) + { + tp=l; + if(ind>tp) + { + ind=tp; + } + } } - } } - return (ind+1); + if(ind==size1+1) + { + ind=size1; + } + return ind; } |