sdot.c
Go to the documentation of this file.
00001 /* forms the dot product of two vectors
00002    uses unrolled loops for increments equal to one
00003    Ver.1.0, May,23,1988                            */
00004 
00005 #include "arith.h"
00006 
00007 REAL sdot(n,sx,isx,jsx,incx,sy,isy,jsy,incy)
00008 int n,incx,incy,isx,jsx,isy,jsy;
00009 MATRIX sx,sy;
00010 {
00011     REAL stemp;
00012     int i,ix,iy,m;
00013 
00014     stemp=0.0;
00015 
00016     if(n <= 0)
00017         return;
00018 
00019     if((incx != 1) || (incy != 1)){
00020 
00021         /* code for unequal increments or equal increments
00022            not equal to 1 */
00023 /*
00024         ix=1;
00025         iy=1;
00026 
00027         if(incx < 0)
00028             ix= (-n+1)*incx+1;
00029         if(incy < 0)
00030             iy= (-n+1)*incy+1;
00031         for(i=1; i<=n; i++){
00032             stemp= stemp+sx[ix][1]*sy[iy][1];
00033             ix= ix+incx;
00034             iy= iy+incy;
00035         }
00036 
00037         return(stemp);
00038 */
00039     }
00040 
00041     /* code for both increments equal to 1 */
00042 
00043     /* clean-up loop */
00044 
00045     m=n%5;
00046     if(m != 0){
00047         for(i=0; i<m; i++)
00048             stemp= stemp+sx[isx+i][jsx]*sy[isy+i][jsy];
00049     }
00050     if((m == 0) || (n >= 5)){
00051         for(i=m; i<n; i += 5)
00052             stemp= stemp+sx[isx+i][jsx]*sy[isy+i][jsy]
00053                         +sx[isx+i+1][jsx]*sy[isy+i+1][jsy]
00054                         +sx[isx+i+2][jsx]*sy[isy+i+2][jsy]
00055                         +sx[isx+i+3][jsx]*sy[isy+i+3][jsy]
00056                         +sx[isx+i+4][jsx]*sy[isy+i+4][jsy];
00057     }
00058 
00059     return(stemp);
00060 }
00061 
00062 
00063 
00064 
00065 


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Sep 3 2015 10:36:20