Project

General

Profile

Actions

Feature #2265

closed

Matrix#empty? [patch]

Added by marcandre (Marc-Andre Lafortune) over 14 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
[ruby-core:26284]

Description

=begin
Now that the Matrix library handles well empty matrices, how about a new instance method #empty?

diff --git a/lib/matrix.rb b/lib/matrix.rb
index b577ef3..45ef25e 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -386,6 +386,14 @@ class Matrix
#++

#
  • Returns +true+ if this is an empty matrix, i.e. if the number of rows

  • or the number of columns is 0.

  • def empty?
  • column_size == 0 || row_size == 0
  • end
  • Returns +true+ if this is a regular matrix.

def regular?
@@ -924,7 +932,7 @@ class Matrix

Overrides Object#to_s

def to_s

  • if row_size == 0 || column_size == 0
  • if empty?
    "Matrix.empty(#{row_size}, #{column_size})"
    else
    "Matrix[" + @rows.collect{|row|
    @@ -939,7 +947,7 @@ class Matrix

Overrides Object#inspect

def inspect

  • if row_size == 0 || column_size == 0
  • if empty?
    "Matrix.empty(#{row_size}, #{column_size})"
    else
    "Matrix#{@rows.inspect}"
    =end
Actions #1

Updated by marcandre (Marc-Andre Lafortune) almost 14 years ago

  • Assignee changed from keiju (Keiju Ishitsuka) to marcandre (Marc-Andre Lafortune)
  • Target version set to 1.9.2

=begin

=end

Actions #2

Updated by marcandre (Marc-Andre Lafortune) almost 14 years ago

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

=begin
This issue was solved with changeset r27156.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0