"src/TNL/Functions/MeshFunction_impl.h" did not exist on "7398d2d0bc6d791433725cd499641db415c0bcfa"
Newer
Older
/***************************************************************************
EllpackIndexMultimapValues_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 */
#include "EllpackIndexMultimapValues.h"
#include <TNL/Assert.h>
typename Device,
typename LocalIndex >
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
EllpackIndexMultimapValues()
Jakub Klinkovský
committed
: values( nullptr ), allocatedSize( 0 )
typename Device,
typename LocalIndex >
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
Jakub Klinkovský
committed
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
EllpackIndexMultimapValues( ThisType&& other )
: values( other.values ), allocatedSize( other.allocatedSize )
{
other.values = nullptr;
other.allocatedSize = 0;
}
template< typename Index,
typename Device,
typename LocalIndex >
EllpackIndexMultimapValues< Index, Device, LocalIndex >&
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
operator=( const ThisType& other )
{
Assert( this->getSize() == other.getSize(), );
if( this->values != other.values ) {
for( LocalIndexType i = 0; i < this->getSize(); i++ )
this->setValue( i, other[ i ] );
}
return *this;
}
template< typename Index,
typename Device,
typename LocalIndex >
EllpackIndexMultimapValues< Index, Device, LocalIndex >&
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
operator=( ThisType&& other )
{
this->values = other.values;
this->allocatedSize = other.allocatedSize;
other.values = nullptr;
other.allocatedSize = 0;
return *this;
}
template< typename Index,
typename Device,
typename LocalIndex >
void
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
bind( const ThisType& other )
{
this->values = other.values;
this->allocatedSize = other.allocatedSize;
}
template< typename Index,
typename Device,
typename LocalIndex >
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
EllpackIndexMultimapValues( IndexType* values,
Jakub Klinkovský
committed
const LocalIndexType& allocatedSize )
{
this->values = &values[ input * ( allocatedSize + 1 ) ];
this->allocatedSize = allocatedSize;
}
template< typename Index,
typename Device,
typename LocalIndex >
bool
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
setSize( const LocalIndexType& size )
{
if( ! this->values || size > this->allocatedSize )
return false;
this->values[ this->allocatedSize ] = size;
return true;
}
template< typename Index,
typename Device,
typename LocalIndex >
LocalIndex
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
getSize() const
Jakub Klinkovský
committed
if( ! this->values )
return 0;
return this->values[ this->allocatedSize ];
typename Device,
typename LocalIndex >
LocalIndex
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
Jakub Klinkovský
committed
getAllocatedSize() const
Jakub Klinkovský
committed
return this->allocatedSize;
typename Device,
typename LocalIndex >
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
Jakub Klinkovský
committed
setValue( const LocalIndexType& portIndex,
const IndexType& value )
Jakub Klinkovský
committed
Assert( portIndex < this->getSize(),
std::cerr << " portIndex = " << portIndex
Jakub Klinkovský
committed
<< " getSize() = " << this->getSize()
Jakub Klinkovský
committed
this->values[ portIndex ] = value;
typename Device,
typename LocalIndex >
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
Jakub Klinkovský
committed
getValue( const LocalIndexType& portIndex ) const
Jakub Klinkovský
committed
Assert( portIndex < this->getSize(),
std::cerr << " portIndex = " << portIndex
Jakub Klinkovský
committed
<< " getSize() = " << this->getSize()
Jakub Klinkovský
committed
return this->values[ portIndex ];
typename Device,
typename LocalIndex >
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
operator[]( const LocalIndexType& portIndex )
Jakub Klinkovský
committed
Assert( portIndex < this->getSize(),
std::cerr << " portIndex = " << portIndex
Jakub Klinkovský
committed
<< " getSize() = " << this->getSize()
Jakub Klinkovský
committed
return this->values[ portIndex ];
typename Device,
typename LocalIndex >
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
operator[]( const LocalIndexType& portIndex ) const
Jakub Klinkovský
committed
Assert( portIndex < this->getSize(),
std::cerr << " portIndex = " << portIndex
Jakub Klinkovský
committed
<< " getSize() = " << this->getSize()
Jakub Klinkovský
committed
return this->values[ portIndex ];
Tomáš Oberhuber
committed
template< typename Index,
typename Device,
typename LocalIndex >
Tomáš Oberhuber
committed
void
EllpackIndexMultimapValues< Index, Device, LocalIndex >::
Tomáš Oberhuber
committed
print( std::ostream& str ) const
{
str << "[ ";
if( this->getSize() > 0 )
Tomáš Oberhuber
committed
{
for( typename std::remove_const< Index >::type i = 1; i < this->getSize(); i++ )
str << ", " << this->getValue( i );
Tomáš Oberhuber
committed
}
str << " ]";
}
template< typename Index,
typename Device,
typename LocalIndex >
std::ostream& operator << ( std::ostream& str, const EllpackIndexMultimapValues< Index, Device, LocalIndex >& ports )
Tomáš Oberhuber
committed
{
ports.print( str );
return str;
}