diff options
author | siddhu8990 | 2016-05-10 17:17:41 +0530 |
---|---|---|
committer | siddhu8990 | 2016-05-10 17:17:41 +0530 |
commit | a9d0c72c839428a17956fa0530977fc058d8a799 (patch) | |
tree | 90c89d1eeeb3130c35927bceefe4bbb7ba175300 /src/c | |
parent | fe32d3a31c1f9d26cbefad9e2512a641ef323f0a (diff) | |
download | Scilab2C_fossee_old-a9d0c72c839428a17956fa0530977fc058d8a799.tar.gz Scilab2C_fossee_old-a9d0c72c839428a17956fa0530977fc058d8a799.tar.bz2 Scilab2C_fossee_old-a9d0c72c839428a17956fa0530977fc058d8a799.zip |
Added support for cumprod, cumsum, triu, tril functions
Diffstat (limited to 'src/c')
63 files changed, 2219 insertions, 37 deletions
diff --git a/src/c/differential_calculus/includes/ode.h b/src/c/differential_calculus/includes/ode.h index 46220a8..f08909c 100644 --- a/src/c/differential_calculus/includes/ode.h +++ b/src/c/differential_calculus/includes/ode.h @@ -1,9 +1,23 @@ -// FOSSEE IIT Bombay -#ifdef __INT_ODE_H__ -#define __INT_ODE_H__ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in -double ODE(double initial_value, double start_time, double end_time, \ - char *ode_function, double nequs, double eps_abs, double eps_rel \ - double step_size) +#ifndef __ODE_H__ +#define __ODE_H__ -#endif /*__INT_ODE_H__*/
\ No newline at end of file +double dodes(double initial_value, double start_time, double end_time, \ + char *ode_function, double nequs, double eps_abs, double eps_rel, \ + double step_size); + +void doded(double *initial_value, double start_time, double end_time, \ + char *ode_function, double nequs, double eps_abs, double eps_rel, \ + double step_size, double *out); + +#endif /*__ODE_H__*/
\ No newline at end of file diff --git a/src/c/differential_calculus/interfaces/int_ode.h b/src/c/differential_calculus/interfaces/int_ode.h index 5000ed5..a27acba 100644 --- a/src/c/differential_calculus/interfaces/int_ode.h +++ b/src/c/differential_calculus/interfaces/int_ode.h @@ -1,9 +1,30 @@ -// FOSSEE IIT Bombay +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in -#ifdef __INT_ODE_H__ +#ifndef __INT_ODE_H__ #define __INT_ODE_H__ -#define d0d0d0g2ODEd0(in1, in2, in3, in4) ODE(in1, in2, in3, in4, 1, 1.0e-2,\ +#ifdef __cplusplus +extern "C" { +#endif + +#define d0d0d0g2oded0(in1, in2, in3, in4) dodes(in1, in2, in3, in4, 1, 1.0e-2,\ 1.0e-2, 1.0e-6) +#define d2d0d0g2oded2(in1, size1, in2, in3, func_name, strsize, out) doded(in1, in2, in3, func_name \ + 1, 1.0e-2, 1.0e-2, 1.0e-6, out) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + #endif /*__INT_ODE_H__*/
\ No newline at end of file diff --git a/src/c/differential_calculus/ode/doded.c b/src/c/differential_calculus/ode/doded.c new file mode 100644 index 0000000..b544c42 --- /dev/null +++ b/src/c/differential_calculus/ode/doded.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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +#include "ode.h" +#include "types.h" +#include <gsl/gsl_errno.h> +#include <gsl/gsl_matrix.h> +#include <gsl/gsl_odeiv2.h> + + +void doded(double *initial_value, double start_time, double end_time, \ + char *ode_function, double nequs, double eps_abs, double eps_rel, \ + double step_size, double *out) +{ + double t = start_time; + //Setup ODE related parameters + gsl_odeiv2_system sys = {ode_function, NULL, 2, NULL}; + + gsl_odeiv2_step *s = gsl_odeiv2_step_alloc (gsl_odeiv2_step_rkf45, nequs); + gsl_odeiv2_control *c = gsl_odeiv2_control_y_new (eps_abs, eps_rel); + gsl_odeiv2_evolve *e = gsl_odeiv2_evolve_alloc (nequs); + + while(t < end_time) + { + gsl_odeiv2_evolve_apply_fixed_step (e, c, s, &sys, &t, step_size, &out); + } + + gsl_odeiv2_evolve_free (e); + gsl_odeiv2_control_free (c); + gsl_odeiv2_step_free (s); +} diff --git a/src/c/differential_calculus/ode/dodes.c b/src/c/differential_calculus/ode/dodes.c new file mode 100644 index 0000000..ee6718b --- /dev/null +++ b/src/c/differential_calculus/ode/dodes.c @@ -0,0 +1,36 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +#include "ode.h" +#include "types.h" +#include <gsl/gsl_errno.h> +#include <gsl/gsl_matrix.h> +#include <gsl/gsl_odeiv2.h> + + +double dodes(double initial_value, double start_time, double end_time, \ + char *ode_function, double nequs, double eps_abs, double eps_rel, \ + double step_size) +{ + double out = 0; + //int status; + //Setup ODE related parameters + gsl_odeiv2_system sys = {ode_function, NULL, 2, NULL}; + + gsl_odeiv2_step *s = gsl_odeiv2_step_alloc (gsl_odeiv2_step_rkf45, nequs); + gsl_odeiv2_control *c = gsl_odeiv2_control_y_new (eps_abs, eps_rel); + gsl_odeiv2_evolve *e = gsl_odeiv2_evolve_alloc (nequs); + + gsl_odeiv2_evolve_apply_fixed_step (e, c, s, &sys, &start_time, step_size, &out); + + return out; + +} diff --git a/src/c/differential_calculus/ode/ode.c b/src/c/differential_calculus/ode/ode.c deleted file mode 100644 index b815e36..0000000 --- a/src/c/differential_calculus/ode/ode.c +++ /dev/null @@ -1,26 +0,0 @@ -// FOSSEE IIT Bombay - -#include "ODE.h" -#include "types.h" - - -double ODE(double initial_value, double start_time, double end_time, \ - char *ode_function, double nequs, double eps_abs, double eps_rel \ - double step_size) -{ - double out = 0; - int status; - //Setup ODE related parameters - gsl_odeiv2_system sys = {ode_function, NULL, 2, NULL}; - - gsl_odeiv2_step *s = gsl_odeiv2_step_alloc (gsl_odeiv2_step_rkf45, nequs); - gsl_odeiv2_control *c = gsl_odeiv2_control_y_new (eps_abs, eps_rel); - gsl_odeiv2_evolve *e = gsl_odeiv2_evolve_alloc (nequs); - - status = gsl_odeiv2_evolve_apply_fixed_step (e, c, s, &sys, &t, stepsize, x_dot); - - if (status == GSL_SUCCESS) { - return out; - } - else return 0; -} diff --git a/src/c/matrixOperations/cumprod/dcolumncumproda.c b/src/c/matrixOperations/cumprod/dcolumncumproda.c new file mode 100644 index 0000000..7bed70b --- /dev/null +++ b/src/c/matrixOperations/cumprod/dcolumncumproda.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void dcolumncumproda(double *in1, int row, int column, double *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/dcumproda.c b/src/c/matrixOperations/cumprod/dcumproda.c new file mode 100644 index 0000000..0a40868 --- /dev/null +++ b/src/c/matrixOperations/cumprod/dcumproda.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void dcumproda(double *in1, int row, int column, double *out) +{ + int row_cnt, col_cnt = 0; + double cumprod = 1; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumprod *= in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumprod; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/drowcumproda.c b/src/c/matrixOperations/cumprod/drowcumproda.c new file mode 100644 index 0000000..74b2bfc --- /dev/null +++ b/src/c/matrixOperations/cumprod/drowcumproda.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void drowcumproda(double *in1, int row, int column, double *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/i16columncumproda.c b/src/c/matrixOperations/cumprod/i16columncumproda.c new file mode 100644 index 0000000..3c64477 --- /dev/null +++ b/src/c/matrixOperations/cumprod/i16columncumproda.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void i16columncumproda(int16 *in1, int row, int column, int16 *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/i16cumproda.c b/src/c/matrixOperations/cumprod/i16cumproda.c new file mode 100644 index 0000000..8352f41 --- /dev/null +++ b/src/c/matrixOperations/cumprod/i16cumproda.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void i16cumproda(int16 *in1, int row, int column, int16 *out) +{ + int row_cnt, col_cnt = 0; + int16 cumprod = 1; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumprod *= in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumprod; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/i16rowcumproda.c b/src/c/matrixOperations/cumprod/i16rowcumproda.c new file mode 100644 index 0000000..35ab6d4 --- /dev/null +++ b/src/c/matrixOperations/cumprod/i16rowcumproda.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void i16rowcumproda(int16 *in1, int row, int column, int16 *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/i8columncumproda.c b/src/c/matrixOperations/cumprod/i8columncumproda.c new file mode 100644 index 0000000..df9109d --- /dev/null +++ b/src/c/matrixOperations/cumprod/i8columncumproda.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void i8columncumproda(int8 *in1, int row, int column, int8 *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/i8cumproda.c b/src/c/matrixOperations/cumprod/i8cumproda.c new file mode 100644 index 0000000..ba502ba --- /dev/null +++ b/src/c/matrixOperations/cumprod/i8cumproda.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void i8cumproda(int8 *in1, int row, int column, int8 *out) +{ + int row_cnt, col_cnt = 0; + int8 cumprod = 1; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumprod *= in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumprod; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/i8rowcumproda.c b/src/c/matrixOperations/cumprod/i8rowcumproda.c new file mode 100644 index 0000000..20b4126 --- /dev/null +++ b/src/c/matrixOperations/cumprod/i8rowcumproda.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void i8rowcumproda(int8 *in1, int row, int column, int8 *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/scolumncumproda.c b/src/c/matrixOperations/cumprod/scolumncumproda.c new file mode 100644 index 0000000..5c2c0c3 --- /dev/null +++ b/src/c/matrixOperations/cumprod/scolumncumproda.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void scolumncumproda(float *in1, int row, int column, float *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/scumproda.c b/src/c/matrixOperations/cumprod/scumproda.c new file mode 100644 index 0000000..b50ea63 --- /dev/null +++ b/src/c/matrixOperations/cumprod/scumproda.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void scumproda(float *in1, int row, int column, float *out) +{ + int row_cnt, col_cnt = 0; + float cumprod = 1; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumprod += in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumprod; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/srowcumproda.c b/src/c/matrixOperations/cumprod/srowcumproda.c new file mode 100644 index 0000000..e3d146a --- /dev/null +++ b/src/c/matrixOperations/cumprod/srowcumproda.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void srowcumproda(float *in1, int row, int column, float *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/u16columncumproda.c b/src/c/matrixOperations/cumprod/u16columncumproda.c new file mode 100644 index 0000000..a0e821f --- /dev/null +++ b/src/c/matrixOperations/cumprod/u16columncumproda.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void u16columncumproda(uint16 *in1, int row, int column, uint16 *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/u16cumproda.c b/src/c/matrixOperations/cumprod/u16cumproda.c new file mode 100644 index 0000000..de969fb --- /dev/null +++ b/src/c/matrixOperations/cumprod/u16cumproda.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void u16cumproda(uint16 *in1, int row, int column, uint16 *out) +{ + int row_cnt, col_cnt = 0; + uint16 cumprod = 1; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumprod *= in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumprod; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/u16rowcumproda.c b/src/c/matrixOperations/cumprod/u16rowcumproda.c new file mode 100644 index 0000000..1ea4468 --- /dev/null +++ b/src/c/matrixOperations/cumprod/u16rowcumproda.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void u16rowcumproda(uint16 *in1, int row, int column, uint16 *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/u8columncumproda.c b/src/c/matrixOperations/cumprod/u8columncumproda.c new file mode 100644 index 0000000..70eb058 --- /dev/null +++ b/src/c/matrixOperations/cumprod/u8columncumproda.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void u8columncumproda(uint8 *in1, int row, int column, uint8 *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/u8cumproda.c b/src/c/matrixOperations/cumprod/u8cumproda.c new file mode 100644 index 0000000..048b26f --- /dev/null +++ b/src/c/matrixOperations/cumprod/u8cumproda.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void u8cumproda(uint8 *in1, int row, int column, uint8 *out) +{ + int row_cnt, col_cnt = 0; + uint8 cumprod = 1; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumprod *= in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumprod; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumprod/u8rowcumproda.c b/src/c/matrixOperations/cumprod/u8rowcumproda.c new file mode 100644 index 0000000..fb500c7 --- /dev/null +++ b/src/c/matrixOperations/cumprod/u8rowcumproda.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumprod.h" +#include "types.h" + +void u8rowcumproda(uint8 *in1, int row, int column, uint8 *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + * out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/dcolumncumsuma.c b/src/c/matrixOperations/cumsum/dcolumncumsuma.c new file mode 100644 index 0000000..b97704e --- /dev/null +++ b/src/c/matrixOperations/cumsum/dcolumncumsuma.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void dcolumncumsuma(double *in1, int row, int column, double *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/dcumsuma.c b/src/c/matrixOperations/cumsum/dcumsuma.c new file mode 100644 index 0000000..6a2eb1b --- /dev/null +++ b/src/c/matrixOperations/cumsum/dcumsuma.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void dcumsuma(double *in1, int row, int column, double *out) +{ + int row_cnt, col_cnt = 0; + double cumsum = 0; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumsum += in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumsum; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/drowcumsuma.c b/src/c/matrixOperations/cumsum/drowcumsuma.c new file mode 100644 index 0000000..5b46f16 --- /dev/null +++ b/src/c/matrixOperations/cumsum/drowcumsuma.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void drowcumsuma(double *in1, int row, int column, double *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/i16columncumsuma.c b/src/c/matrixOperations/cumsum/i16columncumsuma.c new file mode 100644 index 0000000..5c43bbd --- /dev/null +++ b/src/c/matrixOperations/cumsum/i16columncumsuma.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void i16columncumsuma(int16 *in1, int row, int column, int16 *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/i16cumsuma.c b/src/c/matrixOperations/cumsum/i16cumsuma.c new file mode 100644 index 0000000..7632c58 --- /dev/null +++ b/src/c/matrixOperations/cumsum/i16cumsuma.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void i16cumsuma(int16 *in1, int row, int column, int16 *out) +{ + int row_cnt, col_cnt = 0; + int16 cumsum = 0; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumsum += in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumsum; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/i16rowcumsuma.c b/src/c/matrixOperations/cumsum/i16rowcumsuma.c new file mode 100644 index 0000000..0e75f25 --- /dev/null +++ b/src/c/matrixOperations/cumsum/i16rowcumsuma.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void i16rowcumsuma(int16 *in1, int row, int column, int16 *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/i8columncumsuma.c b/src/c/matrixOperations/cumsum/i8columncumsuma.c new file mode 100644 index 0000000..27fdbde --- /dev/null +++ b/src/c/matrixOperations/cumsum/i8columncumsuma.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void i8columncumsuma(int8 *in1, int row, int column, int8 *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/i8cumsuma.c b/src/c/matrixOperations/cumsum/i8cumsuma.c new file mode 100644 index 0000000..d8b9c32 --- /dev/null +++ b/src/c/matrixOperations/cumsum/i8cumsuma.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void i8cumsuma(int8 *in1, int row, int column, int8 *out) +{ + int row_cnt, col_cnt = 0; + int8 cumsum = 0; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumsum += in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumsum; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/i8rowcumsuma.c b/src/c/matrixOperations/cumsum/i8rowcumsuma.c new file mode 100644 index 0000000..39298ce --- /dev/null +++ b/src/c/matrixOperations/cumsum/i8rowcumsuma.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void i8rowcumsuma(int8 *in1, int row, int column, int8 *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/scolumncumsuma.c b/src/c/matrixOperations/cumsum/scolumncumsuma.c new file mode 100644 index 0000000..befbdfe --- /dev/null +++ b/src/c/matrixOperations/cumsum/scolumncumsuma.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void scolumncumsuma(float *in1, int row, int column, float *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/scumsuma.c b/src/c/matrixOperations/cumsum/scumsuma.c new file mode 100644 index 0000000..8370186 --- /dev/null +++ b/src/c/matrixOperations/cumsum/scumsuma.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void scumsuma(float *in1, int row, int column, float *out) +{ + int row_cnt, col_cnt = 0; + float cumsum = 0; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumsum += in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumsum; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/srowcumsuma.c b/src/c/matrixOperations/cumsum/srowcumsuma.c new file mode 100644 index 0000000..1ce17da --- /dev/null +++ b/src/c/matrixOperations/cumsum/srowcumsuma.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void srowcumsuma(float *in1, int row, int column, float *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/u16columncumsuma.c b/src/c/matrixOperations/cumsum/u16columncumsuma.c new file mode 100644 index 0000000..bbff8c8 --- /dev/null +++ b/src/c/matrixOperations/cumsum/u16columncumsuma.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void u16columncumsuma(uint16 *in1, int row, int column, uint16 *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/u16cumsuma.c b/src/c/matrixOperations/cumsum/u16cumsuma.c new file mode 100644 index 0000000..601a7ef --- /dev/null +++ b/src/c/matrixOperations/cumsum/u16cumsuma.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void u16cumsuma(uint16 *in1, int row, int column, uint16 *out) +{ + int row_cnt, col_cnt = 0; + uint16 cumsum = 0; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumsum += in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumsum; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/u16rowcumsuma.c b/src/c/matrixOperations/cumsum/u16rowcumsuma.c new file mode 100644 index 0000000..b27e453 --- /dev/null +++ b/src/c/matrixOperations/cumsum/u16rowcumsuma.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void u16rowcumsuma(uint16 *in1, int row, int column, uint16 *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/u8columncumsuma.c b/src/c/matrixOperations/cumsum/u8columncumsuma.c new file mode 100644 index 0000000..598c4a6 --- /dev/null +++ b/src/c/matrixOperations/cumsum/u8columncumsuma.c @@ -0,0 +1,38 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void u8columncumsuma(uint8 *in1, int row, int column, uint8 *out) +{ + int row_cnt, col_cnt = 0; + + //Assign elements in first column as it is + for(row_cnt = 0; row_cnt < row; row_cnt++) + { + out[row_cnt] = in1[row_cnt]; + } + + //For second column onwards + for (row_cnt = 0; row_cnt < row; row_cnt++) + { + for ( col_cnt = 1; col_cnt < column; col_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[(col_cnt-1)*row+row_cnt]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/u8cumsuma.c b/src/c/matrixOperations/cumsum/u8cumsuma.c new file mode 100644 index 0000000..38792e6 --- /dev/null +++ b/src/c/matrixOperations/cumsum/u8cumsuma.c @@ -0,0 +1,30 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void u8cumsuma(uint8 *in1, int row, int column, uint8 *out) +{ + int row_cnt, col_cnt = 0; + uint8 cumsum = 0; + for (col_cnt = 0; col_cnt < row; col_cnt++) + { + for ( row_cnt = 0; row_cnt < column; row_cnt++) + { + cumsum += in1[col_cnt*column+row_cnt]; + out[col_cnt*column+row_cnt] = cumsum; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/cumsum/u8rowcumsuma.c b/src/c/matrixOperations/cumsum/u8rowcumsuma.c new file mode 100644 index 0000000..184cf71 --- /dev/null +++ b/src/c/matrixOperations/cumsum/u8rowcumsuma.c @@ -0,0 +1,37 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function returns cumulative sum of members of array/matrix + +#include "cumsum.h" +#include "types.h" + +void u8rowcumsuma(uint8 *in1, int row, int column, uint8 *out) +{ + int row_cnt, col_cnt = 0; + + //assign elements in first row as it is + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + out[col_cnt*row] = in1[col_cnt*row]; + } + //For second row onwards + for (col_cnt = 0; col_cnt < column; col_cnt++) + { + for ( row_cnt = 1; row_cnt < row; row_cnt++) + { + + out[col_cnt*row+row_cnt] = in1[col_cnt*row+row_cnt] \ + + out[col_cnt*row+row_cnt -1]; + } + } + +}
\ No newline at end of file diff --git a/src/c/matrixOperations/includes/cumprod.h b/src/c/matrixOperations/includes/cumprod.h new file mode 100644 index 0000000..bc08aba --- /dev/null +++ b/src/c/matrixOperations/includes/cumprod.h @@ -0,0 +1,52 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + + +#ifndef __CUMPROD_H__ +#define __CUMPROD_H__ + +#include "types.h" + +#ifdef __cplusplus +#extern "C" { +#endif + +void dcumproda(double *in1, int row, int column, double *out); +void drowcumproda(double *in1, int row, int column, double *out); +void dcolumncumproda(double *in1, int row, int column, double *out); + +void scumproda(float *in1, int row, int column, float *out); +void srowcumproda(float *in1, int row, int column, float *out); +void scolumncumproda(float *in1, int row, int column, float *out); + +void u8cumproda(uint8 *in1, int row, int column, uint8 *out); +void u8rowcumproda(uint8 *in1, int row, int column, uint8 *out); +void u8columncumproda(uint8 *in1, int row, int column, uint8 *out); + +void i8cumproda(int8 *in1, int row, int column, int8 *out); +void i8rowcumproda(int8 *in1, int row, int column, int8 *out); +void i8columncumproda(int8 *in1, int row, int column, int8 *out); + +void u16cumproda(uint16 *in1, int row, int column, uint16 *out); +void u16rowcumproda(uint16 *in1, int row, int column, uint16 *out); +void u16columncumproda(uint16 *in1, int row, int column, uint16 *out); + +void i16cumproda(int16 *in1, int row, int column, int16 *out); +void i16rowcumproda(int16 *in1, int row, int column, int16 *out); +void i16columncumproda(int16 *in1, int row, int column, int16 *out); + + + +#ifdef __cplusplus +#} /* extern "C" */ +#endif + +#endif /*__CUMPROD_H__*/ diff --git a/src/c/matrixOperations/includes/cumsum.h b/src/c/matrixOperations/includes/cumsum.h new file mode 100644 index 0000000..4c6a3b3 --- /dev/null +++ b/src/c/matrixOperations/includes/cumsum.h @@ -0,0 +1,52 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + + +#ifndef __CUMSUM_H__ +#define __CUMSUM_H__ + +#include "types.h" + +#ifdef __cplusplus +#extern "C" { +#endif + +void dcumsuma(double *in1, int row, int column, double *out); +void drowcumsuma(double *in1, int row, int column, double *out); +void dcolumncumsuma(double *in1, int row, int column, double *out); + +void scumsuma(float *in1, int row, int column, float *out); +void srowcumsuma(float *in1, int row, int column, float *out); +void scolumncumsuma(float *in1, int row, int column, float *out); + +void u8cumsuma(uint8 *in1, int row, int column, uint8 *out); +void u8rowcumsuma(uint8 *in1, int row, int column, uint8 *out); +void u8columncumsuma(uint8 *in1, int row, int column, uint8 *out); + +void i8cumsuma(int8 *in1, int row, int column, int8 *out); +void i8rowcumsuma(int8 *in1, int row, int column, int8 *out); +void i8columncumsuma(int8 *in1, int row, int column, int8 *out); + +void u16cumsuma(uint16 *in1, int row, int column, uint16 *out); +void u16rowcumsuma(uint16 *in1, int row, int column, uint16 *out); +void u16columncumsuma(uint16 *in1, int row, int column, uint16 *out); + +void i16cumsuma(int16 *in1, int row, int column, int16 *out); +void i16rowcumsuma(int16 *in1, int row, int column, int16 *out); +void i16columncumsuma(int16 *in1, int row, int column, int16 *out); + + + +#ifdef __cplusplus +#} /* extern "C" */ +#endif + +#endif /*__CUMSUM_H__*/ diff --git a/src/c/matrixOperations/includes/tril.h b/src/c/matrixOperations/includes/tril.h new file mode 100644 index 0000000..e61a3b7 --- /dev/null +++ b/src/c/matrixOperations/includes/tril.h @@ -0,0 +1,33 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + + +#ifndef __TRIL_H__ +#define __TRIL_H__ + +#include "types.h" + +#ifdef __cplusplus +#extern "C" { +#endif + +void dtrila (double *in, int row, int column, double diag, double *out); +void strila (float *in, int row, int column, double diag, float *out); +void u8trila (uint8 *in, int row, int column, double diag, uint8 *out); +void u16trila (uint16 *in, int row, int column, double diag, uint16 *out); +void i8trila (int8 *in, int row, int column, double diag, int8 *out); +void i16trila (int16 *in, int row, int column, double diag, int16 *out); + +#ifdef __cplusplus +#} /* extern "C" */ +#endif + +#endif /*__TRIL_H__*/ diff --git a/src/c/matrixOperations/includes/triu.h b/src/c/matrixOperations/includes/triu.h new file mode 100644 index 0000000..1dda279 --- /dev/null +++ b/src/c/matrixOperations/includes/triu.h @@ -0,0 +1,33 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + + +#ifndef __TRIU_H__ +#define __TRIU_H__ + +#include "types.h" + +#ifdef __cplusplus +#extern "C" { +#endif + +void dtriua (double *in, int row, int column, double diag, double *out); +void striua (float *in, int row, int column, double diag, float *out); +void u8triua (uint8 *in, int row, int column, double diag, uint8 *out); +void u16triua (uint16 *in, int row, int column, double diag, uint16 *out); +void i8triua (int8 *in, int row, int column, double diag, int8 *out); +void i16triua (int16 *in, int row, int column, double diag, int16 *out); + +#ifdef __cplusplus +#} /* extern "C" */ +#endif + +#endif /*__TRIU_H__*/ diff --git a/src/c/matrixOperations/interfaces/int_cumprod.h b/src/c/matrixOperations/interfaces/int_cumprod.h new file mode 100644 index 0000000..722efbb --- /dev/null +++ b/src/c/matrixOperations/interfaces/int_cumprod.h @@ -0,0 +1,54 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + + +#ifndef __INT_CUMPROD_H__ +#define __INT_CUMPROD_H__ + + +#ifdef __cplusplus +#extern "C" { +#endif + +#define d0cumprodd0(in) in +#define s0cumprods0(in) in +#define u80cumprodu80(in) in +#define u160cumprodu160(in) in +#define i80cumprodi80(in) in +#define i160cumprodi160(in) in + +#define d2cumprodd2(in1, size1, out) dcumproda(in1, size1[0], size1[1], out) +#define s2cumprods2(in1, size1, out) scumproda(in1, size1[0], size1[1], out) +#define u82cumprodu82(in1, size1, out) u8cumproda(in1, size1[0], size1[1], out) +#define u162cumprodu162(in1, size1, out) u16cumproda(in1, size1[0], size1[1], out) +#define i82cumprodi82(in1, size1, out) i8cumproda(in1, size1[0], size1[1], out) +#define i162cumprodi162(in1, size1, out) i16cumproda(in1, size1[0], size1[1], out) + +#define d2g2cumprodd2(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + drowcumproda(in1,size1[0],size1[1],out) : dcolumncumproda(in1,size1[0],size1[1],out) +#define s2g2cumprods2(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + srowcumproda(in1,size1[0],size1[1],out) : scolumncumproda(in1,size1[0],size1[1],out) +#define u82g2cumprodu82(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + u8rowcumproda(in1,size1[0],size1[1],out) : u8columncumproda(in1,size1[0],size1[1],out) +#define i82g2cumprodi82(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + i8rowcumproda(in1,size1[0],size1[1],out) : i8columncumproda(in1,size1[0],size1[1],out) +#define u162g2cumprodu162(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + u16rowcumproda(in1,size1[0],size1[1],out) : u16columncumproda(in1,size1[0],size1[1],out) +#define i162g2cumprodi162(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + i16rowcumproda(in1,size1[0],size1[1],out) : i16columncumproda(in1,size1[0],size1[1],out) + + + +#ifdef __cplusplus +#} /* extern "C" */ +#endif + +#endif /*__INT_CUMPROD_H__*/ diff --git a/src/c/matrixOperations/interfaces/int_cumsum.h b/src/c/matrixOperations/interfaces/int_cumsum.h new file mode 100644 index 0000000..c09a9b4 --- /dev/null +++ b/src/c/matrixOperations/interfaces/int_cumsum.h @@ -0,0 +1,54 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + + +#ifndef __INT_CUMSUM_H__ +#define __INT_CUMSUM_H__ + + +#ifdef __cplusplus +#extern "C" { +#endif + +#define d0cumsumd0(in) in +#define s0cumsums0(in) in +#define u80cumsumu80(in) in +#define u160cumsumu160(in) in +#define i80cumsumi80(in) in +#define i160cumsumi160(in) in + +#define d2cumsumd2(in1, size1, out) dcumsuma(in1, size1[0], size1[1], out) +#define s2cumsums2(in1, size1, out) scumsuma(in1, size1[0], size1[1], out) +#define u82cumsumu82(in1, size1, out) u8cumsuma(in1, size1[0], size1[1], out) +#define u162cumsumu162(in1, size1, out) u16cumsuma(in1, size1[0], size1[1], out) +#define i82cumsumi82(in1, size1, out) i8cumsuma(in1, size1[0], size1[1], out) +#define i162cumsumi162(in1, size1, out) i16cumsuma(in1, size1[0], size1[1], out) + +#define d2g2cumsumd2(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + drowcumsuma(in1,size1[0],size1[1],out) : dcolumncumsuma(in1,size1[0],size1[1],out) +#define s2g2cumsums2(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + srowcumsuma(in1,size1[0],size1[1],out) : scolumncumsuma(in1,size1[0],size1[1],out) +#define u82g2cumsumu82(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + u8rowcumsuma(in1,size1[0],size1[1],out) : u8columncumsuma(in1,size1[0],size1[1],out) +#define i82g2cumsumi82(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + i8rowcumsuma(in1,size1[0],size1[1],out) : i8columncumsuma(in1,size1[0],size1[1],out) +#define u162g2cumsumu162(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + u16rowcumsuma(in1,size1[0],size1[1],out) : u16columncumsuma(in1,size1[0],size1[1],out) +#define i162g2cumsumi162(in1, size1, in2, size2, out) (in2[0]=='r') ? \ + i16rowcumsuma(in1,size1[0],size1[1],out) : i16columncumsuma(in1,size1[0],size1[1],out) + + + +#ifdef __cplusplus +#} /* extern "C" */ +#endif + +#endif /*__INT_CUMSUM_H__*/ diff --git a/src/c/matrixOperations/interfaces/int_tril.h b/src/c/matrixOperations/interfaces/int_tril.h new file mode 100644 index 0000000..d362aab --- /dev/null +++ b/src/c/matrixOperations/interfaces/int_tril.h @@ -0,0 +1,62 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + + +#ifndef __INT_TRIL_H__ +#define __INT_TRIL_H__ + + +#ifdef __cplusplus +#extern "C" { +#endif + +#define d0trild0(in) in +#define s0trils0(in) in +#define u80trilu80(in) in +#define u160trilu160(in) in +#define i80trili80(in) in +#define i160trili160(in) in + +#define d0d0trild0(in1, in2) (in2 == 0 ? in1 : 0) +#define s0s0trils0(in1, in2) (in2 == 0 ? in1 : 0) +#define u80u80trilu80(in1, in2) (in2 == 0 ? in1 : 0) +#define i80i80trili80(in1, in2) (in2 == 0 ? in1 : 0) +#define u160u160trilu160(in1, in2) (in2 == 0 ? in1 : 0) +#define i160i160trili160(in1, in2) (in2 == 0 ? in1 : 0) +#define u80d0trilu80(in1, in2) (in2 == 0 ? in1 : 0) +#define i80d0trili80(in1, in2) (in2 == 0 ? in1 : 0) +#define u160d0trilu160(in1, in2) (in2 == 0 ? in1 : 0) +#define i160d0trili160(in1, in2) (in2 == 0 ? in1 : 0) + +#define d2trild2(in, size, out) dtrila(in, size[0], size[1], 0, out); +#define s2trils2(in, size, out) strila(in, size[0], size[1], 0, out); +#define u82trilu82(in, size, out) u8trila(in, size[0], size[1], 0, out); +#define u162trilu162(in, size, out) u16trila(in, size[0], size[1], 0, out); +#define i82trili82(in, size, out) i8trila(in, size[0], size[1], 0, out); +#define i162trili162(in, size, out) i16trila(in, size[0], size[1], 0, out); + +#define d2d0trild2(in1, size1, in2, out) dtrila(in1, size1[0], size1[1], in2, out); +#define s2s0trils2(in1, size1, in2, out) strila(in1, size1[0], size1[1], in2, out); +#define u82u80trilu82(in1, size1, in2, out) u8trila(in1, size1[0], size1[1], (double)in2, out); +#define i82i80trili82(in1, size1, in2, out) i8trila(in1, size1[0], size1[1], (double)in2, out); +#define u162u160trilu162(in1, size1, in2, out) u16trila(in1, size1[0], size1[1], (double)in2, out); +#define i162i160trili162(in1, size1, in2, out) i16trila(in1, size1[0], size1[1], (double)in2, out); +#define u82d0trilu82(in1, size1, in2, out) u8trila(in1, size1[0], size1[1], in2, out); +#define i82d0trili82(in1, size1, in2, out) i8trila(in1, size1[0], size1[1], in2, out); +#define u162d0trilu162(in1, size1, in2, out) u16trila(in1, size1[0], size1[1], in2, out); +#define i162d0trili162(in1, size1, in2, out) i16trila(in1, size1[0], size1[1], in2, out); + + +#ifdef __cplusplus +#} /* extern "C" */ +#endif + +#endif /*__INT_TRIL_H__*/ diff --git a/src/c/matrixOperations/interfaces/int_triu.h b/src/c/matrixOperations/interfaces/int_triu.h new file mode 100644 index 0000000..fd5448e --- /dev/null +++ b/src/c/matrixOperations/interfaces/int_triu.h @@ -0,0 +1,62 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + + +#ifndef __INT_TRIU_H__ +#define __INT_TRIU_H__ + + +#ifdef __cplusplus +#extern "C" { +#endif + +#define d0triud0(in) in +#define s0trius0(in) in +#define u80triuu80(in) in +#define u160triuu160(in) in +#define i80triui80(in) in +#define i160triui160(in) in + +#define d0d0triud0(in1, in2) (in2 == 0 ? in1 : 0) +#define s0s0trius0(in1, in2) (in2 == 0 ? in1 : 0) +#define u80u80triuu80(in1, in2) (in2 == 0 ? in1 : 0) +#define i80i80triui80(in1, in2) (in2 == 0 ? in1 : 0) +#define u160u160triuu160(in1, in2) (in2 == 0 ? in1 : 0) +#define i160i160triui160(in1, in2) (in2 == 0 ? in1 : 0) +#define u80d0triuu80(in1, in2) (in2 == 0 ? in1 : 0) +#define i80d0triui80(in1, in2) (in2 == 0 ? in1 : 0) +#define u160d0triuu160(in1, in2) (in2 == 0 ? in1 : 0) +#define i160d0triui160(in1, in2) (in2 == 0 ? in1 : 0) + +#define d2triud2(in, size, out) dtriua(in, size[0], size[1], 0, out); +#define s2trius2(in, size, out) striua(in, size[0], size[1], 0, out); +#define u82triuu82(in, size, out) u8triua(in, size[0], size[1], 0, out); +#define u162triuu162(in, size, out) u16triua(in, size[0], size[1], 0, out); +#define i82triui82(in, size, out) i8triua(in, size[0], size[1], 0, out); +#define i162triui162(in, size, out) i16triua(in, size[0], size[1], 0, out); + +#define d2d0triud2(in1, size1, in2, out) dtriua(in1, size1[0], size1[1], in2, out); +#define s2s0trius2(in1, size1, in2, out) striua(in1, size1[0], size1[1], in2, out); +#define u82u80triuu82(in1, size1, in2, out) u8triua(in1, size1[0], size1[1], (double)in2, out); +#define i82i80triui82(in1, size1, in2, out) i8triua(in1, size1[0], size1[1], (double)in2, out); +#define u162u160triuu162(in1, size1, in2, out) u16triua(in1, size1[0], size1[1], (double)in2, out); +#define i162i160triui162(in1, size1, in2, out) i16triua(in1, size1[0], size1[1], (double)in2, out); +#define u82d0triuu82(in1, size1, in2, out) u8triua(in1, size1[0], size1[1], in2, out); +#define i82d0triui82(in1, size1, in2, out) i8triua(in1, size1[0], size1[1], in2, out); +#define u162d0triuu162(in1, size1, in2, out) u16triua(in1, size1[0], size1[1], in2, out); +#define i162d0triui162(in1, size1, in2, out) i16triua(in1, size1[0], size1[1], in2, out); + + +#ifdef __cplusplus +#} /* extern "C" */ +#endif + +#endif /*__INT_TRIU_H__*/ diff --git a/src/c/matrixOperations/tril/dtrila.c b/src/c/matrixOperations/tril/dtrila.c new file mode 100644 index 0000000..b727e5c --- /dev/null +++ b/src/c/matrixOperations/tril/dtrila.c @@ -0,0 +1,33 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix +#include "triu.h" + +void dtrila (double *in, int row, int column, double diag, double *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) >= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/tril/i16trila.c b/src/c/matrixOperations/tril/i16trila.c new file mode 100644 index 0000000..e17b361 --- /dev/null +++ b/src/c/matrixOperations/tril/i16trila.c @@ -0,0 +1,34 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix + +#include "triu.h" + +void i16trila (int16 *in, int row, int column, double diag, int16 *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) >= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/tril/i8trila.c b/src/c/matrixOperations/tril/i8trila.c new file mode 100644 index 0000000..a91594a --- /dev/null +++ b/src/c/matrixOperations/tril/i8trila.c @@ -0,0 +1,34 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix + +#include "triu.h" + +void i8trila (int8 *in, int row, int column, double diag, int8 *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) >= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/tril/strila.c b/src/c/matrixOperations/tril/strila.c new file mode 100644 index 0000000..f588089 --- /dev/null +++ b/src/c/matrixOperations/tril/strila.c @@ -0,0 +1,34 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix + +#include "triu.h" + +void strila (float *in, int row, int column, double diag, float *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) >= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/tril/u16trila.c b/src/c/matrixOperations/tril/u16trila.c new file mode 100644 index 0000000..d697418 --- /dev/null +++ b/src/c/matrixOperations/tril/u16trila.c @@ -0,0 +1,33 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix +#include "triu.h" + +void u16trila (uint16 *in, int row, int column, double diag, uint16 *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) >= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/tril/u8trila.c b/src/c/matrixOperations/tril/u8trila.c new file mode 100644 index 0000000..ebc4d72 --- /dev/null +++ b/src/c/matrixOperations/tril/u8trila.c @@ -0,0 +1,34 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix + +#include "triu.h" + +void u8trila (uint8 *in, int row, int column, double diag, uint8 *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) >= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/triu/.fuse_hidden0000338200000001 b/src/c/matrixOperations/triu/.fuse_hidden0000338200000001 new file mode 100644 index 0000000..887b5b6 --- /dev/null +++ b/src/c/matrixOperations/triu/.fuse_hidden0000338200000001 @@ -0,0 +1,32 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix + +void dtriu (double *in, int row, int column, double *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter< row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if(row_counter < col_counter) + { + out[col_counter*row+col_counter] = in[col_counter*row+col_counter]; + } + else + { + out[col_counter*row+col_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/triu/dtriua.c b/src/c/matrixOperations/triu/dtriua.c new file mode 100644 index 0000000..3a3cc0e --- /dev/null +++ b/src/c/matrixOperations/triu/dtriua.c @@ -0,0 +1,33 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix +#include "triu.h" + +void dtriua (double *in, int row, int column, double diag, double *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) <= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/triu/i16triua.c b/src/c/matrixOperations/triu/i16triua.c new file mode 100644 index 0000000..c4b397f --- /dev/null +++ b/src/c/matrixOperations/triu/i16triua.c @@ -0,0 +1,34 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix + +#include "triu.h" + +void i16triua (int16 *in, int row, int column, double diag, int16 *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) <= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/triu/i8triua.c b/src/c/matrixOperations/triu/i8triua.c new file mode 100644 index 0000000..6493ad1 --- /dev/null +++ b/src/c/matrixOperations/triu/i8triua.c @@ -0,0 +1,34 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix + +#include "triu.h" + +void i8triua (int8 *in, int row, int column, double diag, int8 *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) <= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/triu/striua.c b/src/c/matrixOperations/triu/striua.c new file mode 100644 index 0000000..95305ef --- /dev/null +++ b/src/c/matrixOperations/triu/striua.c @@ -0,0 +1,34 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix + +#include "triu.h" + +void striua (float *in, int row, int column, double diag, float *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) <= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/triu/u16triua.c b/src/c/matrixOperations/triu/u16triua.c new file mode 100644 index 0000000..2786c04 --- /dev/null +++ b/src/c/matrixOperations/triu/u16triua.c @@ -0,0 +1,33 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix +#include "triu.h" + +void u16triua (uint16 *in, int row, int column, double diag, uint16 *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) <= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/matrixOperations/triu/u8triua.c b/src/c/matrixOperations/triu/u8triua.c new file mode 100644 index 0000000..8ab3cb1 --- /dev/null +++ b/src/c/matrixOperations/triu/u8triua.c @@ -0,0 +1,34 @@ +// 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: Siddhesh Wani +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in + +//Function to extract lower triagular entries from given matrix + +#include "triu.h" + +void u8triua (uint8 *in, int row, int column, double diag, uint8 *out) +{ + int row_counter, col_counter = 0; + + for(row_counter=0; row_counter < row; row_counter++) + { + for(col_counter=0; col_counter < column; col_counter++) + { + if((double)(row_counter + diag) <= (double)col_counter) + { + out[col_counter*row+row_counter] = in[col_counter*row+row_counter]; + } + else + { + out[col_counter*row+row_counter] = 0; + } + } + } +}
\ No newline at end of file diff --git a/src/c/scilab-arduino/includes/cmd_analog_in.h b/src/c/scilab-arduino/includes/cmd_analog_in.h index 5361fe8..1ab9f3a 100644 --- a/src/c/scilab-arduino/includes/cmd_analog_in.h +++ b/src/c/scilab-arduino/includes/cmd_analog_in.h @@ -26,4 +26,4 @@ uint16 u8cmd_analog_ins(uint8 board_no, uint8 pin); } /* extern "C" */ #endif -#endif /* __CMD_DIGITAL_IN_H__ */ +#endif /* __CMD_ANALOG_IN_H__ */ |