From 678f4bffea505fd356b265c2b0c8b3074ba475f6 Mon Sep 17 00:00:00 2001 From: npriyadarshi Date: Sat, 4 Mar 2017 16:08:24 +0530 Subject: [PATCH] fixes det method for dtype object --- lib/nmatrix/math.rb | 4 ++-- spec/math_spec.rb | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/nmatrix/math.rb b/lib/nmatrix/math.rb index eca6e1fc..0f5f6c53 100644 --- a/lib/nmatrix/math.rb +++ b/lib/nmatrix/math.rb @@ -767,7 +767,7 @@ def det raise(ShapeError, "determinant can be calculated only for square matrices") unless self.dim == 2 && self.shape[0] == self.shape[1] # Cast to a dtype for which getrf is implemented - new_dtype = self.integer_dtype? ? :float64 : self.dtype + new_dtype = self.integer_dtype? || self.object_dtype? ? :float64 : self.dtype copy = self.cast(:dense, new_dtype) # Need to know the number of permutations. We'll add up the diagonals of @@ -1393,4 +1393,4 @@ def dtype_for_floor_or_ceil self.__dense_map__ { |l| l.send(op,rhs) } end end -end \ No newline at end of file +end diff --git a/spec/math_spec.rb b/spec/math_spec.rb index f19bd4ea..89abfbfa 100644 --- a/spec/math_spec.rb +++ b/spec/math_spec.rb @@ -1032,19 +1032,13 @@ end end it "computes the determinant of 2x2 matrix" do - if dtype != :object expect(@a.det).to be_within(@err).of(-2) - end end it "computes the determinant of 3x3 matrix" do - if dtype != :object expect(@b.det).to be_within(@err).of(-8) - end end it "computes the determinant of 4x4 matrix" do - if dtype != :object expect(@c.det).to be_within(@err).of(-18) - end end it "computes the exact determinant of 2x2 matrix" do if dtype == :byte