Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TensorDefs.hh
Go to the documentation of this file.
1 #pragma clang diagnostic push
2 #pragma clang diagnostic ignored "-Wdocumentation-unknown-command"
3 ///
4 /// @file TensorDefs.hh
5 /// @brief Hammer tensor class template methods definitions
6 ///
7 #pragma clang diagnostic pop
8 
9 //**** This file is a part of the HAMMER library
10 //**** Copyright (C) 2016 - 2020 The HAMMER Collaboration
11 //**** HAMMER is licensed under version 3 of the GPL; see COPYING for details
12 //**** Please note the MCnet academic guidelines; see GUIDELINES for details
13 
14 // -*- C++ -*-
15 
16 #include "Hammer/Exceptions.hh"
17 #include "Hammer/Tools/Logging.hh"
18 
19 namespace Hammer {
20 
21  template <typename... Args>
22  void Tensor::setValue(std::complex<double> elem, Args... rest) {
23  try {
24  element({static_cast<IndexType>(rest)...}) = elem;
25  } catch (RangeError& e) {
26  MSG_ERROR(std::string("Error setting element: ") + e.what() + std::string(" Element not set."));
27  }
28  }
29 
30  template <typename... Args>
31  std::complex<double> Tensor::value(Args... rest) const {
32  return element({static_cast<IndexType>(rest)...});
33  }
34 
35 
36 } // namespace Hammer
std::complex< double > & element(const IndexList &indices={})
access an element given its indices
Definition: Tensor.cc:67
Message logging routines.
uint16_t IndexType
std::complex< double > value(Args...rest) const
returns the value of a specific tensor element
Definition: TensorDefs.hh:31
Hammer exception definitions.
void setValue(std::complex< double > value, Args...rest)
set the value of a specific tensor element
Definition: TensorDefs.hh:22
#define MSG_ERROR(x)
Definition: Logging.hh:367
Out-of-range error class.
Definition: Exceptions.hh:49