summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c/differential_calculus/diff/ddiffca.c203
-rw-r--r--src/c/differential_calculus/diff/i16diffca.c203
-rw-r--r--src/c/differential_calculus/diff/i8diffca.c203
-rw-r--r--src/c/differential_calculus/diff/sdiffca.c203
-rw-r--r--src/c/differential_calculus/diff/u16dissca.c203
-rw-r--r--src/c/differential_calculus/diff/u8diffca.c203
-rw-r--r--src/c/differential_calculus/includes/diffc.h37
-rw-r--r--src/c/differential_calculus/interfaces/int_diffc.h105
-rw-r--r--src/c/elementaryFunctions/nthroot/dnthroot.c0
-rw-r--r--src/c/matrixOperations/includes/norm.h32
-rw-r--r--src/c/matrixOperations/interfaces/int_norm.h53
-rw-r--r--src/c/matrixOperations/norm/dnorma.c72
-rw-r--r--src/c/matrixOperations/norm/dnormv.c60
-rw-r--r--src/c/matrixOperations/norm/snorma.c72
-rw-r--r--src/c/matrixOperations/norm/snormv.c60
15 files changed, 1709 insertions, 0 deletions
diff --git a/src/c/differential_calculus/diff/ddiffca.c b/src/c/differential_calculus/diff/ddiffca.c
new file mode 100644
index 0000000..92727da
--- /dev/null
+++ b/src/c/differential_calculus/diff/ddiffca.c
@@ -0,0 +1,203 @@
+/* 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
+*/
+
+ /* This function calculates difference between adjacent members of given
+ input array/matrix */
+
+#include "diffc.h"
+
+
+void ddiffca(double *in, int row, int col, int depth, int dim, double *out)
+{
+ int counter, depth_count;
+ int row_count, col_count;
+ double *buffer; /*To store intermediate results*/
+
+ depth_count = 1;
+
+ if(dim == 0)
+ { /*For dim = 0, we calculate difference between adjacent elements
+ in case of arrays. In case of matrices, we calculate difference along
+ first column, and then continue to second (diff between first element
+ of second column and last element of first column, then third etc.*/
+ if(depth == 1)
+ {/*for depth=1, a buffer is not needed. Directly write result in
+ out buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else
+ { /*define buffer for storing intermediate results*/
+
+ buffer = (double *) malloc (sizeof(double)*(row*col-1));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*calculate diff and store in buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ buffer[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(counter = 0; counter <= row*col - depth_count ; counter++)
+ {
+ buffer[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ /*For last step use output buffer to store result*/
+ else
+ {
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ depth_count += 1;
+ }
+ }
+
+ }
+ else if(dim == 1)
+ {
+ /*For dim = 1, difference is calculated along rows. Each element of
+ first row is subtracted from corresponding element of second row and
+ result is stored in first row. Same thing is repeated till last row. */
+
+ if (depth == 1)
+ {
+ /*If depth is 1, store result directly in out buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (double *) malloc (sizeof(double)*((row-1)*col));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*For first step, use in buffer and store results in buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \
+ - in[col_count*row + row_count];
+ }
+
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \
+ - buffer[col_count*row + row_count];
+ }
+
+ }
+ }
+ else
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count +=1;
+ }
+ }
+ }
+ else if(dim == 2)
+ {
+ /*For dim = 2, difference is calculated along columns. Each element of
+ first column is subtracted from corresponding element of second column
+ and result is stored in first column. Same thing is repeated till last
+ column. */
+ if(depth == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (double *) malloc (sizeof(double)*(row*(col-1)));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count += 1;
+ }
+ }
+ }
+}
diff --git a/src/c/differential_calculus/diff/i16diffca.c b/src/c/differential_calculus/diff/i16diffca.c
new file mode 100644
index 0000000..d1c70a5
--- /dev/null
+++ b/src/c/differential_calculus/diff/i16diffca.c
@@ -0,0 +1,203 @@
+/* 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
+*/
+
+ /* This function calculates difference between adjacent members of given
+ input array/matrix */
+
+#include "diffc.h"
+
+
+void i16diffca(int16 *in, int row, int col, int depth, int dim, int16 *out)
+{
+ int counter, depth_count;
+ int row_count, col_count;
+ int16 *buffer; /*To store intermediate results*/
+
+ depth_count = 1;
+
+ if(dim == 0)
+ { /*For dim = 0, we calculate difference between adjacent elements
+ in case of arrays. In case of matrices, we calculate difference along
+ first column, and then continue to second (diff between first element
+ of second column and last element of first column, then third etc.*/
+ if(depth == 1)
+ {/*for depth=1, a buffer is not needed. Directly write result in
+ out buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else
+ { /*define buffer for storing intermediate results*/
+
+ buffer = (int16 *) malloc (sizeof(int16)*(row*col-1));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*calculate diff and store in buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ buffer[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(counter = 0; counter <= row*col - depth_count ; counter++)
+ {
+ buffer[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ /*For last step use output buffer to store result*/
+ else
+ {
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ depth_count += 1;
+ }
+ }
+
+ }
+ else if(dim == 1)
+ {
+ /*For dim = 1, difference is calculated along rows. Each element of
+ first row is subtracted from corresponding element of second row and
+ result is stored in first row. Same thing is repeated till last row. */
+
+ if (depth == 1)
+ {
+ /*If depth is 1, store result directly in out buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (int16 *) malloc (sizeof(int16)*((row-1)*col));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*For first step, use in buffer and store results in buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \
+ - in[col_count*row + row_count];
+ }
+
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \
+ - buffer[col_count*row + row_count];
+ }
+
+ }
+ }
+ else
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count +=1;
+ }
+ }
+ }
+ else if(dim == 2)
+ {
+ /*For dim = 2, difference is calculated along columns. Each element of
+ first column is subtracted from corresponding element of second column
+ and result is stored in first column. Same thing is repeated till last
+ column. */
+ if(depth == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (int16 *) malloc (sizeof(int16)*(row*(col-1)));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count += 1;
+ }
+ }
+ }
+}
diff --git a/src/c/differential_calculus/diff/i8diffca.c b/src/c/differential_calculus/diff/i8diffca.c
new file mode 100644
index 0000000..7b76f96
--- /dev/null
+++ b/src/c/differential_calculus/diff/i8diffca.c
@@ -0,0 +1,203 @@
+/* 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
+*/
+
+ /* This function calculates difference between adjacent members of given
+ input array/matrix */
+
+#include "diffc.h"
+
+
+void i8diffca(int8 *in, int row, int col, int depth, int dim, int8 *out)
+{
+ int counter, depth_count;
+ int row_count, col_count;
+ int8 *buffer; /*To store intermediate results*/
+
+ depth_count = 1;
+
+ if(dim == 0)
+ { /*For dim = 0, we calculate difference between adjacent elements
+ in case of arrays. In case of matrices, we calculate difference along
+ first column, and then continue to second (diff between first element
+ of second column and last element of first column, then third etc.*/
+ if(depth == 1)
+ {/*for depth=1, a buffer is not needed. Directly write result in
+ out buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else
+ { /*define buffer for storing intermediate results*/
+
+ buffer = (int8 *) malloc (sizeof(int8)*(row*col-1));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*calculate diff and store in buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ buffer[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(counter = 0; counter <= row*col - depth_count ; counter++)
+ {
+ buffer[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ /*For last step use output buffer to store result*/
+ else
+ {
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ depth_count += 1;
+ }
+ }
+
+ }
+ else if(dim == 1)
+ {
+ /*For dim = 1, difference is calculated along rows. Each element of
+ first row is subtracted from corresponding element of second row and
+ result is stored in first row. Same thing is repeated till last row. */
+
+ if (depth == 1)
+ {
+ /*If depth is 1, store result directly in out buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (int8 *) malloc (sizeof(int8)*((row-1)*col));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*For first step, use in buffer and store results in buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \
+ - in[col_count*row + row_count];
+ }
+
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \
+ - buffer[col_count*row + row_count];
+ }
+
+ }
+ }
+ else
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count +=1;
+ }
+ }
+ }
+ else if(dim == 2)
+ {
+ /*For dim = 2, difference is calculated along columns. Each element of
+ first column is subtracted from corresponding element of second column
+ and result is stored in first column. Same thing is repeated till last
+ column. */
+ if(depth == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (int8 *) malloc (sizeof(int8)*(row*(col-1)));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count += 1;
+ }
+ }
+ }
+}
diff --git a/src/c/differential_calculus/diff/sdiffca.c b/src/c/differential_calculus/diff/sdiffca.c
new file mode 100644
index 0000000..67526ad
--- /dev/null
+++ b/src/c/differential_calculus/diff/sdiffca.c
@@ -0,0 +1,203 @@
+/* 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
+*/
+
+ /* This function calculates difference between adjacent members of given
+ input array/matrix */
+
+#include "diffc.h"
+
+
+void sdiffca(float *in, int row, int col, int depth, int dim, float *out)
+{
+ int counter, depth_count;
+ int row_count, col_count;
+ float *buffer; /*To store intermediate results*/
+
+ depth_count = 1;
+
+ if(dim == 0)
+ { /*For dim = 0, we calculate difference between adjacent elements
+ in case of arrays. In case of matrices, we calculate difference along
+ first column, and then continue to second (diff between first element
+ of second column and last element of first column, then third etc.*/
+ if(depth == 1)
+ {/*for depth=1, a buffer is not needed. Directly write result in
+ out buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else
+ { /*define buffer for storing intermediate results*/
+
+ buffer = (float *) malloc (sizeof(float)*(row*col-1));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*calculate diff and store in buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ buffer[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(counter = 0; counter <= row*col - depth_count ; counter++)
+ {
+ buffer[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ /*For last step use output buffer to store result*/
+ else
+ {
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ depth_count += 1;
+ }
+ }
+
+ }
+ else if(dim == 1)
+ {
+ /*For dim = 1, difference is calculated along rows. Each element of
+ first row is subtracted from corresponding element of second row and
+ result is stored in first row. Same thing is repeated till last row. */
+
+ if (depth == 1)
+ {
+ /*If depth is 1, store result directly in out buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (float *) malloc (sizeof(float)*((row-1)*col));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*For first step, use in buffer and store results in buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \
+ - in[col_count*row + row_count];
+ }
+
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \
+ - buffer[col_count*row + row_count];
+ }
+
+ }
+ }
+ else
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count +=1;
+ }
+ }
+ }
+ else if(dim == 2)
+ {
+ /*For dim = 2, difference is calculated along columns. Each element of
+ first column is subtracted from corresponding element of second column
+ and result is stored in first column. Same thing is repeated till last
+ column. */
+ if(depth == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (float *) malloc (sizeof(float)*(row*(col-1)));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count += 1;
+ }
+ }
+ }
+}
diff --git a/src/c/differential_calculus/diff/u16dissca.c b/src/c/differential_calculus/diff/u16dissca.c
new file mode 100644
index 0000000..d83a9e6
--- /dev/null
+++ b/src/c/differential_calculus/diff/u16dissca.c
@@ -0,0 +1,203 @@
+/* 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
+*/
+
+ /* This function calculates difference between adjacent members of given
+ input array/matrix */
+
+#include "diffc.h"
+
+
+void u16diffca(uint16 *in, int row, int col, int depth, int dim, uint16 *out)
+{
+ int counter, depth_count;
+ int row_count, col_count;
+ uint16 *buffer; /*To store intermediate results*/
+
+ depth_count = 1;
+
+ if(dim == 0)
+ { /*For dim = 0, we calculate difference between adjacent elements
+ in case of arrays. In case of matrices, we calculate difference along
+ first column, and then continue to second (diff between first element
+ of second column and last element of first column, then third etc.*/
+ if(depth == 1)
+ {/*for depth=1, a buffer is not needed. Directly write result in
+ out buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else
+ { /*define buffer for storing intermediate results*/
+
+ buffer = (uint16 *) malloc (sizeof(uint16)*(row*col-1));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*calculate diff and store in buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ buffer[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(counter = 0; counter <= row*col - depth_count ; counter++)
+ {
+ buffer[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ /*For last step use output buffer to store result*/
+ else
+ {
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ depth_count += 1;
+ }
+ }
+
+ }
+ else if(dim == 1)
+ {
+ /*For dim = 1, difference is calculated along rows. Each element of
+ first row is subtracted from corresponding element of second row and
+ result is stored in first row. Same thing is repeated till last row. */
+
+ if (depth == 1)
+ {
+ /*If depth is 1, store result directly in out buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (uint16 *) malloc (sizeof(uint16)*((row-1)*col));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*For first step, use in buffer and store results in buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \
+ - in[col_count*row + row_count];
+ }
+
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \
+ - buffer[col_count*row + row_count];
+ }
+
+ }
+ }
+ else
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count +=1;
+ }
+ }
+ }
+ else if(dim == 2)
+ {
+ /*For dim = 2, difference is calculated along columns. Each element of
+ first column is subtracted from corresponding element of second column
+ and result is stored in first column. Same thing is repeated till last
+ column. */
+ if(depth == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (uint16 *) malloc (sizeof(uint16)*(row*(col-1)));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count += 1;
+ }
+ }
+ }
+}
diff --git a/src/c/differential_calculus/diff/u8diffca.c b/src/c/differential_calculus/diff/u8diffca.c
new file mode 100644
index 0000000..567ff8e
--- /dev/null
+++ b/src/c/differential_calculus/diff/u8diffca.c
@@ -0,0 +1,203 @@
+/* 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
+*/
+
+ /* This function calculates difference between adjacent members of given
+ input array/matrix */
+
+#include "diffc.h"
+
+
+void u8diffca(uint8 *in, int row, int col, int depth, int dim, uint8 *out)
+{
+ int counter, depth_count;
+ int row_count, col_count;
+ uint8 *buffer; /*To store intermediate results*/
+
+ depth_count = 1;
+
+ if(dim == 0)
+ { /*For dim = 0, we calculate difference between adjacent elements
+ in case of arrays. In case of matrices, we calculate difference along
+ first column, and then continue to second (diff between first element
+ of second column and last element of first column, then third etc.*/
+ if(depth == 1)
+ {/*for depth=1, a buffer is not needed. Directly write result in
+ out buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else
+ { /*define buffer for storing intermediate results*/
+
+ buffer = (uint8 *) malloc (sizeof(uint8)*(row*col-1));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*calculate diff and store in buffer*/
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ buffer[counter] = in[counter+1] - in[counter];
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(counter = 0; counter <= row*col - depth_count ; counter++)
+ {
+ buffer[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ /*For last step use output buffer to store result*/
+ else
+ {
+ for(counter = 0; counter < row*col - depth_count; counter++)
+ {
+ out[counter] = buffer[counter+1] - buffer[counter];
+ }
+ }
+ depth_count += 1;
+ }
+ }
+
+ }
+ else if(dim == 1)
+ {
+ /*For dim = 1, difference is calculated along rows. Each element of
+ first row is subtracted from corresponding element of second row and
+ result is stored in first row. Same thing is repeated till last row. */
+
+ if (depth == 1)
+ {
+ /*If depth is 1, store result directly in out buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ out[col_count*(row-1)+row_count] = in[col_count*row + row_count+1] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (uint8 *) malloc (sizeof(uint8)*((row-1)*col));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ /*For first step, use in buffer and store results in buffer*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - 1; row_count++)
+ {
+ buffer[col_count*row+row_count] = in[col_count*row + row_count + 1] \
+ - in[col_count*row + row_count];
+ }
+
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[col_count*row + row_count + 1] \
+ - buffer[col_count*row + row_count];
+ }
+
+ }
+ }
+ else
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ for(row_count = 0; row_count < row - depth_count; row_count++)
+ {
+ out[col_count*(row-depth_count)+row_count] = buffer[col_count*row + row_count+1] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count +=1;
+ }
+ }
+ }
+ else if(dim == 2)
+ {
+ /*For dim = 2, difference is calculated along columns. Each element of
+ first column is subtracted from corresponding element of second column
+ and result is stored in first column. Same thing is repeated till last
+ column. */
+ if(depth == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ out[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ /*If depth is not 1, declare a buffer to store intermediate
+ results. At last step store result into out buffer*/
+ buffer = (uint8 *) malloc (sizeof(uint8)*(row*(col-1)));
+
+ while(depth_count <= depth)
+ {
+ if(depth_count == 1)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - 1; col_count++)
+ {
+ buffer[col_count*row+row_count] = in[(col_count+1)*row + row_count] \
+ - in[col_count*row + row_count];
+ }
+ }
+ }
+ else if(depth_count < depth)
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ buffer[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ else
+ {
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col - depth_count; col_count++)
+ {
+ out[col_count*row+row_count] = buffer[(col_count+1)*row + row_count] \
+ - buffer[col_count*row + row_count];
+ }
+ }
+ }
+ depth_count += 1;
+ }
+ }
+ }
+}
diff --git a/src/c/differential_calculus/includes/diffc.h b/src/c/differential_calculus/includes/diffc.h
new file mode 100644
index 0000000..7d266f1
--- /dev/null
+++ b/src/c/differential_calculus/includes/diffc.h
@@ -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
+ */
+#ifndef __DIFFC_H__
+#define __DIFFC_H__
+
+#include "types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void ddiffca(double *in, int row, int col, int depth, int dim, double *out);
+
+void sdiffca(float *in, int row, int col, int depth, int dim, float *out);
+
+void u8diffca(uint8 *in, int row, int col, int depth, int dim, uint8 *out);
+
+void i8diffca(int8 *in, int row, int col, int depth, int dim, int8 *out);
+
+void u16diffca(uint16 *in, int row, int col, int depth, int dim, uint16 *out);
+
+void i16diffca(int16 *in, int row, int col, int depth, int dim, int16 *out);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__DIFFC_H__*/
diff --git a/src/c/differential_calculus/interfaces/int_diffc.h b/src/c/differential_calculus/interfaces/int_diffc.h
new file mode 100644
index 0000000..3c03242
--- /dev/null
+++ b/src/c/differential_calculus/interfaces/int_diffc.h
@@ -0,0 +1,105 @@
+ /* 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_DIFFC_H__
+#define __INT_DIFFC_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define d2diffd2(in, size, out) ddiffca(in, size[0], size[1], 1, 0, out)
+
+#define d2d0diffd2(in, size, depth, out) ddiffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define d2d0d0diffd2(in, size, depth, dim, out) ddiffca(in, size[0], size[1], \
+ depth, dim, out)
+
+#define s2diffs2(in, size, out) sdiffca(in, size[0], size[1], 1, 0, out)
+
+#define s2d0diffs2(in, size, depth, out) sdiffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define s2s0diffs2(in, size, depth, out) sdiffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define s2s0d0diffs2(in, size, depth, dim, out) sdiffca(in, size[0], size[1], \
+ depth, dim, out)
+
+#define s2d0d0diffs2(in, size, depth, dim, out) sdiffca(in, size[0], size[1], \
+ depth, dim, out)
+
+#define u82diffu82(in, size, out) u8diffca(in, size[0], size[1], 1, 0, out)
+
+#define u82d0diffu82(in, size, depth, out) u8diffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define u82u80diffu82(in, size, depth, out) u8diffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define u82u80d0diffu82(in, size, depth, dim, out) u8diffca(in, size[0], size[1], \
+ depth, dim, out)
+
+
+#define u82d0d0diffu82(in, size, depth, dim, out) u8diffca(in, size[0], size[1], \
+ depth, dim, out)
+
+#define i82diffi82(in, size, out) i8diffca(in, size[0], size[1], 1, 0, out)
+
+#define i82d0diffi82(in, size, depth, out) i8diffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define i82u80diffi82(in, size, depth, out) i8diffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define i82u80d0diffi82(in, size, depth, dim, out) i8diffca(in, size[0], size[1], \
+ depth, dim, out)
+
+
+#define i82d0d0diffi82(in, size, depth, dim, out) i8diffca(in, size[0], size[1], \
+ depth, dim, out)
+
+#define u162diffu162(in, size, out) u16diffca(in, size[0], size[1], 1, 0, out)
+
+#define u162d0diffu162(in, size, depth, out) u16diffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define u162u160diffu162(in, size, depth, out) u16diffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define u162u160d0diffu162(in, size, depth, dim, out) u16diffca(in, size[0], size[1], \
+ depth, dim, out)
+
+
+#define u162d0d0diffu162(in, size, depth, dim, out) u16diffca(in, size[0], size[1], \
+ depth, dim, out)
+
+#define i162diffi162(in, size, out) i16diffca(in, size[0], size[1], 1, 0, out)
+
+#define i162d0diffi162(in, size, depth, out) i16diffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define i162u160diffi162(in, size, depth, out) i16diffca (in, size[0], size[1], \
+ depth, 0, out)
+
+#define i162u160d0diffi162(in, size, depth, dim, out) i16diffca(in, size[0], size[1], \
+ depth, dim, out)
+
+
+#define i162d0d0diffi162(in, size, depth, dim, out) i16diffca(in, size[0], size[1], \
+ depth, dim, out)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_DIFFC_H__*/
diff --git a/src/c/elementaryFunctions/nthroot/dnthroot.c b/src/c/elementaryFunctions/nthroot/dnthroot.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/c/elementaryFunctions/nthroot/dnthroot.c
diff --git a/src/c/matrixOperations/includes/norm.h b/src/c/matrixOperations/includes/norm.h
new file mode 100644
index 0000000..6ac4c06
--- /dev/null
+++ b/src/c/matrixOperations/includes/norm.h
@@ -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
+ */
+#ifndef __NORM_H__
+#define __NORM_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+double dnormv (double *in, int size, int norm);
+
+double dnorma (double *in, int row, int col, int norm);
+
+float dnormv (float *in, int size, int norm);
+
+float dnorma (float *in, int row, int col, int norm);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__NORM_H__*/
diff --git a/src/c/matrixOperations/interfaces/int_norm.h b/src/c/matrixOperations/interfaces/int_norm.h
new file mode 100644
index 0000000..a42a675
--- /dev/null
+++ b/src/c/matrixOperations/interfaces/int_norm.h
@@ -0,0 +1,53 @@
+ /* 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_NORM_H__
+#define __INT_NORM_H__
+
+#include "statMax.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define d0normd0(in) in
+#define s0norms0(in) in
+
+#define d2normd0(in,size,out) ((size[0] == 1) || (size[1]==1))? \
+ dnormv(in, size[0]*size[1], 2): \
+ dnorma(in, size[0], size[1], 2)
+
+#define s2norms0(in,size,out) ((size[0] == 1) || (size[1]==1))? \
+ snormv(in, size[0]*size[1], 2): \
+ snorma(in, size[0], size[1], 2)
+
+#define d2d0normd0(in,size,norm) ((size[0] == 1) || (size[1]==1))? \
+ dnormv(in,size[0]*size[1],norm) : \
+ dnorma(in,size[0],size[1],norm)
+
+#define s2s0norms0(in,size,norm) ((size[0] == 1) || (size[1]==1))? \
+ snormv(in,size[0]*size[1],norm) : \
+ snorma(in,size[0],size[1],norm)
+
+#define d2g2normd0(in,size,norm,normsize) ((size[0] == 1) || (size[1]==1))? \
+ (norm[0]=='i') ? dmaxa(in,size[0]*size[1]) : dnormv(in,size[0]*size[1],2) : \
+ (norm[0]=='i') ? dnorma(in,size[0],size[1],3) : dnorma(in,size[0],size[1],4)
+
+#define s2g2norms0(in,size,norm,normsize) ((size[0] == 1) || (size[1]==1))? \
+ (norm[0]=='i') ? smaxa(in,size[0]*size[1]) : snormv(in,size[0]*size[1],2) : \
+ (norm[0]=='i') ? snorma(in,size[0],size[1],3) : snorma(in,size[0],size[1],4)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /*__INT_NORM_H__*/
diff --git a/src/c/matrixOperations/norm/dnorma.c b/src/c/matrixOperations/norm/dnorma.c
new file mode 100644
index 0000000..c912f85
--- /dev/null
+++ b/src/c/matrixOperations/norm/dnorma.c
@@ -0,0 +1,72 @@
+ /* 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
+ */
+
+ /*This function calculates norms for matrices*/
+ /*Acceptable norms are: 1, 2, 'inf', 'fro', */
+
+#include "norm.h"
+#include <math.h>
+
+double dnorma (double *in, int row, int col, int norm)
+{
+ double res = 0, sum = 0;
+ int col_count, row_count;
+
+ switch (norm)
+ {
+ case 1: /*largest column sum*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ sum = 0;
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ sum += in[col_count*row+row_count];
+ }
+ if (sum >= res)
+ res = sum;
+ }
+ break;
+
+ case 2: /*Largest singular value of the matrix*/
+ break;
+
+ case 3: /*inf: largest row sum*/
+
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ sum = 0;
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ sum += in[col_count*row + row_count];
+ }
+ if(sum >= res)
+ res = sum;
+ }
+ break;
+
+ case 4: /*Frobenius norm*/
+
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ sum += in[col_count*row + row_count] * in[col_count*row + row_count];
+ }
+ }
+ res = sqrt(sum);
+
+ break;
+ }
+
+
+ return res;
+} \ No newline at end of file
diff --git a/src/c/matrixOperations/norm/dnormv.c b/src/c/matrixOperations/norm/dnormv.c
new file mode 100644
index 0000000..5d20d60
--- /dev/null
+++ b/src/c/matrixOperations/norm/dnormv.c
@@ -0,0 +1,60 @@
+ /* 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
+ */
+
+ /*This function calculates norms for vectors (row or column)*/
+
+#include "norm.h"
+#include <math.h>
+
+double dnormv (double *in, int size, int norm)
+{
+ double sum = 0;
+ double res = 0;
+ int counter = 0;
+
+ switch (norm)
+ {
+ case 0:
+ res = INFINITY;
+ break;
+ case 1: /*Addition of all elements*/
+ for (counter=0; counter < size; counter++)
+ {
+ sum += in[counter];
+ }
+ res = sum;
+ break;
+ case 2: /*Square root of addition of squares of all elements*/
+ for (counter=0; counter < size; counter++)
+ {
+ sum += in[counter]*in[counter];
+ }
+ res = sqrt(sum);
+ break;
+ case 3: /*Cube root of addition of cubes of all elements*/
+ for (counter=0; counter < size; counter++)
+ {
+ sum += pow(in[counter],3);
+ }
+ res = cbrt(sum);
+ break;
+ default : /*Nth root of addition of all elements raised to n*/
+ for (counter=0; counter < size; counter++)
+ {
+ sum += pow(in[counter],norm);
+ }
+ res = pow(sum, 1./norm);
+ break;
+ }
+
+ return res;
+} \ No newline at end of file
diff --git a/src/c/matrixOperations/norm/snorma.c b/src/c/matrixOperations/norm/snorma.c
new file mode 100644
index 0000000..4bf2ccd
--- /dev/null
+++ b/src/c/matrixOperations/norm/snorma.c
@@ -0,0 +1,72 @@
+ /* 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
+ */
+
+ /*This function calculates norms for matrices*/
+ /*Acceptable norms are: 1, 2, 'inf', 'fro', */
+
+#include "norm.h"
+#include <math.h>
+
+float dnorma (float *in, int row, int col, int norm)
+{
+ float res = 0, sum = 0;
+ int col_count, row_count;
+
+ switch (norm)
+ {
+ case 1: /*largest column sum*/
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ sum = 0;
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ sum += in[col_count*row+row_count];
+ }
+ if (sum >= res)
+ res = sum;
+ }
+ break;
+
+ case 2: /*Largest singular value of the matrix*/
+ break;
+
+ case 3: /*inf: largest row sum*/
+
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ sum = 0;
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ sum += in[col_count*row + row_count];
+ }
+ if(sum >= res)
+ res = sum;
+ }
+ break;
+
+ case 4: /*Frobenius norm*/
+
+ for(row_count = 0; row_count < row; row_count++)
+ {
+ for(col_count = 0; col_count < col; col_count++)
+ {
+ sum += in[col_count*row + row_count] * in[col_count*row + row_count];
+ }
+ }
+ res = sqrt(sum);
+
+ break;
+ }
+
+
+ return res;
+} \ No newline at end of file
diff --git a/src/c/matrixOperations/norm/snormv.c b/src/c/matrixOperations/norm/snormv.c
new file mode 100644
index 0000000..03e9ed6
--- /dev/null
+++ b/src/c/matrixOperations/norm/snormv.c
@@ -0,0 +1,60 @@
+ /* 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
+ */
+
+ /*This function calculates norms for vectors (row or column)*/
+
+#include "norm.h"
+#include <math.h>
+
+float dnormv (float *in, int size, int norm)
+{
+ float sum = 0;
+ float res = 0;
+ int counter = 0;
+
+ switch (norm)
+ {
+ case 0:
+ res = INFINITY;
+ break;
+ case 1: /*Addition of all elements*/
+ for (counter=0; counter < size; counter++)
+ {
+ sum += in[counter];
+ }
+ res = sum;
+ break;
+ case 2: /*Square root of addition of squares of all elements*/
+ for (counter=0; counter < size; counter++)
+ {
+ sum += in[counter]*in[counter];
+ }
+ res = sqrt(sum);
+ break;
+ case 3: /*Cube root of addition of cubes of all elements*/
+ for (counter=0; counter < size; counter++)
+ {
+ sum += pow(in[counter],3);
+ }
+ res = cbrt(sum);
+ break;
+ default : /*Nth root of addition of all elements raised to n*/
+ for (counter=0; counter < size; counter++)
+ {
+ sum += pow(in[counter],norm);
+ }
+ res = pow(sum, 1./norm);
+ break;
+ }
+
+ return res;
+} \ No newline at end of file