casa
5.7.0-16
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
casa
code
synthesis
MeasurementComponents
ExpCache.h
Go to the documentation of this file.
1
//# ExpCache.cc: Implementation of ExpCache (tabulated exponential) class
2
//# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
3
//# Associated Universities, Inc. Washington DC, USA.
4
//#
5
//# This library is free software; you can redistribute it and/or modify it
6
//# under the terms of the GNU Library General Public License as published by
7
//# the Free Software Foundation; either version 2 of the License, or (at your
8
//# option) any later version.
9
//#
10
//# This library is distributed in the hope that it will be useful, but WITHOUT
11
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13
//# License for more details.
14
//#
15
//# You should have received a copy of the GNU Library General Public License
16
//# along with this library; if not, write to the Free Software Foundation,
17
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18
//#
19
//# Correspondence concerning AIPS++ should be addressed as follows:
20
//# Internet email: aips2-request@nrao.edu.
21
//# Postal address: AIPS++ Project Office
22
//# National Radio Astronomy Observatory
23
//# 520 Edgemont Road
24
//# Charlottesville, VA 22903-2475 USA
25
//#
26
//# $Id$
27
28
#if !defined(EXP_CACHE_H)
29
#define EXP_CACHE_H
30
31
#include <
stdlib.h
>
32
#include <
math.h
>
33
34
namespace
casa
35
{
36
template
<
class
T>
class
ExpCache
37
{
38
public
:
39
ExpCache
() {
EStep
=0;
ETable
=NULL;
Size
=0;};
40
ExpCache
(
int
n, T Step) {
EStep
=
Size
=0;
ETable
=NULL;Build(n,Step);};
41
~ExpCache
() {
if
(
ETable
)
free
(
ETable
);};
42
43
inline
void
build
(
int
n, T Step)
44
{
45
if
(
ETable
)
free
(
ETable
);
46
47
ETable
=(T *)malloc(
sizeof
(T)*n);
48
Size
= n;
49
EStep
= Step;
50
51
for
(
int
i=0;i<n;i++)
ETable
[i]=
exp
(-i*Step);
52
}
53
inline
T
operator()
(T
arg
)
54
{
55
int
N
=(int)(-arg/
EStep
);
56
57
// return (fabs(N)>=Size)?0:((ETable[N]-ETable[N+1])*arg + ETable[N]);
58
59
return
(
abs
(N)>=
Size
)?0:
ETable
[N];
60
}
61
private
:
62
T
EStep
;
63
T *
ETable
;
64
int
Size
;
65
};
66
};
67
#endif
math.h
casa::ExpCache::ETable
T * ETable
Definition:
ExpCache.h:63
casacore::arg
LatticeExprNode arg(const LatticeExprNode &expr)
casacore::exp
LatticeExprNode exp(const LatticeExprNode &expr)
casa::ExpCache::ExpCache
ExpCache(int n, T Step)
Definition:
ExpCache.h:40
casa::ExpCache::Size
int Size
Definition:
ExpCache.h:64
casa::ExpCache::build
void build(int n, T Step)
Definition:
ExpCache.h:43
casa::ExpCache
Definition:
ExpCache.h:36
casacore::abs
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type...
N
uInt N
Axis number.
Definition:
ArrayAccessor.h:60
free
free(pool)
casa::ExpCache::ExpCache
ExpCache()
Definition:
ExpCache.h:39
stdlib.h
casa::ExpCache::~ExpCache
~ExpCache()
Definition:
ExpCache.h:41
casa::ExpCache::operator()
T operator()(T arg)
Definition:
ExpCache.h:53
casa::ExpCache::EStep
T EStep
Definition:
ExpCache.h:62
Generated on Sun Sep 1 2019 23:32:42 for casa by
1.8.5