TABLE OF CONTENTS


ABINIT/dotproduct [ Functions ]

[ Top ] [ Functions ]

NAME

 dotproduct

FUNCTION

 scalar product of two vectors

COPYRIGHT

 Copyright (C) 1998-2018 ABINIT group (DCA, XG, MT)
 This file is distributed under the terms of the
 GNU General Public License, see ~ABINIT/COPYING
 or http://www.gnu.org/copyleft/gpl.txt .
 For the initials of contributors, see ~ABINIT/Infos/contributors .

INPUTS

 v1 and v2: two real(dp) vectors

OUTPUT

 scalar product of the two vectors

SIDE EFFECTS

WARNINGS

 vector size is not checked

NOTES

 I've benchmarked this to be speedier than the intrinsic dot_product even on
 big vectors. The point is that less check is performed.

PARENTS

 cgpr,brent

CHILDREN

SOURCE

39 #if defined HAVE_CONFIG_H
40 #include "config.h"
41 #endif
42 
43 #include "abi_common.h"
44 
45 
46 function dotproduct(nv1,nv2,v1,v2)
47 
48  use defs_basis
49 
50 !This section has been created automatically by the script Abilint (TD).
51 !Do not modify the following lines by hand.
52 #undef ABI_FUNC
53 #define ABI_FUNC 'dotproduct'
54 !End of the abilint section
55 
56  implicit none
57 
58 !Arguments ------------------------------------
59 !scalars
60  integer,intent(in) :: nv1,nv2
61  real(dp) :: dotproduct
62 !arrays
63  real(dp),intent(in) :: v1(nv1,nv2),v2(nv1,nv2)
64 
65 !Local variables-------------------------------
66 !scalars
67  integer :: i,j
68 
69 ! *************************************************************************
70  dotproduct=zero
71  do j=1,nv2
72   do i=1,nv1
73    dotproduct=dotproduct+v1(i,j)*v2(i,j)
74   end do
75  end do
76 end function dotproduct