Skip to content

Commit

Permalink
update for julia 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
jey committed Jun 20, 2017
1 parent 9dff14f commit dcfc1de
Showing 1 changed file with 53 additions and 51 deletions.
104 changes: 53 additions & 51 deletions src/Lbfgsb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,56 +7,55 @@ else
end

# package code goes here
macro callLBFGS(cmd)
quote
if length($cmd) != 0
@simd for i = 1:length($cmd)
task[i] = ($cmd)[i];
end
@simd for i = length($cmd)+1:60
task[i] = ' ';
end
function callLBFGS(cmd, n, m, x, lb, ub, btype, f, g, factr, pgtol, wa, iwa,
task, iprint, csave, lsave, isave, dsave)
if length(cmd) != 0
for i = 1:length(cmd)
task[i] = (cmd)[i];
end
for i = length(cmd)+1:60
task[i] = ' ';
end

ccall((:setulb_, liblbfgsbf),
Void,
(Ptr{Int32},
Ptr{Int32},
Ptr{Float64},
Ptr{Float64},
Ptr{Float64},
Ptr{Int32},
Ptr{Float64},
Ptr{Float64},
Ptr{Float64},
Ptr{Float64},
Ptr{Float64},
Ptr{Int32},
Ptr{UInt8},
Ptr{Int32},
Ptr{UInt8},
Ptr{Bool},
Ptr{Int32},
Ptr{Float64} ),
n,
m,
x,
lb,
ub,
btype,
f,
g,
factr,
pgtol,
wa,
iwa,
task,
iprint,
csave,
lsave,
isave,
dsave );
end

ccall((:setulb_, liblbfgsbf),
Void,
(Ptr{Int32},
Ptr{Int32},
Ptr{Float64},
Ptr{Float64},
Ptr{Float64},
Ptr{Int32},
Ptr{Float64},
Ptr{Float64},
Ptr{Float64},
Ptr{Float64},
Ptr{Float64},
Ptr{Int32},
Ptr{UInt8},
Ptr{Int32},
Ptr{UInt8},
Ptr{Bool},
Ptr{Int32},
Ptr{Float64} ),
n,
m,
x,
lb,
ub,
btype,
f,
g,
factr,
pgtol,
wa,
iwa,
task,
iprint,
csave,
lsave,
isave,
dsave );
end


Expand Down Expand Up @@ -109,7 +108,8 @@ function lbfgsb(ogFunc!::Function,
isave = [convert(Int32, 0) for i=1:44];
dsave = [convert(Float64, 0.0) for i=1:29];

@callLBFGS "START"
callLBFGS("START", n, m, x, lb, ub, btype, f, g, factr, pgtol,
wa, iwa, task, iprint, csave, lsave, isave, dsave)

status = "success";

Expand All @@ -125,7 +125,8 @@ function lbfgsb(ogFunc!::Function,
elseif task[1] == UInt32('N')
t += 1;
if t >= maxiter # exceed maximum number of iteration
@callLBFGS "STOP"
callLBFGS("STOP", n, m, x, lb, ub, btype, f, g, factr, pgtol,
wa, iwa, task, iprint, csave, lsave, isave, dsave)
break;
end
elseif task[1] == UInt32('C') # convergence
Expand All @@ -138,7 +139,8 @@ function lbfgsb(ogFunc!::Function,
break;
end

@callLBFGS ""
callLBFGS("", n, m, x, lb, ub, btype, f, g, factr, pgtol,
wa, iwa, task, iprint, csave, lsave, isave, dsave)
end

return (f[1], x, t, c, status)
Expand Down

0 comments on commit dcfc1de

Please sign in to comment.