A point product between two matrices in ruby, in the most efficient way

I am writing a ruby โ€‹โ€‹machine learning algorithm that uses gradient descent and logistic regression.

The algorithms work fine, except that in a ruby, the product of points between matrices is very slow.

I started using gem RubyPython, which allows you to import python libraries, such as numpy, into ruby โ€‹โ€‹and use its functions.

The performance is numpyimpressive. The application started to work 1000% faster, except that I always get segmentation faulthalfway.

Does anyone know any other way to speed up a dot product from 2 matrices in ruby?

+4
source share
1

Ruby matrix. ,

require 'matrix'

. ,

a = Vector[1,3,-5]
b = Vector[4,-2,-1]

a.inner_product(b)
=> 3
+5

All Articles