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
8a5f12df
Commit
8a5f12df
authored
Apr 19, 2013
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding export function for the rational function
parent
c39cda9b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
30 deletions
+38
-30
sources/core/function.h
sources/core/function.h
+8
-8
sources/core/rational_function.cpp
sources/core/rational_function.cpp
+19
-17
sources/core/rational_function.h
sources/core/rational_function.h
+6
-5
sources/plugins/rational_fitter_quadprog/rational_fitter.cpp
sources/plugins/rational_fitter_quadprog/rational_fitter.cpp
+5
-0
No files found.
sources/core/function.h
View file @
8a5f12df
...
...
@@ -114,29 +114,29 @@ class function
protected:
// function
//! \brief Standard saving function.
virtual
void
save
(
const
std
::
string
&
filename
)
const
{
NOT_IMPLEMENTED
();
virtual
void
save
(
const
std
::
string
&
filename
)
const
{
NOT_IMPLEMENTED
();
}
//! \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
const
arguments
&
args
)
const
{
NOT_IMPLEMENTED
();
}
//! \brief Output the rational function using a C++ function formating.
virtual
void
save_cpp
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
const
{
{
NOT_IMPLEMENTED
();
}
//! \brief Output the rational function using a C++ function formating.
virtual
void
save_matlab
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
const
{
NOT_IMPLEMENTED
();
{
NOT_IMPLEMENTED
();
}
...
...
sources/core/rational_function.cpp
View file @
8a5f12df
...
...
@@ -357,7 +357,10 @@ void rational_function::save_matlab(const std::string& filename, const arguments
std
::
ofstream
file
(
filename
.
c_str
(),
std
::
ios_base
::
trunc
);
file
<<
"global s = ["
;
file
<<
"function y = brdf(x)"
<<
std
::
endl
;
file
<<
std
::
endl
;
file
<<
"
\t
s = ["
;
for
(
int
i
=
0
;
i
<
dimX
();
++
i
)
{
file
<<
1.0
/
(
_max
[
i
]
-
_min
[
i
]);
...
...
@@ -367,7 +370,7 @@ void rational_function::save_matlab(const std::string& filename, const arguments
}
}
file
<<
"];"
<<
std
::
endl
;
file
<<
"
global
c = ["
;
file
<<
"
\t
c = ["
;
for
(
int
i
=
0
;
i
<
dimX
();
++
i
)
{
file
<<
_min
[
i
];
...
...
@@ -379,33 +382,31 @@ void rational_function::save_matlab(const std::string& filename, const arguments
file
<<
"];"
<<
std
::
endl
;
file
<<
std
::
endl
;
file
<<
"function y = brdf(x)"
<<
std
::
endl
;
file
<<
std
::
endl
;
file
<<
"
\t
p, q;"
<<
std
::
endl
;
// Export each color channel independantly
for
(
int
j
=
0
;
j
<
dimY
();
++
j
)
{
// Export the numerator of the jth color channel
file
<<
"
\t
p = "
;
file
<<
"
\t
p
("
<<
j
+
1
<<
",:)
= "
;
for
(
unsigned
int
i
=
0
;
i
<
np
;
++
i
)
{
if
(
i
>
0
&&
a
[
np
*
j
+
i
]
>=
0.0
)
{
file
<<
" + "
;
}
else
if
(
a
[
np
*
j
+
i
]
<
0.0
)
file
<<
" "
;
file
<<
a
[
np
*
j
+
i
];
std
::
vector
<
int
>
degree
=
index2degree
(
i
);
for
(
unsigned
int
k
=
0
;
k
<
degree
.
size
();
++
k
)
{
file
<<
"*l(2.0*((x\["
<<
k
<<
"\]-c["
<<
k
<<
"])/s["
<<
k
<<
"] - 0.5), "
<<
degree
[
k
]
<<
")"
;
file
<<
".*legendrepoly("
<<
degree
[
k
]
<<
", 2.0*((x("
<<
k
+
1
<<
",:)"
<<
"-c("
<<
k
+
1
<<
"))/s("
<<
k
+
1
<<
") - 0.5))"
;
}
}
file
<<
";"
<<
std
::
endl
;
// Export the denominator of the jth color channel
file
<<
"
\t
q = "
;
file
<<
"
\t
q
("
<<
j
+
1
<<
",:)
= "
;
for
(
unsigned
int
i
=
0
;
i
<
nq
;
++
i
)
{
if
(
i
>
0
&&
b
[
np
*
j
+
i
]
>=
0.0
)
...
...
@@ -418,12 +419,13 @@ void rational_function::save_matlab(const std::string& filename, const arguments
std
::
vector
<
int
>
degree
=
index2degree
(
i
);
for
(
unsigned
int
k
=
0
;
k
<
degree
.
size
();
++
k
)
{
file
<<
"*l(2.0*((x\["
<<
k
<<
"\]-c["
<<
k
<<
"])/s["
<<
k
<<
"] - 0.5), "
<<
degree
[
k
]
<<
")"
;
file
<<
".*legendrepoly("
<<
degree
[
k
]
<<
", 2.0*((x("
<<
k
+
1
<<
",:)"
<<
"-c("
<<
k
+
1
<<
"))/s("
<<
k
+
1
<<
") - 0.5))"
;
}
}
file
<<
";"
<<
std
::
endl
;
file
<<
"
\t
y
["
<<
j
<<
"] = p
/q;"
<<
std
::
endl
;
file
<<
"
\t
y
("
<<
j
+
1
<<
",:) = p.
/q;"
<<
std
::
endl
;
if
(
j
<
dimY
()
-
1
)
{
file
<<
std
::
endl
;
...
...
@@ -479,7 +481,7 @@ void rational_function::save_cpp(const std::string& filename, const arguments& a
file
<<
" }"
<<
std
::
endl
;
file
<<
" else"
<<
std
::
endl
;
file
<<
" {"
<<
std
::
endl
;
file
<<
" return ((2*i-1)*x*l
egendre(x, i-1) - (i-1)*legendre
(x, i-2)) / (double)i ;"
<<
std
::
endl
;
file
<<
" return ((2*i-1)*x*l
(x, i-1) - (i-1)*l
(x, i-2)) / (double)i ;"
<<
std
::
endl
;
file
<<
" }"
<<
std
::
endl
;
file
<<
"}"
<<
std
::
endl
;
file
<<
std
::
endl
;
...
...
@@ -504,7 +506,7 @@ void rational_function::save_cpp(const std::string& filename, const arguments& a
std
::
vector
<
int
>
degree
=
index2degree
(
i
);
for
(
unsigned
int
k
=
0
;
k
<
degree
.
size
();
++
k
)
{
file
<<
"*l(2.0*((x\["
<<
k
<<
"\]-c["
<<
k
<<
"])
/
s["
<<
k
<<
"] - 0.5), "
<<
degree
[
k
]
<<
")"
;
file
<<
"*l(2.0*((x\["
<<
k
<<
"\]-c["
<<
k
<<
"])
*
s["
<<
k
<<
"] - 0.5), "
<<
degree
[
k
]
<<
")"
;
}
}
file
<<
";"
<<
std
::
endl
;
...
...
@@ -523,7 +525,7 @@ void rational_function::save_cpp(const std::string& filename, const arguments& a
std
::
vector
<
int
>
degree
=
index2degree
(
i
);
for
(
unsigned
int
k
=
0
;
k
<
degree
.
size
();
++
k
)
{
file
<<
"*l(2.0*((x\["
<<
k
<<
"\]-c["
<<
k
<<
"])
/
s["
<<
k
<<
"] - 0.5), "
<<
degree
[
k
]
<<
")"
;
file
<<
"*l(2.0*((x\["
<<
k
<<
"\]-c["
<<
k
<<
"])
*
s["
<<
k
<<
"] - 0.5), "
<<
degree
[
k
]
<<
")"
;
}
}
file
<<
";"
<<
std
::
endl
;
...
...
@@ -568,7 +570,7 @@ void rational_function::save(const std::string& filename) const
file
<<
"#DIM "
<<
_nX
<<
" "
<<
_nY
<<
std
::
endl
;
file
<<
"#NP "
<<
a
.
size
()
/
_nY
<<
std
::
endl
;
file
<<
"#NQ "
<<
b
.
size
()
/
_nY
<<
std
::
endl
;
file
<<
"#BASIS LEGENDRE"
<<
std
::
endl
;
file
<<
"#BASIS LEGENDRE"
<<
std
::
endl
;
unsigned
int
np
=
a
.
size
()
/
_nY
;
unsigned
int
nq
=
b
.
size
()
/
_nY
;
...
...
sources/core/rational_function.h
View file @
8a5f12df
...
...
@@ -38,7 +38,6 @@ class rational_function : public QObject, public function
// IO function to text files
virtual
void
load
(
const
std
::
string
&
filename
)
;
virtual
void
save
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
const
;
// Update the function
virtual
void
update
(
const
std
::
vector
<
double
>&
in_a
,
...
...
@@ -59,15 +58,17 @@ class rational_function : public QObject, public function
std
::
vector
<
int
>
index2degree
(
int
i
)
const
;
//! \brief Save the rational function to the rational format (see \ref formating).
void
save
(
const
std
::
string
&
filename
)
const
;
v
irtual
v
oid
save
(
const
std
::
string
&
filename
)
const
;
//! \brief Output the rational function as a gnuplot file. It requires
//! the data object to output the function at the input location only.
void
save_gnuplot
(
const
std
::
string
&
filename
,
const
data
*
d
,
const
arguments
&
args
)
const
;
virtual
void
save_gnuplot
(
const
std
::
string
&
filename
,
const
data
*
d
,
const
arguments
&
args
)
const
;
//! \brief Output the rational function using a C++ function formating.
void
save_cpp
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
const
;
virtual
void
save_cpp
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
const
;
//! \brief Output the rational function using a C++ function formating.
void
save_matlab
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
const
;
v
irtual
v
oid
save_matlab
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
const
;
protected:
// data
...
...
sources/plugins/rational_fitter_quadprog/rational_fitter.cpp
View file @
8a5f12df
...
...
@@ -19,6 +19,11 @@
using
namespace
std
;
fitter
*
provide_fitter
()
{
return
new
rational_fitter_quadprog
();
}
data
*
rational_fitter_quadprog
::
provide_data
()
const
{
return
new
vertical_segment
()
;
...
...
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