casacore
Loading...
Searching...
No Matches
MaskedArray.h
Go to the documentation of this file.
1// # MaskedArray.h: A templated N-D masked array class with zero origin.
2// # Copyright (C) 1993,1994,1995,1996,1997,1999,2000,2005
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: casa-feedback@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#ifndef CASA_MASKEDARRAY2_H
27#define CASA_MASKEDARRAY2_H
28
29// # Includes
30#include "ArrayLogical.h"
31#include "ArrayFwd.h"
32#include "IPosition.h"
33#include "MaskLogiArrFwd.h"
34
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// # Forward declarations
38// # <note role=warning>
39// # Array.h cannot be included in this header file. Anything needed
40// # from it must be forwarded. This is why LogicalArrayFwd.h is
41// # included instead of LogicalArray.h .
42// # </note>
43class Slicer;
44
45// <summary> Class for masking an Array for operations on that Array. </summary>
46// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMaskedArray tMaskArrExcp">
47// </reviewed>
48//
49// <prerequisite>
50// <li> <linkto class=Array>Array</linkto>
51// <li> <linkto group="LogiArray.h#LogicalArray">LogicalArray</linkto>
52// </prerequisite>
53//
54// <etymology>
55// MaskedArray is a class for masking elements of an Array while performing
56// operations on that Array.
57// </etymology>
58//
59// <synopsis>
60// A MaskedArray is an association between an Array and a mask. The mask
61// selects elements of the Array. Only elements of the Array where the
62// corresponding element of the mask is true are defined. Thus, operations
63// on a MaskedArray only operate on those elements of the Array where the
64// corresponding element of the mask is true.
65//
66// A MaskedArray should be thought of as a manipulator for an Array, analogous
67// to an iterator. It allows one to perform whole Array operations on selected
68// elements of the Array.
69//
70// The mask used in the constructor for the MaskedArray must conform to
71// the Array, thus have the same shape.
72// The internal mask is (will be) copy constructed with reference semantics
73// from the input mask. Therefore, it is (will be) possible to change the
74// internal mask by changing values in the input mask *after* the MaskedArray
75// has been constructed. To ensure that the internal mask is independent of
76// the input mask after construction, use mask.copy() as the input argument.
77//
78// One can explicitly construct a MaskedArray from an Array and a mask or
79// a MaskedArray and a mask. One can also use operator() on an Array or
80// a MaskedArray to implicitly create a MaskedArray.
81//
82// One can create a MaskedArray from a MaskedArray and a mask. The resulting
83// MaskedArray has as its Array the Array from the original MaskedArray.
84// The mask for the resulting MaskedArray is the AND of the mask from the
85// original MaskedArray and the input mask.
86//
87// Any operation involving a MaskedArray or a set of MaskedArrays is only
88// performed for those elements where the AND of the masks is true.
89//
90// Any operation involving a MaskedArray or a set of MaskedArrays results
91// in a MaskedArray whose mask is the AND of the masks of the original
92// MaskedArrays. The only exception to this is assignment, where the
93// mask determines which elements of the underlying Array are assigned.
94//
95// Masks, which are LogicalArrays, can be constructed by logical operations
96// involving Arrays. They can also, of course, be constructed by individually
97// setting individual elements of an LogicalArray.
98//
99// MaskedArrays constructed directly from Arrays are by default writeable.
100// MaskedArrays constructed indirectly from Arrays by <src>operator()</src>
101// are writeable if the Array is non-const and are readonly if the
102// Array is const.
103// MaskedArrays constructed from other MaskedArrays, either directly by
104// constructors or indirectly by <src>operator()</src>, are by default
105// writeable if the input MaskedArray is writeable, and readonly if the
106// input MaskedArray is readonly.
107//
108// A given MaskedArray can be set to be readonly. One specifies
109// this in the constructor with the bool argument <src>isreadonly</src>,
110// or calls the <src>setReadOnly()</src> member function.
111// A MaskedArray which would default to be readonly cannot be forced to
112// be writeable. It will remain readonly even if the bool argument
113// <src>isreadonly</src> is set to be <src>false</src>.
114//
115// The <src>isReadOnly(),</src> member function is used to test whether
116// the MaskedArray is readonly.
117//
118// Member functions which change the MaskedArray test to see whether
119// the MaskedArray is readonly, and throw an ArrayError exception if
120// it is. These member functions are:
121// <ul>
122// <li> <src>operator=()</src>
123// <li> <src>getRWArray()</src>
124// <li> <src>getRWArrayStorage()</src>
125// <li> <src>putArrayStorage()</src>
126// </ul>
127//
128// The copy() member function makes a deep copy of a MaskedArray.
129// By default it returns a writeable MaskedArray, but the MaskedArray
130// returned can be made readonly by using the bool argument "isreadonly"
131// to copy() (or by calling setReadOnly() on the new MaskedArray).
132//
133// The valid elements of the MaskedArray can be manipulated as a
134// "compressed" Array which contains only the valid elements.
135// The number of elements in this "compressed" Array is the number of valid
136// elements in the MaskedArray, <src>nelementsValid()</src>.
137// The "compressed" Array can have any shape which meets this requirement.
138// The MaskedArray can have any shape.
139//
140// The <src>getCompressedArray()</src> member functions get a compressed
141// Array from the valid members of the MaskedArray, while the
142// <src>setCompressedArray()</src> member function sets the valid members
143// of the MaskedArray from the input compressed Array.
144//
145// Many mathematical and logical global operators and functions which operate
146// on MaskedArrays are defined. Typically, they are defined for all sensible
147// combinations of MaskedArrays, Arrays, and scalars.
148//
149// Mathematical global operators and functions are defined in
150// Arrays/MaskArrMath.h .
151// The list is:
152// <ul>
153// <li> operator+= ()
154// <li> operator-= ()
155// <li> operator*= ()
156// <li> operator/= ()
157// <li> operator+ ()
158// <li> operator- ()
159// <li> operator* ()
160// <li> operator/ ()
161// <li> sin ()
162// <li> cos ()
163// <li> tan ()
164// <li> asin ()
165// <li> acos ()
166// <li> atan ()
167// <li> sinh ()
168// <li> cosh ()
169// <li> tanh ()
170// <li> exp ()
171// <li> log ()
172// <li> log10 ()
173// <li> sqrt ()
174// <li> abs ()
175// <li> fabs ()
176// <li> ceil ()
177// <li> floor ()
178// <li> atan2 ()
179// <li> fmod ()
180// <li> pow ()
181// <li> minMax ()
182// <li> min ()
183// <li> max ()
184// <li> indgen ()
185// <li> sum ()
186// <li> sumsquares ()
187// <li> product ()
188// <li> mean ()
189// <li> variance ()
190// <li> stddev ()
191// <li> avdev ()
192// <li> median ()
193// <li> square ()
194// <li> cube ()
195// </ul>
196//
197// Logical global operators and functions are defined in
198// Arrays/MaskArrLogi.h .
199// The list is:
200// <ul>
201// <li> allLE ()
202// <li> allLT ()
203// <li> allGE ()
204// <li> allGT ()
205// <li> allEQ ()
206// <li> allNE ()
207// <li> allAND ()
208// <li> allOR ()
209// <li> anyLE ()
210// <li> anyLT ()
211// <li> anyGE ()
212// <li> anyGT ()
213// <li> anyEQ ()
214// <li> anyNE ()
215// <li> anyAND ()
216// <li> anyOR ()
217// <li> operator<= ()
218// <li> operator< ()
219// <li> operator>= ()
220// <li> operator< ()
221// <li> operator== ()
222// <li> operator!= ()
223// <li> operator&& ()
224// <li> operator|| ()
225// </ul>
226// </synopsis>
227//
228// <example>
229// Use an explicit MaskedArray to limit the maximum value of an Array.
230//
231// <srcblock>
232// Vector<int> arr (20);
233// . . .
234// MaskedArray<int> marr (arr, (arr > 5));
235// marr = 5;
236// </srcblock>
237//
238// This sets all elements of arr which are greater than 5 to 5.
239// </example>
240//
241// <example>
242// Use an implicit MaskedArray to limit the minimum value of an Array.
243//
244// <srcblock>
245// Vector<int> arr (20);
246// . . .
247// arr (arr < 0) = 0;
248// </srcblock>
249//
250// This sets all elements of arr which are less than 0 to 0.
251// </example>
252//
253// <example>
254// It does not matter where in an expression the MaskedArrays are located.
255// The operation is only performed on those elements where the AND of the
256// masks is true.
257//
258// The following expressions are all equivalent.
259// The first (and second) expressions are the most efficient, since the sum
260// is only performed for those elements where ((a > 0) && (b > 0)).
261// The third example is less efficient, since the sum is performed for
262// all elements of a and b, and then the assignment is only performed for
263// those elements where ((a > 0) && (b > 0)).
264//
265// <srcblock>
266// Vector<int> arr (20);
267// Vector<int> a (20);
268// Vector<int> b (20);
269// . . .
270// arr = a(a > 0) + b(b > 0);
271//
272// arr = a(b > 0) + b(a > 0);
273//
274// arr ((a > 0) && (b > 0)) = a + b;
275//
276// arr = (a + b) ((a > 0) && (b > 0));
277//
278// arr (a > 0) = a + b(b > 0);
279//
280// </srcblock>
281//
282// All of these expressions set those elements of arr where
283// ((a > 0) && (b > 0)) to a + b. Those elements of arr where the condition
284// is false are unchanged.
285// </example>
286//
287// <example>
288// This example extracts the valid elements of the MaskedArray as a
289// "compressed" Vector, manipulates this Vector, and then puts the result
290// back into the MaskedArray.
291//
292// <srcblock>
293// Matrix<int> arr (20,5);
294// . . .
295// MaskedArray<int> marr (arr, (arr>0) && (arr<10));
296// Vector<int> vec (marr.getCompressedArray());
297// . . .
298// marr.setCompressedArray (vec);
299// </srcblock>
300//
301// </example>
302//
303// <motivation>
304// A MaskedArray is an association between an Array and a LogicalArray which
305// masks the Array. It allows one to perform whole Array manipulations
306// with a single expression, selecting those elements of the Array to modify
307// based either on a logical expression, typically involving some of the
308// Arrays involved in the expression, or based on a specifically set mask.
309// </motivation>
310//
311// <todo asof="$DATE:$>
312// <li> Consider whether there should be constructors for masks
313// specified as Array<bool>.
314// <li> Change constructors to always do copy construction with
315// reference semantics when creating the internal mask.
316// </todo>
317
318template <typename T>
320 public:
324
325 // Default constructor for a MaskedArray does not allocate any memory
326 // for the Data array or Mask. Hence the masked array
327 // should not be used until some data is allocated to the object using one
328 // of the set functions.
330 // Reset the data and mask of the the MaskedArray. There should perhaps be
331 // a whole family of setData functions with different arguements,
332 // analogous to the constructors. However these are sufficient for the
333 // moment.
334 void setData(const array_type &data, const mask_type &mask, bool isReadOnly = false);
335 void setData(const masked_array_type &array, bool isReadOnly = false);
336 // Create a MaskedArray from an Array and a LogicalArray.
337 //
338 // The internal mask is a total copy of the input mask, and is
339 // completely independent of the input mask.
340 //
341 // The Array is copy constructed, which means that it is a really smart
342 // pointer to the underlying Block, and shares this Block with the input
343 // Array.
344 //
345 // By default, the MaskedArray constructed is writeable. If
346 // <src>isreadonly</src> is <src>true</src>, then the MaskedArray
347 // returned is readonly.
348 //
349 // <thrown>
350 // <li> ArrayConformanceError
351 // </thrown>
352 //
353 // <group>
354 MaskedArray(const array_type &inarray, const LogicalArray &inmask, bool isreadonly);
355 MaskedArray(const array_type &inarray, const LogicalArray &inmask);
356 // </group>
357
358 // Create a MaskedArray from a MaskedArray and a LogicalArray.
359 //
360 // The internal mask is the AND of the input mask and the mask of
361 // the input MaskedArray.
362 //
363 // The Array from the input MaskedArray is copy constructed, which
364 // means that it is a really smart pointer to the underlying Block, and
365 // shares this Block with the Array from the input MaskedArray.
366 //
367 // By default, the MaskedArray constructed is writeable if the input
368 // MaskedArray is writeable, and readonly if the input MaskedArray
369 // is readonly. If <src>isreadonly</src> is <src>true</src>, then
370 // the MaskedArray returned is readonly. If <src>isreadonly</src> is
371 // <src>false</src> and the input MaskedArray is readonly, then the
372 // constructed MaskedArray is readonly.
373 //
374 // <thrown>
375 // <li> ArrayConformanceError
376 // </thrown>
377 //
378 // <group>
379 MaskedArray(const masked_array_type &inarray, const LogicalArray &inmask, bool isreadonly);
380 MaskedArray(const masked_array_type &inarray, const LogicalArray &inmask);
381 // </group>
382
383 // Create a MaskedArray from an Array and a MaskedLogicalArray.
384 //
385 // The internal mask is the AND of the internal LogicalArray and the
386 // internal mask of the MaskedLogicalArray.
387 //
388 // The Array is copy constructed, which means that it is a really smart
389 // pointer to the underlying Block, and shares this Block with the input
390 // Array.
391 //
392 // By default, the MaskedArray constructed is writeable. If
393 // <src>isreadonly</src> is <src>true</src>, then the MaskedArray
394 // returned is readonly.
395 //
396 // <thrown>
397 // <li> ArrayConformanceError
398 // </thrown>
399 //
400 // <group>
401 MaskedArray(const array_type &inarray, const MaskedLogicalArray &inmask, bool isreadonly);
402 MaskedArray(const array_type &inarray, const MaskedLogicalArray &inmask);
403 // </group>
404
405 // Create a MaskedArray from a MaskedArray and a MaskedLogicalArray.
406 //
407 // The internal mask is the AND of the internal LogicalArray and the
408 // internal mask of the MaskedLogicalArray, ANDed with the mask of
409 // the input MaskedArray.
410 //
411 // The Array from the input MaskedArray is copy constructed, which
412 // means that it is a really smart pointer to the underlying Block, and
413 // shares this Block with the Array from the input MaskedArray.
414 //
415 // By default, the MaskedArray constructed is writeable if the input
416 // MaskedArray is writeable, and readonly if the input MaskedArray
417 // is readonly. If <src>isreadonly</src> is <src>true</src>, then
418 // the MaskedArray returned is readonly. If <src>isreadonly</src> is
419 // <src>false</src> and the input MaskedArray is readonly, then the
420 // constructed MaskedArray is readonly.
421 //
422 // <thrown>
423 // <li> ArrayConformanceError
424 // </thrown>
425 //
426 // <group>
427 MaskedArray(const masked_array_type &inarray, const MaskedLogicalArray &inmask, bool isreadonly);
428 MaskedArray(const masked_array_type &inarray, const MaskedLogicalArray &inmask);
429 // </group>
430
431 // Copy constructor.
432 //
433 // The internal mask is a total copy of the mask from the input
434 // MaskedArray, and is completely independent of this input mask.
435 //
436 // The Array from the input MaskedArray is copy constructed, which
437 // means that it is a really smart pointer to the underlying Block, and
438 // shares this Block with the Array from the input MaskedArray.
439 //
440 // By default, the MaskedArray constructed is writeable if the input
441 // MaskedArray is writeable, and readonly if the input MaskedArray
442 // is readonly. If <src>isreadonly</src> is <src>true</src>, then
443 // the MaskedArray returned is readonly. If <src>isreadonly</src> is
444 // <src>false</src> and the input MaskedArray is readonly, then the
445 // constructed MaskedArray is readonly.
446 //
447 // <group>
448 MaskedArray(const masked_array_type &other, bool isreadonly);
450
451 // The source is left empty after moving
453 // </group>
454
455 // Return a MaskedArray. The new MaskedArray is masked by the input
456 // LogicalArray "anded" with the mask of the original MaskedArray.
457 // This mask must conform to the array.
458 //
459 // The MaskedArray constructed is writeable if the input
460 // MaskedArray is writeable, and readonly if the input MaskedArray
461 // is readonly.
462 //
464
465 // Return a MaskedArray. The new MaskedArray is masked by the input
466 // MaskedLogicalArray "anded" with the mask of the original MaskedArray.
467 // This mask must conform to the array.
468 //
469 // The MaskedArray constructed is writeable if the input
470 // MaskedArray is writeable, and readonly if the input MaskedArray
471 // is readonly.
472 //
474
475 // Get a reference to an array part which extends from "start" to end."
476 // <group>
478 // Along the ith axis, every inc[i]'th element is chosen.
479 masked_array_type operator()(const IPosition &start, const IPosition &end, const IPosition &inc);
480 // </group>
481
482 // Get a reference to an array using a Slicer.
484
485 // Make a copy of the masked array.
486 //
487 // This is a deep copy. The Array and mask components of the returned
488 // MaskedArray are deep copies of the Array and mask in the input
489 // MaskedArray pointed to by this. In other words, the Array and mask
490 // in the output MaskedArray are completely independent of those in
491 // the input MaskedArray.
492 //
493 // By default, the MaskedArray returned is writeable. If
494 // <src>isreadonly</src> is <src>true</src>, then the MaskedArray
495 // returned is readonly.
496 //
497 // <group>
498 masked_array_type copy(bool isreadonly) const;
500 // </group>
501
502 // Return the internal Array.
503 const array_type &getArray() const;
504
505 // Return the internal Array, writeable.
506 //
507 // <thrown>
508 // <li> ArrayError
509 // </thrown>
510 //
512
513 // Return the (const) internal Mask.
514 const mask_type &getMask() const;
515
516 // The dimensionality of this masked array.
517 size_t ndim() const;
518
519 // The number of elements of this masked array.
520 // This is the number of elements in the underlying Array.
521 // <group>
522 size_t nelements() const;
523 size_t size() const { return nelements(); }
524 // </group>
525
526 // The number of valid elements of this masked array.
527 // This is the number of elements of the mask which are TRUE.
528 size_t nelementsValid() const;
529
530 // Check to see if the masked array is consistent. This is about the same
531 // thing as checking for invariants. If AIPS_DEBUG is defined, this is
532 // invoked after construction and on entry to most member functions.
533 bool ok() const;
534
535 // Are the shapes identical?
536 // <group>
537 bool conform(const array_type &other) const;
538 bool conform(const masked_array_type &other) const;
539 // </group>
540
541 // The length of each axis.
542 const IPosition &shape() const { return pArray->shape(); }
543
544 // Is the array read only?
545 bool isReadOnly() const { return isRO; }
546
547 // Set the array to be read only.
548 void setReadOnly() const;
549
550 // Copy the values in inarray to this, only copying those elements
551 // for which the corresponding mask element is true.
552 // <thrown>
553 // <li> ArrayConformanceError
554 // <li> ArrayError
555 // </thrown>
556 // TODO rename, see copy assignment operator.
559
560 // Copies/moves the values in other to this, only copying those elements
561 // for which the logical AND of the corresponding mask elements
562 // of both MaskedArrays is true.
563 //
564 // <thrown>
565 // <li> ArrayConformanceError
566 // <li> ArrayError
567 // </thrown>
568 //
569 // <group>
570 // TODO this should be renamed: assignment operator should make
571 // obervable state equal, which should thus include getArray().
574 // </group>
575
576 // Set every element of this array to "value", only setting those elements
577 // for which the corresponding mask element is true.
578 // In other words, a scalar behaves as if it were a constant conformant
579 // array.
580 //
581 // <thrown>
582 // <li> ArrayError
583 // </thrown>
584 //
586
587 // Return a "compressed" Array containing only the valid
588 // elements of the MaskedArray. The number of elements in the
589 // Array will be <src>nelementsValid()</src> for the
590 // MaskedArray. The MaskedArray can have any shape.
591 // <group>
592
593 // The returned Array will have dimension one.
595
596 // The returned Array will have the input shape. This shape must
597 // give the returned Array the required number of elements.
598 //
599 // <thrown>
600 // <li> ArrayError
601 // </thrown>
602 //
604
605 // </group>
606
607 // Fill the argument "compressed" Array with only the
608 // valid elements of the MaskedArray. The size of the
609 // Array must be <src>nelementsValid()</src> for the MaskedArray.
610 // The Array can have any shape which meets this requirement.
611 // The MaskedArray can have any shape.
612 //
613 // <thrown>
614 // <li> ArrayError
615 // </thrown>
616 //
617 void getCompressedArray(array_type &inarr) const;
618
619 // Set only the valid elements of the MaskedArray from the argument
620 // "compressed" Array. The size of the
621 // Array must be <src>nelementsValid()</src> for the MaskedArray.
622 // The Array can have any shape which meets this requirement.
623 // The MaskedArray can have any shape.
624 //
625 // <thrown>
626 // <li> ArrayError
627 // </thrown>
628 //
629 void setCompressedArray(const array_type &inarr);
630
631 // Manipulate the storage for the underlying Array.
632 // See the description of the corresponding Array functions
633 // for more information.
634 // <group>
635 const T *getArrayStorage(bool &deleteIt) const;
636 //
637 // <thrown>
638 // <li> ArrayError
639 // </thrown>
640 //
641 T *getRWArrayStorage(bool &deleteIt) const;
642 //
643 void freeArrayStorage(const T *&storage, bool deleteIt) const;
644 //
645 // <thrown>
646 // <li> ArrayError
647 // </thrown>
648 //
649 void putArrayStorage(T *&storage, bool deleteAndCopy) const;
650 // </group>
651
652 // Manipulate the storage for the underlying Mask.
653 // See the description of the corresponding Array functions
654 // for more information.
655 // <group>
656 const LogicalArrayElem *getMaskStorage(bool &deleteIt) const;
657 //
658 void freeMaskStorage(const LogicalArrayElem *&storage, bool deleteIt) const;
659 // </group>
660
661 protected:
662 // The array.
663 std::unique_ptr<array_type> pArray;
664
665 // The mask.
666 std::unique_ptr<mask_type> pMask;
667
668 // Cache the number of valid elements.
670
671 // Is the number of valid elements cache OK?
672 // i.e. has it been calculated?
674
675 // Is the array read only?
676 bool isRO;
677};
678
679// <summary> General global functions for MaskedArrays, and MaskedArrays and Arrays. </summary>
680// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMaskedArray">
681//
682// <prerequisite>
683// <li> <linkto class=Array>Array</linkto>
684// <li> <linkto group="LogiArray.h#LogicalArray">LogicalArray</linkto>
685// <li> <linkto class=MaskedArray>MaskedArray</linkto>
686// </prerequisite>
687//
688// <synopsis>
689// These are generally useful global functions which operate on all
690// MaskedArrays, or on MaskedArrays and Arrays.
691// </synopsis>
692//
693// <linkfrom anchor="MaskedArray general global functions" classes="MaskedArray Array Vector Matrix
694// Cube">
695// <here>MaskedArray general global functions</here> -- General global
696// functions for MaskedArrays, and between MaskedArrays and Arrays.
697// </linkfrom>
698//
699// <group name="MaskedArray general global functions">
701// Test conformance for masked arrays and arrays of different types.
702// Are the shapes identical?
703//
704// <group name=conform2>
705//
706template <typename TLL, typename TRR>
707bool conform2(const MaskedArray<TLL> &left, const Array<TRR> &right);
708template <typename TLL, typename TRR>
709bool conform2(const Array<TLL> &left, const MaskedArray<TRR> &right);
710template <typename TLL, typename TRR>
711bool conform2(const MaskedArray<TLL> &left, const MaskedArray<TRR> &right);
712//
713// </group>
714
715// </group>
716
717} // namespace casacore
718
719#include "MaskedArray.tcc"
720
721#endif
masked_array_type operator()(const IPosition &start, const IPosition &end)
Get a reference to an array part which extends from "start" to end.
void setReadOnly() const
Set the array to be read only.
masked_array_type operator()(const Slicer &)
Get a reference to an array using a Slicer.
std::unique_ptr< mask_type > pMask
MaskedArray(const masked_array_type &other, bool isreadonly)
Copy constructor.
MaskedArray(const masked_array_type &other)
array_type & getRWArray() const
Return the internal Array, writeable.
const T * getArrayStorage(bool &deleteIt) const
Manipulate the storage for the underlying Array.
masked_array_type copy(bool isreadonly) const
Make a copy of the masked array.
Array< T > getCompressedArray(const IPosition &shape) const
The returned Array will have the input shape.
MaskedArray()
Default constructor for a MaskedArray does not allocate any memory for the Data array or Mask.
masked_array_type & operator=(const T &value)
Set every element of this array to "value", only setting those elements for which the corresponding m...
MaskedArray< LogicalArrayElem > masked_array_type
masked_array_type operator()(const LogicalArray &mask) const
Return a MaskedArray.
MaskedArray(const masked_array_type &inarray, const LogicalArray &inmask, bool isreadonly)
Create a MaskedArray from a MaskedArray and a LogicalArray.
void getCompressedArray(array_type &inarr) const
Fill the argument "compressed" Array with only the valid elements of the MaskedArray.
MaskedArray(const masked_array_type &inarray, const MaskedLogicalArray &inmask, bool isreadonly)
Create a MaskedArray from a MaskedArray and a MaskedLogicalArray.
const mask_type & getMask() const
Return the (const) internal Mask.
size_t nelementsValid() const
The number of valid elements of this masked array.
masked_array_type & operator=(const array_type &inarray)
Copy the values in inarray to this, only copying those elements for which the corresponding mask elem...
void setData(const array_type &data, const mask_type &mask, bool isReadOnly=false)
Reset the data and mask of the the MaskedArray.
MaskedArray(const array_type &inarray, const LogicalArray &inmask, bool isreadonly)
Create a MaskedArray from an Array and a LogicalArray.
void freeMaskStorage(const LogicalArrayElem *&storage, bool deleteIt) const
const array_type & getArray() const
Return the internal Array.
void setData(const masked_array_type &array, bool isReadOnly=false)
std::unique_ptr< array_type > pArray
Array< LogicalArrayElem > array_type
void putArrayStorage(T *&storage, bool deleteAndCopy) const
MaskedArray(const masked_array_type &inarray, const MaskedLogicalArray &inmask)
masked_array_type copy() const
void freeArrayStorage(const T *&storage, bool deleteIt) const
Array< LogicalArrayElem > mask_type
masked_array_type & operator=(masked_array_type &&other)
const IPosition & shape() const
The length of each axis.
size_t nelements() const
The number of elements of this masked array.
MaskedArray(const masked_array_type &inarray, const LogicalArray &inmask)
const LogicalArrayElem * getMaskStorage(bool &deleteIt) const
Manipulate the storage for the underlying Mask.
MaskedArray(const array_type &inarray, const LogicalArray &inmask)
masked_array_type operator()(const MaskedLogicalArray &mask) const
Return a MaskedArray.
size_t ndim() const
The dimensionality of this masked array.
masked_array_type & operator=(const masked_array_type &other)
Copies/moves the values in other to this, only copying those elements for which the logical AND of th...
Array< T > getCompressedArray() const
Return a "compressed" Array containing only the valid elements of the MaskedArray.
void setCompressedArray(const array_type &inarr)
Set only the valid elements of the MaskedArray from the argument "compressed" Array.
bool ok() const
Check to see if the masked array is consistent.
MaskedArray(masked_array_type &&source)
The source is left empty after moving.
T * getRWArrayStorage(bool &deleteIt) const
bool conform(const masked_array_type &other) const
MaskedArray(const array_type &inarray, const MaskedLogicalArray &inmask)
size_t size() const
MaskedArray(const array_type &inarray, const MaskedLogicalArray &inmask, bool isreadonly)
Create a MaskedArray from an Array and a MaskedLogicalArray.
masked_array_type operator()(const IPosition &start, const IPosition &end, const IPosition &inc)
Along the ith axis, every inc[i]'th element is chosen.
bool conform(const array_type &other) const
Are the shapes identical?
masked_array_type & operator=(array_type &&inarray)
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
T * array
The actual storage.
Definition Block.h:689
T * storage()
If you really, really, need a "raw" pointer to the beginning of the storage area this will give it to...
Definition Block.h:559
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
Array< LogicalArrayElem > LogicalArray
Definition ArrayFwd.h:17
MaskedArray< LogicalArrayElem > MaskedLogicalArray
Definition ArrayFwd.h:20
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:360
bool LogicalArrayElem
Definition ArrayFwd.h:16
iterator end()
Definition Block.h:601
General global functions for MaskedArrays, and MaskedArrays and Arrays.
bool conform2(const MaskedArray< TLL > &left, const MaskedArray< TRR > &right)
bool conform2(const Array< TLL > &left, const MaskedArray< TRR > &right)
bool conform2(const MaskedArray< TLL > &left, const Array< TRR > &right)
Test conformance for masked arrays and arrays of different types.