diff options
author | Brijeshcr | 2017-07-07 16:43:27 +0530 |
---|---|---|
committer | Brijeshcr | 2017-07-07 16:43:27 +0530 |
commit | 46da80312c4bc66bb5f16044c5c5597ac259d419 (patch) | |
tree | 34796b1bca87abf2b3e1530bd2af5b07e2cfd184 /2.3-1/src/c | |
parent | 850c0ff1ca5cd660b76d0568a215bab0547312ad (diff) | |
download | Scilab2C-46da80312c4bc66bb5f16044c5c5597ac259d419.tar.gz Scilab2C-46da80312c4bc66bb5f16044c5c5597ac259d419.tar.bz2 Scilab2C-46da80312c4bc66bb5f16044c5c5597ac259d419.zip |
Toeplitz Added
Diffstat (limited to '2.3-1/src/c')
-rw-r--r-- | 2.3-1/src/c/matrixOperations/includes/toeplitz.h | 37 | ||||
-rw-r--r-- | 2.3-1/src/c/matrixOperations/interfaces/int_toeplitz.h | 50 | ||||
-rw-r--r-- | 2.3-1/src/c/matrixOperations/toeplitz/ctoeplitza.c | 36 | ||||
-rw-r--r-- | 2.3-1/src/c/matrixOperations/toeplitz/dtoeplitza.c | 33 | ||||
-rw-r--r-- | 2.3-1/src/c/matrixOperations/toeplitz/gtoeplitza.c | 35 | ||||
-rw-r--r-- | 2.3-1/src/c/matrixOperations/toeplitz/i16toeplitza.c | 32 | ||||
-rw-r--r-- | 2.3-1/src/c/matrixOperations/toeplitz/i8toeplitza.c | 33 | ||||
-rw-r--r-- | 2.3-1/src/c/matrixOperations/toeplitz/stoeplitza.c | 32 | ||||
-rw-r--r-- | 2.3-1/src/c/matrixOperations/toeplitz/u16toeplitza.c | 33 | ||||
-rw-r--r-- | 2.3-1/src/c/matrixOperations/toeplitz/u8toeplitza.c | 33 | ||||
-rw-r--r-- | 2.3-1/src/c/matrixOperations/toeplitz/ztoeplitza.c | 36 |
11 files changed, 390 insertions, 0 deletions
diff --git a/2.3-1/src/c/matrixOperations/includes/toeplitz.h b/2.3-1/src/c/matrixOperations/includes/toeplitz.h new file mode 100644 index 00000000..7384b43c --- /dev/null +++ b/2.3-1/src/c/matrixOperations/includes/toeplitz.h @@ -0,0 +1,37 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ + +#ifndef __TOEPLITZ_H__ +#define __TOEPLITZ_H__ +#include "types.h" +#include "doubleComplex.h" +#include "floatComplex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void dtoeplitza(double* inp1,int size1,double* inp2,int size2,double* oup); +void u8toeplitza(uint8* inp1,int size1,uint8* inp2,int size2,uint8* oup); +void u16toeplitza(uint16* inp1,int size1,uint16* inp2,int size2,uint16* oup); +void ztoeplitza(doubleComplex* inp1,int size1,doubleComplex* inp2,int size2,doubleComplex* oup); +void gtoeplitza(char* inp1,int size1,char* inp2,int size2,char* oup); +void stoeplitza(float* inp1,int size1,float* inp2,int size2,float* oup); +void ctoeplitza(floatComplex* inp1,int size1,floatComplex* inp2,int size2,floatComplex* oup); +void i8toeplitza(int8* inp1,int size1,int8* inp2,int size2,int8* oup); +void i16toeplitza(int16* inp1,int size1,int16* inp2,int size2,int16* oup); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__TOEPLITZ_H__*/ diff --git a/2.3-1/src/c/matrixOperations/interfaces/int_toeplitz.h b/2.3-1/src/c/matrixOperations/interfaces/int_toeplitz.h new file mode 100644 index 00000000..b602e9a8 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/interfaces/int_toeplitz.h @@ -0,0 +1,50 @@ + /* Copyright (C) 2017 - IIT Bombay - FOSSEE + + This file must be used under the terms of the CeCILL. + This source file is licensed as described in the file COPYING, which + you should have received as part of this distribution. The terms + are also available at + http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + Author: Brijesh Gupta C R + Organization: FOSSEE, IIT Bombay + Email: toolbox@scilab.in + */ +#ifndef __INT_TOEPLITZ_H__ +#define __INT_TOEPLITZ_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define d2d2toeplitzd2(in1,size1,in2,size2,out) dtoeplitza(in1,size1[1],in2,size2[1],out) +#define d2toeplitzd2(in1,size1,out) dtoeplitza(in1,size1[1],in1,size1[1],out) + +#define u82u82toeplitzu82(in1,size1,in2,size2,out) u8toeplitza(in1,size1[1],in2,size2[1],out) +#define u82toeplitzu82(in1,size1,out) u8toeplitza(in1,size1[1],in1,size1[1],out) + +#define u162u162toeplitzu162(in1,size1,in2,size2,out) u16toeplitza(in1,size1[1],in2,size2[1],out) +#define u162toeplitzu162(in1,size1,out) u16toeplitza(in1,size1[1],in1,size1[1],out) + +#define g2g2toeplitzg2(in1,size1,in2,size2,out) gtoeplitza(in1,size1[1],in2,size2[1],out) +#define g2toeplitzg2(in1,size1,out) gtoeplitza(in1,size1[1],in1,size1[1],out) + +#define z2z2toeplitzz2(in1,size1,in2,size2,out) ztoeplitza(in1,size1[1],in2,size2[1],out) +#define z2toeplitzz2(in1,size1,out) ztoeplitza(in1,size1[1],in1,size1[1],out) + +#define s2s2toeplitzs2(in1,size1,in2,size2,out) stoeplitza(in1,size1[1],in2,size2[1],out) +#define s2toeplitzs2(in1,size1,out) stoeplitza(in1,size1[1],in1,size1[1],out) + +#define c2c2toeplitzc2(in1,size1,in2,size2,out) ctoeplitza(in1,size1[1],in2,size2[1],out) +#define c2toeplitzc2(in1,size1,out) ctoeplitza(in1,size1[1],in1,size1[1],out) + +#define i82i82toeplitzi82(in1,size1,in2,size2,out) i8toeplitza(in1,size1[1],in2,size2[1],out) +#define i82toeplitzi82(in1,size1,out) i8toeplitza(in1,size1[1],in1,size1[1],out) + +#define i162i162toeplitzi162(in1,size1,in2,size2,out) i16toeplitza(in1,size1[1],in2,size2[1],out) +#define i162toeplitzi162(in1,size1,out) i16toeplitza(in1,size1[1],in1,size1[1],out) + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /*__INT_TOEPLITZ_H__*/ diff --git a/2.3-1/src/c/matrixOperations/toeplitz/ctoeplitza.c b/2.3-1/src/c/matrixOperations/toeplitz/ctoeplitza.c new file mode 100644 index 00000000..048a367a --- /dev/null +++ b/2.3-1/src/c/matrixOperations/toeplitz/ctoeplitza.c @@ -0,0 +1,36 @@ +#include <stdio.h> +#include "toeplitz.h" +#include "floatComplex.h" +#include "stdlib.h" +#include "string.h" +#include "cat.h" + +/*Function to build a Toeplitz Matrix for inputs of SingleComplex datatype*/ + +void ctoeplitza(floatComplex* inp1,int size1,floatComplex* inp2,int size2,floatComplex* oup) +{ + if (inp1[0]!=inp2[0]) + { + printf("Error!The first elements of the Vectors are not equal."); // First element of both input vectors must be equal for Toeplitz. + return; + } + int i, j; + + for(i=0;i<size1*size2;i++) oup[i] = 0; // Initializing the output matrix with zeros. + + for (i = 0; i<size1; i++) + { + for (j = 0; j<size2; j++) + { + oup[j*size1] = inp2[j]; // Elements of the second input vector are copied to the first row of the Toeplitx Matrix. + } + oup[i] = inp1[i]; // Elements of the first input vector are copied to the first column of the Toeplitx Matrix. + } + for (i = size2+1; i<size1*size2; i++) // Loop to build the rest of the Toeplitz matrix. + { + if (oup[i] == 0) + oup[i] = oup[i-size2-1]; + } +} + + diff --git a/2.3-1/src/c/matrixOperations/toeplitz/dtoeplitza.c b/2.3-1/src/c/matrixOperations/toeplitz/dtoeplitza.c new file mode 100644 index 00000000..ef075a9a --- /dev/null +++ b/2.3-1/src/c/matrixOperations/toeplitz/dtoeplitza.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include "toeplitz.h" + + +/*Function to build a Toeplitz Matrix for inputs of Double datatype*/ + + +void dtoeplitza(double* inp1,int size1,double* inp2,int size2,double* oup) +{ + if (inp1[0]!=inp2[0]) + { + printf("Error!The first elements of the Vectors are not equal."); // First element of both input vectors must be equal for Toeplitz. + return; + } + int i, j; + + for(i=0;i<size1*size2;i++) oup[i] = 0; // Initializing the output matrix with zeros. + + for (i = 0; i<size1; i++) + { + for (j = 0; j<size2; j++) + { + oup[j*size1] = inp2[j]; // Elements of the second input vector are copied to the first row of the Toeplitx Matrix. + } + oup[i] = inp1[i]; // Elements of the first input vector are copied to the first column of the Toeplitx Matrix. + } + for (i = size2+1; i<size1*size2; i++) // Loop to build the rest of the Toeplitz matrix. + { + if (oup[i] == 0) + oup[i] = oup[i-size2-1]; + } +} + diff --git a/2.3-1/src/c/matrixOperations/toeplitz/gtoeplitza.c b/2.3-1/src/c/matrixOperations/toeplitz/gtoeplitza.c new file mode 100644 index 00000000..c852f92f --- /dev/null +++ b/2.3-1/src/c/matrixOperations/toeplitz/gtoeplitza.c @@ -0,0 +1,35 @@ +#include <stdio.h> +#include "toeplitz.h" + + +/*Function to build a Toeplitz Matrix for inputs of Character datatype*/ + + +void gtoeplitza(char* inp1,int size1,char* inp2,int size2,char* oup) +{ + if (inp1[0]!=inp2[0]) + { + printf("Error!The first elements of the Vectors are not equal."); // First element of both input vectors must be equal for Toeplitz. + return; + } + int i, j; + + for(i=0;i<size1*size2;i++) oup[i] = 0; // Initializing the output matrix with zeros. + + for (i = 0; i<size1; i++) + { + for (j = 0; j<size2; j++) + { + oup[j*size1] = inp2[j]; // Elements of the second input vector are copied to the first row of the Toeplitx Matrix. + } + oup[i] = inp1[i]; // Elements of the first input vector are copied to the first column of the Toeplitx Matrix. + } + for (i = size2+1; i<size1*size2; i++) // Loop to build the rest of the Toeplitz matrix. + { + if (oup[i] == 0) + oup[i] = oup[i-size2-1]; + } + +} + + diff --git a/2.3-1/src/c/matrixOperations/toeplitz/i16toeplitza.c b/2.3-1/src/c/matrixOperations/toeplitz/i16toeplitza.c new file mode 100644 index 00000000..945f626e --- /dev/null +++ b/2.3-1/src/c/matrixOperations/toeplitz/i16toeplitza.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include "toeplitz.h" +#include "int16.h" + +/*Function to build a Toeplitz Matrix for inputs of Signed Int16 datatype*/ + + +void i16toeplitza(int16* inp1,int size1,int16* inp2,int size2,int16* oup) +{ + if (inp1[0]!=inp2[0]) + { + printf("Error!The first elements of the Vectors are not equal."); // First element of both input vectors must be equal for Toeplitz. + return; + } + int i, j; + + for(i=0;i<size1*size2;i++) oup[i] = 0; // Initializing the output matrix with zeros. + + for (i = 0; i<size1; i++) + { + for (j = 0; j<size2; j++) + { + oup[j*size1] = inp2[j]; // Elements of the second input vector are copied to the first row of the Toeplitx Matrix. + } + oup[i] = inp1[i]; // Elements of the first input vector are copied to the first column of the Toeplitx Matrix. + } + for (i = size2+1; i<size1*size2; i++) // Loop to build the rest of the Toeplitz matrix. + { + if (oup[i] == 0) + oup[i] = oup[i-size2-1]; + } +} diff --git a/2.3-1/src/c/matrixOperations/toeplitz/i8toeplitza.c b/2.3-1/src/c/matrixOperations/toeplitz/i8toeplitza.c new file mode 100644 index 00000000..5075cc13 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/toeplitz/i8toeplitza.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include "toeplitz.h" +#include "int8.h" + + +/*Function to build a Toeplitz Matrix for inputs of Signed Int8 datatype*/ + + +void i8toeplitza(int8* inp1,int size1,int8* inp2,int size2,int8* oup) +{ + if (inp1[0]!=inp2[0]) + { + printf("Error!The first elements of the Vectors are not equal."); // First element of both input vectors must be equal for Toeplitz. + return; + } + int i, j; + + for(i=0;i<size1*size2;i++) oup[i] = 0; // Initializing the output matrix with zeros. + + for (i = 0; i<size1; i++) + { + for (j = 0; j<size2; j++) + { + oup[j*size1] = inp2[j]; // Elements of the second input vector are copied to the first row of the Toeplitx Matrix. + } + oup[i] = inp1[i]; // Elements of the first input vector are copied to the first column of the Toeplitx Matrix. + } + for (i = size2+1; i<size1*size2; i++) // Loop to build the rest of the Toeplitz matrix. + { + if (oup[i] == 0) + oup[i] = oup[i-size2-1]; + } +} diff --git a/2.3-1/src/c/matrixOperations/toeplitz/stoeplitza.c b/2.3-1/src/c/matrixOperations/toeplitz/stoeplitza.c new file mode 100644 index 00000000..11d91ce1 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/toeplitz/stoeplitza.c @@ -0,0 +1,32 @@ +#include <stdio.h> +#include "toeplitz.h" + + +/*Function to build a Toeplitz Matrix for inputs of Float datatype*/ + + +void stoeplitza(float* inp1,int size1,float* inp2,int size2,float* oup) +{ + if (inp1[0]!=inp2[0]) + { + printf("Error!The first elements of the Vectors are not equal."); // First element of both input vectors must be equal for Toeplitz. + return; + } + int i, j; + + for(i=0;i<size1*size2;i++) oup[i] = 0; // Initializing the output matrix with zeros. + + for (i = 0; i<size1; i++) + { + for (j = 0; j<size2; j++) + { + oup[j*size1] = inp2[j]; // Elements of the second input vector are copied to the first row of the Toeplitx Matrix. + } + oup[i] = inp1[i]; // Elements of the first input vector are copied to the first column of the Toeplitx Matrix. + } + for (i = size2+1; i<size1*size2; i++) // Loop to build the rest of the Toeplitz matrix. + { + if (oup[i] == 0) + oup[i] = oup[i-size2-1]; + } +} diff --git a/2.3-1/src/c/matrixOperations/toeplitz/u16toeplitza.c b/2.3-1/src/c/matrixOperations/toeplitz/u16toeplitza.c new file mode 100644 index 00000000..8dab5452 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/toeplitz/u16toeplitza.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include "toeplitz.h" +#include "uint16.h" + + +/*Function to build a Toeplitz Matrix for inputs of Unsigned Int16 datatype*/ + + +void u16toeplitza(uint16* inp1,int size1,uint16* inp2,int size2,uint16* oup) +{ + if (inp1[0]!=inp2[0]) + { + printf("Error!The first elements of the Vectors are not equal."); // First element of both input vectors must be equal for Toeplitz. + return; + } + int i, j; + + for(i=0;i<size1*size2;i++) oup[i] = 0; // Initializing the output matrix with zeros. + + for (i = 0; i<size1; i++) + { + for (j = 0; j<size2; j++) + { + oup[j*size1] = inp2[j]; // Elements of the second input vector are copied to the first row of the Toeplitx Matrix. + } + oup[i] = inp1[i]; // Elements of the first input vector are copied to the first column of the Toeplitx Matrix. + } + for (i = size2+1; i<size1*size2; i++) // Loop to build the rest of the Toeplitz matrix. + { + if (oup[i] == 0) + oup[i] = oup[i-size2-1]; + } +} diff --git a/2.3-1/src/c/matrixOperations/toeplitz/u8toeplitza.c b/2.3-1/src/c/matrixOperations/toeplitz/u8toeplitza.c new file mode 100644 index 00000000..8301fc16 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/toeplitz/u8toeplitza.c @@ -0,0 +1,33 @@ +#include <stdio.h> +#include "toeplitz.h" +#include "uint8.h" + + +/*Function to build a Toeplitz Matrix for inputs of Unsigned Int8 datatype*/ + + +void u8toeplitza(uint8* inp1,int size1,uint8* inp2,int size2,uint8* oup) +{ + if (inp1[0]!=inp2[0]) + { + printf("Error!The first elements of the Vectors are not equal."); // First element of both input vectors must be equal for Toeplitz. + return; + } + int i, j; + + for(i=0;i<size1*size2;i++) oup[i] = 0; // Initializing the output matrix with zeros. + + for (i = 0; i<size1; i++) + { + for (j = 0; j<size2; j++) + { + oup[j*size1] = inp2[j]; // Elements of the second input vector are copied to the first row of the Toeplitx Matrix. + } + oup[i] = inp1[i]; // Elements of the first input vector are copied to the first column of the Toeplitx Matrix. + } + for (i = size2+1; i<size1*size2; i++) // Loop to build the rest of the Toeplitz matrix. + { + if (oup[i] == 0) + oup[i] = oup[i-size2-1]; + } +} diff --git a/2.3-1/src/c/matrixOperations/toeplitz/ztoeplitza.c b/2.3-1/src/c/matrixOperations/toeplitz/ztoeplitza.c new file mode 100644 index 00000000..d47c5e15 --- /dev/null +++ b/2.3-1/src/c/matrixOperations/toeplitz/ztoeplitza.c @@ -0,0 +1,36 @@ +#include <stdio.h> +#include "toeplitz.h" +#include "doubleComplex.h" +#include "stdlib.h" +#include "string.h" +#include "cat.h" + + +/*Function to build a Toeplitz Matrix for inputs of DoubleComplex datatype*/ + + +void ztoeplitza(doubleComplex* inp1,int size1,doubleComplex* inp2,int size2,doubleComplex* oup) +{ + if (inp1[0]!=inp2[0]) + { + printf("Error!The first elements of the Vectors are not equal."); // First element of both input vectors must be equal for Toeplitz. + return; + } + int i, j; + + for(i=0;i<size1*size2;i++) oup[i] = DoubleComplex(0,0); // Initializing the output matrix with zeros. + + for (i = 0; i<size1; i++) + { + for (j = 0; j<size2; j++) + { + oup[j*size1] = inp2[j]; // Elements of the second input vector are copied to the first row of the Toeplitx Matrix. + } + oup[i] = inp1[i]; // Elements of the first input vector are copied to the first column of the Toeplitx Matrix. + } + for (i = size2+1; i<size1*size2; i++) // Loop to build the rest of the Toeplitz matrix. + { + if (oup[i] == DoubleComplex(0,0)) + oup[i] = oup[i-size2-1]; + } +} |