mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* lib/matrix.rb (Matrix#eql?): fixed [ruby-dev:36298].
Reported by an anonymous user. * lib/matrix.rb (Vector#eql?): ditto. * (Matrix#compare_by_row_vectors): takes comparison strategy as an optional parameter. * (Vector#compare_by): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@19361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									d58d4bbf0f
								
							
						
					
					
						commit
						b4248a2710
					
				
					 2 changed files with 26 additions and 6 deletions
				
			
		
							
								
								
									
										12
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								ChangeLog
									
										
									
									
									
								
							|  | @ -1,3 +1,15 @@ | |||
| Mon Sep 15 20:57:00 2008  Yuki Sonoda (Yugui)  <yugui@yugui.jp> | ||||
| 
 | ||||
| 	* lib/matrix.rb (Matrix#eql?): fixed [ruby-dev:36298]. | ||||
| 	  Reported by an anonymous user. | ||||
| 
 | ||||
| 	* lib/matrix.rb (Vector#eql?): ditto. | ||||
| 
 | ||||
| 	* (Matrix#compare_by_row_vectors): takes comparison | ||||
| 	  strategy as an optional parameter. | ||||
| 
 | ||||
| 	* (Vector#compare_by): ditto. | ||||
| 
 | ||||
| Mon Sep 15 10:28:10 2008  Yuki Sonoda (Yugui)  <yugui@yugui.jp> | ||||
| 
 | ||||
| 	* test/matrix/test_matrix.rb (setup): typo. | ||||
|  |  | |||
|  | @ -402,17 +402,21 @@ class Matrix | |||
|      | ||||
|     other.compare_by_row_vectors(@rows) | ||||
|   end | ||||
|   alias eql? == | ||||
|   def eql?(other) | ||||
|     return false unless Matrix === other | ||||
|      | ||||
|     other.compare_by_row_vectors(@rows, :eql?) | ||||
|   end | ||||
|    | ||||
|   # | ||||
|   # Not really intended for general consumption. | ||||
|   # | ||||
|   def compare_by_row_vectors(rows) | ||||
|   def compare_by_row_vectors(rows, comparison = :==) | ||||
|     return false unless @rows.size == rows.size | ||||
|      | ||||
|     0.upto(@rows.size - 1) do | ||||
|       |i| | ||||
|       return false unless @rows[i] == rows[i] | ||||
|       return false unless @rows[i].send(comparison, rows[i]) | ||||
|     end | ||||
|     true | ||||
|   end | ||||
|  | @ -1087,13 +1091,17 @@ class Vector | |||
|      | ||||
|     other.compare_by(@elements) | ||||
|   end | ||||
|   alias eql? == | ||||
|   def eql?(other) | ||||
|     return false unless Vector === other | ||||
|      | ||||
|     other.compare_by(@elements, :eql?) | ||||
|   end | ||||
|    | ||||
|   # | ||||
|   # For internal use. | ||||
|   # | ||||
|   def compare_by(elements) | ||||
|     @elements == elements | ||||
|   def compare_by(elements, comparison = :==) | ||||
|     @elements.send(comparison, elements) | ||||
|   end | ||||
|    | ||||
|   # | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 yugui
						yugui