Mantid
Loading...
Searching...
No Matches
GridDomain.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7//----------------------------------------------------------------------
8// Includes
9//----------------------------------------------------------------------
10#include <numeric>
11#include <stdexcept>
12
14#include "MantidKernel/Logger.h"
15
16namespace Mantid::API {
17namespace {
19Kernel::Logger g_log("GridDomain");
20} // namespace
21
23size_t GridDomain::size() const {
24 if (m_grids.empty())
25 return 0;
26 else
27 return std::accumulate(m_grids.begin(), m_grids.end(), size_t{1},
28 [](size_t n, const std::shared_ptr<GridDomain> &grid) { return n * grid->size(); });
29}
30
33 return std::accumulate(m_grids.begin(), m_grids.end(), size_t{0},
34 [](size_t n, std::shared_ptr<GridDomain> &grid) { return n + grid->nDimensions(); });
35}
36
37/* return item of member m_grids
38 * @param index the particular item of m_grids to return
39 */
42 try {
43 g = m_grids.at(index);
44 } catch (std::out_of_range &ex) {
45 g_log.error(ex.what());
46 }
47 return g;
48}
49
50void GridDomain::reScale(const std::string &scaling) {
51 for (auto &grid : m_grids)
52 grid->reScale(scaling);
53}
54
55} // namespace Mantid::API
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
size_t size() const override
number of grid points
Definition: GridDomain.cpp:23
size_t nDimensions()
number of dimensions in the grid
Definition: GridDomain.cpp:32
void reScale(const std::string &scaling)
re-scale all grids
Definition: GridDomain.cpp:50
std::shared_ptr< GridDomain > getGrid(size_t index)
get the grid at specified index
Definition: GridDomain.cpp:40
std::vector< std::shared_ptr< GridDomain > > m_grids
composition of grids
Definition: GridDomain.h:40
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
std::shared_ptr< GridDomain > GridDomain_sptr
typedef for a shared pointer
Definition: GridDomain.h:45
Kernel::Logger g_log("ExperimentInfo")
static logger object