Skip to content

Commit

Permalink
Adding convolve1d and gaussian1d convolution.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuernber committed May 22, 2021
1 parent 0610916 commit 8bf90fc
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
22 changes: 22 additions & 0 deletions java/tech/v3/datatype/ArrayHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,26 @@ public static void accumPlus(float[] data, int idx, float val) {
public static void accumPlus(double[] data, int idx, double val) {
data[idx] += val;
}

public static void accumMul(byte[] data, int idx, byte val) {
data[idx] *= val;
}
public static void accumMul(short[] data, int idx, short val) {
data[idx] *= val;
}
public static void accumMul(char[] data, int idx, char val) {
data[idx] *= val;
}
public static void accumMul(int[] data, int idx, int val) {
data[idx] *= val;
}
public static void accumMul(long[] data, int idx, long val) {
data[idx] *= val;
}
public static void accumMul(float[] data, int idx, float val) {
data[idx] *= val;
}
public static void accumMul(double[] data, int idx, double val) {
data[idx] *= val;
}
}
1 change: 1 addition & 0 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
tech.v3.datatype.bitmap
tech.v3.datatype.datetime
tech.v3.datatype.mmap
tech.v3.datatype.convolve
tech.v3.datatype.mmap-writer
tech.v3.datatype.native-buffer
tech.v3.datatype.sampling
Expand Down
27 changes: 26 additions & 1 deletion src/tech/v3/datatype/reductions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,32 @@
Each bucket's results end up ordered by index iteration order. The original parallel pass
goes through each index in order and then the reduction goes through the thread groups in order
so if your index reduction merger just does (.addAll lhs rhs) then the final result ends up
ordered."
ordered.
Example:
```clojure
user> (import '[tech.v3.datatype IndexReduction])
tech.v3.datatype.IndexReduction
user> (require '[tech.v3.datatype :as dtype])
nil
user> (require '[tech.v3.datatype.reductions :as dt-reduce])
nil
user> (def key-col [:a :b :a :a :c :d])
#'user/key-col
user> (def val-col (mapv name key-col))
#'user/val-col
user> (dt-reduce/ordered-group-by-reduce
(reify IndexReduction
(reduceIndex [this batch ctx idx]
(conj ctx (val-col idx)))
(reduceReductions [this lhs rhs]
(vec (concat lhs rhs))))
key-col)
{:a (\"a\" \"a\" \"a\"), :b (\"b\"), :c (\"c\"), :d (\"d\")}
user>
```"
(^Map [^IndexReduction reducer batch-data rdr]
(let [rdr (dtype-base/->reader rdr)
n-elems (.lsize rdr)
Expand Down

0 comments on commit 8bf90fc

Please sign in to comment.