File: example_dot_product.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 (18 lines) | stat: -rw-r--r-- 623 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
program example_dot_product
    use stdlib_kinds, only: sp
    use stdlib_intrinsics, only: stdlib_dot_product, stdlib_dot_product_kahan
    implicit none

    real(sp), allocatable :: x(:), y(:)
    real(sp) :: total_prod(3)

    allocate( x(1000), y(1000) )
    call random_number(x)
    call random_number(y)

    total_prod(1) = dot_product(x,y) !> compiler intrinsic
    total_prod(2) = stdlib_dot_product(x,y)       !> chunked summation over inner product
    total_prod(3) = stdlib_dot_product_kahan(x,y) !> chunked kahan summation over inner product
    print *, total_prod(1:3)
    
end program example_dot_product