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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/***************************************************************************
StaticEllpackIndexMultimap_impl.h - description
-------------------
begin : Sep 9, 2015
copyright : (C) 2015 by Tomas Oberhuber et al.
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
#pragma once
#include <TNL/Experimental/Multimaps/StaticEllpackIndexMultimap.h>
namespace TNL {
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
StaticEllpackIndexMultimap()
: keysRange( 0 )
{
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
String
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
getType()
{
return String( "StaticEllpackIndexMultimap< ") +
String( TNL::getType< Index >() ) +
String( ", " ) +
Device :: getDeviceType() +
String( ", " ) +
String( TNL::getType< LocalIndexType >() ) +
String( " >" );
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
String
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
getTypeVirtual() const
{
return this->getType();
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
void
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
setKeysRange( const IndexType& keysRange )
{
Assert( keysRange >= 0, );
this->keysRange = keysRange;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
const Index
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
getKeysRange() const
{
return this->keysRange;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
bool
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
allocate()
{
return this->values.setSize( this->keysRange * ValuesCount );
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
typename StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::ValuesAccessorType
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
getValues( const IndexType& inputIndex )
{
Assert( inputIndex < this->getKeysRange(), );
return ValuesAccessorType( this->values.getData(), inputIndex );
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
typename StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::ConstValuesAccessorType
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
getValues( const IndexType& inputIndex ) const
{
Assert( inputIndex < this->getKeysRange(), );
return ConstValuesAccessorType( this->values.getData(), inputIndex );
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
bool
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
operator==( const StaticEllpackIndexMultimap& other ) const
{
return ( this->keysRange == other.keysRange && this->values == other.values );
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
bool
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
save( File& file ) const
{
if( ! Object::save( file ) )
return false;
if( ! file.write( &this->keysRange ) )
return false;
if( ! this->values.save( file ) )
return false;
return true;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
bool
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
load( File& file )
{
if( ! Object::load( file ) )
return false;
if( ! file.read( &this->keysRange ) )
return false;
if( ! this->values.load( file ) )
return false;
return true;
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
void
StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >::
print( std::ostream& str ) const
{
str << "[ ";
if( this->getKeysRange() > 0 )
{
str << this->getValues( 0 );
for( Index i = 1; i < this->getKeysRange(); i++ )
str << ",\n " << this->getValues( i );
}
str << " ]";
}
template< int ValuesCount,
typename Index,
typename Device,
typename LocalIndex >
std::ostream& operator << ( std::ostream& str, const StaticEllpackIndexMultimap< ValuesCount, Index, Device, LocalIndex >& multimap )
{
multimap.print( str );
return str;
}
} // namespace TNL