codac 2.0.0
Loading...
Searching...
No Matches
codac2_trunc.h
Go to the documentation of this file.
1
9
10#pragma once
11
12#include "codac2_Interval.h"
13#include "codac2_matrices.h"
14
15namespace codac2
16{
17 double trunc(double x);
18 Interval trunc(const Interval& x);
19 Interval trunc(const Interval& x);
20
21 double untrunc(double x);
22 Interval untrunc(const Interval& x);
23
24 template<typename OtherDerived,typename Func>
25 auto trunc_common(const Eigen::MatrixBase<OtherDerived>& x, const Func& apply_trunc)
26 {
27 using M = Eigen::MatrixBase<OtherDerived>;
28 Eigen::Matrix<typename M::Scalar,M::RowsAtCompileTime,M::ColsAtCompileTime> u(x.rows(),x.cols());
29
30 for(Index i = 0 ; i < x.rows() ; i++)
31 for(Index j = 0 ; j < x.cols() ; j++)
32 u(i,j) = apply_trunc(x(i,j));
33
34 return u;
35 }
36
37 template<typename OtherDerived>
38 inline auto trunc(const Eigen::MatrixBase<OtherDerived>& x)
39 {
40 using T = Eigen::MatrixBase<OtherDerived>::Scalar;
41 return trunc_common(x,static_cast<T(*)(const T&)>(&trunc));
42 }
43
44 template<typename OtherDerived>
45 inline auto untrunc(const Eigen::MatrixBase<OtherDerived>& x)
46 {
47 using T = Eigen::MatrixBase<OtherDerived>::Scalar;
48 return trunc_common(x,static_cast<T(*)(const T&)>(&untrunc));
49 }
50
51 double graphic_trunc(double x);
52}
Interval class, for representing closed and connected subsets of .
Definition codac2_Interval.h:49
Definition codac2_OctaSym.h:21