source: branches/hpc33/src/STIdxIter.h@ 2523

Last change on this file since 2523 was 2519, checked in by Takeshi Nakazato, 13 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: Defined STIdxIter and its python interface

Test Programs: List test programs

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Defined STIdxIter module that contains STIdxIterAcc class.
Python interface for STIdxIterAcc class also defined.
STMath::almacal is rewritten using STIdxIterAcc.


File size: 3.3 KB
Line 
1#ifndef _ASAP_INDEX_ITERATOR_H_
2#define _ASAP_INDEX_ITERATOR_H_
3
4#include <vector>
5#include <casa/Containers/Block.h>
6#include <casa/Arrays/Vector.h>
7#include <casa/Arrays/Matrix.h>
8
9#include "Scantable.h"
10
11using namespace std ;
12using namespace casa ;
13
14namespace asap {
15class IndexIterator
16{
17public:
18 IndexIterator( vector< vector<uInt> > &idlist ) ;
19 Vector<uInt> current() ;
20 Bool pastEnd() ;
21 void next() ;
22private:
23 vector< vector<uInt> > idxlist_m ;
24 uInt nfield_m ;
25 Block<uInt> prod_m ;
26 Block<uInt> idx_m ;
27 uInt niter_m ;
28 uInt maxiter_m ;
29 Vector<uInt> current_m ;
30} ;
31
32class ArrayIndexIterator
33{
34public:
35 ArrayIndexIterator( Matrix<uInt> &arr,
36 vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
37 virtual ~ArrayIndexIterator() ;
38 Vector<uInt> current() ;
39 Bool pastEnd() ;
40 virtual void next() = 0 ;
41 virtual Vector<uInt> getRows() = 0 ;
42protected:
43 IndexIterator *iter_m ;
44 uInt nrow_m ;
45 uInt ncol_m ;
46 //Vector<uInt> storage_m ;
47 Matrix<uInt> arr_m ;
48 //IPosition pos_m ;
49} ;
50
51class ArrayIndexIteratorNormal : public ArrayIndexIterator
52{
53public:
54 ArrayIndexIteratorNormal( Matrix<uInt> &arr,
55 vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
56 void next() ;
57 Vector<uInt> getRows() ;
58private:
59 Block<uInt> storage_m ;
60 IPosition pos_m ;
61} ;
62
63class ArrayIndexIteratorAcc : public ArrayIndexIterator
64{
65public:
66 ArrayIndexIteratorAcc( Matrix<uInt> &arr,
67 vector< vector<uInt> > idlist=vector< vector<uInt> >() ) ;
68 void next() ;
69 Vector<uInt> getRows() ;
70private:
71 Int isChanged( Vector<uInt> &idx ) ;
72 uInt *updateStorage( Int &icol, uInt *base, uInt &v ) ;
73
74 Vector<uInt> prev_m ;
75 Block<uInt> storage_m ;
76 IPosition pos_m ;
77 Block<uInt> len_m ;
78} ;
79
80class STIdxIter
81{
82public:
83 STIdxIter() ;
84 STIdxIter( const string &name,
85 const vector<string> &cols ) ;
86 STIdxIter( const CountedPtr<Scantable> &s,
87 const vector<string> &cols ) ;
88 virtual ~STIdxIter() ;
89 vector<uInt> currentSTL() { return tovector( iter_m->current() ) ; } ;
90 Vector<uInt> current() { return iter_m->current() ; } ;
91 Bool pastEnd() { return iter_m->pastEnd() ; } ;
92 void next() { iter_m->next() ; } ;
93 vector<uInt> getRowsSTL() { return tovector( iter_m->getRows() ) ; } ;
94 Vector<uInt> getRows() { return iter_m->getRows() ; } ;
95protected:
96 ArrayIndexIterator *iter_m ;
97 virtual void init( Table &t,
98 const vector<string> &cols ) = 0 ;
99private:
100 vector<uInt> tovector( Vector<uInt> v ) ;
101} ;
102
103class STIdxIterNormal : public STIdxIter
104{
105public:
106 STIdxIterNormal() ;
107 STIdxIterNormal( const string &name,
108 const vector<string> &cols ) ;
109 STIdxIterNormal( const CountedPtr<Scantable> &s,
110 const vector<string> &cols ) ;
111 ~STIdxIterNormal() ;
112protected:
113 void init( Table &t,
114 const vector<string> &cols ) ;
115} ;
116
117class STIdxIterAcc : public STIdxIter
118{
119public:
120 STIdxIterAcc() ;
121 STIdxIterAcc( const string &name,
122 const vector<string> &cols ) ;
123 STIdxIterAcc( const CountedPtr<Scantable> &s,
124 const vector<string> &cols ) ;
125 ~STIdxIterAcc() ;
126protected:
127 void init( Table &t,
128 const vector<string> &cols ) ;
129} ;
130
131} // namespace
132#endif /* _ASAP_INDEX_ITERATOR_H_ */
Note: See TracBrowser for help on using the repository browser.