source: trunk/src/SDMathWrapper.cc@ 170

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

Modify SDMath to be a class rather than just a namespace

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