33 #ifndef __H__UG__LIB_ALGEBRA__OPERATIONS_VEC__
34 #define __H__UG__LIB_ALGEBRA__OPERATIONS_VEC__
55 inline void VecScaleAdd(
double &dest,
double alpha1,
const double &v1,
double alpha2,
const double &v2)
57 dest = alpha1*v1 + alpha2*v2;
61 inline void VecScaleAdd(
double &dest,
double alpha1,
const double &v1,
double alpha2,
const double &v2,
double alpha3,
const double &v3)
63 dest = alpha1*v1 + alpha2*v2 + alpha3*v3;
70 inline void VecProdAdd(
const double &a,
const double &b,
double &s)
75 template<
typename vector_t>
76 inline void VecProdAdd(
const vector_t &a,
const vector_t &b,
double &s)
78 for(
size_t i=0; i<a.size(); i++)
84 inline double VecProd(
const double &a,
const double &b)
91 inline void VecProd(
const double &a,
const double &b,
double &s)
122 inline void VecExp(
double &dest,
const double &v)
128 inline void VecLog(
double &dest,
const double &v)
145 template<
typename vector_t>
148 for(
size_t i=0; i<dest.size(); i++)
153 template<
typename vector_t>
154 inline void VecAssign(vector_t &dest,
const vector_t &v1)
156 for(
size_t i=0; i<dest.size(); i++)
161 template<
typename vector_t,
template <
class T>
class TE_VEC>
162 inline void VecScaleAdd(TE_VEC<vector_t> &dest,
double alpha1,
const TE_VEC<vector_t> &v1,
double alpha2,
const TE_VEC<vector_t> &v2)
164 for(
size_t i=0; i<dest.size(); i++)
165 VecScaleAdd(dest[i], alpha1, v1[i], alpha2, v2[i]);
169 template<
typename vector_t,
template <
class T>
class TE_VEC>
170 inline void VecScaleAdd(TE_VEC<vector_t> &dest,
double alpha1,
const TE_VEC<vector_t> &v1,
double alpha2,
const TE_VEC<vector_t> &v2,
double alpha3,
const TE_VEC<vector_t> &v3)
172 for(
size_t i=0; i<dest.size(); i++)
173 VecScaleAdd(dest[i], alpha1, v1[i], alpha2, v2[i], alpha3, v3[i]);
180 template<
typename vector_t>
181 inline void VecProd(
const vector_t &a,
const vector_t &b,
double &sum)
183 for(
size_t i=0; i<a.size(); i++)
188 template<
typename vector_t>
189 inline double VecProd(
const vector_t &a,
const vector_t &b)
198 template<
typename vector_t>
201 for(
size_t i=0; i<a.size(); i++)
206 template<
typename vector_t>
215 template<
typename vector_t>
218 for(
size_t i=0; i<dest.size(); i++)
223 template<
typename vector_t>
224 inline void VecExp(vector_t &dest,
const vector_t &v)
226 for(
size_t i=0; i<dest.size(); i++)
231 template<
typename vector_t>
232 inline void VecLog(vector_t &dest,
const vector_t &v)
234 for(
size_t i=0; i<dest.size(); i++)
void VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition: math_vector_functions_common_impl.hpp:265
void VecAssign(vector_t &dest, const vector_t &v1)
sets dest = v1 entrywise
Definition: operations_vec.h:154
void VecExp(double &dest, const double &v)
calculates elementwise exp
Definition: operations_vec.h:122
double VecProd(const double &a, const double &b)
returns scal<a, b>
Definition: operations_vec.h:84
void VecNormSquaredAdd(const double &a, double &s)
calculates s += norm_2^2(a)
Definition: operations_vec.h:106
void VecLog(double &dest, const double &v)
calculates elementwise log (natural logarithm)
Definition: operations_vec.h:128
double VecNormSquared(const double &a)
returns norm_2^2(a)
Definition: operations_vec.h:100
void VecHadamardProd(double &dest, const double &v1, const double &v2)
calculates s = a * b (the Hadamard product)
Definition: operations_vec.h:114
void VecProdAdd(const double &a, const double &b, double &s)
calculates s += scal<a, b>
Definition: operations_vec.h:70
void VecScaleAssign(double &dest, double alpha1, const double &v1)
calculates dest = alpha1*v1. for doubles
Definition: operations_vec.h:49