Skip to content

Commit a052599

Browse files
committed
modified example and slight changes
1 parent cee5bba commit a052599

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

example/intrinsics/example_matmul.f90

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
program example_matmul
22
use stdlib_intrinsics, only: stdlib_matmul
3-
complex :: x(2, 2), y(2, 2)
4-
real :: r1(50, 100), r2(100, 40), r3(40, 50)
5-
real, allocatable :: res(:, :)
3+
complex :: x(2, 2), y(2, 2), z(2, 2)
64
x = reshape([(0, 0), (1, 0), (1, 0), (0, 0)], [2, 2])
75
y = reshape([(0, 0), (0, 1), (0, -1), (0, 0)], [2, 2]) ! pauli y-matrix
6+
z = reshape([(1, 0), (0, 0), (0, 0), (-1, 0)], [2, 2])
87

9-
print *, stdlib_matmul(y, y, y) ! should be y
10-
print *, stdlib_matmul(x, x, y, x) ! should be -i x sigma_z
11-
12-
call random_seed()
13-
call random_number(r1)
14-
call random_number(r2)
15-
call random_number(r3)
16-
17-
res = stdlib_matmul(r1, r2, r3) ! 50x50 matrix
18-
print *, shape(res)
8+
print *, stdlib_matmul(x, y) ! should be iota*z
9+
print *, stdlib_matmul(y, z, x) ! should be iota*identity
10+
print *, stdlib_matmul(x, x, z, y) ! should be -iota*x
11+
print *, stdlib_matmul(x, x, z, y, y) ! should be z
1912
end program example_matmul

src/stdlib_intrinsics_matmul.fypp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ contains
7474
k = p(start + 1)
7575
call gemm('N', 'N', m, n, k, one_${s}$, temp, m, m3, k, zero_${s}$, r, m)
7676
else
77-
error stop "stdlib_matmul: error: unexpected s(i,j)"
77+
! our internal functions are incorrent, abort
78+
error stop this//": error: unexpected s(i,j)"
7879
end if
7980

8081
end function matmul_chain_mult_${s}$_3
@@ -120,7 +121,8 @@ contains
120121
k = p(start + 3)
121122
call gemm('N', 'N', m, n, k, one_${s}$, temp, m, m4, k, zero_${s}$, r, m)
122123
else
123-
error stop "stdlib_matmul: error: unexpected s(i,j)"
124+
! our internal functions are incorrent, abort
125+
error stop this//": error: unexpected s(i,j)"
124126
end if
125127

126128
end function matmul_chain_mult_${s}$_4

0 commit comments

Comments
 (0)