Project

General

Profile

Bug #2770 ยป matrix_det.diff

marcandre (Marc-Andre Lafortune), 02/21/2010 04:46 AM

View differences:

lib/matrix.rb
661 661
  #++
662 662

  
663 663
  #
664
  # Returns the determinant of the matrix.  If the matrix is not square, the
665
  # result is 0. This method's algorithm is Gaussian elimination method
664
  # Returns the determinant of the matrix.
665
  # This method's algorithm is Gaussian elimination method
666 666
  # and using Numeric#quo(). Beware that using Float values, with their
667 667
  # usual lack of precision, can affect the value returned by this method.  Use
668 668
  # Rational values or Matrix#det_e instead if this is important to you.
......
671 671
  #     => 45.0
672 672
  #
673 673
  def determinant
674
    return 0 unless square?
674
    Matrix.Raise ErrDimensionMismatch unless square?
675 675

  
676 676
    size = row_size
677 677
    a = to_a
......
701 701
  alias det determinant
702 702

  
703 703
  #
704
  # Returns the determinant of the matrix.  If the matrix is not square, the
705
  # result is 0. This method's algorithm is Gaussian elimination method.
704
  # Returns the determinant of the matrix.
705
  # This method's algorithm is Gaussian elimination method.
706 706
  # This method uses Euclidean algorithm. If all elements are integer,
707 707
  # really exact value. But, if an element is a float, can't return
708 708
  # exact value.
......
711 711
  #     => 63
712 712
  #
713 713
  def determinant_e
714
    return 0 unless square?
714
    Matrix.Raise ErrDimensionMismatch unless square?
715 715

  
716 716
    size = row_size
717 717
    a = to_a