Created
December 30, 2016 22:48
-
-
Save mthomure/ffb21e549af1be4b16f7c01e928ff5dc to your computer and use it in GitHub Desktop.
Using OpenBLAS from Clojure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Port of https://github.com/bytedeco/javacpp-presets/tree/master/openblas | |
;; Requires openblas dependency: | |
;; [org.bytedeco.javacpp-presets/openblas-platform "0.2.19-1.3"] | |
(ns ExampleDGELSrowmajor | |
(:import [org.bytedeco.javacpp openblas])) | |
(defn print-matrix-rowmajor [desc m n mat ldm] | |
(println "\n " desc) | |
(doseq [i (range m)] | |
(doseq [j (range n)] | |
(print (format " %6.2f" (aget mat (+ j (* i ldm)))))) | |
(println))) | |
(defn main [] | |
(let [a (double-array [1, 1, 1, 2, 3, 4, 3, 5, 2, 4, 2, 5, 5, 4, 3]) | |
b (double-array [-10, -3, 12, 14, 14, 12, 16, 16, 18, 16]) | |
m 5 | |
n 3 | |
nrhs 2 | |
lda 3 | |
ldb 2] | |
(print-matrix-rowmajor "Entry Matrix A" m n a lda) | |
(print-matrix-rowmajor "Right Hand Side b" n nrhs b ldb) | |
(println "LAPACKE_dgels (row-major, high-level) Example Program Results") | |
(let [info (openblas/LAPACKE_dgels openblas/LAPACK_ROW_MAJOR (byte \N) m n | |
nrhs a lda b ldb)] | |
(print-matrix-rowmajor "Solution" n nrhs b ldb)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment