Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Frida
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
Container Registry
Model registry
Operate
Environments
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
Coenen, Joachim
Frida
Commits
4ed895f9
Commit
4ed895f9
authored
12 years ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
sort class members, comments, prepare for precomputed grid step
parent
73fc3f01
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
pub/src/expr.cpp
+72
-59
72 additions, 59 deletions
pub/src/expr.cpp
pub/src/expr.h
+23
-19
23 additions, 19 deletions
pub/src/expr.h
with
95 additions
and
78 deletions
pub/src/expr.cpp
+
72
−
59
View file @
4ed895f9
...
...
@@ -69,14 +69,19 @@ CContext::CContext( uint _k, uint _j, uint _i )
void
CContext
::
request_VT
(
const
vector
<
double
>
*
_vt
)
{
dim
=
_VT
;
nv
=
_vt
->
size
();
vt
=
_vt
;
dim
=
_VT
;
nv
=
_vt
->
size
();
vt
=
_vt
;
if
(
!
mystd
::
is_equidis
(
&
vt_step
,
vt
)
||
vt_step
<
0
)
vt_step
=
0
;
}
//! Request a vector of indices.
void
CContext
::
request_VI
(
uint
_nv
)
{
dim
=
_VI
;
nv
=
_nv
;
dim
=
_VI
;
nv
=
_nv
;
}
//! Introspection, for debugging.
...
...
@@ -414,91 +419,111 @@ string CRef::ref_info() const
//***************************************************************************//
//*
class CTree (parsed expressions)
*//
//*
CTree: constructors
*//
//***************************************************************************//
//!
Constructors
.
//!
Empty tree. Probably needed for copying, in assignments &c
.
CTree
::
CTree
()
:
typ
(
_NOTREE
),
fun
(
0
)
{}
//! Universal constructor, for given _typ, with no tree arguments.
CTree
::
CTree
(
char
_typ
)
{
if
(
_typ
==
't'
)
{
// function argument
typ
=
_DUMMY
;
}
else
if
(
_typ
==
'd'
)
{
// Dirac delta function centered at 0
typ
=
_DIRAC
;
arg
[
0
]
=
PTree
(
new
CTree
(
0.0
)
);
narg
=
1
;
}
else
throw
string
(
"invalid tree type in char-constructor"
);
}
//! Universal constructor, for given _typ, with 1 tree argument.
CTree
::
CTree
(
char
_typ
,
const
PTree
&
a0
)
{
if
(
_typ
==
'd'
)
{
// Dirac delta function centered at a0
typ
=
_DIRAC
;
if
(
a0
->
has_dummy
()
)
throw
string
(
"shift of Dirac delta must not contain t"
);
arg
[
0
]
=
a0
;
narg
=
1
;
}
else
throw
string
(
"invalid tree type in char-constructor"
);
}
//! Universal constructor, for given _typ, with 2 tree argument.
CTree
::
CTree
(
char
_typ
,
const
PTree
&
a0
,
const
PTree
&
a1
)
{
if
(
_typ
==
'c'
)
{
// convolution
typ
=
_CONV
;
arg
[
0
]
=
a0
;
arg
[
1
]
=
a1
;
narg
=
2
;
}
else
throw
string
(
"invalid tree type in char-constructor"
);
}
//! Numeric value node constructor.
CTree
::
CTree
(
double
v_in
)
:
typ
(
_VAL
),
val
(
v_in
),
fun
(
0
)
{}
:
typ
(
_VAL
),
fun
(
0
),
val
(
v_in
)
{}
//! Function node with 1 argument.
CTree
::
CTree
(
const
class
CFunc
*
f_in
,
PTree
a0
)
:
typ
(
_OP
),
fun
(
f_in
),
narg
(
1
)
:
typ
(
_OP
),
narg
(
1
),
fun
(
f_in
)
{
arg
[
0
]
=
a0
;
if
(
fun
->
narg
!=
1
)
throw
string
(
"BUG: CTree(1) with conflicting #arg"
);
}
//! Function node constructor with 2 arguments.
CTree
::
CTree
(
const
class
CFunc
*
f_in
,
PTree
a0
,
PTree
a1
)
:
typ
(
_OP
),
fun
(
f_in
),
narg
(
2
)
:
typ
(
_OP
),
narg
(
2
),
fun
(
f_in
)
{
arg
[
0
]
=
a0
;
arg
[
1
]
=
a1
;
if
(
fun
->
narg
!=
2
)
throw
string
(
"BUG: CTree(2) with conflicting #arg"
);
}
//! Function node constructor with 3 arguments.
CTree
::
CTree
(
const
class
CFunc
*
f_in
,
PTree
a0
,
PTree
a1
,
PTree
a2
)
:
typ
(
_OP
),
fun
(
f_in
),
narg
(
3
)
:
typ
(
_OP
),
narg
(
3
),
fun
(
f_in
)
{
arg
[
0
]
=
a0
;
arg
[
1
]
=
a1
;
arg
[
2
]
=
a2
;
if
(
fun
->
narg
!=
3
)
throw
string
(
"BUG: CTree(3) with conflicting #arg"
);
}
//! Reference node constructor.
CTree
::
CTree
(
PRef
&
_ref
)
:
typ
(
_REF
),
fun
(
0
),
ref
(
_ref
)
{};
//! Curve evaluation node constructor.
CTree
::
CTree
(
PRef
&
_ref
,
PTree
a0
)
:
typ
(
_CEV
),
fun
(
0
),
ref
(
_ref
)
{
arg
[
0
]
=
a0
;
}
//! Register reference node constructor.
CTree
::
CTree
(
PRgr
&
_rgr
)
:
typ
(
_RGR
),
rgr
(
_rgr
)
{};
CTree
::
CTree
(
char
which
)
{
if
(
which
==
't'
)
{
// function argument
typ
=
_DUMMY
;
}
else
if
(
which
==
'd'
)
{
// Dirac delta function centered at 0
typ
=
_DIRAC
;
arg
[
0
]
=
PTree
(
new
CTree
(
0.0
)
);
narg
=
1
;
}
else
throw
string
(
"invalid tree type in char-constructor"
);
}
CTree
::
CTree
(
char
which
,
const
PTree
&
a0
)
{
if
(
which
==
'd'
)
{
// Dirac delta function centered at a0
typ
=
_DIRAC
;
if
(
a0
->
has_dummy
()
)
throw
string
(
"shift of Dirac delta must not contain t"
);
arg
[
0
]
=
a0
;
narg
=
1
;
}
else
throw
string
(
"invalid tree type in char-constructor"
);
}
CTree
::
CTree
(
char
which
,
const
PTree
&
a0
,
const
PTree
&
a1
)
{
if
(
which
==
'c'
)
{
// convolution
typ
=
_CONV
;
arg
[
0
]
=
a0
;
arg
[
1
]
=
a1
;
narg
=
2
;
}
else
throw
string
(
"invalid tree type in char-constructor"
);
}
//***************************************************************************//
//* CTree
/ read out various properties
*//
//* CTree
: status requests
*//
//***************************************************************************//
//! How many curve parameters are contained in the tree?
...
...
@@ -510,7 +535,6 @@ uint CTree::npar() const
return
np
;
}
//! Implementation with pointer argument to allow recursion.
void
CTree
::
npar_exec
(
uint
*
np
)
const
...
...
@@ -527,7 +551,6 @@ void CTree::npar_exec( uint *np ) const
throw
string
(
"BUG: npar(UNDEF)"
);
}
//! Does the result depend on k?
bool
CTree
::
k_dependent
()
const
...
...
@@ -537,7 +560,6 @@ bool CTree::k_dependent() const
return
kd
;
}
//! Implementation with pointer argument to allow recursion.
void
CTree
::
kdep_exec
(
bool
*
kd
)
const
...
...
@@ -553,7 +575,6 @@ void CTree::kdep_exec( bool *kd ) const
throw
string
(
"BUG: kdep(UNDEF)"
);
}
//! Does expression contain dummy argument t ?
bool
CTree
::
has_dummy
()
const
...
...
@@ -616,7 +637,6 @@ void CTree::set_coord( CCoord& ret, uint k ) const
}
}
//! Tree -> expression.
string
CTree
::
tree_info
()
const
...
...
@@ -649,7 +669,7 @@ string CTree::tree_info() const
//***************************************************************************//
//* CTree
/
low-level tree evaluation *//
//* CTree
:
low-level tree evaluation
*//
//***************************************************************************//
//! Evaluate tree and convert result to integer, for use as index.
...
...
@@ -662,7 +682,6 @@ void CTree::tree_uival( uint *ret, const CContext& ctx ) const
*
ret
=
(
uint
)
(
val
.
r
+
0.5
);
}
//! Evaluate tree. Private. User calls pass through API implemented below.
void
CTree
::
tree_val
(
CResult
&
ret
,
const
CContext
&
ctx
)
const
...
...
@@ -696,7 +715,6 @@ void CTree::tree_val( CResult& ret, const CContext& ctx ) const
}
}
//! A function of 1,2,.. arguments (including operators like +,-,.. ).
void
CTree
::
tree_op
(
CResult
&
ret
,
const
CContext
&
ctx
)
const
...
...
@@ -808,7 +826,6 @@ void CTree::tree_op( CResult& ret, const CContext& ctx ) const
}
}
//! A curve evaluation: fc[k,j](arg).
void
CTree
::
tree_cev
(
CResult
&
ret
,
const
CContext
&
ctx
)
const
...
...
@@ -866,7 +883,7 @@ void CTree::tree_cev( CResult& ret, const CContext& ctx ) const
//***************************************************************************//
//* CTree
/
public interface to tree evaluation *//
//* CTree
:
public interface to tree evaluation
*//
//***************************************************************************//
//! Evaluate tree. Public API.
...
...
@@ -885,7 +902,6 @@ void CTree::tree_point_val(
*
dret
=
val
.
dr
;
}
//! Evaluate tree. Public API.
void
CTree
::
tree_vec_val
(
...
...
@@ -910,7 +926,7 @@ void CTree::tree_vec_val(
//***************************************************************************//
//* CTree
/
convolution evaluation *//
//* CTree
:
convolution evaluation
*//
//***************************************************************************//
//! Return kconc and jconv, according to fc[k,j]->kconv.
...
...
@@ -945,7 +961,6 @@ void CTree::setConv( uint& kconv, uint& jconv, uint k, uint j )
strg
(
kconv
)
+
": number of spectra does not match"
;
}
//! Convolution context. Declared locally because only needed in tree_conv.
typedef
struct
{
...
...
@@ -957,7 +972,6 @@ typedef struct {
PTree
arg
;
}
ConvDatTyp
;
//! Call-back for integration. Only needed in tree_conv.
double
tree_conv_eval
(
double
tt
,
void
*
data
)
...
...
@@ -972,7 +986,6 @@ double tree_conv_eval( double tt, void *data )
return
mydata
->
res
.
to_r
(
0
)
*
mydata
->
sv
->
intpol
(
tt
);
}
//! Convolution or Dirac function: conv(f, shift), dirac(shift).
void
CTree
::
tree_conv
(
CResult
&
ret
,
const
CContext
&
ctx
)
const
...
...
This diff is collapsed.
Click to expand it.
pub/src/expr.h
+
23
−
19
View file @
4ed895f9
...
...
@@ -18,6 +18,7 @@ class CContext {
public:
uint
k
,
j
,
i
;
// file,scan,point we are refering to
const
vector
<
double
>
*
vt
;
// a vector we may refer to
double
vt_step
;
// step of equidistant vt, otherwise 0
enum
TDim
{
_1
,
_VI
,
_VT
}
dim
;
// kind of requested output
bool
want_error
;
// errors requested?
uint
nv
;
// number of requested vector elements
...
...
@@ -43,13 +44,19 @@ class CResult {
CResult
()
:
vectorial
(
false
),
dr
(
0
)
{};
void
set_r
(
double
_r
)
{
vectorial
=
false
;
r
=
_r
;
};
void
preset_v
(
int
n
)
{
vectorial
=
true
;
v
.
resize
(
n
);
};
void
set_v
(
const
vector
<
double
>&
v_
)
{
vectorial
=
true
;
v
=
v_
;
};
double
to_r
(
int
i
)
const
{
return
vectorial
?
v
[
i
]
:
r
;
};
double
to_dr
(
int
i
)
const
{
return
vectorial
?
(
dv
.
size
()
?
dv
[
i
]
:
0
)
:
dr
;
};
bool
has_err
()
const
{
return
vectorial
?
dv
.
size
()
:
dr
;
};
void
set_r
(
double
_r
)
{
vectorial
=
false
;
r
=
_r
;
};
void
preset_v
(
int
n
)
{
vectorial
=
true
;
v
.
resize
(
n
);
};
void
set_v
(
const
vector
<
double
>&
v_
)
{
vectorial
=
true
;
v
=
v_
;
};
double
to_r
(
int
i
)
const
{
return
vectorial
?
v
[
i
]
:
r
;
};
double
to_dr
(
int
i
)
const
{
return
vectorial
?
(
dv
.
size
()
?
dv
[
i
]
:
0
)
:
dr
;
};
bool
has_err
()
const
{
return
vectorial
?
dv
.
size
()
:
dr
;
};
string
result_info
()
const
;
};
...
...
@@ -88,11 +95,11 @@ class CTree {
_DIRAC
// Dirac delta function
};
TreeTyp
typ
;
double
val
;
const
class
CFunc
*
fun
;
static
const
uint
maxarg
=
3
;
PTree
arg
[
maxarg
];
uint
narg
;
const
class
CFunc
*
fun
;
double
val
;
PRef
ref
;
PRgr
rgr
;
...
...
@@ -100,8 +107,14 @@ class CTree {
void
tree_conv
(
CResult
&
ret
,
const
CContext
&
ctx
)
const
;
void
tree_cev
(
CResult
&
ret
,
const
CContext
&
ctx
)
const
;
void
npar_exec
(
uint
*
np
)
const
;
void
kdep_exec
(
bool
*
kd
)
const
;
public
:
CTree
();
CTree
(
char
_typ
);
CTree
(
char
_typ
,
const
PTree
&
a0
);
CTree
(
char
_typ
,
const
PTree
&
a0
,
const
PTree
&
a1
);
CTree
(
double
v_in
);
CTree
(
const
class
CFunc
*
f_in
,
PTree
a0
);
CTree
(
const
class
CFunc
*
f_in
,
PTree
a0
,
PTree
a1
);
...
...
@@ -109,9 +122,6 @@ class CTree {
CTree
(
PRef
&
_ref
);
CTree
(
PRef
&
_ref
,
PTree
a0
);
CTree
(
PRgr
&
_rgr
);
CTree
(
char
which
);
CTree
(
char
which
,
const
PTree
&
a0
);
CTree
(
char
which
,
const
PTree
&
a0
,
const
PTree
&
a1
);
static
void
setConv
(
uint
&
kconv
,
uint
&
jconv
,
uint
k
,
uint
j
);
...
...
@@ -119,8 +129,7 @@ class CTree {
bool
k_dependent
()
const
;
bool
has_dummy
()
const
;
void
tree_val
(
CResult
&
ret
,
const
CContext
&
ctx
)
const
;
void
tree_val
(
CResult
&
ret
,
const
CContext
&
ctx
)
const
;
void
tree_uival
(
uint
*
ret
,
const
CContext
&
ctx
)
const
;
void
tree_point_val
(
double
*
ret
,
double
*
dret
,
...
...
@@ -128,11 +137,6 @@ class CTree {
void
tree_vec_val
(
vector
<
double
>
*
ret
,
vector
<
double
>
*
dret
,
uint
k
=
(
uint
)
-
1
,
uint
j
=
(
uint
)
-
1
)
const
;
void
set_coord
(
CCoord
&
ret
,
uint
k
=
(
uint
)
-
1
)
const
;
string
tree_info
()
const
;
private
:
void
npar_exec
(
uint
*
np
)
const
;
void
kdep_exec
(
bool
*
kd
)
const
;
};
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