diff --git a/casadi-bindings.cabal b/casadi-bindings.cabal
--- a/casadi-bindings.cabal
+++ b/casadi-bindings.cabal
@@ -1,5 +1,5 @@
 name:                casadi-bindings
-version:             2.1.3.2
+version:             2.2.0.0
 synopsis:            mid-level bindings to CasADi
 category:            Numerical, Math
 description:
@@ -50,15 +50,15 @@
                        Casadi.Overloading
                        Casadi.SharedObject
                        Casadi.Slice
+                       Casadi.Sparsity
                        Casadi.SX
-                       Casadi.SXElement
                        Casadi.SXFunction
   build-depends:       base >=4.6 && <5,
                        linear,
                        vector,
                        containers,
-                       casadi-bindings-internal == 0.1.1,
-                       casadi-bindings-core     == 2.1.3.0
+                       casadi-bindings-internal == 0.1.2,
+                       casadi-bindings-core     == 2.2.0.0
   default-language:    Haskell2010
 
 source-repository head
diff --git a/src/Casadi/Callback.hs b/src/Casadi/Callback.hs
--- a/src/Casadi/Callback.hs
+++ b/src/Casadi/Callback.hs
@@ -4,15 +4,21 @@
 
 module Casadi.Callback
        ( makeCallback
+       , makeCustomEvaluate
+       , makeDerivativeGenerator
        ) where
 
-import Foreign.C.Types
+import Foreign.C.Types ( CInt )
 import Foreign.Ptr ( Ptr )
 import Foreign.ForeignPtr ( newForeignPtr_ )
+import Foreign.ForeignPtr.Unsafe ( unsafeForeignPtrToPtr )
 
 import Casadi.Core.Data
 import Casadi.Internal.WrapReturn ( WrapReturn(..) )
-import Casadi.Internal.Callback ( mkCallback, c_newCallbackHaskell )
+import Casadi.Internal.Callback ( mkCallback, c_newCallbackHaskell
+                                , mkCustomEvaluate, c_newCustomEvaluateHaskell
+                                , mkDerivativeGenerator, c_newDerivativeGeneratorHaskell
+                                )
 
 -- | add a callback to an NLPSolver
 makeCallback :: (Function -> IO CInt) -> IO Callback
@@ -28,3 +34,36 @@
 
   -- create the callback object
   (c_newCallbackHaskell callbackFunPtr :: IO (Ptr Callback')) >>= wrapReturn
+
+
+-- | add a callback to an NLPSolver
+makeCustomEvaluate :: (CustomFunction -> IO ()) -> IO CustomEvaluate
+makeCustomEvaluate callback = do
+  -- safely wrap the callback into the C-friendly version
+  let callback' :: Ptr CustomFunction' -> IO ()
+      callback' ptrFx = do
+        foreignCFun <- newForeignPtr_ ptrFx
+        callback (CustomFunction foreignCFun)
+
+  -- turn the callback into a FunPtr
+  callbackFunPtr <- mkCustomEvaluate callback'
+
+  -- create the callback object
+  (c_newCustomEvaluateHaskell callbackFunPtr :: IO (Ptr CustomEvaluate')) >>= wrapReturn
+
+
+-- | add a callback to an NLPSolver
+makeDerivativeGenerator :: (Function -> Int -> Int -> IO Function) -> IO DerivativeGenerator
+makeDerivativeGenerator callback = do
+  -- safely wrap the callback into the C-friendly version
+  let callback' :: Ptr Function' -> CInt -> CInt -> IO (Ptr Function')
+      callback' ptrFx nfwd nadj = do
+        foreignCFun <- newForeignPtr_ ptrFx
+        Function fun <- callback (Function foreignCFun) (fromIntegral nfwd) (fromIntegral nadj)
+        return (unsafeForeignPtrToPtr fun)
+
+  -- turn the callback into a FunPtr
+  callbackFunPtr <- mkDerivativeGenerator callback'
+
+  -- create the callback object
+  (c_newDerivativeGeneratorHaskell callbackFunPtr :: IO (Ptr DerivativeGenerator')) >>= wrapReturn
diff --git a/src/Casadi/DMatrix.hs b/src/Casadi/DMatrix.hs
--- a/src/Casadi/DMatrix.hs
+++ b/src/Casadi/DMatrix.hs
@@ -2,11 +2,15 @@
 
 module Casadi.DMatrix
        ( DMatrix, dcrs, dmm, dvector, ddata, ddiag
-       , ddense, dsparse, dtrans, dtriu, dtril
+       , ddense, dsparsify, dtrans
+       , dtriu, dtril
+       , dtriu2symm, dtril2symm
        , dsize, dsize1, dsize2, dnumel
        , dvertcat, dhorzcat, dveccat, dvertsplit, dhorzsplit
-       , dones, dzeros
+       , deye, dones, dzeros, dzerosSp
        , dindexed
+       , dgetNZ, dsetNZ
+       , dcopy
        ) where
 
 import qualified Data.Vector as V
@@ -16,9 +20,8 @@
 import Casadi.Core.Classes.Sparsity
 import Casadi.Core.Classes.DMatrix
 import Casadi.Core.Classes.Slice ( Slice )
-import qualified Casadi.Core.Tools as C
 
-import Casadi.Overloading ( Fmod(..), ArcTan2(..), SymOrd(..) )
+import Casadi.Overloading ( Fmod(..), ArcTan2(..), SymOrd(..), Erf(..) )
 
 instance Conjugate DMatrix where
   conjugate = id
@@ -28,33 +31,33 @@
   {-# NOINLINE show #-}
 
 instance Eq DMatrix where
-  x == y = unsafePerformIO (dmatrix_isEqual x y)
+  x == y = unsafePerformIO (dmatrix_zz_isEqual__0 x y)
   {-# NOINLINE (==) #-}
 
 -- | matrix matrix product
 dmm :: DMatrix -> DMatrix -> DMatrix
-dmm x y = unsafePerformIO (dmatrix_mul__0 x y)
+dmm x y = unsafePerformIO (dmatrix_zz_mtimes__1 x y)
 {-# NOINLINE dmm #-}
 
 -- | transpose
 dtrans :: DMatrix -> DMatrix
-dtrans x = unsafePerformIO (dmatrix_trans x)
+dtrans x = unsafePerformIO (dmatrix_T x)
 {-# NOINLINE dtrans #-}
 
 ddense :: DMatrix -> DMatrix
-ddense x = unsafePerformIO (C.dense__2 x)
+ddense x = unsafePerformIO (dmatrix_zz_dense x)
 {-# NOINLINE ddense #-}
 
-dsparse :: DMatrix -> DMatrix
-dsparse x = unsafePerformIO (C.sparse__2 x)
-{-# NOINLINE dsparse #-}
+dsparsify :: DMatrix -> DMatrix
+dsparsify x = unsafePerformIO (dmatrix_zz_sparsify__0 x)
+{-# NOINLINE dsparsify #-}
 
 dcrs :: DMatrix -> Sparsity
 dcrs x = unsafePerformIO (dmatrix_sparsityRef__0 x)
 {-# NOINLINE dcrs #-}
 
 ddiag :: DMatrix -> DMatrix
-ddiag x = unsafePerformIO (C.diag__2 x)
+ddiag x = unsafePerformIO (dmatrix_zz_diag x)
 {-# NOINLINE ddiag #-}
 
 -- | from vector
@@ -79,37 +82,49 @@
 {-# NOINLINE dsize2 #-}
 
 dnumel :: DMatrix -> Int
-dnumel x = unsafePerformIO (dmatrix_numel x)
+dnumel x = unsafePerformIO (dmatrix_numel__1 x)
 {-# NOINLINE dnumel #-}
 
 dvertcat :: V.Vector DMatrix -> DMatrix
-dvertcat x = unsafePerformIO (C.vertcat__3 x)
+dvertcat x = unsafePerformIO (dmatrix_zz_vertcat x)
 {-# NOINLINE dvertcat #-}
 
 dveccat :: V.Vector DMatrix -> DMatrix
-dveccat x = unsafePerformIO (C.veccat__2 x)
+dveccat x = unsafePerformIO (dmatrix_zz_veccat x)
 {-# NOINLINE dveccat #-}
 
 dvertsplit :: DMatrix -> V.Vector Int -> V.Vector DMatrix
-dvertsplit x ks = unsafePerformIO (C.vertsplit__9 x ks)
+dvertsplit x ks = unsafePerformIO (dmatrix_zz_vertsplit x ks)
 {-# NOINLINE dvertsplit #-}
 
 dhorzsplit :: DMatrix -> V.Vector Int -> V.Vector DMatrix
-dhorzsplit x ks = unsafePerformIO (C.horzsplit__9 x ks)
+dhorzsplit x ks = unsafePerformIO (dmatrix_zz_horzsplit x ks)
 {-# NOINLINE dhorzsplit #-}
 
 dhorzcat :: V.Vector DMatrix -> DMatrix
-dhorzcat x = unsafePerformIO (C.horzcat__3 x)
+dhorzcat x = unsafePerformIO (dmatrix_zz_horzcat x)
 {-# NOINLINE dhorzcat #-}
 
 dtriu :: DMatrix -> DMatrix
-dtriu x = unsafePerformIO (C.triu__4 (castDMatrix x))
+dtriu x = unsafePerformIO (dmatrix_zz_triu__0 x)
 {-# NOINLINE dtriu #-}
 
 dtril :: DMatrix -> DMatrix
-dtril x = unsafePerformIO (C.tril__4 (castDMatrix x))
+dtril x = unsafePerformIO (dmatrix_zz_tril__0 x)
 {-# NOINLINE dtril #-}
 
+dtriu2symm :: DMatrix -> DMatrix
+dtriu2symm x = unsafePerformIO (dmatrix_zz_triu2symm x)
+{-# NOINLINE dtriu2symm #-}
+
+dtril2symm :: DMatrix -> DMatrix
+dtril2symm x = unsafePerformIO (dmatrix_zz_tril2symm x)
+{-# NOINLINE dtril2symm #-}
+
+deye :: Int -> DMatrix
+deye n = unsafePerformIO (dmatrix_eye n)
+{-# NOINLINE deye #-}
+
 dones :: (Int,Int) -> DMatrix
 dones (r,c) = unsafePerformIO (dmatrix_ones__3 r c)
 {-# NOINLINE dones #-}
@@ -118,22 +133,36 @@
 dzeros (r,c) = unsafePerformIO (dmatrix_zeros__3 r c)
 {-# NOINLINE dzeros #-}
 
+dzerosSp :: Sparsity -> DMatrix
+dzerosSp sp = unsafePerformIO (dmatrix_zeros__0 sp)
+{-# NOINLINE dzerosSp #-}
+
 dindexed :: DMatrix -> Slice -> Slice -> DMatrix
-dindexed m sx sy = unsafePerformIO (dmatrix_indexed__5 m sx sy)
+dindexed m sx sy = unsafePerformIO (dmatrix_getSub__3 m False sx sy)
 {-# NOINLINE dindexed #-}
 
+dgetNZ :: DMatrix -> Slice -> DMatrix
+dgetNZ m s = unsafePerformIO (dmatrix_getNZ__1 m False s)
+{-# NOINLINE dgetNZ #-}
+
+dsetNZ :: DMatrix -> DMatrix -> Slice -> IO ()
+dsetNZ m y s = dmatrix_setNZ__1 m y False s
+
+dcopy :: DMatrix -> IO DMatrix
+dcopy m = dmatrix__10 m
+
 instance Num DMatrix where
-  (+) x y = unsafePerformIO (dmatrix___add__ x y)
+  (+) x y = unsafePerformIO (dmatrix_zz_plus x y)
   {-# NOINLINE (+) #-}
-  (-) x y = unsafePerformIO (dmatrix___sub__ x y)
+  (-) x y = unsafePerformIO (dmatrix_zz_minus x y)
   {-# NOINLINE (-) #-}
-  (*) x y = unsafePerformIO (dmatrix___mul__ x y)
+  (*) x y = unsafePerformIO (dmatrix_zz_times x y)
   {-# NOINLINE (*) #-}
   fromInteger x = unsafePerformIO (dmatrix__5 (fromInteger x :: Double))
   {-# NOINLINE fromInteger #-}
-  abs x = unsafePerformIO (dmatrix_fabs x)
+  abs x = unsafePerformIO (dmatrix_zz_abs x)
   {-# NOINLINE abs #-}
-  signum x = unsafePerformIO (dmatrix_sign x)
+  signum x = unsafePerformIO (dmatrix_zz_sign x)
   {-# NOINLINE signum #-}
 
 instance Fractional DMatrix where
@@ -145,49 +174,56 @@
 instance Floating DMatrix where
   pi = unsafePerformIO (dmatrix__5 (pi :: Double))
   {-# NOINLINE pi #-}
-  (**) x y = unsafePerformIO (dmatrix___pow__ x y)
+  (**) x y = unsafePerformIO (dmatrix_zz_power x y)
   {-# NOINLINE (**) #-}
-  exp x   = unsafePerformIO (dmatrix_exp x)
+  exp x   = unsafePerformIO (dmatrix_zz_exp x)
   {-# NOINLINE exp #-}
-  log x   = unsafePerformIO (dmatrix_log x)
+  log x   = unsafePerformIO (dmatrix_zz_log x)
   {-# NOINLINE log #-}
-  sin x   = unsafePerformIO (dmatrix_sin x)
+  sin x   = unsafePerformIO (dmatrix_zz_sin x)
   {-# NOINLINE sin #-}
-  cos x   = unsafePerformIO (dmatrix_cos x)
+  cos x   = unsafePerformIO (dmatrix_zz_cos x)
   {-# NOINLINE cos #-}
-  tan x   = unsafePerformIO (dmatrix_tan x)
+  tan x   = unsafePerformIO (dmatrix_zz_tan x)
   {-# NOINLINE tan #-}
-  asin x  = unsafePerformIO (dmatrix_arcsin x)
+  asin x  = unsafePerformIO (dmatrix_zz_asin x)
   {-# NOINLINE asin #-}
-  atan x  = unsafePerformIO (dmatrix_arctan x)
+  atan x  = unsafePerformIO (dmatrix_zz_atan x)
   {-# NOINLINE atan #-}
-  acos x  = unsafePerformIO (dmatrix_arccos x)
+  acos x  = unsafePerformIO (dmatrix_zz_acos x)
   {-# NOINLINE acos #-}
-  sinh x  = unsafePerformIO (dmatrix_sinh x)
+  sinh x  = unsafePerformIO (dmatrix_zz_sinh x)
   {-# NOINLINE sinh #-}
-  cosh x  = unsafePerformIO (dmatrix_cosh x)
+  cosh x  = unsafePerformIO (dmatrix_zz_cosh x)
   {-# NOINLINE cosh #-}
-  tanh x  = unsafePerformIO (dmatrix_tanh x)
+  tanh x  = unsafePerformIO (dmatrix_zz_tanh x)
   {-# NOINLINE tanh #-}
-  asinh x = unsafePerformIO (dmatrix_arcsinh x)
+  asinh x = unsafePerformIO (dmatrix_zz_asinh x)
   {-# NOINLINE asinh #-}
-  atanh x = unsafePerformIO (dmatrix_arctanh x)
+  atanh x = unsafePerformIO (dmatrix_zz_atanh x)
   {-# NOINLINE atanh #-}
-  acosh x = unsafePerformIO (dmatrix_arccosh x)
+  acosh x = unsafePerformIO (dmatrix_zz_acosh x)
   {-# NOINLINE acosh #-}
 
 instance Fmod DMatrix where
-  fmod x y = unsafePerformIO (dmatrix_fmod x y)
+  fmod x y = unsafePerformIO (dmatrix_zz_mod x y)
   {-# NOINLINE fmod #-}
 
 instance ArcTan2 DMatrix where
-  arctan2 x y = unsafePerformIO (dmatrix_arctan2 x y)
+  arctan2 x y = unsafePerformIO (dmatrix_zz_atan2 x y)
   {-# NOINLINE arctan2 #-}
 
 instance SymOrd DMatrix where
-  x `leq` y = unsafePerformIO (dmatrix___le__ x y)
+  x `leq` y = unsafePerformIO (dmatrix_zz_le x y)
   {-# NOINLINE leq #-}
-  x `geq` y = unsafePerformIO (dmatrix___ge____0 x y)
+  x `geq` y = unsafePerformIO (dmatrix_zz_ge x y)
   {-# NOINLINE geq #-}
-  x  `eq` y = unsafePerformIO (dmatrix___eq__ x y)
+  x  `eq` y = unsafePerformIO (dmatrix_zz_eq x y)
   {-# NOINLINE eq #-}
+
+
+instance Erf DMatrix where
+  erf x = unsafePerformIO (dmatrix_zz_erf x)
+  {-# NOINLINE erf #-}
+  erfinv x = unsafePerformIO (dmatrix_zz_erfinv x)
+  {-# NOINLINE erfinv #-}
diff --git a/src/Casadi/Function.hs b/src/Casadi/Function.hs
--- a/src/Casadi/Function.hs
+++ b/src/Casadi/Function.hs
@@ -14,6 +14,7 @@
 import qualified Casadi.Core.Classes.IOInterfaceFunction as C
 import qualified Casadi.Core.Classes.Function as C
 import qualified Casadi.Core.Classes.ExternalFunction as C
+import qualified Casadi.Core.CustomWrappers as C
 
 import Casadi.SX ( SX )
 import Casadi.MX ( MX )
@@ -60,8 +61,8 @@
 derivative :: C.FunctionClass a => a -> Int -> Int -> IO C.Function
 derivative = C.function_derivative
 
-generateCode :: C.FunctionClass a => a -> String
-generateCode f = unsafePerformIO (C.function_generateCode__0 f)
+generateCode :: C.FunctionClass a => a -> Bool -> String
+generateCode f x = unsafePerformIO (C.function_custom_generateCode f x)
 {-# NOINLINE generateCode #-}
 
 externalFunction :: String -> IO C.Function
diff --git a/src/Casadi/GenericC.hs b/src/Casadi/GenericC.hs
--- a/src/Casadi/GenericC.hs
+++ b/src/Casadi/GenericC.hs
@@ -9,6 +9,7 @@
 import Data.Vector ( Vector )
 import Casadi.Core.Classes.Function ( Function )
 import Casadi.Core.Classes.GenericType
+import Casadi.Core.Classes.DerivativeGenerator ( DerivativeGenerator )
 
 import Casadi.SharedObject ( castSharedObject )
 
@@ -24,22 +25,22 @@
 getDescription = genericType_get_description
 
 instance GenericC Bool where
-  mkGeneric = genericType__11
+  mkGeneric = genericType__12
   fromGeneric = ifThenGet genericType_isBool genericType_toBool
 instance GenericC Int where
-  mkGeneric = genericType__10
+  mkGeneric = genericType__11
   fromGeneric = ifThenGet genericType_isInt genericType_toInt
 instance GenericC Double where
-  mkGeneric = genericType__9
+  mkGeneric = genericType__10
   fromGeneric = ifThenGet genericType_isDouble genericType_toDouble
 instance GenericC String where
-  mkGeneric = genericType__8
+  mkGeneric = genericType__9
   fromGeneric = ifThenGet genericType_isString genericType_toString
 instance GenericC (Vector Bool) where
-  mkGeneric = genericType__7
+  mkGeneric = genericType__8
   fromGeneric = const (return Nothing)
 instance GenericC (Vector Int) where
-  mkGeneric = genericType__6
+  mkGeneric = genericType__7
   fromGeneric = ifThenGet genericType_isIntVector genericType_toIntVector
 instance GenericC (Vector Double) where
   mkGeneric = genericType__5
@@ -53,6 +54,9 @@
 instance GenericC Function where
   mkGeneric = genericType__3
   fromGeneric = ifThenGet genericType_isFunction genericType_toFunction
+instance GenericC DerivativeGenerator where
+  mkGeneric = genericType__1
+  fromGeneric = const $ return $ error "no fromGeneric for DerivativeGenerator"
 
 ifThenGet :: (a -> IO Bool) -> (a -> IO b) -> a -> IO (Maybe b)
 ifThenGet isOpt getOpt g = do
diff --git a/src/Casadi/IOSchemes.hs b/src/Casadi/IOSchemes.hs
--- a/src/Casadi/IOSchemes.hs
+++ b/src/Casadi/IOSchemes.hs
@@ -54,7 +54,7 @@
   fmap V.fromList $ mapM getElem entries
 
 mkSchemeSX :: InputOutputScheme -> [(String,SX)] -> IO (V.Vector SX)
-mkSchemeSX = mkScheme sx__14
+mkSchemeSX = mkScheme sx__13
 
 mkSchemeMX :: InputOutputScheme -> [(String,MX)] -> IO (V.Vector MX)
 mkSchemeMX = mkScheme mx__8
diff --git a/src/Casadi/MX.hs b/src/Casadi/MX.hs
--- a/src/Casadi/MX.hs
+++ b/src/Casadi/MX.hs
@@ -5,14 +5,16 @@
        , gradient, jacobian -- , hessian
        , solve
        , expand
-       , triu
-       , tril
+       , triu, tril
+       , triu2symm, tril2symm
        , dense --, sparse
        , d2m
        , size, size1, size2, numel
        , crs, vertcat, horzcat, veccat, vertsplit, horzsplit
-       , ones, zeros
+       , eye, ones, zeros, zerosSp
        , indexed
+       , getNZ, setNZ
+       , copy
        ) where
 
 import Data.Vector ( Vector )
@@ -26,14 +28,14 @@
 import Casadi.Core.Classes.Slice ( Slice )
 import qualified Casadi.Core.Tools as C
 
-import Casadi.Overloading ( Fmod(..), ArcTan2(..), SymOrd(..) )
+import Casadi.Overloading ( Fmod(..), ArcTan2(..), SymOrd(..), Erf(..) )
 import Casadi.SharedObject ( castSharedObject )
 
 instance Conjugate MX where
   conjugate = id
 
 instance Eq MX where
-  x == y = unsafePerformIO (mx_isEqual__0 x y)
+  x == y = unsafePerformIO (mx_zz_isEqual__0 x y)
   {-# NOINLINE (==) #-}
 
 instance Show MX where
@@ -78,32 +80,40 @@
 
 -- | matrix matrix product
 mm :: MX -> MX -> MX
-mm x y = unsafePerformIO (mx_mul__0 x y)
+mm x y = unsafePerformIO (mx_zz_mtimes__1 x y)
 {-# NOINLINE mm #-}
 
 -- | transpose
 trans :: MX -> MX
-trans x = unsafePerformIO (mx_trans x)
+trans x = unsafePerformIO (mx_T x)
 {-# NOINLINE trans #-}
 
 dense :: MX -> MX
-dense x = unsafePerformIO (C.dense__0 x)
+dense x = unsafePerformIO (mx_zz_dense x)
 {-# NOINLINE dense #-}
 
---sparse :: MX -> MX
---sparse x = unsafePerformIO (C.sparse x)
---{-# NOINLINE sparse #-}
+--sparsify :: MX -> MX
+--sparsify x = unsafePerformIO (mx_zz_sparsify__0 x)
+--{-# NOINLINE sparsify #-}
 
 triu :: MX -> MX
-triu x = unsafePerformIO (C.triu__2 (castMX x))
+triu x = unsafePerformIO (mx_zz_triu__0 x)
 {-# NOINLINE triu #-}
 
 tril :: MX -> MX
-tril x = unsafePerformIO (C.tril__2 (castMX x))
+tril x = unsafePerformIO (mx_zz_tril__0 x)
 {-# NOINLINE tril #-}
 
+triu2symm :: MX -> MX
+triu2symm x = unsafePerformIO (mx_zz_triu2symm x)
+{-# NOINLINE triu2symm #-}
+
+tril2symm :: MX -> MX
+tril2symm x = unsafePerformIO (mx_zz_tril2symm x)
+{-# NOINLINE tril2symm #-}
+
 diag :: MX -> MX
-diag x = unsafePerformIO (C.diag__0 x)
+diag x = unsafePerformIO (mx_zz_diag x)
 {-# NOINLINE diag #-}
 
 crs :: MX -> Sparsity
@@ -124,29 +134,33 @@
 {-# NOINLINE size2 #-}
 
 numel :: MX -> Int
-numel x = unsafePerformIO (mx_numel x)
+numel x = unsafePerformIO (mx_numel__1 x)
 {-# NOINLINE numel #-}
 
 vertcat :: V.Vector MX -> MX
-vertcat x = unsafePerformIO (C.vertcat__0 x)
+vertcat x = unsafePerformIO (mx_zz_vertcat x)
 {-# NOINLINE vertcat #-}
 
 veccat :: V.Vector MX -> MX
-veccat x = unsafePerformIO (C.veccat__0 x)
+veccat x = unsafePerformIO (mx_zz_veccat x)
 {-# NOINLINE veccat #-}
 
 vertsplit :: MX -> V.Vector Int -> V.Vector MX
-vertsplit x ks = unsafePerformIO (C.vertsplit__2 x ks)
+vertsplit x ks = unsafePerformIO (mx_zz_vertsplit x ks)
 {-# NOINLINE vertsplit #-}
 
 horzsplit :: MX -> V.Vector Int -> V.Vector MX
-horzsplit x ks = unsafePerformIO (C.horzsplit__2 x ks)
+horzsplit x ks = unsafePerformIO (mx_zz_horzsplit x ks)
 {-# NOINLINE horzsplit #-}
 
 horzcat :: V.Vector MX -> MX
-horzcat x = unsafePerformIO (C.horzcat__0 x)
+horzcat x = unsafePerformIO (mx_zz_horzcat x)
 {-# NOINLINE horzcat #-}
 
+eye :: Int -> MX
+eye n = unsafePerformIO (mx_eye n)
+{-# NOINLINE eye #-}
+
 ones :: (Int,Int) -> MX
 ones (r,c) = unsafePerformIO (mx_ones__3 r c)
 {-# NOINLINE ones #-}
@@ -155,22 +169,36 @@
 zeros (r,c) = unsafePerformIO (mx_zeros__3 r c)
 {-# NOINLINE zeros #-}
 
+zerosSp :: Sparsity -> MX
+zerosSp sp = unsafePerformIO (mx_zeros__0 sp)
+{-# NOINLINE zerosSp #-}
+
 indexed :: MX -> Slice -> Slice -> MX
-indexed m sx sy = unsafePerformIO (mx_indexed__6 m sx sy)
+indexed m sx sy = unsafePerformIO (mx_getSub__3 m False sx sy)
 {-# NOINLINE indexed #-}
 
+getNZ :: MX -> Slice -> MX
+getNZ m s = unsafePerformIO (mx_getNZ__1 m False s)
+{-# NOINLINE getNZ #-}
+
+setNZ :: MX -> MX -> Slice -> IO ()
+setNZ m y s = mx_setNZ__1 m y False s
+
+copy :: MX -> IO MX
+copy m = mx__2 m
+
 instance Num MX where
-  (+) x y = unsafePerformIO (mx___add__ x y)
+  (+) x y = unsafePerformIO (mx_zz_plus x y)
   {-# NOINLINE (+) #-}
-  (-) x y = unsafePerformIO (mx___sub__ x y)
+  (-) x y = unsafePerformIO (mx_zz_minus x y)
   {-# NOINLINE (-) #-}
-  (*) x y = unsafePerformIO (mx___mul__ x y)
+  (*) x y = unsafePerformIO (mx_zz_times x y)
   {-# NOINLINE (*) #-}
   fromInteger x = unsafePerformIO (mx__3 (fromInteger x :: Double))
   {-# NOINLINE fromInteger #-}
-  abs x = unsafePerformIO (mx_fabs x)
+  abs x = unsafePerformIO (mx_zz_abs x)
   {-# NOINLINE abs #-}
-  signum x = unsafePerformIO (mx_sign x)
+  signum x = unsafePerformIO (mx_zz_sign x)
   {-# NOINLINE signum #-}
 
 instance Fractional MX where
@@ -182,50 +210,55 @@
 instance Floating MX where
   pi = unsafePerformIO (mx__3 (pi :: Double))
   {-# NOINLINE pi #-}
-  (**) x y = unsafePerformIO (mx___pow__ x y)
+  (**) x y = unsafePerformIO (mx_zz_power x y)
   {-# NOINLINE (**) #-}
-  exp x   = unsafePerformIO (mx_exp x)
+  exp x   = unsafePerformIO (mx_zz_exp x)
   {-# NOINLINE exp #-}
-  log x   = unsafePerformIO (mx_log x)
+  log x   = unsafePerformIO (mx_zz_log x)
   {-# NOINLINE log #-}
-  sin x   = unsafePerformIO (mx_sin x)
+  sin x   = unsafePerformIO (mx_zz_sin x)
   {-# NOINLINE sin #-}
-  cos x   = unsafePerformIO (mx_cos x)
+  cos x   = unsafePerformIO (mx_zz_cos x)
   {-# NOINLINE cos #-}
-  tan x   = unsafePerformIO (mx_tan x)
+  tan x   = unsafePerformIO (mx_zz_tan x)
   {-# NOINLINE tan #-}
-  asin x  = unsafePerformIO (mx_arcsin x)
+  asin x  = unsafePerformIO (mx_zz_asin x)
   {-# NOINLINE asin #-}
-  atan x  = unsafePerformIO (mx_arctan x)
+  atan x  = unsafePerformIO (mx_zz_atan x)
   {-# NOINLINE atan #-}
-  acos x  = unsafePerformIO (mx_arccos x)
+  acos x  = unsafePerformIO (mx_zz_acos x)
   {-# NOINLINE acos #-}
-  sinh x  = unsafePerformIO (mx_sinh x)
+  sinh x  = unsafePerformIO (mx_zz_sinh x)
   {-# NOINLINE sinh #-}
-  cosh x  = unsafePerformIO (mx_cosh x)
+  cosh x  = unsafePerformIO (mx_zz_cosh x)
   {-# NOINLINE cosh #-}
-  tanh x  = unsafePerformIO (mx_tanh x)
+  tanh x  = unsafePerformIO (mx_zz_tanh x)
   {-# NOINLINE tanh #-}
-  asinh x = unsafePerformIO (mx_arcsinh x)
+  asinh x = unsafePerformIO (mx_zz_asinh x)
   {-# NOINLINE asinh #-}
-  atanh x = unsafePerformIO (mx_arctanh x)
+  atanh x = unsafePerformIO (mx_zz_atanh x)
   {-# NOINLINE atanh #-}
-  acosh x = unsafePerformIO (mx_arccosh x)
+  acosh x = unsafePerformIO (mx_zz_acosh x)
   {-# NOINLINE acosh #-}
 
 instance Fmod MX where
-  fmod x y = unsafePerformIO (mx_fmod x y)
+  fmod x y = unsafePerformIO (mx_zz_mod x y)
   {-# NOINLINE fmod #-}
 
 instance ArcTan2 MX where
-  arctan2 x y = unsafePerformIO (mx_arctan2 x y)
+  arctan2 x y = unsafePerformIO (mx_zz_atan2 x y)
   {-# NOINLINE arctan2 #-}
 
 instance SymOrd MX where
-  x `leq` y = unsafePerformIO (mx___le__ x y)
+  x `leq` y = unsafePerformIO (mx_zz_le x y)
   {-# NOINLINE leq #-}
-  x `geq` y = unsafePerformIO (mx___ge__ x y)
+  x `geq` y = unsafePerformIO (mx_zz_ge x y)
   {-# NOINLINE geq #-}
-  x  `eq` y = unsafePerformIO (mx___eq__ x y)
+  x  `eq` y = unsafePerformIO (mx_zz_eq x y)
   {-# NOINLINE eq #-}
 
+instance Erf MX where
+  erf x = unsafePerformIO (mx_zz_erf x)
+  {-# NOINLINE erf #-}
+  erfinv x = unsafePerformIO (mx_zz_erfinv x)
+  {-# NOINLINE erfinv #-}
diff --git a/src/Casadi/Overloading.hs b/src/Casadi/Overloading.hs
--- a/src/Casadi/Overloading.hs
+++ b/src/Casadi/Overloading.hs
@@ -4,6 +4,7 @@
        ( Fmod(..)
        , ArcTan2(..)
        , SymOrd(..)
+       , Erf(..)
        ) where
 
 import Data.Fixed ( mod' )
@@ -36,3 +37,8 @@
   x `leq` y = if x <= y then 1 else 0
   x `geq` y = if x >= y then 1 else 0
   x  `eq` y = if x == y then 1 else 0
+
+-- | error function
+class Erf a where
+  erf :: a -> a
+  erfinv :: a -> a
diff --git a/src/Casadi/SX.hs b/src/Casadi/SX.hs
--- a/src/Casadi/SX.hs
+++ b/src/Casadi/SX.hs
@@ -2,38 +2,38 @@
 
 module Casadi.SX
        ( SX, ssym, ssymV, ssymM, smm, strans
-       , sgradient, sjacobian, shessian, svector, sdiag
+       , sgradient, sjacobian, shessian, sdiag
        , ssolve
-       , sdata
-       , striu
-       , stril
-       , sdense, ssparse
+       , striu, stril
+       , striu2symm, stril2symm
+       , sdense, ssparsify
        , d2s
        , ssize, ssize1, ssize2, snumel
        , scrs, svertcat, shorzcat, sveccat, svertsplit, shorzsplit
-       , sones, szeros
+       , seye, sones, szeros, szerosSp
        , sindexed
+       , sgetNZ, ssetNZ
+       , scopy
        ) where
 
 import qualified Data.Vector as V
 import System.IO.Unsafe ( unsafePerformIO )
 import Linear.Conjugate ( Conjugate(..) )
 
-import Casadi.Core.Classes.SXElement ( SXElement )
 import Casadi.Core.Classes.SX
 import Casadi.Core.Classes.DMatrix ( DMatrix )
 import Casadi.Core.Classes.Sparsity ( Sparsity )
 import Casadi.Core.Classes.Slice ( Slice )
 import qualified Casadi.Core.Tools as C
 
-import Casadi.Overloading ( Fmod(..), ArcTan2(..), SymOrd(..) )
+import Casadi.Overloading ( Fmod(..), ArcTan2(..), SymOrd(..), Erf(..) )
 
 instance Show SX where
   show x = unsafePerformIO (sx_getDescription x)
   {-# NOINLINE show #-}
 
 instance Eq SX where
-  x == y = unsafePerformIO (sx_isEqual x y)
+  x == y = unsafePerformIO (sx_zz_isEqual__0 x y)
   {-# NOINLINE (==) #-}
 
 instance Conjugate SX where
@@ -65,7 +65,7 @@
 
 -- | matrix matrix product
 smm :: SX -> SX -> SX
-smm x y = unsafePerformIO (sx_mul__0 x y)
+smm x y = unsafePerformIO (sx_zz_mtimes__1 x y)
 {-# NOINLINE smm #-}
 
 d2s :: DMatrix -> SX
@@ -73,43 +73,42 @@
 {-# NOINLINE d2s #-}
 
 sdiag :: SX -> SX
-sdiag x = unsafePerformIO (C.diag__1 x)
+sdiag x = unsafePerformIO (sx_zz_diag x)
 {-# NOINLINE sdiag #-}
 
 -- | transpose
 strans :: SX -> SX
-strans x = unsafePerformIO (sx_trans x)
+strans x = unsafePerformIO (sx_T x)
 {-# NOINLINE strans #-}
 
 sdense :: SX -> SX
-sdense x = unsafePerformIO (C.dense__1 x)
+sdense x = unsafePerformIO (sx_zz_dense x)
 {-# NOINLINE sdense #-}
 
-ssparse :: SX -> SX
-ssparse x = unsafePerformIO (C.sparse__0 x)
-{-# NOINLINE ssparse #-}
+ssparsify :: SX -> SX
+ssparsify x = unsafePerformIO (sx_zz_sparsify__0 x)
+{-# NOINLINE ssparsify #-}
 
 striu :: SX -> SX
-striu x = unsafePerformIO (C.triu__3 (castSX x))
+striu x = unsafePerformIO (sx_zz_triu__0 x)
 {-# NOINLINE striu #-}
 
 stril :: SX -> SX
-stril x = unsafePerformIO (C.tril__3 (castSX x))
+stril x = unsafePerformIO (sx_zz_tril__0 x)
 {-# NOINLINE stril #-}
 
+striu2symm :: SX -> SX
+striu2symm x = unsafePerformIO (sx_zz_triu2symm x)
+{-# NOINLINE striu2symm #-}
+
+stril2symm :: SX -> SX
+stril2symm x = unsafePerformIO (sx_zz_tril2symm x)
+{-# NOINLINE stril2symm #-}
+
 scrs :: SX -> Sparsity
 scrs x = unsafePerformIO (sx_sparsityRef__0 x)
 {-# NOINLINE scrs #-}
 
--- | from SXElement vector
-svector :: V.Vector SXElement -> SX
-svector x = unsafePerformIO (sx__7 x)
-{-# NOINLINE svector #-}
-
-sdata :: SX -> V.Vector SXElement
-sdata x = unsafePerformIO (sx_data__0 x)
-{-# NOINLINE sdata #-}
-
 ssize :: SX -> Int
 ssize x = unsafePerformIO (sx_size__1 x)
 {-# NOINLINE ssize #-}
@@ -123,33 +122,37 @@
 {-# NOINLINE ssize2 #-}
 
 snumel :: SX -> Int
-snumel x = unsafePerformIO (sx_numel x)
+snumel x = unsafePerformIO (sx_numel__1 x)
 {-# NOINLINE snumel #-}
 
 svertcat :: V.Vector SX -> SX
-svertcat x = unsafePerformIO (C.vertcat__2 x)
+svertcat x = unsafePerformIO (sx_zz_vertcat x)
 {-# NOINLINE svertcat #-}
 
 shorzcat :: V.Vector SX -> SX
-shorzcat x = unsafePerformIO (C.horzcat__2 x)
+shorzcat x = unsafePerformIO (sx_zz_horzcat x)
 {-# NOINLINE shorzcat #-}
 
 sveccat :: V.Vector SX -> SX
-sveccat x = unsafePerformIO (C.veccat__1 x)
+sveccat x = unsafePerformIO (sx_zz_veccat x)
 {-# NOINLINE sveccat #-}
 
 svertsplit :: SX -> V.Vector Int -> V.Vector SX
-svertsplit x ks = unsafePerformIO (C.vertsplit__6 x ks)
+svertsplit x ks = unsafePerformIO (sx_zz_vertsplit x ks)
 {-# NOINLINE svertsplit #-}
 
 shorzsplit :: SX -> V.Vector Int -> V.Vector SX
-shorzsplit x ks = unsafePerformIO (C.horzsplit__6 x ks)
+shorzsplit x ks = unsafePerformIO (sx_zz_horzsplit x ks)
 {-# NOINLINE shorzsplit #-}
 
 ssolve :: SX -> SX -> SX
 ssolve a b = unsafePerformIO (C.solve__2 a b)
 {-# NOINLINE ssolve #-}
 
+seye :: Int -> SX
+seye n = unsafePerformIO (sx_eye n)
+{-# NOINLINE seye #-}
+
 sones :: (Int,Int) -> SX
 sones (r,c) = unsafePerformIO (sx_ones__3 r c)
 {-# NOINLINE sones #-}
@@ -158,22 +161,36 @@
 szeros (r,c) = unsafePerformIO (sx_zeros__3 r c)
 {-# NOINLINE szeros #-}
 
+szerosSp :: Sparsity -> SX
+szerosSp sp = unsafePerformIO (sx_zeros__0 sp)
+{-# NOINLINE szerosSp #-}
+
 sindexed :: SX -> Slice -> Slice -> SX
-sindexed m sx sy = unsafePerformIO (sx_indexed__5 m sx sy)
+sindexed m sx sy = unsafePerformIO (sx_getSub__3 m False sx sy)
 {-# NOINLINE sindexed #-}
 
+sgetNZ :: SX -> Slice -> SX
+sgetNZ m s = unsafePerformIO (sx_getNZ__1 m False s)
+{-# NOINLINE sgetNZ #-}
+
+ssetNZ :: SX -> SX -> Slice -> IO ()
+ssetNZ m y s = sx_setNZ__1 m y False s
+
+scopy :: SX -> IO SX
+scopy m = sx__12 m
+
 instance Num SX where
-  (+) x y = unsafePerformIO (sx___add__ x y)
+  (+) x y = unsafePerformIO (sx_zz_plus x y)
   {-# NOINLINE (+) #-}
-  (-) x y = unsafePerformIO (sx___sub__ x y)
+  (-) x y = unsafePerformIO (sx_zz_minus x y)
   {-# NOINLINE (-) #-}
-  (*) x y = unsafePerformIO (sx___mul__ x y)
+  (*) x y = unsafePerformIO (sx_zz_times x y)
   {-# NOINLINE (*) #-}
   fromInteger x = unsafePerformIO (sx__8 (fromInteger x :: Double))
   {-# NOINLINE fromInteger #-}
-  abs x = unsafePerformIO (sx_fabs x)
+  abs x = unsafePerformIO (sx_zz_abs x)
   {-# NOINLINE abs #-}
-  signum x = unsafePerformIO (sx_sign x)
+  signum x = unsafePerformIO (sx_zz_sign x)
   {-# NOINLINE signum #-}
 
 instance Fractional SX where
@@ -185,49 +202,55 @@
 instance Floating SX where
   pi = unsafePerformIO (sx__8 (pi :: Double))
   {-# NOINLINE pi #-}
-  (**) x y = unsafePerformIO (sx___pow__ x y)
+  (**) x y = unsafePerformIO (sx_zz_power x y)
   {-# NOINLINE (**) #-}
-  exp x   = unsafePerformIO (sx_exp x)
+  exp x   = unsafePerformIO (sx_zz_exp x)
   {-# NOINLINE exp #-}
-  log x   = unsafePerformIO (sx_log x)
+  log x   = unsafePerformIO (sx_zz_log x)
   {-# NOINLINE log #-}
-  sin x   = unsafePerformIO (sx_sin x)
+  sin x   = unsafePerformIO (sx_zz_sin x)
   {-# NOINLINE sin #-}
-  cos x   = unsafePerformIO (sx_cos x)
+  cos x   = unsafePerformIO (sx_zz_cos x)
   {-# NOINLINE cos #-}
-  tan x   = unsafePerformIO (sx_tan x)
+  tan x   = unsafePerformIO (sx_zz_tan x)
   {-# NOINLINE tan #-}
-  asin x  = unsafePerformIO (sx_arcsin x)
+  asin x  = unsafePerformIO (sx_zz_asin x)
   {-# NOINLINE asin #-}
-  atan x  = unsafePerformIO (sx_arctan x)
+  atan x  = unsafePerformIO (sx_zz_atan x)
   {-# NOINLINE atan #-}
-  acos x  = unsafePerformIO (sx_arccos x)
+  acos x  = unsafePerformIO (sx_zz_acos x)
   {-# NOINLINE acos #-}
-  sinh x  = unsafePerformIO (sx_sinh x)
+  sinh x  = unsafePerformIO (sx_zz_sinh x)
   {-# NOINLINE sinh #-}
-  cosh x  = unsafePerformIO (sx_cosh x)
+  cosh x  = unsafePerformIO (sx_zz_cosh x)
   {-# NOINLINE cosh #-}
-  tanh x  = unsafePerformIO (sx_tanh x)
+  tanh x  = unsafePerformIO (sx_zz_tanh x)
   {-# NOINLINE tanh #-}
-  asinh x = unsafePerformIO (sx_arcsinh x)
+  asinh x = unsafePerformIO (sx_zz_asinh x)
   {-# NOINLINE asinh #-}
-  atanh x = unsafePerformIO (sx_arctanh x)
+  atanh x = unsafePerformIO (sx_zz_atanh x)
   {-# NOINLINE atanh #-}
-  acosh x = unsafePerformIO (sx_arccosh x)
+  acosh x = unsafePerformIO (sx_zz_acosh x)
   {-# NOINLINE acosh #-}
 
 instance Fmod SX where
-  fmod x y = unsafePerformIO (sx_fmod x y)
+  fmod x y = unsafePerformIO (sx_zz_mod x y)
   {-# NOINLINE fmod #-}
 
 instance ArcTan2 SX where
-  arctan2 x y = unsafePerformIO (sx_arctan2 x y)
+  arctan2 x y = unsafePerformIO (sx_zz_atan2 x y)
   {-# NOINLINE arctan2 #-}
 
 instance SymOrd SX where
-  x `leq` y = unsafePerformIO (sx___le__ x y)
+  x `leq` y = unsafePerformIO (sx_zz_le x y)
   {-# NOINLINE leq #-}
-  x `geq` y = unsafePerformIO (sx___ge____0 x y)
+  x `geq` y = unsafePerformIO (sx_zz_ge x y)
   {-# NOINLINE geq #-}
-  x  `eq` y = unsafePerformIO (sx___eq__ x y)
+  x  `eq` y = unsafePerformIO (sx_zz_eq x y)
   {-# NOINLINE eq #-}
+
+instance Erf SX where
+  erf x = unsafePerformIO (sx_zz_erf x)
+  {-# NOINLINE erf #-}
+  erfinv x = unsafePerformIO (sx_zz_erfinv x)
+  {-# NOINLINE erfinv #-}
diff --git a/src/Casadi/SXElement.hs b/src/Casadi/SXElement.hs
deleted file mode 100644
--- a/src/Casadi/SXElement.hs
+++ /dev/null
@@ -1,90 +0,0 @@
-{-# OPTIONS_GHC -Wall -fno-cse -fno-warn-orphans #-}
-
-module Casadi.SXElement
-       ( SXElement, sxElement_sym
-       ) where
-
-import qualified Data.Vector as V
-import System.IO.Unsafe ( unsafePerformIO )
-import Linear.Conjugate ( Conjugate(..) )
-
-import Casadi.Core.Classes.SXElement
-
-import Casadi.SX ( svector )
-import Casadi.Overloading ( Fmod(..), ArcTan2(..), SymOrd(..) )
-
-instance Show SXElement where
-  show x = show (svector (V.singleton x))
-
-instance Conjugate SXElement where
-  conjugate = id
-
-instance Num SXElement where
-  (+) x y = unsafePerformIO (sxElement___add__ x y)
-  {-# NOINLINE (+) #-}
-  (-) x y = unsafePerformIO (sxElement___sub__ x y)
-  {-# NOINLINE (-) #-}
-  (*) x y = unsafePerformIO (sxElement___mul__ x y)
-  {-# NOINLINE (*) #-}
-  abs x = unsafePerformIO (sxElement_fabs x)
-  {-# NOINLINE abs #-}
-  signum x = unsafePerformIO (sxElement_sign x)
-  {-# NOINLINE signum #-}
-  fromInteger x = unsafePerformIO (sxElement__0 (fromInteger x :: Double))
-  {-# NOINLINE fromInteger #-}
-
-instance Fractional SXElement where
-  (/) x y = unsafePerformIO (sxElement___truediv____0 x y)
-  {-# NOINLINE (/) #-}
-  fromRational x = unsafePerformIO (sxElement__0 (fromRational x :: Double))
-  {-# NOINLINE fromRational #-}
-
-instance Floating SXElement where
-  pi = unsafePerformIO (sxElement__0 (pi :: Double))
-  {-# NOINLINE pi #-}
-  (**) x y = unsafePerformIO (sxElement___pow__ x y)
-  {-# NOINLINE (**) #-}
-  exp x   = unsafePerformIO (sxElement_exp x)
-  {-# NOINLINE exp #-}
-  log x   = unsafePerformIO (sxElement_log x)
-  {-# NOINLINE log #-}
-  sin x   = unsafePerformIO (sxElement_sin x)
-  {-# NOINLINE sin #-}
-  cos x   = unsafePerformIO (sxElement_cos x)
-  {-# NOINLINE cos #-}
-  tan x   = unsafePerformIO (sxElement_tan x)
-  {-# NOINLINE tan #-}
-  asin x  = unsafePerformIO (sxElement_arcsin x)
-  {-# NOINLINE asin #-}
-  atan x  = unsafePerformIO (sxElement_arctan x)
-  {-# NOINLINE atan #-}
-  acos x  = unsafePerformIO (sxElement_arccos x)
-  {-# NOINLINE acos #-}
-  sinh x  = unsafePerformIO (sxElement_sinh x)
-  {-# NOINLINE sinh #-}
-  cosh x  = unsafePerformIO (sxElement_cosh x)
-  {-# NOINLINE cosh #-}
-  tanh x  = unsafePerformIO (sxElement_tanh x)
-  {-# NOINLINE tanh #-}
-  asinh x = unsafePerformIO (sxElement_arcsinh x)
-  {-# NOINLINE asinh #-}
-  atanh x = unsafePerformIO (sxElement_arctanh x)
-  {-# NOINLINE atanh #-}
-  acosh x = unsafePerformIO (sxElement_arccosh x)
-  {-# NOINLINE acosh #-}
-
-instance Fmod SXElement where
-  fmod x y = unsafePerformIO (sxElement_fmod x y)
-  {-# NOINLINE fmod #-}
-
-instance ArcTan2 SXElement where
-  arctan2 x y = unsafePerformIO (sxElement_arctan2__1 x y)
-  {-# NOINLINE arctan2 #-}
-
-instance SymOrd SXElement where
-  x `leq` y = unsafePerformIO (sxElement___le__ x y)
-  {-# NOINLINE leq #-}
-  x `geq` y = unsafePerformIO (sxElement___ge__ x y)
-  {-# NOINLINE geq #-}
-  x  `eq` y = unsafePerformIO (sxElement___eq__ x y)
-  {-# NOINLINE eq #-}
diff --git a/src/Casadi/Slice.hs b/src/Casadi/Slice.hs
--- a/src/Casadi/Slice.hs
+++ b/src/Casadi/Slice.hs
@@ -1,10 +1,9 @@
 {-# OPTIONS_GHC -Wall -fno-cse -fno-warn-orphans #-}
 
 module Casadi.Slice
-       ( Slice, slice
+       ( Slice, slice, slice'
        ) where
 
-import Data.Vector ( Vector )
 import System.IO.Unsafe ( unsafePerformIO )
 
 import Casadi.Core.Classes.Slice
@@ -15,5 +14,10 @@
 
 -- | slice start stop step
 slice :: Int -> Int -> Int -> Slice
-slice x y z = unsafePerformIO (slice__3 x y z)
+slice x y z = unsafePerformIO (slice__4 x y z)
 {-# NOINLINE slice #-}
+
+-- | Slice()
+slice' :: Slice
+slice' = unsafePerformIO slice__6
+{-# NOINLINE slice' #-}
diff --git a/src/Casadi/Sparsity.hs b/src/Casadi/Sparsity.hs
new file mode 100644
--- /dev/null
+++ b/src/Casadi/Sparsity.hs
@@ -0,0 +1,48 @@
+{-# OPTIONS_GHC -Wall -fno-cse -fno-warn-orphans #-}
+
+module Casadi.Sparsity
+       ( Sparsity
+       , upper, lower, spy, spyMatlab
+       , dense, sparse, scalar
+       ) where
+
+import qualified Data.Vector as V
+import System.IO.Unsafe ( unsafePerformIO )
+
+import Casadi.Core.Classes.Sparsity
+
+import Casadi.SharedObject ( castSharedObject )
+
+instance Show Sparsity where
+  show x = show (castSharedObject x)
+  {-# NOINLINE show #-}
+
+instance Eq Sparsity where
+  x == y = unsafePerformIO (sparsity_isEqual__1 x y)
+  {-# NOINLINE (==) #-}
+
+upper :: Int -> Sparsity
+upper k = unsafePerformIO (sparsity_upper k)
+{-# NOINLINE upper #-}
+
+lower :: Int -> Sparsity
+lower k = unsafePerformIO (sparsity_lower k)
+{-# NOINLINE lower #-}
+
+spy :: Sparsity -> IO ()
+spy = sparsity_spy
+
+spyMatlab :: Sparsity -> String -> IO ()
+spyMatlab = sparsity_spyMatlab
+
+scalar :: Sparsity
+scalar = unsafePerformIO sparsity_scalar__0
+{-# NOINLINE scalar #-}
+
+sparse :: Int -> Int -> V.Vector Int -> V.Vector Int -> Sparsity
+sparse nr nc r c = unsafePerformIO (sparsity__0 nr nc r c)
+{-# NOINLINE sparse #-}
+
+dense :: Int -> Int -> Sparsity
+dense nr nc = unsafePerformIO (sparsity_dense__1 nr nc)
+{-# NOINLINE dense #-}
