Commit e1eb429c authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Ties will be applied in the order they are set. re #999

parent 66abe6bc
......@@ -143,7 +143,7 @@ private:
/// Keeps parameter values
std::vector<double> m_parameters;
/// Holds parameter ties
std::map<int,ParameterTie*> m_ties;
std::vector<std::pair<int,ParameterTie*> > m_ties;
};
/** Represents the Jacobian in functionDeriv.
......
......@@ -181,7 +181,9 @@ int CompositeFunction::parameterIndex(const std::string& name)const
std::string CompositeFunction::parameterName(int i)const
{
int iFun = functionIndex(i);
return m_functions[ iFun ]->parameterName(i - m_paramOffsets[iFun]);
std::ostringstream ostr;
ostr << 'f' << iFun << '.' << m_functions[ iFun ]->parameterName(i - m_paramOffsets[iFun]);
return ostr.str();
}
/// Number of active (in terms of fitting) parameters
......@@ -225,7 +227,9 @@ int CompositeFunction::indexOfActive(int i)const
std::string CompositeFunction::nameOfActive(int i)const
{
int iFun = functionIndexActive(i);
return m_functions[ iFun ]->nameOfActive(i - m_activeOffsets[iFun]);
std::ostringstream ostr;
ostr << 'f' << iFun << '.' << m_functions[ iFun ]->nameOfActive(i - m_activeOffsets[iFun]);
return ostr.str();
}
/**
......
......@@ -34,7 +34,7 @@ IFunction& IFunction::operator=(const IFunction& f)
/// Destructor
IFunction::~IFunction()
{
for(std::map<int,ParameterTie*>::iterator it = m_ties.begin();it != m_ties.end(); it++)
for(std::vector<std::pair<int,ParameterTie*> >::iterator it = m_ties.begin();it != m_ties.end(); it++)
delete it->second;
m_ties.clear();
}
......@@ -282,7 +282,7 @@ void IFunction::tie(const std::string& parName,const std::string& expr)
throw std::logic_error("Parameter "+parName+" is already tied.");
}
tie->set(expr);
m_ties[i] = tie;
m_ties.push_back(std::pair<int,ParameterTie*>(i,tie));
this->removeActive(i);
}
......@@ -291,7 +291,7 @@ void IFunction::tie(const std::string& parName,const std::string& expr)
*/
void IFunction::applyTies()
{
for(std::map<int,ParameterTie*>::iterator tie=m_ties.begin();tie!=m_ties.end();++tie)
for(std::vector<std::pair<int,ParameterTie*> >::iterator tie=m_ties.begin();tie!=m_ties.end();++tie)
{
this->parameter(tie->first) = tie->second->eval();
}
......
......@@ -510,10 +510,10 @@ namespace CurveFitting
Mantid::API::ITableWorkspace_sptr m_result = Mantid::API::WorkspaceFactory::Instance().createTable("TableWorkspace");
m_result->addColumn("str","Name");
m_result->addColumn("double","Value");
for(size_t i=0;i<nParams();i++)
for(size_t i=0;i<m_function->nParams();i++)
{
Mantid::API::TableRow row = m_result->appendRow();
row << m_function->nameOfActive(i) << m_function->activeParameter(i);
row << m_function->parameterName(i) << m_function->parameter(i);
}
setProperty("OutputParameters",m_result);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment