sdot.c
Go to the documentation of this file.
1 /* forms the dot product of two vectors
2  uses unrolled loops for increments equal to one
3  Ver.1.0, May,23,1988 */
4 
5 #include "arith.h"
6 
7 REAL sdot(n,sx,isx,jsx,incx,sy,isy,jsy,incy)
8 int n,incx,incy,isx,jsx,isy,jsy;
9 MATRIX sx,sy;
10 {
11  REAL stemp;
12  int i,ix,iy,m;
13 
14  stemp=0.0;
15 
16  if(n <= 0)
17  return;
18 
19  if((incx != 1) || (incy != 1)){
20 
21  /* code for unequal increments or equal increments
22  not equal to 1 */
23 /*
24  ix=1;
25  iy=1;
26 
27  if(incx < 0)
28  ix= (-n+1)*incx+1;
29  if(incy < 0)
30  iy= (-n+1)*incy+1;
31  for(i=1; i<=n; i++){
32  stemp= stemp+sx[ix][1]*sy[iy][1];
33  ix= ix+incx;
34  iy= iy+incy;
35  }
36 
37  return(stemp);
38 */
39  }
40 
41  /* code for both increments equal to 1 */
42 
43  /* clean-up loop */
44 
45  m=n%5;
46  if(m != 0){
47  for(i=0; i<m; i++)
48  stemp= stemp+sx[isx+i][jsx]*sy[isy+i][jsy];
49  }
50  if((m == 0) || (n >= 5)){
51  for(i=m; i<n; i += 5)
52  stemp= stemp+sx[isx+i][jsx]*sy[isy+i][jsy]
53  +sx[isx+i+1][jsx]*sy[isy+i+1][jsy]
54  +sx[isx+i+2][jsx]*sy[isy+i+2][jsy]
55  +sx[isx+i+3][jsx]*sy[isy+i+3][jsy]
56  +sx[isx+i+4][jsx]*sy[isy+i+4][jsy];
57  }
58 
59  return(stemp);
60 }
61 
62 
63 
64 
65 
GLfloat n[6][3]
Definition: cube.c:15
double REAL
Definition: arith.h:25
REAL sdot(int n, MATRIX sx, int isx, int jsx, int incx, MATRIX sy, int isy, int jsy, int incy)
Definition: sdot.c:7
VECTOR MATRIX[MAX]
Definition: arith.h:27
static int ix
Definition: printer.c:29


euslisp
Author(s): Toshihiro Matsui
autogenerated on Mon Feb 28 2022 22:18:28