-
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.
refs #5634. Template for new Product function.
- Loading branch information
1 parent
3ec922f
commit 83b754d
Showing
4 changed files
with
167 additions
and
3 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
54 changes: 54 additions & 0 deletions
54
Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/ProductQuadraticExp.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,54 @@ | ||
#ifndef MANTID_CURVEFITTING_PRODUCTQUADRATICEXP_H_ | ||
#define MANTID_CURVEFITTING_PRODUCTQUADRATICEXP_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/ParamFunction.h" | ||
#include "MantidAPI/IFunction1D.h" | ||
|
||
namespace Mantid | ||
{ | ||
namespace CurveFitting | ||
{ | ||
|
||
/** ProductQuadraticExp : Function that evauates the product of an exponential and quadratic function. | ||
Copyright © 2012 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 DLLExport ProductQuadraticExp : public API::ParamFunction, public API::IFunction1D | ||
{ | ||
public: | ||
ProductQuadraticExp(); | ||
virtual ~ProductQuadraticExp(); | ||
|
||
std::string name()const{return "ProductQuadraticExp";} | ||
|
||
virtual const std::string category() const { return "Calibrate";} | ||
|
||
protected: | ||
virtual void functionDeriv1D(API::Jacobian* out, const double* xValues, const size_t nData); | ||
virtual void function1D(double* out, const double* xValues, const size_t nData) const; | ||
}; | ||
|
||
|
||
} // namespace CurveFitting | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_CURVEFITTING_PRODUCTQUADRATICEXP_H_ */ |
49 changes: 49 additions & 0 deletions
49
Code/Mantid/Framework/CurveFitting/src/ProductQuadraticExp.cpp
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,49 @@ | ||
#include "MantidCurveFitting/ProductQuadraticExp.h" | ||
|
||
namespace Mantid | ||
{ | ||
namespace CurveFitting | ||
{ | ||
//---------------------------------------------------------------------------------------------- | ||
/** Constructor | ||
*/ | ||
ProductQuadraticExp::ProductQuadraticExp() | ||
{ | ||
declareParameter("A0", 0.0); | ||
declareParameter("A1", 0.0); | ||
declareParameter("A2", 0.0); | ||
declareParameter("Height", 1.0); | ||
declareParameter("Lifetime", 1.0); | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------- | ||
/** Destructor | ||
*/ | ||
ProductQuadraticExp::~ProductQuadraticExp() | ||
{ | ||
} | ||
|
||
void ProductQuadraticExp::functionDeriv1D(API::Jacobian* out, const double* xValues, const size_t nData) | ||
{ | ||
throw std::runtime_error("Not Implemented"); | ||
} | ||
|
||
void ProductQuadraticExp::function1D(double* out, const double* xValues, const size_t nData) const | ||
{ | ||
double A0 = getParameter("A0"); | ||
double A1 = getParameter("A1"); | ||
double A2 = getParameter("A2"); | ||
double Height = getParameter("Height"); | ||
double Lifetime = getParameter("Lifetime"); | ||
|
||
UNUSED_ARG(A0); | ||
UNUSED_ARG(A1); | ||
UNUSED_ARG(A2); | ||
UNUSED_ARG(Height); | ||
UNUSED_ARG(Lifetime); | ||
|
||
throw std::runtime_error("Not Implemented"); | ||
} | ||
|
||
} // namespace CurveFitting | ||
} // namespace Mantid |
58 changes: 58 additions & 0 deletions
58
Code/Mantid/Framework/CurveFitting/test/ProductQuadraticExpTest.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,58 @@ | ||
#ifndef MANTID_CURVEFITTING_PRODUCTQUADRATICEXPTEST_H_ | ||
#define MANTID_CURVEFITTING_PRODUCTQUADRATICEXPTEST_H_ | ||
|
||
#include <cxxtest/TestSuite.h> | ||
|
||
#include "MantidCurveFitting/ProductQuadraticExp.h" | ||
|
||
using Mantid::CurveFitting::ProductQuadraticExp; | ||
|
||
class ProductQuadraticExpTest : public CxxTest::TestSuite | ||
{ | ||
public: | ||
// This pair of boilerplate methods prevent the suite being created statically | ||
// This means the constructor isn't called when running other tests | ||
static ProductQuadraticExpTest *createSuite() { return new ProductQuadraticExpTest(); } | ||
static void destroySuite( ProductQuadraticExpTest *suite ) { delete suite; } | ||
|
||
|
||
void test_name() | ||
{ | ||
ProductQuadraticExp func; | ||
TS_ASSERT_EQUALS("ProductQuadraticExp", func.name()); | ||
} | ||
|
||
void test_catagory() | ||
{ | ||
ProductQuadraticExp func; | ||
TS_ASSERT_EQUALS("Calibrate", func.category()); | ||
} | ||
|
||
void test_set_parameters() | ||
{ | ||
const double A0 = 1; | ||
const double A1 = 2; | ||
const double A2 = 3; | ||
const double Height = 4; | ||
const double Lifetime = 0.1; | ||
|
||
ProductQuadraticExp func; | ||
func.setParameter("A0", A0); | ||
func.setParameter("A1", A1); | ||
func.setParameter("A2", A2); | ||
func.setParameter("Height", Height); | ||
func.setParameter("Lifetime", Lifetime); | ||
|
||
TS_ASSERT_EQUALS(A0, func.getParameter("A0")); | ||
TS_ASSERT_EQUALS(A1, func.getParameter("A1")); | ||
TS_ASSERT_EQUALS(A2, func.getParameter("A2")); | ||
TS_ASSERT_EQUALS(Height, func.getParameter("Height")); | ||
TS_ASSERT_EQUALS(Lifetime, func.getParameter("Lifetime")); | ||
} | ||
|
||
|
||
|
||
}; | ||
|
||
|
||
#endif /* MANTID_CURVEFITTING_PRODUCTQUADRATICEXPTEST_H_ */ |