source: trunk/src/SDMathWrapper.cc@ 173

Last change on this file since 173 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
RevLine 
[169]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"
[170]34#include "SDMath.h"
[169]35
[170]36
[169]37using namespace asap;
38using namespace casa;
39
40SDMemTableWrapper SDMathWrapper::quotient(const SDMemTableWrapper& on,
41 const SDMemTableWrapper& off)
42{
[170]43 SDMath sdm;
44 return SDMemTableWrapper(sdm.quotient(on.getCP(), off.getCP()));
[169]45}
46
47
[170]48void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll)
[169]49{
50 SDMemTable* pIn = in.getPtr();
51 const uInt what = 0;
[170]52//
53 SDMath sdm;
54 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(factor), Bool(doAll), what);
[169]55 *pIn = *pOut;
56 delete pOut;
57}
58
59SDMemTableWrapper SDMathWrapper::scale(const SDMemTableWrapper& in,
[170]60 float factor, bool doAll)
[169]61{
62 const CountedPtr<SDMemTable>& pIn = in.getCP();
63 const uInt what = 0;
[170]64 SDMath sdm;
65 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(factor), Bool(doAll), what));
[169]66}
67
68
69
[170]70void SDMathWrapper::addInSitu(SDMemTableWrapper& in, float offset, bool doAll)
[169]71{
72 SDMemTable* pIn = in.getPtr();
73 const uInt what = 1;
[170]74//
75 SDMath sdm;
76 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(offset), Bool(doAll), what);
[169]77 *pIn = *pOut;
78 delete pOut;
79}
80
81SDMemTableWrapper SDMathWrapper::add(const SDMemTableWrapper& in,
[170]82 float offset, bool doAll)
[169]83{
84 const CountedPtr<SDMemTable>& pIn = in.getCP();
85 const uInt what = 1;
[170]86 SDMath sdm;
87 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(offset), Bool(doAll), what));
[169]88}
89
[171]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}
[169]98
[171]99SDMemTableWrapper SDMathWrapper::hanning (const SDMemTableWrapper& in)
[169]100{
[171]101 const CountedPtr<SDMemTable>& pIn = in.getCP();
[170]102 SDMath sdm;
[171]103 return CountedPtr<SDMemTable>(sdm.hanning(*pIn));
[169]104}
105
106
[171]107
[169]108void SDMathWrapper::binInSitu(SDMemTableWrapper& in, int width)
109{
110 SDMemTable* pIn = in.getPtr();
[170]111 SDMath sdm;
112 SDMemTable* pOut = sdm.bin (*pIn, Int(width));
[169]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();
[170]121 SDMath sdm;
122 return CountedPtr<SDMemTable>(sdm.bin(*pIn, Int(width)));
[169]123}
124
125
126void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask)
127{
128 SDMemTable* pIn = in.getPtr();
[170]129 SDMath sdm;
130 SDMemTable* pOut = sdm.averagePol (*pIn, mask);
[169]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();
[170]139 SDMath sdm;
140 return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, mask));
[169]141}
142
143
144std::vector<float> SDMathWrapper::statistic(const SDMemTableWrapper& in,
145 const std::vector<bool>& mask,
146 const std::string& which)
147{
[170]148 SDMath sdm;
149 return sdm.statistic(in.getCP(), mask, which);
[169]150}
Note: See TracBrowser for help on using the repository browser.