{"id":15057427,"url":"https://github.com/cnuernber/libjulia-clj","last_synced_at":"2025-08-20T16:31:09.300Z","repository":{"id":56060828,"uuid":"268153596","full_name":"cnuernber/libjulia-clj","owner":"cnuernber","description":"Julia bindings for Clojure -- Currently somewhat unstable --","archived":false,"fork":false,"pushed_at":"2023-03-13T23:11:14.000Z","size":1801,"stargazers_count":113,"open_issues_count":3,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-12-07T21:36:19.339Z","etag":null,"topics":["clojure","julia-language"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnuernber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-30T20:21:28.000Z","updated_at":"2024-11-26T13:23:30.000Z","dependencies_parsed_at":"2022-08-15T12:20:58.902Z","dependency_job_id":null,"html_url":"https://github.com/cnuernber/libjulia-clj","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnuernber%2Flibjulia-clj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnuernber%2Flibjulia-clj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnuernber%2Flibjulia-clj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnuernber%2Flibjulia-clj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnuernber","download_url":"https://codeload.github.com/cnuernber/libjulia-clj/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230438185,"owners_count":18225870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","julia-language"],"created_at":"2024-09-24T22:06:28.124Z","updated_at":"2024-12-19T13:07:03.212Z","avatar_url":"https://github.com/cnuernber.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# julia-clj\n\n[![Clojars Project](https://img.shields.io/clojars/v/com.cnuernber/libjulia-clj.svg)](https://clojars.org/cnuernber/libjulia-clj)\n[![travis integration](https://travis-ci.com/cnuernber/libjulia-clj.svg?branch=master)](https://travis-ci.com/cnuernber/libjulia-clj)\n\n\n* [API docs](https://cnuernber.github.io/libjulia-clj/)\n* [In-Depth Example](https://github.com/cnuernber/kmeans-mnist)\n* We now support julia-1.7.X so you can use it with the latest Julia.\n\n## Usage\n\nInstall julia and set JULIA_HOME:\n\n```console\nscripts/activate-julia\n```\n\nIn your repl, load the julia base namespace and initialize the system.\n\n```clojure\nuser\u003e (require '[libjulia-clj.julia :as julia])\nnil\nuser\u003e (julia/initialize!)\n07:07:06.228 [nREPL-session-e1c7b4a4-54f4-4298-80bb-972e83b902ff] INFO libjulia-clj.impl.base - Attempting to initialize Julia at /home/chrisn/dev/cnuernber/libjulia-clj/julia-1.5.3/lib/libjulia.so\n07:07:07.121 [nREPL-session-e1c7b4a4-54f4-4298-80bb-972e83b902ff] INFO tech.v3.jna.base - Library /home/chrisn/dev/cnuernber/libjulia-clj/julia-1.5.3/lib/libjulia.so found at [:system \"/home/chrisn/dev/cnuernber/libjulia-clj/julia-1.5.3/lib/libjulia.so\"]\n:ok\nuser\u003e (def ones-fn (julia/jl \"Base.ones\"))\n#'user/ones-fn\nuser\u003e (ones-fn 3 4)\n[1.0 1.0 1.0 1.0; 1.0 1.0 1.0 1.0; 1.0 1.0 1.0 1.0]\nuser\u003e (def julia-ary *1)\n#'user/julia-ary\nuser\u003e (require '[tech.v3.tensor :as dtt])\nnil\nuser\u003e (dtt/ensure-tensor julia-ary)\n#tech.v3.tensor\u003cfloat64\u003e[3 4]\n[[1.000 1.000 1.000 1.000]\n [1.000 1.000 1.000 1.000]\n [1.000 1.000 1.000 1.000]]\nuser\u003e (def clj-tens *1)\n#'user/clj-tens\nuser\u003e (dtt/mset! clj-tens 0 25)\n#tech.v3.tensor\u003cfloat64\u003e[3 4]\n[[25.00 25.00 25.00 25.00]\n [1.000 1.000 1.000 1.000]\n [1.000 1.000 1.000 1.000]]\nuser\u003e julia-ary\n[25.0 25.0 25.0 25.0; 1.0 1.0 1.0 1.0; 1.0 1.0 1.0 1.0]\n```\n\n## Something Fun\n\n```clojure\nuser\u003e (require '[tech.v3.libs.buffered-image :as bufimg])\nnil\nuser\u003e (require '[tech.v3.datatype :as dtype])\nnil\nuser\u003e (def fract-width 1920)\n(def fract-height 1080)\n(def i1 0.31)\n(def i2 -0.6)\n(def d 11)\n(def zoom-factor 0.2)\n#'user/fract-width#'user/fract-height#'user/i1#'user/i2#'user/d#'user/zoom-factor\nuser\u003e (def julia-code\n  \"function juliaSet(i1,i2,d,zoomFactor,imgWidth,imgHeight)\n    # Allocating a widthxheight matrix as our Clojure client is row-major\n    matrix = Array{UInt8}(undef,imgWidth,imgHeight)\n    icomp = Complex{Float64}(i1,i2)\n    Threads.@threads for i in CartesianIndices(matrix)\n        ## Julia has 1-based indexing...\n        pos =  complex(((i[1]-1) - (0.5 * imgWidth)) / (zoomFactor * imgWidth),\n                       ((i[2]-1) - (0.5 * imgHeight)) / (zoomFactor * imgHeight))\n\n        for c in (1:d) pos = (pos * pos) + icomp end\n        absval = abs(pos)\n        if (absval != NaN \u0026\u0026 absval \u003c (d-1))\n            matrix[i] = 255\n        else\n            matrix[i] = 0\n        end\n    end\n    return matrix\nend\")\n#'user/julia-code\nuser\u003e (def fractal-fn (julia/jl julia-code))\n#'user/fractal-fn\nuser\u003e (defn jl-fractal\n        []\n        (-\u003e (fractal-fn i1 i2 d zoom-factor fract-width fract-height)\n            (dtt/ensure-tensor)\n            ;;Julia is column-major so our image comes out widthxheight\n            ;;datatype is row major.\n            (dtt/transpose [1 0])\n            ;;The tensor library *knows* the original was transposed so transposing the result\n            ;;back into row-major means the memory can be read in order and thus\n            ;;the copy operation below is one large memcopy into a jvm byte array.\n            (dtype/copy! (bufimg/new-image fract-height fract-width :byte-gray))))\n#'user/jl-fractal\nuser\u003e (jl-fractal)\n#object[java.awt.image.BufferedImage 0x4d63b28f \"BufferedImage@4d63b28f: type = 10 ColorModel: #pixelBits = 8 numComponents = 1 color space = java.awt.color.ICC_ColorSpace@2703464d transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1920 height = 1080 #numDataElements 1 dataOff[0] = 0\"]\n;; Roughly 1920*1080*11*3, or 68428800 complex number operations\nuser\u003e (time (def ignored (jl-fractal)))\n\"Elapsed time: 31.487044 msecs\"\n#'user/ignored\nuser\u003e (bufimg/save! (jl-fractal) \"julia.png\")\ntrue\n```\n\n![julia-img](topics/images/julia.png)\n\n\n## License\n\nCopyright © 2021 Chris Nuernberger\n\n * [MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnuernber%2Flibjulia-clj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnuernber%2Flibjulia-clj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnuernber%2Flibjulia-clj/lists"}