Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
reservable_array.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
34#ifndef __H__UG__COMMON__VARIABLE_ARRAY_H__
35#define __H__UG__COMMON__VARIABLE_ARRAY_H__
36
37#include "storage.h"
38#include <iostream>
39#include <cassert>
40
41namespace ug{
42
44// ReservableArray2
52template<typename T, eMatrixOrdering T_ordering=ColMajor>
54{
55public:
56 typedef T value_type;
57 typedef size_t size_type;
58 static const eMatrixOrdering ordering = T_ordering;
59 enum { is_static=false };
60 enum { static_num_rows=0};
61 enum { static_num_cols=0};
63
64public:
68
69//protected:
70 // see Alexandrescu: non-virtual destructors should be protected
72
73public:
74 // Capacity
75 inline size_type
76 num_rows() const;
77
78 inline size_type
79 num_cols() const;
80
81 inline bool
82 resize(size_type newRows, size_type newCols, bool bCopyValues=true);
83
84 inline size_type
85 capacity_num_rows() const { return rows; }
86
87 inline size_type
88 capacity_num_cols() const { return cols; };
89
90 inline bool
91 reserve(size_type nrRows, size_type nrCols) const { return; }
92
93 // Element Access
94
95 inline const T &
97 {
98 // todo: if(r >= rows || c >= cols) throw
99 return operator()(r, c);
100 }
101
102 inline T &
104 {
105 // todo: if(r >= rows || c >= cols) throw
106 return operator()(r, c);
107 }
108
109 inline const T &
110 operator()(size_type r, size_type c) const ;
111
112 inline T &
114
115 // output
116
117 template<typename _T, eMatrixOrdering _T_Ordering>
118 friend std::ostream &operator << (std::ostream &out, const ReservableArray2<_T, _T_Ordering> &arr);
119
120protected:
125};
126
127}
128
129#include "variable_array_impl.h"
130
131#endif // #define __H__UG__COMMON__VARIABLE_ARRAY_H__
Definition reservable_array.h:54
size_type capacity_num_cols() const
Definition reservable_array.h:88
T * values
Definition reservable_array.h:121
~ReservableArray2()
Definition reservable_array_impl.h:82
bool reserve(size_type nrRows, size_type nrCols) const
Definition reservable_array.h:91
@ is_static
Definition reservable_array.h:59
friend std::ostream & operator<<(std::ostream &out, const ReservableArray2< _T, _T_Ordering > &arr)
ReservableArray2()
Definition reservable_array_impl.h:49
variable_type storage_type
Definition reservable_array.h:62
size_type rows
Definition reservable_array.h:122
@ static_num_cols
Definition reservable_array.h:61
size_type arraySize
Definition reservable_array.h:124
static const eMatrixOrdering ordering
Definition reservable_array.h:58
T value_type
Definition reservable_array.h:56
const T & operator()(size_type r, size_type c) const
Definition reservable_array_impl.h:226
size_type num_rows() const
Definition reservable_array_impl.h:92
const T & at(size_type r, size_type c) const
Definition reservable_array.h:96
T & at(size_type r, size_type c)
Definition reservable_array.h:103
size_type num_cols() const
Definition reservable_array_impl.h:99
@ static_num_rows
Definition reservable_array.h:60
ReservableArray2(const VariableArray2< T, T_ordering > &other)
size_type capacity_num_rows() const
Definition reservable_array.h:85
size_t size_type
Definition reservable_array.h:57
size_type cols
Definition reservable_array.h:123
bool resize(size_type newRows, size_type newCols, bool bCopyValues=true)
Definition reservable_array_impl.h:107
Definition variable_array.h:139
the ug namespace
eMatrixOrdering
Definition storage.h:47
Definition storage.h:64