Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in the dot method caused by dot product with complex vectors #14

Merged
merged 1 commit into from
Jul 25, 2018

Conversation

yoshoku
Copy link
Contributor

@yoshoku yoshoku commented Jul 25, 2018

I found a bug on the Numo::Linalg.dot method. The bug occurs when performing dot product with complex vectors.

> require 'numo/narray'
=> true
> x=Numo::DComplex.new(3).rand
=> Numo::DComplex#shape=[3]
[0.0617545+0.373067i, 0.794815+0.201042i, 0.116041+0.344032i]
> y=Numo::DComplex.new(3).rand
=> Numo::DComplex#shape=[3]
[0.539948+0.737815i, 0.165089+0.0508827i, 0.108065+0.0687079i]
> x.dot(y)
=> (-0.13202269608393907+0.365782771213446i)
>
*
> require 'numo/linalg/autoloader'
=> true
> x.dot(y)
NoMethodError: undefined method `zdot' for Numo::Linalg::Blas:Module

The BLAS function that performs dot product of complex vectors are zdotu and cdotu. Thus, I fixed those functions to be called when given a complex vector to the dot method.

> require 'numo/linalg/autoloader'
=> true
> x=Numo::DComplex.new(3).rand
=> Numo::DComplex#shape=[3]
[0.0617545+0.373067i, 0.794815+0.201042i, 0.116041+0.344032i]
> y=Numo::DComplex.new(3).rand
=> Numo::DComplex#shape=[3]
[0.539948+0.737815i, 0.165089+0.0508827i, 0.108065+0.0687079i]
> x.dot(y)
=> (-0.13202269608393907+0.36578277121344605i)

@masa16 masa16 merged commit d533274 into ruby-numo:master Jul 25, 2018
@yoshoku yoshoku deleted the fix_dot_complex_vector branch July 25, 2018 11:35
@yoshoku yoshoku mentioned this pull request Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants