Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
alta
alta
Commits
f4b15b4c
Commit
f4b15b4c
authored
Jul 17, 2013
by
Laurent Belcour
Browse files
Function can be loaded with the same param in and out
parent
d3fccb69
Changes
4
Hide whitespace changes
Inline
Side-by-side
sources/core/function.h
View file @
f4b15b4c
...
...
@@ -128,10 +128,11 @@ class function
//! defined one.
virtual
void
setParametrization
(
params
::
input
new_param
)
{
if
(
_in_param
!=
params
::
UNKNOWN_INPUT
)
if
(
_in_param
==
new_param
||
_in_param
==
params
::
UNKNOWN_INPUT
)
_in_param
=
new_param
;
else
throw
(
"A parametrization is already defined"
);
_in_param
=
new_param
;
}
//! \brief can set the output parametrization of a non-parametrized
...
...
@@ -139,10 +140,11 @@ class function
//! defined one.
virtual
void
setParametrization
(
params
::
output
new_param
)
{
if
(
_out_param
!=
params
::
UNKNOWN_OUTPUT
)
if
(
_out_param
==
new_param
||
_out_param
==
params
::
UNKNOWN_OUTPUT
)
_out_param
=
new_param
;
else
throw
(
"A parametrization is already defined"
);
_out_param
=
new_param
;
}
protected:
// function
...
...
sources/core/rational_function.cpp
View file @
f4b15b4c
...
...
@@ -308,6 +308,8 @@ void rational_function::load(const std::string& filename)
{
std
::
string
param
;
linestream
>>
param
;
setParametrization
(
params
::
parse_input
(
param
));
}
continue
;
...
...
sources/core/rational_function.h
View file @
f4b15b4c
...
...
@@ -44,28 +44,31 @@ class rational_function : public QObject, public function
const
std
::
vector
<
double
>&
in_b
)
;
// Get the coefficients
virtual
double
getP
(
int
i
)
const
{
return
a
[
i
]
;
}
virtual
double
getQ
(
int
i
)
const
{
return
b
[
i
]
;
}
virtual
double
getP
(
int
i
)
const
{
return
a
[
i
];
}
virtual
double
getQ
(
int
i
)
const
{
return
b
[
i
];
}
virtual
std
::
vector
<
double
>
getP
()
const
{
return
a
;
}
virtual
std
::
vector
<
double
>
getQ
()
const
{
return
b
;
}
// STL stream ouput
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
rational_function
&
r
)
;
static
int
estimate_dk
(
int
k
,
int
d
);
static
void
populate
(
std
::
vector
<
int
>&
vec
,
int
N
,
int
M
,
int
j
);
static
int
estimate_dk
(
int
k
,
int
d
);
static
void
populate
(
std
::
vector
<
int
>&
vec
,
int
N
,
int
M
,
int
j
);
//! \brief Output the rational function as a gnuplot file. It requires
//! the data object to output the function at the input location only.
virtual
void
save_gnuplot
(
const
std
::
string
&
filename
,
const
data
*
d
,
const
arguments
&
args
)
const
;
//! \brief Output the rational function as a gnuplot file. It requires
//! the data object to output the function at the input location only.
virtual
void
save_gnuplot
(
const
std
::
string
&
filename
,
const
data
*
d
,
const
arguments
&
args
)
const
;
protected:
// functions
//! Convert a 1D index into a vector of degree for a
//! multinomial coeffcient. The resulting vector v should
//! be used as prod_k x[k]^v[k] for the monomial basis
//! Convert a 1D index into a vector of degree for a
//! multinomial coeffcient. The resulting vector v should
//! be used as prod_k x[k]^v[k] for the monomial basis
std
::
vector
<
int
>
index2degree
(
int
i
)
const
;
//! \brief Save the rational function to the rational format (see \ref formating).
virtual
void
save
(
const
std
::
string
&
filename
)
const
;
virtual
void
save
(
const
std
::
string
&
filename
)
const
;
//! \brief Output the rational function using a C++ function formating.
virtual
void
save_cpp
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
const
;
...
...
sources/plugins/rational_fitter_dca/rational_fitter.cpp
View file @
f4b15b4c
...
...
@@ -194,6 +194,7 @@ bool rational_fitter_dca::fit_data(const data* d, int np, int nq, rational_funct
engPutVariable
(
ep
,
"l"
,
l
);
double
delta_k
;
unsigned
int
nb_passes
=
1
;
// Loop until you get a converge solution \delta > \delta_k
do
...
...
@@ -322,6 +323,10 @@ bool rational_fitter_dca::fit_data(const data* d, int np, int nq, rational_funct
b
.
push_back
(
val
[
i
])
;
}
}
std
::
vector
<
double
>
tempP
=
r
->
getP
();
std
::
vector
<
double
>
tempQ
=
r
->
getQ
();
r
->
update
(
a
,
b
)
;
#ifdef DEBUG
std
::
cout
<<
"<<DEBUG>> current rational function: "
<<
*
r
<<
std
::
endl
;
...
...
@@ -330,8 +335,19 @@ bool rational_fitter_dca::fit_data(const data* d, int np, int nq, rational_funct
// Compute the new delta_k, the distance to the data points
delta
=
distance
(
r
,
d
);
//delta = val[(np+nq)*nY];
// Stopping condition if the optimization did not manage to improve the
// L_inf norm quit !
if
(
delta
>
delta_k
)
{
r
->
update
(
tempP
,
tempQ
);
break
;
}
}
while
(
delta
<=
delta_k
);
++
nb_passes
;
}
while
(
true
);
mxDestroyArray
(
f
);
mxDestroyArray
(
A
);
...
...
@@ -339,7 +355,16 @@ bool rational_fitter_dca::fit_data(const data* d, int np, int nq, rational_funct
mxDestroyArray
(
u
);
mxDestroyArray
(
l
);
return
true
;
if
(
nb_passes
==
1
)
{
std
::
cout
<<
"<<ERROR>> Could no optimize with respect to Linf"
<<
std
::
endl
;
return
false
;
}
else
{
std
::
cout
<<
"<<INFO>> Used "
<<
nb_passes
<<
" passes to optimize the solution"
<<
std
::
endl
;
return
true
;
}
}
Q_EXPORT_PLUGIN2
(
rational_fitter_dca
,
rational_fitter_dca
)
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