/usr/include/vmmlib/blas_dot.hpp is in libvmmlib-dev 1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | #ifndef __VMML__VMMLIB_BLAS_DOT__HPP__
#define __VMML__VMMLIB_BLAS_DOT__HPP__
#include <vmmlib/vector.hpp>
#include <vmmlib/exception.hpp>
#include <vmmlib/blas_includes.hpp>
#include <vmmlib/blas_types.hpp>
/**
*
* a wrapper for blas's DOT routine.
* REAL FUNCTION SDOT(N,SX,INCX,SY,INCY)
* .. Scalar Arguments ..
* INTEGER INCX,INCY,N
*
* .. Array Arguments ..
* REAL SX(*),SY(*)
*
*
* Purpose
* =======
*
* SDOT forms the dot product of two vectors.
* uses unrolled loops for increments equal to one. *
*
* more information in: http://netlib.org/blas/sdot.f
**
*/
namespace vmml
{
namespace blas
{
#if 0
/* Subroutine */
float cblas_sdot( const int N, const float *X, const int incX, const float *Y, const int incY );
double cblas_ddot( const int N, const double *X, const int incX, const double *Y, const int incY );
#endif
template< typename float_t >
struct dot_params
{
blas_int n;
float_t* x;
blas_int inc_x;
float_t* y;
blas_int inc_y;
friend std::ostream& operator << ( std::ostream& os,
const dot_params< float_t >& p )
{
os
<< " (1)\tn " << p.n << std::endl
<< " (2)\tx " << p.x << std::endl
<< " (3)\tincX " << p.inc_x << std::endl
<< " (4)\ty " << p.y << std::endl
<< " (5)\tincY " << p.inc_y << std::endl
<< std::endl;
return os;
}
};
template< typename float_t >
inline float_t
dot_call( dot_params< float_t >& p )
{
VMMLIB_ERROR( "not implemented for this type.", VMMLIB_HERE );
}
template<>
inline float
dot_call( dot_params< float >& p )
{
//std::cout << "calling blas sdot (single precision) " << std::endl;
float vvi = cblas_sdot(
p.n,
p.x,
p.inc_x,
p.y,
p.inc_y
);
return vvi;
}
template<>
inline double
dot_call( dot_params< double >& p )
{
//std::cout << "calling blas ddot (double precision) " << std::endl;
double vvi = cblas_ddot(
p.n,
p.x,
p.inc_x,
p.y,
p.inc_y
);
return vvi;
}
} // namespace blas
template< size_t M, typename float_t >
struct blas_dot
{
typedef vector< M, float_t > vector_t;
blas_dot();
~blas_dot() {};
bool compute( const vector_t& A_, const vector_t& B_, float_t& dot_prod_ );
blas::dot_params< float_t > p;
const blas::dot_params< float_t >& get_params(){ return p; };
}; // struct blas_dot
template< size_t M, typename float_t >
blas_dot< M, float_t >::blas_dot()
{
p.n = M;
p.x = 0;
p.inc_x = 1;
p.y = 0;
p.inc_y = 1;
}
template< size_t M, typename float_t >
bool
blas_dot< M, float_t >::compute( const vector_t& A_, const vector_t& B_, float_t& dot_prod_ )
{
// blas needs non-const data
vector_t* AA = new vector_t( A_ );
vector_t* BB = new vector_t( B_ );
p.x = AA->array;
p.y = BB->array;
dot_prod_ = blas::dot_call< float_t >( p );
//std::cout << dot_prod_ << std::endl; //debug
delete AA;
delete BB;
return true;
}
} // namespace vmml
#endif
|