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
5c944269
Commit
5c944269
authored
Apr 17, 2013
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding correct parsing of the input param
parent
ca5ea84a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
123 additions
and
99 deletions
+123
-99
sources/core/data.h
sources/core/data.h
+111
-93
sources/core/vertical_segment.cpp
sources/core/vertical_segment.cpp
+12
-6
No files found.
sources/core/data.h
View file @
5c944269
...
...
@@ -14,7 +14,7 @@
*/
class
data
{
public:
// methods
public:
// methods
// Load data from a file
virtual
void
load
(
const
std
::
string
&
filename
)
=
0
;
...
...
@@ -35,18 +35,36 @@ class data
virtual
vec
min
()
const
=
0
;
virtual
vec
max
()
const
=
0
;
virtual
int
dimX
()
const
{
return
_nX
;
}
virtual
int
dimY
()
const
{
return
_nY
;
}
virtual
int
dimX
()
const
{
return
_nX
;
}
virtual
int
dimY
()
const
{
return
_nY
;
}
virtual
params
::
input
parametrization
()
const
{
return
params
::
UNKNOWN_INPUT
;
}
protected:
// data
//! \brief provide the parametrization of the function.
//! \note some function type can modify the parametrization to adapt
//! to the data.
virtual
params
::
input
parametrization
()
const
{
return
_in_param
;
}
//! \brief can set the input parametrization of a non-parametrized
//! function. Throw an exception if it tries to erase a previously
//! defined one.
virtual
void
setParametrization
(
params
::
input
new_param
)
{
if
(
_in_param
!=
params
::
UNKNOWN_INPUT
)
throw
(
"A parametrization is already defined"
);
_in_param
=
new_param
;
}
protected:
// data
// Dimensions of the data
// Dimensions of the data
int
_nX
,
_nY
;
// Input and output parametrization
params
::
input
_in_param
;
params
::
output
_out_param
;
}
;
Q_DECLARE_INTERFACE
(
data
,
"Fitter.Data"
)
...
...
@@ -60,87 +78,87 @@ Q_DECLARE_INTERFACE(data, "Fitter.Data")
*/
class
data_params
:
public
data
{
public:
// structures
//! \brief when changing from a parametrization to another, you might
//! lose some dimensions. This list enumerate the different operators
//! that can be applied on the raw data to be clusterized.
//! \note by default we use <em>none</em>, but if the input space
//! dimension is reduced, the program will halt.
enum
clustrering
{
MEAN
,
MEDIAN
,
NONE
};
public:
// methods
//! \brief contructor requires the definition of a base class that
//! has a parametrization, and a new parametrization.
data_params
(
const
data
*
d
,
params
::
input
param
,
data_params
::
clustrering
method
=
data_params
::
NONE
)
:
_d
(
d
),
_param_in
(
param
),
_clustering_method
(
method
)
{
_nX
=
params
::
dimension
(
param
);
_nY
=
d
->
dimY
();
if
(
_nX
<
_d
->
dimX
()
&&
method
==
data_params
::
NONE
)
{
throw
(
"No cluster method provided"
);
}
}
// Load data from a file
virtual
void
load
(
const
std
::
string
&
filename
)
{
std
::
cerr
<<
"<<ERROR>> this data type cannot load data"
<<
std
::
endl
;
throw
;
}
virtual
void
load
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
{
std
::
cerr
<<
"<<ERROR>> this data type cannot load data"
<<
std
::
endl
;
throw
;
}
// Acces to data
virtual
vec
get
(
int
i
)
const
{
vec
res
(
_nX
+
_nY
);
vec
in
=
_d
->
get
(
i
);
params
::
convert
(
&
in
[
0
],
_d
->
parametrization
(),
_param_in
,
&
res
[
0
]);
memcpy
(
&
res
[
_nX
],
&
in
[
_d
->
dimX
()],
_nY
*
sizeof
(
double
));
return
res
;
}
virtual
vec
operator
[](
int
i
)
const
{
return
this
->
get
(
i
);
}
// Get data size, e.g. the number of samples to fit
virtual
int
size
()
const
{
return
_d
->
size
();
}
// Get min and max input space values
virtual
vec
min
()
const
{
return
_d
->
min
();
}
virtual
vec
max
()
const
{
return
_d
->
max
();
}
protected:
// data
const
data
*
_d
;
params
::
input
_param_in
;
data_params
::
clustrering
_clustering_method
;
//! \todo Add a cluster object that will duplicate data or store indices.
public:
// structures
//! \brief when changing from a parametrization to another, you might
//! lose some dimensions. This list enumerate the different operators
//! that can be applied on the raw data to be clusterized.
//! \note by default we use <em>none</em>, but if the input space
//! dimension is reduced, the program will halt.
enum
clustrering
{
MEAN
,
MEDIAN
,
NONE
};
public:
// methods
//! \brief contructor requires the definition of a base class that
//! has a parametrization, and a new parametrization.
data_params
(
const
data
*
d
,
params
::
input
param
,
data_params
::
clustrering
method
=
data_params
::
NONE
)
:
_d
(
d
),
_param_in
(
param
),
_clustering_method
(
method
)
{
_nX
=
params
::
dimension
(
param
);
_nY
=
d
->
dimY
();
if
(
_nX
<
_d
->
dimX
()
&&
method
==
data_params
::
NONE
)
{
throw
(
"No cluster method provided"
);
}
}
// Load data from a file
virtual
void
load
(
const
std
::
string
&
filename
)
{
std
::
cerr
<<
"<<ERROR>> this data type cannot load data"
<<
std
::
endl
;
throw
;
}
virtual
void
load
(
const
std
::
string
&
filename
,
const
arguments
&
args
)
{
std
::
cerr
<<
"<<ERROR>> this data type cannot load data"
<<
std
::
endl
;
throw
;
}
// Acces to data
virtual
vec
get
(
int
i
)
const
{
vec
res
(
_nX
+
_nY
);
vec
in
=
_d
->
get
(
i
);
params
::
convert
(
&
in
[
0
],
_d
->
parametrization
(),
_param_in
,
&
res
[
0
]);
memcpy
(
&
res
[
_nX
],
&
in
[
_d
->
dimX
()],
_nY
*
sizeof
(
double
));
return
res
;
}
virtual
vec
operator
[](
int
i
)
const
{
return
this
->
get
(
i
);
}
// Get data size, e.g. the number of samples to fit
virtual
int
size
()
const
{
return
_d
->
size
();
}
// Get min and max input space values
virtual
vec
min
()
const
{
return
_d
->
min
();
}
virtual
vec
max
()
const
{
return
_d
->
max
();
}
protected:
// data
const
data
*
_d
;
params
::
input
_param_in
;
data_params
::
clustrering
_clustering_method
;
//! \todo Add a cluster object that will duplicate data or store indices.
};
sources/core/vertical_segment.cpp
View file @
5c944269
...
...
@@ -72,12 +72,18 @@ void vertical_segment::load(const std::string& filename, const arguments& args)
linestream
>>
t
;
vs
[
current_vs
]
=
t
;
++
current_vs
;
}
else
if
(
comment
==
std
::
string
(
"PARAM_IN"
))
{
}
else
if
(
comment
==
std
::
string
(
"PARAM_OUT"
))
{
}
else
if
(
comment
==
std
::
string
(
"PARAM_IN"
))
{
std
::
string
param
;
linestream
>>
param
;
_in_param
=
params
::
parse_input
(
param
);
}
else
if
(
comment
==
std
::
string
(
"PARAM_OUT"
))
{
std
::
string
param
;
linestream
>>
param
;
_out_param
=
params
::
parse_output
(
param
);
}
continue
;
}
else
if
(
line
.
empty
())
...
...
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