source: trunk/src/SDMathWrapper.cc@ 181

Last change on this file since 181 was 178, checked in by kil064, 20 years ago

remove 'hanning' functions and add 'smooth' functions

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1//#---------------------------------------------------------------------------
2//# SDMathWrapper.cc: Wrapper classes to use CountedPtr
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//# Internet email: Malte.Marquarding@csiro.au
23//# Postal address: Malte Marquarding,
24//# Australia Telescope National Facility,
25//# P.O. Box 76,
26//# Epping, NSW, 2121,
27//# AUSTRALIA
28//#
29//# $Id:
30//#---------------------------------------------------------------------------
31
32
33#include "SDMathWrapper.h"
34#include "SDMath.h"
35
36
37using namespace asap;
38using namespace casa;
39
40SDMemTableWrapper SDMathWrapper::quotient(const SDMemTableWrapper& on,
41 const SDMemTableWrapper& off)
42{
43 SDMath sdm;
44 return SDMemTableWrapper(sdm.quotient(on.getCP(), off.getCP()));
45}
46
47
48void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll)
49{
50 SDMemTable* pIn = in.getPtr();
51 const uInt what = 0;
52//
53 SDMath sdm;
54 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(factor), Bool(doAll), what);
55 *pIn = *pOut;
56 delete pOut;
57}
58
59SDMemTableWrapper SDMathWrapper::scale(const SDMemTableWrapper& in,
60 float factor, bool doAll)
61{
62 const CountedPtr<SDMemTable>& pIn = in.getCP();
63 const uInt what = 0;
64 SDMath sdm;
65 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(factor), Bool(doAll), what));
66}
67
68
69
70void SDMathWrapper::addInSitu(SDMemTableWrapper& in, float offset, bool doAll)
71{
72 SDMemTable* pIn = in.getPtr();
73 const uInt what = 1;
74//
75 SDMath sdm;
76 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(offset), Bool(doAll), what);
77 *pIn = *pOut;
78 delete pOut;
79}
80
81SDMemTableWrapper SDMathWrapper::add(const SDMemTableWrapper& in,
82 float offset, bool doAll)
83{
84 const CountedPtr<SDMemTable>& pIn = in.getCP();
85 const uInt what = 1;
86 SDMath sdm;
87 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(offset), Bool(doAll), what));
88}
89
90
91void SDMathWrapper::smoothInSitu(SDMemTableWrapper& in, const std::string& kernel, float width, bool doAll)
92{
93 SDMemTable* pIn = in.getPtr();
94 SDMath sdm;
95 SDMemTable* pOut = sdm.smooth(*pIn, String(kernel), Float(width), Bool(doAll));
96 *pIn = *pOut;
97 delete pOut;
98}
99
100
101SDMemTableWrapper SDMathWrapper::smooth (const SDMemTableWrapper& in, const std::string& kernel,
102 float width, bool doAll)
103{
104 const CountedPtr<SDMemTable>& pIn = in.getCP();
105 SDMath sdm;
106 return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel), Float(width), Bool(doAll)));
107}
108
109
110
111void SDMathWrapper::binInSitu(SDMemTableWrapper& in, int width)
112{
113 SDMemTable* pIn = in.getPtr();
114 SDMath sdm;
115 SDMemTable* pOut = sdm.bin (*pIn, Int(width));
116 *pIn = *pOut;
117 delete pOut;
118}
119
120SDMemTableWrapper SDMathWrapper::bin (const SDMemTableWrapper& in,
121 int width)
122{
123 const CountedPtr<SDMemTable>& pIn = in.getCP();
124 SDMath sdm;
125 return CountedPtr<SDMemTable>(sdm.bin(*pIn, Int(width)));
126}
127
128
129void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask)
130{
131 SDMemTable* pIn = in.getPtr();
132 SDMath sdm;
133 SDMemTable* pOut = sdm.averagePol (*pIn, mask);
134 *pIn = *pOut;
135 delete pOut;
136}
137
138SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in, const std::vector<bool>& mask)
139
140{
141 const CountedPtr<SDMemTable>& pIn = in.getCP();
142 SDMath sdm;
143 return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, mask));
144}
145
146
147std::vector<float> SDMathWrapper::statistic(const SDMemTableWrapper& in,
148 const std::vector<bool>& mask,
149 const std::string& which)
150{
151 SDMath sdm;
152 return sdm.statistic(in.getCP(), mask, which);
153}
Note: See TracBrowser for help on using the repository browser.