Skip to content

Instantly share code, notes, and snippets.

View adamnemecek's full-sized avatar

adamnemecek

View GitHub Profile
@adamnemecek
adamnemecek / OpenStarSemiring.lhs
Created March 2, 2024 04:37 — forked from sjoerdvisscher/OpenStarSemiring.lhs
Playing with 'A Very General Method of Computing Shortest Paths'
This is an extension of "A Very General Method of Computing Shortest Paths" to use "open matrices".
This is from a paper "The Open Algebraic Path Problem" by Jade Master https://arxiv.org/abs/2005.06682
> {-# LANGUAGE TypeFamilies #-}
> {-# LANGUAGE TypeApplications #-}
> {-# LANGUAGE FlexibleContexts #-}
> {-# LANGUAGE StandaloneDeriving #-}
> {-# LANGUAGE AllowAmbiguousTypes #-}
> {-# LANGUAGE ScopedTypeVariables #-}
> module OpenStarSemiring where
@adamnemecek
adamnemecek / conv.jl
Created January 9, 2024 16:40
convolution == superposition
using DSP: conv
@assert conv([1, 0, 0], 1:4) .+ # [1, 2, 3, 4, 0, 0]
conv([0, 2, 0], 1:4) .+ # [0, 2, 4, 6, 8, 0]
conv([0, 0, 3], 1:4) == # [0, 0, 3, 6, 9, 12]
conv([1, 2, 3], 1:4) # [1, 4, 10, 16, 17, 12]
@adamnemecek
adamnemecek / dsp.jl
Created September 30, 2023 20:42
DSP in 20 loc
using LinearAlgebra: diag
# returns a `LinRange` representing `k`s which can
# be passed into `diag`, starting from top right
function diags(m::AbstractMatrix)
(nr, nc) = size(m) .- 1
return reverse(-nr:nc)
end
# sum of values along diagonal, `diagsum(m, 0) == tr(m)`
@adamnemecek
adamnemecek / definition_of_truth.md
Created August 23, 2022 18:58 — forked from Mec-iS/definition_of_truth.md
Truth as Eigenform

Definition of Truth

Jason the Goodman <jasonthegoodman@....com>:

How about defining "truth" with "stability" of the coupling loop between "the object" and the cognitive system coupling with the "object"? If the process stabilizes and an eigenvalue of the loop emerges, we say "a truth" is found. This would refocus our attention from the "object" itself to the nature of the cognitive system, which may include animals and robots in addition to humans. My tentative way to upgrade from first-order thinking to the second-order thinking. Then, instead of searching for "truth", we search for the "Lyapunov potential function" for the situation if we could find one...

Louis H Kauffman <kauffman@....edu>

Eigenform is important way to formalize a kind of stability. Truth is a special kind of eigenform, not just any eigenform. Truth means the truth of a PROPOSITION about something. So we need to have a language involved and the notion that the propositions are talking about some domain where it is possible to c

struct User : Equatable {
let id: UInt
let selected: Bool
}
var z = (0...10).map { User(id: $0, selected: $0 == 3 || $0 == 6 || $0 == 10) }
var q = (0...10).map { User(id: $0, selected: $0 == 3 || $0 == 6 || $0 == 10) }
z.gather(at: 0) { $0.selected }
z.gather(at: 5) { $0.selected }
@adamnemecek
adamnemecek / programming-as-theory-building.md
Created June 1, 2020 03:25 — forked from onlurking/programming-as-theory-building.md
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

@adamnemecek
adamnemecek / launch.json
Last active March 17, 2023 13:15
VSCode Rust debugging on macOS config
{
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceRoot}/target/debug/${workspaceRootFolderName}",
"args": [],
"cwd": "${workspaceRoot}",

Adjointness

Adjoint

Adjointness expresses a condition that is essentially universal in mathematics, category theory, probability, logic, optimization, machine learning.

What is adjointness? Depends on the context.

This page is really illuminating.

@adamnemecek
adamnemecek / gist:ae2755c5c4eaabd0d864e6c62dbe5088
Created November 28, 2019 21:10 — forked from LearnCocos2D/gist:77f0ced228292676689f
Overview of Entity Component System (ECS) variations with pseudo-code

For background and further references see: Entity Component Systems on Wikipedia

ECS by Scott Bilas (GDC 2002)

Entity->Components->Update
  • entity = class: no logic + no data OR at most small set of frequently used data (ie position)
  • component = class: logic + data
foreach entity in allEntities do
    foreach component in entity.components do
@adamnemecek
adamnemecek / Clifford.hs
Created March 29, 2019 16:55 — forked from fkuehnel/Clifford.hs
Haskell module for Clifford Algebra tensor representations, and a Geometric Algebra module utilizing the tensor representation
-- credit goes to sigfpe
{-# LANGUAGE MultiParamTypeClasses
,TemplateHaskell
,GeneralizedNewtypeDeriving
,DeriveFunctor
,FunctionalDependencies
,FlexibleInstances
,UndecidableInstances
,FlexibleContexts
,Rank2Types #-}