Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes det method for dtype object #575

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/nmatrix/math.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1393,4 +1393,4 @@ def dtype_for_floor_or_ceil
self.__dense_map__ { |l| l.send(op,rhs) }
end
end
end
end
6 changes: 0 additions & 6 deletions spec/math_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down