File: example_matmul.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (13 lines) | stat: -rw-r--r-- 597 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
program example_matmul
    use stdlib_intrinsics, only: stdlib_matmul
    complex :: x(2, 2), y(2, 2), z(2, 2)

    x = reshape([(0, 0), (1, 0), (1, 0), (0, 0)], [2, 2])  ! pauli x-matrix
    y = reshape([(0, 0), (0, 1), (0, -1), (0, 0)], [2, 2]) ! pauli y-matrix
    z = reshape([(1, 0), (0, 0), (0, 0), (-1, 0)], [2, 2]) ! pauli z-matrix

    print *, stdlib_matmul(x, y) ! should be iota*z
    print *, stdlib_matmul(y, z, x) ! should be iota*identity
    print *, stdlib_matmul(x, x, z, y) ! should be -iota*x
    print *, stdlib_matmul(x, x, z, y, y) ! should be z
end program example_matmul