Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
095cc396
Commit
095cc396
authored
7 years ago
by
Xavier Valls Pla
Committed by
Guilherme Amadio
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add test for TF1 constructors
parent
d6cdaaa8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hist/hist/inc/TF1.h
+1
-1
1 addition, 1 deletion
hist/hist/inc/TF1.h
hist/hist/test/test_tf1.cxx
+42
-0
42 additions, 0 deletions
hist/hist/test/test_tf1.cxx
with
43 additions
and
1 deletion
hist/hist/inc/TF1.h
+
1
−
1
View file @
095cc396
...
@@ -321,7 +321,7 @@ public:
...
@@ -321,7 +321,7 @@ public:
TF1
(
const
char
*
name
,
std
::
function
<
T
(
const
T
*
data
,
const
Double_t
*
param
)
>
&
fcn
,
Double_t
xmin
=
0
,
Double_t
xmax
=
1
,
Int_t
npar
=
0
,
Int_t
ndim
=
1
,
EAddToList
addToGlobList
=
EAddToList
::
kDefault
)
:
TF1
(
const
char
*
name
,
std
::
function
<
T
(
const
T
*
data
,
const
Double_t
*
param
)
>
&
fcn
,
Double_t
xmin
=
0
,
Double_t
xmax
=
1
,
Int_t
npar
=
0
,
Int_t
ndim
=
1
,
EAddToList
addToGlobList
=
EAddToList
::
kDefault
)
:
TF1
(
EFType
::
kTemplScalar
,
name
,
xmin
,
xmax
,
npar
,
ndim
,
addToGlobList
,
new
TF1Parameters
(
npar
),
new
TF1FunctorPointerImpl
<
T
>
(
fcn
))
TF1
(
EFType
::
kTemplScalar
,
name
,
xmin
,
xmax
,
npar
,
ndim
,
addToGlobList
,
new
TF1Parameters
(
npar
),
new
TF1FunctorPointerImpl
<
T
>
(
fcn
))
{
{
fType
=
std
::
is_same
<
T
,
double
>::
value
?
TF1
::
EFType
::
kTemplScalar
:
TF1
::
EFType
::
kTemplVec
;
fType
=
std
::
is_same
<
T
,
double
>::
value
?
TF1
::
EFType
::
kTemplScalar
:
TF1
::
EFType
::
kTemplVec
;
}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
...
...
This diff is collapsed.
Click to expand it.
hist/hist/test/test_tf1.cxx
+
42
−
0
View file @
095cc396
...
@@ -8,6 +8,25 @@
...
@@ -8,6 +8,25 @@
using
namespace
std
;
using
namespace
std
;
class
MyClass
{
public:
double
operator
()(
double
*
x
,
double
*
p
)
{
return
*
x
+
*
p
;
};
};
class
MyClassConst
{
public:
double
operator
()(
const
double
*
x
,
const
double
*
p
)
{
return
*
x
+
*
p
;
};
};
double
func
(
const
double
*
x
,
const
double
*
p
)
{
return
*
x
+
*
p
;
}
double
functionConst
(
const
double
*
x
,
const
double
*
p
)
{
return
*
x
+
*
p
;
}
Float_t
delta
=
0.00000000001
;
Float_t
delta
=
0.00000000001
;
void
coeffNamesGeneric
(
TString
&
formula
,
TObjArray
*
coeffNames
)
void
coeffNamesGeneric
(
TString
&
formula
,
TObjArray
*
coeffNames
)
...
@@ -177,3 +196,26 @@ TEST(TF1, CopyClone)
...
@@ -177,3 +196,26 @@ TEST(TF1, CopyClone)
{
{
test_copyClone
();
test_copyClone
();
}
}
TEST
(
TF1
,
Constructors
)
{
MyClass
testObj
,
testObjConst
;
double
x
=
1
;
double
p
=
1
;
std
::
function
<
double
(
const
double
*
data
,
const
double
*
param
)
>
stdFunction
=
functionConst
;
std
::
vector
<
TF1
>
vtf1
;
vtf1
.
emplace_back
(
TF1
(
"Functor"
,
testObj
,
0
,
1
,
0
));
vtf1
.
emplace_back
(
TF1
(
"FunctorConst"
,
testObjConst
,
0
,
1
,
0
));
vtf1
.
emplace_back
(
TF1
(
"FunctorPtr"
,
&
testObj
,
0
,
1
,
0
));
vtf1
.
emplace_back
(
TF1
(
"FunctorConstPtr"
,
&
testObjConst
,
0
,
1
,
0
));
vtf1
.
emplace_back
(
TF1
(
"function"
,
func
));
vtf1
.
emplace_back
(
TF1
(
"functionConst"
,
functionConst
));
vtf1
.
emplace_back
(
TF1
(
"lambda"
,
[](
double
*
x1
,
double
*
x2
)
{
return
*
x1
+
*
x2
;
}));
vtf1
.
emplace_back
(
TF1
(
"lambdaConst"
,
[](
double
*
x1
,
double
*
x2
)
{
return
*
x1
+
*
x2
;
}));
vtf1
.
emplace_back
(
TF1
(
"stdFunction"
,
stdFunction
));
for
(
auto
tf1
:
vtf1
)
EXPECT_EQ
(
tf1
(
&
x
,
&
p
),
2
);
}
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