From 11fc5ef04b1a4db1374bcb005c5bc1a12bec4e71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz>
Date: Tue, 6 Aug 2019 20:04:15 +0200
Subject: [PATCH] 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.
---
 .../Containers/Algorithms/VectorOperations.h  | 22 ------------
 .../Algorithms/VectorOperationsCuda_impl.h    | 21 ------------
 .../Algorithms/VectorOperationsHost_impl.h    | 21 ------------
 src/TNL/Containers/DistributedVector.h        |  8 -----
 src/TNL/Containers/DistributedVector.hpp      | 34 -------------------
 src/TNL/Containers/DistributedVectorView.h    |  8 -----
 src/TNL/Containers/DistributedVectorView.hpp  | 34 -------------------
 src/TNL/Containers/Vector.h                   | 21 ------------
 src/TNL/Containers/Vector.hpp                 | 26 --------------
 src/TNL/Containers/VectorView.h               | 10 ------
 src/TNL/Containers/VectorView.hpp             | 21 ------------
 11 files changed, 226 deletions(-)

diff --git a/src/TNL/Containers/Algorithms/VectorOperations.h b/src/TNL/Containers/Algorithms/VectorOperations.h
index 3a71dc720e..9487518423 100644
--- a/src/TNL/Containers/Algorithms/VectorOperations.h
+++ b/src/TNL/Containers/Algorithms/VectorOperations.h
@@ -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 );
 
diff --git a/src/TNL/Containers/Algorithms/VectorOperationsCuda_impl.h b/src/TNL/Containers/Algorithms/VectorOperationsCuda_impl.h
index b4c1b61a25..0deea8196f 100644
--- a/src/TNL/Containers/Algorithms/VectorOperationsCuda_impl.h
+++ b/src/TNL/Containers/Algorithms/VectorOperationsCuda_impl.h
@@ -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 >::
diff --git a/src/TNL/Containers/Algorithms/VectorOperationsHost_impl.h b/src/TNL/Containers/Algorithms/VectorOperationsHost_impl.h
index 81c978f32d..286e4f7b75 100644
--- a/src/TNL/Containers/Algorithms/VectorOperationsHost_impl.h
+++ b/src/TNL/Containers/Algorithms/VectorOperationsHost_impl.h
@@ -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 >::
diff --git a/src/TNL/Containers/DistributedVector.h b/src/TNL/Containers/DistributedVector.h
index 9a9f107a27..7ac6733d7f 100644
--- a/src/TNL/Containers/DistributedVector.h
+++ b/src/TNL/Containers/DistributedVector.h
@@ -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 > >
diff --git a/src/TNL/Containers/DistributedVector.hpp b/src/TNL/Containers/DistributedVector.hpp
index 45a6faef7d..f09a5a2f1e 100644
--- a/src/TNL/Containers/DistributedVector.hpp
+++ b/src/TNL/Containers/DistributedVector.hpp
@@ -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,
diff --git a/src/TNL/Containers/DistributedVectorView.h b/src/TNL/Containers/DistributedVectorView.h
index f696a3e560..649d0fa57e 100644
--- a/src/TNL/Containers/DistributedVectorView.h
+++ b/src/TNL/Containers/DistributedVectorView.h
@@ -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 > >
diff --git a/src/TNL/Containers/DistributedVectorView.hpp b/src/TNL/Containers/DistributedVectorView.hpp
index 7afaee2761..6da3389c84 100644
--- a/src/TNL/Containers/DistributedVectorView.hpp
+++ b/src/TNL/Containers/DistributedVectorView.hpp
@@ -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,
diff --git a/src/TNL/Containers/Vector.h b/src/TNL/Containers/Vector.h
index e02c9adb5b..e75730a48f 100644
--- a/src/TNL/Containers/Vector.h
+++ b/src/TNL/Containers/Vector.h
@@ -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.
     */
diff --git a/src/TNL/Containers/Vector.hpp b/src/TNL/Containers/Vector.hpp
index dcaf8f2d59..1c58209fbf 100644
--- a/src/TNL/Containers/Vector.hpp
+++ b/src/TNL/Containers/Vector.hpp
@@ -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,
diff --git a/src/TNL/Containers/VectorView.h b/src/TNL/Containers/VectorView.h
index 8819c59eb5..9ccbb7a02e 100644
--- a/src/TNL/Containers/VectorView.h
+++ b/src/TNL/Containers/VectorView.h
@@ -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 > >
diff --git a/src/TNL/Containers/VectorView.hpp b/src/TNL/Containers/VectorView.hpp
index 49580d5c94..2d72e74f4e 100644
--- a/src/TNL/Containers/VectorView.hpp
+++ b/src/TNL/Containers/VectorView.hpp
@@ -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 >
-- 
GitLab