Changeset 137


Ignore:
Timestamp:
12/23/04 15:57:26 (20 years ago)
Author:
kil064
Message:

split MathUtils::hanning function into MathUtils2.cc as the
new MU::statistics function is not templated

Location:
trunk/src
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile

    r134 r137  
    3636
    3737OBJECTS   := MathUtils.o \
     38             MathUtils2.o \
    3839             SDContainer.o \
    3940             SDMemTable.o \
  • trunk/src/MathUtils.cc

    r136 r137  
    3131
    3232#include <casa/aips.h>
    33 #include <casa/Arrays/Vector.h>
    34 #include <casa/Arrays/VectorSTLIterator.h>
     33#include <casa/Arrays/MaskedArray.h>
    3534#include <casa/Arrays/MaskArrMath.h>
    3635#include <casa/BasicSL/String.h>
     
    4140//using namespace asap;
    4241
    43 template <class T>
    44 void mathutil::hanning(Vector<T>& out, Vector<Bool>& outmask,
    45              const Vector<T>& in, const Vector<Bool>& mask,
    46              Bool relaxed, Bool ignoreOther) {
    47 
    48   Vector< Vector<T> > weights(8);
    49   Vector<Float> vals(3);
    50   vals = 0.0;weights[0] = vals;// FFF
    51   vals[0] = 1.0; vals[1] = 0.0; vals[2] = 0.0; weights[1] = vals;// TFF
    52   vals[0] = 0.0; vals[1] = 1.0; vals[2] = 0.0; weights[2] = vals;// FTF
    53   vals[0] = 1.0/3.0; vals[1] = 2.0/3.0; vals[2] = 0.0; weights[3] = vals;// TTF
    54   vals[0] = 0.0; vals[1] = 0.0; vals[2] = 1.0;weights[4] = vals;// FFT
    55   vals[0] = 0.5; vals[1] = 0.0; vals[2] = 0.5; weights[5] = vals;// TFT
    56   vals[0] = 0.0; vals[1] = 2.0/3.0; vals[2] = 1.0/3.0; weights[6] = vals;// FTT
    57   vals[0] = 0.25; vals[1] = 0.5; vals[2] = 0.25; weights[7] = vals;// TTT 
    58   // Chris' case
    59   Vector<Bool> weighted(8);
    60   if (relaxed) {
    61     weighted = False;
    62     weighted[7] = True;
    63 
    64   } else {
    65     weighted = True;
    66     weighted[0] = False;
    67   }
    68  
    69   out.resize(in.nelements());
    70   outmask.resize(mask.nelements());
    71 
    72   // make special case for first and last
    73   /// ...here
    74   // loop from 1..n-2
    75   uInt i = 1;
    76   VectorSTLIterator<T> outit(out);
    77   outit++;
    78   VectorSTLIterator<Bool> outmit(outmask);outmit++;
    79   uInt m;Vector<T>* w;
    80   for (VectorSTLIterator<T> it = outit;it != out.end()-1;++it) {
    81 
    82     m = mask[i-1] + 2*mask[i] + 4*mask[i+1];
    83     w = &(weights[m]);
    84     if (weighted[m]) {
    85       (*it) = (*w)[0]*in[i-1] + (*w)[1]*in[i] + (*w)[2]*in[i+1];
    86       (*outmit) = True;
    87     } else { // mask it
    88       (*outmit) = False;
    89     }
    90     ++i;
    91     ++outmit;
    92   }
    93 }
    9442
    9543
  • trunk/src/SDTemplates.cc

    r132 r137  
    8989template void LatticeUtilities::bin(MaskedArray<float>&, MaskedArray<float> const&, uInt, uInt);
    9090template class PtrHolder<Lattice<Float> >;
    91 #include "MathUtils.cc"
     91#include "MathUtils2.cc"
    9292namespace mathutil {
    9393  template void hanning(Vector<Float>&, Vector<Bool>&,
Note: See TracChangeset for help on using the changeset viewer.