Skip to content

Instantly share code, notes, and snippets.

@stevengj
Last active January 29, 2016 16:52
Show Gist options
  • Save stevengj/791259c450ee7e360c10 to your computer and use it in GitHub Desktop.
Save stevengj/791259c450ee7e360c10 to your computer and use it in GitHub Desktop.
function cmatshell(m::C.Mat, y::C.Vec, x::C.Vec)
f_ = MatGetContext(m)
f = Function(unsafe_object_ptr(f_)) # get actual Julia function
f(Vec(y), Vec(x))
end
function Mat(f::Function, ...)
m = MatCreate(...)
m.data = f
MatSetContext(f)
MatSetShellOperation(m, cfunction(cmatshell)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment