Skip to content

Instantly share code, notes, and snippets.

View torfjelde's full-sized avatar

Tor Erlend Fjelde torfjelde

View GitHub Profile
@jthaman
jthaman / consult-ripgrep-all.el
Last active April 10, 2024 01:09
Call ripgrep-all in emacs with consult
;; Note: put `rga' in your PATH. -*- lexical-binding: t; -*-
(require 'consult)
(defcustom consult-ripgrep-all-args
"rga --null --line-buffered --color=never --max-columns=1000 --path-separator /\ --smart-case --no-heading --with-filename --line-number"
"Command line arguments for ripgrep, see `consult-ripgrep-all'.
The dynamically computed arguments are appended.
Can be either a string, or a list of strings or expressions."
:type '(choice string (repeat (choice string expression))))
using ForwardDiff
goo((x, y, z),) = [x^2*z, x*y*z, abs(z)-y]
foo((x, y, z),) = [x^2*z, x*y*z, abs(z)-y]
function foo(u::Vector{ForwardDiff.Dual{T,V,P}}) where {T,V,P}
# unpack: AoS -> SoA
vs = ForwardDiff.value.(u)
# you can play with the dimension here, sometimes it makes sense to transpose
ps = mapreduce(ForwardDiff.partials, hcat, u)
# get f(vs)
val = foo(vs)