Newer
Older
Jakub Klinkovský
committed
/***************************************************************************
VectorView_impl.h - description
-------------------
begin : Sep 1, 2018
copyright : (C) 2018 by Tomas Oberhuber et al.
email : tomas.oberhuber@fjfi.cvut.cz
Jakub Klinkovský
committed
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
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
#pragma once
#include <TNL/Containers/VectorView.h>
#include <TNL/Containers/Algorithms/VectorOperations.h>
namespace TNL {
namespace Containers {
template< typename Real,
typename Device,
typename Index >
String
VectorView< Real, Device, Index >::
getType()
{
return String( "Containers::VectorView< " ) +
TNL::getType< Real >() + ", " +
Device::getDeviceType() + ", " +
TNL::getType< Index >() + " >";
}
template< typename Real,
typename Device,
typename Index >
void
VectorView< Real, Device, Index >::
addElement( IndexType i, RealType value )
{
Algorithms::VectorOperations< Device >::addElement( *this, i, value );
}
template< typename Real,
typename Device,
typename Index >
void
VectorView< Real, Device, Index >::
addElement( IndexType i, RealType value, RealType thisElementMultiplicator )
{
Algorithms::VectorOperations< Device >::addElement( *this, i, value, thisElementMultiplicator );
}
template< typename Real,
typename Device,
typename Index >
template< typename Vector >
VectorView< Real, Device, Index >&
VectorView< Real, Device, Index >::
operator-=( const Vector& vector )
{
addVector( vector, -1.0 );
return *this;
}
template< typename Real,
typename Device,
typename Index >
template< typename Vector >
VectorView< Real, Device, Index >&
VectorView< Real, Device, Index >::
operator+=( const Vector& vector )
{
addVector( vector );
return *this;
}
template< typename Real,
typename Device,
typename Index >
VectorView< Real, Device, Index >&
VectorView< Real, Device, Index >::
operator*=( RealType c )
{
Algorithms::VectorOperations< Device >::vectorScalarMultiplication( *this, c );
return *this;
}
template< typename Real,
typename Device,
typename Index >
VectorView< Real, Device, Index >&
VectorView< Real, Device, Index >::
operator/=( RealType c )
{
Algorithms::VectorOperations< Device >::vectorScalarMultiplication( *this, 1.0 / c );
return *this;
}
template< typename Real,
typename Device,
typename Index >
Jakub Klinkovský
committed
typename VectorView< Real, Device, Index >::NonConstReal
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
max() const
{
Jakub Klinkovský
committed
return Algorithms::VectorOperations< Device >::template getVectorMax< VectorView, NonConstReal >( *this );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
Jakub Klinkovský
committed
typename VectorView< Real, Device, Index >::NonConstReal
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
min() const
{
Jakub Klinkovský
committed
return Algorithms::VectorOperations< Device >::template getVectorMin< VectorView, NonConstReal >( *this );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
Jakub Klinkovský
committed
typename VectorView< Real, Device, Index >::NonConstReal
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
absMax() const
{
Jakub Klinkovský
committed
return Algorithms::VectorOperations< Device >::template getVectorAbsMax< VectorView, NonConstReal >( *this );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
Jakub Klinkovský
committed
typename VectorView< Real, Device, Index >::NonConstReal
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
absMin() const
{
Jakub Klinkovský
committed
return Algorithms::VectorOperations< Device >::template getVectorAbsMin< VectorView, NonConstReal >( *this );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
template< typename ResultType, typename Real_ >
ResultType
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
Jakub Klinkovský
committed
{
return Algorithms::VectorOperations< Device >::template getVectorLpNorm< VectorView, ResultType >( *this, p );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
template< typename ResultType >
ResultType
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
sum() const
{
return Algorithms::VectorOperations< Device >::template getVectorSum< VectorView, ResultType >( *this );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
template< typename Vector >
Jakub Klinkovský
committed
typename VectorView< Real, Device, Index >::NonConstReal
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
differenceMax( const Vector& v ) const
{
Jakub Klinkovský
committed
return Algorithms::VectorOperations< Device >::template getVectorDifferenceMax< VectorView, Vector, NonConstReal >( *this, v );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
template< typename Vector >
Jakub Klinkovský
committed
typename VectorView< Real, Device, Index >::NonConstReal
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::differenceMin( const Vector& v ) const
{
Jakub Klinkovský
committed
return Algorithms::VectorOperations< Device >::template getVectorDifferenceMin< VectorView, Vector, NonConstReal >( *this, v );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
template< typename Vector >
Jakub Klinkovský
committed
typename VectorView< Real, Device, Index >::NonConstReal
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
differenceAbsMax( const Vector& v ) const
{
Jakub Klinkovský
committed
return Algorithms::VectorOperations< Device >::template getVectorDifferenceAbsMax< VectorView, Vector, NonConstReal >( *this, v );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
Jakub Klinkovský
committed
template< typename Vector >
typename VectorView< Real, Device, Index >::NonConstReal
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
differenceAbsMin( const Vector& v ) const
{
Jakub Klinkovský
committed
return Algorithms::VectorOperations< Device >::template getVectorDifferenceAbsMin< VectorView, Vector, NonConstReal >( *this, v );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
template< typename ResultType, typename Vector, typename Real_ >
ResultType
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
differenceLpNorm( const Vector& v, const Real_ p ) const
Jakub Klinkovský
committed
{
return Algorithms::VectorOperations< Device >::template getVectorDifferenceLpNorm< VectorView, Vector, ResultType >( *this, v, p );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
template< typename ResultType, typename Vector >
ResultType
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
differenceSum( const Vector& v ) const
{
return Algorithms::VectorOperations< Device >::template getVectorDifferenceSum< VectorView, Vector, ResultType >( *this, v );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
void
VectorView< Real, Device, Index >::
scalarMultiplication( Real alpha )
{
Algorithms::VectorOperations< Device >::vectorScalarMultiplication( *this, alpha );
}
template< typename Real,
typename Device,
typename Index >
Jakub Klinkovský
committed
template< typename Vector >
typename VectorView< Real, Device, Index >::NonConstReal
Jakub Klinkovský
committed
VectorView< Real, Device, Index >::
scalarProduct( const Vector& v ) const
Jakub Klinkovský
committed
{
Jakub Klinkovský
committed
return Algorithms::VectorOperations< Device >::template getScalarProduct< VectorView, Vector, NonConstReal >( *this, v );
Jakub Klinkovský
committed
}
template< typename Real,
typename Device,
typename Index >
Jakub Klinkovský
committed
template< typename Vector >
Jakub Klinkovský
committed
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
void
VectorView< Real, Device, Index >::
addVector( const Vector& x, Real alpha, Real thisMultiplicator )
{
Algorithms::VectorOperations< Device >::addVector( *this, x, alpha, thisMultiplicator );
}
template< typename Real,
typename Device,
typename Index >
template< typename Vector >
void
VectorView< Real, Device, Index >::
addVectors( const Vector& v1,
Real multiplicator1,
const Vector& v2,
Real multiplicator2,
Real thisMultiplicator )
{
Algorithms::VectorOperations< Device >::addVectors( *this, v1, multiplicator1, v2, multiplicator2, thisMultiplicator );
}
template< typename Real,
typename Device,
typename Index >
void
VectorView< Real, Device, Index >::
computePrefixSum()
{
Algorithms::VectorOperations< Device >::computePrefixSum( *this, 0, this->getSize() );
}
template< typename Real,
typename Device,
typename Index >
void
VectorView< Real, Device, Index >::
computePrefixSum( IndexType begin, IndexType end )
{
Algorithms::VectorOperations< Device >::computePrefixSum( *this, begin, end );
}
template< typename Real,
typename Device,
typename Index >
void
VectorView< Real, Device, Index >::
computeExclusivePrefixSum()
{
Algorithms::VectorOperations< Device >::computeExclusivePrefixSum( *this, 0, this->getSize() );
}
template< typename Real,
typename Device,
typename Index >
void
VectorView< Real, Device, Index >::
computeExclusivePrefixSum( IndexType begin, IndexType end )
{
Algorithms::VectorOperations< Device >::computeExclusivePrefixSum( *this, begin, end );
}
} // namespace Containers
} // namespace TNL