Skip to content

Commit

Permalink
Apply suggestions from code review (explicitly set result)
Browse files Browse the repository at this point in the history
Co-authored-by: Vindaar <basti90@gmail.com>
  • Loading branch information
AngelEzquerra and Vindaar authored Oct 6, 2023
1 parent 6d6efd7 commit d6d9e32
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/arraymancer/linear_algebra/algebra.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ proc pinv*[T: SomeFloat](A: Tensor[T], rcond = 1e-15): Tensor[T] =
const unit = T(1.0)
for n in 0..<S.shape[0]:
S_inv[n, n] = if abs(S[n]) > epsilon: unit / S[n] else: 0.0
Vt.transpose * S_inv * U.transpose
result = Vt.transpose * S_inv * U.transpose

proc pinv*[T: Complex32 | Complex64](A: Tensor[T], rcond = 1e-15): Tensor[T] =
## Compute the (Moore-Penrose) pseudo-inverse of a matrix.
Expand All @@ -51,4 +51,4 @@ proc pinv*[T: Complex32 | Complex64](A: Tensor[T], rcond = 1e-15): Tensor[T] =
const unit = complex(1.0)
for n in 0..<S.shape[0]:
S_inv[n, n] = if abs(S[n]) > epsilon: unit / S[n] else: complex(0.0)
Vt.conjugate.transpose * S_inv * U.conjugate.transpose
result = Vt.conjugate.transpose * S_inv * U.conjugate.transpose

0 comments on commit d6d9e32

Please sign in to comment.