Commit 8626f81b authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Re #15699. Apply clang-format patch.

parent 0e002d99
......@@ -11,7 +11,7 @@ namespace API {
class Column;
/**
Represent a domain of a very general type.
Represent a domain of a very general type.
Copyright © 2016 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
......@@ -44,6 +44,7 @@ public:
void addColumn(boost::shared_ptr<Column> column);
/// Get i-th column
boost::shared_ptr<Column> getColumn(size_t i) const;
private:
/// Columns containing function arguments
std::vector<boost::shared_ptr<Column>> m_columns;
......
......@@ -329,8 +329,11 @@ protected:
void removeFromColumn(Column *c, size_t index) { c->remove(index); }
private:
ITableWorkspace *doClone() const override {return doCloneColumns(std::vector<std::string>());}
virtual ITableWorkspace *doCloneColumns(const std::vector<std::string> &colNames) const = 0;
ITableWorkspace *doClone() const override {
return doCloneColumns(std::vector<std::string>());
}
virtual ITableWorkspace *
doCloneColumns(const std::vector<std::string> &colNames) const = 0;
};
// =====================================================================================
......
......@@ -1122,14 +1122,14 @@ void IFunction::unfixParameter(const std::string &name) {
/// Fix all parameters
void IFunction::fixAll() {
for(size_t i = 0; i < nParams(); ++i) {
for (size_t i = 0; i < nParams(); ++i) {
fix(i);
}
}
/// Free all parameters
void IFunction::unfixAll() {
for(size_t i = 0; i < nParams(); ++i) {
for (size_t i = 0; i < nParams(); ++i) {
fix(i);
}
}
......
......@@ -11,40 +11,58 @@ using namespace Mantid::API;
namespace {
template<typename T>
class TestColumn: public Column {
template <typename T> class TestColumn : public Column {
public:
/// Constructor
TestColumn(size_t n) : m_data(n) {}
/// Number of individual elements in the column.
virtual size_t size() const {return m_data.size();}
virtual size_t size() const { return m_data.size(); }
/// Returns typeid for the data in the column
virtual const std::type_info &get_type_info() const {return typeid(T);}
virtual const std::type_info &get_type_info() const { return typeid(T); }
/// Returns typeid for the pointer type to the data element in the column
virtual const std::type_info &get_pointer_type_info() const {return typeid(T*);}
virtual const std::type_info &get_pointer_type_info() const {
return typeid(T *);
}
/// Prints out the value to a stream
virtual void print(size_t index, std::ostream &s) const {throw std::logic_error("Not implemented");}
virtual void print(size_t index, std::ostream &s) const {
throw std::logic_error("Not implemented");
}
/// Specialized type check
virtual bool isBool() const {return false;}
virtual bool isBool() const { return false; }
/// Must return overall memory size taken by the column.
virtual long int sizeOfData() const {throw std::logic_error("Not implemented");}
virtual long int sizeOfData() const {
throw std::logic_error("Not implemented");
}
/// Virtual constructor. Fully clone any column.
virtual Column *clone() const {throw std::logic_error("Not implemented");}
virtual Column *clone() const { throw std::logic_error("Not implemented"); }
/// Cast an element to double if possible
virtual double toDouble(size_t index) const {throw std::logic_error("Not implemented");}
virtual double toDouble(size_t index) const {
throw std::logic_error("Not implemented");
}
/// Assign an element from double if possible
virtual void fromDouble(size_t index, double value) {throw std::logic_error("Not implemented");}
virtual void fromDouble(size_t index, double value) {
throw std::logic_error("Not implemented");
}
protected:
/// Sets the new column size.
virtual void resize(size_t count) {throw std::logic_error("Not implemented");}
virtual void resize(size_t count) {
throw std::logic_error("Not implemented");
}
/// Inserts an item.
virtual void insert(size_t index) {throw std::logic_error("Not implemented");}
virtual void insert(size_t index) {
throw std::logic_error("Not implemented");
}
/// Removes an item.
virtual void remove(size_t index) {throw std::logic_error("Not implemented");}
virtual void remove(size_t index) {
throw std::logic_error("Not implemented");
}
/// Pointer to a data element
virtual void *void_pointer(size_t index) {return &m_data[index];}
virtual void *void_pointer(size_t index) { return &m_data[index]; }
/// Pointer to a data element
virtual const void *void_pointer(size_t index) const {return &m_data[index];}
virtual const void *void_pointer(size_t index) const {
return &m_data[index];
}
/// Data storage
std::vector<T> m_data;
};
......@@ -53,7 +71,9 @@ protected:
class FunctionDomainGeneralTest : public CxxTest::TestSuite {
public:
static FunctionDomainGeneralTest *createSuite() { return new FunctionDomainGeneralTest(); }
static FunctionDomainGeneralTest *createSuite() {
return new FunctionDomainGeneralTest();
}
static void destroySuite(FunctionDomainGeneralTest *suite) { delete suite; }
void test_sizes() {
......@@ -91,7 +111,6 @@ public:
TS_ASSERT_EQUALS(strCol->cell<std::string>(1), "General");
TS_ASSERT_EQUALS(strCol->cell<std::string>(2), "Domain");
}
};
#endif /*FUNCTIONDOMAINGENERALTEST_H_*/
......@@ -8,23 +8,28 @@ namespace Mantid {
namespace CurveFitting {
namespace Functions {
void MANTID_CURVEFITTING_DLL calculateEigesystem(
DoubleFortranVector &eigenvalues, ComplexFortranMatrix &eigenvectors,
ComplexFortranMatrix &hamiltonian, int nre, const DoubleFortranVector &bmol,
const DoubleFortranVector &bext, const ComplexFortranMatrix &bkq,
double alpha_euler = 0.0, double beta_euler = 0.0,
double gamma_euler = 0.0);
void MANTID_CURVEFITTING_DLL
calculateEigesystem(DoubleFortranVector &eigenvalues,
ComplexFortranMatrix &eigenvectors,
ComplexFortranMatrix &hamiltonian, int nre,
const DoubleFortranVector &bmol,
const DoubleFortranVector &bext,
const ComplexFortranMatrix &bkq, double alpha_euler = 0.0,
double beta_euler = 0.0, double gamma_euler = 0.0);
void MANTID_CURVEFITTING_DLL calculateIntensities(
int nre, const DoubleFortranVector &energies,
const ComplexFortranMatrix &wavefunctions, double temperature, double de,
double di, IntFortranVector &degeneration, DoubleFortranVector &e_energies,
DoubleFortranMatrix &i_energies);
void MANTID_CURVEFITTING_DLL
calculateIntensities(int nre, const DoubleFortranVector &energies,
const ComplexFortranMatrix &wavefunctions,
double temperature, double de, double di,
IntFortranVector &degeneration,
DoubleFortranVector &e_energies,
DoubleFortranMatrix &i_energies);
void MANTID_CURVEFITTING_DLL calculateExcitations(
const DoubleFortranVector &e_energies,
const DoubleFortranMatrix &i_energies, double de, double di,
DoubleFortranVector &e_excitations, DoubleFortranVector &i_excitations);
void MANTID_CURVEFITTING_DLL
calculateExcitations(const DoubleFortranVector &e_energies,
const DoubleFortranMatrix &i_energies, double de,
double di, DoubleFortranVector &e_excitations,
DoubleFortranVector &i_excitations);
} // namespace Functions
} // namespace CurveFitting
......
......@@ -61,6 +61,7 @@ public:
void declareDatasetProperties(const std::string &suffix = "",
bool addProp = true) override;
private:
/// Retrive the input workspace from the property manager.
boost::shared_ptr<API::ITableWorkspace> getInputWorkspace() const;
......
......@@ -14,23 +14,21 @@ DECLARE_FUNCTION(CrystalFieldPeaks)
namespace {
// Maps ion name to its int code.
std::map<std::string, int> ion2nre{
{"Ce", 1},
{"Pr", 2},
{"Nd", 3},
{"Pm", 4},
{"Sm", 5},
{"Eu", 6},
{"Gd", 7},
{"Tb", 8},
{"Dy", 9},
{"Ho", 10},
{"Er", 11},
{"Tm", 12},
{"Yb", 13}
};
void fixx(API::IFunction& fun, const std::string& par) {
std::map<std::string, int> ion2nre{{"Ce", 1},
{"Pr", 2},
{"Nd", 3},
{"Pm", 4},
{"Sm", 5},
{"Eu", 6},
{"Gd", 7},
{"Tb", 8},
{"Dy", 9},
{"Ho", 10},
{"Er", 11},
{"Tm", 12},
{"Yb", 13}};
void fixx(API::IFunction &fun, const std::string &par) {
fun.setParameter(par, 0.0);
fun.fixParameter(par);
const std::string ipar = "I" + par;
......@@ -38,7 +36,7 @@ void fixx(API::IFunction& fun, const std::string& par) {
fun.fixParameter(ipar);
}
void free(API::IFunction& fun, const std::string& par, bool realOnly) {
void free(API::IFunction &fun, const std::string &par, bool realOnly) {
fun.unfixParameter(par);
const std::string ipar = "I" + par;
if (realOnly) {
......@@ -53,10 +51,10 @@ const bool real = true;
const bool cmplx = false;
// Set symmetry C1 or Ci
void setSymmetryC1(API::IFunction& fun) {
void setSymmetryC1(API::IFunction &fun) {
fun.clearTies();
auto i = fun.parameterIndex("B20");
for(;i < fun.nParams(); ++i) {
for (; i < fun.nParams(); ++i) {
fun.unfix(i);
}
fun.setParameter("IB21", 0.0);
......@@ -64,7 +62,7 @@ void setSymmetryC1(API::IFunction& fun) {
}
// Set symmetry C2, Cs or C2h
void setSymmetryC2(API::IFunction& fun) {
void setSymmetryC2(API::IFunction &fun) {
fun.clearTies();
fun.unfixParameter("B20");
fun.unfixParameter("B40");
......@@ -84,7 +82,7 @@ void setSymmetryC2(API::IFunction& fun) {
}
// Set symmetry C2v, D2 or D2h
void setSymmetryC2v(API::IFunction& fun) {
void setSymmetryC2v(API::IFunction &fun) {
fun.clearTies();
fun.unfixParameter("B20");
fun.unfixParameter("B40");
......@@ -104,7 +102,7 @@ void setSymmetryC2v(API::IFunction& fun) {
}
// Set symmetry C4, S4 or C4h
void setSymmetryC4(API::IFunction& fun) {
void setSymmetryC4(API::IFunction &fun) {
fun.clearTies();
fun.unfixParameter("B20");
fun.unfixParameter("B40");
......@@ -124,7 +122,7 @@ void setSymmetryC4(API::IFunction& fun) {
}
// Set symmetry D4, C4v, D2d or D4h
void setSymmetryD4(API::IFunction& fun) {
void setSymmetryD4(API::IFunction &fun) {
fun.clearTies();
fun.unfixParameter("B20");
fun.unfixParameter("B40");
......@@ -144,7 +142,7 @@ void setSymmetryD4(API::IFunction& fun) {
}
// Set symmetry C3 or S6
void setSymmetryC3(API::IFunction& fun) {
void setSymmetryC3(API::IFunction &fun) {
fun.clearTies();
fun.unfixParameter("B20");
fun.unfixParameter("B40");
......@@ -164,7 +162,7 @@ void setSymmetryC3(API::IFunction& fun) {
}
// Set symmetry D3, C3v or D3d
void setSymmetryD3(API::IFunction& fun) {
void setSymmetryD3(API::IFunction &fun) {
fun.clearTies();
fun.unfixParameter("B20");
fun.unfixParameter("B40");
......@@ -184,7 +182,7 @@ void setSymmetryD3(API::IFunction& fun) {
}
// Set symmetry C6, C3h, C6h, D6, C6v, D3h, or D6h
void setSymmetryC6(API::IFunction& fun) {
void setSymmetryC6(API::IFunction &fun) {
fun.clearTies();
fun.unfixParameter("B20");
fun.unfixParameter("B40");
......@@ -204,7 +202,7 @@ void setSymmetryC6(API::IFunction& fun) {
}
// Set symmetry T, Td, Th, O, or Oh
void setSymmetryT(API::IFunction& fun) {
void setSymmetryT(API::IFunction &fun) {
fun.clearTies();
fun.setParameter("B20", 0.0);
fun.fixParameter("B20");
......@@ -227,49 +225,48 @@ void setSymmetryT(API::IFunction& fun) {
}
/// Maps symmetry group names to the symmetry setting functions
std::map<std::string, std::function<void(API::IFunction&)>> symmetryMap{
// Set symmetry C1 or Ci
{"C1", setSymmetryC1},
{"Ci", setSymmetryC1},
// Set symmetry C2, Cs or C2h
{"C2", setSymmetryC2},
{"Cs", setSymmetryC2},
{"C2h", setSymmetryC2},
// Set symmetry C2v, D2 or D2h
{"C2v", setSymmetryC2v},
{"D2", setSymmetryC2v},
{"D2h", setSymmetryC2v},
// Set symmetry C4, S4 or C4h
{"C4", setSymmetryC4},
{"S4", setSymmetryC4},
{"C4h", setSymmetryC4},
// Set symmetry D4, C4v, D2d or D4h
{"D4", setSymmetryD4},
{"C4v", setSymmetryD4},
{"D2d", setSymmetryD4},
{"D4h", setSymmetryD4},
// Set symmetry C3 or S6
{"C3", setSymmetryC3},
{"S6", setSymmetryC3},
// Set symmetry D3, C3v or D3d
{"D3", setSymmetryD3},
{"C3v", setSymmetryD3},
{"D3d", setSymmetryD3},
// Set symmetry C6, C3h, C6h, D6, C6v, D3h, or D6h
{"C6", setSymmetryC6},
{"C3h", setSymmetryC6},
{"C6h", setSymmetryC6},
{"D6", setSymmetryC6},
{"C6v", setSymmetryC6},
{"D3h", setSymmetryC6},
{"D6h", setSymmetryC6},
// Set symmetry T, Td, Th, O, or Oh
{"T", setSymmetryT},
{"Td", setSymmetryT},
{"Th", setSymmetryT},
{"O", setSymmetryT},
{"Oh", setSymmetryT}
};
std::map<std::string, std::function<void(API::IFunction &)>> symmetryMap{
// Set symmetry C1 or Ci
{"C1", setSymmetryC1},
{"Ci", setSymmetryC1},
// Set symmetry C2, Cs or C2h
{"C2", setSymmetryC2},
{"Cs", setSymmetryC2},
{"C2h", setSymmetryC2},
// Set symmetry C2v, D2 or D2h
{"C2v", setSymmetryC2v},
{"D2", setSymmetryC2v},
{"D2h", setSymmetryC2v},
// Set symmetry C4, S4 or C4h
{"C4", setSymmetryC4},
{"S4", setSymmetryC4},
{"C4h", setSymmetryC4},
// Set symmetry D4, C4v, D2d or D4h
{"D4", setSymmetryD4},
{"C4v", setSymmetryD4},
{"D2d", setSymmetryD4},
{"D4h", setSymmetryD4},
// Set symmetry C3 or S6
{"C3", setSymmetryC3},
{"S6", setSymmetryC3},
// Set symmetry D3, C3v or D3d
{"D3", setSymmetryD3},
{"C3v", setSymmetryD3},
{"D3d", setSymmetryD3},
// Set symmetry C6, C3h, C6h, D6, C6v, D3h, or D6h
{"C6", setSymmetryC6},
{"C3h", setSymmetryC6},
{"C6h", setSymmetryC6},
{"D6", setSymmetryC6},
{"C6v", setSymmetryC6},
{"D3h", setSymmetryC6},
{"D6h", setSymmetryC6},
// Set symmetry T, Td, Th, O, or Oh
{"T", setSymmetryT},
{"Td", setSymmetryT},
{"Th", setSymmetryT},
{"O", setSymmetryT},
{"Oh", setSymmetryT}};
} // anonymous namespace
......@@ -438,7 +435,8 @@ void CrystalFieldPeaks::functionGeneral(
}
/// Perform a castom action when an attribute is set.
void CrystalFieldPeaks::setAttribute(const std::string &name, const IFunction::Attribute &attr) {
void CrystalFieldPeaks::setAttribute(const std::string &name,
const IFunction::Attribute &attr) {
if (name == "Symmetry") {
auto symmIter = symmetryMap.find(attr.asString());
if (symmIter == symmetryMap.end()) {
......
......@@ -74,7 +74,8 @@ void GeneralDomainCreator::declareDatasetProperties(const std::string &suffix,
}
/// Retrive the input workspace from the property manager.
boost::shared_ptr<API::ITableWorkspace> GeneralDomainCreator::getInputWorkspace() const {
boost::shared_ptr<API::ITableWorkspace>
GeneralDomainCreator::getInputWorkspace() const {
auto workspacePropertyName = m_workspacePropertyNames.front();
if (!m_manager->existsProperty(workspacePropertyName)) {
return API::ITableWorkspace_sptr();
......@@ -87,7 +88,6 @@ boost::shared_ptr<API::ITableWorkspace> GeneralDomainCreator::getInputWorkspace(
return tableWorkspace;
}
/**
* Creates a domain corresponding to the assigned MatrixWorkspace
*
......@@ -186,12 +186,12 @@ Workspace_sptr GeneralDomainCreator::createOutputWorkspace(
}
size_t rowCount = domain->size();
if (rowCount == 0) {
auto &generalFunction = dynamic_cast<IFunctionGeneral&>(*function);
auto &generalFunction = dynamic_cast<IFunctionGeneral &>(*function);
rowCount = generalFunction.getDefaultDomainSize();
}
// Clone the data and domain columns from inputWorkspace to outputWorkspace.
//auto &generalDomain = *static_cast<FunctionDomainGeneral *>(domain.get());
// auto &generalDomain = *static_cast<FunctionDomainGeneral *>(domain.get());
ITableWorkspace_sptr outputWorkspace;
......@@ -244,8 +244,8 @@ Workspace_sptr GeneralDomainCreator::createOutputWorkspace(
if (!outputWorkspacePropertyName.empty()) {
declareProperty(
new API::WorkspaceProperty<API::ITableWorkspace>(outputWorkspacePropertyName,
"", Kernel::Direction::Output),
new API::WorkspaceProperty<API::ITableWorkspace>(
outputWorkspacePropertyName, "", Kernel::Direction::Output),
"Name of the output Workspace holding resulting simulated values");
m_manager->setPropertyValue(outputWorkspacePropertyName,
baseName + "Workspace");
......
......@@ -181,8 +181,8 @@ void IFittingAlgorithm::addWorkspace(const std::string &workspacePropertyName,
IFunction_sptr fun = getProperty("Function");
setDomainType();
IDomainCreator *creator = createDomainCreator(
fun.get(), workspacePropertyName, this, m_domainType);
IDomainCreator *creator =
createDomainCreator(fun.get(), workspacePropertyName, this, m_domainType);
if (!m_domainCreator) {
if (m_workspacePropertyNames.empty()) {
......@@ -234,9 +234,8 @@ void IFittingAlgorithm::addWorkspaces() {
if ((*prop).direction() == Kernel::Direction::Input &&
dynamic_cast<API::IWorkspaceProperty *>(prop)) {
const std::string workspacePropertyName = (*prop).name();
IDomainCreator *creator =
createDomainCreator(m_function.get(), workspacePropertyName,
this, m_domainType);
IDomainCreator *creator = createDomainCreator(
m_function.get(), workspacePropertyName, this, m_domainType);
const size_t n = std::string("InputWorkspace").size();
const std::string suffix = (workspacePropertyName.size() > n)
......
......@@ -208,7 +208,7 @@ public:
void test_int_array() {
typedef FortranVector<std::vector<int>> FortranIntVector;
FortranIntVector ivec(1,3);
FortranIntVector ivec(1, 3);
ivec(1) = 11;
ivec(2) = 22;
ivec(3) = 33;
......
......@@ -25,44 +25,46 @@ using Mantid::CurveFitting::GeneralDomainCreator;
namespace {
class TestFunction1: public IFunctionGeneral, public ParamFunction {
class TestFunction1 : public IFunctionGeneral, public ParamFunction {
public:
TestFunction1() : IFunctionGeneral(), ParamFunction() {
declareParameter("a", 1.0);
}
std::string name() const override {return "TestFunction1";}
size_t getNumberDomainColumns() const override {return 2;}
size_t getNumberValuesPerArgument() const override {return 3;}
void functionGeneral(const FunctionDomainGeneral &generalDomain, FunctionValues &values) const override {
std::string name() const override { return "TestFunction1"; }
size_t getNumberDomainColumns() const override { return 2; }
size_t getNumberValuesPerArgument() const override { return 3; }
void functionGeneral(const FunctionDomainGeneral &generalDomain,
FunctionValues &values) const override {
double a = getParameter(0);
auto x = generalDomain.getColumn(0);
auto nam = generalDomain.getColumn(1);
auto n = x->size();
for(size_t i = 0; i < n; ++i) {
for (size_t i = 0; i < n; ++i) {
double v = a * x->toDouble(i);
if (nam->cell<std::string>(i) == "Beta") {
v *= 2.0;
}
values.setCalculated(i, v);
values.setCalculated(i + n, v / 10.);
values.setCalculated(i + 2*n, v / 100.);
values.setCalculated(i + 2 * n, v / 100.);
}
}
};
class TestFunction2: public IFunctionGeneral, public ParamFunction {
class TestFunction2 : public IFunctionGeneral, public ParamFunction {
public:
TestFunction2() : IFunctionGeneral(), ParamFunction() {
declareParameter("a", 0.0);
}
std::string name() const override {return "TestFunction2";}
size_t getNumberDomainColumns() const override {return 0;}
size_t getNumberValuesPerArgument() const override {return 2;}
size_t getDefaultDomainSize() const override {return 5;}
void functionGeneral(const FunctionDomainGeneral &generalDomain, FunctionValues &values) const override {
std::string name() const override { return "TestFunction2"; }
size_t getNumberDomainColumns() const override { return 0; }
size_t getNumberValuesPerArgument() const override { return 2; }
size_t getDefaultDomainSize() const override { return 5; }
void functionGeneral(const FunctionDomainGeneral &generalDomain,
FunctionValues &values) const override {
double a = getParameter(0);
auto n = getDefaultDomainSize();
for(size_t i = 0; i < n; ++i) {
for (size_t i = 0; i < n; ++i) {
values.setCalculated(i, a * double(i));
values.setCalculated(i + n, a * (10.0 - double(i)));
}
......@@ -106,9 +108,9 @@ public:
TableWorkspace_sptr ws = makeData1();
manager.declareProperty(
make_unique<WorkspaceProperty<Workspace>>("InputWorkspace", "", Direction::Input),
"Name of the input Workspace");
manager.declareProperty(make_unique<WorkspaceProperty<Workspace>>(
"InputWorkspace", "", Direction::Input),
"Name of the input Workspace");
manager.setProperty("InputWorkspace", ws);
manager.setProperty("ArgumentColumn", "X");
manager.setProperty("ArgumentColumn_1", "Name");
......@@ -126,7 +128,7 @@ public:
TS_ASSERT_EQUALS(domain->size(), 4);
TS_ASSERT_EQUALS(values->size(), 12);
auto &generalDomain = static_cast<FunctionDomainGeneral&>(*domain);
auto &generalDomain = static_cast<FunctionDomainGeneral &>(*domain);