Bug #6966

Vector#norm は複素数ベクトルの正しいノルムを返さない

Added by 5 5 over 1 year ago. Updated over 1 year ago.

[ruby-dev:46100]
Status:Closed
Priority:Low
Assignee:-
Category:lib
Target version:1.9.3
ruby -v:ruby 1.9.3p194 (2012-04-20) [i386-mingw32] Backport:

Description

Vector#norm は,単に成分の自乗和の正の平方根を取っていますが,これだと成分が複素数のときに正しい値を返しません。成分の絶対値自乗和の正の平方根を取るべきではないでしょうか。

Vector[Complex(0, 1), 1].norm
=> 0.0

Vector[Complex(0, 1), 0].norm
=> Math::DomainError: Numerical argument is out of domain - "sqrt"

Associated revisions

Revision 36887
Added by Nobuyoshi Nakada over 1 year ago

matrix.rb: complex vector

  • lib/matrix.rb (Vector#magnitude): accumulate squares of absolute values to fix for complex vector. [Bug #6966]

History

#1 Updated by Nobuyoshi Nakada over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r36887.
5, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


matrix.rb: complex vector

  • lib/matrix.rb (Vector#magnitude): accumulate squares of absolute values to fix for complex vector. [Bug #6966]

Also available in: Atom PDF