[arrayfire] 86/248: unit tests for correlation coefficient function

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Tue Nov 17 15:54:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch dfsg-clean
in repository arrayfire.

commit d004ca8c972fa72b246f36f7907a76a52023e382
Author: pradeep <pradeep at arrayfire.com>
Date:   Tue Sep 29 16:30:49 2015 -0400

    unit tests for correlation coefficient function
---
 test/corrcoef.cpp | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 test/data         |  2 +-
 2 files changed, 96 insertions(+), 1 deletion(-)

diff --git a/test/corrcoef.cpp b/test/corrcoef.cpp
new file mode 100644
index 0000000..ea537d9
--- /dev/null
+++ b/test/corrcoef.cpp
@@ -0,0 +1,95 @@
+/*******************************************************
+ * Copyright (c) 2015, ArrayFire
+ * All rights reserved.
+ *
+ * This file is distributed under 3-clause BSD license.
+ * The complete license agreement can be obtained at:
+ * http://arrayfire.com/licenses/BSD-3-Clause
+ ********************************************************/
+
+#include <gtest/gtest.h>
+#include <arrayfire.h>
+#include <af/dim4.hpp>
+#include <af/traits.hpp>
+#include <string>
+#include <vector>
+#include <ctime>
+#include <iostream>
+#include <algorithm>
+#include <testHelpers.hpp>
+
+using namespace std;
+using namespace af;
+
+template<typename T>
+class CorrelationCoefficient : public ::testing::Test
+{
+    public:
+        virtual void SetUp() {}
+};
+
+// create a list of types to be tested
+typedef ::testing::Types<float, double, int, uint, intl, uintl, char, uchar> TestTypes;
+
+// register the type list
+TYPED_TEST_CASE(CorrelationCoefficient, TestTypes);
+
+template<typename T>
+struct f32HelperType {
+   typedef typename cond_type<is_same_type<T, double>::value,
+                                             double,
+                                             float>::type type;
+};
+
+template<typename T>
+struct c32HelperType {
+   typedef typename cond_type<is_same_type<T, cfloat>::value,
+                                             cfloat,
+                                             typename f32HelperType<T>::type >::type type;
+};
+
+template<typename T>
+struct elseType {
+   typedef typename cond_type< is_same_type<T, uintl>::value ||
+                               is_same_type<T, intl> ::value,
+                                              double,
+                                              T>::type type;
+};
+
+template<typename T>
+struct ccOutType {
+   typedef typename cond_type< is_same_type<T, float>   ::value ||
+                               is_same_type<T, int>     ::value ||
+                               is_same_type<T, uint>    ::value ||
+                               is_same_type<T, uchar>   ::value ||
+                               is_same_type<T, short>   ::value ||
+                               is_same_type<T, ushort>  ::value ||
+                               is_same_type<T, char>    ::value,
+                                              float,
+                              typename elseType<T>::type>::type type;
+};
+
+TYPED_TEST(CorrelationCoefficient, All)
+{
+    typedef typename ccOutType<TypeParam>::type outType;
+    if (noDoubleTests<TypeParam>()) return;
+    if (noDoubleTests<outType>()) return;
+
+    vector<af::dim4>      numDims;
+    vector<vector<int> >       in;
+    vector<vector<float> >  tests;
+
+    readTestsFromFile<int,float>(string(TEST_DIR "/corrcoef/mat_10x10_scalar.test"),
+                                 numDims, in, tests);
+
+    vector<TypeParam> input1(in[0].begin(), in[0].end());
+    vector<TypeParam> input2(in[1].begin(), in[1].end());
+
+    array a(numDims[0], &(input1.front()));
+    array b(numDims[1], &(input2.front()));
+    outType c = corrcoef<outType>(a, b);
+
+    vector<outType> currGoldBar(tests[0].begin(), tests[0].end());
+    ASSERT_NEAR(::real(currGoldBar[0]), ::real(c), 1.0e-3);
+    ASSERT_NEAR(::imag(currGoldBar[0]), ::imag(c), 1.0e-3);
+}
diff --git a/test/data b/test/data
index c1d040d..5686e8a 160000
--- a/test/data
+++ b/test/data
@@ -1 +1 @@
-Subproject commit c1d040d3a0016fbb20b9c82e602dce8339c4d1cc
+Subproject commit 5686e8a66849f73017ffff1ad49e5dfbc68bdf47

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git



More information about the debian-science-commits mailing list