这篇博文简要介绍使用MKL函数库计算两个向量的内积
代码如下:
program MKL_dot
use blas95
implicit none
integer, parameter :: n = 10
real*8 :: x(n), y(n), res
call random_seed()
call random_number(x)
write(*,*) 'the vector x is...'
write(*,*) x
call random_number(y)
write(*,*) 'the vector y is...'
write(*,*) y
res = dot(x, y)
write(*,*) 'the dot of vector x and y is...'
write(*,*) res
end program MKL_dot
结果如下:
the vector x is...
0.679810766961385 0.940445379325120 0.118188116255211
0.816592771285391 0.838392989366967 0.849352073015143
0.266004683268441 0.847329051710184 0.322610789640767
0.493228510452631
the vector y is...
0.376989557893998 0.270279820064913 9.455209506532534E-003
0.102345081371875 0.396037357702467 0.419892290928794
0.960550118073242 0.357395240281985 0.350215226303922
0.206699864272721
the dot of vector x and y is...
2.05710372421063