[arrayfire] 14/75: Clean up of surface()

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:01:09 UTC 2016


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 213c8e6c3711ed55420fcbb6267f7334cddaf43a
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date:   Tue Feb 9 16:39:20 2016 -0500

    Clean up of surface()
    
    - Avoids unnecessary reorders by transposing vectors (more efficient)
---
 src/api/c/surface.cpp | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/src/api/c/surface.cpp b/src/api/c/surface.cpp
index 7db8441..2394f5f 100644
--- a/src/api/c/surface.cpp
+++ b/src/api/c/surface.cpp
@@ -49,21 +49,29 @@ fg::Surface* setup_surface(const af_array xVals, const af_array yVals, const af_
     af::dim4 Y_dims = Yinfo.dims();
     af::dim4 Z_dims = Zinfo.dims();
 
-    dim4   rdims(1, 0, 2, 3);
-    dim4 x_tdims(1, Y_dims[0], 1, 1);
-    dim4 y_tdims(1, X_dims[0], 1, 1);
     if(Xinfo.isVector()){
+        // Convert xIn is a column vector
+        xIn.modDims(xIn.elements());
+        // Now tile along second dimension
+        dim4 x_tdims(1, Y_dims[0], 1, 1);
         xIn = tile(xIn, x_tdims);
+
+        // Convert yIn to a row vector
+        yIn.modDims(af::dim4(1, yIn.elements()));
+        // Now tile along first dimension
+        dim4 y_tdims(X_dims[0], 1, 1, 1);
         yIn = tile(yIn, y_tdims);
-        yIn = reorder(yIn, rdims);
     }
 
-    xIn.modDims(xIn.elements());
-    yIn.modDims(yIn.elements());
-    zIn.modDims(zIn.elements());
-    Array<T> Z = join(1, join(1, xIn, yIn), zIn);
-    Z = reorder(Z, rdims);
-    Z.modDims(Z.elements());
+    // Flatten xIn, yIn and zIn into row vectors
+    dim4 rowDims = dim4(1, zIn.elements());
+    xIn.modDims(rowDims);
+    yIn.modDims(rowDims);
+    zIn.modDims(rowDims);
+
+    // Now join along first dimension, skip reorder
+    std::vector<Array<T> > inputs{xIn, yIn, zIn};
+    Array<T> Z = join(0, inputs);
 
     ForgeManager& fgMngr = ForgeManager::getInstance();
     fg::Surface* surface = fgMngr.getSurface(Z_dims[0], Z_dims[1], getGLType<T>());

-- 
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