Changeset 170


Ignore:
Timestamp:
01/06/05 13:52:30 (20 years ago)
Author:
kil064
Message:

Modify SDMath to be a class rather than just a namespace

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMath.cc

    r169 r170  
    6363using namespace asap;
    6464
     65
     66SDMath::SDMath()
     67{;}
     68
     69SDMath::SDMath (const SDMath& other)
     70{
     71
     72// No state
     73
     74}
     75
     76SDMath& SDMath::operator=(const SDMath& other)
     77{
     78  if (this != &other) {
     79// No state
     80  }
     81  return *this;
     82}
     83
     84
    6585CountedPtr<SDMemTable> SDMath::average (const Block<CountedPtr<SDMemTable> >& in,
    6686                                        const Vector<Bool>& mask, bool scanAv,
  • trunk/src/SDMath.h

    r169 r170  
    4141class SDMemTable;
    4242
    43 namespace SDMath {
     43class SDMath {
     44
     45 public:
     46
     47// Default constructor
     48   SDMath();
     49
     50// Copy Constructor (copy semantics)
     51   SDMath (const SDMath& other);
     52
     53// Assignment  (copy semantics)
     54   SDMath &operator=(const SDMath& other);
    4455
    4556// Quotient
    4657
    47   casa::CountedPtr<SDMemTable> quotient(const casa::CountedPtr<SDMemTable>& on,
     58   casa::CountedPtr<SDMemTable> quotient(const casa::CountedPtr<SDMemTable>& on,
    4859                                         const casa::CountedPtr<SDMemTable>& off);
    4960
    5061//  Hanning
    5162
    52   casa::CountedPtr<SDMemTable> hanning(const casa::CountedPtr<SDMemTable>& in);
     63   casa::CountedPtr<SDMemTable> hanning(const casa::CountedPtr<SDMemTable>& in);
    5364
    5465// Average in time
    5566
    56   casa::CountedPtr<SDMemTable>  average (const casa::Block<casa::CountedPtr<SDMemTable> >& in,
    57                                          const casa::Vector<casa::Bool>& mask,
    58                                          bool scanAverage, const std::string& weightStr);
     67   casa::CountedPtr<SDMemTable>  average (const casa::Block<casa::CountedPtr<SDMemTable> >& in,
     68                                          const casa::Vector<casa::Bool>& mask,
     69                                          bool scanAverage, const std::string& weightStr);
    5970
    6071// Statistics
    6172
    62   std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in,
    63                                 const std::vector<bool>& mask, const std::string& which);
     73   std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in,
     74                                const std::vector<bool>& mask, const std::string& which);
    6475
    6576
    6677// Simple mathematical operations.  what=0 (mul) or 1 (add)
    6778
    68   SDMemTable* simpleOperate (const SDMemTable& in, casa::Float offset,
    69                             casa::Bool doAll, casa::uInt what);
     79   SDMemTable* simpleOperate (const SDMemTable& in, casa::Float offset,
     80                              casa::Bool doAll, casa::uInt what);
    7081
    7182// Average polarizations
    7283
    73   SDMemTable* averagePol (const SDMemTable& in, const casa::Vector<casa::Bool>& mask);
     84   SDMemTable* averagePol (const SDMemTable& in, const casa::Vector<casa::Bool>& mask);
    7485
    7586// Bin up spectra
    7687
    77   SDMemTable* bin (const SDMemTable& in, casa::Int width);
     88   SDMemTable* bin (const SDMemTable& in, casa::Int width);
    7889
    7990
    80 
    81 // private like functions (this is not a class so can't make them private)
     91 private:
    8292
    8393// Weighting type for time averaging
  • trunk/src/SDMathWrapper.cc

    r169 r170  
    3232
    3333#include "SDMathWrapper.h"
     34#include "SDMath.h"
     35
    3436
    3537using namespace asap;
     
    3941                                          const SDMemTableWrapper& off)
    4042{
    41     return SDMemTableWrapper(SDMath::quotient(on.getCP(),
    42                                             off.getCP()));
     43    SDMath sdm;
     44    return SDMemTableWrapper(sdm.quotient(on.getCP(), off.getCP()));
    4345}
    4446
    4547
    46 void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, casa::Float factor, casa::Bool doAll)
     48void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll)
    4749{
    4850  SDMemTable* pIn = in.getPtr();
    4951  const uInt what = 0;
    50   SDMemTable* pOut = SDMath::simpleOperate (*pIn, factor, doAll, what);
     52//
     53  SDMath sdm;
     54  SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(factor), Bool(doAll), what);
    5155  *pIn = *pOut;
    5256   delete pOut;
     
    5458
    5559SDMemTableWrapper SDMathWrapper::scale(const SDMemTableWrapper& in,
    56                           casa::Float factor, casa::Bool doAll)
     60                          float factor, bool doAll)
    5761{
    5862  const CountedPtr<SDMemTable>& pIn = in.getCP();
    5963  const uInt what = 0;
    60   return CountedPtr<SDMemTable>(SDMath::simpleOperate(*pIn, factor, doAll, what));
     64  SDMath sdm;
     65  return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(factor), Bool(doAll), what));
    6166}
    6267
    6368
    6469
    65 void SDMathWrapper::addInSitu(SDMemTableWrapper& in, casa::Float offset, casa::Bool doAll)
     70void SDMathWrapper::addInSitu(SDMemTableWrapper& in, float offset, bool doAll)
    6671{
    6772  SDMemTable* pIn = in.getPtr();
    6873  const uInt what = 1;
    69   SDMemTable* pOut = SDMath::simpleOperate (*pIn, offset, doAll, what);
     74//
     75  SDMath sdm;
     76  SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(offset), Bool(doAll), what);
    7077  *pIn = *pOut;
    7178   delete pOut;
     
    7380
    7481SDMemTableWrapper SDMathWrapper::add(const SDMemTableWrapper& in,
    75                                      casa::Float offset, casa::Bool doAll)
     82                                     float offset, bool doAll)
    7683{
    7784  const CountedPtr<SDMemTable>& pIn = in.getCP();
    7885  const uInt what = 1;
    79   return CountedPtr<SDMemTable>(SDMath::simpleOperate(*pIn, offset, doAll, what));
     86  SDMath sdm;
     87  return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(offset), Bool(doAll), what));
    8088}
    8189
     
    8391SDMemTableWrapper SDMathWrapper::hanning(const SDMemTableWrapper& in)
    8492{
    85   return SDMemTableWrapper(SDMath::hanning(in.getCP()));
     93  SDMath sdm;
     94  return SDMemTableWrapper(sdm.hanning(in.getCP()));
    8695}
    8796
     
    9099{
    91100  SDMemTable* pIn = in.getPtr();
    92   SDMemTable* pOut = SDMath::bin (*pIn, Int(width));
     101  SDMath sdm;
     102  SDMemTable* pOut = sdm.bin (*pIn, Int(width));
    93103  *pIn = *pOut;
    94104   delete pOut;
     
    99109{
    100110  const CountedPtr<SDMemTable>& pIn = in.getCP();
    101   return CountedPtr<SDMemTable>(SDMath::bin(*pIn, Int(width)));
     111  SDMath sdm;
     112  return CountedPtr<SDMemTable>(sdm.bin(*pIn, Int(width)));
    102113}
    103114
     
    106117{
    107118  SDMemTable* pIn = in.getPtr();
    108   SDMemTable* pOut = SDMath::averagePol (*pIn, mask);
     119  SDMath sdm;
     120  SDMemTable* pOut = sdm.averagePol (*pIn, mask);
    109121  *pIn = *pOut;
    110122   delete pOut;
     
    115127{
    116128  const CountedPtr<SDMemTable>& pIn = in.getCP();
    117   return CountedPtr<SDMemTable>(SDMath::averagePol(*pIn, mask));
     129  SDMath sdm;
     130  return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, mask));
    118131}
    119132
     
    123136                                            const std::string& which)
    124137{
    125   return SDMath::statistic(in.getCP(), mask, which);
     138  SDMath sdm;
     139  return sdm.statistic(in.getCP(), mask, which);
    126140}
  • trunk/src/SDMathWrapper.h

    r169 r170  
    3838
    3939#include "SDMemTableWrapper.h"
    40 #include "SDMath.h"
    4140
    4241namespace asap {
     
    4645// Quotient
    4746  SDMemTableWrapper quotient(const SDMemTableWrapper& on,
    48                             const SDMemTableWrapper& off);
     47                             const SDMemTableWrapper& off);
    4948
    5049// Multiply
    5150
    52   void scaleInSitu(SDMemTableWrapper& in, casa::Float factor, casa::Bool all);
     51  void scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll);
    5352  SDMemTableWrapper scale(const SDMemTableWrapper& in,
    54                           casa::Float factor, casa::Bool all);
     53                          float factor, bool all);
    5554
    5655// Add
    5756
    58   void addInSitu(SDMemTableWrapper& in, casa::Float offset, casa::Bool all);
    59   SDMemTableWrapper add(const SDMemTableWrapper& in, casa::Float offset, casa::Bool all);
     57  void addInSitu(SDMemTableWrapper& in, float offset, bool all);
     58  SDMemTableWrapper add(const SDMemTableWrapper& in, float offset, bool all);
    6059
    6160// Hanning
  • trunk/src/python_SDMath.cc

    r167 r170  
    3636
    3737#include "SDMathWrapper.h"
     38#include "SDMath.h"
    3839
    3940using namespace casa;
     
    5556      }
    5657      Vector<Bool> msk(mask);
    57       return SDMemTableWrapper(SDMath::average(b,msk,scanAv,weightStr));
     58//
     59      SDMath sdm;
     60      return SDMemTableWrapper(sdm.average(b, msk, Bool(scanAv), weightStr));
    5861    };
    5962  } // namespace SDMathWrapper
Note: See TracChangeset for help on using the changeset viewer.