This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn add-in-place! | |
"Modify xs, incrementing each element by the corresponding element of ys" | |
[xs ys] | |
(dbl/afill! [x xs y ys] (+ x y))) | |
(defn pointwise-product | |
"Produce a new double array with the product of corresponding elements of xs and ys" | |
[xs ys] | |
(dbl/amap [x xs y ys] (* x y))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(dbl/aset xs i (* 2.0 (dbl/aget xs (inc i))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 8.5 us for 10k doubles: 2.3 GFlops | |
(require '[hiphip.double :as dbl]) | |
(defn dot-product [ws xs] | |
(dbl/asum [x xs w ws] (* x w))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 8.5 us for 10k doubles: 2.3 GFlops | |
public double dotProduct(double [] ws, double[] xs) { | |
double result = 0.0; | |
for (int i=0; i < ws.length; ++i) { | |
result += ws[i] * xs[i]; | |
} | |
return result; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 8.5 us for 10k doubles: 2.3 GFlops | |
;; (11 us with *unchecked-math* false) | |
(defn dot-product [^doubles ws ^doubles xs] | |
(areduce xs i ret 0.0 | |
(+ ret (* (aget xs i) | |
(aget ws i))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 1ms for 10k doubles: 20 MFlops | |
(defn dot-product [^doubles ws ^doubles xs] | |
(reduce + (map * ws xs)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(eval `(fn positional-graph# | |
~arg-keywords | |
(let ~(vec (interleave (vals value-syms) function-calls)) | |
(new ~(def-graph-record g) | |
~@(->> g pfnk/output-schema keys (map value-syms)))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let [Ra (Ra-fnk day-of-year lat) | |
Rs (Rs-fnk tmax tmin kRs Ra) | |
...]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(fn term32635 | |
[map2634] | |
(let | |
[Rs (get map2634 :Rs nil) | |
Rso (get map2634 :Rso nil)] | |
(-> (* 1.35 Rs) (/ Rso) (- 0.35)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn restricted-call | |
"Call fnk f on the subset of keys its input schema explicitly asks for." | |
[f in-map] | |
(f (select-keys in-map (keys (pfnk/input-schema f))))) |