[arrayfire] 128/408: Add SVD example

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:36 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 864c51d79966e37c17b440d9ed247b3886b4daef
Author: Richard Klemm <richy at coding-reality.de>
Date:   Sat Jul 4 22:40:58 2015 +0200

    Add SVD example
---
 examples/lin_algebra/svd.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/examples/lin_algebra/svd.cpp b/examples/lin_algebra/svd.cpp
new file mode 100644
index 0000000..070d74b
--- /dev/null
+++ b/examples/lin_algebra/svd.cpp
@@ -0,0 +1,51 @@
+/*******************************************************
+ * Copyright (c) 2014, 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 <arrayfire.h>
+#include <cstdio>
+#include <cstdlib>
+
+using namespace af;
+
+int main(int argc, char* argv[])
+{
+    try {
+        // Select a device and display arrayfire info
+        int device = argc > 1 ? atoi(argv[1]) : 0;
+        af::setDevice(device);
+        af::info();
+
+        float h_buffer[] = {1, 4, 2, 5, 3, 6 };  // host array
+        array in(2, 3, h_buffer);                        // copy host data to device
+        print("in", in);
+
+        array s;
+        array u;
+        array vt;
+        printf("Running svd");
+        svd(s, u, vt, in);
+        print("in", in);
+        print("s", s);
+        print("u", u);
+        print("vt", vt);
+
+    } catch (af::exception& e) {
+        fprintf(stderr, "%s\n", e.what());
+        throw;
+    }
+
+#ifdef WIN32  // pause in Windows
+    if (!(argc == 2 && argv[1][0] == '-')) {
+        printf("hit [enter]...");
+        fflush(stdout);
+        getchar();
+    }
+#endif
+    return 0;
+}

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