Newer
Older
/***************************************************************************
-------------------
begin : Nov 8, 2012
copyright : (C) 2012 by Tomas Oberhuber
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
Jakub Klinkovský
committed
#pragma once
#include <TNL/Containers/Algorithms/PrefixSum.h>
#include <TNL/Containers/Algorithms/Reduction.h>
#include <TNL/Devices/Host.h>
#include <TNL/Devices/Cuda.h>
Jakub Klinkovský
committed
namespace Containers {
Jakub Klinkovský
committed
namespace Algorithms {
class VectorOperations< Devices::Host >
Jakub Klinkovský
committed
public:
template< typename Vector >
static void addElement( Vector& v,
const typename Vector::IndexType i,
const typename Vector::RealType& value );
template< typename Vector, typename Scalar >
static void addElement( Vector& v,
const typename Vector::IndexType i,
const typename Vector::RealType& value,
const Scalar thisElementMultiplicator );
template< typename Vector1, typename Vector2, typename Scalar1, typename Scalar2 >
static void addVector( Vector1& y,
Jakub Klinkovský
committed
const Vector2& x,
const Scalar1 alpha,
const Scalar2 thisMultiplicator = 1.0 );
Jakub Klinkovský
committed
template< typename Vector1, typename Vector2, typename Vector3, typename Scalar1, typename Scalar2, typename Scalar3 >
static void addVectors( Vector1& v,
const Vector2& v1,
const Vector3& v2,
const Scalar2 multiplicator2,
const Scalar3 thisMultiplicator = 1.0 );
template< typename Vector, typename ResultType = typename Vector::RealType >
static ResultType getVectorSum( const Vector& v );
template< Algorithms::PrefixSumType Type,
typename Vector >
static void prefixSum( Vector& v,
const typename Vector::IndexType begin,
const typename Vector::IndexType end );
template< Algorithms::PrefixSumType Type, typename Vector, typename Flags >
static void segmentedPrefixSum( Vector& v,
Flags& f,
const typename Vector::IndexType begin,
const typename Vector::IndexType end );
class VectorOperations< Devices::Cuda >
Jakub Klinkovský
committed
public:
template< typename Vector >
static void addElement( Vector& v,
const typename Vector::IndexType i,
const typename Vector::RealType& value );
template< typename Vector, typename Scalar >
static void addElement( Vector& v,
const typename Vector::IndexType i,
const typename Vector::RealType& value,
const Scalar thisElementMultiplicator );
template< typename Vector1, typename Vector2, typename Scalar1, typename Scalar2 >
static void addVector( Vector1& y,
const Vector2& x,
const Scalar1 alpha,
const Scalar2 thisMultiplicator = 1.0 );
Jakub Klinkovský
committed
template< typename Vector1, typename Vector2, typename Vector3, typename Scalar1, typename Scalar2, typename Scalar3 >
static void addVectors( Vector1& v,
const Vector2& v1,
const Vector3& v2,
const Scalar2 multiplicator2,
const Scalar3 thisMultiplicator = 1.0 );
template< typename Vector, typename ResultType = typename Vector::RealType >
static ResultType getVectorSum( const Vector& v );
template< Algorithms::PrefixSumType Type,
typename Vector >
static void prefixSum( Vector& v,
const typename Vector::IndexType begin,
const typename Vector::IndexType end );
template< Algorithms::PrefixSumType Type, typename Vector, typename Flags >
static void segmentedPrefixSum( Vector& v,
Flags& f,
const typename Vector::IndexType begin,
const typename Vector::IndexType end );

Vít Hanousek
committed
Jakub Klinkovský
committed
} // namespace Algorithms
#include <TNL/Containers/Algorithms/VectorOperationsHost_impl.h>
#include <TNL/Containers/Algorithms/VectorOperationsCuda_impl.h>