Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F75823731
observer.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Aug 4, 12:32
Size
1 KB
Mime Type
text/x-c++
Expires
Tue, Aug 6, 12:32 (2 d)
Engine
blob
Format
Raw Data
Handle
19615838
Attached To
R9411 tisue modeling
observer.hpp
View Options
#ifndef __OBSERVER_HPP__
#define __OBSERVER_HPP__
#include <iterator>
#include <vector>
#include <algorithm>
//#include "Vector.h"
//#include <boost/numeric/ublas/vector.hpp>
typedef
std
::
vector
<
double
>
state_type
;
//typedef boost::numeric::ublas::vector<double> state_type;
class
KeepLast
{
protected
:
state_type
last
;
double
time
;
public
:
KeepLast
(){}
KeepLast
(
state_type
x
)
:
last
(
x
){}
void
operator
()(
const
state_type
&
x
,
double
t
);
void
resize
(
uint
n
){
last
.
resize
(
n
);}
void
init
(
uint
n
){
last
.
resize
(
n
);}
state_type
&
getState
(){
return
last
;}
double
getTime
(){
return
time
;}
void
setTime
(
double
t
){
time
=
t
;}
};
struct
push_back_state_and_time
{
std
::
vector
<
state_type
>&
m_states
;
std
::
vector
<
double
>&
m_times
;
push_back_state_and_time
(
std
::
vector
<
state_type
>
&
states
,
std
::
vector
<
double
>
&
times
)
:
m_states
(
states
)
,
m_times
(
times
)
{
}
void
operator
()(
const
state_type
&
x
,
double
t
)
{
m_states
.
push_back
(
x
);
m_times
.
push_back
(
t
);}
state_type
&
getState
(){
return
m_states
.
back
();}
};
struct
push_back_sel_state_and_time:
push_back_state_and_time
{
std
::
vector
<
uint
>&
m_idx
;
push_back_sel_state_and_time
(
std
::
vector
<
state_type
>
&
states
,
std
::
vector
<
double
>
&
times
,
std
::
vector
<
uint
>
&
idx
)
:
push_back_state_and_time
(
states
,
times
),
m_idx
(
idx
){}
void
operator
()(
const
state_type
&
x
,
double
t
)
{
state_type
x_sel
(
m_idx
.
size
());
for
(
int
i
=
0
;
i
<
m_idx
.
size
();
i
++
){
x_sel
[
i
]
=
x
[
m_idx
[
i
]];
}
m_states
.
push_back
(
x_sel
);
m_times
.
push_back
(
t
);
}
};
#endif
Event Timeline
Log In to Comment