summaryrefslogtreecommitdiff
path: root/Utilib/src/SDOT.f
diff options
context:
space:
mode:
authorstainer_t <thomas.stainer@oecd-nea.org>2025-09-08 13:48:49 +0200
committerstainer_t <thomas.stainer@oecd-nea.org>2025-09-08 13:48:49 +0200
commit7dfcc480ba1e19bd3232349fc733caef94034292 (patch)
tree03ee104eb8846d5cc1a981d267687a729185d3f3 /Utilib/src/SDOT.f
Initial commit from Polytechnique Montreal
Diffstat (limited to 'Utilib/src/SDOT.f')
-rw-r--r--Utilib/src/SDOT.f76
1 files changed, 76 insertions, 0 deletions
diff --git a/Utilib/src/SDOT.f b/Utilib/src/SDOT.f
new file mode 100644
index 0000000..c1f8897
--- /dev/null
+++ b/Utilib/src/SDOT.f
@@ -0,0 +1,76 @@
+*DECK SDOT
+ REAL FUNCTION SDOT(N,SX,INCX,SY,INCY)
+*
+*-----------------------------------------------------------------------
+*
+*Purpose:
+* forms the dot product of two vectors. Uses unrolled loops for
+* increments equal to one.
+*
+*Copyright:
+* Copyright (C) 2002 Ecole Polytechnique de Montreal
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version
+*
+*Author(s): Jack Dongarra, linpack, 3/11/78.
+*
+*Parameters: input
+* N number of components in the vectors.
+* SX first vector.
+* INCX increment in first vector.
+* SY second vector.
+* INCY increment in second vector.
+*
+*Parameters: output
+* SDOT dot product.
+*
+*-----------------------------------------------------------------------
+*
+*----
+* SUBROUTINE ARGUMENTS
+*----
+ INTEGER N,INCX,INCY
+ REAL SX(N*INCX),SY(N*INCY)
+*----
+* LOCAL VARIABLES
+*----
+ INTEGER I,IX,IY,M,MP1
+ REAL STEMP
+*
+ STEMP = 0.0E0
+ SDOT = 0.0E0
+ IF(N.LE.0)RETURN
+ IF(INCX.EQ.1.AND.INCY.EQ.1)GO TO 20
+*----
+* CODE FOR UNEQUAL INCREMENTS OR EQUAL INCREMENTS NOT EQUAL TO 1.
+*----
+ IX = 1
+ IY = 1
+ IF(INCX.LT.0)IX = (-N+1)*INCX + 1
+ IF(INCY.LT.0)IY = (-N+1)*INCY + 1
+ DO 10 I = 1,N
+ STEMP = STEMP + SX(IX)*SY(IY)
+ IX = IX + INCX
+ IY = IY + INCY
+ 10 CONTINUE
+ SDOT = STEMP
+ RETURN
+*----
+* CODE FOR BOTH INCREMENTS EQUAL TO 1. CLEAN-UP LOOP.
+*----
+ 20 M = MOD(N,5)
+ IF( M .EQ. 0 ) GO TO 40
+ DO 30 I = 1,M
+ STEMP = STEMP + SX(I)*SY(I)
+ 30 CONTINUE
+ IF( N .LT. 5 ) GO TO 60
+ 40 MP1 = M + 1
+ DO 50 I = MP1,N,5
+ STEMP = STEMP + SX(I)*SY(I) + SX(I + 1)*SY(I + 1) +
+ * SX(I + 2)*SY(I + 2) + SX(I + 3)*SY(I + 3) + SX(I + 4)*SY(I + 4)
+ 50 CONTINUE
+ 60 SDOT = STEMP
+ RETURN
+ END