JointDomain.cpp 1.38 KB
Newer Older
1
2
3
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4
5
//   NScD Oak Ridge National Laboratory, European Spallation Source,
//   Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
8
9
10
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/JointDomain.h"
Hahn, Steven's avatar
Hahn, Steven committed
11
#include <numeric>
12

13
14
15
16
17
namespace Mantid {
namespace API {
/// Return the overall size the domain which is a sum of sizes of the
/// member domains.
size_t JointDomain::size() const {
Hahn, Steven's avatar
Hahn, Steven committed
18
19
20
21
  return std::accumulate(m_domains.begin(), m_domains.end(), size_t{0},
                         [](size_t n, const FunctionDomain_sptr &domain) {
                           return n + domain->size();
                         });
22
23
24
25
26
27
28
29
30
31
32
33
34
35
}
/// Return the number of parts in the domain
size_t JointDomain::getNParts() const { return m_domains.size(); }
/** Return i-th domain
 * @param i :: An index of a domain.
 */
const FunctionDomain &JointDomain::getDomain(size_t i) const {
  return *m_domains.at(i);
}

/**
 * Add a new domain.
 * @param domain :: A shared pointer to a domain.
 */
David Fairbrother's avatar
David Fairbrother committed
36
void JointDomain::addDomain(const FunctionDomain_sptr &domain) {
37
  m_domains.emplace_back(domain);
38
}
39

40
41
} // namespace API
} // namespace Mantid