Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alta
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alta
alta
Commits
fe046f36
Commit
fe046f36
authored
Oct 21, 2013
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing some bugs in the product function
parent
93b8e937
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
53 deletions
+76
-53
sources/core/function.cpp
sources/core/function.cpp
+12
-3
sources/core/params.cpp
sources/core/params.cpp
+1
-0
sources/plugins/nonlinear_fitter_nlopt/fitter.cpp
sources/plugins/nonlinear_fitter_nlopt/fitter.cpp
+17
-9
sources/plugins/nonlinear_fresnel_normalized_schlick/function.cpp
...plugins/nonlinear_fresnel_normalized_schlick/function.cpp
+13
-20
sources/plugins/nonlinear_fresnel_normalized_schlick/function.h
...s/plugins/nonlinear_fresnel_normalized_schlick/function.h
+21
-17
sources/plugins/plugins.pro
sources/plugins/plugins.pro
+4
-4
sources/softs/data2brdf/main.cpp
sources/softs/data2brdf/main.cpp
+8
-0
No files found.
sources/core/function.cpp
View file @
fe046f36
...
...
@@ -372,7 +372,16 @@ void compound_function::bootstrap(const ::data* d, const arguments& args)
if
(
args
.
is_vec
(
"bootstrap"
))
{
vec
p
=
args
.
get_vec
(
"bootstrap"
,
nbParameters
());
std
::
cout
<<
"<<INFO>> Will use "
<<
p
<<
" as a bootstrap for the non-linear function"
<<
std
::
endl
;
setParameters
(
p
);
for
(
unsigned
int
i
=
0
;
i
<
fs
.
size
();
++
i
)
{
if
(
fs
[
i
]
->
nbParameters
()
==
0
)
{
fs
[
i
]
->
bootstrap
(
d
,
fs_args
[
i
]);
}
}
}
else
{
...
...
@@ -657,7 +666,7 @@ void product_function::setParameters(const vec& p)
vec
f2_params
(
nb_f2_params
);
for
(
int
i
=
0
;
i
<
nb_f2_params
;
++
i
)
{
f2_params
[
i
]
=
p
[
i
+
nb_f
2
_params
];
f2_params
[
i
]
=
p
[
i
+
nb_f
1
_params
];
}
f2
->
setParameters
(
f2_params
);
}
...
...
@@ -720,8 +729,8 @@ vec product_function::parametersJacobian(const vec& x) const
vec
xf
(
f2
->
dimX
());
params
::
convert
(
&
x
[
0
],
f1
->
input_parametrization
(),
f2
->
input_parametrization
(),
&
xf
[
0
]);
vec
f1_jacobian
=
f1
->
parametersJacobian
(
x
f
);
vec
f2_jacobian
=
f2
->
parametersJacobian
(
x
);
vec
f1_jacobian
=
f1
->
parametersJacobian
(
x
);
vec
f2_jacobian
=
f2
->
parametersJacobian
(
x
f
);
vec
f1_value
=
f1
->
value
(
x
);
vec
f2_value
=
f2
->
value
(
xf
);
...
...
sources/core/params.cpp
View file @
fe046f36
...
...
@@ -324,6 +324,7 @@ std::string params::get_name(const params::input param)
return
it
->
second
.
name
;
}
std
::
cerr
<<
"<<ERROR>> Unknown parametrization, "
<<
get_name
(
param
)
<<
" "
<<
__FILE__
<<
":"
<<
__LINE__
<<
std
::
endl
;
return
std
::
string
(
"UNKNOWN_INPUT"
);
}
...
...
sources/plugins/nonlinear_fitter_nlopt/fitter.cpp
View file @
fe046f36
...
...
@@ -150,39 +150,47 @@ bool nonlinear_fitter_nlopt::fit_data(const data* d, function* fit, const argume
nlopt_algorithm
algorithm
;
nlopt_result
res
;
std
::
string
optimizerName
=
args
[
"nlopt-optimizer"
];
if
(
optimizerName
==
"COBYLA"
)
if
(
optimizerName
==
"
local-
COBYLA"
)
{
algorithm
=
NLOPT_LN_COBYLA
;
}
else
if
(
optimizerName
==
"BOBYQA"
)
else
if
(
optimizerName
==
"
local-
BOBYQA"
)
{
algorithm
=
NLOPT_LN_BOBYQA
;
}
else
if
(
optimizerName
==
"NEWUOA"
)
else
if
(
optimizerName
==
"
local-
NEWUOA"
)
{
algorithm
=
NLOPT_LN_NEWUOA_BOUND
;
}
else
if
(
optimizerName
==
"PRAXIS"
)
else
if
(
optimizerName
==
"
local-
PRAXIS"
)
{
algorithm
=
NLOPT_LN_PRAXIS
;
}
else
if
(
optimizerName
==
"Nelder-Mead"
)
else
if
(
optimizerName
==
"
local-
Nelder-Mead"
)
{
algorithm
=
NLOPT_LN_NELDERMEAD
;
}
else
if
(
optimizerName
==
"
Sbp
lx"
)
else
if
(
optimizerName
==
"
local-spb
lx"
)
{
algorithm
=
NLOPT_LN_SBPLX
;
}
else
if
(
optimizerName
==
"
controlled-random-search
"
)
else
if
(
optimizerName
==
"
global-crs
"
)
{
algorithm
=
NLOPT_GN_CRS2_LM
;
}
else
if
(
optimizerName
==
"MMA"
)
else
if
(
optimizerName
==
"global-stogo"
)
{
algorithm
=
NLOPT_GD_STOGO
;
}
else
if
(
optimizerName
==
"global-isres"
)
{
algorithm
=
NLOPT_GN_ISRES
;
}
else
if
(
optimizerName
==
"local-mma"
)
{
algorithm
=
NLOPT_LD_MMA
;
}
else
if
(
optimizerName
==
"
SQP
"
)
else
if
(
optimizerName
==
"
local-sqp
"
)
{
algorithm
=
NLOPT_LD_SLSQP
;
}
...
...
sources/plugins/nonlinear_fresnel_normalized_schlick/function.cpp
View file @
fe046f36
...
...
@@ -14,11 +14,14 @@ ALTA_DLL_EXPORT function* provide_function()
return
new
schlick
();
}
schlick
::
schlick
()
{
setParametrization
(
params
::
CARTESIAN
);
}
//! Load function specific files
bool
schlick
::
load
(
std
::
istream
&
in
)
{
fresnel
::
load
(
in
);
// Parse line until the next comment
while
(
in
.
peek
()
!=
'#'
)
{
...
...
@@ -59,15 +62,6 @@ void schlick::save_call(std::ostream& out, const arguments& args) const
{
bool
is_alta
=
!
args
.
is_defined
(
"export"
)
||
args
[
"export"
]
==
"alta"
;
if
(
is_alta
)
{
f
->
save_call
(
out
,
args
);
}
else
{
out
<<
"("
;
f
->
save_call
(
out
,
args
);
out
<<
")"
;
}
if
(
is_alta
)
{
out
<<
"#FUNC nonlinear_fresnel_normalized_schlick"
<<
std
::
endl
;
...
...
@@ -79,7 +73,7 @@ void schlick::save_call(std::ostream& out, const arguments& args) const
}
else
{
out
<<
"
*
normalized_schlick_fresnel(L, V, N, X, Y, vec3("
;
out
<<
"normalized_schlick_fresnel(L, V, N, X, Y, vec3("
;
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
out
<<
R
[
i
];
...
...
@@ -91,7 +85,6 @@ void schlick::save_call(std::ostream& out, const arguments& args) const
void
schlick
::
save_body
(
std
::
ostream
&
out
,
const
arguments
&
args
)
const
{
f
->
save_body
(
out
,
args
);
bool
is_shader
=
args
[
"export"
]
==
"shader"
||
args
[
"export"
]
==
"explorer"
;
if
(
is_shader
)
...
...
@@ -107,7 +100,7 @@ void schlick::save_body(std::ostream& out, const arguments& args) const
}
vec
schlick
::
fresnelV
alue
(
const
vec
&
x
)
const
vec
schlick
::
v
alue
(
const
vec
&
x
)
const
{
double
xp
[
3
],
cart
[
6
];
params
::
convert
(
&
x
[
0
],
input_parametrization
(),
params
::
RUSIN_VH
,
xp
);
...
...
@@ -125,12 +118,12 @@ vec schlick::fresnelValue(const vec& x) const
}
//! \brief Number of parameters to this non-linear function
int
schlick
::
nb
Fresnel
Parameters
()
const
int
schlick
::
nbParameters
()
const
{
return
dimY
();
}
vec
schlick
::
getFresnelP
arametersMin
()
const
vec
schlick
::
p
arametersMin
()
const
{
vec
m
(
dimY
());
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
m
[
i
]
=
1.0
;
}
...
...
@@ -138,7 +131,7 @@ vec schlick::getFresnelParametersMin() const
}
//! \brief Get the vector of parameters for the function
vec
schlick
::
getFresnelP
arameters
()
const
vec
schlick
::
p
arameters
()
const
{
vec
p
(
dimY
());
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
p
[
i
]
=
R
[
i
];
}
...
...
@@ -146,14 +139,14 @@ vec schlick::getFresnelParameters() const
}
//! \brief Update the vector of parameters for the function
void
schlick
::
set
Fresnel
Parameters
(
const
vec
&
p
)
void
schlick
::
setParameters
(
const
vec
&
p
)
{
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
R
[
i
]
=
p
[
i
];
}
}
//! \brief Obtain the derivatives of the function with respect to the
//! parameters.
vec
schlick
::
getFresnelP
arametersJacobian
(
const
vec
&
x
)
const
vec
schlick
::
p
arametersJacobian
(
const
vec
&
x
)
const
{
const
int
nY
=
dimY
();
double
xp
[
3
],
cart
[
6
];
...
...
@@ -179,7 +172,7 @@ vec schlick::getFresnelParametersJacobian(const vec& x) const
}
void
schlick
::
fresnelB
ootstrap
(
const
data
*
d
,
const
arguments
&
args
)
void
schlick
::
b
ootstrap
(
const
data
*
d
,
const
arguments
&
args
)
{
for
(
int
i
=
0
;
i
<
dimY
();
++
i
)
{
R
[
i
]
=
1.0
;
}
}
sources/plugins/nonlinear_fresnel_normalized_schlick/function.h
View file @
fe046f36
...
...
@@ -12,50 +12,54 @@
#include <core/common.h>
class
schlick
:
public
fresnel
class
schlick
:
public
nonlinear_function
{
public:
// methods
// Constructor
schlick
();
//! \brief Load function specific files
virtual
bool
load
(
std
::
istream
&
in
)
;
virtual
bool
load
(
std
::
istream
&
in
)
;
virtual
void
save_call
(
std
::
ostream
&
out
,
const
arguments
&
args
)
const
;
virtual
void
save_body
(
std
::
ostream
&
out
,
const
arguments
&
args
)
const
;
protected:
// methods
virtual
vec
fresnelValue
(
const
vec
&
x
)
const
;
virtual
vec
operator
()(
const
vec
&
x
)
const
{
return
value
(
x
);
}
virtual
vec
value
(
const
vec
&
x
)
const
;
//! \brief Number of parameters to this non-linear function
virtual
int
nb
Fresnel
Parameters
()
const
;
virtual
int
nbParameters
()
const
;
//! \brief Get the vector of parameters for the function
virtual
vec
getFresnelP
arameters
()
const
;
virtual
vec
p
arameters
()
const
;
//! \brief Update the vector of parameters for the function
virtual
void
set
Fresnel
Parameters
(
const
vec
&
p
)
;
virtual
void
setParameters
(
const
vec
&
p
)
;
//! Get the vector of min parameters for the function
virtual
vec
getFresnelP
arametersMin
()
const
;
virtual
vec
p
arametersMin
()
const
;
//! \brief Obtain the derivatives of the function with respect to the
//! parameters.
virtual
vec
getFresnelP
arametersJacobian
(
const
vec
&
x
)
const
;
virtual
vec
p
arametersJacobian
(
const
vec
&
x
)
const
;
//! \brief Boostrap the function by defining the diffuse term
virtual
void
fresnelB
ootstrap
(
const
data
*
d
,
const
arguments
&
args
);
virtual
void
b
ootstrap
(
const
data
*
d
,
const
arguments
&
args
);
//! \brief resize the parameter vector
virtual
void
setDimY
(
int
nY
)
{
fresnel
::
setDimY
(
nY
);
R
.
resize
(
nY
);
}
//! \brief resize the parameter vector
virtual
void
setDimY
(
int
nY
)
{
nonlinear_function
::
setDimY
(
nY
);
R
.
resize
(
nY
);
}
private:
// data
//! Unidimensional Fresnel reflectance at theta = 0
vec
R
;
vec
R
;
}
;
sources/plugins/plugins.pro
View file @
fe046f36
...
...
@@ -11,11 +11,11 @@ SUBDIRS = \
rational_function_chebychev
\
rational_function_legendre
\
nonlinear_fitter_eigen
\
#
nonlinear_fitter_ceres
\
#
nonlinear_fitter_ipopt
\
#
nonlinear_fitter_nlopt
\
nonlinear_fitter_ceres
\
nonlinear_fitter_ipopt
\
nonlinear_fitter_nlopt
\
nonlinear_fresnel_schlick
\
#
nonlinear_fresnel_normalized_schlick
\
nonlinear_fresnel_normalized_schlick
\
nonlinear_fresnel_retroschlick
\
nonlinear_function_diffuse
\
nonlinear_function_blinn
\
...
...
sources/softs/data2brdf/main.cpp
View file @
fe046f36
...
...
@@ -11,10 +11,18 @@
#include <limits>
#include <cstdlib>
#ifdef __linux__
#include <fenv.h>
#endif
int
main
(
int
argc
,
char
**
argv
)
{
arguments
args
(
argc
,
argv
)
;
#ifdef __linux__
//feenableexcept(FE_DIVBYZERO | FE_OVERFLOW | FE_INVALID);
#endif
fitter
*
fit
=
plugins_manager
::
get_fitter
(
args
[
"fitter"
])
;
if
(
fit
==
NULL
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment