Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface single precision routines #174

Closed
dpo opened this issue Jan 28, 2019 · 1 comment
Closed

Interface single precision routines #174

dpo opened this issue Jan 28, 2019 · 1 comment

Comments

@dpo
Copy link
Member

dpo commented Jan 28, 2019

We should be able to do something like

for (jtype, ctype) in ((:Float32, Cfloat), (:Float64, Cdouble))
  @eval begin
    function NLPModels.objgrad!(nlp :: CUTEstModel, x :: Vector{$jtype}, g :: Vector{$jtype})
      nvar = nlp.meta.nvar
      ncon = nlp.meta.ncon
      f = $ctype[0]
      io_err = Cint[0]
      get_grad = 1
      if ncon > 0
        ccall(dlsym(cutest_lib, "cutest_cofg_"), Nothing,
            (Ptr{Int32}, Ref{Int32}, Ptr{$jtype}, Ptr{$jtype}, Ptr{$jtype}, Ref{Int32}),
                 io_err,       nvar,          x,            f,           g,   get_grad);
      else
        ccall(dlsym(cutest_lib, "cutest_uofg_"), Nothing,
            (Ptr{Int32}, Ref{Int32}, Ptr{$jtype}, Ptr{$jtype}, Ptr{$jtype}, Ref{Int32}),
                 io_err,       nvar,           x,           f,           g,   get_grad);
      end
      nlp.counters.neval_obj += 1
      nlp.counters.neval_grad += 1
      @cutest_error

      return f[1], g
    end
  end
end

See #177

@amontoison
Copy link
Member

Single and quadruple precision routines are now interfaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants