Skip to content

Commit 3215f27

Browse files
committed
Create wrappers for other languages
1 parent aa69c63 commit 3215f27

File tree

4 files changed

+348
-0
lines changed

4 files changed

+348
-0
lines changed

language_wrappers/Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This Makefile template requires the following variables to be set
2+
# in the environment or on the command-line:
3+
# JULIA: path to julia[.exe] executable
4+
# BIN: binary build directory
5+
6+
ifndef JULIA
7+
$(error "Please pass JULIA=[path of target julia binary], or set as environment variable!")
8+
endif
9+
ifndef BIN
10+
$(error "Please pass BIN=[path of build directory], or set as environment variable!")
11+
endif
12+
13+
#=============================================================================
14+
# location of test source
15+
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
16+
PKGDIR := $(dir $(SRCDIR))
17+
JULIAHOME := $(abspath $(JULIA)/../..)
18+
BUILDSCRIPT := $(BIN)/../share/julia/juliac-buildscript.jl
19+
# include $(JULIAHOME)/Make.inc
20+
21+
# FIXME
22+
SHLIB_EXT := so
23+
24+
# get the executable suffix, if any
25+
EXE := $(suffix $(abspath $(JULIA)))
26+
27+
# get compiler and linker flags. (see: `contrib/julia-config.jl`)
28+
JULIA_CONFIG := $(JULIA) -e 'include(joinpath(Sys.BINDIR, Base.DATAROOTDIR, "julia", "julia-config.jl"))' --
29+
CPPFLAGS_ADD :=
30+
CFLAGS_ADD = $(shell $(JULIA_CONFIG) --cflags)
31+
LDFLAGS_ADD = -lm $(shell $(JULIA_CONFIG) --ldflags --ldlibs) -ljulia-internal
32+
33+
#=============================================================================
34+
35+
release: NMFMerge-jl.$(SHLIB_EXT)
36+
37+
NMFMerge-jl.$(SHLIB_EXT): $(PKGDIR)/src/NMFMerge.jl $(BUILDSCRIPT)
38+
$(JULIA) -t 1 -J $(BIN)/../lib/julia/sys.$(SHLIB_EXT) --project --startup-file=no --history-file=no --output-incremental=no --strip-ir --strip-metadata --experimental --trim $(BUILDSCRIPT) $(SRCDIR)/lib.jl --output-lib NMFMerge-jl.so
39+
40+
check: hello$(EXE) basic_jll$(EXE) # FIXME
41+
$(JULIA) --depwarn=error $(SRCDIR)/../runtests.jl $(SRCDIR)/trimming
42+
43+
clean: # FIXME
44+
-rm -f hello$(EXE) basic_jll$(EXE) init.o hello.o basic_jll.o
45+
46+
.PHONY: release clean check
47+
48+
# Makefile debugging trick:
49+
# call print-VARIABLE to see the runtime value of any variable
50+
print-%:
51+
@echo '$*=$($*)'

language_wrappers/Manifest.toml

Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
# This file is machine-generated - editing it directly is not advised
2+
3+
julia_version = "1.13.0-DEV"
4+
manifest_format = "2.0"
5+
project_hash = "02e7b54fdc8b2775dc61d1c22f0018e675cc17a2"
6+
7+
[[deps.Adapt]]
8+
deps = ["LinearAlgebra", "Requires"]
9+
git-tree-sha1 = "f7817e2e585aa6d924fd714df1e2a84be7896c60"
10+
uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
11+
version = "4.3.0"
12+
13+
[deps.Adapt.extensions]
14+
AdaptSparseArraysExt = "SparseArrays"
15+
AdaptStaticArraysExt = "StaticArrays"
16+
17+
[deps.Adapt.weakdeps]
18+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
19+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
20+
21+
[[deps.AliasTables]]
22+
deps = ["PtrArrays", "Random"]
23+
git-tree-sha1 = "9876e1e164b144ca45e9e3198d0b689cadfed9ff"
24+
uuid = "66dad0bd-aa9a-41b7-9441-69ab47430ed8"
25+
version = "1.1.3"
26+
27+
[[deps.Artifacts]]
28+
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
29+
version = "1.11.0"
30+
31+
[[deps.Base64]]
32+
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
33+
version = "1.11.0"
34+
35+
[[deps.Compat]]
36+
deps = ["TOML", "UUIDs"]
37+
git-tree-sha1 = "8ae8d32e09f0dcf42a36b90d4e17f5dd2e4c4215"
38+
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
39+
version = "4.16.0"
40+
weakdeps = ["Dates", "LinearAlgebra"]
41+
42+
[deps.Compat.extensions]
43+
CompatLinearAlgebraExt = "LinearAlgebra"
44+
45+
[[deps.CompilerSupportLibraries_jll]]
46+
deps = ["Artifacts", "Libdl"]
47+
uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
48+
version = "1.3.0+1"
49+
50+
[[deps.DataAPI]]
51+
git-tree-sha1 = "abe83f3a2f1b857aac70ef8b269080af17764bbe"
52+
uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
53+
version = "1.16.0"
54+
55+
[[deps.DataStructures]]
56+
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
57+
git-tree-sha1 = "4e1fe97fdaed23e9dc21d4d664bea76b65fc50a0"
58+
uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
59+
version = "0.18.22"
60+
61+
[[deps.Dates]]
62+
deps = ["Printf"]
63+
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
64+
version = "1.11.0"
65+
66+
[[deps.DocStringExtensions]]
67+
git-tree-sha1 = "e7b7e6f178525d17c720ab9c081e4ef04429f860"
68+
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
69+
version = "0.9.4"
70+
71+
[[deps.GsvdInitialization]]
72+
deps = ["LinearAlgebra", "NMF", "NonNegLeastSquares", "TSVD"]
73+
git-tree-sha1 = "81fcc977bf68da9024ef413e2588af2e8f3a8d8b"
74+
uuid = "2ac24108-be9c-42b8-8d78-6a4f62a87e7d"
75+
version = "1.0.0"
76+
77+
[[deps.InteractiveUtils]]
78+
deps = ["Markdown"]
79+
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
80+
version = "1.11.0"
81+
82+
[[deps.IrrationalConstants]]
83+
git-tree-sha1 = "e2222959fbc6c19554dc15174c81bf7bf3aa691c"
84+
uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
85+
version = "0.2.4"
86+
87+
[[deps.JuliaSyntaxHighlighting]]
88+
deps = ["StyledStrings"]
89+
uuid = "ac6e5ff7-fb65-4e79-a425-ec3bc9c03011"
90+
version = "1.12.0"
91+
92+
[[deps.Libdl]]
93+
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
94+
version = "1.11.0"
95+
96+
[[deps.LinearAlgebra]]
97+
deps = ["Libdl", "OpenBLAS_jll", "libblastrampoline_jll"]
98+
uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
99+
version = "1.12.0"
100+
101+
[[deps.LogExpFunctions]]
102+
deps = ["DocStringExtensions", "IrrationalConstants", "LinearAlgebra"]
103+
git-tree-sha1 = "13ca9e2586b89836fd20cccf56e57e2b9ae7f38f"
104+
uuid = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
105+
version = "0.3.29"
106+
107+
[deps.LogExpFunctions.extensions]
108+
LogExpFunctionsChainRulesCoreExt = "ChainRulesCore"
109+
LogExpFunctionsChangesOfVariablesExt = "ChangesOfVariables"
110+
LogExpFunctionsInverseFunctionsExt = "InverseFunctions"
111+
112+
[deps.LogExpFunctions.weakdeps]
113+
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
114+
ChangesOfVariables = "9e997f8a-9a97-42d5-a9f1-ce6bfc15e2c0"
115+
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
116+
117+
[[deps.Logging]]
118+
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
119+
version = "1.11.0"
120+
121+
[[deps.Markdown]]
122+
deps = ["Base64", "JuliaSyntaxHighlighting", "StyledStrings"]
123+
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
124+
version = "1.11.0"
125+
126+
[[deps.Missings]]
127+
deps = ["DataAPI"]
128+
git-tree-sha1 = "ec4f7fbeab05d7747bdf98eb74d130a2a2ed298d"
129+
uuid = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"
130+
version = "1.2.0"
131+
132+
[[deps.NMF]]
133+
deps = ["LinearAlgebra", "NonNegLeastSquares", "PrecompileTools", "Printf", "Random", "RandomizedLinAlg", "Statistics", "StatsBase"]
134+
git-tree-sha1 = "d098a41cbc60447b430c32e1ac271193652205ee"
135+
uuid = "6ef6ca0d-6ad7-5ff6-b225-e928bfa0a386"
136+
version = "1.0.3"
137+
138+
[[deps.NMFMerge]]
139+
deps = ["DataStructures", "GsvdInitialization", "LinearAlgebra", "NMF", "TSVD"]
140+
path = ".."
141+
uuid = "9cc52eda-dfaf-4e21-aae3-9f26bed153a3"
142+
version = "1.0.1"
143+
144+
[[deps.NonNegLeastSquares]]
145+
deps = ["LinearAlgebra", "SparseArrays"]
146+
git-tree-sha1 = "cdc11138e74a0dd0b82e7d64eb1350fdf049d3b1"
147+
uuid = "b7351bd1-99d9-5c5d-8786-f205a815c4d7"
148+
version = "0.4.1"
149+
150+
[[deps.OpenBLAS_jll]]
151+
deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"]
152+
uuid = "4536629a-c528-5b80-bd46-f80d51c5b363"
153+
version = "0.3.29+0"
154+
155+
[[deps.OrderedCollections]]
156+
git-tree-sha1 = "cc4054e898b852042d7b503313f7ad03de99c3dd"
157+
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
158+
version = "1.8.0"
159+
160+
[[deps.PrecompileTools]]
161+
deps = ["Preferences"]
162+
git-tree-sha1 = "3fcd5c8c872f7314a7bb5c1328d0349283d5b82d"
163+
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
164+
version = "1.3.1"
165+
166+
[[deps.Preferences]]
167+
deps = ["TOML"]
168+
git-tree-sha1 = "9306f6085165d270f7e3db02af26a400d580f5c6"
169+
uuid = "21216c6a-2e73-6563-6e65-726566657250"
170+
version = "1.4.3"
171+
172+
[[deps.Printf]]
173+
deps = ["Unicode"]
174+
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
175+
version = "1.11.0"
176+
177+
[[deps.PtrArrays]]
178+
git-tree-sha1 = "1d36ef11a9aaf1e8b74dacc6a731dd1de8fd493d"
179+
uuid = "43287f4e-b6f4-7ad1-bb20-aadabca52c3d"
180+
version = "1.3.0"
181+
182+
[[deps.Random]]
183+
deps = ["SHA"]
184+
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
185+
version = "1.11.0"
186+
187+
[[deps.RandomizedLinAlg]]
188+
deps = ["LinearAlgebra", "Random", "Test"]
189+
git-tree-sha1 = "de93780c85c207586369522af7525aa3011b09c3"
190+
uuid = "0448d7d9-159c-5637-8537-fd72090fea46"
191+
version = "0.1.0"
192+
193+
[[deps.Requires]]
194+
deps = ["UUIDs"]
195+
git-tree-sha1 = "62389eeff14780bfe55195b7204c0d8738436d64"
196+
uuid = "ae029012-a4dd-5104-9daa-d747884805df"
197+
version = "1.3.1"
198+
199+
[[deps.SHA]]
200+
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
201+
version = "0.7.0"
202+
203+
[[deps.Serialization]]
204+
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
205+
version = "1.11.0"
206+
207+
[[deps.SortingAlgorithms]]
208+
deps = ["DataStructures"]
209+
git-tree-sha1 = "66e0a8e672a0bdfca2c3f5937efb8538b9ddc085"
210+
uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
211+
version = "1.2.1"
212+
213+
[[deps.SparseArrays]]
214+
deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"]
215+
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
216+
version = "1.12.0"
217+
218+
[[deps.Statistics]]
219+
deps = ["LinearAlgebra"]
220+
git-tree-sha1 = "ae3bb1eb3bba077cd276bc5cfc337cc65c3075c0"
221+
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
222+
version = "1.11.1"
223+
weakdeps = ["SparseArrays"]
224+
225+
[deps.Statistics.extensions]
226+
SparseArraysExt = ["SparseArrays"]
227+
228+
[[deps.StatsAPI]]
229+
deps = ["LinearAlgebra"]
230+
git-tree-sha1 = "1ff449ad350c9c4cbc756624d6f8a8c3ef56d3ed"
231+
uuid = "82ae8749-77ed-4fe6-ae5f-f523153014b0"
232+
version = "1.7.0"
233+
234+
[[deps.StatsBase]]
235+
deps = ["AliasTables", "DataAPI", "DataStructures", "LinearAlgebra", "LogExpFunctions", "Missings", "Printf", "Random", "SortingAlgorithms", "SparseArrays", "Statistics", "StatsAPI"]
236+
git-tree-sha1 = "29321314c920c26684834965ec2ce0dacc9cf8e5"
237+
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
238+
version = "0.34.4"
239+
240+
[[deps.StyledStrings]]
241+
uuid = "f489334b-da3d-4c2e-b8f0-e476e12c162b"
242+
version = "1.11.0"
243+
244+
[[deps.SuiteSparse_jll]]
245+
deps = ["Artifacts", "Libdl", "libblastrampoline_jll"]
246+
uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c"
247+
version = "7.10.1+0"
248+
249+
[[deps.TOML]]
250+
deps = ["Dates"]
251+
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
252+
version = "1.0.3"
253+
254+
[[deps.TSVD]]
255+
deps = ["Adapt", "LinearAlgebra"]
256+
git-tree-sha1 = "c39caef6bae501e5607a6caf68dd9ac6e8addbcb"
257+
uuid = "9449cd9e-2762-5aa3-a617-5413e99d722e"
258+
version = "0.4.4"
259+
260+
[[deps.Test]]
261+
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
262+
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
263+
version = "1.11.0"
264+
265+
[[deps.UUIDs]]
266+
deps = ["Random", "SHA"]
267+
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
268+
version = "1.11.0"
269+
270+
[[deps.Unicode]]
271+
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
272+
version = "1.11.0"
273+
274+
[[deps.libblastrampoline_jll]]
275+
deps = ["Artifacts", "Libdl"]
276+
uuid = "8e850b90-86db-534c-a0d3-1478176c7d93"
277+
version = "5.12.0+0"

language_wrappers/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[deps]
2+
NMFMerge = "9cc52eda-dfaf-4e21-aae3-9f26bed153a3"

language_wrappers/lib.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module NMFMergeLib
2+
3+
using NMFMerge
4+
5+
struct ReturnValue
6+
niters::Int32
7+
converged::Bool
8+
objvalue::Float64
9+
end
10+
11+
Base.@ccallable function nmfmerge_inplace(Wout::Matrix{Float64}, Hout::Matrix{Float64}, X::Matrix{Float64}, ncomponents::Int32, tol::Float64, maxiter::Int32)::ReturnValue
12+
result = nmfmerge(X, ncomponents; tol_final=tol, maxiter)
13+
Wout .= result.W
14+
Hout .= result.H
15+
return ReturnValue(result.niters, result.converged, result.objvalue)
16+
end
17+
18+
end

0 commit comments

Comments
 (0)