MADNESS  version 0.9
Public Member Functions | Public Attributes | List of all members
madness::Slice Class Reference

A slice defines a sub-range or patch of a dimension. More...

#include <slice.h>

Public Member Functions

 Slice ()
 
 Slice (long s, long e, long stp=1)
 
Sliceoperator= (const Slice &s)
 

Public Attributes

long start
 
long end
 
long step
 

Detailed Description

A slice defines a sub-range or patch of a dimension.

Introduction

The slice Slice(start,end,step) defines the subvector

with indices as if generated from these loops

if (step > 0)
for (i=start; i<=end; i+=step) i;
else if (step < 0)
for (i=start; i>=end; i+=step) i;
else if (step == 0 && start == end)
defines a scalar
else
runtime error detected when slice is used

Note that start and end are inclusive, unlike the Python convention of specifying end+1 (note that we cannot do this easily in C/C++ unless we also define a special value to indicate the end of a dimension of unknown size).

Special meanings and conventions

Negative values for start or end (similar to Python) are relative to the end of the (possibly unknown) dimension. E.g.,

Special slices have been defined as constants

Examples

Constructor & Destructor Documentation

madness::Slice::Slice ( )
inline
madness::Slice::Slice ( long  s,
long  e,
long  stp = 1 
)
inline

Member Function Documentation

Slice& madness::Slice::operator= ( const Slice s)
inline

References end, start, and step.

Member Data Documentation

long madness::Slice::end

Referenced by madness::operator<<(), and operator=().

long madness::Slice::start

Referenced by madness::operator<<(), and operator=().

long madness::Slice::step

Referenced by madness::operator<<(), and operator=().


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