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
817a2d90
Commit
817a2d90
authored
Jun 10, 2014
by
Laurent Belcour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correction of the shared pointer affectation issue.
parent
21a54898
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
13 deletions
+38
-13
sources/core/ptr.h
sources/core/ptr.h
+22
-1
sources/core/vertical_segment.cpp
sources/core/vertical_segment.cpp
+1
-1
sources/plugins/rational_fitter_parallel/rational_fitter.cpp
sources/plugins/rational_fitter_parallel/rational_fitter.cpp
+7
-3
sources/softs/data2data/main.cpp
sources/softs/data2data/main.cpp
+8
-8
No files found.
sources/core/ptr.h
View file @
817a2d90
...
...
@@ -81,7 +81,7 @@ template<class T> class ptr
~
ptr
()
{
_counter
->
decrement
();
if
(
_counter
->
value
()
==
0
)
if
(
_counter
->
value
()
<
1
||
_ptr
==
NULL
)
{
if
(
_ptr
!=
NULL
)
{
delete
_ptr
;
}
delete
_counter
;
...
...
@@ -95,6 +95,27 @@ template<class T> class ptr
return
_ptr
;
}
//! Assignment operator. If a valid pointer is already present, its
//! counter is decremented and the pointer and counter might be
//! deleted in case the counter reach zero. Then, the elements of
//! a, both counter and pointer, are copied to this and the counter
//! is incremented.
ptr
<
T
>&
operator
=
(
const
ptr
<
T
>&
a
)
{
_counter
->
decrement
();
if
(
_counter
->
value
()
<
1
)
{
if
(
_ptr
!=
NULL
)
{
delete
_ptr
;
}
delete
_counter
;
}
_counter
=
a
.
_counter
;
_ptr
=
a
.
_ptr
;
_counter
->
increment
();
return
*
this
;
}
//! Raw acces to the pointer. It is sometimes needed to
inline
T
*
get
()
const
{
...
...
sources/core/vertical_segment.cpp
View file @
817a2d90
...
...
@@ -278,7 +278,7 @@ vec vertical_segment::get(int i) const
//! is not already present.
void
vertical_segment
::
set
(
vec
x
)
{
assert
(
x
.
size
()
==
dimX
()
+
dimY
());
// assert(x.size() == dimX() + dimY() || x.size() == dimX() + 3*
dimY());
_data
.
push_back
(
x
);
}
...
...
sources/plugins/rational_fitter_parallel/rational_fitter.cpp
View file @
817a2d90
...
...
@@ -48,14 +48,18 @@ bool rational_fitter_parallel::fit_data(const ptr<data> dat, function* fit, cons
std
::
cerr
<<
"<<WARNING>> we advise you to perform convertion with a separate command."
<<
std
::
endl
;
ptr
<
vertical_segment
>
vs
(
new
vertical_segment
());
vs
->
setDimX
(
dat
->
dimX
());
vs
->
setDimY
(
dat
->
dimY
());
vs
->
setMin
(
dat
->
min
())
;
vs
->
setMax
(
dat
->
max
())
;
for
(
int
i
=
0
;
i
<
dat
->
size
();
++
i
)
{
const
vec
x
=
dat
->
get
(
i
);
vec
y
(
dat
->
dimX
()
+
3
*
dat
->
dimY
());
for
(
int
k
=
0
;
k
<
x
.
size
()
;
++
k
)
{
y
[
k
]
=
x
[
k
];
}
for
(
int
k
=
0
;
k
<
dat
->
dimY
();
++
k
)
{
y
[
k
+
x
.
size
()
+
dat
->
dimY
()]
=
(
1.0
-
args
.
get_float
(
"dt"
,
0.1
))
*
x
[
k
+
dat
->
dimX
()];
}
for
(
int
k
=
0
;
k
<
dat
->
dimY
();
++
k
)
{
y
[
k
+
x
.
size
()
+
2
*
dat
->
dimY
()]
=
(
1.0
+
args
.
get_float
(
"dt"
,
0.1
))
*
x
[
k
+
dat
->
dimX
()];
}
for
(
int
k
=
0
;
k
<
x
.
size
()
;
++
k
)
{
y
[
k
]
=
x
[
k
];
}
for
(
int
k
=
0
;
k
<
dat
->
dimY
();
++
k
)
{
y
[
k
+
dat
->
dimX
()
+
dat
->
dimY
()]
=
(
1.0
-
args
.
get_float
(
"dt"
,
0.1
))
*
x
[
k
+
dat
->
dimX
()];
}
for
(
int
k
=
0
;
k
<
dat
->
dimY
();
++
k
)
{
y
[
k
+
dat
->
dimX
()
+
2
*
dat
->
dimY
()]
=
(
1.0
+
args
.
get_float
(
"dt"
,
0.1
))
*
x
[
k
+
dat
->
dimX
()];
}
vs
->
set
(
y
);
}
...
...
sources/softs/data2data/main.cpp
View file @
817a2d90
...
...
@@ -7,7 +7,7 @@
* or to perform interpolation of sample values (i.e. to fill gaps).
*
* <h3>Usage</h3>
* \verbatim
* \verbatim
data2data --input data.file --output data.file --out-data exporter.so --in-data importer.so
\endverbatim
*
...
...
@@ -96,14 +96,14 @@ int main(int argc, char** argv)
return 1 ;
}
*/
// Import data
ptr
<
data
>
d_in
=
plugins_manager
::
get_data
(
args
[
"in-data"
])
;
d_in
->
load
(
args
[
"input"
],
args
);
ptr
<
data
>
d_out
=
plugins_manager
::
get_data
(
args
[
"out-data"
])
;
if
(
!
d_in
&&
!
d_out
)
{
std
::
cerr
<<
"<<ERROR>> cannot import or export data"
<<
std
::
endl
;
...
...
@@ -136,7 +136,7 @@ int main(int argc, char** argv)
// Copy the input vector
vec
x
=
d_in
->
get
(
i
);
params
::
convert
(
&
x
[
0
],
d_in
->
parametrization
(),
d_out
->
parametrization
(),
&
temp
[
0
]);
for
(
int
j
=
0
;
j
<
d_in
->
dimY
();
++
j
)
{
temp
[
d_out
->
dimX
()
+
j
]
=
x
[
d_in
->
dimX
()
+
j
];
...
...
@@ -144,7 +144,7 @@ int main(int argc, char** argv)
d_out
->
set
(
temp
);
}
}
}
else
{
...
...
@@ -168,8 +168,8 @@ int main(int argc, char** argv)
}
d_out
->
set
(
x
);
}
}
}
}
d_out
->
save
(
args
[
"output"
]);
return
0
;
}
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