narray-convolve 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/narray/convolve.rb +19 -26
- data/lib/narray/convolve/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6aa29c31466271fedbbd1d898e75d89e1d8e3c58d4e8792a676eee027daf174
|
4
|
+
data.tar.gz: 53e2e2de7a27c51556bf88ecd8ccfac48afcbfe31465e205ffdd7b7943975aec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c46aabfc248fad88d6035644b817ea83e2415843c4792b3d77b8ad19b29e42ea7e1b67bf02217f6c4398bbf7fcdf25553c0665e5af76919a86133ff466fab0f5
|
7
|
+
data.tar.gz: e8d70f2255f3b3be56da902754c98183d4a83025dc0c45a4540b35bb9052daa6e386a503f5f7fb96038091412bea9d514ae321d891d533817e5eb47f6eaf0978
|
data/lib/narray/convolve.rb
CHANGED
@@ -5,42 +5,35 @@ require "numo/narray"
|
|
5
5
|
|
6
6
|
module Narray
|
7
7
|
module Convolve
|
8
|
-
# ======================================
|
9
8
|
#
|
10
9
|
# Narray::Convolve is similar to numpy.convolve,
|
11
10
|
# but with a different order of second arguments.
|
12
11
|
#
|
13
12
|
# @example
|
14
|
-
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# m
|
20
|
-
#
|
21
|
-
# => [1, 2.5, 4]
|
22
|
-
#
|
23
|
-
# or
|
13
|
+
# Narray::Convolve
|
14
|
+
#
|
15
|
+
# require "narray/convolve"
|
16
|
+
# n = Numo::DFloat[1,2,3]
|
17
|
+
# m = Numo::DFloat[0,1,0.5].reverse
|
18
|
+
# Narray::Convolve.convolve(n, m, :same)
|
19
|
+
# # => [1, 2.5, 4]
|
24
20
|
#
|
25
|
-
#
|
26
|
-
# => [1, 2.5, 4]
|
27
|
-
# ```
|
21
|
+
# or
|
28
22
|
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
23
|
+
# Narray::Convolve.convolve([1,2,3], [0,1,0.5].reverse, :same)
|
24
|
+
# # => [1, 2.5, 4]
|
25
|
+
#
|
26
|
+
# In case of numpy.convolve
|
27
|
+
# >>> numpy.convolve([1,2,3],[0,1,0.5], 'same')
|
28
|
+
# array([1. , 2.5, 4. ])
|
29
|
+
#
|
34
30
|
#
|
35
|
-
# ======================================
|
36
31
|
#
|
37
|
-
# @param
|
38
|
-
#
|
39
|
-
#
|
40
|
-
# mode: (Symbol) {:full, :same, :valid}
|
32
|
+
# @param n [Numo::DFloat or Array]
|
33
|
+
# @param m [Numo::DFloat or Array]
|
34
|
+
# @param mode [Symbol] (:full, :same, :valid)
|
41
35
|
#
|
42
|
-
# @
|
43
|
-
# convolution of n and m.
|
36
|
+
# @return [Numo::DFloat] convolution of n and m.
|
44
37
|
#
|
45
38
|
def convolve(n, m, mode = :full)
|
46
39
|
case n
|