Commit 67ad77d4 authored by Laurent Belcour's avatar Laurent Belcour

[CMake] Got most of the plugins to compile and link

parent 5e4fac53
cmake_minimum_required (VERSION 3.2)
project (alta CXX)
# Preconfiguration
#############################
# Preconfiguration #
#############################
# Set Python version number
set(Python_ADDITIONAL_VERSIONS 2.7)
# Require C++11 options
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#############################
# Dependencies #
#############################
# Find required packages
find_package(Eigen3)
find_package(OpenMP)
......@@ -18,8 +30,9 @@ include_directories("external/build" "sources" ${EIGEN3_INCLUDE_DIR})
include_directories("external" "external/Catch/include")
# Look for header only dependencies
find_file(EIGEN_FOUND Eigen HINTS ${EIGEN3_INCLUDE_DIR})
find_file(CATCH_FOUND catch.hpp HINTS external/Catch/include)
find_file(EIGEN_FOUND "Eigen/Core" HINTS ${EIGEN3_INCLUDE_DIR})
find_file(CATCH_FOUND "catch.hpp" HINTS external/Catch/include)
find_file(FLANN_FOUND "flann/flann.hpp")
# Check if Eigen is found
if(NOT EIGEN_FOUND)
......@@ -33,26 +46,24 @@ endif(OPENMP_FOUND)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
#############################
# Helper functions #
#############################
function(alta_add_plugin name sources)
add_library(${name} SHARED sources/plugins/${sources})
target_link_libraries(${name} core)
target_compile_features(${name} PRIVATE cxx_range_for)
target_link_libraries(${name} core)
endfunction(alta_add_plugin)
function(alta_add_soft name sources)
add_executable(${name} sources/softs/${sources})
target_link_libraries(${name} core)
target_compile_features(${name} PRIVATE cxx_range_for)
target_link_libraries(${name} core)
endfunction(alta_add_soft)
function(alta_test_unit name sources)
add_executable(${name} sources/tests/${sources})
target_link_libraries(${name} core)
target_compile_features(${name} PRIVATE cxx_range_for)
add_test(NAME ${name} COMMAND ${CMAKE_BINARY_DIR}/tests/${name} WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
set_tests_properties(${name} PROPERTIES ENVIRONMENT "TEST_DATA_DIRECTORY=${CMAKE_SOURCE_DIR}/sources/tests;ALTA_PLUGIN_PATH=${CMAKE_BINARY_DIR}/plugins")
endfunction(alta_test_unit)
......@@ -62,12 +73,13 @@ function(alta_test_soft name)
endfunction(alta_test_soft)
function(alta_download_merl name)
find_file(${name}_FOUND "${CMAKE_BINARY_DIR}/tests/${name}.binary")
find_file(${name}_FOUND "${name}.binary" PATHS "${CMAKE_BINARY_DIR}/tests/")
if(NOT ${name}_FOUND)
message("Dowloading ${name} from MERL database:")
file(DOWNLOAD
"http://people.csail.mit.edu/wojciech/BRDFDatabase/brdfs/${name}.binary"
"${CMAKE_BINARY_DIR}/tests/${name}.binary" SHOW_PROGRESS)
set(${name}_FOUND TRUE)
endif()
endfunction(alta_download_merl)
......@@ -82,23 +94,22 @@ add_library(core STATIC
sources/core/args.h
sources/core/common.h
sources/core/common.cpp
sources/core/metrics.h
sources/core/metrics.cpp
sources/core/params.h
sources/core/params.cpp
sources/core/data.h
sources/core/data.cpp
sources/core/metrics.h
sources/core/metrics.cpp
sources/core/params.h
sources/core/params.cpp
sources/core/data.h
sources/core/data.cpp
sources/core/data_storage.h
sources/core/data_storage.cpp
sources/core/vertical_segment.h
sources/core/vertical_segment.cpp
sources/core/function.h
sources/core/function.cpp
sources/core/rational_function.h
sources/core/rational_function.cpp
sources/core/plugins_manager.h
sources/core/plugins_manager.cpp)
target_compile_features(core PRIVATE cxx_range_for)
sources/core/data_storage.cpp
sources/core/vertical_segment.h
sources/core/vertical_segment.cpp
sources/core/function.h
sources/core/function.cpp
sources/core/rational_function.h
sources/core/rational_function.cpp
sources/core/plugins_manager.h
sources/core/plugins_manager.cpp)
target_link_libraries(core ${CMAKE_DL_LIBS})
......@@ -111,14 +122,43 @@ target_link_libraries(core ${CMAKE_DL_LIBS})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins)
# Data
alta_add_plugin(data_merl data_io/merl.cpp)
alta_add_plugin(data_utia data_io/utia.cpp)
alta_add_plugin(data_astm data_io/astm.cpp)
alta_add_plugin(data_merl data_io/merl.cpp)
alta_add_plugin(data_utia data_io/utia.cpp)
alta_add_plugin(data_slice data_io/slice.cpp)
alta_add_plugin(data_grid data_interpolants/grid.cpp)
if(FLANN_FOUND)
alta_add_plugin(data_rbf data_interpolants/rbf.cpp)
endif()
#alta_add_plugin(data_matlab data_interpolants/matlab.cpp)
# Functions
alta_add_plugin(nonlinear_function_diffuse nonlinear_function_diffuse/function.cpp)
alta_add_plugin(nonlinear_function_abc nonlinear_function_abc/function.cpp)
alta_add_plugin(nonlinear_function_beckmann nonlinear_function_beckmann/function.cpp)
alta_add_plugin(nonlinear_function_blinn nonlinear_function_blinn/function.cpp)
alta_add_plugin(nonlinear_function_diffuse nonlinear_function_diffuse/function.cpp)
alta_add_plugin(nonlinear_function_lafortune nonlinear_function_lafortune/function.cpp)
alta_add_plugin(nonlinear_function_sgd nonlinear_function_sgd/function.cpp)
alta_add_plugin(nonlinear_function_spherical_gaussian nonlinear_function_spherical_gaussian/function.cpp)
alta_add_plugin(nonlinear_function_ward nonlinear_function_ward/function.cpp)
# TODO Missing retro reflective functions
# TODO Missing some Fresnels
alta_add_plugin(nonlinear_fresnel_schlick nonlinear_fresnel_schlick/function.cpp)
alta_add_plugin(nonlinear_shadowing_schlick nonlinear_shadowing_schlick/function.cpp)
alta_add_plugin(nonlinear_shadowing_smith nonlinear_shadowing_smith/function.cpp)
alta_add_plugin(nonlinear_shadowing_walter_smith nonlinear_shadowing_walter_smith/function.cpp)
# Fitters
alta_add_plugin(nonlinear_fitter_eigen nonlinear_fitter_eigen/fitter.cpp)
alta_add_plugin(nonlinear_fitter_eigen nonlinear_fitter_eigen/fitter.cpp)
# TODO: Add check before compiling CERES, NLOPT and IPOPT
alta_add_plugin(nonlinear_fitter_ceres nonlinear_fitter_ceres/fitter.cpp)
alta_add_plugin(nonlinear_fitter_nlopt nonlinear_fitter_nlopt/fitter.cpp)
#alta_add_plugin(nonlinear_fitter_ipopt nonlinear_fitter_ipopt/fitter.cpp)
# Python bindings
if(PYTHONLIBS_FOUND AND Boost_FOUND)
......@@ -126,13 +166,13 @@ if(PYTHONLIBS_FOUND AND Boost_FOUND)
include_directories(${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
add_library(alta SHARED sources/python/alta.cpp)
target_link_libraries(alta core ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
target_compile_features(alta PRIVATE cxx_range_for)
set_target_properties(alta PROPERTIES PREFIX "")
if(APPLE)
set_target_properties(alta PROPERTIES SUFFIX ".so")
endif()
endif()
#############################
# Softs #
#############################
......@@ -144,6 +184,7 @@ alta_add_soft(data2data data2data/main.cpp)
alta_add_soft(data2brdf data2brdf/main.cpp)
alta_add_soft(data2stats data2stats/data2stats.cpp)
#############################
# Tests #
#############################
......@@ -174,17 +215,17 @@ if(CPPQUICKCHECK_FOUND)
endif()
# Integration tests using MERL data
#find_file(MERL_GOLD_FOUND Eigen "${CMAKE_BINARY_DIR}/tests/gold-metallic-paint.binary")
#if(MERL_GOLD_FOUND)
# file(DOWNLOAD
# "http://people.csail.mit.edu/wojciech/BRDFDatabase/brdfs/gold-metallic-paint.binary"
# "${CMAKE_BINARY_DIR}/tests/gold-metallic-paint.binary" SHOW_PROGRESS)
#endif()
alta_download_merl("gold-metallic-paint")
add_test(NAME "data2data_gold" COMMAND "data2data" "--input" "gold-metallic-paint.binary" "--output" "gold-metallic-paint.alta" "--in-data" "data_merl" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
set_tests_properties("data2data_gold" PROPERTIES ENVIRONMENT "TEST_DATA_DIRECTORY=${CMAKE_SOURCE_DIR}/sources/tests;ALTA_PLUGIN_PATH=${CMAKE_BINARY_DIR}/plugins")
if(gold-metallic-paint_FOUND)
add_test(NAME "data2data_gold"
COMMAND "data2data" "--input" "gold-metallic-paint.binary"
"--output" "gold-metallic-paint.alta"
"--in-data" "data_merl"
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
set_tests_properties("data2data_gold" PROPERTIES ENVIRONMENT "ALTA_PLUGIN_PATH=${CMAKE_BINARY_DIR}/plugins")
endif()
if(CATCH_FOUND)
if(gold-metallic-paint_FOUND AND CATCH_FOUND)
alta_test_unit(conversion-catch-1 core/conversion-catch-1.cpp )
endif()
......
......@@ -22,7 +22,7 @@
#include <cmath>
#include <utility>
using namespace alta;
namespace alta {
/*! \ingroup datas
* \ingroup plugins
......@@ -56,7 +56,7 @@ public: //methods
: vertical_segment(params, size, input_data)
{ }
ASTM(const parameters& params, size_t size)
ASTM(const alta::parameters& params, size_t size)
: vertical_segment(params, size)
{ }
};
......@@ -175,3 +175,5 @@ ALTA_DLL_EXPORT data* load_data(std::istream& input, const arguments& args)
return new ASTM(params, size, std::shared_ptr<double>(data));
}
}
......@@ -19,6 +19,7 @@
#include <core/data.h>
#include <core/args.h>
#include <core/common.h>
#include <core/params.h>
using namespace alta;
......
......@@ -19,15 +19,17 @@
#include <cmath>
#include <core/common.h>
#include <core/params.h>
using namespace alta;
ALTA_DLL_EXPORT function* provide_function(const parameters& params)
ALTA_DLL_EXPORT function* provide_function(const alta::parameters& params)
{
return new lafortune_function(params);
}
lafortune_function::lafortune_function(const parameters& params)
lafortune_function::lafortune_function(const alta::parameters& params) :
nonlinear_function(params)
{
auto nY = params.dimY();
......@@ -50,7 +52,8 @@ vec lafortune_function::operator()(const vec& x) const
}
vec lafortune_function::value(const vec& x) const
{
vec res(dimY());
const int nY = _parameters.dimY();
vec res(nY);
#ifdef ADAPT_TO_PARAM
vec y(6);
......@@ -69,7 +72,7 @@ vec lafortune_function::value(const vec& x) const
#endif
// For each color channel
for(int i=0; i<dimY(); ++i)
for(int i=0; i<nY; ++i)
{
// Start with the diffuse term
res[i] = _kd[i];
......@@ -97,7 +100,8 @@ vec lafortune_function::value(const vec& x, const vec& p)
assert(p.size() == nbParameters());
setParameters(p);
vec res(dimY());
const int nY = _parameters.dimY();
vec res(nY);
#ifdef ADAPT_TO_PARAM
vec y(6);
......@@ -116,7 +120,7 @@ vec lafortune_function::value(const vec& x, const vec& p)
#endif
// For each lobe and for each color channel
for(int i=0; i<dimY(); ++i)
for(int i=0; i<nY; ++i)
{
// Start with the diffuse
res[i] = _kd[i];
......@@ -140,6 +144,7 @@ vec lafortune_function::value(const vec& x, const vec& p)
void lafortune_function::setNbLobes(int N)
{
_n = N;
const int _nY = _parameters.dimY();
// Update the length of the vectors
if(_isotropic)
......@@ -152,47 +157,49 @@ void lafortune_function::setNbLobes(int N)
//! Number of parameters to this non-linear function
int lafortune_function::nbParameters() const
{
const int nY = _parameters.dimY();
#ifdef FIT_DIFFUSE
if(_isotropic)
return (3*_n+1)*dimY();
return (3*_n+1)*nY;
else
return (4*_n+1)*dimY();
return (4*_n+1)*nY;
#else
if(_isotropic)
return (3*_n)*dimY();
return (3*_n)*nY;
else
return (4*_n)*dimY();
return (4*_n)*nY;
#endif
}
//! Get the vector of parameters for the function
vec lafortune_function::parameters() const
{
const int nY = _parameters.dimY();
vec res(nbParameters());
for(int n=0; n<_n; ++n)
for(int i=0; i<dimY(); ++i)
for(int i=0; i<nY; ++i)
{
if(_isotropic)
{
res[(n*dimY() + i)*3 + 0] = _C[(n*dimY() + i)*2 + 0];
res[(n*dimY() + i)*3 + 1] = _C[(n*dimY() + i)*2 + 1];
res[(n*dimY() + i)*3 + 2] = _N[n*dimY() + i];
res[(n*nY + i)*3 + 0] = _C[(n*nY + i)*2 + 0];
res[(n*nY + i)*3 + 1] = _C[(n*nY + i)*2 + 1];
res[(n*nY + i)*3 + 2] = _N[n*nY + i];
}
else
{
res[(n*dimY() + i)*4 + 0] = _C[(n*dimY() + i)*3 + 0];
res[(n*dimY() + i)*4 + 1] = _C[(n*dimY() + i)*3 + 1];
res[(n*dimY() + i)*4 + 2] = _C[(n*dimY() + i)*3 + 2];
res[(n*dimY() + i)*4 + 3] = _N[n*dimY() + i];
res[(n*nY + i)*4 + 0] = _C[(n*nY + i)*3 + 0];
res[(n*nY + i)*4 + 1] = _C[(n*nY + i)*3 + 1];
res[(n*nY + i)*4 + 2] = _C[(n*nY + i)*3 + 2];
res[(n*nY + i)*4 + 3] = _N[n*nY + i];
}
}
#ifdef FIT_DIFFUSE
for(int i=0; i<dimY(); ++i)
for(int i=0; i<nY; ++i)
{
if(_isotropic)
{
res[3*_n*dimY() + i] = _kd[i];
res[3*_n*nY + i] = _kd[i];
}
}
#endif
......@@ -202,21 +209,22 @@ vec lafortune_function::parameters() const
//! Update the vector of parameters for the function
void lafortune_function::setParameters(const vec& p)
{
const int nY = _parameters.dimY();
// Safety check the number of parameters
assert(p.size() == nbParameters());
for(int n=0; n<_n; ++n)
for(int i=0; i<dimY(); ++i)
for(int i=0; i<nY; ++i)
{
_C[(n*dimY() + i)*3 + 0] = p[(n*dimY() + i)*4 + 0];
_C[(n*dimY() + i)*3 + 1] = p[(n*dimY() + i)*4 + 1];
_C[(n*dimY() + i)*3 + 2] = p[(n*dimY() + i)*4 + 2];
_N[n*dimY() + i] = p[(n*dimY() + i)*4 + 3];
_C[(n*nY + i)*3 + 0] = p[(n*nY + i)*4 + 0];
_C[(n*nY + i)*3 + 1] = p[(n*nY + i)*4 + 1];
_C[(n*nY + i)*3 + 2] = p[(n*nY + i)*4 + 2];
_N[n*nY + i] = p[(n*nY + i)*4 + 3];
}
#ifdef FIT_DIFFUSE
for(int i=0; i<dimY(); ++i)
for(int i=0; i<nY; ++i)
{
_kd[i] = p[4*_n*dimY() + i];
_kd[i] = p[4*_n*nY + i];
}
#endif
}
......@@ -225,6 +233,7 @@ void lafortune_function::setParameters(const vec& p)
//! parameters.
vec lafortune_function::parametersJacobian(const vec& x) const
{
const int nY = _parameters.dimY();
#ifdef ADAPT_TO_PARAM
vec y(6);
......@@ -242,14 +251,14 @@ vec lafortune_function::parametersJacobian(const vec& x) const
dz = x[2]*x[5];
#endif
vec jac(dimY()*nbParameters());
for(int i=0; i<dimY(); ++i)
vec jac(nY*nbParameters());
for(int i=0; i<nY; ++i)
{
for(int n=0; n<_n; ++n)
for(int j=0; j<dimY(); ++j)
for(int j=0; j<nY; ++j)
{
// index of the current monochromatic lobe
int index = i*nbParameters() + 4*(n*dimY() + j);
int index = i*nbParameters() + 4*(n*nY + j);
double Cx, Cy, Cz, N;
getCurrentLobe(n, j, Cx, Cy, Cz, N);
......@@ -283,10 +292,10 @@ vec lafortune_function::parametersJacobian(const vec& x) const
}
#ifdef FIT_DIFFUSE
for(int j=0; j<dimY(); ++j)
for(int j=0; j<nY; ++j)
{
// index of the current monochromatic lobe
int index = i*nbParameters() + 4*_n*dimY() + j;
int index = i*nbParameters() + 4*_n*nY + j;
jac[index] = 1.0;
}
......@@ -298,31 +307,33 @@ vec lafortune_function::parametersJacobian(const vec& x) const
void lafortune_function::bootstrap(const ptr<data> d, const arguments& args)
{
const int nY = _parameters.dimY();
// Check the arguments for the number of lobes
this->setNbLobes(args.get_int("lobes", 1));
// Set the diffuse component
vec x0 = d->get(0);
for(int i=0; i<d->dimY(); ++i)
_kd[i] = x0[d->dimX() + i];
for(int i=0; i<d->parametrization().dimY(); ++i)
_kd[i] = x0[d->parametrization().dimX() + i];
for(int i=1; i<d->size(); ++i)
{
vec xi = d->get(i);
for(int j=0; j<d->dimY(); ++j)
_kd[j] = std::min(xi[d->dimX() + j], _kd[j]);
for(int j=0; j<d->parametrization().dimY(); ++j)
_kd[j] = std::min(xi[d->parametrization().dimX() + j], _kd[j]);
}
// The remaining data will be equal to one
for(int n=0; n<_n; ++n)
for(int i=0; i<dimY(); ++i)
for(int i=0; i<_parameters.dimY(); ++i)
{
double theta = 0.5 * M_PI * n / (double)_n;
_C[(n*dimY() + i)*3 + 0] = -sin(theta);
_C[(n*dimY() + i)*3 + 1] = -sin(theta);
_C[(n*dimY() + i)*3 + 2] = cos(theta);
_N[n*dimY() + i] = (double)_n;
_C[(n*nY + i)*3 + 0] = -sin(theta);
_C[(n*nY + i)*3 + 1] = -sin(theta);
_C[(n*nY + i)*3 + 2] = cos(theta);
_N[n*nY + i] = (double)_n;
}
}
......@@ -396,6 +407,7 @@ bool lafortune_function::load(std::istream& in)
setNbLobes(nb_lobes);
// Parse the lobe
const int _nY = _parameters.dimY();
for(int n=0; n<_n; ++n)
{
for(int i=0; i<_nY; ++i)
......@@ -418,6 +430,7 @@ void lafortune_function::save_call(std::ostream& out, const arguments& args) con
{
bool is_alta = !args.is_defined("export") || args["export"] == "alta";
const int _nY = _parameters.dimY();
if(is_alta)
{
out << "#FUNC nonlinear_function_lafortune" << std::endl ;
......
......@@ -21,6 +21,7 @@
#include <core/fitter.h>
#include <core/args.h>
#include <core/common.h>
#include <core/params.h>
using namespace alta;
......@@ -44,7 +45,7 @@ class lafortune_function : public nonlinear_function
public: // methods
lafortune_function(const parameters& params);
lafortune_function(const alta::parameters& params);
// Overload the function operator
virtual vec operator()(const vec& x) const ;
......@@ -103,6 +104,7 @@ class lafortune_function : public nonlinear_function
//! n for the color channel number c.
void getCurrentLobe(int n, int c, double& Cx, double& Cy, double& Cz, double& N) const
{
const int _nY = _parameters.dimY();
if(_isotropic)
{
Cx = _C[(n*_nY + c)*2 + 0];
......@@ -128,11 +130,5 @@ class lafortune_function : public nonlinear_function
//!\brief Flags to get an isotropic lobe
bool _isotropic;
lafortune_function()
: nonlinear_function(6, 0,
params::CARTESIAN, params::UNKNOWN_OUTPUT)
{
};
} ;
......@@ -22,18 +22,18 @@
using namespace alta;
ALTA_DLL_EXPORT function* provide_function(const parameters& params)
ALTA_DLL_EXPORT function* provide_function(const alta::parameters& params)
{
return new spherical_gaussian_function(params);
}
spherical_gaussian_function::spherical_gaussian_function(const parameters& params)
spherical_gaussian_function::spherical_gaussian_function(const alta::parameters& params)
: nonlinear_function(params.set_input(6, params::CARTESIAN)),
_non_a(1), _type(Mirror)
_a(1.0), _type(Mirror)
{
// Update the length of the vectors
_n.resize(_nY) ;
_ks.resize(_nY) ;
_n.resize(_parameters.dimY()) ;
_ks.resize(_parameters.dimY()) ;
}
// Overload the function operator
......@@ -43,10 +43,10 @@ vec spherical_gaussian_function::operator()(const vec& x) const
}
vec spherical_gaussian_function::value(const vec& x) const
{
vec res(dimY());
vec res(_parameters.dimY());
double dot = compute_dot(x);
for(int i=0; i<dimY(); ++i)
for(int i=0; i<_parameters.dimY(); ++i)
{
res[i] = _ks[i] * std::exp(_n[i] * (dot-1));
}
......@@ -95,22 +95,23 @@ int spherical_gaussian_function::nbParameters() const
{
if(_type == Moment)
{
return 2*dimY()+1;
return 2*_parameters.dimY()+1;
}
else
{
return 2*dimY();
return 2*_parameters.dimY();
}
}
//! Get the vector of parameters for the function
vec spherical_gaussian_function::parameters() const
{
const int nY = _parameters.dimY();
if(_type == Moment)
{
vec res(2*dimY()+1);
res[2*dimY()] = _a;
for(int i=0; i<dimY(); ++i)
vec res(2*nY+1);
res[2*nY] = _a;
for(int i=0; i<nY; ++i)
{
res[i*2 + 0] = _ks[i];
res[i*2 + 1] = _n[i];
......@@ -120,8 +121,8 @@ vec spherical_gaussian_function::parameters() const
}
else
{
vec res(2*dimY());
for(int i=0; i<dimY(); ++i)
vec res(2*nY);
for(int i=0; i<nY; ++i)
{
res[i*2 + 0] = _ks[i];
res[i*2 + 1] = _n[i];
......@@ -133,11 +134,12 @@ vec spherical_gaussian_function::parameters() const
//! \brief get the min values for the parameters
vec spherical_gaussian_function::getParametersMin() const
{
const int nY = _parameters.dimY();
if(_type == Moment)
{
vec res(2*dimY()+1);
res[2*dimY()] = 0.0;
for(int i=0; i<dimY(); ++i)
vec res(2*nY+1);
res[2*nY] = 0.0;
for(int i=0; i<nY; ++i)
{
res[i*2 + 0] = 0.0;
res[i*2 + 1] = 0.0;
......@@ -147,8 +149,8 @@ vec spherical_gaussian_function::getParametersMin() const
}
else
{
vec res(2*dimY());
for(int i=0; i<dimY(); ++i)
vec res(2*nY);
for(int i=0; i<nY; ++i)
{
res[i*2 + 0] = 0.0;
res[i*2 + 1] = 0.0;
......@@ -163,10 +165,10 @@ void spherical_gaussian_function::setParameters(const vec& p)
{
if(_type == Moment)
{
_a = p[2*dimY()];
_a = p[2*_parameters.dimY()];
}
for(int i=0; i<dimY(); ++i)
for(int i=0; i<_parameters.dimY(); ++i)
{
_ks[i] = p[i*2 + 0];
_n[i] = p[i*2 + 1];
......@@ -179,10 +181,10 @@ vec spherical_gaussian_function::parametersJacobian(const vec& x) const
{
double dot = compute_dot(x);
vec jac(dimY()*nbParameters());
for(int i=0; i<dimY(); ++i)
vec jac(_parameters.dimY()*nbParameters());
for(int i=0; i<_parameters.dimY(); ++i)
{
for(int j=0; j<dimY(); ++j)
for(int j=0; j<_parameters.dimY(); ++j)
{
if(i == j)
{
......@@ -221,7 +223,7 @@ vec spherical_gaussian_function::parametersJacobian(const vec& x) const
void spherical_gaussian_function::bootstrap(const ptr<data> d, const arguments& args)
{
for(int i=0; i<dimY(); ++i)
for(int i=0; i<_parameters.dimY(); ++i)
{
_ks[i] = 1.0;
_n[i] = 1.0;
......@@ -287,7 +289,7 @@ bool spherical_gaussian_function::load(std::istream& in)
}
// Parse the lobe
for(int i=0; i<_nY; ++i)
for(int i=0; i<_parameters.dimY(); ++i)
{
in >> token >> _ks[i];
...