33 #ifndef __H__UG__LIB_ALGEBRA__OPERATIONS_VEC_ON_INDEX_SET__
34 #define __H__UG__LIB_ALGEBRA__OPERATIONS_VEC_ON_INDEX_SET__
43 template<
typename vector_t>
45 const std::vector<size_t> vIndex)
47 std::vector<size_t>::const_iterator iter = vIndex.begin();
48 std::vector<size_t>::const_iterator iterEnd = vIndex.end();
50 for(; iter < iterEnd; ++iter)
52 const size_t i = *iter;
53 UG_ASSERT(i < dest.size(),
"Index to large in index set.");
59 template<
typename vector_t>
61 number alpha1,
const vector_t &v1,
62 const std::vector<size_t> vIndex)
64 std::vector<size_t>::const_iterator iter = vIndex.begin();
65 std::vector<size_t>::const_iterator iterEnd = vIndex.end();
67 for(; iter < iterEnd; ++iter)
69 const size_t i = *iter;
70 UG_ASSERT(i < dest.size(),
"Index to large in index set.");
71 UG_ASSERT(i < v1.size(),
"Index to large in index set.");
77 template<
typename vector_t>
79 number alpha1,
const vector_t &v1,
80 number alpha2,
const vector_t &v2,
81 const std::vector<size_t> vIndex)
83 std::vector<size_t>::const_iterator iter = vIndex.begin();
84 std::vector<size_t>::const_iterator iterEnd = vIndex.end();
86 for(; iter < iterEnd; ++iter)
88 const size_t i = *iter;
89 UG_ASSERT(i < dest.size(),
"Index to large in index set.");
90 UG_ASSERT(i < v1.size(),
"Index to large in index set.");
91 UG_ASSERT(i < v2.size(),
"Index to large in index set.");
98 template<
typename vector_t>
100 number alpha1,
const vector_t &v1,
101 number alpha2,
const vector_t &v2,
102 number alpha3,
const vector_t &v3,
103 const std::vector<size_t> vIndex)
105 std::vector<size_t>::const_iterator iter = vIndex.begin();
106 std::vector<size_t>::const_iterator iterEnd = vIndex.end();
108 for(; iter < iterEnd; ++iter)
110 const size_t i = *iter;
111 UG_ASSERT(i < dest.size(),
"Index to large in index set.");
112 UG_ASSERT(i < v1.size(),
"Index to large in index set.");
113 UG_ASSERT(i < v2.size(),
"Index to large in index set.");
114 UG_ASSERT(i < v3.size(),
"Index to large in index set.");
115 VecScaleAdd(dest[i], alpha1, v1[i], alpha2, v2[i], alpha3, v3[i]);
123 template<
typename vector_t>
124 inline void VecProd(
const vector_t &a,
const vector_t &b,
125 number &sum,
const std::vector<size_t> vIndex)
127 std::vector<size_t>::const_iterator iter = vIndex.begin();
128 std::vector<size_t>::const_iterator iterEnd = vIndex.end();
130 for(; iter < iterEnd; ++iter)
132 const size_t i = *iter;
133 UG_ASSERT(i < a.size(),
"Index to large in index set.");
134 UG_ASSERT(i < b.size(),
"Index to large in index set.");
140 template<
typename vector_t>
142 const std::vector<size_t> vIndex)
151 template<
typename vector_t>
153 number &sum,
const std::vector<size_t> vIndex)
155 std::vector<size_t>::const_iterator iter = vIndex.begin();
156 std::vector<size_t>::const_iterator iterEnd = vIndex.end();
158 for(; iter < iterEnd; ++iter)
160 const size_t i = *iter;
161 UG_ASSERT(i < a.size(),
"Index to large in index set.");
167 template<
typename vector_t>
169 const std::vector<size_t> vIndex)
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
double number
Definition: types.h:124
void VecSet(vector_t &vInOut, typename vector_t::value_type s)
Set each vector component to scalar (componentwise)
Definition: math_vector_functions_common_impl.hpp:539
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
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
double VecNormSquared(const double &a)
returns norm_2^2(a)
Definition: operations_vec.h:100
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