Skip to content

Commit dd785a1

Browse files
committed
Added example for pivoting QR.
1 parent bd80504 commit dd785a1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

example/linalg/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ ADD_EXAMPLE(svdvals)
5454
ADD_EXAMPLE(determinant)
5555
ADD_EXAMPLE(determinant2)
5656
ADD_EXAMPLE(qr)
57+
ADD_EXAMPLE(pivoting_qr)
5758
ADD_EXAMPLE(qr_space)
5859
ADD_EXAMPLE(cholesky)
5960
ADD_EXAMPLE(chol)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
program example_pivoting_qr
2+
use stdlib_linalg, only: qr
3+
implicit none
4+
real :: A(104, 32), Q(104, 32), R(32, 32)
5+
integer :: pivots(32)
6+
7+
! Create a random matrix
8+
call random_number(A)
9+
10+
! Compute its QR factorization (reduced)
11+
call qr(A, Q, R, pivots)
12+
13+
! Test factorization: Q*R = A
14+
print *, maxval(abs(matmul(Q, R) - A(:, pivots)))
15+
16+
end program example_pivoting_qr

0 commit comments

Comments
 (0)