Project

General

Profile

Bug #6966

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

Added by 5 5 over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
ruby -v:
ruby 1.9.3p194 (2012-04-20) [i386-mingw32]
Backport:
2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
[ruby-dev:46100]

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 3 years ago

matrix.rb: complex vector

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

Revision 36887
Added by Nobuyoshi Nakada over 3 years 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 3 years 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