casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFFloatLattice.h
Go to the documentation of this file.
1 //# RFFloatLattice.h: this defines RFFloatLattice
2 //# Copyright (C) 2000,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 #ifndef FLAGGING_RFFLOATLATTICE_H
28 #define FLAGGING_RFFLOATLATTICE_H
29 
30 #include <casa/Arrays/Matrix.h>
33 #include <vector>
34 
35 namespace casa { //# NAMESPACE CASA - BEGIN
36 
37 
38 // <summary>
39 // RFFloatLatticeIterator: iterator over a cubic buffer
40 // </summary>
41 
42 // <use visibility=local>
43 
44 // <reviewed reviewer="" date="" tests="" demos="">
45 // </reviewed>
46 
47 // <prerequisite>
48 // <li> std::vector, Matrix
49 // </prerequisite>
50 //
51 // <synopsis>
52 // See RFFloatLattice, below
53 // </synopsis>
54 //
55 // <todo asof="2001/04/16">
56 // <li> add this feature
57 // <li> fix this bug
58 // <li> start discussion of this possible extension
59 // </todo>
60 
61 class RFFloatLattice;
62 
64 {
65  private:
66  // vector<bool>: is a space-efficient specialization of std::vector for the type bool
67  std::vector<std::vector<bool> > *lattice;
68 
70 
71  unsigned int iter_pos;
72 
73  unsigned n_chan, n_ifr, /* n_time,*/ n_bit, n_corr;
74 
75  void update_curs();
76 
77  public:
78  // default constructor creates empty iterator
80 
81  // creates and attaches to lattice
82  RFFloatLatticeIterator(std::vector<std::vector<bool> > *lat,
83  unsigned nchan, unsigned nifr,
84  unsigned ntime, unsigned nbit, unsigned ncorr);
85 
86  // destructor
88 
89  // resets the lattice iterator to beginning, returns cursor
91 
92  // advances internal iterator to specified slot along the Z axis, returns cursor
94 
95  // returns position of internal iterator
97  { return iter_pos; }
98 
99  // returns internal cursor
101 
102  // returns element at i,j of cursor
104 
105  void flush_curs();
106 };
107 
108 
109 // <summary>
110 // RFFloatLatice: a cubic lattice
111 // </summary>
112 
113 // <use visibility=local>
114 
115 // <reviewed reviewer="" date="" tests="" demos="">
116 // </reviewed>
117 
118 // <prerequisite>
119 // <li> TempLattice
120 // </prerequisite>
121 //
122 // <synopsis>
123 // RFFloatLattice is a [NX,NY,NZ] vector of Matrices which
124 // is iterated over the Z axis.
125 // While a vector of Matrices may not be localized in memory, it has the
126 // advantage that the total amount of memory allocated can exceed
127 // the available RAM, which is probably not possible if allocated as a
128 // single giant block.
129 // Each element of the matrices is a few bits, therefore (in order to
130 // save memory), the full matrix is represented as a bitsequence, which
131 // is converted to casacore::Matrix<casacore::Float> on the fly.
132 //
133 // The buffer is no longer implemented using a casacore::TempLattice because the
134 // template parameter to casacore::TempLattice is restricted to certain types, and
135 // cannot be dynamic_bitset<>. Besides, casacore::TempLattice is currently(?)
136 // *not* well implemented: it creates casacore::TempLattice disk files although most
137 // of the RAM is free.
138 //
139 // If more memory than avilable RAM is requested, swapping will occur.
140 // The underlying OS probably knows better when to swap!
141 //
142 // </synopsis>
143 //
144 // <motivation>
145 // Many flagging agents make use of cubic lattices (typically, to maintain
146 // [NCHAN,NIFR,NTIME] cubes of something) in an identical way. This class
147 // provides a clean and convenient interface to the basic functions.
148 // </motivation>
149 //
150 // <templating arg=T>
151 // <li> same as Matrix
152 // </templating>
153 //
154 // <todo asof="2001/04/16">
155 // <li> add this feature
156 // <li> fix this bug
157 // <li> start discussion of this possible extension
158 // </todo>
159 
161 {
162 protected:
164  std::vector<std::vector<bool> > lat;
167 
168 public:
169 // default constructor creates empty cube
170  RFFloatLattice();
171 // creates NX x NY x NZ cube
173 // creates NX x NY x NZ cube and fills with initial value
175 // destructor
176  ~RFFloatLattice();
177 
178 // creates NX x NY x NZ cube
179 // tile_mb is the tile size, in MB (when using paging)
180  void init ( casacore::uInt nx,casacore::uInt ny,casacore::uInt nz, casacore::uInt ncorr, casacore::uInt nAgent, casacore::Int maxmem=-1,casacore::Int tile_mb=2 );
181 // creates NX x NY x NZ cube and fills with initial value
182 // tile_mb is the tile size, in MB (when using paging)
183  void init ( casacore::uInt nx,casacore::uInt ny,casacore::uInt nz, casacore::uInt ncorr, casacore::uInt nAgent, const casacore::Float &init_val,casacore::Int maxmem=-1,casacore::Int tile_mb=2 );
184 // destroys cube
185  void cleanup ();
186 // returns size of cube
188  { return nx*ny*nz*sizeof(casacore::Float)/(1024*1024) + 1; }
189 
190 // resets the lattice iterator to beginning.
192  casacore::Bool will_write=true );
193 
194 // advances internal iterator to specified slot along the Z axis, returns cursor
196 
197 // returns position of internal iterator
199 
200 // returns shape
201  const casacore::IPosition & shape () { return lat_shape; }
202 
203 // returns internal cursor
205 
206 // returns element at i,j of cursor
208 
209 // provides access to lattice itself
210 // std::vector<std::vector<bool> > & lattice() { return lat; }
211 
212 // provides access to iterator
214 
215 // creates a new iterator for this lattice
217 };
218 
219 
220 
221 } //# NAMESPACE CASA - END
222 
223 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
int Int
Definition: aipstype.h:50
RFFloatLatticeIterator iter
casacore::Matrix< casacore::Float > curs
casacore::IPosition lat_shape
RFFloatLatticeIterator newIter()
creates a new iterator for this lattice
casacore::Float & operator()(casacore::uInt i, casacore::uInt j)
returns element at i,j of cursor
void init(casacore::uInt nx, casacore::uInt ny, casacore::uInt nz, casacore::uInt ncorr, casacore::uInt nAgent, casacore::Int maxmem=-1, casacore::Int tile_mb=2)
creates NX x NY x NZ cube tile_mb is the tile size, in MB (when using paging)
const casacore::IPosition & shape()
returns shape
RFFloatLatticeIterator & iterator()
provides access to lattice itself std::vector&lt;std::vector&lt;bool&gt; &gt; &amp; lattice() { return lat; } ...
RFFloatLatice: a cubic lattice.
casacore::Int position()
returns position of internal iterator
casacore::Matrix< casacore::Float > * advance(casacore::Int iz)
advances internal iterator to specified slot along the Z axis, returns cursor
std::vector< std::vector< bool > > lat
~RFFloatLattice()
destructor
RFFloatLatticeIterator()
default constructor creates empty iterator
void cleanup()
destroys cube
RFFloatLattice()
default constructor creates empty cube
casacore::Matrix< casacore::Float > * cursor()
returns internal cursor
static casacore::uInt estimateMemoryUse(casacore::uInt nx, casacore::uInt ny, casacore::uInt nz)
returns size of cube
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
~RFFloatLatticeIterator()
destructor
float Float
Definition: aipstype.h:54
casacore::Matrix< casacore::Float > * reset(casacore::Bool will_read=true, casacore::Bool will_write=true)
resets the lattice iterator to beginning.
casacore::Matrix< casacore::Float > * cursor()
returns internal cursor
casacore::Matrix< casacore::Float > * reset()
resets the lattice iterator to beginning, returns cursor
casacore::Matrix< casacore::Float > * advance(casacore::uInt iz)
advances internal iterator to specified slot along the Z axis, returns cursor
casacore::uInt position()
returns position of internal iterator
casacore::Float & operator()(casacore::uInt i, casacore::uInt j)
returns element at i,j of cursor
unsigned int uInt
Definition: aipstype.h:51
std::vector< std::vector< bool > > * lattice
vector&lt;bool&gt;: is a space-efficient specialization of std::vector for the type bool ...