Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
vector_interface.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2015: G-CSC, Goethe University Frankfurt
3 * Author: Martin Rupp
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef VECTOR_INTERFACE_H_
34#define VECTOR_INTERFACE_H_
35
36template <typename TValueType>
37class Vector
38{
39public:
40 typedef TValueType value_type;
41 //typedef subvector<value_type> subvector_type;
43 typedef size_t size_type;
44
45public:
48
50 Vector(size_t _length);
51
54
55 Vector(const vector_type & v);
56
57public:
59 bool resize(size_t new_length, bool bCopyValues=true);
60
62 inline value_type &operator [] (size_t i);
63 inline const value_type &operator [] (size_t i) const;
64
73 template <typename V> bool add(const V& u);
74 template <typename V> bool set(const V& u);
75 template <typename V> bool get(V& u) const;
76
77
79 double dotprod(const Vector &w); //const;
80
81
82 //double energynorm2(const SparseMatrix &A) const;
83 /*double energynorm(const SparseMatrix &A) const
84 {
85 return sqrt(energynorm2(A));
86 }*/
87
89 double operator = (double d);
91 bool set(double d);
92 bool set_random(double from, double to);
93
94
96 void operator = (const Vector &v);
97 void operator += (const Vector &v);
98 void operator -= (const Vector &v);
99
100 bool operator *= (const number &a);
101
103 inline double norm() const;
104
105 size_t size();
107
108public:
109 /*size_t begin_index() { return 0;}
110 size_t end_index() { return size();}
111
112 value_type *begin() { return values + begin_index(); }
113 value_type *end() { return values + end_index(); }*/
114};
115
116template<typename TValueType>
118{
119 // clone stuff like
120 dest.resize(src.size());
121}
122
123#endif /* VECTOR_INTERFACE_H_ */
Definition vector_interface.h:38
bool set_random(double from, double to)
Vector(size_t _length)
constructor with length
bool set(const V &u)
bool operator*=(const number &a)
value_type & operator[](size_t i)
access element i of the vector
bool add(const V &u)
bool get(V &u) const
void defragment()
double norm() const
return sqrt(sum values[i]^2) (euclidian norm)
bool set(double d)
assign double d to whole Vector
bool resize(size_t new_length, bool bCopyValues=true)
resize vector
~Vector()
destructor
void operator-=(const Vector &v)
void operator+=(const Vector &v)
TValueType value_type
Definition vector_interface.h:40
Vector()
constructor
Vector< TValueType > vector_type
Definition vector_interface.h:42
Vector(const vector_type &v)
size_t size_type
Definition vector_interface.h:43
double dotprod(const Vector &w)
returns v.T w, that is the dotprod of this vector and w
size_t size()
double operator=(double d)
assign double d to whole Vector
double number
Definition types.h:124
bool CloneVector(Vector< TValueType > &dest, const Vector< TValueType > src)
Definition vector_interface.h:117