0.0
No commit activity in last 3 years
No release in over 3 years
This is a convolve method for numo-narray. Similar to numpy convolve method.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Gem Version

Narray::Convolve

Narray::Convolve is returns the discrete, linear convolution of two one-dimensional sequences.

Installation

Add this line to your application's Gemfile:

gem 'narray-convolve'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install narray-convolve

Usage

Narray::Convolve is similar to numpy.convolve, but with a different order of second arguments.

irb(main):001:0> require "narray/convolve"
=> true
irb(main):002:0> n = Numo::DFloat[1,2,3]
=>
Numo::DFloat#shape=[3]
...
irb(main):003:0> m = Numo::DFloat[0,1,0.5].reverse
=>
Numo::DFloat(view)#shape=[3]
...
irb(main):004:0> Narray::Convolve.convolve(n, m, :same)
=>
Numo::DFloat(view)#shape=[3]
[1, 2.5, 4]

or

> Narray::Convolve.convolve([1,2,3], [0,1,0.5].reverse, :same)
=> [1, 2.5, 4]

In case of Python

>>> import numpy as np
>>> np.convolve([1,2,3],[0,1,0.5], 'same')
array([1. , 2.5, 4. ])
>>>

See also: numpy.convolve — NumPy v1.20 Manual

License

The gem is available as open source under the terms of the MIT License.