]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ti-machine-learning/ti-machine-learning.git/blobdiff - debian/ti-timl/usr/src/timl/src/common/util/timlUtilConv2Valid.c
modified
[ti-machine-learning/ti-machine-learning.git] / debian / ti-timl / usr / src / timl / src / common / util / timlUtilConv2Valid.c
diff --git a/debian/ti-timl/usr/src/timl/src/common/util/timlUtilConv2Valid.c b/debian/ti-timl/usr/src/timl/src/common/util/timlUtilConv2Valid.c
new file mode 100644 (file)
index 0000000..0853739
--- /dev/null
@@ -0,0 +1,83 @@
+/******************************************************************************/\r
+/*!\r
+ * \file timlUtilConv2Valid.c\r
+ */\r
+/* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ *    Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ *\r
+ *    Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the\r
+ *    distribution.\r
+ *\r
+ *    Neither the name of Texas Instruments Incorporated nor the names of\r
+ *    its contributors may be used to endorse or promote products derived\r
+ *    from this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ *\r
+ ******************************************************************************/\r
+\r
+\r
+/*******************************************************************************\r
+ *\r
+ * INCLUDES\r
+ *\r
+ ******************************************************************************/\r
+\r
+#include "../api/timl.h"\r
+\r
+\r
+/******************************************************************************/\r
+/*!\r
+ * \ingroup    util\r
+ * \brief      conv2(a, b, 'valid')\r
+ * \param[in]  a    a matrix\r
+ * \param[in]  b    b matrix\r
+ * \param[out] c    c = conv2(a, b, 'valid')\r
+ * \param[in]  aRow a row size\r
+ * \param[in]  aCol a col size\r
+ * \param[in]  bRow b row size\r
+ * \param[in]  bCol b col size\r
+ * \return     Error code\r
+ */\r
+/******************************************************************************/\r
+\r
+int timlUtilConv2Valid(float *a, float *b, float *c, int aRow, int aCol, int bRow, int bCol)\r
+{\r
+   int i;\r
+   int j;\r
+   int m;\r
+   int n;\r
+   float sum;\r
+   int cRow = aRow - bRow + 1;\r
+   int cCol = aCol - bCol + 1;\r
+   for (m = 0; m < cRow; m++) {\r
+      for (n = 0; n < cCol; n++) {\r
+         sum = 0.0;\r
+         for (i = 0; i < bRow; i++) {\r
+            for (j = 0; j < bCol; j++) {\r
+               sum += a[(bCol - 1 + n - j) + aCol*(bRow - 1 + m - i)]*b[bCol*i + j];\r
+            }\r
+         }\r
+         c[n + cCol*m] += sum;\r
+      }\r
+   }\r
+   return 0;\r
+}\r