Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
a2e8c970
Commit
a2e8c970
authored
2 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
replace addAxis, and simplify
parent
53263ac3
No related branches found
No related tags found
1 merge request
!890
set axes in Powerfield creator
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Device/Data/DataUtils.cpp
+16
-17
16 additions, 17 deletions
Device/Data/DataUtils.cpp
with
16 additions
and
17 deletions
Device/Data/DataUtils.cpp
+
16
−
17
View file @
a2e8c970
...
...
@@ -71,24 +71,21 @@ DataUtils::Data::createRearrangedDataSet(const Powerfield<double>& data, int n)
n
=
(
4
+
n
%
4
)
%
4
;
if
(
n
==
0
)
return
std
::
unique_ptr
<
Powerfield
<
double
>>
(
data
.
clone
());
std
::
unique_ptr
<
Powerfield
<
double
>>
output
(
new
Powerfield
<
double
>
());
// swapping axes if necessary
const
IAxis
&
x_axis
=
data
.
axis
(
0
);
const
IAxis
&
y_axis
=
data
.
axis
(
1
);
output
->
addAxis
(
n
==
2
?
x_axis
:
y_axis
);
output
->
addAxis
(
n
==
2
?
y_axis
:
x_axis
);
// creating index mapping
std
::
unique_ptr
<
Powerfield
<
double
>>
output
;
std
::
function
<
void
(
std
::
vector
<
int
>&
)
>
index_mapping
;
if
(
n
==
2
)
{
const
int
end_bin_x
=
static_cast
<
int
>
(
x_axis
.
size
())
-
1
;
const
int
end_bin_y
=
static_cast
<
int
>
(
y_axis
.
size
())
-
1
;
if
(
n
==
2
)
{
output
.
reset
(
new
Powerfield
<
double
>
({
data
.
axis
(
0
).
clone
(),
data
.
axis
(
1
).
clone
()}));
const
int
end_bin_x
=
static_cast
<
int
>
(
data
.
axis
(
0
).
size
())
-
1
;
const
int
end_bin_y
=
static_cast
<
int
>
(
data
.
axis
(
1
).
size
())
-
1
;
index_mapping
=
[
end_bin_x
,
end_bin_y
](
std
::
vector
<
int
>&
inds
)
{
inds
[
0
]
=
end_bin_x
-
inds
[
0
];
inds
[
1
]
=
end_bin_y
-
inds
[
1
];
};
}
else
{
output
.
reset
(
new
Powerfield
<
double
>
({
data
.
axis
(
1
).
clone
(),
data
.
axis
(
0
).
clone
()}));
const
size_t
rev_axis_i
=
n
%
3
;
const
size_t
end_bin
=
data
.
axis
(
rev_axis_i
).
size
()
-
1
;
index_mapping
=
[
rev_axis_i
,
end_bin
](
std
::
vector
<
int
>&
inds
)
{
...
...
@@ -116,15 +113,16 @@ DataUtils::Data::createClippedDataSet(const Powerfield<double>& origin, double x
throw
std
::
runtime_error
(
"DataUtils::Data::createClippedData()"
" -> Error! Works only on two-dimensional data"
);
std
::
unique_ptr
<
Powerfield
<
double
>>
result
(
new
Powerfield
<
double
>
)
;
std
::
vector
<
IAxis
*>
axes
;
for
(
size_t
i_axis
=
0
;
i_axis
<
origin
.
rank
();
i_axis
++
)
{
std
::
unique_ptr
<
IAxis
>
new_axis
{
origin
.
axis
(
i_axis
).
clone
()
}
;
IAxis
*
new_axis
=
origin
.
axis
(
i_axis
).
clone
();
if
(
i_axis
==
0
)
new_axis
->
clip
(
x1
,
x2
);
else
new_axis
->
clip
(
y1
,
y2
);
result
->
addAxis
(
*
new_axis
);
axes
.
emplace_back
(
new_axis
);
}
std
::
unique_ptr
<
Powerfield
<
double
>>
result
(
new
Powerfield
<
double
>
(
axes
));
result
->
setAllTo
(
0.0
);
Powerfield
<
double
>::
const_iterator
it_origin
=
origin
.
begin
();
...
...
@@ -216,12 +214,13 @@ DataUtils::Data::create2DArrayfromPowerfield(const Powerfield<double>& data)
std
::
unique_ptr
<
Powerfield
<
double
>>
DataUtils
::
Data
::
createPowerfieldfrom2DArray
(
const
std
::
vector
<
std
::
vector
<
double
>>&
array_2d
)
{
std
::
unique_ptr
<
Powerfield
<
double
>>
result
(
new
Powerfield
<
double
>
);
size_t
nrows
=
array_2d
.
size
();
size_t
ncols
=
array_2d
[
0
].
size
();
result
->
addAxis
(
"x"
,
nrows
,
0.0
,
double
(
nrows
));
result
->
addAxis
(
"y"
,
ncols
,
0.0
,
double
(
ncols
));
std
::
unique_ptr
<
Powerfield
<
double
>>
result
(
new
Powerfield
<
double
>
(
FixedBinAxis
(
"x"
,
nrows
,
0.0
,
double
(
nrows
)),
FixedBinAxis
(
"y"
,
ncols
,
0.0
,
double
(
ncols
))));
std
::
vector
<
unsigned
>
axes_indices
(
2
);
for
(
unsigned
row
=
0
;
row
<
nrows
;
row
++
)
{
for
(
unsigned
col
=
0
;
col
<
ncols
;
col
++
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment