Loading...
Searching...
No Matches
casacore::Slice Class Reference
casa package (libcasa_casa) » Arrays_module

More...

`#include <Slice.h>`

## Public Member Functions

| Slice ()
| The entire range of indices on the axis is desired.
| Slice (size_t Start, size_t Length=1, size_t Inc=1)
| Create a Slice with a given start, length, and increment.
| Slice (size_t Start, size_t End, size_t Inc, bool endIsLength)
| Create a Slice with a given start, end or length, and increment.
bool | all () const
| Was the entire range of indices on this axis selected?
size_t | start () const
| Report the selected starting position.
size_t | length () const
| Report the defined length.
size_t | inc () const
| Report the defined increment.
size_t | end () const
| Attempt to report the last element of the slice.

## Static Public Member Functions

static IPosition | checkSlices (Vector< Vector< Slice > > &slices, Slicer &first, const IPosition &shape)
| Check a vector of slices.

## Private Attributes

size_t | startp
ssize_t | incp
size_t | lengthp

## Detailed Description

define a (start,length,increment) along an axis

### Review Status

Reviewed By:
  UNKNOWN
Date Reviewed:
  before2004/08/25

### Synopsis

A "slice" (aka Section) is a a regular sub-Array (and ultimately sub-Image) that is defined by defining a (start,length,increment) for each axis in the array. That is, the output array's axis is of size "length", and the elements are sampled by stepping along the input array in strides of "increment".
Warning:
The "length" is the length of the OUTPUT array, the output length is NOT divided by the increment/stride;
If increment is not defined, then it defaults to one. (Increment, if defined, must be >= 1). If length is not defined, then it defaults to a length of one also (i.e. just the pixel "start"). If start is also undefined, then all pixels along this axis are chosen. This class deprecates the "_" (IndexRange) class, which had a failed syntax and used (start,end,increment) which is generally less convenient. Some simple examples follow:

Vector<int> vi(100); // Vector of length 100;
//..\.
// Copy odd values onto even values
vi(Slice(0,50,2)) = vi(Slice(1,50,2));
Matrix<float> mf(100,50), smallMf;
smallMf.reference(mf(Slice(0,10,10), Slice(0,5,10)));
// smallMF is now a "dezoomed" (every 10th pix)
// refference to mf. Of course we could also
// make it a copy by using assignment; e.g:
smallMf.resize(0,0); // Make it so it will "size to fit"
smallMf = mf(Slice(0,10,10), Slice(0,5,10));
casacore::Array::reference
virtual void reference(const Array< T > &other)
After invocation, this array and other reference the same storage.
casacore::Matrix
Definition Matrix.h:87
casacore::Matrix::resize
void resize(size_t nx, size_t ny, bool copyValues=false)
casacore::Slice::Slice
Slice()
The entire range of indices on the axis is desired.
Definition Slice.h:135
casacore::Vector
Definition Vector.h:82

As shown above, normally Slices will normally be used as temporaries, but they may also be put into variables if desired (the default copy constructors and assignment operators suffice for this class).

While it will be unusual for a user to want this, a zero-length slice is allowable.

Another way to produce a slice from any of the Array classes is to use SomeArray(blc,trc,inc) where blc,trc,inc are IPositions. This is described in the documentation for Array<T>.

Definition at line 88 of file Slice.h.

## Constructor & Destructor Documentation

## Slice() [1/3]

casacore::Slice::Slice | ( |  | ) |

inline

The entire range of indices on the axis is desired.

Nothing

Definition at line 135 of file Slice.h.

References incp, lengthp, and startp.

## Slice() [2/3]

casacore::Slice::Slice | ( | size_t | Start,
|  | size_t | Length = 1,
|  | size_t | Inc = 1 )

inline

Create a Slice with a given start, length, and increment.

The latter two default to one if not given.

Definition at line 141 of file Slice.h.

References incp, lengthp, and startp.

## Slice() [3/3]

casacore::Slice::Slice | ( | size_t | Start,
|  | size_t | End,
|  | size_t | Inc,
|  | bool | endIsLength )

inline

Create a Slice with a given start, end or length, and increment.

If endIsLength=false, end is interpreted as length.

Definition at line 150 of file Slice.h.

References incp, lengthp, and startp.

## Member Function Documentation

## all()

bool casacore::Slice::all | ( |  | ) | const

inline

Was the entire range of indices on this axis selected?

Definition at line 161 of file Slice.h.

References incp.

Referenced by inc().

## checkSlices()

IPosition casacore::Slice::checkSlices | ( | Vector< Vector< Slice > > & | slices,
|  | Slicer & | first,
|  | const IPosition & | shape )

static

Check a vector of slices.

If a vector of an axis is empty or missing, it is replaced by a Slice representing the entire axis. It checks if the Slices do not exceed the array shape. It returns the shape of the combined slices and fills the Slicer for the first array part defined by the slices.

References first, and casacore::shape().

## end()

size_t casacore::Slice::end | ( |  | ) | const

inline

Attempt to report the last element of the slice.

If all() is true, end() returns -1 (which is less than start(), which returns zero in that case).

return -1 if all()

Definition at line 185 of file Slice.h.

References incp, lengthp, and startp.

## inc()

size_t casacore::Slice::inc | ( |  | ) | const

inline

Report the defined increment.

If all() is true, start=len=inc=0 is set.

Definition at line 176 of file Slice.h.

References all(), and incp.

## length()

size_t casacore::Slice::length | ( |  | ) | const

inline

Report the defined length.

If all() is true, start=len=inc=0 is set.

Definition at line 171 of file Slice.h.

References lengthp.

## start()

size_t casacore::Slice::start | ( |  | ) | const

inline

Report the selected starting position.

If all() is true, start=len=inc=0 is set.

Definition at line 166 of file Slice.h.

References startp.

## Member Data Documentation

## incp

ssize_t casacore::Slice::incp

private

Definition at line 131 of file Slice.h.

Referenced by all(), end(), inc(), Slice(), Slice(), and Slice().

## lengthp

size_t casacore::Slice::lengthp

private

Definition at line 132 of file Slice.h.

Referenced by end(), length(), Slice(), Slice(), and Slice().

## startp

size_t casacore::Slice::startp

private

Definition at line 130 of file Slice.h.

Referenced by end(), Slice(), Slice(), Slice(), and start().

The documentation for this class was generated from the following file:

- casa/Arrays/Slice.h