Skip to content

Commit

Permalink
Algorithms return a Status
Browse files Browse the repository at this point in the history
  • Loading branch information
emmt committed Oct 20, 2023
1 parent a73f854 commit 762a1a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 5 additions & 3 deletions gen/wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ function main()
r"\bprima_message\b" => "Message",
r"\bprima_rc\b" => "Status",
r"\bPRIMA_" => "",
# Make enum signed (see PRIMA library doc. about negative `iprint`
# values).
r"^(\s*@enum\s+\w+)\s*::\s*U(Int[0-9]*)\s+begin\s*$" => s"\1::\2 begin",
# Force enums to have signed value of type Cint (see PRIMA library doc.
# about negative `iprint` values).
r"^ *@enum +(\w+) *:: *U?Int\d+ +begin *$" => s"@enum \1::Cint begin",
# All algorithms return a Status.
r"\) *:: *Cint *$" => s")::Status",
# Remove some useless code.
r"^\s*const\s+PRIMAC_API\s*=.*$" => "",
]
Expand Down
14 changes: 7 additions & 7 deletions src/wrappers.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@enum Message::Int32 begin
@enum Message::Cint begin
MSG_NONE = 0
MSG_EXIT = 1
MSG_RHO = 2
MSG_FEVL = 3
end

@enum Status::Int32 begin
@enum Status::Cint begin
SMALL_TR_RADIUS = 0
FTARGET_ACHIEVED = 1
TRSUBP_FAILED = 2
Expand Down Expand Up @@ -39,21 +39,21 @@ function prima_bobyqa(calfun, n, x, f, xl, xu, nf, rhobeg, rhoend, ftarget, maxf
f::Ptr{Cdouble}, xl::Ptr{Cdouble}, xu::Ptr{Cdouble},
nf::Ptr{Cint}, rhobeg::Cdouble, rhoend::Cdouble,
ftarget::Cdouble, maxfun::Cint, npt::Cint,
iprint::Cint)::Cint
iprint::Cint)::Status
end

function prima_newuoa(calfun, n, x, f, nf, rhobeg, rhoend, ftarget, maxfun, npt, iprint)
@ccall libprimac.prima_newuoa(calfun::prima_obj, n::Cint, x::Ptr{Cdouble},
f::Ptr{Cdouble}, nf::Ptr{Cint}, rhobeg::Cdouble,
rhoend::Cdouble, ftarget::Cdouble, maxfun::Cint,
npt::Cint, iprint::Cint)::Cint
npt::Cint, iprint::Cint)::Status
end

function prima_uobyqa(calfun, n, x, f, nf, rhobeg, rhoend, ftarget, maxfun, iprint)
@ccall libprimac.prima_uobyqa(calfun::prima_obj, n::Cint, x::Ptr{Cdouble},
f::Ptr{Cdouble}, nf::Ptr{Cint}, rhobeg::Cdouble,
rhoend::Cdouble, ftarget::Cdouble, maxfun::Cint,
iprint::Cint)::Cint
iprint::Cint)::Status
end

function prima_cobyla(m_nlcon, calcfc, n, x, f, cstrv, nlconstr, m_ineq, Aineq, bineq, m_eq,
Expand All @@ -64,7 +64,7 @@ function prima_cobyla(m_nlcon, calcfc, n, x, f, cstrv, nlconstr, m_ineq, Aineq,
bineq::Ptr{Cdouble}, m_eq::Cint, Aeq::Ptr{Cdouble},
beq::Ptr{Cdouble}, xl::Ptr{Cdouble}, xu::Ptr{Cdouble},
nf::Ptr{Cint}, rhobeg::Cdouble, rhoend::Cdouble,
ftarget::Cdouble, maxfun::Cint, iprint::Cint)::Cint
ftarget::Cdouble, maxfun::Cint, iprint::Cint)::Status
end

function prima_lincoa(calfun, n, x, f, cstrv, m_ineq, Aineq, bineq, m_eq, Aeq, beq, xl, xu,
Expand All @@ -75,5 +75,5 @@ function prima_lincoa(calfun, n, x, f, cstrv, m_ineq, Aineq, bineq, m_eq, Aeq, b
Aeq::Ptr{Cdouble}, beq::Ptr{Cdouble}, xl::Ptr{Cdouble},
xu::Ptr{Cdouble}, nf::Ptr{Cint}, rhobeg::Cdouble,
rhoend::Cdouble, ftarget::Cdouble, maxfun::Cint,
npt::Cint, iprint::Cint)::Cint
npt::Cint, iprint::Cint)::Status
end

0 comments on commit 762a1a1

Please sign in to comment.