MADNESS  0.10.1
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)
 
template<typename Archive >
void serialize (Archive &ar)
 

Public Attributes

long end
 
long start
 
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

long end
Definition: slice.h:107
long step
Definition: slice.h:108
long start
Definition: slice.h:106

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
void error(const char *msg)
Definition: world.cc:139
static const double a
Definition: nonlinschro.cc:118

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

◆ Slice() [1/2]

madness::Slice::Slice ( )
inline

◆ Slice() [2/2]

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

Member Function Documentation

◆ operator=()

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

References end, start, and step.

◆ serialize()

template<typename Archive >
void madness::Slice::serialize ( Archive &  ar)
inline

References end, start, and step.

Member Data Documentation

◆ end

long madness::Slice::end

Referenced by operator=(), and serialize().

◆ start

long madness::Slice::start

Referenced by operator=(), and serialize().

◆ step

long madness::Slice::step

Referenced by operator=(), and serialize().


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