Skip to content

Commit ff7ad85

Browse files
committed
Fix ranges with negative steps in QR
1 parent 2502181 commit ff7ad85

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

nx/lib/nx/binary_backend/matrix.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ defmodule Nx.BinaryBackend.Matrix do
118118

119119
defp qr_decomposition(matrix, m, n, eps) when m >= n do
120120
# QR decomposition is performed by using Householder transform
121-
122121
max_i = if m == n, do: n - 2, else: n - 1
123122

124123
{q_matrix, r_matrix} =

nx/lib/nx/lin_alg/qr.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ defmodule Nx.LinAlg.QR do
5757
column_iota = Nx.iota({Nx.axis_size(a, 0)}, vectorized_axes: a.vectorized_axes)
5858

5959
{{q, r}, _} =
60-
while {{q = base_h, r = Nx.as_type(a, type)}, {column_iota}}, i <- 0..max_i do
60+
while {{q = base_h, r = Nx.as_type(a, type)}, {column_iota}}, i <- 0..max_i//1 do
6161
x = r[[.., i]]
6262
x = Nx.select(column_iota < i, 0, x)
6363
h = householder_reflector(x, i, eps)

0 commit comments

Comments
 (0)