casadi-bindings-1.8.0.0: Casadi/Wrappers/Classes/FX.hs
{-# OPTIONS_GHC -Wall #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# Language ForeignFunctionInterface #-}
{-# Language FlexibleInstances #-}
{-# Language MultiParamTypeClasses #-}
module Casadi.Wrappers.Classes.FX
(
FX,
FXClass(..),
fx_addMonitor,
fx_call,
fx_call'',
fx_checkInputs,
fx_checkNode,
fx_evalMX,
fx_evalSX,
fx_evaluate,
fx_fullJacobian,
fx_generateCode,
fx_getInputScheme,
fx_getOutputScheme,
fx_getStat,
fx_gradient,
fx_hessian,
fx_inputScheme,
fx_jacobian,
fx_outputScheme,
fx_removeMonitor,
fx_setInputScheme,
fx_setOutputScheme,
fx_solve,
fx_symbolicInput,
fx_symbolicInputSX,
) where
import Prelude hiding ( Functor )
import Data.Vector ( Vector )
import Foreign.C.Types
import Foreign.Ptr ( Ptr )
import Foreign.ForeignPtr ( newForeignPtr )
import System.IO.Unsafe ( unsafePerformIO ) -- for show instances
import Casadi.Wrappers.Classes.PrintableObject
import Casadi.Wrappers.ForeignToolsInstances ( )
import Casadi.Wrappers.Deleters
import Casadi.Wrappers.Data
import Casadi.Wrappers.Enums
import Casadi.MarshalTypes ( CppVec, CppVecVec, CppVecVecVec,
StdString', CppBool' ) -- StdOstream'
import Casadi.Marshal ( CornerCase(..), Marshal(..) )
import Casadi.WrapReturn ( WrapReturn(..) )
instance Show FX where
show = unsafePerformIO . printableObject_getDescription
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__inputScheme" c_CasADi__FX__inputScheme
:: Ptr FX' -> IO (Ptr IOScheme')
casADi__FX__inputScheme
:: FX -> IO IOScheme
casADi__FX__inputScheme x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__inputScheme x0' >>= (newForeignPtr c_delete_CasADi__IOScheme) >>= wrapReturn
-- classy wrapper
{-|
>Access input/output scheme.
-}
fx_inputScheme :: FXClass a => a -> IO IOScheme
fx_inputScheme x = casADi__FX__inputScheme (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__outputScheme" c_CasADi__FX__outputScheme
:: Ptr FX' -> IO (Ptr IOScheme')
casADi__FX__outputScheme
:: FX -> IO IOScheme
casADi__FX__outputScheme x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__outputScheme x0' >>= (newForeignPtr c_delete_CasADi__IOScheme) >>= wrapReturn
-- classy wrapper
{-|
>Access input/output scheme.
-}
fx_outputScheme :: FXClass a => a -> IO IOScheme
fx_outputScheme x = casADi__FX__outputScheme (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__setInputScheme" c_CasADi__FX__setInputScheme
:: Ptr FX' -> Ptr IOScheme' -> IO ()
casADi__FX__setInputScheme
:: FX -> IOScheme -> IO ()
casADi__FX__setInputScheme x0 x1 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
c_CasADi__FX__setInputScheme x0' x1' >>= wrapReturn
-- classy wrapper
{-|
>Set input scheme.
-}
fx_setInputScheme :: FXClass a => a -> IOScheme -> IO ()
fx_setInputScheme x = casADi__FX__setInputScheme (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__setOutputScheme" c_CasADi__FX__setOutputScheme
:: Ptr FX' -> Ptr IOScheme' -> IO ()
casADi__FX__setOutputScheme
:: FX -> IOScheme -> IO ()
casADi__FX__setOutputScheme x0 x1 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
c_CasADi__FX__setOutputScheme x0' x1' >>= wrapReturn
-- classy wrapper
{-|
>Set output scheme.
-}
fx_setOutputScheme :: FXClass a => a -> IOScheme -> IO ()
fx_setOutputScheme x = casADi__FX__setOutputScheme (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__getInputScheme" c_CasADi__FX__getInputScheme
:: Ptr FX' -> IO (Ptr IOScheme')
casADi__FX__getInputScheme
:: FX -> IO IOScheme
casADi__FX__getInputScheme x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__getInputScheme x0' >>= (newForeignPtr c_delete_CasADi__IOScheme) >>= wrapReturn
-- classy wrapper
{-|
>Get input scheme.
-}
fx_getInputScheme :: FXClass a => a -> IO IOScheme
fx_getInputScheme x = casADi__FX__getInputScheme (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__getOutputScheme" c_CasADi__FX__getOutputScheme
:: Ptr FX' -> IO (Ptr IOScheme')
casADi__FX__getOutputScheme
:: FX -> IO IOScheme
casADi__FX__getOutputScheme x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__getOutputScheme x0' >>= (newForeignPtr c_delete_CasADi__IOScheme) >>= wrapReturn
-- classy wrapper
{-|
>Get output scheme.
-}
fx_getOutputScheme :: FXClass a => a -> IO IOScheme
fx_getOutputScheme x = casADi__FX__getOutputScheme (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__evaluate" c_CasADi__FX__evaluate
:: Ptr FX' -> IO ()
casADi__FX__evaluate
:: FX -> IO ()
casADi__FX__evaluate x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__evaluate x0' >>= wrapReturn
-- classy wrapper
{-|
>Evaluate.
-}
fx_evaluate :: FXClass a => a -> IO ()
fx_evaluate x = casADi__FX__evaluate (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__solve" c_CasADi__FX__solve
:: Ptr FX' -> IO ()
casADi__FX__solve
:: FX -> IO ()
casADi__FX__solve x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__solve x0' >>= wrapReturn
-- classy wrapper
{-|
>the same as evaluate(0,0)
-}
fx_solve :: FXClass a => a -> IO ()
fx_solve x = casADi__FX__solve (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__jacobian" c_CasADi__FX__jacobian
:: Ptr FX' -> CInt -> CInt -> Ptr CppBool' -> Ptr CppBool' -> IO (Ptr FX')
casADi__FX__jacobian
:: FX -> Int -> Int -> Bool -> Bool -> IO FX
casADi__FX__jacobian x0 x1 x2 x3 x4 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
withMarshal x2 $ \x2' ->
withMarshal x3 $ \x3' ->
withMarshal x4 $ \x4' ->
c_CasADi__FX__jacobian x0' x1' x2' x3' x4' >>= (newForeignPtr c_delete_CasADi__FX) >>= wrapReturn
-- classy wrapper
{-|
>Generate a Jacobian function of output oind with respect to input iind.
>
>Parameters:
>-----------
>
>iind: The index of the input
>
>oind: The index of the output
>
>The default behavior of this class is defined by the derived class. If
>compact is set to true, only the nonzeros of the input and output
>expressions are considered. If symmetric is set to true, the Jacobian being
>calculated is known to be symmetric (usually a Hessian), which can be
>exploited by the algorithm.
>
>The generated Jacobian has one more output than the calling function
>corresponding to the Jacobian and the same number of inputs.
-}
fx_jacobian :: FXClass a => a -> Int -> Int -> Bool -> Bool -> IO FX
fx_jacobian x = casADi__FX__jacobian (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__gradient" c_CasADi__FX__gradient
:: Ptr FX' -> CInt -> CInt -> IO (Ptr FX')
casADi__FX__gradient
:: FX -> Int -> Int -> IO FX
casADi__FX__gradient x0 x1 x2 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
withMarshal x2 $ \x2' ->
c_CasADi__FX__gradient x0' x1' x2' >>= (newForeignPtr c_delete_CasADi__FX) >>= wrapReturn
-- classy wrapper
{-|
>Generate a gradient function of output oind with respect to input iind.
>
>Parameters:
>-----------
>
>iind: The index of the input
>
>oind: The index of the output
>
>The default behavior of this class is defined by the derived class. Note
>that the output must be scalar. In other cases, use the Jacobian instead.
-}
fx_gradient :: FXClass a => a -> Int -> Int -> IO FX
fx_gradient x = casADi__FX__gradient (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__hessian" c_CasADi__FX__hessian
:: Ptr FX' -> CInt -> CInt -> IO (Ptr FX')
casADi__FX__hessian
:: FX -> Int -> Int -> IO FX
casADi__FX__hessian x0 x1 x2 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
withMarshal x2 $ \x2' ->
c_CasADi__FX__hessian x0' x1' x2' >>= (newForeignPtr c_delete_CasADi__FX) >>= wrapReturn
-- classy wrapper
{-|
>Generate a Hessian function of output oind with respect to input iind.
>
>Parameters:
>-----------
>
>iind: The index of the input
>
>oind: The index of the output
>
>The generated Hessian has two more outputs than the calling function
>corresponding to the Hessian and the gradients.
-}
fx_hessian :: FXClass a => a -> Int -> Int -> IO FX
fx_hessian x = casADi__FX__hessian (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__fullJacobian" c_CasADi__FX__fullJacobian
:: Ptr FX' -> IO (Ptr FX')
casADi__FX__fullJacobian
:: FX -> IO FX
casADi__FX__fullJacobian x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__fullJacobian x0' >>= (newForeignPtr c_delete_CasADi__FX) >>= wrapReturn
-- classy wrapper
{-|
>Generate a Jacobian function of all the inputs nonzeros (
>getNumScalarInputs()) with respect to all the output nonzeros (
>getNumScalarOutputs()).
-}
fx_fullJacobian :: FXClass a => a -> IO FX
fx_fullJacobian x = casADi__FX__fullJacobian (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__call" c_CasADi__FX__call
:: Ptr FX' -> Ptr (CppVec (Ptr MX')) -> IO (Ptr (CppVec (Ptr MX')))
casADi__FX__call
:: FX -> Vector MX -> IO (Vector MX)
casADi__FX__call x0 x1 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
c_CasADi__FX__call x0' x1' >>= (newForeignPtr c_delete_std__vector_CasADi__MX_) >>= wrapReturn
-- classy wrapper
{-|
>> vector< MX > CasADi::FX::call(const MX &arg)
>------------------------------------------------------------------------
>
>Create a function call (single input)
>
>> std::vector<MX> CasADi::FX::call(const std::vector< MX > &arg)
>------------------------------------------------------------------------
>
>Create a function call ( MX graph)
>
>> void CasADi::FX::call(const MXVector &arg, MXVector &res, const MXVectorVector &fseed, MXVectorVector &fsens, const MXVectorVector &aseed, MXVectorVector &asens)
>------------------------------------------------------------------------
>
>Create a function call with directional derivatives Note: return by
>reference with SWIG.
>
>> std::vector<std::vector<MX> > CasADi::FX::call(const std::vector< std::vector< MX > > &arg, const Dictionary &paropt=Dictionary())
>------------------------------------------------------------------------
>
>Evaluate symbolically in parallel (matrix graph) paropt: Set of options to
>be passed to the Parallelizer.
-}
fx_call :: FXClass a => a -> Vector MX -> IO (Vector MX)
fx_call x = casADi__FX__call (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__call_TIC_TIC" c_CasADi__FX__call_TIC_TIC
:: Ptr FX' -> Ptr (CppVecVec (Ptr MX')) -> IO (Ptr (CppVecVec (Ptr MX')))
casADi__FX__call''
:: FX -> Vector (Vector MX) -> IO (Vector (Vector MX))
casADi__FX__call'' x0 x1 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
c_CasADi__FX__call_TIC_TIC x0' x1' >>= (newForeignPtr c_delete_std__vector_std__vector_CasADi__MX__) >>= wrapReturn
-- classy wrapper
fx_call'' :: FXClass a => a -> Vector (Vector MX) -> IO (Vector (Vector MX))
fx_call'' x = casADi__FX__call'' (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__evalMX" c_CasADi__FX__evalMX
:: Ptr FX' -> Ptr (CppVec (Ptr MX')) -> IO (Ptr (CppVec (Ptr MX')))
casADi__FX__evalMX
:: FX -> Vector MX -> IO (Vector MX)
casADi__FX__evalMX x0 x1 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
c_CasADi__FX__evalMX x0' x1' >>= (newForeignPtr c_delete_std__vector_CasADi__MX_) >>= wrapReturn
-- classy wrapper
{-|
>> std::vector<MX> CasADi::FX::evalMX(const std::vector< MX > &arg)
>------------------------------------------------------------------------
>
>evaluate symbolically, MX type (unambiguous)
>
>> void CasADi::FX::evalMX(const MXVector &arg, MXVector &res, const MXVectorVector &fseed, MXVectorVector &fsens, const MXVectorVector &aseed, MXVectorVector &asens)
>------------------------------------------------------------------------
>
>Evaluate symbolically with with directional derivatives, MX type The first
>two arguments are the nondifferentiated inputs and results of the
>evaluation, the next two arguments are a set of forward directional seeds
>and the resulting forward directional derivatives, the length of the vector
>being the number of forward directions. The next two arguments are a set of
>adjoint directional seeds and the resulting adjoint directional derivatives,
>the length of the vector being the number of adjoint directions.
-}
fx_evalMX :: FXClass a => a -> Vector MX -> IO (Vector MX)
fx_evalMX x = casADi__FX__evalMX (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__evalSX" c_CasADi__FX__evalSX
:: Ptr FX' -> Ptr (CppVec (Ptr SXMatrix')) -> IO (Ptr (CppVec (Ptr SXMatrix')))
casADi__FX__evalSX
:: FX -> Vector SXMatrix -> IO (Vector SXMatrix)
casADi__FX__evalSX x0 x1 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
c_CasADi__FX__evalSX x0' x1' >>= (newForeignPtr c_delete_std__vector_CasADi__Matrix_CasADi__SX__) >>= wrapReturn
-- classy wrapper
{-|
>> std::vector<SXMatrix> CasADi::FX::evalSX(const std::vector< SXMatrix > &arg)
>------------------------------------------------------------------------
>
>evaluate symbolically, SX type (unambiguous)
>
>> void CasADi::FX::evalSX(const SXMatrixVector &arg, SXMatrixVector &res, const SXMatrixVectorVector &fseed, SXMatrixVectorVector &fsens, const SXMatrixVectorVector &aseed, SXMatrixVectorVector &asens)
>------------------------------------------------------------------------
>
>Evaluate symbolically with with directional derivatives, SX type The first
>two arguments are the nondifferentiated inputs and results of the
>evaluation, the next two arguments are a set of forward directional seeds
>and the resulting forward directional derivatives, the length of the vector
>being the number of forward directions. The next two arguments are a set of
>adjoint directional seeds and the resulting adjoint directional derivatives,
>the length of the vector being the number of adjoint directions.
-}
fx_evalSX :: FXClass a => a -> Vector SXMatrix -> IO (Vector SXMatrix)
fx_evalSX x = casADi__FX__evalSX (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__generateCode" c_CasADi__FX__generateCode
:: Ptr FX' -> Ptr StdString' -> IO ()
casADi__FX__generateCode
:: FX -> String -> IO ()
casADi__FX__generateCode x0 x1 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
c_CasADi__FX__generateCode x0' x1' >>= wrapReturn
-- classy wrapper
{-|
>Export / Generate C code for the function.
-}
fx_generateCode :: FXClass a => a -> String -> IO ()
fx_generateCode x = casADi__FX__generateCode (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__checkNode" c_CasADi__FX__checkNode
:: Ptr FX' -> IO (Ptr CppBool')
casADi__FX__checkNode
:: FX -> IO Bool
casADi__FX__checkNode x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__checkNode x0' >>= (newForeignPtr c_delete_bool) >>= wrapReturn
-- classy wrapper
{-|
>Check if the node is pointing to the right type of object.
-}
fx_checkNode :: FXClass a => a -> IO Bool
fx_checkNode x = casADi__FX__checkNode (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__getStat" c_CasADi__FX__getStat
:: Ptr FX' -> Ptr StdString' -> IO (Ptr GenericType')
casADi__FX__getStat
:: FX -> String -> IO GenericType
casADi__FX__getStat x0 x1 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
c_CasADi__FX__getStat x0' x1' >>= (newForeignPtr c_delete_CasADi__GenericType) >>= wrapReturn
-- classy wrapper
{-|
>Get a single statistic obtained at the end of the last evaluate call.
-}
fx_getStat :: FXClass a => a -> String -> IO GenericType
fx_getStat x = casADi__FX__getStat (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__symbolicInput" c_CasADi__FX__symbolicInput
:: Ptr FX' -> IO (Ptr (CppVec (Ptr MX')))
casADi__FX__symbolicInput
:: FX -> IO (Vector MX)
casADi__FX__symbolicInput x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__symbolicInput x0' >>= (newForeignPtr c_delete_std__vector_CasADi__MX_) >>= wrapReturn
-- classy wrapper
{-|
>Get a vector of symbolic variables with the same dimensions as the inputs
>There is no guarantee that consecutive calls return identical objects.
-}
fx_symbolicInput :: FXClass a => a -> IO (Vector MX)
fx_symbolicInput x = casADi__FX__symbolicInput (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__symbolicInputSX" c_CasADi__FX__symbolicInputSX
:: Ptr FX' -> IO (Ptr (CppVec (Ptr SXMatrix')))
casADi__FX__symbolicInputSX
:: FX -> IO (Vector SXMatrix)
casADi__FX__symbolicInputSX x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__symbolicInputSX x0' >>= (newForeignPtr c_delete_std__vector_CasADi__Matrix_CasADi__SX__) >>= wrapReturn
-- classy wrapper
{-|
>Get a vector of symbolic variables with the same dimensions as the inputs,
>SX graph There is no guarantee that consecutive calls return identical
>objects.
-}
fx_symbolicInputSX :: FXClass a => a -> IO (Vector SXMatrix)
fx_symbolicInputSX x = casADi__FX__symbolicInputSX (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__addMonitor" c_CasADi__FX__addMonitor
:: Ptr FX' -> Ptr StdString' -> IO ()
casADi__FX__addMonitor
:: FX -> String -> IO ()
casADi__FX__addMonitor x0 x1 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
c_CasADi__FX__addMonitor x0' x1' >>= wrapReturn
-- classy wrapper
{-|
>Add modules to be monitored.
-}
fx_addMonitor :: FXClass a => a -> String -> IO ()
fx_addMonitor x = casADi__FX__addMonitor (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__removeMonitor" c_CasADi__FX__removeMonitor
:: Ptr FX' -> Ptr StdString' -> IO ()
casADi__FX__removeMonitor
:: FX -> String -> IO ()
casADi__FX__removeMonitor x0 x1 =
withMarshal x0 $ \x0' ->
withMarshal x1 $ \x1' ->
c_CasADi__FX__removeMonitor x0' x1' >>= wrapReturn
-- classy wrapper
{-|
>Remove modules to be monitored.
-}
fx_removeMonitor :: FXClass a => a -> String -> IO ()
fx_removeMonitor x = casADi__FX__removeMonitor (castFX x)
-- direct wrapper
foreign import ccall unsafe "CasADi__FX__checkInputs" c_CasADi__FX__checkInputs
:: Ptr FX' -> IO ()
casADi__FX__checkInputs
:: FX -> IO ()
casADi__FX__checkInputs x0 =
withMarshal x0 $ \x0' ->
c_CasADi__FX__checkInputs x0' >>= wrapReturn
-- classy wrapper
{-|
>Check if the numerical values of the supplied bounds make sense.
-}
fx_checkInputs :: FXClass a => a -> IO ()
fx_checkInputs x = casADi__FX__checkInputs (castFX x)