33 #ifndef __H__UG__CPU_ALGEBRA__VECTOR__
34 #define __H__UG__CPU_ALGEBRA__VECTOR__
38 #include "../common/template_expressions.h"
39 #include "../common/operations.h"
53 template <
typename TValueType>
109 void resize(
size_t newSize,
bool bCopyValues=
true)
113 void reserve(
size_t newCapacity,
bool bCopyValues=
true)
153 template <
typename V>
void add(
const V& u);
154 template <
typename V>
void set(
const V& u);
155 template <
typename V>
void get(V& u)
const;
158 void add(
const value_type *u,
const size_t *indices,
size_t nr);
159 void set(
const value_type *u,
const size_t *indices,
size_t nr);
160 void get(
value_type *u,
const size_t *indices,
size_t nr)
const;
172 for(
size_t i=0; i<
size(); i++)
values[i] *= a;
176 inline double norm()
const;
186 void print(
const char *
const text = NULL)
const;
192 output <<
"Vector " <<
"[" << v.
m_size <<
"]";
virtual ~Vector()
virtual destructor
Definition: vector_impl.h:140
void resize_exactly(size_t newSize, bool bCopyValues=true)
resize the vector to be EXACTLY newSize big (no overhead)
Definition: vector_impl.h:230
virtual vector_type * virtual_clone_without_values() const
virtual clone using covariant return type excluding values
Definition: vector_impl.h:181
void set(double d)
assign double d to whole Vector
Definition: vector.h:143
void resize_sloppy(size_t newSize, bool bCopyValues=true)
Definition: vector_impl.h:219
size_t capacity() const
Definition: vector.h:118
void reserve_sloppy(size_t newCapacity, bool bCopyValues=true)
Definition: vector_impl.h:212
TValueType value_type
Definition: vector.h:57
friend std::ostream & operator<<(std::ostream &output, const Vector &v)
ostream << operator
Definition: vector.h:190
void operator-=(const Vector &v)
Definition: vector_impl.h:116
void set_random(double from, double to)
Definition: vector_impl.h:91
void print(const char *const text=NULL) const
print vector to console
Definition: vector_impl.h:255
void operator*=(const number &a)
Definition: vector.h:170
size_t m_capacity
size of the vector (vector is from 0..size-1)
Definition: vector.h:226
void operator+=(const Vector &v)
Definition: vector_impl.h:108
size_t defragment()
Definition: vector.h:196
SmartPtr< vector_type > clone() const
clones the vector (deep-copy) including values
Definition: vector_impl.h:175
void add(const V &u)
Definition: vector_impl.h:269
virtual vector_type * virtual_clone() const
virtual clone using covariant return type
Definition: vector_impl.h:169
double norm() const
return sqrt(sum values[i]^2) (euclidian norm)
Definition: vector_impl.h:323
void destroy()
Definition: vector_impl.h:146
void create(size_t size)
create a vector with specific size
Definition: vector_impl.h:158
double dotprod(const Vector &w)
returns v.T w, that is the dotprod of this vector and w
Definition: vector_impl.h:72
value_type & operator[](size_t i)
access element i of the vector
Definition: vector_impl.h:47
void get(V &u) const
Definition: vector_impl.h:285
void reserve_exactly(size_t newCapacity, bool bCopyValues)
Definition: vector_impl.h:193
void resize(size_t newSize, bool bCopyValues=true)
Definition: vector.h:109
double operator=(double d)
assign double d to whole Vector
Definition: vector_impl.h:83
value_type * values
array where the values are stored, size m_size
Definition: vector.h:227
void p()
gdb shortcut for print
Definition: vector.h:187
Vector(const vector_type &v)
Definition: vector.h:72
Vector< TValueType > vector_type
Definition: vector.h:59
double maxnorm() const
return max values[i] (max norm)
Definition: vector_impl.h:332
size_t size() const
Definition: vector.h:181
size_t m_size
size of the vector (vector is from 0..size-1)
Definition: vector.h:225
SmartPtr< vector_type > clone_without_values() const
clones the vector (deep-copy) excluding values
Definition: vector_impl.h:187
void reserve(size_t newCapacity, bool bCopyValues=true)
Definition: vector.h:113
Vector()
constructor
Definition: vector_impl.h:127
double number
Definition: types.h:124
CPUAlgebra::vector_type vector_type
T value_type
Definition: sparsematrix_interface.h:2