diff options
author | Brijeshcr | 2017-07-07 16:43:27 +0530 |
---|---|---|
committer | Brijeshcr | 2017-07-07 16:43:27 +0530 |
commit | 124ef41ebab756797803b30c4c07ce37213a6477 (patch) | |
tree | 4a42bf4b29b9b87e0c50c69d1cbf6385e49ea972 /src/c/matrixOperations/toeplitz/dtoeplitza.c | |
parent | ea958d3c401761dcc24865d9639b2fab31038db8 (diff) | |
download | Scilab2C_fossee_old-124ef41ebab756797803b30c4c07ce37213a6477.tar.gz Scilab2C_fossee_old-124ef41ebab756797803b30c4c07ce37213a6477.tar.bz2 Scilab2C_fossee_old-124ef41ebab756797803b30c4c07ce37213a6477.zip |
Toeplitz Added
Diffstat (limited to 'src/c/matrixOperations/toeplitz/dtoeplitza.c')
-rw-r--r-- | src/c/matrixOperations/toeplitz/dtoeplitza.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/c/matrixOperations/toeplitz/dtoeplitza.c b/src/c/matrixOperations/toeplitz/dtoeplitza.c new file mode 100644 index 0000000..ef075a9 --- /dev/null +++ b/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]; + } +} + |