Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88554758
odeint_types.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
Sat, Oct 19, 11:11
Size
3 KB
Mime Type
text/x-c++
Expires
Mon, Oct 21, 11:11 (2 d)
Engine
blob
Format
Raw Data
Handle
21788110
Attached To
rSPECMICP SpecMiCP / ReactMiCP
odeint_types.hpp
View Options
/*-------------------------------------------------------
- Module : odeint
- File : odeint_types.hpp
- Author : Fabien Georget
Copyright (c) 2014, Fabien Georget <fabieng@princeton.edu>, Princeton University
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Princeton University nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------*/
#ifndef SPECMICP_ODEINT_ODEINTTYPES_HPP
#define SPECMICP_ODEINT_ODEINTTYPES_HPP
//! \file odeint_types.hpp common types for odeint
#include "common.hpp"
#include <functional>
#include <Eigen/Core>
namespace
specmicp
{
namespace
odeint
{
namespace
internal
{
//! \brief implementation for the vector type (which may not be a vector for dim=1)
template
<
int
dim
>
struct
vector_trait
{
using
type
=
Eigen
::
Matrix
<
scalar_t
,
Eigen
::
Dynamic
,
1
>
;
};
//! Specialisation for dimension 1 (scalar)
template
<>
struct
vector_trait
<
1
>
{
using
type
=
scalar_t
;
};
//! Specialization for dimension 2 (fixed-size vector)
template
<>
struct
vector_trait
<
2
>
{
using
type
=
Eigen
::
Matrix
<
scalar_t
,
2
,
1
>
;
};
//! Specialization for dimension 3 (fixed-size vector)
template
<>
struct
vector_trait
<
3
>
{
using
type
=
Eigen
::
Matrix
<
scalar_t
,
3
,
1
>
;
};
}
// end namespace internal
//! The vector type
template
<
int
dim
>
using
vector_t
=
typename
internal
::
vector_trait
<
dim
>::
type
;
//! Return the maximum coefficient of the vector
template
<
int
dim
>
inline
scalar_t
max_coeff
(
const
vector_t
<
dim
>&
vec
)
{
return
vec
.
maxCoeff
();}
template
<>
inline
scalar_t
max_coeff
<
1
>
(
const
vector_t
<
1
>&
vec
)
{
return
vec
;}
//! \brief Type of the function f in dy/dx=f(x,y)
template
<
int
dim
>
using
rhs_f
=
std
::
function
<
void
(
scalar_t
,
const
vector_t
<
dim
>&
,
vector_t
<
dim
>&
)
>
;
//! \brief Return true of all members of 'vec' are non-negative
template
<
int
dim
>
inline
bool
is_nonnegative
(
vector_t
<
dim
>&
vec
)
{
return
(
vec
.
array
()
>=
Eigen
::
VectorXd
::
Zero
(
vec
.
rows
()).
array
()).
all
();
}
template
<>
inline
bool
is_nonnegative
<
1
>
(
vector_t
<
1
>&
vec
)
{
return
vec
>=
0.0
;
}
//! \brief Project to the positive quadrant
template
<
int
dim
>
inline
void
set_non_negative
(
vector_t
<
dim
>&
vec
)
{
vec
=
vec
.
cwiseMax
(
Eigen
::
VectorXd
::
Zero
(
vec
.
rows
()));
}
template
<>
inline
void
set_non_negative
<
1
>
(
vector_t
<
1
>&
vec
)
{
vec
=
std
::
max
(
0.0
,
vec
);
}
}
// end namespace odeint
}
// end namespace specmicp
#endif
// SPECMICP_ODEINT_ODEINTTYPES_HPP
Event Timeline
Log In to Comment