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
c69f5c29
Commit
c69f5c29
authored
3 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
Histogram2D: template -> regular
parent
3ecd7694
No related branches found
No related tags found
1 merge request
!237
ArrayUtils now w/o templates
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Device/Histo/Histogram2D.cpp
+14
-0
14 additions, 0 deletions
Device/Histo/Histogram2D.cpp
Device/Histo/Histogram2D.h
+1
-15
1 addition, 15 deletions
Device/Histo/Histogram2D.h
with
15 additions
and
15 deletions
Device/Histo/Histogram2D.cpp
+
14
−
0
View file @
c69f5c29
...
...
@@ -44,6 +44,20 @@ Histogram2D::Histogram2D(std::vector<std::vector<double>> data)
this
->
setContent
(
data
);
}
void
Histogram2D
::
initFromShape
(
const
std
::
vector
<
std
::
vector
<
double
>>&
data
)
{
auto
shape
=
DataUtils
::
Array
::
getShape
(
data
);
const
size_t
nrows
=
shape
.
first
;
const
size_t
ncols
=
shape
.
second
;
if
(
nrows
==
0
||
ncols
==
0
)
throw
std
::
runtime_error
(
"Histogram2D::Histogram2D() -> Error. "
"Not a two-dimensional numpy array"
);
m_data
.
addAxis
(
FixedBinAxis
(
"x-axis"
,
ncols
,
0.0
,
static_cast
<
double
>
(
ncols
)));
m_data
.
addAxis
(
FixedBinAxis
(
"y-axis"
,
nrows
,
0.0
,
static_cast
<
double
>
(
nrows
)));
}
Histogram2D
*
Histogram2D
::
clone
()
const
{
return
new
Histogram2D
(
*
this
);
...
...
This diff is collapsed.
Click to expand it.
Device/Histo/Histogram2D.h
+
1
−
15
View file @
c69f5c29
...
...
@@ -100,7 +100,7 @@ public:
void
addContent
(
const
std
::
vector
<
std
::
vector
<
double
>>&
data
);
protected
:
template
<
typename
T
>
void
initFromShape
(
const
T
&
data
);
void
initFromShape
(
const
std
::
vector
<
std
::
vector
<
double
>>
&
data
);
//! Creates projection along X. The projections is made by collecting the data in the range
//! between [ybinlow, ybinup].
...
...
@@ -111,18 +111,4 @@ protected:
Histogram1D
*
create_projectionY
(
int
xbinlow
,
int
xbinup
);
};
template
<
typename
T
>
void
Histogram2D
::
initFromShape
(
const
T
&
data
)
{
auto
shape
=
DataUtils
::
Array
::
getShape
(
data
);
const
size_t
nrows
=
shape
.
first
;
const
size_t
ncols
=
shape
.
second
;
if
(
nrows
==
0
||
ncols
==
0
)
throw
std
::
runtime_error
(
"Histogram2D::Histogram2D() -> Error. "
"Not a two-dimensional numpy array"
);
m_data
.
addAxis
(
FixedBinAxis
(
"x-axis"
,
ncols
,
0.0
,
static_cast
<
double
>
(
ncols
)));
m_data
.
addAxis
(
FixedBinAxis
(
"y-axis"
,
nrows
,
0.0
,
static_cast
<
double
>
(
nrows
)));
}
#endif // BORNAGAIN_DEVICE_HISTO_HISTOGRAM2D_H
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