Skip to content
Snippets Groups Projects
Commit 11fc5ef0 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Removed unused addElement method from all vector types

It is very slow and unnecessary - the user can easily use operator[] or
getElement and setElement for any operation with a single element, not
just addition.
parent c3b7c004
No related branches found
No related tags found
1 merge request!36Fixed expression templates
......@@ -26,17 +26,6 @@ template<>
class VectorOperations< Devices::Host >
{
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 Vector, typename ResultType = typename Vector::RealType >
static ResultType getVectorSum( const Vector& v );
......@@ -57,17 +46,6 @@ template<>
class VectorOperations< Devices::Cuda >
{
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 Vector, typename ResultType = typename Vector::RealType >
static ResultType getVectorSum( const Vector& v );
......
......@@ -18,27 +18,6 @@ namespace TNL {
namespace Containers {
namespace Algorithms {
template< typename Vector >
void
VectorOperations< Devices::Cuda >::
addElement( Vector& v,
const typename Vector::IndexType i,
const typename Vector::RealType& value )
{
v[ i ] += value;
}
template< typename Vector, typename Scalar >
void
VectorOperations< Devices::Cuda >::
addElement( Vector& v,
const typename Vector::IndexType i,
const typename Vector::RealType& value,
const Scalar thisElementMultiplicator )
{
v[ i ] = thisElementMultiplicator * v[ i ] + value;
}
template< typename Vector, typename ResultType >
ResultType
VectorOperations< Devices::Cuda >::
......
......@@ -17,27 +17,6 @@ namespace TNL {
namespace Containers {
namespace Algorithms {
template< typename Vector >
void
VectorOperations< Devices::Host >::
addElement( Vector& v,
const typename Vector::IndexType i,
const typename Vector::RealType& value )
{
v[ i ] += value;
}
template< typename Vector, typename Scalar >
void
VectorOperations< Devices::Host >::
addElement( Vector& v,
const typename Vector::IndexType i,
const typename Vector::RealType& value,
const Scalar thisElementMultiplicator )
{
v[ i ] = thisElementMultiplicator * v[ i ] + value;
}
template< typename Vector, typename ResultType >
ResultType
VectorOperations< Devices::Host >::
......
......@@ -77,14 +77,6 @@ public:
/*
* Usual Vector methods follow below.
*/
void addElement( IndexType i,
RealType value );
template< typename Scalar >
void addElement( IndexType i,
RealType value,
Scalar thisElementMultiplicator );
template< typename Scalar,
typename...,
typename = std::enable_if_t< ! HasSubscriptOperator<Scalar>::value > >
......
......@@ -116,40 +116,6 @@ getTypeVirtual() const
* Usual Vector methods follow below.
*/
template< typename Real,
typename Device,
typename Index,
typename Communicator >
void
DistributedVector< Real, Device, Index, Communicator >::
addElement( IndexType i,
RealType value )
{
if( this->getCommunicationGroup() != CommunicatorType::NullGroup ) {
const IndexType li = this->getLocalRange().getLocalIndex( i );
LocalViewType view = getLocalView();
view.addElement( li, value );
}
}
template< typename Real,
typename Device,
typename Index,
typename Communicator >
template< typename Scalar >
void
DistributedVector< Real, Device, Index, Communicator >::
addElement( IndexType i,
RealType value,
Scalar thisElementMultiplicator )
{
if( this->getCommunicationGroup() != CommunicatorType::NullGroup ) {
const IndexType li = this->getLocalRange().getLocalIndex( i );
LocalViewType view = getLocalView();
view.addElement( li, value, thisElementMultiplicator );
}
}
template< typename Real,
typename Device,
typename Index,
......
......@@ -77,14 +77,6 @@ public:
/*
* Usual Vector methods follow below.
*/
void addElement( IndexType i,
RealType value );
template< typename Scalar >
void addElement( IndexType i,
RealType value,
Scalar thisElementMultiplicator );
template< typename Scalar,
typename...,
typename = std::enable_if_t< ! HasSubscriptOperator<Scalar>::value > >
......
......@@ -86,40 +86,6 @@ getType()
* Usual Vector methods follow below.
*/
template< typename Real,
typename Device,
typename Index,
typename Communicator >
void
DistributedVectorView< Real, Device, Index, Communicator >::
addElement( IndexType i,
RealType value )
{
if( this->getCommunicationGroup() != CommunicatorType::NullGroup ) {
const IndexType li = this->getLocalRange().getLocalIndex( i );
LocalViewType view = getLocalView();
view.addElement( li, value );
}
}
template< typename Real,
typename Device,
typename Index,
typename Communicator >
template< typename Scalar >
void
DistributedVectorView< Real, Device, Index, Communicator >::
addElement( IndexType i,
RealType value,
Scalar thisElementMultiplicator )
{
if( this->getCommunicationGroup() != CommunicatorType::NullGroup ) {
const IndexType li = this->getLocalRange().getLocalIndex( i );
LocalViewType view = getLocalView();
view.addElement( li, value, thisElementMultiplicator );
}
}
template< typename Real,
typename Device,
typename Index,
......
......@@ -112,27 +112,6 @@ public:
*/
operator ConstViewType() const;
/**
* \brief Adds another element to this vector.
*
* New element has index type \e i and reference to its real type \e value.
*/
[[deprecated("useless method - use getElement and setElement")]]
void addElement( const IndexType i,
const RealType& value );
/**
* \brief Adds another element with multiplicator to this vector.
*
* New element has index type \e i and reference to its real type \e value
* multiplied by \e thisElementMultiplicator.
*/
template< typename Scalar >
[[deprecated("useless method - use getElement and setElement")]]
void addElement( const IndexType i,
const RealType& value,
const Scalar thisElementMultiplicator );
/**
* \brief Assigns a vector expression to this vector.
*/
......
......@@ -98,32 +98,6 @@ operator ConstViewType() const
return getConstView();
}
template< typename Real,
typename Device,
typename Index,
typename Allocator >
void
Vector< Real, Device, Index, Allocator >::
addElement( const IndexType i,
const RealType& value )
{
Algorithms::VectorOperations< Device >::addElement( *this, i, value );
}
template< typename Real,
typename Device,
typename Index,
typename Allocator >
template< typename Scalar >
void
Vector< Real, Device, Index, Allocator >::
addElement( const IndexType i,
const RealType& value,
const Scalar thisElementMultiplicator )
{
Algorithms::VectorOperations< Device >::addElement( *this, i, value, thisElementMultiplicator );
}
template< typename Real,
typename Device,
typename Index,
......
......@@ -84,16 +84,6 @@ public:
static String getType();
// All other Vector methods follow...
[[deprecated("useless method - use getElement and setElement")]]
void addElement( IndexType i, RealType value );
template< typename Scalar >
[[deprecated("useless method - use getElement and setElement")]]
void addElement( IndexType i,
RealType value,
Scalar thisElementMultiplicator );
template< typename VectorExpression,
typename...,
typename = std::enable_if_t< Expressions::IsExpressionTemplate< VectorExpression >::value > >
......
......@@ -58,27 +58,6 @@ getType()
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 >
template< typename Scalar >
void
VectorView< Real, Device, Index >::
addElement( IndexType i, RealType value, Scalar thisElementMultiplicator )
{
Algorithms::VectorOperations< Device >::addElement( *this, i, value, thisElementMultiplicator );
}
template< typename Real,
typename Device,
typename Index >
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment