-
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.
Re #4158. Added an experimental fitting algorithm.
- Loading branch information
1 parent
b2d1abc
commit 2971e0e
Showing
12 changed files
with
753 additions
and
19 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
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,115 @@ | ||
//---------------------------------------------------------------------- | ||
// Includes | ||
//---------------------------------------------------------------------- | ||
#include "MantidAPI/FunctionDomain.h" | ||
#include <iostream> | ||
|
||
namespace Mantid | ||
{ | ||
namespace API | ||
{ | ||
|
||
/** | ||
* Constructs a domain base of size n. | ||
* @param n :: Size of the domain, i.e. number of values a function should calculate. | ||
*/ | ||
FunctionDomain::FunctionDomain(size_t n) | ||
{ | ||
if (n == 0) | ||
{ | ||
throw std::invalid_argument("FunctionDomain cannot have zero size."); | ||
} | ||
m_calculated.resize(n); | ||
} | ||
|
||
/** | ||
* Set a fitting data value. | ||
* @param i :: Index | ||
* @param value :: Value | ||
*/ | ||
void FunctionDomain::setFitData(size_t i,double value) | ||
{ | ||
if (m_data.size() != m_calculated.size()) | ||
{ | ||
setDataSize(); | ||
} | ||
m_data[i] = value; | ||
} | ||
|
||
/** | ||
* Set fitting data values. | ||
* @param values :: Values for fitting | ||
*/ | ||
void FunctionDomain::setFitData(const std::vector<double>& values) | ||
{ | ||
if (values.size() != this->size()) | ||
{ | ||
throw std::invalid_argument("Setting data of a wrong size"); | ||
} | ||
m_data.assign(values.begin(),values.end()); | ||
} | ||
|
||
/** | ||
* Get a fitting data value | ||
* @param i :: Index | ||
*/ | ||
double FunctionDomain::getFitData(size_t i) const | ||
{ | ||
if (m_data.size() != m_calculated.size()) | ||
{ | ||
throw std::runtime_error("Fitting data was not set"); | ||
} | ||
return m_data[i]; | ||
} | ||
|
||
/** | ||
* Set a fitting weight | ||
* @param i :: Index | ||
* @param value :: Value | ||
*/ | ||
void FunctionDomain::setFitWeight(size_t i,double value) | ||
{ | ||
if (m_data.size() != m_calculated.size()) | ||
{ | ||
setDataSize(); | ||
} | ||
m_weights[i] = value; | ||
} | ||
|
||
/** | ||
* Set fitting data values. | ||
* @param values :: Values for fitting | ||
*/ | ||
void FunctionDomain::setFitWeights(const std::vector<double>& values) | ||
{ | ||
if (values.size() != this->size()) | ||
{ | ||
throw std::invalid_argument("Setting data of a wrong size"); | ||
} | ||
m_weights.assign(values.begin(),values.end()); | ||
} | ||
|
||
/** | ||
* Get a fitting weight. | ||
* @param i :: Index | ||
*/ | ||
double FunctionDomain::getFitWeight(size_t i) const | ||
{ | ||
if (m_data.size() != m_calculated.size()) | ||
{ | ||
throw std::runtime_error("Fitting data was not set"); | ||
} | ||
return m_weights[i]; | ||
} | ||
|
||
/** | ||
* Resize the fitting data and weight buffers to match the size of the calculated buffer. | ||
*/ | ||
void FunctionDomain::setDataSize() | ||
{ | ||
m_data.resize(m_calculated.size()); | ||
m_weights.resize(m_calculated.size()); | ||
} | ||
|
||
} // namespace API | ||
} // namespace Mantid |
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
Oops, something went wrong.