Project

General

Profile

Actions

Bug #2651

closed

Matrix#compare_by_row_vectors does not receive array of Vector

Added by mame (Yusuke Endoh) over 15 years ago. Updated over 14 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-11-16 trunk 25792) [i686-linux]
Backport:
[ruby-dev:40152]

Description

=begin
遠藤です。

Matrix#compare_by_row_vectors が、その名前に反して、Vector の配列を
与えても正しく比較してくれません。

require "matrix"
m = Matrix[[1, 2], [3, 4]]
a = [Vector[1, 2], Vector[3, 4]]
p m.compare_by_row_vectors(a) #=> false

配列の配列ならちゃんと動きます。これは意図的でしょうか。

p m.compare_by_row_vectors([[1, 2], [3, 4]]) #=> true

意図的でなければ、以下のパッチはどうでしょうか。

--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -427,7 +428,7 @@ class Matrix
return false unless @rows.size == rows.size

  @rows.size.times do |i|
  •  return false unless @rows[i].send(comparison, rows[i])
    
  •  return false unless @rows[i].send(comparison,
    

Matrix.convert_to_array(rows[i]))
end
true
end

--
Yusuke ENDOH
=end

Actions #1

Updated by naruse (Yui NARUSE) over 15 years ago

  • Priority changed from 3 to Normal
  • ruby -v set to ruby 1.9.2dev (2009-11-16 trunk 25792) [i686-linux]

=begin

=end

Actions #2

Updated by marcandre (Marc-Andre Lafortune) over 15 years ago

  • Category set to lib
  • Status changed from Open to Closed
  • Assignee set to marcandre (Marc-Andre Lafortune)

=begin
Matrix#compare_by_row_vectors has been removed
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0