NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
nc::Slice Class Reference

A Class for slicing into NdArrays. More...

#include <Slice.hpp>

Public Member Functions

constexpr Slice ()=default
 
constexpr Slice (int32 inStart, int32 inStop) noexcept
 
constexpr Slice (int32 inStart, int32 inStop, int32 inStep) noexcept
 
constexpr Slice (int32 inStop) noexcept
 
void makePositiveAndValidate (uint32 inArraySize)
 
uint32 numElements (uint32 inArraySize)
 
bool operator!= (const Slice &inOtherSlice) const noexcept
 
bool operator== (const Slice &inOtherSlice) const noexcept
 
void print () const
 
std::string str () const
 
std::vector< uint32toIndices (uint32 inArrayDimSize)
 

Data Fields

int32 start { 0 }
 
int32 step { 1 }
 
int32 stop { 1 }
 

Friends

std::ostream & operator<< (std::ostream &inOStream, const Slice &inSlice)
 

Detailed Description

A Class for slicing into NdArrays.

Constructor & Destructor Documentation

◆ Slice() [1/4]

constexpr nc::Slice::Slice ( )
constexprdefault

Constructor

◆ Slice() [2/4]

constexpr nc::Slice::Slice ( int32  inStop)
inlineexplicitconstexprnoexcept

Constructor

Parameters
inStop(index not included)

◆ Slice() [3/4]

constexpr nc::Slice::Slice ( int32  inStart,
int32  inStop 
)
inlineconstexprnoexcept

Constructor

Parameters
inStart
inStop(index not included)

◆ Slice() [4/4]

constexpr nc::Slice::Slice ( int32  inStart,
int32  inStop,
int32  inStep 
)
inlineconstexprnoexcept

Constructor

Parameters
inStart
inStop(not included)
inStep

Member Function Documentation

◆ makePositiveAndValidate()

void nc::Slice::makePositiveAndValidate ( uint32  inArraySize)
inline

Make the slice all positive and does some error checking

Parameters
inArraySize

◆ numElements()

uint32 nc::Slice::numElements ( uint32  inArraySize)
inline

Returns the number of elements that the slice contains. be aware that this method will also make the slice all positive!

Parameters
inArraySize

◆ operator!=()

bool nc::Slice::operator!= ( const Slice inOtherSlice) const
inlinenoexcept

Not equality operator

Parameters
inOtherSlice
Returns
bool

◆ operator==()

bool nc::Slice::operator== ( const Slice inOtherSlice) const
inlinenoexcept

Equality operator

Parameters
inOtherSlice
Returns
bool

◆ print()

void nc::Slice::print ( ) const
inline

Prints the shape to the console

◆ str()

std::string nc::Slice::str ( ) const
inline

Prints the shape to the console

Returns
std::string

◆ toIndices()

std::vector< uint32 > nc::Slice::toIndices ( uint32  inArrayDimSize)
inline

Returns the indices that coorespond to the slice be aware that this method will also make the slice all positive!

Parameters
inArrayDimSizethe size of the dimension that is being sliced

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  inOStream,
const Slice inSlice 
)
friend

IO operator for the Slice class

Parameters
inOStream
inSlice
Returns
std::ostream

Field Documentation

◆ start

int32 nc::Slice::start { 0 }

◆ step

int32 nc::Slice::step { 1 }

◆ stop

int32 nc::Slice::stop { 1 }

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