Skip to content

Instantly share code, notes, and snippets.

{-# OPTIONS_GHC -Wall #-}
{-# Language DeriveGeneric #-}
{-# Language DeriveFunctor #-}
module Main where
import GHC.Generics ( Generic )
import Data.Vector ( Vector )
import qualified Data.Vector as V
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)
@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
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
This is Ipopt version 3.11.9, running with linear solver ma86.
Number of nonzeros in equality constraint Jacobian...: 0
Number of nonzeros in inequality constraint Jacobian.: 0
Number of nonzeros in Lagrangian Hessian.............: 786
Total number of variables............................: 109
variables with only lower bounds: 0
variables with lower and upper bounds: 0
variables with only upper bounds: 0
cbits/autogen/casadi_wrap_classes.cpp: In function ‘casadi::CodeGenerator* casadi__CodeGenerator__CONSTRUCTOR__0(std::string**)’:
cbits/autogen/casadi_wrap_classes.cpp:1331:59:
error: use of deleted function ‘casadi::CodeGenerator::CodeGenerator(casadi::CodeGenerator&&)’
casadi::CodeGenerator ret = casadi::CodeGenerator();
^
In file included from /home/greghorn/casadi_install/include/casadi/core/core.hpp:46:0:
0,
from /home/greghorn/casadi_install/include/casadi/casadi.hpp:29,
proc wall num proc time wall time
time time evals per eval per eval
eval_f 0.002 [s] 0.002 [s] 15 0.10 [ms] 0.10 [ms]
eval_grad_f 0.002 [s] 0.002 [s] 16 0.11 [ms] 0.11 [ms]
eval_g 0.002 [s] 0.002 [s] 15 0.11 [ms] 0.11 [ms]
eval_jac_g 0.006 [s] 0.006 [s] 17 0.36 [ms] 0.36 [ms]
eval_h 0.306 [s] 0.306 [s] 15 20.39 [ms] 20.41 [ms]
main loop 0.329 [s] 0.330 [s]
callback function 0.000 [s] 0.000 [s]
callback preparation 0.000 [s] 0.000 [s]
proc wall num mean mean
time time evals proc time wall time
eval_f 0.368 [s] 0.112 [s] 6 61.27 [ms] 18.62 [ms]
eval_grad_f 1.256 [s] 0.937 [s] 7 179.38 [ms] 133.85 [ms]
eval_g 0.360 [s] 0.109 [s] 6 60.02 [ms] 18.09 [ms]
eval_jac_g 5.360 [s] 5.052 [s] 8 670.00 [ms] 631.47 [ms]
eval_h 2.749 [s] 2.749 [s] 6 458.21 [ms] 458.11 [ms]
main loop 10.373 [s] 9.221 [s]
jit + serial:
@ghorn
ghorn / HackPlotLib.hs
Created November 15, 2015 18:32
work in progress simple matlab-like plotting API with multiple backends
{-# OPTIONS_GHC -Wall #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
-- | Some plotting utilities.
module HackPlotLib
( Plotter
-- * plotting functions
, figure, figure'
, plot, plot', plot3, plot3'
# check for inequalities
for k in range(arg['lbx'].shape[0]):
lbx = arg['lbx'].cat[k]
ubx = arg['ubx'].cat[k]
if lbx == ubx:
pass
elif lbx == -np.inf and ubx == np.inf:
pass
else:
raise ValueError('x index %d is an inequality (%.3g, %.3g)' % (k, lbx, ubx))