summaryrefslogtreecommitdiff
path: root/src/c/matrixOperations/toeplitz/u16toeplitza.c
diff options
context:
space:
mode:
authorAbhinav Dronamraju2017-07-10 22:08:27 +0530
committerAbhinav Dronamraju2017-07-10 22:08:27 +0530
commitd2c00f5343785085bcfefb62cbc041a5cffa8f31 (patch)
tree3d4fc371c30f2340af2def6dcabeb4fd4821eaf8 /src/c/matrixOperations/toeplitz/u16toeplitza.c
parentc7d123014c05daaa6c7ce32bc5e86e5f3e7e4692 (diff)
parent49d8281d2da2f4c6bf0e62d148a8a7328d3bf970 (diff)
downloadScilab2C_fossee_old-d2c00f5343785085bcfefb62cbc041a5cffa8f31.tar.gz
Scilab2C_fossee_old-d2c00f5343785085bcfefb62cbc041a5cffa8f31.tar.bz2
Scilab2C_fossee_old-d2c00f5343785085bcfefb62cbc041a5cffa8f31.zip
Pulled from upstream master
Diffstat (limited to 'src/c/matrixOperations/toeplitz/u16toeplitza.c')
-rw-r--r--src/c/matrixOperations/toeplitz/u16toeplitza.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/c/matrixOperations/toeplitz/u16toeplitza.c b/src/c/matrixOperations/toeplitz/u16toeplitza.c
new file mode 100644
index 0000000..8dab545
--- /dev/null
+++ b/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];
+ }
+}