
struct BAOABConstantCache{uType,uEltypeNoUnits} <: StochasticDiffEqConstantCache
  k::uType
  half::uEltypeNoUnits
  c1::uEltypeNoUnits
  c2::uEltypeNoUnits
end
@cache struct BAOABCache{uType,uEltypeNoUnits,rateNoiseType} <: StochasticDiffEqMutableCache
  utmp::uType
  dutmp::uType
  k::uType
  gtmp::uType
  noise::rateNoiseType
  half::uEltypeNoUnits
  c1::uEltypeNoUnits
  c2::uEltypeNoUnits
end

function alg_cache(alg::BAOAB,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_prototype,jump_rate_prototype,::Type{uEltypeNoUnits},::Type{uBottomEltypeNoUnits},::Type{tTypeNoUnits},uprev,f,t,dt,::Type{Val{false}}) where {uEltypeNoUnits,uBottomEltypeNoUnits,tTypeNoUnits}
  k = zero(rate_prototype.x[1])
  c1 = exp(-alg.gamma*dt)
  c2 = sqrt(1 - c1^2)
  BAOABConstantCache(k, uEltypeNoUnits(1//2), uEltypeNoUnits(c1), uEltypeNoUnits(c2))
end

function alg_cache(alg::BAOAB,prob,u,ΔW,ΔZ,p,rate_prototype,noise_rate_prototype,jump_rate_prototype,::Type{uEltypeNoUnits},::Type{uBottomEltypeNoUnits},::Type{tTypeNoUnits},uprev,f,t,dt,::Type{Val{true}}) where {uEltypeNoUnits,uBottomEltypeNoUnits,tTypeNoUnits}
  dutmp = zero(u.x[1])
  utmp = zero(u.x[2])
  k = zero(rate_prototype.x[1])

  gtmp = zero(rate_prototype.x[1])
  noise = zero(rate_prototype.x[1])

  half = uEltypeNoUnits(1//2)
  c1 = exp(-alg.gamma*dt)
  c2 = sqrt(1 - c1^2)

  BAOABCache(utmp, dutmp, k, gtmp, noise, half, uEltypeNoUnits(c1), uEltypeNoUnits(c2))
end
