6 #ifndef _STD_VEC_OPS_H_ 7 #define _STD_VEC_OPS_H_ 18 long sum(
const std::vector<int>& a_iv )
21 for (
int i=0; i<a_iv.size(); i++) retval += a_iv[i];
27 long product(
const std::vector<int>& a_iv )
30 for (
int i=0; i<a_iv.size(); i++) retval *= a_iv[i];
37 const int*
const a_iv_carr,
42 for (
int i=0; i<a_n; i++) a_iv[i] = a_iv_carr[i];
48 void add( std::vector<int>& a_iv,
51 for (
int i=0; i<a_iv.size(); i++) a_iv[i] += a_a;
58 const double*
const a_iv_carr,
63 for (
int i=0; i<a_n; i++) a_iv[i] = a_iv_carr[i];
74 a_normal_vec = std::vector<double>(a_size, 0.0);
76 for (
int i=0; i<a_size; i++) {
77 magn += (double)(a_vec[i]*a_vec[i]);
81 for (
int i=0; i<a_size; i++) {
82 a_normal_vec[i] = a_vec[i] / magn;
92 const std::vector<int>& a_vec )
103 const std::vector<double>& a_b )
107 for (
int i = 0; i <
std::min(a_a.size(),a_b.size()); i++) {
108 retval += ( (a_a[i]-a_b[i]) * (a_a[i]-a_b[i]) );
110 retval = sqrt(retval);
long sum(const std::vector< int > &a_iv)
Some basic definitions and macros.
void createNormalVector(std::vector< double > &a_normal_vec, const int *a_vec, const int a_size)
double compute2Norm(const std::vector< double > &a_a, const std::vector< double > &a_b)
void add(std::vector< int > &a_iv, const int a_a)
long product(const std::vector< int > &a_iv)
void copyFrom(std::vector< int > &a_iv, const int *const a_iv_carr, int a_n)