source: trunk/src/SDMathWrapper.cc@ 172

Last change on this file since 172 was 171, checked in by kil064, 20 years ago

implement insitu version of Hanning smoothing

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 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
90void SDMathWrapper::hanningInSitu(SDMemTableWrapper& in)
91{
92 SDMemTable* pIn = in.getPtr();
93 SDMath sdm;
94 SDMemTable* pOut = sdm.hanning (*pIn);
95 *pIn = *pOut;
96 delete pOut;
97}
98
99SDMemTableWrapper SDMathWrapper::hanning (const SDMemTableWrapper& in)
100{
101 const CountedPtr<SDMemTable>& pIn = in.getCP();
102 SDMath sdm;
103 return CountedPtr<SDMemTable>(sdm.hanning(*pIn));
104}
105
106
107
108void SDMathWrapper::binInSitu(SDMemTableWrapper& in, int width)
109{
110 SDMemTable* pIn = in.getPtr();
111 SDMath sdm;
112 SDMemTable* pOut = sdm.bin (*pIn, Int(width));
113 *pIn = *pOut;
114 delete pOut;
115}
116
117SDMemTableWrapper SDMathWrapper::bin (const SDMemTableWrapper& in,
118 int width)
119{
120 const CountedPtr<SDMemTable>& pIn = in.getCP();
121 SDMath sdm;
122 return CountedPtr<SDMemTable>(sdm.bin(*pIn, Int(width)));
123}
124
125
126void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask)
127{
128 SDMemTable* pIn = in.getPtr();
129 SDMath sdm;
130 SDMemTable* pOut = sdm.averagePol (*pIn, mask);
131 *pIn = *pOut;
132 delete pOut;
133}
134
135SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in, const std::vector<bool>& mask)
136
137{
138 const CountedPtr<SDMemTable>& pIn = in.getCP();
139 SDMath sdm;
140 return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, mask));
141}
142
143
144std::vector<float> SDMathWrapper::statistic(const SDMemTableWrapper& in,
145 const std::vector<bool>& mask,
146 const std::string& which)
147{
148 SDMath sdm;
149 return sdm.statistic(in.getCP(), mask, which);
150}
Note: See TracBrowser for help on using the repository browser.