Skip to content
Merged
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
10 changes: 5 additions & 5 deletions ext/nmatrix/ruby_nmatrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -3006,12 +3006,12 @@ static VALUE nm_det_exact(VALUE self) {
nm::dtype_t dtype = NM_DTYPE(self);
nm_math_det_exact(NM_SHAPE0(self), NM_STORAGE_DENSE(self)->elements, NM_SHAPE0(self), NM_DTYPE(self), result);

VALUE to_return;
if (dtype == nm::RUBYOBJ) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on this. @cjfuller Just want to check this with you since you wrote the register/unregister functions.

nm_register_values(reinterpret_cast<VALUE*>(result), 1);
}
VALUE to_return = nm::rubyobj_from_cval(result, NM_DTYPE(self)).rval;
if (dtype == nm::RUBYOBJ) {
nm_unregister_values(reinterpret_cast<VALUE*>(result), 1);
to_return = *reinterpret_cast<VALUE*>(result);

} else {
to_return = nm::rubyobj_from_cval(result, NM_DTYPE(self)).rval;
}
NM_CONSERVATIVE(nm_unregister_value(&self));

Expand Down
13 changes: 9 additions & 4 deletions spec/math_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,6 @@

context "determinants" do
ALL_DTYPES.each do |dtype|
next if dtype == :object
context dtype do
before do
@a = NMatrix.new([2,2], [1,2,
Expand All @@ -968,13 +967,19 @@
end
end
it "computes the determinant of 2x2 matrix" do
expect(@a.det).to be_within(@err).of(-2)
if dtype != :object

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you're not testing #det with Ruby objects anymore.

@isuruf isuruf May 19, 2016

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not testing #det, only #det_exact. Both were disabled in line 949 before

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh! I see now.

expect(@a.det).to be_within(@err).of(-2)
end
end
it "computes the determinant of 3x3 matrix" do
expect(@b.det).to be_within(@err).of(-8)
if dtype != :object
expect(@b.det).to be_within(@err).of(-8)
end
end
it "computes the determinant of 4x4 matrix" do
expect(@c.det).to be_within(@err).of(-18)
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