text:
# Julia wrapper for header: /home/astukalov/.julia/v0.5/Sundials/deps/usr/include/idas/idas.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

function IDACreate()
    ccall((:IDACreate,libsundials_idas),IDAMemPtr,())
end

function __IDASetErrHandlerFn(ida_mem::IDAMemPtr,ehfun::IDAErrHandlerFn,eh_data::Ptr{Void})
    ccall((:IDASetErrHandlerFn,libsundials_idas),Cint,(IDAMemPtr,IDAErrHandlerFn,Ptr{Void}),ida_mem,ehfun,eh_data)
end

function IDASetErrHandlerFn(ida_mem,ehfun,eh_data)
    __IDASetErrHandlerFn(convert(IDAMemPtr,ida_mem),ehfun,pointer(eh_data))
end

function __IDASetErrFile(ida_mem::IDAMemPtr,errfp::Ptr{FILE})
    ccall((:IDASetErrFile,libsundials_idas),Cint,(IDAMemPtr,Ptr{FILE}),ida_mem,errfp)
end

function IDASetErrFile(ida_mem,errfp)
    __IDASetErrFile(convert(IDAMemPtr,ida_mem),errfp)
end

function __IDASetUserData(ida_mem::IDAMemPtr,user_data::Any)
    ccall((:IDASetUserData,libsundials_idas),Cint,(IDAMemPtr,Any),ida_mem,user_data)
end

function IDASetUserData(ida_mem,user_data)
    __IDASetUserData(convert(IDAMemPtr,ida_mem),user_data)
end

function __IDASetMaxOrd(ida_mem::IDAMemPtr,maxord::Cint)
    ccall((:IDASetMaxOrd,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxord)
end

function IDASetMaxOrd(ida_mem,maxord)
    __IDASetMaxOrd(convert(IDAMemPtr,ida_mem),convert(Cint,maxord))
end

function __IDASetMaxNumSteps(ida_mem::IDAMemPtr,mxsteps::Clong)
    ccall((:IDASetMaxNumSteps,libsundials_idas),Cint,(IDAMemPtr,Clong),ida_mem,mxsteps)
end

function IDASetMaxNumSteps(ida_mem,mxsteps)
    __IDASetMaxNumSteps(convert(IDAMemPtr,ida_mem),convert(Clong,mxsteps))
end

function __IDASetInitStep(ida_mem::IDAMemPtr,hin::realtype)
    ccall((:IDASetInitStep,libsundials_idas),Cint,(IDAMemPtr,realtype),ida_mem,hin)
end

function IDASetInitStep(ida_mem,hin)
    __IDASetInitStep(convert(IDAMemPtr,ida_mem),hin)
end

function __IDASetMaxStep(ida_mem::IDAMemPtr,hmax::realtype)
    ccall((:IDASetMaxStep,libsundials_idas),Cint,(IDAMemPtr,realtype),ida_mem,hmax)
end

function IDASetMaxStep(ida_mem,hmax)
    __IDASetMaxStep(convert(IDAMemPtr,ida_mem),hmax)
end

function __IDASetStopTime(ida_mem::IDAMemPtr,tstop::realtype)
    ccall((:IDASetStopTime,libsundials_idas),Cint,(IDAMemPtr,realtype),ida_mem,tstop)
end

function IDASetStopTime(ida_mem,tstop)
    __IDASetStopTime(convert(IDAMemPtr,ida_mem),tstop)
end

function __IDASetNonlinConvCoef(ida_mem::IDAMemPtr,epcon::realtype)
    ccall((:IDASetNonlinConvCoef,libsundials_idas),Cint,(IDAMemPtr,realtype),ida_mem,epcon)
end

function IDASetNonlinConvCoef(ida_mem,epcon)
    __IDASetNonlinConvCoef(convert(IDAMemPtr,ida_mem),epcon)
end

function __IDASetMaxErrTestFails(ida_mem::IDAMemPtr,maxnef::Cint)
    ccall((:IDASetMaxErrTestFails,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxnef)
end

function IDASetMaxErrTestFails(ida_mem,maxnef)
    __IDASetMaxErrTestFails(convert(IDAMemPtr,ida_mem),convert(Cint,maxnef))
end

function __IDASetMaxNonlinIters(ida_mem::IDAMemPtr,maxcor::Cint)
    ccall((:IDASetMaxNonlinIters,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxcor)
end

function IDASetMaxNonlinIters(ida_mem,maxcor)
    __IDASetMaxNonlinIters(convert(IDAMemPtr,ida_mem),convert(Cint,maxcor))
end

function __IDASetMaxConvFails(ida_mem::IDAMemPtr,maxncf::Cint)
    ccall((:IDASetMaxConvFails,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxncf)
end

function IDASetMaxConvFails(ida_mem,maxncf)
    __IDASetMaxConvFails(convert(IDAMemPtr,ida_mem),convert(Cint,maxncf))
end

function __IDASetSuppressAlg(ida_mem::IDAMemPtr,suppressalg::Cint)
    ccall((:IDASetSuppressAlg,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,suppressalg)
end

function IDASetSuppressAlg(ida_mem,suppressalg)
    __IDASetSuppressAlg(convert(IDAMemPtr,ida_mem),convert(Cint,suppressalg))
end

function __IDASetId(ida_mem::IDAMemPtr,id::N_Vector)
    ccall((:IDASetId,libsundials_idas),Cint,(IDAMemPtr,N_Vector),ida_mem,id)
end

function IDASetId(ida_mem,id)
    __id = convert(NVector,id)
    __IDASetId(convert(IDAMemPtr,ida_mem),convert(N_Vector,__id))
end

function __IDASetConstraints(ida_mem::IDAMemPtr,constraints::N_Vector)
    ccall((:IDASetConstraints,libsundials_idas),Cint,(IDAMemPtr,N_Vector),ida_mem,constraints)
end

function IDASetConstraints(ida_mem,constraints)
    __constraints = convert(NVector,constraints)
    __IDASetConstraints(convert(IDAMemPtr,ida_mem),convert(N_Vector,__constraints))
end

function __IDASetRootDirection(ida_mem::IDAMemPtr,rootdir::Ptr{Cint})
    ccall((:IDASetRootDirection,libsundials_idas),Cint,(IDAMemPtr,Ptr{Cint}),ida_mem,rootdir)
end

function IDASetRootDirection(ida_mem,rootdir)
    __IDASetRootDirection(convert(IDAMemPtr,ida_mem),pointer(rootdir))
end

function __IDASetNoInactiveRootWarn(ida_mem::IDAMemPtr)
    ccall((:IDASetNoInactiveRootWarn,libsundials_idas),Cint,(IDAMemPtr,),ida_mem)
end

function IDASetNoInactiveRootWarn(ida_mem)
    __IDASetNoInactiveRootWarn(convert(IDAMemPtr,ida_mem))
end

function __IDAInit(ida_mem::IDAMemPtr,res::IDAResFn,t0::realtype,yy0::N_Vector,yp0::N_Vector)
    ccall((:IDAInit,libsundials_idas),Cint,(IDAMemPtr,IDAResFn,realtype,N_Vector,N_Vector),ida_mem,res,t0,yy0,yp0)
end

function IDAInit(ida_mem,res,t0,yy0,yp0)
    __yy0 = convert(NVector,yy0)
    __yp0 = convert(NVector,yp0)
    __IDAInit(convert(IDAMemPtr,ida_mem),IDAResFn_wrapper(res),t0,convert(N_Vector,__yy0),convert(N_Vector,__yp0))
end

function __IDAReInit(ida_mem::IDAMemPtr,t0::realtype,yy0::N_Vector,yp0::N_Vector)
    ccall((:IDAReInit,libsundials_idas),Cint,(IDAMemPtr,realtype,N_Vector,N_Vector),ida_mem,t0,yy0,yp0)
end

function IDAReInit(ida_mem,t0,yy0,yp0)
    __yy0 = convert(NVector,yy0)
    __yp0 = convert(NVector,yp0)
    __IDAReInit(convert(IDAMemPtr,ida_mem),t0,convert(N_Vector,__yy0),convert(N_Vector,__yp0))
end

function __IDASStolerances(ida_mem::IDAMemPtr,reltol::realtype,abstol::realtype)
    ccall((:IDASStolerances,libsundials_idas),Cint,(IDAMemPtr,realtype,realtype),ida_mem,reltol,abstol)
end

function IDASStolerances(ida_mem,reltol,abstol)
    __IDASStolerances(convert(IDAMemPtr,ida_mem),reltol,abstol)
end

function __IDASVtolerances(ida_mem::IDAMemPtr,reltol::realtype,abstol::N_Vector)
    ccall((:IDASVtolerances,libsundials_idas),Cint,(IDAMemPtr,realtype,N_Vector),ida_mem,reltol,abstol)
end

function IDASVtolerances(ida_mem,reltol,abstol)
    __abstol = convert(NVector,abstol)
    __IDASVtolerances(convert(IDAMemPtr,ida_mem),reltol,convert(N_Vector,__abstol))
end

function __IDAWFtolerances(ida_mem::IDAMemPtr,efun::IDAEwtFn)
    ccall((:IDAWFtolerances,libsundials_idas),Cint,(IDAMemPtr,IDAEwtFn),ida_mem,efun)
end

function IDAWFtolerances(ida_mem,efun)
    __IDAWFtolerances(convert(IDAMemPtr,ida_mem),efun)
end

function __IDASetNonlinConvCoefIC(ida_mem::IDAMemPtr,epiccon::realtype)
    ccall((:IDASetNonlinConvCoefIC,libsundials_idas),Cint,(IDAMemPtr,realtype),ida_mem,epiccon)
end

function IDASetNonlinConvCoefIC(ida_mem,epiccon)
    __IDASetNonlinConvCoefIC(convert(IDAMemPtr,ida_mem),epiccon)
end

function __IDASetMaxNumStepsIC(ida_mem::IDAMemPtr,maxnh::Cint)
    ccall((:IDASetMaxNumStepsIC,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxnh)
end

function IDASetMaxNumStepsIC(ida_mem,maxnh)
    __IDASetMaxNumStepsIC(convert(IDAMemPtr,ida_mem),convert(Cint,maxnh))
end

function __IDASetMaxNumJacsIC(ida_mem::IDAMemPtr,maxnj::Cint)
    ccall((:IDASetMaxNumJacsIC,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxnj)
end

function IDASetMaxNumJacsIC(ida_mem,maxnj)
    __IDASetMaxNumJacsIC(convert(IDAMemPtr,ida_mem),convert(Cint,maxnj))
end

function __IDASetMaxNumItersIC(ida_mem::IDAMemPtr,maxnit::Cint)
    ccall((:IDASetMaxNumItersIC,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxnit)
end

function IDASetMaxNumItersIC(ida_mem,maxnit)
    __IDASetMaxNumItersIC(convert(IDAMemPtr,ida_mem),convert(Cint,maxnit))
end

function __IDASetLineSearchOffIC(ida_mem::IDAMemPtr,lsoff::Cint)
    ccall((:IDASetLineSearchOffIC,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,lsoff)
end

function IDASetLineSearchOffIC(ida_mem,lsoff)
    __IDASetLineSearchOffIC(convert(IDAMemPtr,ida_mem),convert(Cint,lsoff))
end

function __IDASetStepToleranceIC(ida_mem::IDAMemPtr,steptol::realtype)
    ccall((:IDASetStepToleranceIC,libsundials_idas),Cint,(IDAMemPtr,realtype),ida_mem,steptol)
end

function IDASetStepToleranceIC(ida_mem,steptol)
    __IDASetStepToleranceIC(convert(IDAMemPtr,ida_mem),steptol)
end

function __IDARootInit(ida_mem::IDAMemPtr,nrtfn::Cint,g::IDARootFn)
    ccall((:IDARootInit,libsundials_idas),Cint,(IDAMemPtr,Cint,IDARootFn),ida_mem,nrtfn,g)
end

function IDARootInit(ida_mem,nrtfn,g)
    __IDARootInit(convert(IDAMemPtr,ida_mem),convert(Cint,nrtfn),IDARootFn_wrapper(g))
end

function __IDASetQuadErrCon(ida_mem::IDAMemPtr,errconQ::Cint)
    ccall((:IDASetQuadErrCon,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,errconQ)
end

function IDASetQuadErrCon(ida_mem,errconQ)
    __IDASetQuadErrCon(convert(IDAMemPtr,ida_mem),convert(Cint,errconQ))
end

function __IDAQuadInit(ida_mem::IDAMemPtr,rhsQ::IDAQuadRhsFn,yQ0::N_Vector)
    ccall((:IDAQuadInit,libsundials_idas),Cint,(IDAMemPtr,IDAQuadRhsFn,N_Vector),ida_mem,rhsQ,yQ0)
end

function IDAQuadInit(ida_mem,rhsQ,yQ0)
    __yQ0 = convert(NVector,yQ0)
    __IDAQuadInit(convert(IDAMemPtr,ida_mem),rhsQ,convert(N_Vector,__yQ0))
end

function __IDAQuadReInit(ida_mem::IDAMemPtr,yQ0::N_Vector)
    ccall((:IDAQuadReInit,libsundials_idas),Cint,(IDAMemPtr,N_Vector),ida_mem,yQ0)
end

function IDAQuadReInit(ida_mem,yQ0)
    __yQ0 = convert(NVector,yQ0)
    __IDAQuadReInit(convert(IDAMemPtr,ida_mem),convert(N_Vector,__yQ0))
end

function __IDAQuadSStolerances(ida_mem::IDAMemPtr,reltolQ::realtype,abstolQ::realtype)
    ccall((:IDAQuadSStolerances,libsundials_idas),Cint,(IDAMemPtr,realtype,realtype),ida_mem,reltolQ,abstolQ)
end

function IDAQuadSStolerances(ida_mem,reltolQ,abstolQ)
    __IDAQuadSStolerances(convert(IDAMemPtr,ida_mem),reltolQ,abstolQ)
end

function __IDAQuadSVtolerances(ida_mem::IDAMemPtr,reltolQ::realtype,abstolQ::N_Vector)
    ccall((:IDAQuadSVtolerances,libsundials_idas),Cint,(IDAMemPtr,realtype,N_Vector),ida_mem,reltolQ,abstolQ)
end

function IDAQuadSVtolerances(ida_mem,reltolQ,abstolQ)
    __abstolQ = convert(NVector,abstolQ)
    __IDAQuadSVtolerances(convert(IDAMemPtr,ida_mem),reltolQ,convert(N_Vector,__abstolQ))
end

function __IDASetSensDQMethod(ida_mem::IDAMemPtr,DQtype::Cint,DQrhomax::realtype)
    ccall((:IDASetSensDQMethod,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype),ida_mem,DQtype,DQrhomax)
end

function IDASetSensDQMethod(ida_mem,DQtype,DQrhomax)
    __IDASetSensDQMethod(convert(IDAMemPtr,ida_mem),convert(Cint,DQtype),DQrhomax)
end

function __IDASetSensParams(ida_mem::IDAMemPtr,p::Ptr{realtype},pbar::Ptr{realtype},plist::Ptr{Cint})
    ccall((:IDASetSensParams,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype},Ptr{realtype},Ptr{Cint}),ida_mem,p,pbar,plist)
end

function IDASetSensParams(ida_mem,p,pbar,plist)
    __IDASetSensParams(convert(IDAMemPtr,ida_mem),pointer(p),pointer(pbar),pointer(plist))
end

function __IDASetSensErrCon(ida_mem::IDAMemPtr,errconS::Cint)
    ccall((:IDASetSensErrCon,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,errconS)
end

function IDASetSensErrCon(ida_mem,errconS)
    __IDASetSensErrCon(convert(IDAMemPtr,ida_mem),convert(Cint,errconS))
end

function __IDASetSensMaxNonlinIters(ida_mem::IDAMemPtr,maxcorS::Cint)
    ccall((:IDASetSensMaxNonlinIters,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxcorS)
end

function IDASetSensMaxNonlinIters(ida_mem,maxcorS)
    __IDASetSensMaxNonlinIters(convert(IDAMemPtr,ida_mem),convert(Cint,maxcorS))
end

function __IDASensInit(ida_mem::IDAMemPtr,Ns::Cint,ism::Cint,resS::IDASensResFn,yS0::Ptr{N_Vector},ypS0::Ptr{N_Vector})
    ccall((:IDASensInit,libsundials_idas),Cint,(IDAMemPtr,Cint,Cint,IDASensResFn,Ptr{N_Vector},Ptr{N_Vector}),ida_mem,Ns,ism,resS,yS0,ypS0)
end

function IDASensInit(ida_mem,Ns,ism,resS,yS0,ypS0)
    __IDASensInit(convert(IDAMemPtr,ida_mem),convert(Cint,Ns),convert(Cint,ism),resS,pointer(yS0),pointer(ypS0))
end

function __IDASensReInit(ida_mem::IDAMemPtr,ism::Cint,yS0::Ptr{N_Vector},ypS0::Ptr{N_Vector})
    ccall((:IDASensReInit,libsundials_idas),Cint,(IDAMemPtr,Cint,Ptr{N_Vector},Ptr{N_Vector}),ida_mem,ism,yS0,ypS0)
end

function IDASensReInit(ida_mem,ism,yS0,ypS0)
    __IDASensReInit(convert(IDAMemPtr,ida_mem),convert(Cint,ism),pointer(yS0),pointer(ypS0))
end

function __IDASensToggleOff(ida_mem::IDAMemPtr)
    ccall((:IDASensToggleOff,libsundials_idas),Cint,(IDAMemPtr,),ida_mem)
end

function IDASensToggleOff(ida_mem)
    __IDASensToggleOff(convert(IDAMemPtr,ida_mem))
end

function __IDASensSStolerances(ida_mem::IDAMemPtr,reltolS::realtype,abstolS::Ptr{realtype})
    ccall((:IDASensSStolerances,libsundials_idas),Cint,(IDAMemPtr,realtype,Ptr{realtype}),ida_mem,reltolS,abstolS)
end

function IDASensSStolerances(ida_mem,reltolS,abstolS)
    __IDASensSStolerances(convert(IDAMemPtr,ida_mem),reltolS,pointer(abstolS))
end

function __IDASensSVtolerances(ida_mem::IDAMemPtr,reltolS::realtype,abstolS::Ptr{N_Vector})
    ccall((:IDASensSVtolerances,libsundials_idas),Cint,(IDAMemPtr,realtype,Ptr{N_Vector}),ida_mem,reltolS,abstolS)
end

function IDASensSVtolerances(ida_mem,reltolS,abstolS)
    __IDASensSVtolerances(convert(IDAMemPtr,ida_mem),reltolS,pointer(abstolS))
end

function __IDASensEEtolerances(ida_mem::IDAMemPtr)
    ccall((:IDASensEEtolerances,libsundials_idas),Cint,(IDAMemPtr,),ida_mem)
end

function IDASensEEtolerances(ida_mem)
    __IDASensEEtolerances(convert(IDAMemPtr,ida_mem))
end

function __IDAQuadSensInit(ida_mem::IDAMemPtr,resQS::IDAQuadSensRhsFn,yQS0::Ptr{N_Vector})
    ccall((:IDAQuadSensInit,libsundials_idas),Cint,(IDAMemPtr,IDAQuadSensRhsFn,Ptr{N_Vector}),ida_mem,resQS,yQS0)
end

function IDAQuadSensInit(ida_mem,resQS,yQS0)
    __IDAQuadSensInit(convert(IDAMemPtr,ida_mem),resQS,pointer(yQS0))
end

function __IDAQuadSensReInit(ida_mem::IDAMemPtr,yQS0::Ptr{N_Vector})
    ccall((:IDAQuadSensReInit,libsundials_idas),Cint,(IDAMemPtr,Ptr{N_Vector}),ida_mem,yQS0)
end

function IDAQuadSensReInit(ida_mem,yQS0)
    __IDAQuadSensReInit(convert(IDAMemPtr,ida_mem),pointer(yQS0))
end

function __IDAQuadSensSStolerances(ida_mem::IDAMemPtr,reltolQS::realtype,abstolQS::Ptr{realtype})
    ccall((:IDAQuadSensSStolerances,libsundials_idas),Cint,(IDAMemPtr,realtype,Ptr{realtype}),ida_mem,reltolQS,abstolQS)
end

function IDAQuadSensSStolerances(ida_mem,reltolQS,abstolQS)
    __IDAQuadSensSStolerances(convert(IDAMemPtr,ida_mem),reltolQS,pointer(abstolQS))
end

function __IDAQuadSensSVtolerances(ida_mem::IDAMemPtr,reltolQS::realtype,abstolQS::Ptr{N_Vector})
    ccall((:IDAQuadSensSVtolerances,libsundials_idas),Cint,(IDAMemPtr,realtype,Ptr{N_Vector}),ida_mem,reltolQS,abstolQS)
end

function IDAQuadSensSVtolerances(ida_mem,reltolQS,abstolQS)
    __IDAQuadSensSVtolerances(convert(IDAMemPtr,ida_mem),reltolQS,pointer(abstolQS))
end

function __IDAQuadSensEEtolerances(ida_mem::IDAMemPtr)
    ccall((:IDAQuadSensEEtolerances,libsundials_idas),Cint,(IDAMemPtr,),ida_mem)
end

function IDAQuadSensEEtolerances(ida_mem)
    __IDAQuadSensEEtolerances(convert(IDAMemPtr,ida_mem))
end

function __IDASetQuadSensErrCon(ida_mem::IDAMemPtr,errconQS::Cint)
    ccall((:IDASetQuadSensErrCon,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,errconQS)
end

function IDASetQuadSensErrCon(ida_mem,errconQS)
    __IDASetQuadSensErrCon(convert(IDAMemPtr,ida_mem),convert(Cint,errconQS))
end

function __IDACalcIC(ida_mem::IDAMemPtr,icopt::Cint,tout1::realtype)
    ccall((:IDACalcIC,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype),ida_mem,icopt,tout1)
end

function IDACalcIC(ida_mem,icopt,tout1)
    __IDACalcIC(convert(IDAMemPtr,ida_mem),convert(Cint,icopt),tout1)
end

function __IDASolve(ida_mem::IDAMemPtr,tout::realtype,tret::Ptr{realtype},yret::N_Vector,ypret::N_Vector,itask::Cint)
    ccall((:IDASolve,libsundials_idas),Cint,(IDAMemPtr,realtype,Ptr{realtype},N_Vector,N_Vector,Cint),ida_mem,tout,tret,yret,ypret,itask)
end

function IDASolve(ida_mem,tout,tret,yret,ypret,itask)
    __yret = convert(NVector,yret)
    __ypret = convert(NVector,ypret)
    __IDASolve(convert(IDAMemPtr,ida_mem),tout,pointer(tret),convert(N_Vector,__yret),convert(N_Vector,__ypret),convert(Cint,itask))
end

function __IDAGetDky(ida_mem::IDAMemPtr,t::realtype,k::Cint,dky::N_Vector)
    ccall((:IDAGetDky,libsundials_idas),Cint,(IDAMemPtr,realtype,Cint,N_Vector),ida_mem,t,k,dky)
end

function IDAGetDky(ida_mem,t,k,dky)
    __dky = convert(NVector,dky)
    __IDAGetDky(convert(IDAMemPtr,ida_mem),t,convert(Cint,k),convert(N_Vector,__dky))
end

function __IDAGetWorkSpace(ida_mem::IDAMemPtr,lenrw::Ptr{Clong},leniw::Ptr{Clong})
    ccall((:IDAGetWorkSpace,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong},Ptr{Clong}),ida_mem,lenrw,leniw)
end

function IDAGetWorkSpace(ida_mem,lenrw,leniw)
    __IDAGetWorkSpace(convert(IDAMemPtr,ida_mem),pointer(lenrw),pointer(leniw))
end

function __IDAGetNumSteps(ida_mem::IDAMemPtr,nsteps::Ptr{Clong})
    ccall((:IDAGetNumSteps,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nsteps)
end

function IDAGetNumSteps(ida_mem,nsteps)
    __IDAGetNumSteps(convert(IDAMemPtr,ida_mem),pointer(nsteps))
end

function __IDAGetNumResEvals(ida_mem::IDAMemPtr,nrevals::Ptr{Clong})
    ccall((:IDAGetNumResEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nrevals)
end

function IDAGetNumResEvals(ida_mem,nrevals)
    __IDAGetNumResEvals(convert(IDAMemPtr,ida_mem),pointer(nrevals))
end

function __IDAGetNumLinSolvSetups(ida_mem::IDAMemPtr,nlinsetups::Ptr{Clong})
    ccall((:IDAGetNumLinSolvSetups,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nlinsetups)
end

function IDAGetNumLinSolvSetups(ida_mem,nlinsetups)
    __IDAGetNumLinSolvSetups(convert(IDAMemPtr,ida_mem),pointer(nlinsetups))
end

function __IDAGetNumErrTestFails(ida_mem::IDAMemPtr,netfails::Ptr{Clong})
    ccall((:IDAGetNumErrTestFails,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,netfails)
end

function IDAGetNumErrTestFails(ida_mem,netfails)
    __IDAGetNumErrTestFails(convert(IDAMemPtr,ida_mem),pointer(netfails))
end

function __IDAGetNumBacktrackOps(ida_mem::IDAMemPtr,nbacktr::Ptr{Clong})
    ccall((:IDAGetNumBacktrackOps,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nbacktr)
end

function IDAGetNumBacktrackOps(ida_mem,nbacktr)
    __IDAGetNumBacktrackOps(convert(IDAMemPtr,ida_mem),pointer(nbacktr))
end

function __IDAGetConsistentIC(ida_mem::IDAMemPtr,yy0_mod::N_Vector,yp0_mod::N_Vector)
    ccall((:IDAGetConsistentIC,libsundials_idas),Cint,(IDAMemPtr,N_Vector,N_Vector),ida_mem,yy0_mod,yp0_mod)
end

function IDAGetConsistentIC(ida_mem,yy0_mod,yp0_mod)
    __yy0_mod = convert(NVector,yy0_mod)
    __yp0_mod = convert(NVector,yp0_mod)
    __IDAGetConsistentIC(convert(IDAMemPtr,ida_mem),convert(N_Vector,__yy0_mod),convert(N_Vector,__yp0_mod))
end

function __IDAGetLastOrder(ida_mem::IDAMemPtr,klast::Ptr{Cint})
    ccall((:IDAGetLastOrder,libsundials_idas),Cint,(IDAMemPtr,Ptr{Cint}),ida_mem,klast)
end

function IDAGetLastOrder(ida_mem,klast)
    __IDAGetLastOrder(convert(IDAMemPtr,ida_mem),pointer(klast))
end

function __IDAGetCurrentOrder(ida_mem::IDAMemPtr,kcur::Ptr{Cint})
    ccall((:IDAGetCurrentOrder,libsundials_idas),Cint,(IDAMemPtr,Ptr{Cint}),ida_mem,kcur)
end

function IDAGetCurrentOrder(ida_mem,kcur)
    __IDAGetCurrentOrder(convert(IDAMemPtr,ida_mem),pointer(kcur))
end

function __IDAGetActualInitStep(ida_mem::IDAMemPtr,hinused::Ptr{realtype})
    ccall((:IDAGetActualInitStep,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype}),ida_mem,hinused)
end

function IDAGetActualInitStep(ida_mem,hinused)
    __IDAGetActualInitStep(convert(IDAMemPtr,ida_mem),pointer(hinused))
end

function __IDAGetLastStep(ida_mem::IDAMemPtr,hlast::Ptr{realtype})
    ccall((:IDAGetLastStep,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype}),ida_mem,hlast)
end

function IDAGetLastStep(ida_mem,hlast)
    __IDAGetLastStep(convert(IDAMemPtr,ida_mem),pointer(hlast))
end

function __IDAGetCurrentStep(ida_mem::IDAMemPtr,hcur::Ptr{realtype})
    ccall((:IDAGetCurrentStep,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype}),ida_mem,hcur)
end

function IDAGetCurrentStep(ida_mem,hcur)
    __IDAGetCurrentStep(convert(IDAMemPtr,ida_mem),pointer(hcur))
end

function __IDAGetCurrentTime(ida_mem::IDAMemPtr,tcur::Ptr{realtype})
    ccall((:IDAGetCurrentTime,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype}),ida_mem,tcur)
end

function IDAGetCurrentTime(ida_mem,tcur)
    __IDAGetCurrentTime(convert(IDAMemPtr,ida_mem),pointer(tcur))
end

function __IDAGetTolScaleFactor(ida_mem::IDAMemPtr,tolsfact::Ptr{realtype})
    ccall((:IDAGetTolScaleFactor,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype}),ida_mem,tolsfact)
end

function IDAGetTolScaleFactor(ida_mem,tolsfact)
    __IDAGetTolScaleFactor(convert(IDAMemPtr,ida_mem),pointer(tolsfact))
end

function __IDAGetErrWeights(ida_mem::IDAMemPtr,eweight::N_Vector)
    ccall((:IDAGetErrWeights,libsundials_idas),Cint,(IDAMemPtr,N_Vector),ida_mem,eweight)
end

function IDAGetErrWeights(ida_mem,eweight)
    __eweight = convert(NVector,eweight)
    __IDAGetErrWeights(convert(IDAMemPtr,ida_mem),convert(N_Vector,__eweight))
end

function __IDAGetEstLocalErrors(ida_mem::IDAMemPtr,ele::N_Vector)
    ccall((:IDAGetEstLocalErrors,libsundials_idas),Cint,(IDAMemPtr,N_Vector),ida_mem,ele)
end

function IDAGetEstLocalErrors(ida_mem,ele)
    __ele = convert(NVector,ele)
    __IDAGetEstLocalErrors(convert(IDAMemPtr,ida_mem),convert(N_Vector,__ele))
end

function __IDAGetNumGEvals(ida_mem::IDAMemPtr,ngevals::Ptr{Clong})
    ccall((:IDAGetNumGEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,ngevals)
end

function IDAGetNumGEvals(ida_mem,ngevals)
    __IDAGetNumGEvals(convert(IDAMemPtr,ida_mem),pointer(ngevals))
end

function __IDAGetRootInfo(ida_mem::IDAMemPtr,rootsfound::Ptr{Cint})
    ccall((:IDAGetRootInfo,libsundials_idas),Cint,(IDAMemPtr,Ptr{Cint}),ida_mem,rootsfound)
end

function IDAGetRootInfo(ida_mem,rootsfound)
    __IDAGetRootInfo(convert(IDAMemPtr,ida_mem),pointer(rootsfound))
end

function __IDAGetIntegratorStats(ida_mem::IDAMemPtr,nsteps::Ptr{Clong},nrevals::Ptr{Clong},nlinsetups::Ptr{Clong},netfails::Ptr{Clong},qlast::Ptr{Cint},qcur::Ptr{Cint},hinused::Ptr{realtype},hlast::Ptr{realtype},hcur::Ptr{realtype},tcur::Ptr{realtype})
    ccall((:IDAGetIntegratorStats,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong},Ptr{Clong},Ptr{Clong},Ptr{Clong},Ptr{Cint},Ptr{Cint},Ptr{realtype},Ptr{realtype},Ptr{realtype},Ptr{realtype}),ida_mem,nsteps,nrevals,nlinsetups,netfails,qlast,qcur,hinused,hlast,hcur,tcur)
end

function IDAGetIntegratorStats(ida_mem,nsteps,nrevals,nlinsetups,netfails,qlast,qcur,hinused,hlast,hcur,tcur)
    __IDAGetIntegratorStats(convert(IDAMemPtr,ida_mem),pointer(nsteps),pointer(nrevals),pointer(nlinsetups),pointer(netfails),pointer(qlast),pointer(qcur),pointer(hinused),pointer(hlast),pointer(hcur),pointer(tcur))
end

function __IDAGetNumNonlinSolvIters(ida_mem::IDAMemPtr,nniters::Ptr{Clong})
    ccall((:IDAGetNumNonlinSolvIters,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nniters)
end

function IDAGetNumNonlinSolvIters(ida_mem,nniters)
    __IDAGetNumNonlinSolvIters(convert(IDAMemPtr,ida_mem),pointer(nniters))
end

function __IDAGetNumNonlinSolvConvFails(ida_mem::IDAMemPtr,nncfails::Ptr{Clong})
    ccall((:IDAGetNumNonlinSolvConvFails,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nncfails)
end

function IDAGetNumNonlinSolvConvFails(ida_mem,nncfails)
    __IDAGetNumNonlinSolvConvFails(convert(IDAMemPtr,ida_mem),pointer(nncfails))
end

function __IDAGetNonlinSolvStats(ida_mem::IDAMemPtr,nniters::Ptr{Clong},nncfails::Ptr{Clong})
    ccall((:IDAGetNonlinSolvStats,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong},Ptr{Clong}),ida_mem,nniters,nncfails)
end

function IDAGetNonlinSolvStats(ida_mem,nniters,nncfails)
    __IDAGetNonlinSolvStats(convert(IDAMemPtr,ida_mem),pointer(nniters),pointer(nncfails))
end

function __IDAGetQuad(ida_mem::IDAMemPtr,t::Ptr{realtype},yQout::N_Vector)
    ccall((:IDAGetQuad,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype},N_Vector),ida_mem,t,yQout)
end

function IDAGetQuad(ida_mem,t,yQout)
    __yQout = convert(NVector,yQout)
    __IDAGetQuad(convert(IDAMemPtr,ida_mem),pointer(t),convert(N_Vector,__yQout))
end

function __IDAGetQuadDky(ida_mem::IDAMemPtr,t::realtype,k::Cint,dky::N_Vector)
    ccall((:IDAGetQuadDky,libsundials_idas),Cint,(IDAMemPtr,realtype,Cint,N_Vector),ida_mem,t,k,dky)
end

function IDAGetQuadDky(ida_mem,t,k,dky)
    __dky = convert(NVector,dky)
    __IDAGetQuadDky(convert(IDAMemPtr,ida_mem),t,convert(Cint,k),convert(N_Vector,__dky))
end

function __IDAGetQuadNumRhsEvals(ida_mem::IDAMemPtr,nrhsQevals::Ptr{Clong})
    ccall((:IDAGetQuadNumRhsEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nrhsQevals)
end

function IDAGetQuadNumRhsEvals(ida_mem,nrhsQevals)
    __IDAGetQuadNumRhsEvals(convert(IDAMemPtr,ida_mem),pointer(nrhsQevals))
end

function __IDAGetQuadNumErrTestFails(ida_mem::IDAMemPtr,nQetfails::Ptr{Clong})
    ccall((:IDAGetQuadNumErrTestFails,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nQetfails)
end

function IDAGetQuadNumErrTestFails(ida_mem,nQetfails)
    __IDAGetQuadNumErrTestFails(convert(IDAMemPtr,ida_mem),pointer(nQetfails))
end

function __IDAGetQuadErrWeights(ida_mem::IDAMemPtr,eQweight::N_Vector)
    ccall((:IDAGetQuadErrWeights,libsundials_idas),Cint,(IDAMemPtr,N_Vector),ida_mem,eQweight)
end

function IDAGetQuadErrWeights(ida_mem,eQweight)
    __eQweight = convert(NVector,eQweight)
    __IDAGetQuadErrWeights(convert(IDAMemPtr,ida_mem),convert(N_Vector,__eQweight))
end

function __IDAGetQuadStats(ida_mem::IDAMemPtr,nrhsQevals::Ptr{Clong},nQetfails::Ptr{Clong})
    ccall((:IDAGetQuadStats,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong},Ptr{Clong}),ida_mem,nrhsQevals,nQetfails)
end

function IDAGetQuadStats(ida_mem,nrhsQevals,nQetfails)
    __IDAGetQuadStats(convert(IDAMemPtr,ida_mem),pointer(nrhsQevals),pointer(nQetfails))
end

function __IDAGetSens(ida_mem::IDAMemPtr,tret::Ptr{realtype},yySout::Ptr{N_Vector})
    ccall((:IDAGetSens,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype},Ptr{N_Vector}),ida_mem,tret,yySout)
end

function IDAGetSens(ida_mem,tret,yySout)
    __IDAGetSens(convert(IDAMemPtr,ida_mem),pointer(tret),pointer(yySout))
end

function __IDAGetSens1(ida_mem::IDAMemPtr,tret::Ptr{realtype},is::Cint,yySret::N_Vector)
    ccall((:IDAGetSens1,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype},Cint,N_Vector),ida_mem,tret,is,yySret)
end

function IDAGetSens1(ida_mem,tret,is,yySret)
    __yySret = convert(NVector,yySret)
    __IDAGetSens1(convert(IDAMemPtr,ida_mem),pointer(tret),convert(Cint,is),convert(N_Vector,__yySret))
end

function __IDAGetSensDky(ida_mem::IDAMemPtr,t::realtype,k::Cint,dkyS::Ptr{N_Vector})
    ccall((:IDAGetSensDky,libsundials_idas),Cint,(IDAMemPtr,realtype,Cint,Ptr{N_Vector}),ida_mem,t,k,dkyS)
end

function IDAGetSensDky(ida_mem,t,k,dkyS)
    __IDAGetSensDky(convert(IDAMemPtr,ida_mem),t,convert(Cint,k),pointer(dkyS))
end

function __IDAGetSensDky1(ida_mem::IDAMemPtr,t::realtype,k::Cint,is::Cint,dkyS::N_Vector)
    ccall((:IDAGetSensDky1,libsundials_idas),Cint,(IDAMemPtr,realtype,Cint,Cint,N_Vector),ida_mem,t,k,is,dkyS)
end

function IDAGetSensDky1(ida_mem,t,k,is,dkyS)
    __dkyS = convert(NVector,dkyS)
    __IDAGetSensDky1(convert(IDAMemPtr,ida_mem),t,convert(Cint,k),convert(Cint,is),convert(N_Vector,__dkyS))
end

function __IDAGetSensConsistentIC(ida_mem::IDAMemPtr,yyS0::Ptr{N_Vector},ypS0::Ptr{N_Vector})
    ccall((:IDAGetSensConsistentIC,libsundials_idas),Cint,(IDAMemPtr,Ptr{N_Vector},Ptr{N_Vector}),ida_mem,yyS0,ypS0)
end

function IDAGetSensConsistentIC(ida_mem,yyS0,ypS0)
    __IDAGetSensConsistentIC(convert(IDAMemPtr,ida_mem),pointer(yyS0),pointer(ypS0))
end

function __IDAGetSensNumResEvals(ida_mem::IDAMemPtr,nresSevals::Ptr{Clong})
    ccall((:IDAGetSensNumResEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nresSevals)
end

function IDAGetSensNumResEvals(ida_mem,nresSevals)
    __IDAGetSensNumResEvals(convert(IDAMemPtr,ida_mem),pointer(nresSevals))
end

function __IDAGetNumResEvalsSens(ida_mem::IDAMemPtr,nresevalsS::Ptr{Clong})
    ccall((:IDAGetNumResEvalsSens,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nresevalsS)
end

function IDAGetNumResEvalsSens(ida_mem,nresevalsS)
    __IDAGetNumResEvalsSens(convert(IDAMemPtr,ida_mem),pointer(nresevalsS))
end

function __IDAGetSensNumErrTestFails(ida_mem::IDAMemPtr,nSetfails::Ptr{Clong})
    ccall((:IDAGetSensNumErrTestFails,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nSetfails)
end

function IDAGetSensNumErrTestFails(ida_mem,nSetfails)
    __IDAGetSensNumErrTestFails(convert(IDAMemPtr,ida_mem),pointer(nSetfails))
end

function __IDAGetSensNumLinSolvSetups(ida_mem::IDAMemPtr,nlinsetupsS::Ptr{Clong})
    ccall((:IDAGetSensNumLinSolvSetups,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nlinsetupsS)
end

function IDAGetSensNumLinSolvSetups(ida_mem,nlinsetupsS)
    __IDAGetSensNumLinSolvSetups(convert(IDAMemPtr,ida_mem),pointer(nlinsetupsS))
end

function __IDAGetSensErrWeights(ida_mem::IDAMemPtr,eSweight::N_Vector_S)
    ccall((:IDAGetSensErrWeights,libsundials_idas),Cint,(IDAMemPtr,N_Vector_S),ida_mem,eSweight)
end

function IDAGetSensErrWeights(ida_mem,eSweight)
    __IDAGetSensErrWeights(convert(IDAMemPtr,ida_mem),eSweight)
end

function __IDAGetSensStats(ida_mem::IDAMemPtr,nresSevals::Ptr{Clong},nresevalsS::Ptr{Clong},nSetfails::Ptr{Clong},nlinsetupsS::Ptr{Clong})
    ccall((:IDAGetSensStats,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong},Ptr{Clong},Ptr{Clong},Ptr{Clong}),ida_mem,nresSevals,nresevalsS,nSetfails,nlinsetupsS)
end

function IDAGetSensStats(ida_mem,nresSevals,nresevalsS,nSetfails,nlinsetupsS)
    __IDAGetSensStats(convert(IDAMemPtr,ida_mem),pointer(nresSevals),pointer(nresevalsS),pointer(nSetfails),pointer(nlinsetupsS))
end

function __IDAGetSensNumNonlinSolvIters(ida_mem::IDAMemPtr,nSniters::Ptr{Clong})
    ccall((:IDAGetSensNumNonlinSolvIters,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nSniters)
end

function IDAGetSensNumNonlinSolvIters(ida_mem,nSniters)
    __IDAGetSensNumNonlinSolvIters(convert(IDAMemPtr,ida_mem),pointer(nSniters))
end

function __IDAGetSensNumNonlinSolvConvFails(ida_mem::IDAMemPtr,nSncfails::Ptr{Clong})
    ccall((:IDAGetSensNumNonlinSolvConvFails,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nSncfails)
end

function IDAGetSensNumNonlinSolvConvFails(ida_mem,nSncfails)
    __IDAGetSensNumNonlinSolvConvFails(convert(IDAMemPtr,ida_mem),pointer(nSncfails))
end

function __IDAGetSensNonlinSolvStats(ida_mem::IDAMemPtr,nSniters::Ptr{Clong},nSncfails::Ptr{Clong})
    ccall((:IDAGetSensNonlinSolvStats,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong},Ptr{Clong}),ida_mem,nSniters,nSncfails)
end

function IDAGetSensNonlinSolvStats(ida_mem,nSniters,nSncfails)
    __IDAGetSensNonlinSolvStats(convert(IDAMemPtr,ida_mem),pointer(nSniters),pointer(nSncfails))
end

function __IDAGetQuadSensNumRhsEvals(ida_mem::IDAMemPtr,nrhsQSevals::Ptr{Clong})
    ccall((:IDAGetQuadSensNumRhsEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nrhsQSevals)
end

function IDAGetQuadSensNumRhsEvals(ida_mem,nrhsQSevals)
    __IDAGetQuadSensNumRhsEvals(convert(IDAMemPtr,ida_mem),pointer(nrhsQSevals))
end

function __IDAGetQuadSensNumErrTestFails(ida_mem::IDAMemPtr,nQSetfails::Ptr{Clong})
    ccall((:IDAGetQuadSensNumErrTestFails,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nQSetfails)
end

function IDAGetQuadSensNumErrTestFails(ida_mem,nQSetfails)
    __IDAGetQuadSensNumErrTestFails(convert(IDAMemPtr,ida_mem),pointer(nQSetfails))
end

function __IDAGetQuadSensErrWeights(ida_mem::IDAMemPtr,eQSweight::Ptr{N_Vector})
    ccall((:IDAGetQuadSensErrWeights,libsundials_idas),Cint,(IDAMemPtr,Ptr{N_Vector}),ida_mem,eQSweight)
end

function IDAGetQuadSensErrWeights(ida_mem,eQSweight)
    __IDAGetQuadSensErrWeights(convert(IDAMemPtr,ida_mem),pointer(eQSweight))
end

function __IDAGetQuadSensStats(ida_mem::IDAMemPtr,nrhsQSevals::Ptr{Clong},nQSetfails::Ptr{Clong})
    ccall((:IDAGetQuadSensStats,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong},Ptr{Clong}),ida_mem,nrhsQSevals,nQSetfails)
end

function IDAGetQuadSensStats(ida_mem,nrhsQSevals,nQSetfails)
    __IDAGetQuadSensStats(convert(IDAMemPtr,ida_mem),pointer(nrhsQSevals),pointer(nQSetfails))
end

function __IDAGetQuadSens(ida_mem::IDAMemPtr,tret::Ptr{realtype},yyQSout::Ptr{N_Vector})
    ccall((:IDAGetQuadSens,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype},Ptr{N_Vector}),ida_mem,tret,yyQSout)
end

function IDAGetQuadSens(ida_mem,tret,yyQSout)
    __IDAGetQuadSens(convert(IDAMemPtr,ida_mem),pointer(tret),pointer(yyQSout))
end

function __IDAGetQuadSens1(ida_mem::IDAMemPtr,tret::Ptr{realtype},is::Cint,yyQSret::N_Vector)
    ccall((:IDAGetQuadSens1,libsundials_idas),Cint,(IDAMemPtr,Ptr{realtype},Cint,N_Vector),ida_mem,tret,is,yyQSret)
end

function IDAGetQuadSens1(ida_mem,tret,is,yyQSret)
    __yyQSret = convert(NVector,yyQSret)
    __IDAGetQuadSens1(convert(IDAMemPtr,ida_mem),pointer(tret),convert(Cint,is),convert(N_Vector,__yyQSret))
end

function __IDAGetQuadSensDky(ida_mem::IDAMemPtr,t::realtype,k::Cint,dkyQS::Ptr{N_Vector})
    ccall((:IDAGetQuadSensDky,libsundials_idas),Cint,(IDAMemPtr,realtype,Cint,Ptr{N_Vector}),ida_mem,t,k,dkyQS)
end

function IDAGetQuadSensDky(ida_mem,t,k,dkyQS)
    __IDAGetQuadSensDky(convert(IDAMemPtr,ida_mem),t,convert(Cint,k),pointer(dkyQS))
end

function __IDAGetQuadSensDky1(ida_mem::IDAMemPtr,t::realtype,k::Cint,is::Cint,dkyQS::N_Vector)
    ccall((:IDAGetQuadSensDky1,libsundials_idas),Cint,(IDAMemPtr,realtype,Cint,Cint,N_Vector),ida_mem,t,k,is,dkyQS)
end

function IDAGetQuadSensDky1(ida_mem,t,k,is,dkyQS)
    __dkyQS = convert(NVector,dkyQS)
    __IDAGetQuadSensDky1(convert(IDAMemPtr,ida_mem),t,convert(Cint,k),convert(Cint,is),convert(N_Vector,__dkyQS))
end

function __IDAGetReturnFlagName(flag::Clong)
    ccall((:IDAGetReturnFlagName,libsundials_idas),Ptr{UInt8},(Clong,),flag)
end

function IDAGetReturnFlagName(flag)
    __IDAGetReturnFlagName(convert(Clong,flag))
end

function IDAFree(ida_mem::Ref{IDAMemPtr})
    ccall((:IDAFree,libsundials_idas),Void,(Ref{IDAMemPtr},),ida_mem)
end

function __IDAQuadFree(ida_mem::IDAMemPtr)
    ccall((:IDAQuadFree,libsundials_idas),Void,(IDAMemPtr,),ida_mem)
end

function IDAQuadFree(ida_mem)
    __IDAQuadFree(convert(IDAMemPtr,ida_mem))
end

function __IDASensFree(ida_mem::IDAMemPtr)
    ccall((:IDASensFree,libsundials_idas),Void,(IDAMemPtr,),ida_mem)
end

function IDASensFree(ida_mem)
    __IDASensFree(convert(IDAMemPtr,ida_mem))
end

function __IDAQuadSensFree(ida_mem::IDAMemPtr)
    ccall((:IDAQuadSensFree,libsundials_idas),Void,(IDAMemPtr,),ida_mem)
end

function IDAQuadSensFree(ida_mem)
    __IDAQuadSensFree(convert(IDAMemPtr,ida_mem))
end

function __IDAAdjInit(ida_mem::IDAMemPtr,steps::Clong,interp::Cint)
    ccall((:IDAAdjInit,libsundials_idas),Cint,(IDAMemPtr,Clong,Cint),ida_mem,steps,interp)
end

function IDAAdjInit(ida_mem,steps,interp)
    __IDAAdjInit(convert(IDAMemPtr,ida_mem),convert(Clong,steps),convert(Cint,interp))
end

function __IDAAdjReInit(ida_mem::IDAMemPtr)
    ccall((:IDAAdjReInit,libsundials_idas),Cint,(IDAMemPtr,),ida_mem)
end

function IDAAdjReInit(ida_mem)
    __IDAAdjReInit(convert(IDAMemPtr,ida_mem))
end

function __IDAAdjFree(ida_mem::IDAMemPtr)
    ccall((:IDAAdjFree,libsundials_idas),Void,(IDAMemPtr,),ida_mem)
end

function IDAAdjFree(ida_mem)
    __IDAAdjFree(convert(IDAMemPtr,ida_mem))
end

function __IDACreateB(ida_mem::IDAMemPtr,which::Ptr{Cint})
    ccall((:IDACreateB,libsundials_idas),Cint,(IDAMemPtr,Ptr{Cint}),ida_mem,which)
end

function IDACreateB(ida_mem,which)
    __IDACreateB(convert(IDAMemPtr,ida_mem),pointer(which))
end

function __IDAInitB(ida_mem::IDAMemPtr,which::Cint,resB::IDAResFnB,tB0::realtype,yyB0::N_Vector,ypB0::N_Vector)
    ccall((:IDAInitB,libsundials_idas),Cint,(IDAMemPtr,Cint,IDAResFnB,realtype,N_Vector,N_Vector),ida_mem,which,resB,tB0,yyB0,ypB0)
end

function IDAInitB(ida_mem,which,resB,tB0,yyB0,ypB0)
    __yyB0 = convert(NVector,yyB0)
    __ypB0 = convert(NVector,ypB0)
    __IDAInitB(convert(IDAMemPtr,ida_mem),convert(Cint,which),resB,tB0,convert(N_Vector,__yyB0),convert(N_Vector,__ypB0))
end

function __IDAInitBS(ida_mem::IDAMemPtr,which::Cint,resS::IDAResFnBS,tB0::realtype,yyB0::N_Vector,ypB0::N_Vector)
    ccall((:IDAInitBS,libsundials_idas),Cint,(IDAMemPtr,Cint,IDAResFnBS,realtype,N_Vector,N_Vector),ida_mem,which,resS,tB0,yyB0,ypB0)
end

function IDAInitBS(ida_mem,which,resS,tB0,yyB0,ypB0)
    __yyB0 = convert(NVector,yyB0)
    __ypB0 = convert(NVector,ypB0)
    __IDAInitBS(convert(IDAMemPtr,ida_mem),convert(Cint,which),resS,tB0,convert(N_Vector,__yyB0),convert(N_Vector,__ypB0))
end

function __IDAReInitB(ida_mem::IDAMemPtr,which::Cint,tB0::realtype,yyB0::N_Vector,ypB0::N_Vector)
    ccall((:IDAReInitB,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype,N_Vector,N_Vector),ida_mem,which,tB0,yyB0,ypB0)
end

function IDAReInitB(ida_mem,which,tB0,yyB0,ypB0)
    __yyB0 = convert(NVector,yyB0)
    __ypB0 = convert(NVector,ypB0)
    __IDAReInitB(convert(IDAMemPtr,ida_mem),convert(Cint,which),tB0,convert(N_Vector,__yyB0),convert(N_Vector,__ypB0))
end

function __IDASStolerancesB(ida_mem::IDAMemPtr,which::Cint,relTolB::realtype,absTolB::realtype)
    ccall((:IDASStolerancesB,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype,realtype),ida_mem,which,relTolB,absTolB)
end

function IDASStolerancesB(ida_mem,which,relTolB,absTolB)
    __IDASStolerancesB(convert(IDAMemPtr,ida_mem),convert(Cint,which),relTolB,absTolB)
end

function __IDASVtolerancesB(ida_mem::IDAMemPtr,which::Cint,relTolB::realtype,absTolB::N_Vector)
    ccall((:IDASVtolerancesB,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype,N_Vector),ida_mem,which,relTolB,absTolB)
end

function IDASVtolerancesB(ida_mem,which,relTolB,absTolB)
    __absTolB = convert(NVector,absTolB)
    __IDASVtolerancesB(convert(IDAMemPtr,ida_mem),convert(Cint,which),relTolB,convert(N_Vector,__absTolB))
end

function __IDAQuadInitB(ida_mem::IDAMemPtr,which::Cint,rhsQB::IDAQuadRhsFnB,yQB0::N_Vector)
    ccall((:IDAQuadInitB,libsundials_idas),Cint,(IDAMemPtr,Cint,IDAQuadRhsFnB,N_Vector),ida_mem,which,rhsQB,yQB0)
end

function IDAQuadInitB(ida_mem,which,rhsQB,yQB0)
    __yQB0 = convert(NVector,yQB0)
    __IDAQuadInitB(convert(IDAMemPtr,ida_mem),convert(Cint,which),rhsQB,convert(N_Vector,__yQB0))
end

function __IDAQuadInitBS(ida_mem::IDAMemPtr,which::Cint,rhsQS::IDAQuadRhsFnBS,yQB0::N_Vector)
    ccall((:IDAQuadInitBS,libsundials_idas),Cint,(IDAMemPtr,Cint,IDAQuadRhsFnBS,N_Vector),ida_mem,which,rhsQS,yQB0)
end

function IDAQuadInitBS(ida_mem,which,rhsQS,yQB0)
    __yQB0 = convert(NVector,yQB0)
    __IDAQuadInitBS(convert(IDAMemPtr,ida_mem),convert(Cint,which),rhsQS,convert(N_Vector,__yQB0))
end

function __IDAQuadReInitB(ida_mem::IDAMemPtr,which::Cint,yQB0::N_Vector)
    ccall((:IDAQuadReInitB,libsundials_idas),Cint,(IDAMemPtr,Cint,N_Vector),ida_mem,which,yQB0)
end

function IDAQuadReInitB(ida_mem,which,yQB0)
    __yQB0 = convert(NVector,yQB0)
    __IDAQuadReInitB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(N_Vector,__yQB0))
end

function __IDAQuadSStolerancesB(ida_mem::IDAMemPtr,which::Cint,reltolQB::realtype,abstolQB::realtype)
    ccall((:IDAQuadSStolerancesB,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype,realtype),ida_mem,which,reltolQB,abstolQB)
end

function IDAQuadSStolerancesB(ida_mem,which,reltolQB,abstolQB)
    __IDAQuadSStolerancesB(convert(IDAMemPtr,ida_mem),convert(Cint,which),reltolQB,abstolQB)
end

function __IDAQuadSVtolerancesB(ida_mem::IDAMemPtr,which::Cint,reltolQB::realtype,abstolQB::N_Vector)
    ccall((:IDAQuadSVtolerancesB,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype,N_Vector),ida_mem,which,reltolQB,abstolQB)
end

function IDAQuadSVtolerancesB(ida_mem,which,reltolQB,abstolQB)
    __abstolQB = convert(NVector,abstolQB)
    __IDAQuadSVtolerancesB(convert(IDAMemPtr,ida_mem),convert(Cint,which),reltolQB,convert(N_Vector,__abstolQB))
end

function __IDACalcICB(ida_mem::IDAMemPtr,which::Cint,tout1::realtype,yy0::N_Vector,yp0::N_Vector)
    ccall((:IDACalcICB,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype,N_Vector,N_Vector),ida_mem,which,tout1,yy0,yp0)
end

function IDACalcICB(ida_mem,which,tout1,yy0,yp0)
    __yy0 = convert(NVector,yy0)
    __yp0 = convert(NVector,yp0)
    __IDACalcICB(convert(IDAMemPtr,ida_mem),convert(Cint,which),tout1,convert(N_Vector,__yy0),convert(N_Vector,__yp0))
end

function __IDACalcICBS(ida_mem::IDAMemPtr,which::Cint,tout1::realtype,yy0::N_Vector,yp0::N_Vector,yyS0::Ptr{N_Vector},ypS0::Ptr{N_Vector})
    ccall((:IDACalcICBS,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype,N_Vector,N_Vector,Ptr{N_Vector},Ptr{N_Vector}),ida_mem,which,tout1,yy0,yp0,yyS0,ypS0)
end

function IDACalcICBS(ida_mem,which,tout1,yy0,yp0,yyS0,ypS0)
    __yy0 = convert(NVector,yy0)
    __yp0 = convert(NVector,yp0)
    __IDACalcICBS(convert(IDAMemPtr,ida_mem),convert(Cint,which),tout1,convert(N_Vector,__yy0),convert(N_Vector,__yp0),pointer(yyS0),pointer(ypS0))
end

function __IDASolveF(ida_mem::IDAMemPtr,tout::realtype,tret::Ptr{realtype},yret::N_Vector,ypret::N_Vector,itask::Cint,ncheckPtr::Ptr{Cint})
    ccall((:IDASolveF,libsundials_idas),Cint,(IDAMemPtr,realtype,Ptr{realtype},N_Vector,N_Vector,Cint,Ptr{Cint}),ida_mem,tout,tret,yret,ypret,itask,ncheckPtr)
end

function IDASolveF(ida_mem,tout,tret,yret,ypret,itask,ncheckPtr)
    __yret = convert(NVector,yret)
    __ypret = convert(NVector,ypret)
    __IDASolveF(convert(IDAMemPtr,ida_mem),tout,pointer(tret),convert(N_Vector,__yret),convert(N_Vector,__ypret),convert(Cint,itask),pointer(ncheckPtr))
end

function __IDASolveB(ida_mem::IDAMemPtr,tBout::realtype,itaskB::Cint)
    ccall((:IDASolveB,libsundials_idas),Cint,(IDAMemPtr,realtype,Cint),ida_mem,tBout,itaskB)
end

function IDASolveB(ida_mem,tBout,itaskB)
    __IDASolveB(convert(IDAMemPtr,ida_mem),tBout,convert(Cint,itaskB))
end

function __IDASetAdjNoSensi(ida_mem::IDAMemPtr)
    ccall((:IDASetAdjNoSensi,libsundials_idas),Cint,(IDAMemPtr,),ida_mem)
end

function IDASetAdjNoSensi(ida_mem)
    __IDASetAdjNoSensi(convert(IDAMemPtr,ida_mem))
end

function __IDASetUserDataB(ida_mem::IDAMemPtr,which::Cint,user_dataB::Any)
    ccall((:IDASetUserDataB,libsundials_idas),Cint,(IDAMemPtr,Cint,Any),ida_mem,which,user_dataB)
end

function IDASetUserDataB(ida_mem,which,user_dataB)
    __IDASetUserDataB(convert(IDAMemPtr,ida_mem),convert(Cint,which),user_dataB)
end

function __IDASetMaxOrdB(ida_mem::IDAMemPtr,which::Cint,maxordB::Cint)
    ccall((:IDASetMaxOrdB,libsundials_idas),Cint,(IDAMemPtr,Cint,Cint),ida_mem,which,maxordB)
end

function IDASetMaxOrdB(ida_mem,which,maxordB)
    __IDASetMaxOrdB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Cint,maxordB))
end

function __IDASetMaxNumStepsB(ida_mem::IDAMemPtr,which::Cint,mxstepsB::Clong)
    ccall((:IDASetMaxNumStepsB,libsundials_idas),Cint,(IDAMemPtr,Cint,Clong),ida_mem,which,mxstepsB)
end

function IDASetMaxNumStepsB(ida_mem,which,mxstepsB)
    __IDASetMaxNumStepsB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Clong,mxstepsB))
end

function __IDASetInitStepB(ida_mem::IDAMemPtr,which::Cint,hinB::realtype)
    ccall((:IDASetInitStepB,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype),ida_mem,which,hinB)
end

function IDASetInitStepB(ida_mem,which,hinB)
    __IDASetInitStepB(convert(IDAMemPtr,ida_mem),convert(Cint,which),hinB)
end

function __IDASetMaxStepB(ida_mem::IDAMemPtr,which::Cint,hmaxB::realtype)
    ccall((:IDASetMaxStepB,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype),ida_mem,which,hmaxB)
end

function IDASetMaxStepB(ida_mem,which,hmaxB)
    __IDASetMaxStepB(convert(IDAMemPtr,ida_mem),convert(Cint,which),hmaxB)
end

function __IDASetSuppressAlgB(ida_mem::IDAMemPtr,which::Cint,suppressalgB::Cint)
    ccall((:IDASetSuppressAlgB,libsundials_idas),Cint,(IDAMemPtr,Cint,Cint),ida_mem,which,suppressalgB)
end

function IDASetSuppressAlgB(ida_mem,which,suppressalgB)
    __IDASetSuppressAlgB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Cint,suppressalgB))
end

function __IDASetIdB(ida_mem::IDAMemPtr,which::Cint,idB::N_Vector)
    ccall((:IDASetIdB,libsundials_idas),Cint,(IDAMemPtr,Cint,N_Vector),ida_mem,which,idB)
end

function IDASetIdB(ida_mem,which,idB)
    __idB = convert(NVector,idB)
    __IDASetIdB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(N_Vector,__idB))
end

function __IDASetConstraintsB(ida_mem::IDAMemPtr,which::Cint,constraintsB::N_Vector)
    ccall((:IDASetConstraintsB,libsundials_idas),Cint,(IDAMemPtr,Cint,N_Vector),ida_mem,which,constraintsB)
end

function IDASetConstraintsB(ida_mem,which,constraintsB)
    __constraintsB = convert(NVector,constraintsB)
    __IDASetConstraintsB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(N_Vector,__constraintsB))
end

function __IDASetQuadErrConB(ida_mem::IDAMemPtr,which::Cint,errconQB::Cint)
    ccall((:IDASetQuadErrConB,libsundials_idas),Cint,(IDAMemPtr,Cint,Cint),ida_mem,which,errconQB)
end

function IDASetQuadErrConB(ida_mem,which,errconQB)
    __IDASetQuadErrConB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Cint,errconQB))
end

function __IDAGetB(ida_mem::IDAMemPtr,which::Cint,tret::Ptr{realtype},yy::N_Vector,yp::N_Vector)
    ccall((:IDAGetB,libsundials_idas),Cint,(IDAMemPtr,Cint,Ptr{realtype},N_Vector,N_Vector),ida_mem,which,tret,yy,yp)
end

function IDAGetB(ida_mem,which,tret,yy,yp)
    __yy = convert(NVector,yy)
    __yp = convert(NVector,yp)
    __IDAGetB(convert(IDAMemPtr,ida_mem),convert(Cint,which),pointer(tret),convert(N_Vector,__yy),convert(N_Vector,__yp))
end

function __IDAGetQuadB(ida_mem::IDAMemPtr,which::Cint,tret::Ptr{realtype},qB::N_Vector)
    ccall((:IDAGetQuadB,libsundials_idas),Cint,(IDAMemPtr,Cint,Ptr{realtype},N_Vector),ida_mem,which,tret,qB)
end

function IDAGetQuadB(ida_mem,which,tret,qB)
    __qB = convert(NVector,qB)
    __IDAGetQuadB(convert(IDAMemPtr,ida_mem),convert(Cint,which),pointer(tret),convert(N_Vector,__qB))
end

function __IDAGetAdjIDABmem(ida_mem::IDAMemPtr,which::Cint)
    ccall((:IDAGetAdjIDABmem,libsundials_idas),Ptr{Void},(IDAMemPtr,Cint),ida_mem,which)
end

function IDAGetAdjIDABmem(ida_mem,which)
    __IDAGetAdjIDABmem(convert(IDAMemPtr,ida_mem),convert(Cint,which))
end

function __IDAGetConsistentICB(ida_mem::IDAMemPtr,which::Cint,yyB0::N_Vector,ypB0::N_Vector)
    ccall((:IDAGetConsistentICB,libsundials_idas),Cint,(IDAMemPtr,Cint,N_Vector,N_Vector),ida_mem,which,yyB0,ypB0)
end

function IDAGetConsistentICB(ida_mem,which,yyB0,ypB0)
    __yyB0 = convert(NVector,yyB0)
    __ypB0 = convert(NVector,ypB0)
    __IDAGetConsistentICB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(N_Vector,__yyB0),convert(N_Vector,__ypB0))
end

function __IDAGetAdjY(ida_mem::IDAMemPtr,t::realtype,yy::N_Vector,yp::N_Vector)
    ccall((:IDAGetAdjY,libsundials_idas),Cint,(IDAMemPtr,realtype,N_Vector,N_Vector),ida_mem,t,yy,yp)
end

function IDAGetAdjY(ida_mem,t,yy,yp)
    __yy = convert(NVector,yy)
    __yp = convert(NVector,yp)
    __IDAGetAdjY(convert(IDAMemPtr,ida_mem),t,convert(N_Vector,__yy),convert(N_Vector,__yp))
end

function __IDAGetAdjCheckPointsInfo(ida_mem::IDAMemPtr,ckpnt::Ptr{IDAadjCheckPointRec})
    ccall((:IDAGetAdjCheckPointsInfo,libsundials_idas),Cint,(IDAMemPtr,Ptr{IDAadjCheckPointRec}),ida_mem,ckpnt)
end

function IDAGetAdjCheckPointsInfo(ida_mem,ckpnt)
    __IDAGetAdjCheckPointsInfo(convert(IDAMemPtr,ida_mem),pointer(ckpnt))
end

function __IDAGetAdjDataPointHermite(ida_mem::IDAMemPtr,which::Cint,t::Ptr{realtype},yy::N_Vector,yd::N_Vector)
    ccall((:IDAGetAdjDataPointHermite,libsundials_idas),Cint,(IDAMemPtr,Cint,Ptr{realtype},N_Vector,N_Vector),ida_mem,which,t,yy,yd)
end

function IDAGetAdjDataPointHermite(ida_mem,which,t,yy,yd)
    __yy = convert(NVector,yy)
    __yd = convert(NVector,yd)
    __IDAGetAdjDataPointHermite(convert(IDAMemPtr,ida_mem),convert(Cint,which),pointer(t),convert(N_Vector,__yy),convert(N_Vector,__yd))
end

function __IDAGetAdjDataPointPolynomial(ida_mem::IDAMemPtr,which::Cint,t::Ptr{realtype},order::Ptr{Cint},y::N_Vector)
    ccall((:IDAGetAdjDataPointPolynomial,libsundials_idas),Cint,(IDAMemPtr,Cint,Ptr{realtype},Ptr{Cint},N_Vector),ida_mem,which,t,order,y)
end

function IDAGetAdjDataPointPolynomial(ida_mem,which,t,order,y)
    __y = convert(NVector,y)
    __IDAGetAdjDataPointPolynomial(convert(IDAMemPtr,ida_mem),convert(Cint,which),pointer(t),pointer(order),convert(N_Vector,__y))
end

function __IDAGetAdjCurrentCheckPoint(ida_mem::IDAMemPtr,addr::Ptr{Ptr{Void}})
    ccall((:IDAGetAdjCurrentCheckPoint,libsundials_idas),Cint,(IDAMemPtr,Ptr{Ptr{Void}}),ida_mem,addr)
end

function IDAGetAdjCurrentCheckPoint(ida_mem,addr)
    __IDAGetAdjCurrentCheckPoint(convert(IDAMemPtr,ida_mem),pointer(addr))
end
# Julia wrapper for header: /home/astukalov/.julia/v0.5/Sundials/deps/usr/include/idas/idas_direct.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

function __IDADlsSetDenseJacFn(ida_mem::IDAMemPtr,jac::IDADlsDenseJacFn)
    ccall((:IDADlsSetDenseJacFn,libsundials_idas),Cint,(IDAMemPtr,IDADlsDenseJacFn),ida_mem,jac)
end

function IDADlsSetDenseJacFn(ida_mem,jac)
    __IDADlsSetDenseJacFn(convert(IDAMemPtr,ida_mem),jac)
end

function __IDADlsSetBandJacFn(ida_mem::IDAMemPtr,jac::IDADlsBandJacFn)
    ccall((:IDADlsSetBandJacFn,libsundials_idas),Cint,(IDAMemPtr,IDADlsBandJacFn),ida_mem,jac)
end

function IDADlsSetBandJacFn(ida_mem,jac)
    __IDADlsSetBandJacFn(convert(IDAMemPtr,ida_mem),jac)
end

function __IDADlsGetWorkSpace(ida_mem::IDAMemPtr,lenrwLS::Ptr{Clong},leniwLS::Ptr{Clong})
    ccall((:IDADlsGetWorkSpace,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong},Ptr{Clong}),ida_mem,lenrwLS,leniwLS)
end

function IDADlsGetWorkSpace(ida_mem,lenrwLS,leniwLS)
    __IDADlsGetWorkSpace(convert(IDAMemPtr,ida_mem),pointer(lenrwLS),pointer(leniwLS))
end

function __IDADlsGetNumJacEvals(ida_mem::IDAMemPtr,njevals::Ptr{Clong})
    ccall((:IDADlsGetNumJacEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,njevals)
end

function IDADlsGetNumJacEvals(ida_mem,njevals)
    __IDADlsGetNumJacEvals(convert(IDAMemPtr,ida_mem),pointer(njevals))
end

function __IDADlsGetNumResEvals(ida_mem::IDAMemPtr,nfevalsLS::Ptr{Clong})
    ccall((:IDADlsGetNumResEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nfevalsLS)
end

function IDADlsGetNumResEvals(ida_mem,nfevalsLS)
    __IDADlsGetNumResEvals(convert(IDAMemPtr,ida_mem),pointer(nfevalsLS))
end

function __IDADlsGetLastFlag(ida_mem::IDAMemPtr,flag::Ptr{Clong})
    ccall((:IDADlsGetLastFlag,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,flag)
end

function IDADlsGetLastFlag(ida_mem,flag)
    __IDADlsGetLastFlag(convert(IDAMemPtr,ida_mem),pointer(flag))
end

function __IDADlsGetReturnFlagName(flag::Clong)
    ccall((:IDADlsGetReturnFlagName,libsundials_idas),Ptr{UInt8},(Clong,),flag)
end

function IDADlsGetReturnFlagName(flag)
    __IDADlsGetReturnFlagName(convert(Clong,flag))
end

function __IDADlsSetDenseJacFnB(ida_mem::IDAMemPtr,which::Cint,jacB::IDADlsDenseJacFnB)
    ccall((:IDADlsSetDenseJacFnB,libsundials_idas),Cint,(IDAMemPtr,Cint,IDADlsDenseJacFnB),ida_mem,which,jacB)
end

function IDADlsSetDenseJacFnB(ida_mem,which,jacB)
    __IDADlsSetDenseJacFnB(convert(IDAMemPtr,ida_mem),convert(Cint,which),jacB)
end

function __IDADlsSetBandJacFnB(idaa_mem::IDAMemPtr,which::Cint,jacB::IDADlsBandJacFnB)
    ccall((:IDADlsSetBandJacFnB,libsundials_idas),Cint,(IDAMemPtr,Cint,IDADlsBandJacFnB),idaa_mem,which,jacB)
end

function IDADlsSetBandJacFnB(idaa_mem,which,jacB)
    __IDADlsSetBandJacFnB(convert(IDAMemPtr,idaa_mem),convert(Cint,which),jacB)
end
# Julia wrapper for header: /home/astukalov/.julia/v0.5/Sundials/deps/usr/include/idas/idas_spils.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

function __IDASpilsSetPreconditioner(ida_mem::IDAMemPtr,pset::IDASpilsPrecSetupFn,psolve::IDASpilsPrecSolveFn)
    ccall((:IDASpilsSetPreconditioner,libsundials_idas),Cint,(IDAMemPtr,IDASpilsPrecSetupFn,IDASpilsPrecSolveFn),ida_mem,pset,psolve)
end

function IDASpilsSetPreconditioner(ida_mem,pset,psolve)
    __IDASpilsSetPreconditioner(convert(IDAMemPtr,ida_mem),pset,psolve)
end

function __IDASpilsSetJacTimesVecFn(ida_mem::IDAMemPtr,jtv::IDASpilsJacTimesVecFn)
    ccall((:IDASpilsSetJacTimesVecFn,libsundials_idas),Cint,(IDAMemPtr,IDASpilsJacTimesVecFn),ida_mem,jtv)
end

function IDASpilsSetJacTimesVecFn(ida_mem,jtv)
    __IDASpilsSetJacTimesVecFn(convert(IDAMemPtr,ida_mem),jtv)
end

function __IDASpilsSetGSType(ida_mem::IDAMemPtr,gstype::Cint)
    ccall((:IDASpilsSetGSType,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,gstype)
end

function IDASpilsSetGSType(ida_mem,gstype)
    __IDASpilsSetGSType(convert(IDAMemPtr,ida_mem),convert(Cint,gstype))
end

function __IDASpilsSetMaxRestarts(ida_mem::IDAMemPtr,maxrs::Cint)
    ccall((:IDASpilsSetMaxRestarts,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxrs)
end

function IDASpilsSetMaxRestarts(ida_mem,maxrs)
    __IDASpilsSetMaxRestarts(convert(IDAMemPtr,ida_mem),convert(Cint,maxrs))
end

function __IDASpilsSetMaxl(ida_mem::IDAMemPtr,maxl::Cint)
    ccall((:IDASpilsSetMaxl,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxl)
end

function IDASpilsSetMaxl(ida_mem,maxl)
    __IDASpilsSetMaxl(convert(IDAMemPtr,ida_mem),convert(Cint,maxl))
end

function __IDASpilsSetEpsLin(ida_mem::IDAMemPtr,eplifac::realtype)
    ccall((:IDASpilsSetEpsLin,libsundials_idas),Cint,(IDAMemPtr,realtype),ida_mem,eplifac)
end

function IDASpilsSetEpsLin(ida_mem,eplifac)
    __IDASpilsSetEpsLin(convert(IDAMemPtr,ida_mem),eplifac)
end

function __IDASpilsSetIncrementFactor(ida_mem::IDAMemPtr,dqincfac::realtype)
    ccall((:IDASpilsSetIncrementFactor,libsundials_idas),Cint,(IDAMemPtr,realtype),ida_mem,dqincfac)
end

function IDASpilsSetIncrementFactor(ida_mem,dqincfac)
    __IDASpilsSetIncrementFactor(convert(IDAMemPtr,ida_mem),dqincfac)
end

function __IDASpilsGetWorkSpace(ida_mem::IDAMemPtr,lenrwLS::Ptr{Clong},leniwLS::Ptr{Clong})
    ccall((:IDASpilsGetWorkSpace,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong},Ptr{Clong}),ida_mem,lenrwLS,leniwLS)
end

function IDASpilsGetWorkSpace(ida_mem,lenrwLS,leniwLS)
    __IDASpilsGetWorkSpace(convert(IDAMemPtr,ida_mem),pointer(lenrwLS),pointer(leniwLS))
end

function __IDASpilsGetNumPrecEvals(ida_mem::IDAMemPtr,npevals::Ptr{Clong})
    ccall((:IDASpilsGetNumPrecEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,npevals)
end

function IDASpilsGetNumPrecEvals(ida_mem,npevals)
    __IDASpilsGetNumPrecEvals(convert(IDAMemPtr,ida_mem),pointer(npevals))
end

function __IDASpilsGetNumPrecSolves(ida_mem::IDAMemPtr,npsolves::Ptr{Clong})
    ccall((:IDASpilsGetNumPrecSolves,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,npsolves)
end

function IDASpilsGetNumPrecSolves(ida_mem,npsolves)
    __IDASpilsGetNumPrecSolves(convert(IDAMemPtr,ida_mem),pointer(npsolves))
end

function __IDASpilsGetNumLinIters(ida_mem::IDAMemPtr,nliters::Ptr{Clong})
    ccall((:IDASpilsGetNumLinIters,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nliters)
end

function IDASpilsGetNumLinIters(ida_mem,nliters)
    __IDASpilsGetNumLinIters(convert(IDAMemPtr,ida_mem),pointer(nliters))
end

function __IDASpilsGetNumConvFails(ida_mem::IDAMemPtr,nlcfails::Ptr{Clong})
    ccall((:IDASpilsGetNumConvFails,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nlcfails)
end

function IDASpilsGetNumConvFails(ida_mem,nlcfails)
    __IDASpilsGetNumConvFails(convert(IDAMemPtr,ida_mem),pointer(nlcfails))
end

function __IDASpilsGetNumJtimesEvals(ida_mem::IDAMemPtr,njvevals::Ptr{Clong})
    ccall((:IDASpilsGetNumJtimesEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,njvevals)
end

function IDASpilsGetNumJtimesEvals(ida_mem,njvevals)
    __IDASpilsGetNumJtimesEvals(convert(IDAMemPtr,ida_mem),pointer(njvevals))
end

function __IDASpilsGetNumResEvals(ida_mem::IDAMemPtr,nrevalsLS::Ptr{Clong})
    ccall((:IDASpilsGetNumResEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,nrevalsLS)
end

function IDASpilsGetNumResEvals(ida_mem,nrevalsLS)
    __IDASpilsGetNumResEvals(convert(IDAMemPtr,ida_mem),pointer(nrevalsLS))
end

function __IDASpilsGetLastFlag(ida_mem::IDAMemPtr,flag::Ptr{Clong})
    ccall((:IDASpilsGetLastFlag,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,flag)
end

function IDASpilsGetLastFlag(ida_mem,flag)
    __IDASpilsGetLastFlag(convert(IDAMemPtr,ida_mem),pointer(flag))
end

function __IDASpilsGetReturnFlagName(flag::Clong)
    ccall((:IDASpilsGetReturnFlagName,libsundials_idas),Ptr{UInt8},(Clong,),flag)
end

function IDASpilsGetReturnFlagName(flag)
    __IDASpilsGetReturnFlagName(convert(Clong,flag))
end

function __IDASpilsSetGSTypeB(ida_mem::IDAMemPtr,which::Cint,gstypeB::Cint)
    ccall((:IDASpilsSetGSTypeB,libsundials_idas),Cint,(IDAMemPtr,Cint,Cint),ida_mem,which,gstypeB)
end

function IDASpilsSetGSTypeB(ida_mem,which,gstypeB)
    __IDASpilsSetGSTypeB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Cint,gstypeB))
end

function __IDASpilsSetMaxRestartsB(ida_mem::IDAMemPtr,which::Cint,maxrsB::Cint)
    ccall((:IDASpilsSetMaxRestartsB,libsundials_idas),Cint,(IDAMemPtr,Cint,Cint),ida_mem,which,maxrsB)
end

function IDASpilsSetMaxRestartsB(ida_mem,which,maxrsB)
    __IDASpilsSetMaxRestartsB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Cint,maxrsB))
end

function __IDASpilsSetEpsLinB(ida_mem::IDAMemPtr,which::Cint,eplifacB::realtype)
    ccall((:IDASpilsSetEpsLinB,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype),ida_mem,which,eplifacB)
end

function IDASpilsSetEpsLinB(ida_mem,which,eplifacB)
    __IDASpilsSetEpsLinB(convert(IDAMemPtr,ida_mem),convert(Cint,which),eplifacB)
end

function __IDASpilsSetMaxlB(ida_mem::IDAMemPtr,which::Cint,maxlB::Cint)
    ccall((:IDASpilsSetMaxlB,libsundials_idas),Cint,(IDAMemPtr,Cint,Cint),ida_mem,which,maxlB)
end

function IDASpilsSetMaxlB(ida_mem,which,maxlB)
    __IDASpilsSetMaxlB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Cint,maxlB))
end

function __IDASpilsSetIncrementFactorB(ida_mem::IDAMemPtr,which::Cint,dqincfacB::realtype)
    ccall((:IDASpilsSetIncrementFactorB,libsundials_idas),Cint,(IDAMemPtr,Cint,realtype),ida_mem,which,dqincfacB)
end

function IDASpilsSetIncrementFactorB(ida_mem,which,dqincfacB)
    __IDASpilsSetIncrementFactorB(convert(IDAMemPtr,ida_mem),convert(Cint,which),dqincfacB)
end

function __IDASpilsSetPreconditionerB(ida_mem::IDAMemPtr,which::Cint,psetB::IDASpilsPrecSetupFnB,psolveB::IDASpilsPrecSolveFnB)
    ccall((:IDASpilsSetPreconditionerB,libsundials_idas),Cint,(IDAMemPtr,Cint,IDASpilsPrecSetupFnB,IDASpilsPrecSolveFnB),ida_mem,which,psetB,psolveB)
end

function IDASpilsSetPreconditionerB(ida_mem,which,psetB,psolveB)
    __IDASpilsSetPreconditionerB(convert(IDAMemPtr,ida_mem),convert(Cint,which),psetB,psolveB)
end

function __IDASpilsSetJacTimesVecFnB(ida_mem::IDAMemPtr,which::Cint,jtvB::IDASpilsJacTimesVecFnB)
    ccall((:IDASpilsSetJacTimesVecFnB,libsundials_idas),Cint,(IDAMemPtr,Cint,IDASpilsJacTimesVecFnB),ida_mem,which,jtvB)
end

function IDASpilsSetJacTimesVecFnB(ida_mem,which,jtvB)
    __IDASpilsSetJacTimesVecFnB(convert(IDAMemPtr,ida_mem),convert(Cint,which),jtvB)
end
# Julia wrapper for header: /home/astukalov/.julia/v0.5/Sundials/deps/usr/include/idas/idas_band.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

function __IDABand(ida_mem::IDAMemPtr,Neq::Clong,mupper::Clong,mlower::Clong)
    ccall((:IDABand,libsundials_idas),Cint,(IDAMemPtr,Clong,Clong,Clong),ida_mem,Neq,mupper,mlower)
end

function IDABand(ida_mem,Neq,mupper,mlower)
    __IDABand(convert(IDAMemPtr,ida_mem),convert(Clong,Neq),convert(Clong,mupper),convert(Clong,mlower))
end

function __IDABandB(idaadj_mem::IDAMemPtr,which::Cint,NeqB::Clong,mupperB::Clong,mlowerB::Clong)
    ccall((:IDABandB,libsundials_idas),Cint,(IDAMemPtr,Cint,Clong,Clong,Clong),idaadj_mem,which,NeqB,mupperB,mlowerB)
end

function IDABandB(idaadj_mem,which,NeqB,mupperB,mlowerB)
    __IDABandB(convert(IDAMemPtr,idaadj_mem),convert(Cint,which),convert(Clong,NeqB),convert(Clong,mupperB),convert(Clong,mlowerB))
end
# Julia wrapper for header: /home/astukalov/.julia/v0.5/Sundials/deps/usr/include/idas/idas_bbdpre.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

function __IDABBDPrecInit(ida_mem::IDAMemPtr,Nlocal::Clong,mudq::Clong,mldq::Clong,mukeep::Clong,mlkeep::Clong,dq_rel_yy::realtype,Gres::IDABBDLocalFn,Gcomm::IDABBDCommFn)
    ccall((:IDABBDPrecInit,libsundials_idas),Cint,(IDAMemPtr,Clong,Clong,Clong,Clong,Clong,realtype,IDABBDLocalFn,IDABBDCommFn),ida_mem,Nlocal,mudq,mldq,mukeep,mlkeep,dq_rel_yy,Gres,Gcomm)
end

function IDABBDPrecInit(ida_mem,Nlocal,mudq,mldq,mukeep,mlkeep,dq_rel_yy,Gres,Gcomm)
    __IDABBDPrecInit(convert(IDAMemPtr,ida_mem),convert(Clong,Nlocal),convert(Clong,mudq),convert(Clong,mldq),convert(Clong,mukeep),convert(Clong,mlkeep),dq_rel_yy,Gres,Gcomm)
end

function __IDABBDPrecReInit(ida_mem::IDAMemPtr,mudq::Clong,mldq::Clong,dq_rel_yy::realtype)
    ccall((:IDABBDPrecReInit,libsundials_idas),Cint,(IDAMemPtr,Clong,Clong,realtype),ida_mem,mudq,mldq,dq_rel_yy)
end

function IDABBDPrecReInit(ida_mem,mudq,mldq,dq_rel_yy)
    __IDABBDPrecReInit(convert(IDAMemPtr,ida_mem),convert(Clong,mudq),convert(Clong,mldq),dq_rel_yy)
end

function __IDABBDPrecGetWorkSpace(ida_mem::IDAMemPtr,lenrwBBDP::Ptr{Clong},leniwBBDP::Ptr{Clong})
    ccall((:IDABBDPrecGetWorkSpace,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong},Ptr{Clong}),ida_mem,lenrwBBDP,leniwBBDP)
end

function IDABBDPrecGetWorkSpace(ida_mem,lenrwBBDP,leniwBBDP)
    __IDABBDPrecGetWorkSpace(convert(IDAMemPtr,ida_mem),pointer(lenrwBBDP),pointer(leniwBBDP))
end

function __IDABBDPrecGetNumGfnEvals(ida_mem::IDAMemPtr,ngevalsBBDP::Ptr{Clong})
    ccall((:IDABBDPrecGetNumGfnEvals,libsundials_idas),Cint,(IDAMemPtr,Ptr{Clong}),ida_mem,ngevalsBBDP)
end

function IDABBDPrecGetNumGfnEvals(ida_mem,ngevalsBBDP)
    __IDABBDPrecGetNumGfnEvals(convert(IDAMemPtr,ida_mem),pointer(ngevalsBBDP))
end

function __IDABBDPrecInitB(ida_mem::IDAMemPtr,which::Cint,NlocalB::Clong,mudqB::Clong,mldqB::Clong,mukeepB::Clong,mlkeepB::Clong,dq_rel_yyB::realtype,GresB::IDABBDLocalFnB,GcommB::IDABBDCommFnB)
    ccall((:IDABBDPrecInitB,libsundials_idas),Cint,(IDAMemPtr,Cint,Clong,Clong,Clong,Clong,Clong,realtype,IDABBDLocalFnB,IDABBDCommFnB),ida_mem,which,NlocalB,mudqB,mldqB,mukeepB,mlkeepB,dq_rel_yyB,GresB,GcommB)
end

function IDABBDPrecInitB(ida_mem,which,NlocalB,mudqB,mldqB,mukeepB,mlkeepB,dq_rel_yyB,GresB,GcommB)
    __IDABBDPrecInitB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Clong,NlocalB),convert(Clong,mudqB),convert(Clong,mldqB),convert(Clong,mukeepB),convert(Clong,mlkeepB),dq_rel_yyB,GresB,GcommB)
end

function __IDABBDPrecReInitB(ida_mem::IDAMemPtr,which::Cint,mudqB::Clong,mldqB::Clong,dq_rel_yyB::realtype)
    ccall((:IDABBDPrecReInitB,libsundials_idas),Cint,(IDAMemPtr,Cint,Clong,Clong,realtype),ida_mem,which,mudqB,mldqB,dq_rel_yyB)
end

function IDABBDPrecReInitB(ida_mem,which,mudqB,mldqB,dq_rel_yyB)
    __IDABBDPrecReInitB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Clong,mudqB),convert(Clong,mldqB),dq_rel_yyB)
end
# Julia wrapper for header: /home/astukalov/.julia/v0.5/Sundials/deps/usr/include/idas/idas_dense.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

function __IDADense(ida_mem::IDAMemPtr,Neq::Clong)
    ccall((:IDADense,libsundials_idas),Cint,(IDAMemPtr,Clong),ida_mem,Neq)
end

function IDADense(ida_mem,Neq)
    __IDADense(convert(IDAMemPtr,ida_mem),convert(Clong,Neq))
end

function __IDADenseB(ida_mem::IDAMemPtr,which::Cint,NeqB::Clong)
    ccall((:IDADenseB,libsundials_idas),Cint,(IDAMemPtr,Cint,Clong),ida_mem,which,NeqB)
end

function IDADenseB(ida_mem,which,NeqB)
    __IDADenseB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Clong,NeqB))
end
# Julia wrapper for header: /home/astukalov/.julia/v0.5/Sundials/deps/usr/include/idas/idas_impl.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

# Julia wrapper for header: /home/astukalov/.julia/v0.5/Sundials/deps/usr/include/idas/idas_spbcgs.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

function __IDASpbcg(ida_mem::IDAMemPtr,maxl::Cint)
    ccall((:IDASpbcg,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxl)
end

function IDASpbcg(ida_mem,maxl)
    __IDASpbcg(convert(IDAMemPtr,ida_mem),convert(Cint,maxl))
end

function __IDASpbcgB(ida_mem::IDAMemPtr,which::Cint,maxlB::Cint)
    ccall((:IDASpbcgB,libsundials_idas),Cint,(IDAMemPtr,Cint,Cint),ida_mem,which,maxlB)
end

function IDASpbcgB(ida_mem,which,maxlB)
    __IDASpbcgB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Cint,maxlB))
end
# Julia wrapper for header: /home/astukalov/.julia/v0.5/Sundials/deps/usr/include/idas/idas_spgmr.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

function __IDASpgmr(ida_mem::IDAMemPtr,maxl::Cint)
    ccall((:IDASpgmr,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxl)
end

function IDASpgmr(ida_mem,maxl)
    __IDASpgmr(convert(IDAMemPtr,ida_mem),convert(Cint,maxl))
end

function __IDASpgmrB(ida_mem::IDAMemPtr,which::Cint,maxlB::Cint)
    ccall((:IDASpgmrB,libsundials_idas),Cint,(IDAMemPtr,Cint,Cint),ida_mem,which,maxlB)
end

function IDASpgmrB(ida_mem,which,maxlB)
    __IDASpgmrB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Cint,maxlB))
end
# Julia wrapper for header: /home/astukalov/.julia/v0.5/Sundials/deps/usr/include/idas/idas_sptfqmr.h
# Automatically generated using Clang.jl wrap_c, version 0.0.0

function __IDASptfqmr(ida_mem::IDAMemPtr,maxl::Cint)
    ccall((:IDASptfqmr,libsundials_idas),Cint,(IDAMemPtr,Cint),ida_mem,maxl)
end

function IDASptfqmr(ida_mem,maxl)
    __IDASptfqmr(convert(IDAMemPtr,ida_mem),convert(Cint,maxl))
end

function __IDASptfqmrB(ida_mem::IDAMemPtr,which::Cint,maxlB::Cint)
    ccall((:IDASptfqmrB,libsundials_idas),Cint,(IDAMemPtr,Cint,Cint),ida_mem,which,maxlB)
end

function IDASptfqmrB(ida_mem,which,maxlB)
    __IDASptfqmrB(convert(IDAMemPtr,ida_mem),convert(Cint,which),convert(Cint,maxlB))
end


text:
using SymmetricSparseMatrices
using SparseArrays
using Test

@testset "SymmetricSparseMatrix" begin
    # SymmetricSparseMatrix
    @test size(SymmetricSparseMatrix()) == (0,0)
    @test nnz(SymmetricSparseMatrix()) == 0
    @test getindex(SymmetricSparseMatrix(1,[1,2],[1],[1]),1,1) == 1
    @test nnz(SymmetricSparseMatrix(1,[1,2],[1],[1])) == 1
    @test SymmetricSparseMatrix(5,[1,4,6,9,12,14], [1,2,4,1,2,3,4,5,1,3,4,2,5], [1,-1,-3,-2,5,4,6,4,-4,2,7,8,-5])*ones(5) == [-3, 4, 14, 10, -1]

    # Conversions
    a = sparse([1,2,3,4],[1,2,3,4],[1,2,3,4])
    b = Matrix(a)
    c = symsparse(b)
    @test a == b == c

    a = sparse([1,2,3,4,1,2,3,4],[1,2,3,4,4,3,2,1],[1,2,3,4,4,3,2,1])
    b = Matrix(a)
    c = symsparse(b)
    @test a != c != b
end

ext: jl


text:
# ============================================================
# Mathematical Methods
# ============================================================

export linspace, heaviside, fortsign, mat_split
export finite_difference
export central_diff, central_diff!, central_diff2, central_diff2!
export upwind_diff, upwind_diff!, unstruct_diff
export maxwell_boltzmann, maxwell_boltzmann_prime
export maxwell_boltzmann_dual, maxwell_boltzmann_dual_prime
export kinetic_entropy
export optimize_closure, realizable_reconstruct
export ylm, rlylm, eval_spherharmonic
export basis_size, eval_sphermonomial

include("math_general.jl")
include("math_difference.jl")
include("math_entropy.jl")
include("math_closure.jl")
include("sphere_harmonics.jl")
include("sphere_monomials.jl")


text:
const libpq = Libdl.find_library("libpq")
const UINT_MAX = typemax(UInt32)
typealias FILE Void

include("libpq/common.jl")
include("libpq/output.jl")

max_stars_repo_name: rbt-lang/rbt-proto

max_issues_repo_name: rbt-lang/rbt-proto

max_forks_repo_name: rbt-lang/rbt-proto


text:
#
# This file is part of the DiscreteEvents.jl Julia package, MIT license
#
# Paul Bayer, 2020
#
# This is a Julia package for discrete event simulation
#
using DiscreteEvents, Unitful
import Unitful: Time, ms, s, minute, hr

println("... unit tests ...")
clk = Clock(unit = hr)
@test clk.unit == hr
clk = Clock(1s, t0=1hr, unit=minute)
@test clk.time == 60
@test clk.unit == minute
@test clk.Δt == 1/60
clk = Clock(1s)
@test clk.unit == s
@test clk.Δt == 1
clk = Clock(t0=60s)
@test clk.unit == s
@test clk.time == 60
clk = Clock(1s, t0=1hr)
@test clk.unit == s
@test clk.time == 3600
@test clk.Δt ==1
@test repr(clk) == "Clock 1: state=:idle, t=3600.0s, Δt=1.0s, prc:0\n  scheduled ev:0, cev:0, sampl:0\n"

resetClock!(𝐶)
@test 𝐶.unit == NoUnits
setUnit!(𝐶, s)
@test 𝐶.unit == s
@test setUnit!(𝐶, s) == 0s
clk = Clock(1s, t0=1hr)
setUnit!(clk, hr)
@test clk.unit == hr
@test clk.time == 1
@test clk.Δt == 1/3600
setUnit!(clk, Unitful.m)
@test clk.unit == NoUnits

setUnit!(clk, s)
resetClock!(𝐶, t0=1)
sync!(clk)
@test clk.time == 1
resetClock!(𝐶)
sync!(clk)
clk = Clock(t0=1minute)
resetClock!(𝐶, t0=100s)
sync!(clk)
@test clk.time == 100
@test clk.unit == s

resetClock!(𝐶, unit=s)
@test 𝐶.unit == s
@test isa(1𝐶.unit, Time)
resetClock!(𝐶, 1s, t0=1minute)
@test 𝐶.unit == s
@test 𝐶.time == 60
resetClock!(𝐶, t0=1minute)
@test 𝐶.unit == minute
@test 𝐶.time == 1

myfunc(a, b) = a+b
resetClock!(𝐶)
@test_warn "clock has no time unit" event!(𝐶, fun(myfunc, 1, 2), 1s)

resetClock!(𝐶, unit=s)
event!(𝐶, fun(myfunc, 4, 5), 1minute, 1minute)
event!(𝐶, fun(myfunc, 5, 6), after, 1hr)
@test sample_time!(𝐶, 30s) == 30
periodic!(𝐶, fun(myfunc, 1, 2))
run!(𝐶, 1hr)
@test 𝐶.evcount == 61


text:
module AppCallbackClients
using gRPCClient
using ProtoBuf:google

include("dapr.jl")
using .dapr.proto.runtime.v1

import Base: show

# begin service: dapr.proto.runtime.v1.AppCallback

export AppCallbackBlockingClient, AppCallbackClient

struct AppCallbackBlockingClient
    controller::gRPCController
    channel::gRPCChannel
    stub::AppCallbackBlockingStub

    function AppCallbackBlockingClient(api_base_url::String; kwargs...)
        controller = gRPCController(; kwargs...)
        channel = gRPCChannel(api_base_url)
        stub = AppCallbackBlockingStub(channel)
        new(controller, channel, stub)
    end
end

struct AppCallbackClient
    controller::gRPCController
    channel::gRPCChannel
    stub::AppCallbackStub

    function AppCallbackClient(api_base_url::String; kwargs...)
        controller = gRPCController(; kwargs...)
        channel = gRPCChannel(api_base_url)
        stub = AppCallbackStub(channel)
        new(controller, channel, stub)
    end
end

show(io::IO, client::AppCallbackBlockingClient) = print(io, "AppCallbackBlockingClient(", client.channel.baseurl, ")")
show(io::IO, client::AppCallbackClient) = print(io, "AppCallbackClient(", client.channel.baseurl, ")")

import .dapr.proto.runtime.v1: OnInvoke
"""
    OnInvoke

- input: dapr.proto.common.v1.InvokeRequest
- output: dapr.proto.common.v1.InvokeResponse
"""
OnInvoke(client::AppCallbackBlockingClient, inp::dapr.proto.common.v1.InvokeRequest) = OnInvoke(client.stub, client.controller, inp)
OnInvoke(client::AppCallbackClient, inp::dapr.proto.common.v1.InvokeRequest, done::Function) = OnInvoke(client.stub, client.controller, inp, done)

import .dapr.proto.runtime.v1: ListTopicSubscriptions
"""
    ListTopicSubscriptions

- input: google.protobuf.Empty
- output: dapr.proto.runtime.v1.ListTopicSubscriptionsResponse
"""
ListTopicSubscriptions(client::AppCallbackBlockingClient, inp::google.protobuf.Empty) = ListTopicSubscriptions(client.stub, client.controller, inp)
ListTopicSubscriptions(client::AppCallbackClient, inp::google.protobuf.Empty, done::Function) = ListTopicSubscriptions(client.stub, client.controller, inp, done)

import .dapr.proto.runtime.v1: OnTopicEvent
"""
    OnTopicEvent

- input: dapr.proto.runtime.v1.TopicEventRequest
- output: dapr.proto.runtime.v1.TopicEventResponse
"""
OnTopicEvent(client::AppCallbackBlockingClient, inp::dapr.proto.runtime.v1.TopicEventRequest) = OnTopicEvent(client.stub, client.controller, inp)
OnTopicEvent(client::AppCallbackClient, inp::dapr.proto.runtime.v1.TopicEventRequest, done::Function) = OnTopicEvent(client.stub, client.controller, inp, done)

import .dapr.proto.runtime.v1: ListInputBindings
"""
    ListInputBindings

- input: google.protobuf.Empty
- output: dapr.proto.runtime.v1.ListInputBindingsResponse
"""
ListInputBindings(client::AppCallbackBlockingClient, inp::google.protobuf.Empty) = ListInputBindings(client.stub, client.controller, inp)
ListInputBindings(client::AppCallbackClient, inp::google.protobuf.Empty, done::Function) = ListInputBindings(client.stub, client.controller, inp, done)

import .dapr.proto.runtime.v1: OnBindingEvent
"""
    OnBindingEvent

- input: dapr.proto.runtime.v1.BindingEventRequest
- output: dapr.proto.runtime.v1.BindingEventResponse
"""
OnBindingEvent(client::AppCallbackBlockingClient, inp::dapr.proto.runtime.v1.BindingEventRequest) = OnBindingEvent(client.stub, client.controller, inp)
OnBindingEvent(client::AppCallbackClient, inp::dapr.proto.runtime.v1.BindingEventRequest, done::Function) = OnBindingEvent(client.stub, client.controller, inp, done)

# end service: dapr.proto.runtime.v1.AppCallback

end # module DaprClients


text:
using ArgParse
using Cambrian
using CartesianGeneticProgramming
using Dates
using IICGP
using Random
using UnicodePlots
using LinearAlgebra

import Cambrian.mutate

out(plt) = println(IOContext(stdout, :color=>true), plt)
default_resdir = joinpath(dirname(@__DIR__), "results")
default_cfgdir = joinpath(dirname(@__DIR__), "cfg")

s = ArgParseSettings()
@add_arg_table! s begin
    "--cfg"
    help = "configuration script"
    default = joinpath(default_cfgdir, "nsga2_example.yaml")
    "--seed"
    help = "random seed"
    default = 0
    "--out"
    help = "output directory"
    arg_type = String
    default = default_resdir
end

args = parse_args(ARGS, s)
const cfg_path = args["cfg"]
const seed = args["seed"]
const resdir = args["out"]
const cfg = get_config(cfg_path)

# Specific functions for this example of learning two functions
x = [i for i in 0:0.05:1]
const max_fitness = [0.0, 0.0]
const min_fitness = - length(x) * ones(cfg.d_fitness)
f1(x) = 0.2 * (2.0 + cos(2.0*π*x))
f2(x) = 0.25 * (2.0 + cos(4*π*x))
y1 = f1.(x)
y2 = f2.(x)
out(lineplot([f1, f2], 0, 1, border=:dotted))
function display_paretto(e::NSGA2Evo)
    o1 = [ind.fitness[1] for ind in e.population]
    o2 = [ind.fitness[2] for ind in e.population]
    out(scatterplot(o1, o2, title = "Paretto front"))#, xlim=[0,1], ylim=[0,1]))
end

# User-defined fitness function (normalized)
function my_fitness(ind::NSGA2Ind, seed::Int64, game::Game) # game is a placeholder
    cgp_ind = CGPInd(cfg, ind.chromosome)
    y_hat = zeros(length(y1))
    @inbounds for i in eachindex(y1)
        y_hat[i] = CartesianGeneticProgramming.process(cgp_ind, [x[i]])[1]
    end
    o1 = - norm(y1 - y_hat)
    o2 = - norm(y2 - y_hat)
    ([o1, o2] .- min_fitness) ./ (max_fitness .- min_fitness)
end

# User-defined mutation function
function mutate(ind::NSGA2Ind)
    cgpind = CGPInd(cfg, ind.chromosome)
    child = goldman_mutate(cfg, cgpind)
    NSGA2Ind(cfg, child.chromosome)
end

# User-defined population initialization function
function my_init(cfg::NamedTuple)
    [NSGA2Ind(cfg, CGPInd(cfg).chromosome) for _ in 1:cfg.n_population]
end

e = NSGA2Evo(cfg, resdir, my_fitness, my_init, "boxing") # boxing is a placeholder

init_backup(cfg.id, resdir, cfg_path)
#run!(evo)
for i in 1:e.config.n_gen
    e.gen += 1
    if e.gen > 1
        populate(e)
    end
    evaluate(e)
    display_paretto(e)
    generation(e, max_fitness, min_fitness)
    #=if ((e.config.log_gen > 0) && mod(e.gen, e.config.log_gen) == 0)
        log_gen(e, max_fitness, min_fitness)
    end
    if ((e.config.save_gen > 0) && mod(e.gen, e.config.save_gen) == 0)
        save_gen(e)
    end=#
end

# Display one of the elite (Pareto efficient) individuals
ind = CGPInd(cfg, e.population[1].chromosome)
cgp_f(x) = CartesianGeneticProgramming.process(ind, [x])[1]
out(lineplot([f1, f2, cgp_f], 0, 1, border=:dotted))


text:
# Coverage submission script on travis-ci.com, delete or keep depending on whether you are
# using that service. Only pushes coverage from the given version and OS.
# NOTE: used by the .travis.yml script, if you are not using Travis you can delete this file.
get(ENV, "TRAVIS_OS_NAME", nothing)       == "linux" || exit(0)
get(ENV, "TRAVIS_JULIA_VERSION", nothing) == "1.5"   || exit(0)

using Coverage

cd(joinpath(@__DIR__, "..", "..")) do
    Codecov.submit(Codecov.process_folder())
end


text:
using SIIPExamples
pkgpath = dirname(dirname(pathof(SIIPExamples)))
using Dates

using PowerSystems
using PowerSimulations
using PowerSystemCaseBuilder

using Cbc #solver
solver = optimizer_with_attributes(Cbc.Optimizer, "logLevel" => 1, "ratioGap" => 0.5)

sys = build_system(PSYTestSystems, "tamu_ACTIVSg2000_sys")

horizon = 24;
interval = Dates.Hour(24);
transform_single_time_series!(sys, horizon, interval);

sim_folder = mkpath(joinpath(pkgpath, "TAMU-sim"))
problems = SimulationProblems(
    UC = OperationsProblem(
        template_unit_commitment(transmission = CopperPlatePowerModel),
        sys,
        optimizer = solver,
    ),
)
intervals = Dict("UC" => (Hour(24), Consecutive()))
DA_sequence = SimulationSequence(
    problems = problems,
    intervals = intervals,
    ini_cond_chronology = IntraProblemChronology(),
)

sim = Simulation(
    name = "TAMU-test",
    steps = 3,
    problems = problems,
    sequence = DA_sequence,
    simulation_folder = sim_folder,
)

build!(sim)

execute!(sim)

sim_results = SimulationResults(sim);
uc_results = get_problem_results(sim_results, "UC")
read_realized_variables(uc_results, names = [:On__ThermalStandard])[:On__ThermalStandard]

# This file was generated using Literate.jl, https://github.com/fredrikekre/Literate.jl


text:
@inline function calculate_sor_weights(
    in1::Int,
    ::Type{S},
    ϵ_r::AbstractArray{T, 3},
    geom_weights_3::AbstractArray{T, 2},
    i2, in2, i3, in3,
    pww3r, pww3l, pww2r, pww2l, # pw: precalculated weight
    pww3r_pww2r, pww3l_pww2r, pww3r_pww2l, pww3l_pww2l,
    pwΔmp2_pwΔmp3,
    pwΔmp2r, pwΔmp2l,
    pwΔmp3r, pwΔmp3l,
) where {T, S}

    # pww1r        = pcs.geom_weights[3][1, in1]
    pww1r        = geom_weights_3[1, in1]
    pww1l        = geom_weights_3[2, in1]
    pwΔmp1       = geom_weights_3[3, in1]
    Δ1_ext_inv_l = geom_weights_3[4, in1]
    Δ1_ext_inv_r = geom_weights_3[4, in1 + 1]

    # ϵ_ijk: i: 1.RB-Dim. | j: 2.RB-Dim. | k: 3.RB-Dim.
    ϵ_lll, ϵ_llr, ϵ_lrl, ϵ_lrr, ϵ_rll, ϵ_rlr, ϵ_rrl, ϵ_rrr = get_ϵ_of_oktant(
        ϵ_r, S, in1 + 1, in1, i2, in2, i3, in3
    )

    pww2r_pww1r = pww2r * pww1r
    pww2l_pww1r = pww2l * pww1r
    pww2r_pww1l = pww2r * pww1l
    pww2l_pww1l = pww2l * pww1l
    pww3l_pww1r = pww3l * pww1r
    pww3r_pww1r = pww3r * pww1r
    pww3l_pww1l = pww3l * pww1l
    pww3r_pww1l = pww3r * pww1l

    w1r =        ϵ_rrr * pww3r_pww2r
    w1r = muladd(ϵ_rlr,  pww3r_pww2l, w1r)
    w1r = muladd(ϵ_rrl,  pww3l_pww2r, w1r)
    w1r = muladd(ϵ_rll,  pww3l_pww2l, w1r)

    w1l =        ϵ_lrr * pww3r_pww2r
    w1l = muladd(ϵ_llr,  pww3r_pww2l, w1l)
    w1l = muladd(ϵ_lrl,  pww3l_pww2r, w1l)
    w1l = muladd(ϵ_lll,  pww3l_pww2l, w1l)

    w2r =        ϵ_rrl * pww3l_pww1r
    w2r = muladd(ϵ_rrr,  pww3r_pww1r, w2r)
    w2r = muladd(ϵ_lrl,  pww3l_pww1l, w2r)
    w2r = muladd(ϵ_lrr,  pww3r_pww1l, w2r)

    w2l =        ϵ_rll * pww3l_pww1r
    w2l = muladd(ϵ_rlr,  pww3r_pww1r, w2l)
    w2l = muladd(ϵ_lll,  pww3l_pww1l, w2l)
    w2l = muladd(ϵ_llr,  pww3r_pww1l, w2l)

    w3r =        ϵ_rrr * pww2r_pww1r
    w3r = muladd(ϵ_rlr,  pww2l_pww1r, w3r)
    w3r = muladd(ϵ_lrr,  pww2r_pww1l, w3r)
    w3r = muladd(ϵ_llr,  pww2l_pww1l, w3r)

    w3l =        ϵ_rrl * pww2r_pww1r
    w3l = muladd(ϵ_rll,  pww2l_pww1r, w3l)
    w3l = muladd(ϵ_lrl,  pww2r_pww1l, w3l)
    w3l = muladd(ϵ_lll,  pww2l_pww1l, w3l)

    # wxy *= Surfaces areas of the voxel
    w1l *= Δ1_ext_inv_l * pwΔmp2_pwΔmp3
    w1r *= Δ1_ext_inv_r * pwΔmp2_pwΔmp3
    w2l *= pwΔmp3l * pwΔmp1
    w2r *= pwΔmp3r * pwΔmp1
    w3l *= pwΔmp2l * pwΔmp1
    w3r *= pwΔmp2r * pwΔmp1
    return w1l, w1r, w2l, w2r, w3l, w3r
end

function calculate_weights_for_innerloop!(
    line_weights, pcs::PotentialCalculationSetup{T, S, 3, Array{T, 3}},
    i2, in2, i3, in3,
    update_even_points, i23_is_even_t,
    pww3r, pww3l, pww2r, pww2l, # pw: precalculated weight
    pww3r_pww2r, pww3l_pww2r, pww3r_pww2l, pww3l_pww2l,
    pwΔmp2_pwΔmp3,
    pwΔmp2r, pwΔmp2l,
    pwΔmp3r, pwΔmp3l,
) where {T, S}
    @fastmath @inbounds @simd ivdep for i1 in 2:(size(pcs.potential, 1) - 1)
        in1 = nidx(i1, update_even_points, i23_is_even_t)
        weights = calculate_sor_weights(
            in1,
            S,
            pcs.ϵ_r,
            pcs.geom_weights[3],
            i2, in2, i3, in3,
            pww3r, pww3l, pww2r, pww2l, # pw: precalculated weight
            pww3r_pww2r, pww3l_pww2r, pww3r_pww2l, pww3l_pww2l,
            pwΔmp2_pwΔmp3,
            pwΔmp2r, pwΔmp2l,
            pwΔmp3r, pwΔmp3l,
        )

        line_weights[i1-1, 1] = weights[1]
        line_weights[i1-1, 2] = weights[2]
        line_weights[i1-1, 3] = weights[3]
        line_weights[i1-1, 4] = weights[4]
        line_weights[i1-1, 5] = weights[5]
        line_weights[i1-1, 6] = weights[6]
    end
    nothing
end

function innerloop!(
    line_weights, pcs::PotentialCalculationSetup{T, S, 3, Array{T, 3}},
    i2, in2, i3, in3, rb_tar_idx, rb_src_idx,
    update_even_points, i23_is_even_t,
    depletion_handling::Val{depletion_handling_enabled},
    is_weighting_potential::Val{_is_weighting_potential},
    only2d::Val{only_2d}
) where {T, S, depletion_handling_enabled, _is_weighting_potential, only_2d}
    @fastmath @inbounds @simd ivdep for i1 in 2:(size(pcs.potential, 1) - 1)
        i1r = get_rbidx_right_neighbour(i1, update_even_points, i23_is_even_t)

        old_potential = pcs.potential[i1, i2, i3, rb_tar_idx]

        weights = get_sor_weights(line_weights, i1-1)

        neighbor_potentials = get_neighbor_potentials(
            pcs.potential, old_potential, i1, i2, i3, i1r, in2, in3, rb_src_idx, only2d
        )

        new_potential = calc_new_potential_by_neighbors_3D(
            pcs.volume_weights[i1, i2, i3, rb_tar_idx],
            weights,
            neighbor_potentials
        )

        update_point = pcs.point_types[i1, i2, i3, rb_tar_idx] & update_bit > 0

        if depletion_handling_enabled
            new_potential, new_imp_scale = handle_depletion(
                new_potential,
                pcs.imp_scale[i1, i2, i3, rb_tar_idx],
                r0_handling_depletion_handling(neighbor_potentials, S, in3),
                pcs.q_eff_imp[i1, i2, i3, rb_tar_idx],
                pcs.volume_weights[i1, i2, i3, rb_tar_idx]
            )
            pcs.imp_scale[i1, i2, i3, rb_tar_idx] = ifelse(update_point, new_imp_scale, pcs.imp_scale[i1, i2, i3, rb_tar_idx])
        end

        if !_is_weighting_potential
            q_eff = if depletion_handling_enabled
                pcs.q_eff_fix[i1, i2, i3, rb_tar_idx]
            else
                pcs.q_eff_imp[i1, i2, i3, rb_tar_idx] + pcs.q_eff_fix[i1, i2, i3, rb_tar_idx]
            end
            new_potential += q_eff * pcs.volume_weights[i1, i2, i3, rb_tar_idx]
        end

        if _is_weighting_potential || !depletion_handling_enabled
            new_potential = apply_over_relaxation(new_potential, old_potential, get_sor_constant(pcs.sor_const, S, in3))
        end

        pcs.potential[i1, i2, i3, rb_tar_idx] = ifelse(update_point, new_potential, old_potential)
    end
    nothing
end

@inline function get_ϵ_of_oktant(
    ϵ_r::AbstractArray{T, 3}, ::Type{Cylindrical},
    i1, in1, i2, in2, i3, in3
) where {T}
    # ϵ_r is not transformed into an red-black-4D-array.
    # The inner loop (over i1) is along the z-Dimension (Cylindrical Case),
    # which is the 3rd dimension for Cylindrical coordinates: (r, φ, z)
    return @inbounds begin
        ϵ_r[ in3, in2, in1 ],
        ϵ_r[  i3, in2, in1 ],
        ϵ_r[ in3,  i2, in1 ],
        ϵ_r[  i3,  i2, in1 ],
        ϵ_r[ in3, in2,  i1 ],
        ϵ_r[  i3, in2,  i1 ],
        ϵ_r[ in3,  i2,  i1 ],
        ϵ_r[  i3,  i2,  i1 ]
    end
end

@inline function get_ϵ_of_oktant(
    ϵ_r::AbstractArray{T, 3}, ::Type{Cartesian},
    i1, in1, i2, in2, i3, in3
) where {T}
    # The inner loop (over i1) is along the x-Dimension (Cartesian Case),
    # which is the 1rd dimension for Cartesian coordinates: (x, y, z)
    return @inbounds begin
        ϵ_r[ in1, in2, in3 ],
        ϵ_r[ in1, in2,  i3 ],
        ϵ_r[ in1,  i2, in3 ],
        ϵ_r[ in1,  i2,  i3 ],
        ϵ_r[  i1, in2, in3 ],
        ϵ_r[  i1, in2,  i3 ],
        ϵ_r[  i1,  i2, in3 ],
        ϵ_r[  i1,  i2,  i3 ]
    end
end

@inline function get_sor_weights(line_weights::Matrix{T}, i::Int)::NTuple{6, T} where {T}
    @inbounds return ( # w: weight; 1: RB-dimension; l/r: left/right
        line_weights[i, 1], # w1l
        line_weights[i, 2], # w1r
        line_weights[i, 3], # w2l
        line_weights[i, 4], # w2r
        line_weights[i, 5], # w3l
        line_weights[i, 6], # w3r
    )
end

@inline function get_neighbor_potentials(
    potential::AbstractArray{T, 4},
    old_potential, i1, i2, i3, i1r, in2, in3, rb_src_idx, only2d::Val{only_2d}
)::NTuple{6, T} where {T,only_2d}
    @inbounds return ( # p: potential; 1: RB-dimension; l/r: left/right
    potential[i1r - 1,     i2,     i3, rb_src_idx], # p1l
    potential[    i1r,     i2,     i3, rb_src_idx], # p1r
    only_2d ? old_potential : potential[ i1,    in2, i3, rb_src_idx], # p2l
    only_2d ? old_potential : potential[ i1, i2 + 1, i3, rb_src_idx], # p2r
    potential[     i1,     i2,    in3, rb_src_idx], # p3l
    potential[     i1,     i2, i3 + 1, rb_src_idx], # p3r
    )
end

@inline function get_sor_constant(sor_const::AbstractArray{T}, ::Type{Cylindrical}, i::Int)::T where {T}
    @inbounds sor_const[i]
end
@inline function get_sor_constant(sor_const::AbstractArray{T}, ::Type{Cartesian}, i::Int)::T where {T}
    @inbounds sor_const[1]
end

@inline function r0_handling_depletion_handling(
    np::NTuple{6, T}, ::Type{Cylindrical}, i::Int
) where {T}
    return (ifelse(i == 1, np[2], np[1]), np[2:6]...)
end
@inline function r0_handling_depletion_handling(
    np::NTuple{6, T}, ::Type{Cartesian}, i::Int
) where {T}
    return np
end


text:
# Configuration for nearly neutral simuation with fixed selection coefficient
# Example run from command line:  julia n_neutral.jl examples/fix_example1
const nn_simtype = 1    # nearly neutral infinite alleles
const dfe_s_list = [0.0,0.1]
const dfe_modulus = 5
dfe_str = "dfe_mod with modulus $dfe_modulus"
@everywhere const N_list     = [30]     # sample size n list, popsize N may be larger
const N_mu_list= [2.0]   # Mutation rate as a multiple of 1.0/N
const ngens = 3      # Generations after burn-in
const fix_minimum = 0.45  # Fraction of population needed to "fix"
const burn_in= 2.0    # generations of burn_in as a multiple of 1/mu

max_stars_repo_name: um-tech-evolution/nearly-neutral

max_issues_repo_name: um-tech-evolution/nearly-neutral

max_forks_repo_name: um-tech-evolution/nearly-neutral


text:
using Gadfly, RDatasets

plot(dataset("Zelig", "macro"), x=:Year, y=:Unem, color=:Country, Geom.point)


text:
@testset "find_k_nearest_neighbours" begin

wmd = WordMoversDistance()
d1 = ["obama", "speaks", "media", "illinois"]
d2 = ["president", "greets", "press", "chicago"]
d3 = ["lawyer", "tanks", "car", "africa"]

corpus = [d1, d3]
top1 = find_k_nearest_neighbours(wmd, corpus, d2; k = 1)
@test length(top1) == 1
@test first(top1[1]) == d1 # d2 is closer to d1 than to d3
@test top1[1][2] == evaluate(wmd, d1, d2)

top2 = find_k_nearest_neighbours(wmd, corpus, d2; k = 2)
@test length(top2) == 2
@test first(top2[1]) == d1
@test top2[1][2] == evaluate(wmd, d1, d2)
@test first(top2[2]) == d3
@test top2[2][2] == evaluate(wmd, d3, d2)

top5 = find_k_nearest_neighbours(wmd, corpus, d2; k = 5)
@test length(top5) == 2 # Only two docs available
@test first(top5[1]) == d1
@test first(top5[2]) == d3

end


text:
using Test
using Caesar
using AprilTags
using Optim
using Statistics
using Manifolds

using FileIO

# using ImageView

import DistributedFactorGraphs: AbstractRelative

##

@testset "test Pose2AprilTag4Corners" begin

##

tag_id = 0
arr = [
  0.5533489436587586;
  -0.14817352826667163;
  5.505868642129518;
  -0.19093946817093482;
  0.5594280845251081;
  3.275940643894491;
  -0.0006414676297225159;
  -0.0009483559382987803;
  0.023125003286657522;
]

homog = reshape(arr, 3, 3)

# pixel values
x1 = 210.54965209961784
x2 = 274.48315429688637
x3 = 264.912078857414
x4 = 206.38191223143477
y1 = 176.4522705078025
y2 = 169.23143005371946
y3 = 107.78357696534272
y4 = 117.63999176024579

corners = ((x1,y1),(x2,y2),(x3,y3),(x4,y4))

##

f_w, c_w, c_h = 200.0, 180.0, 120.0
f_h = f_w

pose = tagOrthogonalIteration(corners,homog, f_w, f_h, c_w, c_h, taglength=0.035)

##

# test construction of factor
apt4 = Pose2AprilTag4Corners(corners=corners, homography=homog, f_width=f_w, c_width=c_w, c_height=c_h)

## test adding to a graph

fg = generateCanonicalFG_ZeroPose(varType=Pose2)
addVariable!(fg, :tag17, Pose2)

atf = addFactor!(fg, [:x0;:tag17], apt4)

meas = sampleFactor(IIF._getCCW(atf),2)
# meas = sampleFactor(fg, DFG.getLabel(atf),2)

@error "restore type checking for AprilTags4Corners Factor"
@test  meas isa Vector
@test  meas[1] isa ProductRepr # TBD likely to change to new Manifolds.jl type

##

pts = approxConv(fg, DFG.ls(fg,:tag17)[1], :tag17)

@test 1 < length(pts)
@test length(pts[1].parts[1]) == 2
@test size(pts[1].parts[2]) == (2,2)

## test packing of factor

pf = DFG.packFactor(fg, atf)
uf = DFG.unpackFactor(fg, pf)

uf4 = getFactorType(uf)

@test isapprox(apt4.corners[1][1], uf4.corners[1][1], atol=1e-12)
@test isapprox(apt4.corners[2][1], uf4.corners[2][1], atol=1e-12)
@test isapprox(apt4.corners[3][1], uf4.corners[3][1], atol=1e-12)
@test isapprox(apt4.corners[4][1], uf4.corners[4][1], atol=1e-12)

@test isapprox(apt4.corners[1][2], uf4.corners[1][2], atol=1e-12)
@test isapprox(apt4.corners[2][2], uf4.corners[2][2], atol=1e-12)
@test isapprox(apt4.corners[3][2], uf4.corners[3][2], atol=1e-12)
@test isapprox(apt4.corners[4][2], uf4.corners[4][2], atol=1e-12)

@test norm( apt4.homography - uf4.homography ) < 1e-6

@test norm( apt4.K - uf4.K ) < 1e-6

@test norm( apt4.taglength - uf4.taglength ) < 1e-6

@test apt4.id == uf4.id

## test factor graph solution

solveTree!(fg);

## test saving to file and back

saveDFG("/tmp/atagtest", fg)
fg_ = loadDFG("/tmp/atagtest")
Base.rm("/tmp/atagtest.tar.gz")

uf4_ = getFactorType(fg_, DFG.ls(fg_, :tag17)[1])

@test norm( apt4.homography - uf4_.homography ) < 1e-6
@test norm( apt4.K - uf4_.K ) < 1e-6
@test norm( apt4.taglength - uf4_.taglength ) < 1e-6
@test apt4.id == uf4_.id

## Test deconvolution

pred, meas = approxDeconv(fg, DFG.ls(fg, :tag17)[1])

M = Manifolds.SpecialEuclidean(2)
pred_ = exp.(Ref(M), Ref(identity_element(M)), pred)
meas_ = exp.(Ref(M), Ref(identity_element(M)), meas)

@test isapprox( M, mean(M,pred_),  mean(M, meas_), atol=0.5)

## test preimage search ("SLAM-wise calibration")

# in reality we'd do this over section of the graph for each sample
# FIXME this must be moved up into IncrementalInference
function _solveFactorPreimage(fct::Union{<:AbstractPrior, <:AbstractRelative},
                              meas_; # this is a SpecialEuclidean(2) tangent vector type, ProductRepr or newer
                              method=BFGS(),
                              regularize::Real=0 )
  #

  minObj = 0 == regularize ? (x) -> fct.preimage[1](meas_, x) : (x) -> fct.preimage[1](meas_, x) + regularize*sum((x-fct.preimage[2]).^2)

  residual = Optim.optimize(minObj, fct.preimage[2], method )
  residual.minimizer
end

fct = getFactorType(fg, :x0tag17f1)

preImgs = zeros(5,10)

for i in 1:10
  println("finding preimage $i")
  preImgs[:,i] .= _solveFactorPreimage(fct, pred[i], regularize=0.001)

  # residual = Optim.optimize((x) -> fct.preimage[1](meas[1][:,i], x), fct.preimage[2], BFGS())
  # store sample
  # preImgs[:,i] .= residual.minimizer
end

@show means = Statistics.mean(preImgs, dims=2)[:]
@show preimgSolve = means - fct.preimage[2]
@test sum(abs.(preimgSolve) .< [10;10;10;10;1]) == 5

##

end

##

@testset "test Pose2AprilTag4Corners conventions" begin

##

calibfile = joinpath(dirname(dirname(pathof(AprilTags))),"data/CameraCalibration/taggridphoto.jpg")

cimg = load(calibfile)

# imshow(cimg)

detector = AprilTagDetector()
tags = deepcopy(detector(cimg))
freeDetector!(detector)

# nearby calibration
f_width = 3370.4878918701756 + 5
f_height = 3352.8348099534364 + 5
c_width = 2005.641610450976  + 5
c_height = 1494.8282013012076 + 5
# the physical size of the tag
taglength = 0.0315

##

ARR = Pose2AprilTag4Corners.(tags, f_width=f_width, f_height=f_height, c_width=c_width, c_height=c_height, taglength=taglength)

# make sure the detections are in the same order as the tag ids
@test ((n->(ARR[n].id == n)).(1:length(ARR)) |> sum) == length(ARR)

##

# check a tag on the left is actually on the left according to
# body frame: fwd-lft-up <==> x-y-z
# distance x should show the tag roughly 42cm ahead of the camera body frame
@test 0.4 < ARR[3].Zij.z.μ[1] < 0.5
@test 0.2 < ARR[3].Zij.z.μ[2]
@test abs(ARR[3].Zij.z.μ[3]) < 0.1

# tag on the right should be on the right
@test 0.4 < ARR[38].Zij.z.μ[1] < 0.5
@test ARR[38].Zij.z.μ[2] < -0.2
@test abs(ARR[38].Zij.z.μ[3]) < 0.1

# check a tag in the center should be near the center
@test 0.4 < ARR[18].Zij.z.μ[1] < 0.5
@test abs(ARR[18].Zij.z.μ[2]) < 0.1
@test abs(ARR[18].Zij.z.μ[3]) < 0.1

# check vertical-only displacement
@test 0.4 < ARR[1].Zij.z.μ[1] < 0.5
@test 0.15 < ARR[1].Zij.z.μ[2] < 0.3
@test abs(ARR[1].Zij.z.μ[3]) < 0.1

@test 0.4 < ARR[5].Zij.z.μ[1] < 0.5
@test 0.15 < ARR[5].Zij.z.μ[2] < 0.3
@test abs(ARR[5].Zij.z.μ[3]) < 0.1

## drawing test to ensure the functions are working

for tag in tags
  apt4 = Pose2AprilTag4Corners(corners=tag.p, homography=tag.H, f_width=f_width, c_width=c_width, c_height=c_height)
  drawBearingLinesAprilTags!( cimg, apt4,
                              f_width=f_width, c_width=c_width, taglength=taglength);
  #
end

##

end

## check the grid calibration cost function is working
## NOTICE this test has moved up into AprilTags.jl itself

# IMGS = Vector{typeof(cimg)}()
# push!(IMGS, cimg)

# tags_ = Vector{AprilTag}[]
# push!(tags_, tags)

# obj = (f_width, f_height, c_width, c_height) -> AprilTags.calcCalibResidualAprilTags!( IMGS, tags_, taglength=taglength, f_width=f_width, f_height=f_height, c_width=c_width, c_height=c_height )[1]
# obj_ = (fcwh) -> obj(fcwh...)

##

# check that it works
# obj_([f_width, f_height, c_width, c_height])

##

# start with any available parameters, this is a limited run just to confirm the code is functional
# for a full calibration run, the solver should be allowed to perform many more iterations
# result = optimize(obj_, [f_width; f_height ;c_width ;c_height ], BFGS(), Optim.Options(iterations = 5) )

##

#


text:
module PushDirectBenchmark

using BenchmarkTools
using StatsBase: median
using DataFrames
using VegaLite
using Dates
using InteractiveUtils

export plot_benchmarks, name_helper

const test_cases = Vector{Tuple{String, Function}}()

function register_test_case(f::Function, title::String; ignore = false)
    if !ignore
        push!(test_cases, (title, f))
    end
end

function run_test_case(index::Int64, n::Integer)
    local tc = test_cases[index]
    @info "Run: $(first(tc))($n)"
    last(tc)(n)
end
get_test_cases_count() = length(test_cases)
export run_test_case, get_test_cases_count

include("./testcases.jl")

name_helper(name) = Dates.format(now(), dateformat"yyyymmddTHHMMSS_")*name

function plot_benchmarks(; dir = joinpath(@__DIR__, "..", "images"),
        maxn = 200_000,
        name = name_helper(gethostname()))

    maxn = Int(floor(log2(maxn)))
    paths = Dict{String, String}(
        "version" => "versioninfo.txt",
        "comparison" => "push_direct_comparison.png",
        "rel_max" => "push_direct_comparison_rel_max.png",
        "rel_min" => "push_direct_comparison_rel_min.png")

    for (k, v) in paths
        paths[k] = joinpath(dir, join([name, v], "_"))
    end

    open(paths["version"], "w") do f
       versioninfo(f)
    end

    df = DataFrame(n = Int[], val = Float64[], type = String[])
    for n in 2 .^ collect(0:maxn)
        for tc in test_cases
            local title = first(tc)
            local func = last(tc)
            @info "Benchmarking: $title($n)"
            local b = @benchmark $func($n)
            push!(df, (n, median(b.times)/1000, title))
        end
    end

    df |> @vlplot(
        :line,
        background="white",
        x={field=:n, scale={type="log"}, axis={gridWidth=0.5}},
        y={field=:val, scale={type="log"}, axis={gridWidth=0.5, title="Median time, μs"}},
        color=:type,
        width=600,
        height=600
    ) |> x -> save(paths["comparison"], x)

    df2 = by(df, :n) do d
        DataFrame(
            val = d[!, :val],
            type = d[!, :type],
            val_max = maximum(d[!, :val]),
            val_min = minimum(d[!, :val])
        )
    end

    df2[!, :rel_max] = df2[!, :val] ./ df2[!, :val_max]
    df2[!, :rel_min] = df2[!, :val] ./ df2[!, :val_min]

    df2 |> @vlplot(
        :line,
        background="white",
        x={field=:n, scale={type="log"}, axis={gridWidth=0.5}},
        y={field=:rel_max, axis={gridWidth=0.5, title="Median time, μs"}},
        color=:type,
        width=600,
        height=600
    ) |> x -> save(paths["rel_max"], x)

    df2 |> @vlplot(
        :line,
        background="white",
        x={field=:n, scale={type="log"}, axis={gridWidth=0.5}},
        y={field=:rel_min, axis={gridWidth=0.5, title="Median time, μs"}},
        color=:type,
        width=600,
        height=600
    ) |> x -> save(paths["rel_min"], x)
end
end # module