brew install himeyama/homebrew-lib/libcuda-convolve
Gemfile
gem 'cuda-convolve'
and
bundle
Gem
gem install cuda-convolve
# frozen_string_literal: true
require 'cuda/convolve'
using CudaConvolve
p [1, 2, 3].convolve([0, 1, 0.5])
# [0.0, 1.0, 2.5, 4.0, 1.5]
p [1, 2, 3].convolve([0, 1, 0.5], mode: :same)
# [1.0, 2.5, 4.0]
p [1, 2, 3].convolve([0, 1, 0.5], mode: :valid)
# [2.5]