Skip to content

Commit

Permalink
Re #4158. Fixing some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Apr 4, 2012
1 parent b249e36 commit be0540d
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/API/src/FunctionDomain1D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ FunctionDomain1D(NULL,0)
}
else
{
const double dx = (endX - startX) / (n - 1);
const double dx = (endX - startX) / double(n - 1);
for(size_t i = 0; i < n; ++i)
{
m_X[i] = startX + dx * i;
m_X[i] = startX + dx * double(i);
}
}
resetData(&m_X[0],m_X.size());
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/API/src/IFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,9 @@ void IFunction::calNumericalDeriv(const FunctionDomain& domain, Jacobian& jacobi
*/
void IFunction::setMatrixWorkspace(boost::shared_ptr<const API::MatrixWorkspace> workspace,size_t wi,double startX, double endX)
{
UNUSED_ARG(startX);
UNUSED_ARG(endX);

if (!workspace) return; // unset the workspace

try
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/test/FunctionDomainTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FunctionDomainTest : public CxxTest::TestSuite
std::vector<double> x(10);
for(size_t i = 0; i < x.size(); ++i)
{
x[i] = 1.0 + 0.1 * i;
x[i] = 1.0 + 0.1 * double(i);
}
FunctionDomain1DVector domain(x);
TS_ASSERT_EQUALS(domain.size(), x.size());
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/API/test/FunctionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ class FunctionTest : public CxxTest::TestSuite
TS_ASSERT( ! f.isFixed(2));
TS_ASSERT( f.isFixed(3));

TS_ASSERT_THROWS(double d = f.activeParameter(1),std::runtime_error);
TS_ASSERT_THROWS(double d = f.activeParameter(3),std::runtime_error);
TS_ASSERT_THROWS(f.activeParameter(1),std::runtime_error);
TS_ASSERT_THROWS(f.activeParameter(3),std::runtime_error);
TS_ASSERT_THROWS(f.setActiveParameter(1,0),std::runtime_error);
TS_ASSERT_THROWS(f.setActiveParameter(3,0),std::runtime_error);

Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/test/FunctionValuesTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FunctionValuesTest : public CxxTest::TestSuite
x.resize(10);
for(size_t i = 0; i < x.size(); ++i)
{
x[i] = 1.0 + 0.1 * i;
x[i] = 1.0 + 0.1 * double(i);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/Framework/API/test/IFunction1DTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,21 @@ class IFunction1DTest : public CxxTest::TestSuite
std::vector<double> x(10);
for(size_t i = 0; i < x.size(); ++i)
{
x[i] = 1.0 + 0.1 * i;
x[i] = 1.0 + 0.1 * double(i);
}
FunctionDomain1DVector domain(x);
FunctionValues values(domain);
function.function(domain,values);
for(size_t i = 0; i < domain.size(); ++i)
{
TS_ASSERT_EQUALS(values.getCalculated(i),A * (1.0 + 0.1 * i) + B);
TS_ASSERT_EQUALS(values.getCalculated(i),A * (1.0 + 0.1 * double(i)) + B);
}

IFunction1DTest_Jacobian jacobian(10,2);
function.functionDeriv(domain,jacobian);
for(size_t i = 0; i < domain.size(); ++i)
{
TS_ASSERT_EQUALS(jacobian.get(i,0), 1.0 + 0.1 * i);
TS_ASSERT_EQUALS(jacobian.get(i,0), 1.0 + 0.1 * double(i));
TS_ASSERT_EQUALS(jacobian.get(i,1), 1.0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/test/RunTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace
std::string getDefault() const { return "getDefault() is not implemented in this class"; }
std::string value() const { return "Nothing"; }
std::string setValue( const std::string& ) { return ""; }
std::string setValueFromProperty( const Property& right ) { return ""; }
std::string setValueFromProperty( const Property& ) { return ""; }
std::string setDataItem(const boost::shared_ptr<DataItem>) { return ""; }
Property& operator+=( Property const * ) { return *this; }
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ namespace Mantid
/// declare properties that specify the dataset within the workspace to fit to.
/// @param suffix :: A suffix to give to all new properties.
/// @param addProp :: If false don't actually declare new properties but do other stuff if needed
virtual void declareDatasetProperties(const std::string& suffix = "",bool addProp = true) {}
virtual void declareDatasetProperties(const std::string& suffix = "",bool addProp = true)
{UNUSED_ARG(suffix);UNUSED_ARG(addProp);}
/// Create a domain and values from the input workspace. FunctionValues must be filled with data to fit to.
/// @param workspacePropetyName :: A name of a workspace property. Domain will be created for this workspace.
/// @param domain :: Shared pointer to hold the created domain
Expand All @@ -70,7 +71,8 @@ namespace Mantid
virtual void createOutputWorkspace(
const std::string& baseName,
boost::shared_ptr<API::FunctionDomain> domain,
boost::shared_ptr<API::IFunctionValues> values) {}
boost::shared_ptr<API::IFunctionValues> values)
{UNUSED_ARG(baseName);UNUSED_ARG(domain);UNUSED_ARG(values);}
virtual void initFunction();

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ double CostFuncLeastSquares::val() const

void CostFuncLeastSquares::addVal(API::FunctionDomain_sptr domain, API::FunctionValues_sptr values)const
{
m_function->function(*m_domain,*values);
m_function->function(*domain,*values);
size_t ny = m_values->size();

double retVal = 0.0;
Expand Down Expand Up @@ -223,6 +223,7 @@ void CostFuncLeastSquares::addValDerivHessian(
API::FunctionValues_sptr values,
bool evalFunction , bool evalDeriv, bool evalHessian) const
{
UNUSED_ARG(evalDeriv);
size_t np = m_function->nParams(); // number of parameters
size_t ny = m_domain->size(); // number of data points
Jacobian jacobian(ny,np);
Expand Down Expand Up @@ -275,7 +276,7 @@ void CostFuncLeastSquares::addValDerivHessian(

if (!evalHessian) return;

size_t na = m_der.size(); // number of active parameters
//size_t na = m_der.size(); // number of active parameters

size_t i1 = 0; // active parameter index
for(size_t i = 0; i < np; ++i) // over parameters
Expand Down Expand Up @@ -396,6 +397,7 @@ void CostFuncLeastSquares::getParameters(GSLVector& params) const
*/
void CostFuncLeastSquares::calActiveCovarianceMatrix(GSLMatrix& covar, double epsrel)
{
UNUSED_ARG(epsrel);
if (m_hessian.isEmpty())
{
valDerivHessian();
Expand Down
8 changes: 4 additions & 4 deletions Code/Mantid/Framework/CurveFitting/src/Fit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ namespace CurveFitting
size_t iter = 0;
bool success = false;
std::string errorString;
double costFuncVal = 0;
//double costFuncVal = 0;
do
{
iter++;
Expand All @@ -343,9 +343,9 @@ namespace CurveFitting
}
prog.report();
}
while (iter < maxIterations);
while (static_cast<int>(iter) < maxIterations);

if (iter >= maxIterations)
if (static_cast<int>(iter) >= maxIterations)
{
if ( !errorString.empty() )
{
Expand All @@ -360,7 +360,7 @@ namespace CurveFitting
// degrees of freedom
size_t dof = values->size() - costFunc->nParams();
if (dof == 0) dof = 1;
double finalCostFuncVal = minimizer->costFunctionVal() / dof;
double finalCostFuncVal = minimizer->costFunctionVal() / double(dof);

setProperty("OutputChi2overDoF",finalCostFuncVal);

Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/CurveFitting/src/FitMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace CurveFitting
boost::shared_ptr<API::FunctionDomain>& domain,
boost::shared_ptr<API::IFunctionValues>& ivalues, size_t i0)
{
UNUSED_ARG(i0);
if (workspacePropetyNames.empty())
{
throw std::runtime_error("Cannot create FunctionDomainMD: no workspace given");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void IkedaCarpenterPV::functionLocal(double* out, const double* xValues, const s
}
}

void IkedaCarpenterPV::functionDerivLocal(API::Jacobian* out, const double* xValues, const size_t nData)
void IkedaCarpenterPV::functionDerivLocal(API::Jacobian* , const double* , const size_t )
{
throw Mantid::Kernel::Exception::NotImplementedError("functionDerivLocal is not implemented for IkedaCarpenterPV.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool LevenbergMarquardtMDMinimizer::iterate()
GSLVector p(n);
m_leastSquares->getParameters(p);
double dx_norm = gsl_blas_dnrm2(dx.gsl());
double p_norm = gsl_blas_dnrm2(p.gsl());
//double p_norm = gsl_blas_dnrm2(p.gsl());
if (dx_norm < 0.0001)
{
return false;
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/CurveFitting/src/SimplexMinimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ double SimplexMinimizer::fun(const gsl_vector * x, void *params)


SimplexMinimizer::SimplexMinimizer():
m_gslSolver(NULL),
m_size(1.0)
m_size(1.0),
m_gslSolver(NULL)
{
}

Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/CurveFitting/test/ConvolutionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class ConvolutionTest : public CxxTest::TestSuite
double cc = pi*pi*df*df/a;
for(size_t i=0;i<hout.size();i++)
{
TS_ASSERT_DELTA(hout.real(i),h*sqrt(pi/a)*exp(-cc*i*i),1e-7);
TS_ASSERT_DELTA(hout.real(i),h*sqrt(pi/a)*exp(-cc*double(i*i)),1e-7);
}

//std::ofstream fres("fres.txt");
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/CurveFitting/test/DiffSphereTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class DiffSphereTest : public CxxTest::TestSuite

//set up some frequency values centered around zero
const int N = 117;
double w[N],in[N],w0,dw = 0.13;
double w[N],w0,dw = 0.13;
w0=-dw*int(N/2);
for(int i=0;i<N;i++) w[i] = w0 + i*dw;

Expand Down Expand Up @@ -316,7 +316,7 @@ class DiffSphereTest : public CxxTest::TestSuite
for(int i=0; i<N; i++){
x[i] = w[i];
y[i] = values.getCalculated(i);
e[i] = cc*in[i];
e[i] = cc*values.getCalculated(i);
}
TS_ASSERT_THROWS_NOTHING(AnalysisDataService::Instance().addOrReplace(wsName, ws2D)); //put workspace in the data service

Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/test/PropertyTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PropertyHelper : public Property
Property* clone() { return new PropertyHelper(*this); }
std::string value() const { return "Nothing"; }
std::string setValue( const std::string&) { return ""; }
std::string setValueFromProperty( const Property& right ) { return ""; }
std::string setValueFromProperty( const Property& ) { return ""; }
std::string setDataItem( const boost::shared_ptr<DataItem> ) { return ""; }
bool isDefault() const { return true; }
std::string getDefault() const { return "Is not implemented in this class, should be overriden"; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ namespace Mantid

protected:
virtual void functionLocal(double* out, const double* xValues, const size_t nData)const;
virtual void functionDerivLocal(API::Jacobian* out, const double* xValues, const size_t nData){}
virtual void functionDerivLocal(API::Jacobian* , const double* , const size_t ){}
/// overwrite IFunction base class method, which declare function parameters
virtual void init();

Expand Down

0 comments on commit be0540d

Please sign in to comment.