1 #include "BSprivate.h"
2 
3 /*+ BSpar_bip - Inner products on several vectors at once
4 
5     Input Parameters:
6 .   num_cols - the length of the vectors
7 .   vec1 - the first block of contiguous vectors
8 .   vec2 - the second block of contiguous vectors
9 .   nBS - the number of vectors
10 .   procinfo - the usual processor stuff
11 
12     Output Parameters:
13 .   result - the result of each inner product (length nBS)
14 
15     Returns:
16     void
17 
18  +*/
BSpar_bip(int num_cols,FLOAT * vec1,FLOAT * vec2,int nBS,FLOAT * result,BSprocinfo * procinfo)19 void BSpar_bip(int num_cols, FLOAT *vec1, FLOAT *vec2, int nBS,
20 		FLOAT *result, BSprocinfo *procinfo)
21 {
22 	int	i, j;
23 	FLOAT	t;
24 	FLOAT	*t_vec1, *t_vec2;
25 	FLOAT	*work;
26 
27 	/* compute my contribution to the IP */
28 	t_vec1 = vec1;
29 	t_vec2 = vec2;
30 	for (j=0;j<nBS;j++) {
31 		t = 0.0;
32 		for (i=0;i<num_cols;i++) {
33 			t += t_vec1[i]*t_vec2[i];
34 		}
35 		result[j] = t;
36 		t_vec1 += num_cols;
37 		t_vec2 += num_cols;
38 	}
39 	MY_MALLOC(work,(FLOAT *),sizeof(FLOAT)*nBS,1);
40 	GFLSUM(result,nBS,work,procinfo->procset);
41 	MY_FREE(work);
42 	MLOG_flop((2*nBS*num_cols));
43 }
44