|
5 | 5 |
|
6 | 6 | module DSDP |
7 | 7 |
|
8 | | -import DSDP_jll |
| 8 | +using CEnum: @cenum |
| 9 | +using DSDP_jll: libdsdp |
| 10 | +import LinearAlgebra |
| 11 | +import MathOptInterface as MOI |
9 | 12 |
|
10 | | -using LinearAlgebra |
| 13 | +include("libdsdp.jl") |
11 | 14 |
|
12 | | -macro dsdp_ccall(f, args...) |
13 | | - quote |
14 | | - # QuoteNode prevents the interpretion of the symbol |
15 | | - # and leave it as a symbol |
16 | | - info = |
17 | | - ccall(($(QuoteNode(f)), DSDP_jll.libdsdp), Cint, $(esc.(args)...)) |
18 | | - if !iszero(info) |
19 | | - error("DSDP call $($(QuoteNode(f))) returned nonzero status $info.") |
20 | | - end |
21 | | - end |
22 | | -end |
23 | | - |
24 | | -const DSDPT = Ptr{Nothing} |
25 | | - |
26 | | -include("dsdp5_enums.jl") |
27 | | -include("dsdp5_API.jl") |
28 | | - |
29 | | -include("lpcone.jl") |
30 | | -function CreateLPCone(dsdp::DSDPT) |
31 | | - lpcone = Ref{LPCone.LPConeT}() |
32 | | - @dsdp_ccall DSDPCreateLPCone (DSDPT, Ref{LPCone.LPConeT}) dsdp lpcone |
33 | | - return lpcone[] |
34 | | -end |
35 | | - |
36 | | -include("sdpcone.jl") |
37 | | -function CreateSDPCone(dsdp::DSDPT, n::Integer) |
38 | | - sdpcone = Ref{SDPCone.SDPConeT}() |
39 | | - @dsdp_ccall DSDPCreateSDPCone (DSDPT, Cint, Ref{SDPCone.SDPConeT}) dsdp n sdpcone |
40 | | - return sdpcone[] |
41 | | -end |
42 | | - |
43 | | -include("bcone.jl") |
44 | | -function CreateBCone(dsdp::DSDPT) |
45 | | - bcone = Ref{BCone.BConeT}() |
46 | | - @dsdp_ccall DSDPCreateBCone (DSDPT, Ref{BCone.BConeT}) dsdp bcone |
47 | | - return bcone[] |
48 | | -end |
49 | | - |
50 | | -# Writes to `input.sdpa` |
51 | | -function PrintData( |
52 | | - dsdp::DSDPT, |
53 | | - sdpcone::SDPCone.SDPConeT, |
54 | | - lpcone::LPCone.LPConeT, |
55 | | -) |
56 | | - @dsdp_ccall DSDPPrintData (DSDPT, SDPCone.SDPConeT, LPCone.LPConeT) dsdp sdpcone lpcone |
57 | | -end |
58 | | - |
59 | | -function PrintSolution( |
60 | | - fp::Libc.FILE, |
61 | | - dsdp::DSDPT, |
62 | | - sdpcone::SDPCone.SDPConeT, |
63 | | - lpcone::LPCone.LPConeT, |
64 | | -) |
65 | | - @dsdp_ccall DSDPPrintSolution ( |
66 | | - Ptr{Cvoid}, |
67 | | - DSDPT, |
68 | | - SDPCone.SDPConeT, |
69 | | - LPCone.LPConeT, |
70 | | - ) fp dsdp sdpcone lpcone |
71 | | -end |
72 | | - |
73 | | -function PrintSolution( |
74 | | - dsdp::DSDPT, |
75 | | - sdpcone::SDPCone.SDPConeT, |
76 | | - lpcone::LPCone.LPConeT, |
77 | | -) |
78 | | - # See https://discourse.julialang.org/t/access-c-stdout-in-julia/24187/2 |
79 | | - stdout = Libc.FILE(Libc.RawFD(1), "w") |
80 | | - return PrintSolution(stdout, dsdp, sdpcone, lpcone) |
81 | | -end |
82 | | - |
83 | | -#function PrintSolution(arg1, arg2::DSDPT, arg3::SDPCone.SDPConeT, arg4::LPCone.LPConeT) |
84 | | -# @dsdp_ccall DSDPPrintSolution (Ptr{FILE}, DSDP, SDPCone.SDPConeT, LPCone.LPConeT) arg1 arg2 arg3 arg4 |
85 | | -#end |
| 15 | +# This one is named poorly in the upstream C API |
| 16 | +const DSDPSetReuseMatrix = DSDPReuseMatrix |
86 | 17 |
|
87 | 18 | include("MOI_wrapper.jl") |
88 | 19 |
|
|
0 commit comments