summaryrefslogtreecommitdiff
path: root/2.3-1/src/c/matrixOperations/toeplitz/u8toeplitza.c
diff options
context:
space:
mode:
authorAbhinav Dronamraju2017-07-10 22:08:27 +0530
committerAbhinav Dronamraju2017-07-10 22:08:27 +0530
commitf80b5800ddb8417530f68049f6895beccb89cadf (patch)
tree564a23878bc400ecc0873bb4b1f5b172af22cfc6 /2.3-1/src/c/matrixOperations/toeplitz/u8toeplitza.c
parentc1874d367d68cb47b82cc7a1173caaf38e9e3d68 (diff)
parent2e9eadc75e51483c41a30544496b4e05c0cf7c41 (diff)
downloadScilab2C-f80b5800ddb8417530f68049f6895beccb89cadf.tar.gz
Scilab2C-f80b5800ddb8417530f68049f6895beccb89cadf.tar.bz2
Scilab2C-f80b5800ddb8417530f68049f6895beccb89cadf.zip
Pulled from upstream master
Diffstat (limited to '2.3-1/src/c/matrixOperations/toeplitz/u8toeplitza.c')
-rw-r--r--2.3-1/src/c/matrixOperations/toeplitz/u8toeplitza.c33
1 files changed, 33 insertions, 0 deletions
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];
+ }
+}