Skip to content

Commit

Permalink
Re #4158. Started gradual change to a new function interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Nov 18, 2011
1 parent 4881943 commit 5740f22
Show file tree
Hide file tree
Showing 57 changed files with 1,777 additions and 808 deletions.
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ set ( SRC_FILES
src/IEventList.cpp
src/IEventWorkspace.cpp
src/IFitFunction.cpp
src/IFunction.cpp
src/TempFunction.cpp
src/IFunctionMD.cpp
src/IFunctionMW.cpp
src/IMDEventWorkspace.cpp
Expand Down Expand Up @@ -121,7 +123,9 @@ set ( INC_FILES
inc/MantidAPI/FileFinder.h
inc/MantidAPI/FileProperty.h
inc/MantidAPI/FrameworkManager.h
inc/MantidAPI/FunctionDomain.h
inc/MantidAPI/FunctionFactory.h
inc/MantidAPI/Jacobian.h
inc/MantidAPI/IAlgorithm.h
inc/MantidAPI/IArchiveSearch.h
inc/MantidAPI/IBackgroundFunction.h
Expand All @@ -133,6 +137,8 @@ set ( INC_FILES
inc/MantidAPI/IEventList.h
inc/MantidAPI/IEventWorkspace.h
inc/MantidAPI/IFitFunction.h
inc/MantidAPI/IFunction.h
inc/MantidAPI/TempFunction.h
inc/MantidAPI/IFunctionMD.h
inc/MantidAPI/IFunctionMW.h
inc/MantidAPI/IFunctionWithLocation.h
Expand Down
23 changes: 12 additions & 11 deletions Code/Mantid/Framework/API/inc/MantidAPI/CompositeFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/IFitFunction.h"
#include "MantidAPI/Jacobian.h"
#include <boost/shared_array.hpp>

namespace Mantid
Expand Down Expand Up @@ -104,22 +105,22 @@ class MANTID_API_DLL CompositeFunction : public virtual IFitFunction
/// Return parameter index from a parameter reference.
size_t getParameterIndex(const ParameterReference& ref)const;
/// Get the containing function
IFitFunction* getContainingFunction(const ParameterReference& ref)const;
IFunction* getContainingFunction(const ParameterReference& ref)const;
/// Get the containing function
IFitFunction* getContainingFunction(const IFitFunction* fun);
IFunction* getContainingFunction(const IFunction* fun);

/// Apply the ties
void applyTies();
/// Remove all ties
void clearTies();
// Unhide base class function: removeTie(string). Avoids Intel compiler warning
using IFitFunction::removeTie;
using IFunction::removeTie;
/// Removes i-th parameter's tie
bool removeTie(size_t i);
/// Get the tie of i-th parameter
ParameterTie* getTie(size_t i)const;

/// Overwrite IFitFunction methods
/// Overwrite IFunction methods
void addConstraint(IConstraint* ic);
/// Get constraint of i-th parameter
virtual IConstraint* getConstraint(size_t i)const;
Expand All @@ -131,17 +132,17 @@ class MANTID_API_DLL CompositeFunction : public virtual IFitFunction
/* CompositeFunction own methods */

/// Add a function at the back of the internal function list
virtual size_t addFunction(IFitFunction* f);
virtual size_t addFunction(IFunction* f);
/// Returns the pointer to i-th function
IFitFunction* getFunction(std::size_t i)const;
IFunction* getFunction(std::size_t i)const;
/// Number of functions
std::size_t nFunctions()const{return m_functions.size();}
/// Remove a function
void removeFunction(size_t i, bool del=true);
/// Replace a function
void replaceFunction(size_t i,IFitFunction* f);
void replaceFunction(size_t i,IFunction* f);
/// Replace a function
void replaceFunctionPtr(const IFitFunction* f_old,IFitFunction* f_new);
void replaceFunctionPtr(const IFunction* f_old,IFunction* f_new);
/// Get the function index
std::size_t functionIndex(std::size_t i)const;
/// Get the function index
Expand Down Expand Up @@ -170,17 +171,17 @@ class MANTID_API_DLL CompositeFunction : public virtual IFitFunction
static void parseName(const std::string& varName,size_t& index, std::string& name);

/// Pointers to the included funtions
std::vector<IFitFunction*> m_functions;
std::vector<IFunction*> m_functions;
/// Individual function parameter offsets (function index in m_functions)
/// e.g. m_functions[i]->activeParameter(m_activeOffsets[i]+1) gives second active parameter of i-th function
std::vector<size_t> m_activeOffsets;
/// Individual function parameter offsets (function index in m_functions)
/// e.g. m_functions[i]->parameter(m_paramOffsets[i]+1) gives second declared parameter of i-th function
std::vector<size_t> m_paramOffsets;
/// Keeps the function index for each declared parameter (parameter declared index)
std::vector<size_t> m_IFitFunction;
std::vector<size_t> m_IFunction;
/// Keeps the function index for each active parameter (parameter active index)
std::vector<size_t> m_IFitFunctionActive;
std::vector<size_t> m_IFunctionActive;
/// Number of active parameters
size_t m_nActive;
/// Total number of parameters
Expand Down
59 changes: 59 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/FunctionDomain.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef MANTID_API_FUNCTIONDOMAIN_H_
#define MANTID_API_FUNCTIONDOMAIN_H_

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/Exception.h"

namespace Mantid
{
namespace API
{
/** Abstract 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 &copy; 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 FunctionDomain
{
public:
/// Return the number of points, values, etc in the domain
virtual size_t size() const = 0;
/// store i-th calculated value. 0 <= i < size()
virtual void setCalculated(size_t i,double value) = 0;
/// get i-th calculated value. 0 <= i < size()
virtual double getCalculated(size_t i) const = 0;
/// Virtual destructor
virtual ~FunctionDomain(){}
};

} // namespace API
} // namespace Mantid

#endif /*MANTID_API_FUNCTIONDOMAIN_H_*/

0 comments on commit 5740f22

Please sign in to comment.