[arrayfire] 291/408: Fix conjugate transpose for vectors
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:12:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository arrayfire.
commit cd097af9c8927f3bf9bfd82abc2ba588289ac6c8
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date: Wed Aug 19 13:41:10 2015 -0400
Fix conjugate transpose for vectors
---
src/api/c/transpose.cpp | 16 +++++++++++++---
test/transpose.cpp | 18 ++++++++++++++----
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/src/api/c/transpose.cpp b/src/api/c/transpose.cpp
index c63ab62..eb89695 100644
--- a/src/api/c/transpose.cpp
+++ b/src/api/c/transpose.cpp
@@ -11,6 +11,7 @@
#include <af/defines.h>
#include <af/blas.h>
#include <af/data.h>
+#include <af/arith.h>
#include <err_common.hpp>
#include <handle.hpp>
#include <backend.hpp>
@@ -33,10 +34,19 @@ af_err af_transpose(af_array *out, af_array in, const bool conjugate)
af::dim4 dims = info.dims();
if (dims[0]==1 || dims[1]==1) {
- // for a vector OR a batch of vectors
- // we can use modDims to transpose
af::dim4 outDims(dims[1],dims[0],dims[2],dims[3]);
- return af_moddims(out, in, outDims.ndims(), outDims.get());
+ if(conjugate) {
+ af_array temp = 0;
+ AF_CHECK(af_conjg(&temp, in));
+ AF_CHECK(af_moddims(out, temp, outDims.ndims(), outDims.get()));
+ AF_CHECK(af_release_array(temp));
+ return AF_SUCCESS;
+ } else {
+ // for a vector OR a batch of vectors
+ // we can use modDims to transpose
+ AF_CHECK(af_moddims(out, in, outDims.ndims(), outDims.get()));
+ return AF_SUCCESS;
+ }
}
af_array output;
diff --git a/test/transpose.cpp b/test/transpose.cpp
index 5e0d2ee..1e4ee47 100644
--- a/test/transpose.cpp
+++ b/test/transpose.cpp
@@ -192,11 +192,11 @@ TEST(Transpose, CPP_f32)
}
template<typename T>
-void trsCPPConjTest()
+void trsCPPConjTest(dim_t d0, dim_t d1 = 1, dim_t d2 = 1, dim_t d3 = 1)
{
vector<af::dim4> numDims;
- af::dim4 dims(40, 40);
+ af::dim4 dims(d0, d1, d2, d3);
if (noDoubleTests<T>()) return;
@@ -220,9 +220,19 @@ void trsCPPConjTest()
delete[] cData;
}
-TEST(Transpose, CPP_c32_CONJ)
+TEST(Transpose, CPP_c32_CONJ40x40)
{
- trsCPPConjTest<cfloat>();
+ trsCPPConjTest<cfloat>(40, 40);
+}
+
+TEST(Transpose, CPP_c32_CONJ2000x1)
+{
+ trsCPPConjTest<cfloat>(2000);
+}
+
+TEST(Transpose, CPP_c32_CONJ20x20x5)
+{
+ trsCPPConjTest<cfloat>(20, 20, 5);
}
TEST(Transpose, GFOR)
--
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