OpenStructure
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
stage
include
ost
img
alg
transcendentals.hh
Go to the documentation of this file.
1
//------------------------------------------------------------------------------
2
// This file is part of the OpenStructure project <www.openstructure.org>
3
//
4
// Copyright (C) 2008-2011 by the OpenStructure authors
5
// Copyright (C) 2003-2010 by the IPLT authors
6
//
7
// This library is free software; you can redistribute it and/or modify it under
8
// the terms of the GNU Lesser General Public License as published by the Free
9
// Software Foundation; either version 3.0 of the License, or (at your option)
10
// any later version.
11
// This library is distributed in the hope that it will be useful, but WITHOUT
12
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
// details.
15
//
16
// You should have received a copy of the GNU Lesser General Public License
17
// along with this library; if not, write to the Free Software Foundation, Inc.,
18
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
//------------------------------------------------------------------------------
20
21
/*
22
"overloaded" transcendentals for images; instead of providing the
23
typical func(image) interface, which would limit the use to out-of-place
24
application, a full fletched img::alg interface is given for each:
25
26
cos, exp, log, log10, pow, sin, sqrt, tan
27
28
Author: Ansgar Philippsen
29
*/
30
31
#ifndef IMG_ALG_TRANS_HH
32
#define IMG_ALG_TRANS_HH
33
34
#include <
ost/img/image.hh
>
35
#include <
ost/img/image_state.hh
>
36
#include <
ost/img/alg/module_config.hh
>
37
38
39
#define IMG_ALG_TRANSCENDENTALS_BLOCK(FF,NN,SS) \
40
struct FF { \
41
FF() {} \
42
~FF() {} \
43
template <typename T, class D> \
44
void VisitState(ImageStateImpl<T,D>& isi) const { \
45
T* end = isi.Data().GetEnd(); \
46
for(T* it = isi.Data().GetData(); it!=end; ++it) { \
47
(*it) = SS (*it); \
48
} \
49
} \
50
template <class D> \
51
void VisitState(ImageStateImpl<Word,D>& isi) const { \
52
Word* end = isi.Data().GetEnd(); \
53
for(Word* it = isi.Data().GetData(); it!=end; ++it) { \
54
(*it) = static_cast<Word>(SS(static_cast<Real>(*it))); \
55
} \
56
} \
57
static String GetAlgorithmName() {return "";} \
58
}; \
59
typedef ImageStateConstModIPAlgorithm<FF> NN;
60
61
namespace
ost {
namespace
img {
namespace
alg {
62
63
IMG_ALG_TRANSCENDENTALS_BLOCK
(
CosFnc
,
Cos
,std::cos)
64
IMG_ALG_TRANSCENDENTALS_BLOCK
(
ExpFnc
,
Exp
,std::exp)
65
IMG_ALG_TRANSCENDENTALS_BLOCK
(
LogFnc
,
Log
,std::log)
66
IMG_ALG_TRANSCENDENTALS_BLOCK
(
Log10Fnc
,
Log10
,std::log)
67
IMG_ALG_TRANSCENDENTALS_BLOCK
(
SinFnc
,
Sin
,std::sin)
68
IMG_ALG_TRANSCENDENTALS_BLOCK
(
SqrtFnc
,
Sqrt
,std::sqrt)
69
IMG_ALG_TRANSCENDENTALS_BLOCK
(
TanFnc
,
Tan
,std::tan)
70
71
72
struct
PowFnc
{
73
PowFnc
():exp_(1.0) {}
74
PowFnc
(
Real
exp): exp_(exp) {}
75
76
template
<
typename
T,
class
D>
77
void
VisitState
(ImageStateImpl<T,D>& isi)
const
{
78
T*
end
= isi.Data().GetEnd();
79
for
(T* it = isi.Data().GetData(); it!=
end
; ++it) {
80
(*it) = std::pow(*it,exp_);
81
}
82
}
83
static
String
GetAlgorithmName
() {
return
""
;}
84
private
:
85
Real
exp_;
86
};
87
88
typedef
ImageStateConstModIPAlgorithm<PowFnc>
Pow
;
89
90
91
}}}
// ns
92
93
#undef IMG_ALG_TRANSCENDENTALS_BLOCK
94
95
96
#endif
Generated on Mon Nov 11 2013 09:56:12 for OpenStructure by
1.8.1.1