Skip to content

Instantly share code, notes, and snippets.

@ghorn
ghorn / gist:93cb7ebb808fc7535834
Created February 11, 2015 13:29
haskell has no type-level lambda?
type Compose f g a = f (g a)
type Apply f a = f a
-- This one fails with "Compose has 3 arguments but you gave it 2".
-- All the others work.
x0 :: Apply (Compose f g) a
x0 = undefined
x1 :: (Compose f g) a
x1 = undefined
@ghorn
ghorn / gist:1d3be472ec61f666e130
Created January 27, 2015 09:12
SXElement not completely internal
$ grep -n10 "std::vector<(casadi::SXElement)>" ~/casadi-2.2.0/build/swig/json/casadi.json
44434- "methodDocslink": "",
44435- "methodKind": "Normal"
44436- },
44437- {
44438- "methodDocs": "",
44439- "methodName": "mul_no_alloc",
44440- "methodParams": [
44441- "r.q(const).casadi::Matrix<(casadi::SXElement)>",
44442- "r.q(const).casadi::Matrix<(casadi::SXElement)>",
ghorn@cowabunga:~/casadi-2.2.0-rc1$ grep -r '_core' *
casadi/CMakeLists.txt: if(NOT "${name}" STREQUAL "casadi_core")
casadi/CMakeLists.txt: target_link_libraries(${name} casadi_core)
casadi/core/matrix/matrix.hpp:#ifdef casadi_core_implementation
casadi/core/matrix/generic_matrix.hpp:#ifdef casadi_core_implementation
casadi/core/matrix/generic_matrix.hpp:#ifdef casadi_core_implementation
casadi/core/matrix/submatrix.hpp:#ifdef casadi_core_implementation
casadi/core/matrix/nonzeros.hpp:#ifdef casadi_core_implementation
casadi/core/CMakeLists.txt:casadi_library(casadi_core ${CASADI_SRCS} ${RUNTIME_EMBEDDED_SRC})
casadi/core/CMakeLists.txt:set_property(GLOBAL APPEND PROPERTY CASADI_SWIG_MODULES casadi_core)
{-# OPTIONS_GHC -Wall #-}
{-# Language DeriveGeneric #-}
{-# Language DeriveFunctor #-}
module Main where
import GHC.Generics ( Generic )
import Data.Vector ( Vector )
import qualified Data.Vector as V
from casadi import *
x0 = MX.sym('x',10,1);
u = MX.sym('u',10,1);
f = MXFunction([x0,u],[x0])
f.setOption('name','f')
f.init()
h = MX.sym('h',1,1);
-- multiple shooting
data MsPoint x u a = MsPoint (x a) (u a)
data MsTraj x u n a = MsTraj (Vec n (MsPoint x u a)) (x a)
@ghorn
ghorn / ghc bug?
Created April 6, 2014 14:58
ghc bug?
-- put these two files in a directory and the compile with
-- ghc -fforce-recomp -O2 -prof -fprof-auto-calls Woo.hs
-- Vectorize.hs
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE TypeOperators #-}
module Vectorize
( GVectorize(..)
ghorn@adler:~$ cat .xmonad/xmonad.hs
{-# OPTIONS_GHC -Wall #-}
module Main ( main ) where
import XMonad
import qualified XMonad.StackSet as SS
import XMonad.Util.EZConfig ( additionalKeys )
import XMonad.Prompt.Shell ( shellPrompt )
import XMonad.Prompt ( defaultXPConfig )
ghorn@adler:~$ cat .xsession
# .xsesssion
# nicer looking cursor
xsetroot -cursor_name left_ptr
# background image
xloadimage -onroot -fullscreen ~/Dropbox/desktop_backgrounds/trex_aviators.jpg
# key repeat delay to 250ms, repeat rate to 35Hz
from casadi import *
##### lets integrate something 100 timesteps with 3 different methods #####
# this is whate we want to integrate
def dynamics_fun(x):
xdot = # some complicated shit
return xdot
## 1: inline everything, standard approach to AD afaik
def rk4(x0, h):