-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12892a0
commit c542f00
Showing
16 changed files
with
919 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef MANTID_API_JOINTDOMAIN_H_ | ||
#define MANTID_API_JOINTDOMAIN_H_ | ||
|
||
//---------------------------------------------------------------------- | ||
// Includes | ||
//---------------------------------------------------------------------- | ||
#include "MantidAPI/DllConfig.h" | ||
#include "MantidAPI/CompositeDomain.h" | ||
|
||
#include <stdexcept> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
namespace Mantid | ||
{ | ||
namespace API | ||
{ | ||
/** Base class that represents the domain of a function. | ||
A domain is a generalisation of x (argument) and y (value) arrays. | ||
A domain consists at least of a list of function arguments for which a function should | ||
be evaluated and a buffer for the calculated values. If used in fitting also contains | ||
the fit data and weights. | ||
@author Roman Tolchenov, Tessella plc | ||
@date 15/11/2011 | ||
Copyright © 2009 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>. | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class MANTID_API_DLL JointDomain: public CompositeDomain | ||
{ | ||
public: | ||
/// Return the number of points in the domain | ||
virtual size_t size() const; | ||
/// Return the number of parts in the domain | ||
virtual size_t getNParts() const; | ||
/// Return i-th domain | ||
virtual const FunctionDomain& getDomain(size_t i) const; | ||
void addDomain(FunctionDomain_sptr domain); | ||
protected: | ||
std::vector< FunctionDomain_sptr > m_domains; | ||
}; | ||
|
||
} // namespace API | ||
} // namespace Mantid | ||
|
||
#endif /*MANTID_API_JOINTDOMAIN_H_*/ |
80 changes: 80 additions & 0 deletions
80
Code/Mantid/Framework/API/inc/MantidAPI/MultiDomainFunction.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#ifndef MANTID_API_MULTIDOMAINFUNCTION_H_ | ||
#define MANTID_API_MULTIDOMAINFUNCTION_H_ | ||
|
||
//---------------------------------------------------------------------- | ||
// Includes | ||
//---------------------------------------------------------------------- | ||
#include "MantidAPI/CompositeFunction.h" | ||
|
||
#include <map> | ||
|
||
namespace Mantid | ||
{ | ||
namespace API | ||
{ | ||
class CompositeDomain; | ||
/** A composite function defined on a CompositeDomain. Member functions can be applied to | ||
one or more member domains of the CompositeDomain. If two functions applied to the same domain | ||
the results are added (+). | ||
@author Roman Tolchenov, Tessella plc | ||
@date 13/03/2012 | ||
Copyright © 2009 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>. | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class MANTID_API_DLL MultiDomainFunction : public CompositeFunction | ||
{ | ||
public: | ||
/// Constructor | ||
MultiDomainFunction():m_nDomains(0),m_maxIndex(0){} | ||
|
||
/// Function you want to fit to. | ||
/// @param domain :: The buffer for writing the calculated values. Must be big enough to accept dataSize() values | ||
virtual void function(const FunctionDomain& domain, FunctionValues& values)const; | ||
/// Derivatives of function with respect to active parameters | ||
virtual void functionDeriv(const FunctionDomain& domain, Jacobian& jacobian); | ||
|
||
/// Associate a function and a domain | ||
void setDomainIndex(size_t funIndex, size_t domainIndex); | ||
|
||
/// Associate a function and a list of domains | ||
void setDomainIndices(size_t funIndex, const std::vector<size_t>& domainIndices); | ||
|
||
/// Clear all domain indices | ||
void clearDomainIndices(); | ||
protected: | ||
|
||
/// Counts number of the domains | ||
void countNumberOfDomains(); | ||
void countValueOffsets(const CompositeDomain& domain)const; | ||
/// Domain index map: finction -> domain | ||
std::map<size_t, std::vector<size_t> > m_domains; | ||
/// Number of domains this MultiDomainFunction operates on. == number of different values in m_domains | ||
size_t m_nDomains; | ||
/// Maximum domain index | ||
size_t m_maxIndex; | ||
mutable std::vector<size_t> m_valueOffsets; | ||
}; | ||
|
||
} // namespace API | ||
} // namespace Mantid | ||
|
||
#endif /*MANTID_API_MULTIDOMAINFUNCTION_H_*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//---------------------------------------------------------------------- | ||
// Includes | ||
//---------------------------------------------------------------------- | ||
#include "MantidAPI/JointDomain.h" | ||
|
||
namespace Mantid | ||
{ | ||
namespace API | ||
{ | ||
/// Return the number of points in the domain | ||
size_t JointDomain::size() const | ||
{ | ||
size_t n = 0; | ||
std::for_each(m_domains.begin(),m_domains.end(),[&n](const FunctionDomain_sptr d){ | ||
n += d->size(); | ||
}); | ||
return n; | ||
} | ||
/// Return the number of parts in the domain | ||
size_t JointDomain::getNParts() const | ||
{ | ||
return m_domains.size(); | ||
} | ||
/// Return i-th domain | ||
const FunctionDomain& JointDomain::getDomain(size_t i) const | ||
{ | ||
return *m_domains.at(i); | ||
} | ||
void JointDomain::addDomain(FunctionDomain_sptr domain) | ||
{ | ||
m_domains.push_back(domain); | ||
} | ||
|
||
} // namespace API | ||
} // namespace Mantid |
Oops, something went wrong.