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 |
|
---|
35 | using namespace asap;
|
---|
36 | using namespace casa;
|
---|
37 |
|
---|
38 | SDMemTableWrapper SDMathWrapper::quotient(const SDMemTableWrapper& on,
|
---|
39 | const SDMemTableWrapper& off)
|
---|
40 | {
|
---|
41 | return SDMemTableWrapper(SDMath::quotient(on.getCP(),
|
---|
42 | off.getCP()));
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, casa::Float factor, casa::Bool doAll)
|
---|
47 | {
|
---|
48 | SDMemTable* pIn = in.getPtr();
|
---|
49 | const uInt what = 0;
|
---|
50 | SDMemTable* pOut = SDMath::simpleOperate (*pIn, factor, doAll, what);
|
---|
51 | *pIn = *pOut;
|
---|
52 | delete pOut;
|
---|
53 | }
|
---|
54 |
|
---|
55 | SDMemTableWrapper SDMathWrapper::scale(const SDMemTableWrapper& in,
|
---|
56 | casa::Float factor, casa::Bool doAll)
|
---|
57 | {
|
---|
58 | const CountedPtr<SDMemTable>& pIn = in.getCP();
|
---|
59 | const uInt what = 0;
|
---|
60 | return CountedPtr<SDMemTable>(SDMath::simpleOperate(*pIn, factor, doAll, what));
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 |
|
---|
65 | void SDMathWrapper::addInSitu(SDMemTableWrapper& in, casa::Float offset, casa::Bool doAll)
|
---|
66 | {
|
---|
67 | SDMemTable* pIn = in.getPtr();
|
---|
68 | const uInt what = 1;
|
---|
69 | SDMemTable* pOut = SDMath::simpleOperate (*pIn, offset, doAll, what);
|
---|
70 | *pIn = *pOut;
|
---|
71 | delete pOut;
|
---|
72 | }
|
---|
73 |
|
---|
74 | SDMemTableWrapper SDMathWrapper::add(const SDMemTableWrapper& in,
|
---|
75 | casa::Float offset, casa::Bool doAll)
|
---|
76 | {
|
---|
77 | const CountedPtr<SDMemTable>& pIn = in.getCP();
|
---|
78 | const uInt what = 1;
|
---|
79 | return CountedPtr<SDMemTable>(SDMath::simpleOperate(*pIn, offset, doAll, what));
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | SDMemTableWrapper SDMathWrapper::hanning(const SDMemTableWrapper& in)
|
---|
84 | {
|
---|
85 | return SDMemTableWrapper(SDMath::hanning(in.getCP()));
|
---|
86 | }
|
---|
87 |
|
---|
88 |
|
---|
89 | void SDMathWrapper::binInSitu(SDMemTableWrapper& in, int width)
|
---|
90 | {
|
---|
91 | SDMemTable* pIn = in.getPtr();
|
---|
92 | SDMemTable* pOut = SDMath::bin (*pIn, Int(width));
|
---|
93 | *pIn = *pOut;
|
---|
94 | delete pOut;
|
---|
95 | }
|
---|
96 |
|
---|
97 | SDMemTableWrapper SDMathWrapper::bin (const SDMemTableWrapper& in,
|
---|
98 | int width)
|
---|
99 | {
|
---|
100 | const CountedPtr<SDMemTable>& pIn = in.getCP();
|
---|
101 | return CountedPtr<SDMemTable>(SDMath::bin(*pIn, Int(width)));
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask)
|
---|
106 | {
|
---|
107 | SDMemTable* pIn = in.getPtr();
|
---|
108 | SDMemTable* pOut = SDMath::averagePol (*pIn, mask);
|
---|
109 | *pIn = *pOut;
|
---|
110 | delete pOut;
|
---|
111 | }
|
---|
112 |
|
---|
113 | SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in, const std::vector<bool>& mask)
|
---|
114 |
|
---|
115 | {
|
---|
116 | const CountedPtr<SDMemTable>& pIn = in.getCP();
|
---|
117 | return CountedPtr<SDMemTable>(SDMath::averagePol(*pIn, mask));
|
---|
118 | }
|
---|
119 |
|
---|
120 |
|
---|
121 | std::vector<float> SDMathWrapper::statistic(const SDMemTableWrapper& in,
|
---|
122 | const std::vector<bool>& mask,
|
---|
123 | const std::string& which)
|
---|
124 | {
|
---|
125 | return SDMath::statistic(in.getCP(), mask, which);
|
---|
126 | }
|
---|