Skip to content

Instantly share code, notes, and snippets.

View rebcabin's full-sized avatar

Brian Beckman rebcabin

View GitHub Profile
@rebcabin
rebcabin / virtual-time.clj
Created April 11, 2017 15:48 — forked from didibus/virtual-time.clj
My deftype based take on the google group question found here: https://groups.google.com/forum/#!topic/clojure/oe1Ch1oSlLk
(ns spec-test.virtual-time
(:require [clojure.spec :as s]
[clojure.spec.test :as st]
[clojure.spec.gen :as sgen]))
(deftype VirtualTime [time]
Object
(hashCode [_]
(hash time))
(equals [this that]
@rebcabin
rebcabin / virtual-time.clj
Created April 11, 2017 13:49 — forked from didibus/virtual-time.clj
My take on the google group question found here: https://groups.google.com/forum/#!topic/clojure/oe1Ch1oSlLk
(ns spec-test.virtual-time
(:require [clojure.spec :as s]
[clojure.spec.test :as st]))
(s/def ::virtual-time
(s/or
:positive-infinity #{:positive-infinity}
:negative-infinity #{:negative-infinity}
:number number?))
(s/fdef vt-lt

calc examples

@rebcabin
rebcabin / clj_spec_playground.clj
Last active February 2, 2017 16:23 — forked from ghoseb/clj_spec_playground.clj
Examples of Clojure's new clojure.spec library
(ns clj-spec-playground
(:require [clojure.string :as str]
[clojure.spec :as s]
[clojure.test.check.generators :as gen]))
;;; examples of clojure.spec being used like a gradual/dependently typed system.
(defn make-user
"Create a map of inputs after splitting name."
([name email]
@rebcabin
rebcabin / list.cpp
Created September 18, 2016 14:47 — forked from splinterofchaos/list.cpp
Several of Haskell's Data.List functions implemented in C++ Data.List: http://www.haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html
#include <algorithm>
#include <vector>
#include <iterator>
#include <iostream>
template< class F, class X, class S >
constexpr X foldl( F&& f, X x, const S& s ) {
return std::accumulate (
std::begin(s), std::end(s),
@rebcabin
rebcabin / kalmanSample.c
Last active April 22, 2020 18:16
Kalman filtering as a fold with CBLAS and LAPACK
/*
Copyright 2016 Brian C. Beckman
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@rebcabin
rebcabin / Ukf.fs
Created May 27, 2016 03:27 — forked from praeclarum/Ukf.fs
Unscented Kalman Filter (nonlinear version of the classic Kalman filter) in F#
module Drone.Control.Ukf
open System
open Drone.Control.Matrix
type IDiscreteModel =
abstract Process : Matrix -> Matrix
abstract Observe : Matrix -> Matrix
abstract InitialState : Matrix
@rebcabin
rebcabin / kalman.f90
Created May 19, 2016 01:24 — forked from mrocklin/kalman.f90
Kalman filter in BLAS/LAPACK Fortran
subroutine f(mu, Sigma, H, INFO, R, Sigmavar_2, data, muvar_2, k, n)
implicit none
integer, intent(in) :: k
integer, intent(in) :: n
real*8, intent(in) :: Sigma(n, n) ! Sigma
real*8, intent(in) :: H(k, n) ! H
real*8, intent(in) :: mu(n) ! mu
real*8, intent(in) :: R(k, k) ! R, H*Sigma*H' + R
real*8, intent(in) :: data(k) ! (H*Sigma*H' + R)^-1*((-1)*data + H*mu), data, (-1)* data + H*mu
ClearAll[myNotebook, myStyles, myDemoIntegral, myDemoSolution,
myMathGroup, myItemGroup, myNumberedGroup, myCode, myProgramText,
myMeatyContentGroup, mySectionGroup, myDocumentGroup,
myFontFunction, myDefaultStyles, myNonDefaultStyles];
myNotebook[myStyles_, myDocumentGroup_] :=
Module[{result},
CreateDocument[
result = Notebook[
{Cell[myDocumentGroup]},
StyleDefinitions -> Notebook[
Module[{myNotebook, myCells, myStyles, myDemoIntegral, myDemoSolution,
myMathGroup, myItemGroup, myNumberedGroup, myCode, myProgramText,
myMeatyContentGroup, mySectionGroup, myDocumentGroup,
myFontFunction, myDefaultStyles, myNonDefaultStyles},
myDemoIntegral = RowBox[{
RowBox[{"\[Integral]",
RowBox[{"x", RowBox[{"\[DifferentialD]", "x"}]}]}],
"+", SqrtBox["z"]}];
myDemoSolution = RowBox[{
FractionBox[SuperscriptBox["x", "2"], "2"],