Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/***************************************************************************
StaticEllpackIndexMultimapValues_impl.h - description
-------------------
begin : Sep 10, 2015
copyright : (C) 2015 by Tomas Oberhuber et al.
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
#pragma once
#include "StaticEllpackIndexMultimapValues.h"
#include <TNL/Assert.h>
namespace TNL {
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
StaticEllpackIndexMultimapValues()
: values( nullptr )
{
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
StaticEllpackIndexMultimapValues( StaticEllpackIndexMultimapValues&& other )
: values( other.values )
{
other.values = nullptr;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >&
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
operator=( const StaticEllpackIndexMultimapValues& other )
{
if( this->values != other.values ) {
for( LocalIndexType i = 0; i < this->getSize(); i++ )
this->setValue( i, other[ i ] );
}
return *this;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >&
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
operator=( StaticEllpackIndexMultimapValues&& other )
{
this->values = other.values;
other.values = nullptr;
return *this;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
void
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
bind( const StaticEllpackIndexMultimapValues& other )
{
this->values = other.values;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
StaticEllpackIndexMultimapValues( IndexType* values,
const IndexType& input )
{
this->values = &values[ input * ValuesCount ];
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
constexpr LocalIndex
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
getSize() const
{
return ValuesCount;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
constexpr LocalIndex
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
getAllocatedSize() const
{
return ValuesCount;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
void
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
setValue( const LocalIndexType& portIndex,
const IndexType& value )
{
TNL_ASSERT( this->values,
std::cerr << "This instance is not bound to any multimap." << std::endl; );
TNL_ASSERT( portIndex < this->getSize(),
std::cerr << " portIndex = " << portIndex
<< " getSize() = " << this->getSize()
<< std::endl );
this->values[ portIndex ] = value;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
Index
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
getValue( const LocalIndexType& portIndex ) const
{
TNL_ASSERT( this->values,
std::cerr << "This instance is not bound to any multimap." << std::endl; );
TNL_ASSERT( portIndex < this->getSize(),
std::cerr << " portIndex = " << portIndex
<< " getSize() = " << this->getSize()
<< std::endl );
return this->values[ portIndex ];
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
Index&
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
operator[]( const LocalIndexType& portIndex )
{
TNL_ASSERT( this->values,
std::cerr << "This instance is not bound to any multimap." << std::endl; );
TNL_ASSERT( portIndex < this->getSize(),
std::cerr << " portIndex = " << portIndex
<< " getSize() = " << this->getSize()
<< std::endl );
return this->values[ portIndex ];
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
const Index&
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
operator[]( const LocalIndexType& portIndex ) const
{
TNL_ASSERT( this->values,
std::cerr << "This instance is not bound to any multimap." << std::endl; );
TNL_ASSERT( portIndex < this->getSize(),
std::cerr << " portIndex = " << portIndex
<< " getSize() = " << this->getSize()
<< std::endl );
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
return this->values[ portIndex ];
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
bool
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
operator==( const StaticEllpackIndexMultimapValues& other ) const
{
if( this->values == other.values )
return true;
if( ! this->values || ! other.values )
return false;
for( LocalIndexType i = 0; i < this->getSize(); i++ )
if( this->operator[]( i ) != other[ i ] )
return false;
return true;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
bool
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
operator!=( const StaticEllpackIndexMultimapValues& other ) const
{
return ! ( *this == other );
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
void
StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >::
print( std::ostream& str ) const
{
str << "[ ";
if( this->getSize() > 0 )
{
str << this->getValue( 0 );
for( typename std::remove_const< Index >::type i = 1; i < this->getSize(); i++ )
str << ", " << this->getValue( i );
}
str << " ]";
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
std::ostream& operator << ( std::ostream& str, const StaticEllpackIndexMultimapValues< ValuesCount, Index, Device, LocalIndex >& ports )
{
ports.print( str );
return str;
}
} // namespace TNL