Skip to content

Commit c495958

Browse files
prasunanandtranslunar
authored andcommitted
refactor positive_definite? method
1 parent 9f70486 commit c495958

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/nmatrix/math.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,16 +688,14 @@ def inf_matrix_norm minus = false
688688
def positive_definite?
689689
raise(ShapeError, "positive definite calculated only for square matrices") unless
690690
self.dim == 2 && self.shape[0] == self.shape[1]
691-
ans = true
692691
cond = 0
693692
while cond != self.cols
694693
if self[0..cond, 0..cond].det <= 0
695-
ans = false
696-
break
694+
return false
697695
end
698696
cond += 1
699697
end
700-
ans
698+
true
701699
end
702700

703701
protected

0 commit comments

Comments
 (0)