DivideBy.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Defines function divide_by
6 
7 #pragma once
8 
9 #include "DataStructures/DataVector.hpp"
11 
12 /*!
13  * \ingroup TensorGroup
14  * \brief Divides the components of a tensor by a scalar
15  *
16  * \returns a tensor of the same type as the input tensor
17  */
18 template <typename TensorType>
19 TensorType divide_by(TensorType tensor, const DataVector& divisor) {
20  ASSERT(tensor.get(0).size() == divisor.size(),
21  "The DataVectors in `tensor` and `divisor` do not have the same size");
22  for (auto& component : tensor) {
23  component /= divisor;
24  }
25  return tensor;
26 }
TensorType divide_by(TensorType tensor, const DataVector &divisor)
Divides the components of a tensor by a scalar.
Definition: DivideBy.hpp:19
#define ASSERT(a, m)
Assert that an expression should be true.
Definition: Assert.hpp:49
Defines classes for Tensor.
Stores a collection of function values.
Definition: DataVector.hpp:46