source: trunk/src/SDMathWrapper.cc@ 207

Last change on this file since 207 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
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
[178]90
91void SDMathWrapper::smoothInSitu(SDMemTableWrapper& in, const std::string& kernel, float width, bool doAll)
[171]92{
93 SDMemTable* pIn = in.getPtr();
94 SDMath sdm;
[178]95 SDMemTable* pOut = sdm.smooth(*pIn, String(kernel), Float(width), Bool(doAll));
[171]96 *pIn = *pOut;
97 delete pOut;
98}
[169]99
[178]100
101SDMemTableWrapper SDMathWrapper::smooth (const SDMemTableWrapper& in, const std::string& kernel,
102 float width, bool doAll)
[169]103{
[171]104 const CountedPtr<SDMemTable>& pIn = in.getCP();
[170]105 SDMath sdm;
[178]106 return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel), Float(width), Bool(doAll)));
[169]107}
108
109
[171]110
[169]111void SDMathWrapper::binInSitu(SDMemTableWrapper& in, int width)
112{
113 SDMemTable* pIn = in.getPtr();
[170]114 SDMath sdm;
115 SDMemTable* pOut = sdm.bin (*pIn, Int(width));
[169]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();
[170]124 SDMath sdm;
125 return CountedPtr<SDMemTable>(sdm.bin(*pIn, Int(width)));
[169]126}
127
128
129void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask)
130{
131 SDMemTable* pIn = in.getPtr();
[170]132 SDMath sdm;
133 SDMemTable* pOut = sdm.averagePol (*pIn, mask);
[169]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();
[170]142 SDMath sdm;
143 return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, mask));
[169]144}
145
146
147std::vector<float> SDMathWrapper::statistic(const SDMemTableWrapper& in,
148 const std::vector<bool>& mask,
149 const std::string& which)
150{
[170]151 SDMath sdm;
152 return sdm.statistic(in.getCP(), mask, which);
[169]153}
Note: See TracBrowser for help on using the repository browser.