Mantid
Loading...
Searching...
No Matches
MultiDomainFunction.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2009 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#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
13
14#include <map>
15
16namespace Mantid {
17namespace API {
18class CompositeDomain;
28class MANTID_API_DLL MultiDomainFunction : public CompositeFunction {
29public:
32
34 std::string name() const override { return "MultiDomainFunction"; }
39 void function(const FunctionDomain &domain, FunctionValues &values) const override;
41 void functionDeriv(const FunctionDomain &domain, Jacobian &jacobian) override;
43 void iterationStarting() override;
45 void iterationFinished() override;
46
48 void setDomainIndex(size_t funIndex, size_t domainIndex);
50 void setDomainIndices(size_t funIndex, const std::vector<size_t> &domainIndices);
52 void clearDomainIndices();
54 size_t getMaxIndex() const { return m_maxIndex; }
56 void getDomainIndices(size_t funIndex, size_t nDomains, std::vector<size_t> &domains) const;
58 size_t getNumberDomains() const override;
60 std::vector<IFunction_sptr> createEquivalentFunctions() const override;
61
66 size_t nLocalAttributes() const override { return 1; }
68 std::vector<std::string> getLocalAttributeNames() const override { return std::vector<std::string>(1, "domains"); }
70 Attribute getLocalAttribute(size_t funIndex, const std::string &attName) const override;
72 void setLocalAttribute(size_t funIndex, const std::string &attName, const Attribute &) override;
74 bool hasLocalAttribute(const std::string &attName) const override { return attName == "domains"; }
75
76protected:
78 void countNumberOfDomains();
79 void countValueOffsets(const CompositeDomain &domain) const;
80
82 std::map<size_t, std::vector<size_t>> m_domains;
85 size_t m_nDomains;
87 size_t m_maxIndex;
88 mutable std::vector<size_t> m_valueOffsets;
89};
90
91} // namespace API
92} // namespace Mantid
Base class for a composite domain.
A composite function is a function containing other functions.
Base class that represents the domain of a function.
A class to store values calculated by a function.
Attribute is a non-fitting parameter.
Definition: IFunction.h:282
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22
A composite function defined on a CompositeDomain.
size_t getMaxIndex() const
Get the largest domain index.
size_t nLocalAttributes() const override
Returns the number of "local" attributes associated with the function.
std::vector< size_t > m_valueOffsets
std::map< size_t, std::vector< size_t > > m_domains
Domain index map: finction -> domain.
std::vector< std::string > getLocalAttributeNames() const override
Returns a list of attribute names.
size_t m_nDomains
Number of domains this MultiDomainFunction operates on.
bool hasLocalAttribute(const std::string &attName) const override
Check if attribute attName exists.
size_t m_maxIndex
Maximum domain index.
std::string name() const override
Returns the function's name.
Helper class which provides the Collimation Length for SANS instruments.