CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
npstat::ArrayND< Numeric, StackLen, StackDim > Class Template Reference

#include <ArrayND.h>

Public Types

typedef ProperDblFromCmpl< Numeric >::type proper_double
 
typedef Numeric value_type
 

Public Member Functions

template<typename Num3 , typename Num2 , unsigned Len2, unsigned Dim2>
ArrayNDaddmul (const ArrayND< Num2, Len2, Dim2 > &r, const Num3 &c)
 
template<typename Num3 , typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND< Numeric, Len, Dim > & addmul (const ArrayND< Num2, Len2, Dim2 > &r, const Num3 &c)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void addToProjection (ArrayND< Num2, Len2, Dim2 > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void addToProjection (ArrayND< Num2, Len2, Dim2 > *projection, AbsVisitor< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
template<class Functor >
ArrayNDapply (Functor f)
 
template<class Functor >
ArrayND< Numeric, Len, Dim > & apply (Functor f)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void applySlice (ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, unsigned nFixedIndices, Functor binaryFunct)
 
 ArrayND ()
 
 ArrayND (const ArrayND &)
 
template<typename Num1 , unsigned Len1, unsigned Dim1, typename Num2 , unsigned Len2, unsigned Dim2>
 ArrayND (const ArrayND< Num1, Len1, Dim1 > &a1, const ArrayND< Num2, Len2, Dim2 > &a2)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
 ArrayND (const ArrayND< Num2, Len2, Dim2 > &)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
 ArrayND (const ArrayND< Num2, Len2, Dim2 > &, Functor f)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
 ArrayND (const ArrayND< Num2, Len2, Dim2 > &from, const ArrayRange &fromRange)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
 ArrayND (const ArrayND< Num2, Len2, Dim2 > &from, const ArrayRange &fromRange, Functor f)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
 ArrayND (const ArrayND< Num2, Len2, Dim2 > &slicedArray, const unsigned *indices, unsigned nIndices)
 
 ArrayND (const ArrayShape &shape)
 
 ArrayND (const unsigned *shape, unsigned dim)
 
 ArrayND (unsigned n0)
 
 ArrayND (unsigned n0, unsigned n1)
 
 ArrayND (unsigned n0, unsigned n1, unsigned n2)
 
 ArrayND (unsigned n0, unsigned n1, unsigned n2, unsigned n3)
 
 ArrayND (unsigned n0, unsigned n1, unsigned n2, unsigned n3, unsigned n4)
 
 ArrayND (unsigned n0, unsigned n1, unsigned n2, unsigned n3, unsigned n4, unsigned n5)
 
 ArrayND (unsigned n0, unsigned n1, unsigned n2, unsigned n3, unsigned n4, unsigned n5, unsigned n6)
 
 ArrayND (unsigned n0, unsigned n1, unsigned n2, unsigned n3, unsigned n4, unsigned n5, unsigned n6, unsigned n7)
 
 ArrayND (unsigned n0, unsigned n1, unsigned n2, unsigned n3, unsigned n4, unsigned n5, unsigned n6, unsigned n7, unsigned n8)
 
 ArrayND (unsigned n0, unsigned n1, unsigned n2, unsigned n3, unsigned n4, unsigned n5, unsigned n6, unsigned n7, unsigned n8, unsigned n9)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
ArrayNDassign (const ArrayND< Num2, Len2, Dim2 > &, Functor f)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
ArrayND< Numeric, Len, Dim > & assign (const ArrayND< Num2, Len2, Dim2 > &r, Functor f)
 
Numeric & at ()
 
const Numeric & at () const
 
Numeric & at (unsigned i0)
 
const Numeric & at (unsigned i0) const
 
Numeric & at (unsigned i0, unsigned i1)
 
const Numeric & at (unsigned i0, unsigned i1) const
 
Numeric & at (unsigned i0, unsigned i1, unsigned i2)
 
const Numeric & at (unsigned i0, unsigned i1, unsigned i2) const
 
Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3)
 
const Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3) const
 
Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4)
 
const Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4) const
 
Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5)
 
const Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5) const
 
Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6)
 
const Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6) const
 
Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7)
 
const Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7) const
 
Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8)
 
const Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8) const
 
Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8, unsigned i9)
 
const Numeric & at (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8, unsigned i9) const
 
template<typename Accumulator >
ArrayND< Numeric, Len, Dim > cdfArray (const double inscale) const
 
template<typename Num2 >
ArrayND cdfArray (double scale=1.0) const
 
template<typename Accumulator >
Accumulator cdfValue (const unsigned *index, const unsigned indexLen) const
 
template<typename Num2 >
Num2 cdfValue (const unsigned *index, unsigned indexLen) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void circularFlatScan (ArrayND< Num2, Len2, Dim2 > &other, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, unsigned arrLen, Functor binaryFunct)
 
Numeric & cl ()
 
const Numeric & cl () const
 
Numeric & cl (double x0)
 
const Numeric & cl (double x0) const
 
Numeric & cl (double x0, double x1)
 
const Numeric & cl (double x0, double x1) const
 
Numeric & cl (double x0, double x1, double x2)
 
const Numeric & cl (double x0, double x1, double x2) const
 
Numeric & cl (double x0, double x1, double x2, double x3)
 
const Numeric & cl (double x0, double x1, double x2, double x3) const
 
Numeric & cl (double x0, double x1, double x2, double x3, double x4)
 
const Numeric & cl (double x0, double x1, double x2, double x3, double x4) const
 
Numeric & cl (double x0, double x1, double x2, double x3, double x4, double x5)
 
const Numeric & cl (double x0, double x1, double x2, double x3, double x4, double x5) const
 
Numeric & cl (double x0, double x1, double x2, double x3, double x4, double x5, double x6)
 
const Numeric & cl (double x0, double x1, double x2, double x3, double x4, double x5, double x6) const
 
Numeric & cl (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7)
 
const Numeric & cl (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7) const
 
Numeric & cl (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8)
 
const Numeric & cl (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8) const
 
Numeric & cl (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9)
 
const Numeric & cl (double x0, double x1, double x2, double x3, double x4, double x5, double x6, double x7, double x8, double x9) const
 
gs::ClassId classId () const
 
ArrayNDclear ()
 
Numeric & closest (const double *x, unsigned xDim)
 
const Numeric & closest (const double *x, unsigned xDim) const
 
ArrayNDconstFill (Numeric c)
 
ArrayND contract (unsigned pos1, unsigned pos2) const
 
void convertLinearIndex (unsigned long l, unsigned *index, unsigned indexLen) const
 
template<typename Num2 >
void convertToLastDimCdf (ArrayND *sumSlice, bool useTrapezoids)
 
const Numeric * data () const
 
template<typename Accumulator >
ArrayND< Numeric, Len, Dim > derivative (const double inscale) const
 
template<typename Num2 >
ArrayND derivative (double scale=1.0) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND dot (const ArrayND< Num2, Len2, Dim2 > &r) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND< Numeric, Len, Dim > dot (const ArrayND< Num2, Len2, Dim2 > &r) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void dualCircularScan (ArrayND< Num2, Len2, Dim2 > &other, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, unsigned arrLen, Functor binaryFunct)
 
template<typename Num2 >
void exportMemSlice (Num2 *buffer, unsigned long bufLen, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
void exportSlice (ArrayND< Num2, Len2, Dim2 > *slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
void exportSubrange (const unsigned *fromCorner, unsigned lenCorner, ArrayND< Num2, Len2, Dim2 > *dest) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void flatCircularScan (ArrayND< Num2, Len2, Dim2 > &other, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, unsigned arrLen, Functor binaryFunct)
 
ArrayRange fullRange () const
 
template<class Functor >
ArrayNDfunctorFill (Functor f)
 
template<class Functor >
ArrayND< Numeric, Len, Dim > & functorFill (Functor f)
 
template<typename Num2 >
void importMemSlice (const Num2 *buffer, unsigned long bufLen, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
void importSlice (const ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
void importSubrange (const unsigned *fromCorner, unsigned lenCorner, const ArrayND< Num2, Len2, Dim2 > &from)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayNDinPlaceMul (const ArrayND< Num2, Len2, Dim2 > &r)
 
Numeric interpolate1 (const double *x, unsigned xDim) const
 
Numeric interpolate3 (const double *x, unsigned xDim) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
bool isClose (const ArrayND< Num2, Len2, Dim2 > &r, double eps) const
 
bool isCompatible (const ArrayShape &shape) const
 
bool isDensity () const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
bool isShapeCompatible (const ArrayND< Num2, Len2, Dim2 > &r) const
 
bool isShapeKnown () const
 
bool isZero () const
 
template<typename Num2 , class Functor >
void jointMemSliceScan (Num2 *buffer, unsigned long bufLen, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, Functor binaryFunct)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void jointScan (ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void jointSliceScan (ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, Functor binaryFunct)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void jointSubrangeScan (ArrayND< Num2, Len2, Dim2 > &other, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, unsigned arrLen, Functor binaryFunct)
 
unsigned long length () const
 
ArrayNDlinearFill (const double *coeff, unsigned coeffLen, double c)
 
unsigned long linearIndex (const unsigned *idx, unsigned idxLen) const
 
Numeric & linearValue (unsigned long index)
 
const Numeric & linearValue (unsigned long index) const
 
Numeric & linearValueAt (unsigned long index)
 
const Numeric & linearValueAt (unsigned long index) const
 
unsigned makeCopulaSteps (double tolerance, unsigned maxIterations)
 
ArrayNDmakeNonNegative ()
 
ArrayNDmakeUnit ()
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND< Numeric, StackLen, StackDim > marginalize (const ArrayND< Num2, Len2, Dim2 > &prior, const unsigned *indexMap, const unsigned mapLen) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND marginalize (const ArrayND< Num2, Len2, Dim2 > &prior, const unsigned *indexMap, unsigned mapLen) const
 
Numeric max () const
 
Numeric max (unsigned *index, unsigned indexLen) const
 
template<unsigned Len2, unsigned Dim2>
double maxAbsDifference (const ArrayND< Numeric, Len2, Dim2 > &) const
 
unsigned maximumSpan () const
 
Numeric min () const
 
Numeric min (unsigned *index, unsigned indexLen) const
 
unsigned minimumSpan () const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
void multiMirror (ArrayND< Num2, Len2, Dim2 > *out) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayNDmultiplyBySlice (const ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, unsigned nFixedIndices)
 
template<unsigned Len2, unsigned Dim2>
bool operator!= (const ArrayND< Numeric, Len2, Dim2 > &) const
 
Numeric & operator() ()
 
const Numeric & operator() () const
 
Numeric & operator() (unsigned i0)
 
const Numeric & operator() (unsigned i0) const
 
Numeric & operator() (unsigned i0, unsigned i1)
 
const Numeric & operator() (unsigned i0, unsigned i1) const
 
Numeric & operator() (unsigned i0, unsigned i1, unsigned i2)
 
const Numeric & operator() (unsigned i0, unsigned i1, unsigned i2) const
 
Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3)
 
const Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3) const
 
Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4)
 
const Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4) const
 
Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5)
 
const Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5) const
 
Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6)
 
const Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6) const
 
Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7)
 
const Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7) const
 
Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8)
 
const Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8) const
 
Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8, unsigned i9)
 
const Numeric & operator() (unsigned i0, unsigned i1, unsigned i2, unsigned i3, unsigned i4, unsigned i5, unsigned i6, unsigned i7, unsigned i8, unsigned i9) const
 
template<typename Num2 >
ArrayND operator* (const Num2 &r) const
 
template<typename Num2 >
ArrayND< Numeric, Len, Dim > operator* (const Num2 &r) const
 
template<typename Num2 >
ArrayNDoperator*= (const Num2 &r)
 
template<typename Num2 >
ArrayND< Numeric, Len, Dim > & operator*= (const Num2 &r)
 
ArrayND operator+ () const
 
template<unsigned Len2, unsigned Dim2>
ArrayND operator+ (const ArrayND< Numeric, Len2, Dim2 > &r) const
 
template<unsigned Len2, unsigned Dim2>
ArrayND< Numeric, Len, Dim > operator+ (const ArrayND< Numeric, Len2, Dim2 > &r) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayNDoperator+= (const ArrayND< Num2, Len2, Dim2 > &r)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND< Numeric, Len, Dim > & operator+= (const ArrayND< Num2, Len2, Dim2 > &r)
 
ArrayND operator- () const
 
template<unsigned Len2, unsigned Dim2>
ArrayND operator- (const ArrayND< Numeric, Len2, Dim2 > &r) const
 
template<unsigned Len2, unsigned Dim2>
ArrayND< Numeric, Len, Dim > operator- (const ArrayND< Numeric, Len2, Dim2 > &r) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayNDoperator-= (const ArrayND< Num2, Len2, Dim2 > &r)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND< Numeric, Len, Dim > & operator-= (const ArrayND< Num2, Len2, Dim2 > &r)
 
template<typename Num2 >
ArrayND operator/ (const Num2 &r) const
 
template<typename Num2 >
ArrayND< Numeric, Len, Dim > operator/ (const Num2 &r) const
 
template<typename Num2 >
ArrayNDoperator/= (const Num2 &r)
 
template<typename Num2 >
ArrayND< Numeric, Len, Dim > & operator/= (const Num2 &r)
 
ArrayNDoperator= (const ArrayND &)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayNDoperator= (const ArrayND< Num2, Len2, Dim2 > &)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND< Numeric, Len, Dim > & operator= (const ArrayND< Num2, Len2, Dim2 > &r)
 
template<unsigned Len2, unsigned Dim2>
bool operator== (const ArrayND< Numeric, Len2, Dim2 > &) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND outer (const ArrayND< Num2, Len2, Dim2 > &r) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND< Numeric, Len, Dim > outer (const ArrayND< Num2, Len2, Dim2 > &r) const
 
template<typename Num2 , typename Integer >
void processSubrange (AbsArrayProjector< Numeric, Num2 > &f, const BoxND< Integer > &subrange) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void project (ArrayND< Num2, Len2, Dim2 > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void project (ArrayND< Num2, Len2, Dim2 > *projection, AbsVisitor< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
unsigned rank () const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
void rotate (const unsigned *shifts, unsigned lenShifts, ArrayND< Num2, Len2, Dim2 > *rotated) const
 
template<class Functor >
ArrayNDscanInPlace (Functor f)
 
template<class Functor >
ArrayND< Numeric, Len, Dim > & scanInPlace (Functor f)
 
template<typename Num2 >
ArrayND< Numeric, Len, Dim > & setData (const Num2 *data, const unsigned long dataLength)
 
template<typename Num2 >
ArrayNDsetData (const Num2 *data, unsigned long dataLength)
 
ArrayShape shape () const
 
const unsigned * shapeData () const
 
ArrayShape sliceShape (const unsigned *fixedIndices, unsigned nFixedIndices) const
 
unsigned span (unsigned dim) const
 
const unsigned long * strides () const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void subtractFromProjection (ArrayND< Num2, Len2, Dim2 > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void subtractFromProjection (ArrayND< Num2, Len2, Dim2 > *projection, AbsVisitor< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
template<typename Num2 >
Num2 sum () const
 
template<typename Num2 >
Num2 sumsq () const
 
ArrayND transpose () const
 
ArrayND transpose (unsigned pos1, unsigned pos2) const
 
ArrayNDuninitialize ()
 
Numeric & value (const unsigned *index, unsigned indexLen)
 
const Numeric & value (const unsigned *index, unsigned indexLen) const
 
Numeric & valueAt (const unsigned *index, unsigned indexLen)
 
const Numeric & valueAt (const unsigned *index, unsigned indexLen) const
 
bool write (std::ostream &of) const
 
 ~ArrayND ()
 

Static Public Member Functions

static const char * classname ()
 
static void restore (const gs::ClassId &id, std::istream &in, ArrayND *array)
 
static unsigned version ()
 

Private Member Functions

void buildFromShapePtr (const unsigned *, unsigned)
 
void buildStrides ()
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void circularFlatLoop (unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void commonSubrangeLoop (unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
 
void contractLoop (unsigned thisLevel, unsigned resLevel, unsigned pos1, unsigned pos2, unsigned long idxThis, unsigned long idxRes, ArrayND &result) const
 
template<typename Accumulator >
void convertToLastDimCdfLoop (ArrayND *sumSlice, unsigned level, unsigned long idx0, unsigned long idxSlice, bool useTrapezoids)
 
unsigned coordToIndex (double coord, unsigned idim) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void copyRangeLoopFunct (unsigned level, unsigned long idx0, unsigned long idx1, const ArrayND< Num2, Len2, Dim2 > &r, const ArrayRange &range, Functor f)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
void dotProductLoop (unsigned level, unsigned long idx0, unsigned long idx1, unsigned long idx2, const ArrayND< Num2, Len2, Dim2 > &r, ArrayND &result) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void dualCircularLoop (unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void flatCircularLoop (unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
 
template<class Functor >
void functorFillLoop (unsigned level, unsigned long idx, Functor f, unsigned *farg)
 
Numeric interpolateLoop (unsigned level, const double *x, const Numeric *base) const
 
template<typename Num2 , class Op >
void jointSliceLoop (const unsigned level, const unsigned long idx0, const unsigned level1, const unsigned long idx1, Num2 *sliceData, const unsigned long *sliceStrides, const unsigned *fixedIndices, const unsigned *fixedIndexValues, const unsigned nFixedIndices, Op fcn)
 
template<typename Num2 , class Functor >
void jointSliceLoop (unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, Num2 *sliceData, const unsigned long *sliceStrides, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, Functor binaryFunctor)
 
void linearFillLoop (unsigned level, double s0, unsigned long idx, double shift, const double *coeffs)
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
Numeric marginalizeInnerLoop (unsigned long idx, unsigned levelPr, unsigned long idxPr, const ArrayND< Num2, Len2, Dim2 > &prior, const unsigned *indexMap) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
void marginalizeLoop (unsigned level, unsigned long idx, unsigned levelRes, unsigned long idxRes, const ArrayND< Num2, Len2, Dim2 > &prior, const unsigned *indexMap, ArrayND &res) const
 
template<typename Num1 , unsigned Len1, unsigned Dim1, typename Num2 , unsigned Len2, unsigned Dim2>
void outerProductLoop (unsigned level, unsigned long idx0, unsigned long idx1, unsigned long idx2, const ArrayND< Num1, Len1, Dim1 > &a1, const ArrayND< Num2, Len2, Dim2 > &a2)
 
template<typename Num2 , typename Integer >
void processSubrangeLoop (unsigned level, unsigned long idx0, unsigned *currentIndex, AbsArrayProjector< Numeric, Num2 > &f, const BoxND< Integer > &subrange) const
 
template<typename Num2 >
void projectInnerLoop (unsigned level, unsigned long idx0, unsigned *currentIndex, AbsArrayProjector< Numeric, Num2 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
template<typename Num2 >
void projectInnerLoop2 (unsigned level, unsigned long idx0, AbsVisitor< Numeric, Num2 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 , class Op >
void projectLoop (unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, unsigned *currentIndex, ArrayND< Num2, Len2, Dim2 > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices, Op fcn) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 , class Op >
void projectLoop2 (unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, ArrayND< Num2, Len2, Dim2 > *projection, AbsVisitor< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices, Op fcn) const
 
template<typename Num2 , class Functor >
void scaleBySliceInnerLoop (unsigned level, unsigned long idx0, Num2 &scale, const unsigned *projectedIndices, unsigned nProjectedIndices, Functor binaryFunct)
 
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void scaleBySliceLoop (unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, unsigned nFixedIndices, Functor binaryFunct)
 
template<typename Accumulator >
Accumulator sumBelowLoop (unsigned level, unsigned long idx0, const unsigned *limit) const
 
void transposeLoop (unsigned level, unsigned pos1, unsigned pos2, unsigned long idxThis, unsigned long idxRes, ArrayND &result) const
 
unsigned long verifyBufferSliceCompatibility (unsigned long bufLen, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, unsigned long *sliceStrides) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
void verifyProjectionCompatibility (const ArrayND< Num2, Len2, Dim2 > &projection, const unsigned *projectedIndices, unsigned nProjectedIndices) const
 
template<typename Num2 , unsigned Len2, unsigned Dim2>
unsigned long verifySliceCompatibility (const ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices) const
 

Private Attributes

Numeric * data_
 
unsigned dim_
 
unsigned long len_
 
Numeric localData_ [StackLen]
 
unsigned localShape_ [StackDim]
 
unsigned long localStrides_ [StackDim]
 
unsigned * shape_
 
bool shapeIsKnown_
 
unsigned long * strides_
 

Friends

template<typename Num2 , unsigned Len2, unsigned Dim2>
class ArrayND
 

Detailed Description

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
class npstat::ArrayND< Numeric, StackLen, StackDim >

A class for multidimensional array manipulation. A number of methods of this class will work only if dimensionality is limited by CHAR_BIT*sizeof(unsigned long)-1 (which is 31 and 63 on 32- and 64-bit architectures, respectively).

Depending on how much space is provided with the "StackLen" template parameter, the array data will be placed either on the stack or on the heap. By default, array data leaves on the heap unless the array has rank 0.

Depending on how much space is provided with the "StackDim" template parameter, the array strides will be placed either on the stack or on the heap. By default, strides will be placed on the stack in case the array dimensionality is ten or less.

The "Numeric" type must have a default constructor (of course, pointers to arbitrary types can be used as well).

Both StackLen and StackDim parameters must be positive.

Definition at line 48 of file ArrayND.h.

Member Typedef Documentation

◆ proper_double

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
typedef ProperDblFromCmpl<Numeric>::type npstat::ArrayND< Numeric, StackLen, StackDim >::proper_double

Definition at line 54 of file ArrayND.h.

◆ value_type

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
typedef Numeric npstat::ArrayND< Numeric, StackLen, StackDim >::value_type

Definition at line 53 of file ArrayND.h.

Constructor & Destructor Documentation

◆ ArrayND() [1/20]

template<typename Numeric , unsigned StackLen, unsigned StackDim>
npstat::ArrayND< Numeric, StackLen, StackDim >::ArrayND ( )
inline

Default constructor creates an uninitialized array. Only three things can be done safely with such an array:

1) Assigning it from another array (initialized or not).

2) Passing it as an argument to the class static method "restore".

3) Calling the "uninitialize" method.

Any other operation results in an undefined behavior (often, an exception is thrown). Note that initialized array can not be assigned from uninitialized one.

Definition at line 2488 of file ArrayND.h.

2489  : data_(nullptr), strides_(nullptr), shape_(nullptr), len_(0UL), dim_(0U), shapeIsKnown_(false) {
2490  localData_[0] = Numeric();
2491  data_ = localData_;
2492  }

◆ ArrayND() [2/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( const ArrayShape shape)
explicit

Constructor which creates arrays with the given shape. The array data remains undefined. Simple inilitalization of the data can be performed using methods clear() or constFill(SomeValue). More complicated initialization can be done by "linearFill", "functorFill", or by setting every array element to a desired value.

Definition at line 2664 of file ArrayND.h.

2665  : data_(nullptr), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2666  const unsigned sz = sh.size();
2667  buildFromShapePtr(sz ? &sh[0] : nullptr, sz);
2668  }

◆ ArrayND() [3/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( const unsigned *  shape,
unsigned  dim 
)

Definition at line 2671 of file ArrayND.h.

2672  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2673  buildFromShapePtr(sizes, dim);
2674  }

◆ ArrayND() [4/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( const ArrayND< Numeric, StackLen, StackDim > &  r)

The copy constructor

Definition at line 2495 of file ArrayND.h.

2496  : data_(nullptr), strides_(nullptr), shape_(nullptr), len_(r.len_), dim_(r.dim_), shapeIsKnown_(r.shapeIsKnown_) {
2497  if (dim_) {
2498  // Copy the shape
2499  shape_ = makeBuffer(dim_, localShape_, Dim);
2500  copyBuffer(shape_, r.shape_, dim_);
2501 
2502  // Copy the strides
2504  copyBuffer(strides_, r.strides_, dim_);
2505 
2506  // Copy the data
2507  data_ = makeBuffer(len_, localData_, Len);
2508  copyBuffer(data_, r.data_, len_);
2509  } else {
2510  assert(len_ == 1UL);
2511  localData_[0] = r.localData_[0];
2512  data_ = localData_;
2513  }
2514  }

◆ ArrayND() [5/20]

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( const ArrayND< Num2, Len2, Dim2 > &  r)

Converting constructor. It looks more general than the copy constructor, but the actual copy constructor has to be created anyway – otherwise the compiler will generate an incorrect default copy constructor. Note that existence of this constructor essentially disables data type safety for copying arrays – but the code significantly gains in convenience.

Definition at line 2518 of file ArrayND.h.

2519  : data_(0), strides_(nullptr), shape_(nullptr), len_(r.len_), dim_(r.dim_), shapeIsKnown_(r.shapeIsKnown_) {
2520  if (dim_) {
2521  // Copy the shape
2522  shape_ = makeBuffer(dim_, localShape_, Dim);
2523  copyBuffer(shape_, r.shape_, dim_);
2524 
2525  // Copy the strides
2527  copyBuffer(strides_, r.strides_, dim_);
2528 
2529  // Copy the data
2530  data_ = makeBuffer(len_, localData_, Len);
2531  copyBuffer(data_, r.data_, len_);
2532  } else {
2533  assert(len_ == 1UL);
2534  localData_[0] = static_cast<Numeric>(r.localData_[0]);
2535  data_ = localData_;
2536  }
2537  }

◆ ArrayND() [6/20]

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( const ArrayND< Num2, Len2, Dim2 > &  r,
Functor  f 
)

Converting constructor where the array values are filled by a functor using values of another array as arguments

Definition at line 2541 of file ArrayND.h.

2542  : data_(0), strides_(nullptr), shape_(nullptr), len_(r.len_), dim_(r.dim_), shapeIsKnown_(r.shapeIsKnown_) {
2543  if (dim_) {
2544  // Copy the shape
2545  shape_ = makeBuffer(dim_, localShape_, Dim);
2546  copyBuffer(shape_, r.shape_, dim_);
2547 
2548  // Copy the strides
2550  copyBuffer(strides_, r.strides_, dim_);
2551 
2552  // Copy the data
2553  data_ = makeBuffer(len_, localData_, Len);
2554  for (unsigned long i = 0; i < len_; ++i)
2555  data_[i] = static_cast<Numeric>(f(r.data_[i]));
2556  } else {
2557  assert(len_ == 1UL);
2558  localData_[0] = static_cast<Numeric>(f(r.localData_[0]));
2559  data_ = localData_;
2560  }
2561  }

◆ ArrayND() [7/20]

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( const ArrayND< Num2, Len2, Dim2 > &  from,
const ArrayRange fromRange 
)

Constructor from a subrange of another array

Definition at line 2591 of file ArrayND.h.

2592  : data_(0), strides_(nullptr), shape_(nullptr), len_(r.len_), dim_(r.dim_), shapeIsKnown_(r.shapeIsKnown_) {
2593  if (!range.isCompatible(r.shape_, r.dim_))
2594  throw npstat::NpstatInvalidArgument("In npstat::ArrayND subrange constructor: invalid subrange");
2595  if (dim_) {
2596  len_ = range.rangeSize();
2597  if (!len_)
2598  throw npstat::NpstatInvalidArgument("In npstat::ArrayND subrange constructor: empty subrange");
2599 
2600  // Figure out the shape
2601  shape_ = makeBuffer(dim_, localShape_, Dim);
2602  range.rangeLength(shape_, dim_);
2603 
2604  // Figure out the strides
2605  buildStrides();
2606 
2607  // Allocate the data array
2608  data_ = makeBuffer(len_, localData_, Len);
2609 
2610  // Copy the data
2611  if (dim_ > CHAR_BIT * sizeof(unsigned long))
2613  "In npstat::ArrayND subrange constructor: "
2614  "input array rank is too large");
2615  unsigned lolim[CHAR_BIT * sizeof(unsigned long)];
2616  range.lowerLimits(lolim, dim_);
2617  unsigned toBuf[CHAR_BIT * sizeof(unsigned long)];
2618  clearBuffer(toBuf, dim_);
2619  (const_cast<ArrayND<Num2, Len2, Dim2>&>(r))
2620  .commonSubrangeLoop(0U, 0UL, 0UL, lolim, shape_, toBuf, *this, scast_assign_right<Num2, Numeric>());
2621  } else {
2622  assert(len_ == 1UL);
2623  localData_[0] = static_cast<Numeric>(r.localData_[0]);
2624  data_ = localData_;
2625  }
2626  }

◆ ArrayND() [8/20]

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( const ArrayND< Num2, Len2, Dim2 > &  from,
const ArrayRange fromRange,
Functor  f 
)

Similar constructor with a transforming functor

Definition at line 2630 of file ArrayND.h.

2631  : data_(0), strides_(nullptr), shape_(nullptr), len_(r.len_), dim_(r.dim_), shapeIsKnown_(r.shapeIsKnown_) {
2632  if (!range.isCompatible(r.shape_, r.dim_))
2634  "In npstat::ArrayND transforming subrange constructor: "
2635  "incompatible subrange");
2636  if (dim_) {
2637  len_ = range.rangeSize();
2638  if (!len_)
2640  "In npstat::ArrayND transforming subrange constructor: "
2641  "empty subrange");
2642 
2643  // Figure out the shape
2644  shape_ = makeBuffer(dim_, localShape_, Dim);
2645  for (unsigned i = 0; i < dim_; ++i)
2646  shape_[i] = range[i].length();
2647 
2648  // Figure out the strides
2649  buildStrides();
2650 
2651  // Allocate the data array
2652  data_ = makeBuffer(len_, localData_, Len);
2653 
2654  // Transform the data
2655  copyRangeLoopFunct(0U, 0UL, 0UL, r, range, f);
2656  } else {
2657  assert(len_ == 1UL);
2658  localData_[0] = static_cast<Numeric>(f(r.localData_[0]));
2659  data_ = localData_;
2660  }
2661  }

◆ ArrayND() [9/20]

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
npstat::ArrayND< Numeric, StackLen, StackDim >::ArrayND ( const ArrayND< Num2, Len2, Dim2 > &  slicedArray,
const unsigned *  indices,
unsigned  nIndices 
)

Constructor from a slice of another array. The data of the constructed array remains undefined. The argument "indices" lists either the array indices whose numbers will be fixed when slicing is performed or the indices which will be iterated over during projections (for example, array values may be summed over these indices). These indices will be excluded from the constructed array. The created array can be subsequently used with methods "exportSlice", "importSlice", "project", etc. of the parent array "slicedArray".

Definition at line 1671 of file ArrayND.h.

1674  : data_(0),
1675  strides_(nullptr),
1676  shape_(nullptr),
1677  len_(1UL),
1678  dim_(slicedArray.dim_ - nFixedIndices),
1679  shapeIsKnown_(true) {
1680  if (nFixedIndices) {
1681  assert(fixedIndices);
1682  if (nFixedIndices > slicedArray.dim_)
1683  throw npstat::NpstatInvalidArgument("In npstat::ArrayND slicing constructor: too many fixed indices");
1684  if (!slicedArray.shapeIsKnown_)
1686  "In npstat::ArrayND slicing constructor: "
1687  "uninitialized argument array");
1688 
1689  // Check that the fixed indices are within range
1690  for (unsigned j = 0; j < nFixedIndices; ++j)
1691  if (fixedIndices[j] >= slicedArray.dim_)
1693  "In npstat::ArrayND slicing "
1694  "constructor: fixed index out of range");
1695 
1696  // Build the shape for the slice
1697  shape_ = makeBuffer(dim_, localShape_, StackDim);
1698  unsigned idim = 0;
1699  for (unsigned i = 0; i < slicedArray.dim_; ++i) {
1700  bool fixed = false;
1701  for (unsigned j = 0; j < nFixedIndices; ++j)
1702  if (fixedIndices[j] == i) {
1703  fixed = true;
1704  break;
1705  }
1706  if (!fixed) {
1707  assert(idim < dim_);
1708  shape_[idim++] = slicedArray.shape_[i];
1709  }
1710  }
1711  assert(idim == dim_);
1712 
1713  if (dim_) {
1714  // Copy the array shape and figure out the array length
1715  for (unsigned i = 0; i < dim_; ++i)
1716  len_ *= shape_[i];
1717 
1718  // Figure out the array strides
1719  buildStrides();
1720 
1721  // Allocate the data array
1722  data_ = makeBuffer(len_, localData_, StackLen);
1723  } else {
1724  localData_[0] = Numeric();
1725  data_ = localData_;
1726  }
1727  } else {
1728  new (this) ArrayND(slicedArray);
1729  }
1730  }

◆ ArrayND() [10/20]

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num1 , unsigned Len1, unsigned Dim1, typename Num2 , unsigned Len2, unsigned Dim2>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( const ArrayND< Num1, Len1, Dim1 > &  a1,
const ArrayND< Num2, Len2, Dim2 > &  a2 
)

Outer product constructor

Definition at line 2869 of file ArrayND.h.

2870  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), dim_(a1.dim_ + a2.dim_), shapeIsKnown_(true) {
2871  if (!(a1.shapeIsKnown_ && a2.shapeIsKnown_))
2873  "In npstat::ArrayND outer product constructor: "
2874  "uninitialized argument array");
2875  if (dim_) {
2876  shape_ = makeBuffer(dim_, localShape_, Dim);
2877  copyBuffer(shape_, a1.shape_, a1.dim_);
2878  copyBuffer(shape_ + a1.dim_, a2.shape_, a2.dim_);
2879 
2880  for (unsigned i = 0; i < dim_; ++i) {
2881  assert(shape_[i]);
2882  len_ *= shape_[i];
2883  }
2884 
2885  // Figure out the array strides
2886  buildStrides();
2887 
2888  // Allocate the data array
2889  data_ = makeBuffer(len_, localData_, Len);
2890 
2891  // Fill the data array
2892  if (a1.dim_ == 0) {
2893  for (unsigned long i = 0; i < len_; ++i)
2894  data_[i] = a1.localData_[0] * a2.data_[i];
2895  } else if (a2.dim_ == 0) {
2896  for (unsigned long i = 0; i < len_; ++i)
2897  data_[i] = a1.data_[i] * a2.localData_[0];
2898  } else
2899  outerProductLoop(0U, 0UL, 0UL, 0UL, a1, a2);
2900  } else {
2901  localData_[0] = a1.localData_[0] * a2.localData_[0];
2902  data_ = localData_;
2903  }
2904  }

◆ ArrayND() [11/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( unsigned  n0)
explicit

Constructor in which the spans are explicitly provided for each dimension. The array data remains undefined.

Definition at line 2677 of file ArrayND.h.

2678  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2679  const unsigned dim = 1U;
2680  unsigned sizes[dim];
2681  sizes[0] = n0;
2682  buildFromShapePtr(sizes, dim);
2683  }

◆ ArrayND() [12/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( unsigned  n0,
unsigned  n1 
)

Definition at line 2686 of file ArrayND.h.

2687  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2688  const unsigned dim = 2U;
2689  unsigned sizes[dim];
2690  sizes[0] = n0;
2691  sizes[1] = n1;
2692  buildFromShapePtr(sizes, dim);
2693  }

◆ ArrayND() [13/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( unsigned  n0,
unsigned  n1,
unsigned  n2 
)

Definition at line 2696 of file ArrayND.h.

2697  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2698  const unsigned dim = 3U;
2699  unsigned sizes[dim];
2700  sizes[0] = n0;
2701  sizes[1] = n1;
2702  sizes[2] = n2;
2703  buildFromShapePtr(sizes, dim);
2704  }

◆ ArrayND() [14/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( unsigned  n0,
unsigned  n1,
unsigned  n2,
unsigned  n3 
)

Definition at line 2707 of file ArrayND.h.

2708  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2709  const unsigned dim = 4U;
2710  unsigned sizes[dim];
2711  sizes[0] = n0;
2712  sizes[1] = n1;
2713  sizes[2] = n2;
2714  sizes[3] = n3;
2715  buildFromShapePtr(sizes, dim);
2716  }

◆ ArrayND() [15/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( unsigned  n0,
unsigned  n1,
unsigned  n2,
unsigned  n3,
unsigned  n4 
)

Definition at line 2719 of file ArrayND.h.

2721  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2722  const unsigned dim = 5U;
2723  unsigned sizes[dim];
2724  sizes[0] = n0;
2725  sizes[1] = n1;
2726  sizes[2] = n2;
2727  sizes[3] = n3;
2728  sizes[4] = n4;
2729  buildFromShapePtr(sizes, dim);
2730  }

◆ ArrayND() [16/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( unsigned  n0,
unsigned  n1,
unsigned  n2,
unsigned  n3,
unsigned  n4,
unsigned  n5 
)

Definition at line 2733 of file ArrayND.h.

2735  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2736  const unsigned dim = 6U;
2737  unsigned sizes[dim];
2738  sizes[0] = n0;
2739  sizes[1] = n1;
2740  sizes[2] = n2;
2741  sizes[3] = n3;
2742  sizes[4] = n4;
2743  sizes[5] = n5;
2744  buildFromShapePtr(sizes, dim);
2745  }

◆ ArrayND() [17/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( unsigned  n0,
unsigned  n1,
unsigned  n2,
unsigned  n3,
unsigned  n4,
unsigned  n5,
unsigned  n6 
)

Definition at line 2748 of file ArrayND.h.

2755  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2756  const unsigned dim = 7U;
2757  unsigned sizes[dim];
2758  sizes[0] = n0;
2759  sizes[1] = n1;
2760  sizes[2] = n2;
2761  sizes[3] = n3;
2762  sizes[4] = n4;
2763  sizes[5] = n5;
2764  sizes[6] = n6;
2765  buildFromShapePtr(sizes, dim);
2766  }

◆ ArrayND() [18/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( unsigned  n0,
unsigned  n1,
unsigned  n2,
unsigned  n3,
unsigned  n4,
unsigned  n5,
unsigned  n6,
unsigned  n7 
)

Definition at line 2769 of file ArrayND.h.

2777  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2778  const unsigned dim = 8U;
2779  unsigned sizes[dim];
2780  sizes[0] = n0;
2781  sizes[1] = n1;
2782  sizes[2] = n2;
2783  sizes[3] = n3;
2784  sizes[4] = n4;
2785  sizes[5] = n5;
2786  sizes[6] = n6;
2787  sizes[7] = n7;
2788  buildFromShapePtr(sizes, dim);
2789  }

◆ ArrayND() [19/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( unsigned  n0,
unsigned  n1,
unsigned  n2,
unsigned  n3,
unsigned  n4,
unsigned  n5,
unsigned  n6,
unsigned  n7,
unsigned  n8 
)

Definition at line 2792 of file ArrayND.h.

2801  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2802  const unsigned dim = 9U;
2803  unsigned sizes[dim];
2804  sizes[0] = n0;
2805  sizes[1] = n1;
2806  sizes[2] = n2;
2807  sizes[3] = n3;
2808  sizes[4] = n4;
2809  sizes[5] = n5;
2810  sizes[6] = n6;
2811  sizes[7] = n7;
2812  sizes[8] = n8;
2813  buildFromShapePtr(sizes, dim);
2814  }

◆ ArrayND() [20/20]

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::ArrayND ( unsigned  n0,
unsigned  n1,
unsigned  n2,
unsigned  n3,
unsigned  n4,
unsigned  n5,
unsigned  n6,
unsigned  n7,
unsigned  n8,
unsigned  n9 
)

Definition at line 2817 of file ArrayND.h.

2827  : data_(0), strides_(nullptr), shape_(nullptr), len_(1UL), shapeIsKnown_(true) {
2828  const unsigned dim = 10U;
2829  unsigned sizes[dim];
2830  sizes[0] = n0;
2831  sizes[1] = n1;
2832  sizes[2] = n2;
2833  sizes[3] = n3;
2834  sizes[4] = n4;
2835  sizes[5] = n5;
2836  sizes[6] = n6;
2837  sizes[7] = n7;
2838  sizes[8] = n8;
2839  sizes[9] = n9;
2840  buildFromShapePtr(sizes, dim);
2841  }

◆ ~ArrayND()

template<typename Numeric , unsigned Len, unsigned Dim>
npstat::ArrayND< Numeric, Len, Dim >::~ArrayND ( )
inline

Destructor

Definition at line 2907 of file ArrayND.h.

Member Function Documentation

◆ addmul() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num3 , typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::addmul ( const ArrayND< Num2, Len2, Dim2 > &  r,
const Num3 &  c 
)

This method is equivalent to (but faster than) += r*c

◆ addmul() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num3 , typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::addmul ( const ArrayND< Num2, Len2, Dim2 > &  r,
const Num3 &  c 
)

Definition at line 4188 of file ArrayND.h.

4188  {
4189  if (!isShapeCompatible(r))
4191  "In npstat::ArrayND::addmul: "
4192  "incompatible argument array shape");
4193  for (unsigned long i = 0; i < len_; ++i)
4194  data_[i] += r.data_[i] * c;
4195  return *this;
4196  }

◆ addToProjection() [1/2]

template<typename Numeric, unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void npstat::ArrayND< Numeric, StackLen, StackDim >::addToProjection ( ArrayND< Num2, Len2, Dim2 > *  projection,
AbsArrayProjector< Numeric, Num3 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices 
) const

Similar method to "project", but projections are added to (or subtracted from) the existing projection data instead of replacing them

Definition at line 2129 of file ArrayND.h.

2132  {
2133  assert(projection);
2134  verifyProjectionCompatibility(*projection, projectedIndices, nProjectedIndices);
2135  unsigned ibuf[StackDim];
2136  unsigned* buf = makeBuffer(dim_, ibuf, StackDim);
2137  for (unsigned i = 0; i < dim_; ++i)
2138  buf[i] = 0U;
2139  projectLoop(0U,
2140  0UL,
2141  0U,
2142  0UL,
2143  buf,
2144  projection,
2145  projector,
2146  projectedIndices,
2147  nProjectedIndices,
2148  scast_pluseq_left<Num2, Num3>());
2149  destroyBuffer(buf, ibuf);
2150  }

◆ addToProjection() [2/2]

template<typename Numeric, unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void npstat::ArrayND< Numeric, StackLen, StackDim >::addToProjection ( ArrayND< Num2, Len2, Dim2 > *  projection,
AbsVisitor< Numeric, Num3 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices 
) const

Definition at line 2257 of file ArrayND.h.

2260  {
2261  assert(projection);
2262  verifyProjectionCompatibility(*projection, projectedIndices, nProjectedIndices);
2263  projectLoop2(
2264  0U, 0UL, 0U, 0UL, projection, projector, projectedIndices, nProjectedIndices, scast_pluseq_left<Num2, Num3>());
2265  }

◆ apply() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<class Functor >
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::apply ( Functor  f)

◆ apply() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<class Functor >
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::apply ( Functor  f)

◆ applySlice()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, StackLen, StackDim >::applySlice ( ArrayND< Num2, Len2, Dim2 > &  slice,
const unsigned *  fixedIndices,
unsigned  nFixedIndices,
Functor  binaryFunct 
)

This method applies the values in the slice to all other coresponding values in the array. This can be used, for example, to multiply/divide by some factor which varies across the slice. The slice values will be used as the right functor argument.

Definition at line 2354 of file ArrayND.h.

2357  {
2358  if (nFixedIndices) {
2359  verifyProjectionCompatibility(slice, fixedIndices, nFixedIndices);
2360  if (slice.dim_ == 0U)
2361  for (unsigned long i = 0; i < len_; ++i)
2362  binaryFunct(data_[i], slice.localData_[0]);
2363  else
2364  scaleBySliceLoop(0U, 0UL, 0U, 0UL, slice, fixedIndices, nFixedIndices, binaryFunct);
2365  } else
2366  jointScan(slice, binaryFunct);
2367  }

Referenced by npstat::ArrayND< Num1, Len1, Dim1 >::multiplyBySlice().

◆ assign() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::assign ( const ArrayND< Num2, Len2, Dim2 > &  ,
Functor  f 
)

Converting assignment method with a transforming functor

◆ assign() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::assign ( const ArrayND< Num2, Len2, Dim2 > &  r,
Functor  f 
)

Definition at line 2968 of file ArrayND.h.

2968  {
2969  if (shapeIsKnown_) {
2970  if (!r.shapeIsKnown_)
2971  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::assign: uninitialized argument array");
2972  if (!isShapeCompatible(r))
2973  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::assign: incompatible argument array shape");
2974  if (dim_)
2975  for (unsigned long i = 0; i < len_; ++i)
2976  data_[i] = static_cast<Numeric>(f(r.data_[i]));
2977  else
2978  localData_[0] = static_cast<Numeric>(f(r.localData_[0]));
2979  } else {
2980  // This object is uninitialized. If the object on the
2981  // right is itself initialized, build new array in place.
2982  if (r.shapeIsKnown_)
2983  new (this) ArrayND(r, f);
2984  }
2985  return *this;
2986  }

◆ at() [1/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( )

Fortran-style subscripting with bounds checking (of course, with indices starting at 0).

Definition at line 3268 of file ArrayND.h.

3268  {
3269  if (!shapeIsKnown_)
3270  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"at\"");
3271  if (dim_)
3272  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 0 array)");
3273  return localData_[0];
3274  }

◆ at() [2/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( ) const

Definition at line 3259 of file ArrayND.h.

3259  {
3260  if (!shapeIsKnown_)
3261  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"at\"");
3262  if (dim_)
3263  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 0 array)");
3264  return localData_[0];
3265  }

◆ at() [3/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0)

Definition at line 3286 of file ArrayND.h.

3286  {
3287  if (1U != dim_)
3288  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 1 array)");
3289  if (i0 >= shape_[0])
3290  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 1)");
3291  return data_[i0];
3292  }

◆ at() [4/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0) const

Definition at line 3277 of file ArrayND.h.

3277  {
3278  if (1U != dim_)
3279  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 1 array)");
3280  if (i0 >= shape_[0])
3281  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 1)");
3282  return data_[i0];
3283  }

◆ at() [5/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1 
)

Definition at line 3320 of file ArrayND.h.

3320  {
3321  if (2U != dim_)
3322  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 2 array)");
3323  if (i0 >= shape_[0])
3324  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 2)");
3325  if (i1 >= shape_[1])
3326  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 2)");
3327  return data_[i0 * strides_[0] + i1];
3328  }

◆ at() [6/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1 
) const

Definition at line 3309 of file ArrayND.h.

3309  {
3310  if (2U != dim_)
3311  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 2 array)");
3312  if (i0 >= shape_[0])
3313  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 2)");
3314  if (i1 >= shape_[1])
3315  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 2)");
3316  return data_[i0 * strides_[0] + i1];
3317  }

◆ at() [7/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2 
)

Definition at line 3734 of file ArrayND.h.

3734  {
3735  if (3U != dim_)
3736  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 3 array)");
3737  if (i0 >= shape_[0])
3738  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 3)");
3739  if (i1 >= shape_[1])
3740  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 3)");
3741  if (i2 >= shape_[2])
3742  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 3)");
3743  return data_[i0 * strides_[0] + i1 * strides_[1] + i2];
3744  }

◆ at() [8/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2 
) const

Definition at line 3531 of file ArrayND.h.

3531  {
3532  if (3U != dim_)
3533  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 3 array)");
3534  if (i0 >= shape_[0])
3535  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 3)");
3536  if (i1 >= shape_[1])
3537  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 3)");
3538  if (i2 >= shape_[2])
3539  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 3)");
3540  return data_[i0 * strides_[0] + i1 * strides_[1] + i2];
3541  }

◆ at() [9/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3 
)

Definition at line 3747 of file ArrayND.h.

3747  {
3748  if (4U != dim_)
3749  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 4 array)");
3750  if (i0 >= shape_[0])
3751  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 4)");
3752  if (i1 >= shape_[1])
3753  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 4)");
3754  if (i2 >= shape_[2])
3755  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 4)");
3756  if (i3 >= shape_[3])
3757  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 4)");
3758  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3];
3759  }

◆ at() [10/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3 
) const

Definition at line 3544 of file ArrayND.h.

3547  {
3548  if (4U != dim_)
3549  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 4 array)");
3550  if (i0 >= shape_[0])
3551  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 4)");
3552  if (i1 >= shape_[1])
3553  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 4)");
3554  if (i2 >= shape_[2])
3555  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 4)");
3556  if (i3 >= shape_[3])
3557  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 4)");
3558  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3];
3559  }

◆ at() [11/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4 
)

Definition at line 3762 of file ArrayND.h.

3763  {
3764  if (5U != dim_)
3765  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 5 array)");
3766  if (i0 >= shape_[0])
3767  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 5)");
3768  if (i1 >= shape_[1])
3769  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 5)");
3770  if (i2 >= shape_[2])
3771  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 5)");
3772  if (i3 >= shape_[3])
3773  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 5)");
3774  if (i4 >= shape_[4])
3775  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 5)");
3776  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4];
3777  }

◆ at() [12/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4 
) const

Definition at line 3562 of file ArrayND.h.

3563  {
3564  if (5U != dim_)
3565  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 5 array)");
3566  if (i0 >= shape_[0])
3567  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 5)");
3568  if (i1 >= shape_[1])
3569  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 5)");
3570  if (i2 >= shape_[2])
3571  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 5)");
3572  if (i3 >= shape_[3])
3573  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 5)");
3574  if (i4 >= shape_[4])
3575  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 5)");
3576  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4];
3577  }

◆ at() [13/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5 
)

Definition at line 3780 of file ArrayND.h.

3785  {
3786  if (6U != dim_)
3787  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 6 array)");
3788  if (i0 >= shape_[0])
3789  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 6)");
3790  if (i1 >= shape_[1])
3791  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 6)");
3792  if (i2 >= shape_[2])
3793  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 6)");
3794  if (i3 >= shape_[3])
3795  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 6)");
3796  if (i4 >= shape_[4])
3797  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 6)");
3798  if (i5 >= shape_[5])
3799  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 5 out of range (rank 6)");
3800  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] + i5];
3801  }

◆ at() [14/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5 
) const

Definition at line 3580 of file ArrayND.h.

3585  {
3586  if (6U != dim_)
3587  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 6 array)");
3588  if (i0 >= shape_[0])
3589  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 6)");
3590  if (i1 >= shape_[1])
3591  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 6)");
3592  if (i2 >= shape_[2])
3593  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 6)");
3594  if (i3 >= shape_[3])
3595  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 6)");
3596  if (i4 >= shape_[4])
3597  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 6)");
3598  if (i5 >= shape_[5])
3599  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 5 out of range (rank 6)");
3600  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] + i5];
3601  }

◆ at() [15/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6 
)

Definition at line 3804 of file ArrayND.h.

3810  {
3811  if (7U != dim_)
3812  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 7 array)");
3813  if (i0 >= shape_[0])
3814  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 7)");
3815  if (i1 >= shape_[1])
3816  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 7)");
3817  if (i2 >= shape_[2])
3818  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 7)");
3819  if (i3 >= shape_[3])
3820  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 7)");
3821  if (i4 >= shape_[4])
3822  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 7)");
3823  if (i5 >= shape_[5])
3824  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 5 out of range (rank 7)");
3825  if (i6 >= shape_[6])
3826  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 6 out of range (rank 7)");
3827  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3828  i5 * strides_[5] + i6];
3829  }

◆ at() [16/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6 
) const

Definition at line 3604 of file ArrayND.h.

3610  {
3611  if (7U != dim_)
3612  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 7 array)");
3613  if (i0 >= shape_[0])
3614  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 7)");
3615  if (i1 >= shape_[1])
3616  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 7)");
3617  if (i2 >= shape_[2])
3618  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 7)");
3619  if (i3 >= shape_[3])
3620  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 7)");
3621  if (i4 >= shape_[4])
3622  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 7)");
3623  if (i5 >= shape_[5])
3624  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 5 out of range (rank 7)");
3625  if (i6 >= shape_[6])
3626  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 6 out of range (rank 7)");
3627  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3628  i5 * strides_[5] + i6];
3629  }

◆ at() [17/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7 
)

Definition at line 3832 of file ArrayND.h.

3839  {
3840  if (8U != dim_)
3841  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 8 array)");
3842  if (i0 >= shape_[0])
3843  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 8)");
3844  if (i1 >= shape_[1])
3845  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 8)");
3846  if (i2 >= shape_[2])
3847  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 8)");
3848  if (i3 >= shape_[3])
3849  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 8)");
3850  if (i4 >= shape_[4])
3851  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 8)");
3852  if (i5 >= shape_[5])
3853  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 5 out of range (rank 8)");
3854  if (i6 >= shape_[6])
3855  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 6 out of range (rank 8)");
3856  if (i7 >= shape_[7])
3857  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 7 out of range (rank 8)");
3858  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3859  i5 * strides_[5] + i6 * strides_[6] + i7];
3860  }

◆ at() [18/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7 
) const

Definition at line 3632 of file ArrayND.h.

3639  {
3640  if (8U != dim_)
3641  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 8 array)");
3642  if (i0 >= shape_[0])
3643  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 8)");
3644  if (i1 >= shape_[1])
3645  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 8)");
3646  if (i2 >= shape_[2])
3647  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 8)");
3648  if (i3 >= shape_[3])
3649  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 8)");
3650  if (i4 >= shape_[4])
3651  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 8)");
3652  if (i5 >= shape_[5])
3653  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 5 out of range (rank 8)");
3654  if (i6 >= shape_[6])
3655  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 6 out of range (rank 8)");
3656  if (i7 >= shape_[7])
3657  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 7 out of range (rank 8)");
3658  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3659  i5 * strides_[5] + i6 * strides_[6] + i7];
3660  }

◆ at() [19/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7,
unsigned  i8 
)

Definition at line 3863 of file ArrayND.h.

3871  {
3872  if (9U != dim_)
3873  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 9 array)");
3874  if (i0 >= shape_[0])
3875  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 9)");
3876  if (i1 >= shape_[1])
3877  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 9)");
3878  if (i2 >= shape_[2])
3879  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 9)");
3880  if (i3 >= shape_[3])
3881  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 9)");
3882  if (i4 >= shape_[4])
3883  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 9)");
3884  if (i5 >= shape_[5])
3885  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 5 out of range (rank 9)");
3886  if (i6 >= shape_[6])
3887  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 6 out of range (rank 9)");
3888  if (i7 >= shape_[7])
3889  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 7 out of range (rank 9)");
3890  if (i8 >= shape_[8])
3891  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 8 out of range (rank 9)");
3892  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3893  i5 * strides_[5] + i6 * strides_[6] + i7 * strides_[7] + i8];
3894  }

◆ at() [20/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7,
unsigned  i8 
) const

Definition at line 3663 of file ArrayND.h.

3671  {
3672  if (9U != dim_)
3673  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 9 array)");
3674  if (i0 >= shape_[0])
3675  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 9)");
3676  if (i1 >= shape_[1])
3677  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 9)");
3678  if (i2 >= shape_[2])
3679  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 9)");
3680  if (i3 >= shape_[3])
3681  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 9)");
3682  if (i4 >= shape_[4])
3683  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 9)");
3684  if (i5 >= shape_[5])
3685  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 5 out of range (rank 9)");
3686  if (i6 >= shape_[6])
3687  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 6 out of range (rank 9)");
3688  if (i7 >= shape_[7])
3689  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 7 out of range (rank 9)");
3690  if (i8 >= shape_[8])
3691  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 8 out of range (rank 9)");
3692  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3693  i5 * strides_[5] + i6 * strides_[6] + i7 * strides_[7] + i8];
3694  }

◆ at() [21/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7,
unsigned  i8,
unsigned  i9 
)

Definition at line 3897 of file ArrayND.h.

3906  {
3907  if (10U != dim_)
3908  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 10 array)");
3909  if (i0 >= shape_[0])
3910  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 10)");
3911  if (i1 >= shape_[1])
3912  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 10)");
3913  if (i2 >= shape_[2])
3914  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 10)");
3915  if (i3 >= shape_[3])
3916  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 10)");
3917  if (i4 >= shape_[4])
3918  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 10)");
3919  if (i5 >= shape_[5])
3920  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 5 out of range (rank 10)");
3921  if (i6 >= shape_[6])
3922  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 6 out of range (rank 10)");
3923  if (i7 >= shape_[7])
3924  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 7 out of range (rank 10)");
3925  if (i8 >= shape_[8])
3926  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 8 out of range (rank 10)");
3927  if (i9 >= shape_[9])
3928  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 9 out of range (rank 10)");
3929  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3930  i5 * strides_[5] + i6 * strides_[6] + i7 * strides_[7] + i8 * strides_[8] + i9];
3931  }

◆ at() [22/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::at ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7,
unsigned  i8,
unsigned  i9 
) const

Definition at line 3697 of file ArrayND.h.

3706  {
3707  if (10U != dim_)
3708  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::at: wrong # of args (not rank 10 array)");
3709  if (i0 >= shape_[0])
3710  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 0 out of range (rank 10)");
3711  if (i1 >= shape_[1])
3712  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 1 out of range (rank 10)");
3713  if (i2 >= shape_[2])
3714  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 2 out of range (rank 10)");
3715  if (i3 >= shape_[3])
3716  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 3 out of range (rank 10)");
3717  if (i4 >= shape_[4])
3718  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 4 out of range (rank 10)");
3719  if (i5 >= shape_[5])
3720  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 5 out of range (rank 10)");
3721  if (i6 >= shape_[6])
3722  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 6 out of range (rank 10)");
3723  if (i7 >= shape_[7])
3724  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 7 out of range (rank 10)");
3725  if (i8 >= shape_[8])
3726  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 8 out of range (rank 10)");
3727  if (i9 >= shape_[9])
3728  throw npstat::NpstatOutOfRange("In npstat::ArrayND::at: index 9 out of range (rank 10)");
3729  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3730  i5 * strides_[5] + i6 * strides_[6] + i7 * strides_[7] + i8 * strides_[8] + i9];
3731  }

◆ buildFromShapePtr()

template<typename Numeric , unsigned Len, unsigned Dim>
void npstat::ArrayND< Numeric, Len, Dim >::buildFromShapePtr ( const unsigned *  sizes,
unsigned  dim 
)
private

Definition at line 1641 of file ArrayND.h.

1641  {
1642  dim_ = dim;
1643  if (dim_) {
1644  assert(sizes);
1645  for (unsigned i = 0; i < dim_; ++i)
1646  if (sizes[i] == 0)
1648  "In npstat::ArrayND::buildFromShapePtr: "
1649  "detected span of zero");
1650 
1651  // Copy the array shape and figure out the array length
1652  shape_ = makeBuffer(dim_, localShape_, Dim);
1653  for (unsigned i = 0; i < dim_; ++i) {
1654  shape_[i] = sizes[i];
1655  len_ *= shape_[i];
1656  }
1657 
1658  // Figure out the array strides
1659  buildStrides();
1660 
1661  // Allocate the data array
1662  data_ = makeBuffer(len_, localData_, Len);
1663  } else {
1664  localData_[0] = Numeric();
1665  data_ = localData_;
1666  }
1667  }

◆ buildStrides()

template<typename Numeric , unsigned Len, unsigned Dim>
void npstat::ArrayND< Numeric, Len, Dim >::buildStrides ( )
private

Definition at line 2478 of file ArrayND.h.

2478  {
2479  assert(dim_);
2480  if (strides_ == nullptr)
2482  strides_[dim_ - 1] = 1UL;
2483  for (unsigned j = dim_ - 1; j > 0; --j)
2484  strides_[j - 1] = strides_[j] * shape_[j];
2485  }

◆ cdfArray() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Accumulator >
ArrayND<Numeric, Len, Dim> npstat::ArrayND< Numeric, StackLen, StackDim >::cdfArray ( const double  inscale) const

Definition at line 4852 of file ArrayND.h.

4852  {
4853  if (!shapeIsKnown_)
4854  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"cdfArray\"");
4855  if (!dim_)
4857  "npstat::ArrayND::cdfArray method "
4858  "can not be used with array of 0 rank");
4859 
4860  const proper_double scale = inscale;
4861  const unsigned maxdim = CHAR_BIT * sizeof(unsigned long);
4862  if (dim_ >= maxdim)
4863  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cdfArray: array rank is too large");
4864  const unsigned long maxcycle = 1UL << dim_;
4865 
4866  ArrayShape sh;
4867  sh.reserve(dim_);
4868  for (unsigned i = 0; i < dim_; ++i)
4869  sh.push_back(shape_[i] + 1U);
4870 
4871  ArrayND<Accumulator> result(sh);
4872 
4873  unsigned* psh = &sh[0];
4874  const unsigned long len = result.length();
4875  for (unsigned long ipre = 0; ipre < len; ++ipre) {
4876  result.convertLinearIndex(ipre, psh, dim_);
4877  Accumulator deriv = Accumulator();
4878  bool has0 = false;
4879  for (unsigned i = 0; i < dim_; ++i)
4880  if (psh[i]-- == 0U) {
4881  has0 = true;
4882  break;
4883  }
4884  if (!has0) {
4885  for (unsigned long icycle = 0UL; icycle < maxcycle; ++icycle) {
4886  unsigned long icell = 0UL;
4887  unsigned n1 = 0U;
4888  for (unsigned i = 0; i < dim_; ++i) {
4889  if (icycle & (1UL << i)) {
4890  ++n1;
4891  icell += result.strides_[i] * (psh[i] + 1);
4892  } else
4893  icell += result.strides_[i] * psh[i];
4894  }
4895  if (n1 < dim_) {
4896  if ((dim_ - n1) % 2U)
4897  deriv += result.data_[icell];
4898  else
4899  deriv -= result.data_[icell];
4900  }
4901  }
4902  deriv += static_cast<Accumulator>(value(psh, dim_) * scale);
4903  }
4904  result.data_[ipre] = deriv;
4905  }
4906 
4907  // The "return" will convert Accumulator type into Numeric
4908  return result;
4909  }

◆ cdfArray() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND npstat::ArrayND< Numeric, StackLen, StackDim >::cdfArray ( double  scale = 1.0) const

The operation inverse to "derivative". Constructs multivariate cumulative density function.

◆ cdfValue() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Accumulator >
Accumulator npstat::ArrayND< Numeric, StackLen, StackDim >::cdfValue ( const unsigned *  index,
const unsigned  indexLen 
) const

Definition at line 4835 of file ArrayND.h.

4835  {
4836  if (!shapeIsKnown_)
4837  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"cdfValue\"");
4838  if (!dim_)
4840  "npstat::ArrayND::cdfValue method "
4841  "can not be used with array of 0 rank");
4842  if (indexLen != dim_)
4843  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cdfValue: incompatible index length");
4844  for (unsigned i = 0; i < indexLen; ++i)
4845  if (index[i] >= shape_[i])
4846  throw npstat::NpstatOutOfRange("In npstat::ArrayND::cdfValue: index out of range");
4847  return sumBelowLoop<Accumulator>(0, 0U, index);
4848  }

◆ cdfValue() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
Num2 npstat::ArrayND< Numeric, StackLen, StackDim >::cdfValue ( const unsigned *  index,
unsigned  indexLen 
) const

Calculate just one multivariate cumulative density function value. Point with given index will be included in the sum.

◆ circularFlatLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, Len, Dim >::circularFlatLoop ( unsigned  level,
unsigned long  idx0,
unsigned long  idx1,
const unsigned *  thisCorner,
const unsigned *  range,
const unsigned *  otherCorner,
ArrayND< Num2, Len2, Dim2 > &  other,
Functor  binaryFunct 
)
private

Definition at line 1467 of file ArrayND.h.

1474  {
1475  const unsigned imax = range[level];
1476  const unsigned leftShift = thisCorner[level];
1477  const unsigned leftPeriod = shape_[level];
1478 
1479  if (level == dim_ - 1) {
1480  Numeric* left = data_ + idx0;
1481  Num2* right = r.data_ + (idx1 + otherCorner[level]);
1482  Num2* const rMax = r.data_ + (idx1 + r.shape_[level]);
1483 
1484  for (unsigned i = 0; i < imax && right < rMax; ++i)
1485  binaryFunct(left[(i + leftShift) % leftPeriod], *right++);
1486  } else {
1487  const unsigned long leftStride = strides_[level];
1488  const unsigned long rightStride = r.strides_[level];
1489  const unsigned long rightMax = idx1 + r.shape_[level] * rightStride;
1490  idx1 += otherCorner[level] * rightStride;
1491 
1492  for (unsigned i = 0; i < imax && idx1 < rightMax; ++i, idx1 += rightStride)
1493  circularFlatLoop(level + 1,
1494  idx0 + ((i + leftShift) % leftPeriod) * leftStride,
1495  idx1,
1496  thisCorner,
1497  range,
1498  otherCorner,
1499  r,
1500  binaryFunct);
1501  }
1502  }

◆ circularFlatScan()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, Len, Dim >::circularFlatScan ( ArrayND< Num2, Len2, Dim2 > &  other,
const unsigned *  thisCorner,
const unsigned *  range,
const unsigned *  otherCorner,
unsigned  arrLen,
Functor  binaryFunct 
)

Method similar to "jointSubrangeScan" in which the topology of this array is assumed to be hypertoroidal and the other array flat

Definition at line 1508 of file ArrayND.h.

◆ cl() [1/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( )
inline

Subscripting by continuous coordinate. Works similar to the "closest" method.

Definition at line 5245 of file ArrayND.h.

5245  {
5246  if (!shapeIsKnown_)
5247  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"cl\"");
5248  if (dim_)
5249  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 0 array)");
5250  return localData_[0];
5251  }

◆ cl() [2/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( ) const
inline

Definition at line 5115 of file ArrayND.h.

5115  {
5116  if (!shapeIsKnown_)
5117  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"cl\"");
5118  if (dim_)
5119  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 0 array)");
5120  return localData_[0];
5121  }

◆ cl() [3/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0)
inline

Definition at line 5254 of file ArrayND.h.

5254  {
5255  if (1U != dim_)
5256  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 1 array)");
5257  return data_[coordToIndex(i0, 0)];
5258  }

◆ cl() [4/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0) const
inline

Definition at line 5124 of file ArrayND.h.

5124  {
5125  if (1U != dim_)
5126  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 1 array)");
5127  return data_[coordToIndex(i0, 0)];
5128  }

◆ cl() [5/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1 
)
inline

Definition at line 5261 of file ArrayND.h.

5261  {
5262  if (2U != dim_)
5263  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 2 array)");
5264  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1)];
5265  }

◆ cl() [6/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1 
) const
inline

Definition at line 5131 of file ArrayND.h.

5131  {
5132  if (2U != dim_)
5133  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 2 array)");
5134  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1)];
5135  }

◆ cl() [7/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2 
)
inline

Definition at line 5268 of file ArrayND.h.

5268  {
5269  if (3U != dim_)
5270  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 3 array)");
5271  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] + coordToIndex(i2, 2)];
5272  }

◆ cl() [8/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2 
) const
inline

Definition at line 5138 of file ArrayND.h.

5138  {
5139  if (3U != dim_)
5140  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 3 array)");
5141  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] + coordToIndex(i2, 2)];
5142  }

◆ cl() [9/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3 
)
inline

Definition at line 5275 of file ArrayND.h.

5275  {
5276  if (4U != dim_)
5277  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 4 array)");
5278  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5279  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3)];
5280  }

◆ cl() [10/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3 
) const
inline

Definition at line 5145 of file ArrayND.h.

5148  {
5149  if (4U != dim_)
5150  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 4 array)");
5151  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5152  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3)];
5153  }

◆ cl() [11/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4 
)
inline

Definition at line 5283 of file ArrayND.h.

5284  {
5285  if (5U != dim_)
5286  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 5 array)");
5287  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5288  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] + coordToIndex(i4, 4)];
5289  }

◆ cl() [12/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4 
) const
inline

Definition at line 5156 of file ArrayND.h.

5157  {
5158  if (5U != dim_)
5159  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 5 array)");
5160  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5161  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] + coordToIndex(i4, 4)];
5162  }

◆ cl() [13/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4,
double  x5 
)
inline

Definition at line 5292 of file ArrayND.h.

5293  {
5294  if (6U != dim_)
5295  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 6 array)");
5296  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5297  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] +
5298  coordToIndex(i4, 4) * strides_[4] + coordToIndex(i5, 5)];
5299  }

◆ cl() [14/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4,
double  x5 
) const
inline

Definition at line 5165 of file ArrayND.h.

5166  {
5167  if (6U != dim_)
5168  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 6 array)");
5169  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5170  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] +
5171  coordToIndex(i4, 4) * strides_[4] + coordToIndex(i5, 5)];
5172  }

◆ cl() [15/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4,
double  x5,
double  x6 
)
inline

Definition at line 5302 of file ArrayND.h.

5308  {
5309  if (7U != dim_)
5310  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 7 array)");
5311  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5312  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] +
5313  coordToIndex(i4, 4) * strides_[4] + coordToIndex(i5, 5) * strides_[5] + coordToIndex(i6, 6)];
5314  }

◆ cl() [16/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4,
double  x5,
double  x6 
) const
inline

Definition at line 5175 of file ArrayND.h.

5181  {
5182  if (7U != dim_)
5183  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 7 array)");
5184  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5185  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] +
5186  coordToIndex(i4, 4) * strides_[4] + coordToIndex(i5, 5) * strides_[5] + coordToIndex(i6, 6)];
5187  }

◆ cl() [17/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4,
double  x5,
double  x6,
double  x7 
)
inline

Definition at line 5317 of file ArrayND.h.

5324  {
5325  if (8U != dim_)
5326  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 8 array)");
5327  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5328  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] +
5329  coordToIndex(i4, 4) * strides_[4] + coordToIndex(i5, 5) * strides_[5] +
5330  coordToIndex(i6, 6) * strides_[6] + coordToIndex(i7, 7)];
5331  }

◆ cl() [18/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4,
double  x5,
double  x6,
double  x7 
) const
inline

Definition at line 5190 of file ArrayND.h.

5197  {
5198  if (8U != dim_)
5199  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 8 array)");
5200  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5201  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] +
5202  coordToIndex(i4, 4) * strides_[4] + coordToIndex(i5, 5) * strides_[5] +
5203  coordToIndex(i6, 6) * strides_[6] + coordToIndex(i7, 7)];
5204  }

◆ cl() [19/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4,
double  x5,
double  x6,
double  x7,
double  x8 
)
inline

Definition at line 5334 of file ArrayND.h.

5342  {
5343  if (9U != dim_)
5344  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 9 array)");
5345  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5346  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] +
5347  coordToIndex(i4, 4) * strides_[4] + coordToIndex(i5, 5) * strides_[5] +
5348  coordToIndex(i6, 6) * strides_[6] + coordToIndex(i7, 7) * strides_[7] + coordToIndex(i8, 8)];
5349  }

◆ cl() [20/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4,
double  x5,
double  x6,
double  x7,
double  x8 
) const
inline

Definition at line 5207 of file ArrayND.h.

5215  {
5216  if (9U != dim_)
5217  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 9 array)");
5218  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5219  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] +
5220  coordToIndex(i4, 4) * strides_[4] + coordToIndex(i5, 5) * strides_[5] +
5221  coordToIndex(i6, 6) * strides_[6] + coordToIndex(i7, 7) * strides_[7] + coordToIndex(i8, 8)];
5222  }

◆ cl() [21/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4,
double  x5,
double  x6,
double  x7,
double  x8,
double  x9 
)
inline

Definition at line 5352 of file ArrayND.h.

5361  {
5362  if (10U != dim_)
5363  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 10 array)");
5364  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5365  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] +
5366  coordToIndex(i4, 4) * strides_[4] + coordToIndex(i5, 5) * strides_[5] +
5367  coordToIndex(i6, 6) * strides_[6] + coordToIndex(i7, 7) * strides_[7] +
5368  coordToIndex(i8, 8) * strides_[8] + coordToIndex(i9, 9)];
5369  }

◆ cl() [22/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::cl ( double  x0,
double  x1,
double  x2,
double  x3,
double  x4,
double  x5,
double  x6,
double  x7,
double  x8,
double  x9 
) const
inline

Definition at line 5225 of file ArrayND.h.

5234  {
5235  if (10U != dim_)
5236  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::cl: wrong # of args (not rank 10 array)");
5237  return data_[coordToIndex(i0, 0) * strides_[0] + coordToIndex(i1, 1) * strides_[1] +
5238  coordToIndex(i2, 2) * strides_[2] + coordToIndex(i3, 3) * strides_[3] +
5239  coordToIndex(i4, 4) * strides_[4] + coordToIndex(i5, 5) * strides_[5] +
5240  coordToIndex(i6, 6) * strides_[6] + coordToIndex(i7, 7) * strides_[7] +
5241  coordToIndex(i8, 8) * strides_[8] + coordToIndex(i9, 9)];
5242  }

◆ classId()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
gs::ClassId npstat::ArrayND< Numeric, StackLen, StackDim >::classId ( ) const
inline

Methods related to "geners" I/O

Definition at line 1039 of file ArrayND.h.

1039 { return gs::ClassId(*this); }

◆ classname()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
const char * npstat::ArrayND< Numeric, StackLen, StackDim >::classname ( )
static

Definition at line 5372 of file ArrayND.h.

5372  {
5373  static const std::string name(gs::template_class_name<Numeric>("npstat::ArrayND"));
5374  return name.c_str();
5375  }

◆ clear()

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > & npstat::ArrayND< Numeric, Len, Dim >::clear ( void  )
inline

Zero the array out (every datum becomes Numeric())

Definition at line 4351 of file ArrayND.h.

4351  {
4352  return constFill(Numeric());
4353  }

◆ closest() [1/2]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::closest ( const double *  x,
unsigned  xDim 
)
inline

Closest value accessor (works as if the array allows access with non-integer indices). For example, the second point in some dimension will be accessed in case the coordinate in that dimension is between 0.5 and 1.5. This function can be used, for example, for implementing simple N-D histogramming or for closest value interpolation and extrapolation.

Definition at line 3173 of file ArrayND.h.

3173  {
3174  if (!shapeIsKnown_)
3175  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"closest\"");
3176  if (dim != dim_)
3177  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::closest: incompatible data length");
3178  if (dim) {
3179  assert(x);
3180  unsigned long idx = 0UL;
3181  for (unsigned i = 0; i < dim_; ++i)
3182  idx += coordToIndex(x[i], i) * strides_[i];
3183  return data_[idx];
3184  } else
3185  return localData_[0];
3186  }

Referenced by npstat::Private::ArrayMapper< Num1, Len1, Dim1, Num2, Len2, Dim2 >::operator()().

◆ closest() [2/2]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::closest ( const double *  x,
unsigned  xDim 
) const
inline

Definition at line 3157 of file ArrayND.h.

3157  {
3158  if (!shapeIsKnown_)
3159  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"closest\"");
3160  if (dim != dim_)
3161  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::closest: incompatible data length");
3162  if (dim) {
3163  assert(x);
3164  unsigned long idx = 0UL;
3165  for (unsigned i = 0; i < dim_; ++i)
3166  idx += coordToIndex(x[i], i) * strides_[i];
3167  return data_[idx];
3168  } else
3169  return localData_[0];
3170  }

◆ commonSubrangeLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, Len, Dim >::commonSubrangeLoop ( unsigned  level,
unsigned long  idx0,
unsigned long  idx1,
const unsigned *  thisCorner,
const unsigned *  range,
const unsigned *  otherCorner,
ArrayND< Num2, Len2, Dim2 > &  other,
Functor  binaryFunct 
)
private

Definition at line 1359 of file ArrayND.h.

1366  {
1367  const unsigned imax = range[level];
1368 
1369  if (level == dim_ - 1) {
1370  Numeric* left = data_ + (idx0 + thisCorner[level]);
1371  Numeric* const lMax = data_ + (idx0 + shape_[level]);
1372  Num2* right = r.data_ + (idx1 + otherCorner[level]);
1373  Num2* const rMax = r.data_ + (idx1 + r.shape_[level]);
1374 
1375  for (unsigned i = 0; i < imax && left < lMax && right < rMax; ++i)
1376  binaryFunct(*left++, *right++);
1377  } else {
1378  const unsigned long leftStride = strides_[level];
1379  const unsigned long leftMax = idx0 + shape_[level] * leftStride;
1380  idx0 += thisCorner[level] * leftStride;
1381  const unsigned long rightStride = r.strides_[level];
1382  const unsigned long rightMax = idx1 + r.shape_[level] * rightStride;
1383  idx1 += otherCorner[level] * rightStride;
1384 
1385  for (unsigned i = 0; i < imax && idx0 < leftMax && idx1 < rightMax; ++i, idx0 += leftStride, idx1 += rightStride)
1386  commonSubrangeLoop(level + 1, idx0, idx1, thisCorner, range, otherCorner, r, binaryFunct);
1387  }
1388  }

◆ constFill()

template<typename Numeric, unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > & npstat::ArrayND< Numeric, Len, Dim >::constFill ( Numeric  c)

This method fills the array data with a constant value

Definition at line 4342 of file ArrayND.h.

4342  {
4343  if (!shapeIsKnown_)
4344  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"constFill\"");
4345  for (unsigned long i = 0; i < len_; ++i)
4346  data_[i] = c;
4347  return *this;
4348  }

Referenced by npstat::HistoND< Numeric, Axis >::setBinsToConst(), and npstat::HistoND< Numeric, Axis >::setOverflowsToConst().

◆ contract()

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > npstat::ArrayND< Numeric, Len, Dim >::contract ( unsigned  pos1,
unsigned  pos2 
) const

Contraction of a pair of indices. Note that the array length must be the same in both dimensions.

Definition at line 4590 of file ArrayND.h.

4590  {
4591  if (!shapeIsKnown_)
4592  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"contract\"");
4593  if (!(pos1 < dim_ && pos2 < dim_ && pos1 != pos2))
4595  "In npstat::ArrayND::contract: "
4596  "incompatible contraction indices");
4597  if (shape_[pos1] != shape_[pos2])
4599  "In npstat::ArrayND::contract: incompatible "
4600  "length of contracted dimensions");
4601 
4602  // Construct the new shape
4603  unsigned newshapeBuf[Dim];
4604  unsigned* newshape = makeBuffer(dim_ - 2, newshapeBuf, Dim);
4605  unsigned ishap = 0;
4606  for (unsigned i = 0; i < dim_; ++i)
4607  if (i != pos1 && i != pos2)
4608  newshape[ishap++] = shape_[i];
4609 
4610  // Form the result array
4611  ArrayND<Numeric, Len, Dim> result(newshape, ishap);
4612  if (ishap)
4613  contractLoop(0, 0, pos1, pos2, 0UL, 0UL, result);
4614  else {
4615  // We are just calculating the trace
4616  Numeric sum = Numeric();
4617  const unsigned imax = shape_[0];
4618  const unsigned long stride = strides_[0] + strides_[1];
4619  for (unsigned i = 0; i < imax; ++i)
4620  sum += data_[i * stride];
4621  result() = sum;
4622  }
4623 
4624  destroyBuffer(newshape, newshapeBuf);
4625  return result;
4626  }

◆ contractLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
void npstat::ArrayND< Numeric, Len, Dim >::contractLoop ( unsigned  thisLevel,
unsigned  resLevel,
unsigned  pos1,
unsigned  pos2,
unsigned long  idxThis,
unsigned long  idxRes,
ArrayND< Numeric, StackLen, StackDim > &  result 
) const
private

Definition at line 4556 of file ArrayND.h.

4562  {
4563  while (thisLevel == pos1 || thisLevel == pos2)
4564  ++thisLevel;
4565  assert(thisLevel < dim_);
4566 
4567  if (resLevel == result.dim_ - 1) {
4568  const unsigned ncontract = shape_[pos1];
4569  const unsigned imax = result.shape_[resLevel];
4570  const unsigned long stride = strides_[pos1] + strides_[pos2];
4571  for (unsigned i = 0; i < imax; ++i) {
4572  const Numeric* tmp = data_ + (idxThis + i * strides_[thisLevel]);
4573  Numeric sum = Numeric();
4574  for (unsigned j = 0; j < ncontract; ++j)
4575  sum += tmp[j * stride];
4576  result.data_[idxRes + i] = sum;
4577  }
4578  } else {
4579  const unsigned imax = result.shape_[resLevel];
4580  assert(imax == shape_[thisLevel]);
4581  for (unsigned i = 0; i < imax; ++i) {
4582  contractLoop(thisLevel + 1, resLevel + 1, pos1, pos2, idxThis, idxRes, result);
4583  idxThis += strides_[thisLevel];
4584  idxRes += result.strides_[resLevel];
4585  }
4586  }
4587  }

◆ convertLinearIndex()

template<typename Numeric , unsigned Len, unsigned Dim>
void npstat::ArrayND< Numeric, Len, Dim >::convertLinearIndex ( unsigned long  l,
unsigned *  index,
unsigned  indexLen 
) const

Convert linear index into multidimensional index

Definition at line 3048 of file ArrayND.h.

3048  {
3049  if (!shapeIsKnown_)
3051  "Initialize npstat::ArrayND before calling "
3052  "method \"convertLinearIndex\"");
3053  if (!dim_)
3055  "npstat::ArrayND::convertLinearIndex method "
3056  "can not be used with array of 0 rank");
3057  if (idxLen != dim_)
3058  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::convertLinearIndex: incompatible index length");
3059  if (l >= len_)
3060  throw npstat::NpstatOutOfRange("In npstat::ArrayND::convertLinearIndex: linear index out of range");
3061  assert(idx);
3062 
3063  for (unsigned i = 0; i < dim_; ++i) {
3064  idx[i] = l / strides_[i];
3065  l -= (idx[i] * strides_[i]);
3066  }
3067  }

Referenced by npstat::HistoND< Numeric, Axis >::HistoND().

◆ convertToLastDimCdf()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Accumulator >
void npstat::ArrayND< Numeric, Len, Dim >::convertToLastDimCdf ( ArrayND< Numeric, StackLen, StackDim > *  sumSlice,
bool  useTrapezoids 
)
inline

The next function turns the array data into the conditional cumulative density function for the last dimension. "Num2" is the type of accumulator class used. The cdf is stored in such a way that the cdf value of 0 is skipped (the first stored value is the sum which includes the 0th bin). The slice is filled with the sum of values. The "useTrapezoids" parameter specifies whether trapezoidal integration formula should be utilized (rectangular integration is used in case "useTrapezoids" value is "false").

Definition at line 4496 of file ArrayND.h.

4496  {
4497  if (!shapeIsKnown_)
4499  "Initialize npstat::ArrayND before calling "
4500  "method \"convertToLastDimCdf\"");
4501  if (!dim_)
4503  "npstat::ArrayND::convertToLastDimCdf method "
4504  "can not be used with array of 0 rank");
4505  assert(sumSlice);
4506  if (!sumSlice->shapeIsKnown_)
4508  "In npstat::ArrayND::convertToLastDimCdf: "
4509  "uninitialized argument array");
4510  convertToLastDimCdfLoop<Accumulator>(sumSlice, 0U, 0UL, 0UL, useTrapezoids);
4511  }

◆ convertToLastDimCdfLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Accumulator >
void npstat::ArrayND< Numeric, Len, Dim >::convertToLastDimCdfLoop ( ArrayND< Numeric, StackLen, StackDim > *  sumSlice,
unsigned  level,
unsigned long  idx0,
unsigned long  idxSlice,
bool  useTrapezoids 
)
private

Definition at line 4457 of file ArrayND.h.

4458  {
4459  static const proper_double half = 0.5;
4460  const unsigned imax = shape_[level];
4461  if (level == dim_ - 1) {
4462  Accumulator acc = Accumulator();
4463  Numeric* data = data_ + idx0;
4464  if (useTrapezoids) {
4465  Numeric oldval = Numeric();
4466  for (unsigned i = 0; i < imax; ++i) {
4467  acc += (data[i] + oldval) * half;
4468  oldval = data[i];
4469  data[i] = static_cast<Numeric>(acc);
4470  }
4471  acc += oldval * half;
4472  } else
4473  for (unsigned i = 0; i < imax; ++i) {
4474  acc += data[i];
4475  data[i] = static_cast<Numeric>(acc);
4476  }
4477  if (sumSlice->dim_)
4478  sumSlice->data_[idxSlice] = static_cast<Numeric>(acc);
4479  else
4480  sumSlice->localData_[0] = static_cast<Numeric>(acc);
4481  } else {
4482  const unsigned long stride = strides_[level];
4483  unsigned long sumStride = 0UL;
4484  if (sumSlice->dim_)
4485  sumStride = sumSlice->strides_[level];
4486  for (unsigned i = 0; i < imax; ++i) {
4487  convertToLastDimCdfLoop<Accumulator>(sumSlice, level + 1, idx0, idxSlice, useTrapezoids);
4488  idx0 += stride;
4489  idxSlice += sumStride;
4490  }
4491  }
4492  }

◆ coordToIndex()

template<typename Numeric , unsigned Len, unsigned Dim>
unsigned npstat::ArrayND< Numeric, Len, Dim >::coordToIndex ( double  coord,
unsigned  idim 
) const
inlineprivate

Definition at line 3147 of file ArrayND.h.

3147  {
3148  if (x <= 0.0)
3149  return 0;
3150  else if (x >= static_cast<double>(shape_[idim] - 1))
3151  return shape_[idim] - 1;
3152  else
3153  return static_cast<unsigned>(std::floor(x + 0.5));
3154  }

◆ copyRangeLoopFunct()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, Len, Dim >::copyRangeLoopFunct ( unsigned  level,
unsigned long  idx0,
unsigned long  idx1,
const ArrayND< Num2, Len2, Dim2 > &  r,
const ArrayRange range,
Functor  f 
)
private

Definition at line 2565 of file ArrayND.h.

2570  {
2571  const unsigned imax = shape_[level];
2572  if (level == dim_ - 1) {
2573  Numeric* to = data_ + idx0;
2574  const Num2* from = r.data_ + (idx1 + range[level].min());
2575  for (unsigned i = 0; i < imax; ++i)
2576  *to++ = static_cast<Numeric>(f(*from++));
2577  } else {
2578  const unsigned long fromstride = r.strides_[level];
2579  const unsigned long tostride = strides_[level];
2580  idx1 += range[level].min() * fromstride;
2581  for (unsigned i = 0; i < imax; ++i) {
2582  copyRangeLoopFunct(level + 1, idx0, idx1, r, range, f);
2583  idx0 += tostride;
2584  idx1 += fromstride;
2585  }
2586  }
2587  }

◆ data()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
const Numeric* npstat::ArrayND< Numeric, StackLen, StackDim >::data ( ) const
inline

Linearized data

Definition at line 236 of file ArrayND.h.

236 { return data_; }

Referenced by npstat::LinInterpolatedTableND< Numeric, Axis >::invert1DResponse(), and npstat::Private::lind_invert1DSlice().

◆ derivative() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Accumulator >
ArrayND<Numeric, Len, Dim> npstat::ArrayND< Numeric, StackLen, StackDim >::derivative ( const double  inscale) const

Definition at line 4763 of file ArrayND.h.

4763  {
4764  if (!shapeIsKnown_)
4765  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"derivative\"");
4766  if (!dim_)
4768  "npstat::ArrayND::derivative method "
4769  "can not be used with array of 0 rank");
4770 
4771  const typename ProperDblFromCmpl<Accumulator>::type scale = inscale;
4772  const unsigned maxdim = CHAR_BIT * sizeof(unsigned long);
4773  if (dim_ >= maxdim)
4774  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::derivative: array rank is too large");
4775  const unsigned long maxcycle = 1UL << dim_;
4776 
4777  ArrayShape sh;
4778  sh.reserve(dim_);
4779  for (unsigned i = 0; i < dim_; ++i) {
4780  if (shape_[i] <= 1U)
4782  "In npstat::ArrayND::derivative: in some dimendions "
4783  "array size is too small");
4784  sh.push_back(shape_[i] - 1U);
4785  }
4786 
4787  ArrayND result(sh);
4788  const unsigned long rLen = result.length();
4789  for (unsigned long ilin = 0; ilin < rLen; ++ilin) {
4790  result.convertLinearIndex(ilin, &sh[0], dim_);
4791 
4792  Accumulator deriv = Accumulator();
4793  for (unsigned long icycle = 0UL; icycle < maxcycle; ++icycle) {
4794  unsigned long icell = 0UL;
4795  unsigned n1 = 0U;
4796  for (unsigned i = 0; i < dim_; ++i) {
4797  if (icycle & (1UL << i)) {
4798  ++n1;
4799  icell += strides_[i] * (sh[i] + 1);
4800  } else
4801  icell += strides_[i] * sh[i];
4802  }
4803  if ((dim_ - n1) % 2U)
4804  deriv -= data_[icell];
4805  else
4806  deriv += data_[icell];
4807  }
4808  result.data_[ilin] = static_cast<Numeric>(deriv * scale);
4809  }
4810 
4811  return result;
4812  }

◆ derivative() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND npstat::ArrayND< Numeric, StackLen, StackDim >::derivative ( double  scale = 1.0) const

Mixed derivative over all directions. Useful for generating densities from distribution functions. The resulting array will have one less point in each dimension. Class Num2 is used as accumulator for calculations. static_cast from Num2 to Numeric must exist. The result is multiplied by the scale factor provided.

◆ dot() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND npstat::ArrayND< Numeric, StackLen, StackDim >::dot ( const ArrayND< Num2, Len2, Dim2 > &  r) const

Here, dot product corresponds to outer product followed by the contraction over two indices – the last index of this object and the first index of the argument.

◆ dot() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND<Numeric, Len, Dim> npstat::ArrayND< Numeric, StackLen, StackDim >::dot ( const ArrayND< Num2, Len2, Dim2 > &  r) const

Definition at line 5052 of file ArrayND.h.

5052  {
5053  if (!dim_)
5055  "npstat::ArrayND::dot method "
5056  "can not be used with array of 0 rank");
5057  if (!r.dim_)
5059  "npstat::ArrayND::dot method "
5060  "can not be used with argument array of 0 rank");
5061  if (shape_[dim_ - 1] != r.shape_[0])
5062  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::dot: incompatible argument array shape");
5063 
5064  if (dim_ == 1 && r.dim_ == 1) {
5065  // Special case: the result is of 0 rank
5066  ArrayND<Numeric, Len, Dim> result(static_cast<unsigned*>(nullptr), 0U);
5067  Numeric sum = Numeric();
5068  const unsigned imax = shape_[0];
5069  for (unsigned i = 0; i < imax; ++i)
5070  sum += data_[i] * r.data_[i];
5071  result() = sum;
5072  return result;
5073  } else {
5074  unsigned newshapeBuf[2 * Dim];
5075  unsigned* newshape = makeBuffer(dim_ + r.dim_ - 2, newshapeBuf, 2 * Dim);
5076  copyBuffer(newshape, shape_, dim_ - 1);
5077  copyBuffer(newshape + (dim_ - 1), r.shape_ + 1, r.dim_ - 1);
5078  ArrayND<Numeric, Len, Dim> result(newshape, dim_ + r.dim_ - 2);
5079 
5080  dotProductLoop(0U, 0UL, 0UL, 0UL, r, result);
5081 
5082  destroyBuffer(newshape, newshapeBuf);
5083  return result;
5084  }
5085  }

◆ dotProductLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
void npstat::ArrayND< Numeric, Len, Dim >::dotProductLoop ( unsigned  level,
unsigned long  idx0,
unsigned long  idx1,
unsigned long  idx2,
const ArrayND< Num2, Len2, Dim2 > &  r,
ArrayND< Numeric, StackLen, StackDim > &  result 
) const
private

Definition at line 5019 of file ArrayND.h.

5024  {
5025  // idx0 -- this object
5026  // idx1 -- dot product argument
5027  // idx2 -- result
5028  if (level == result.dim_) {
5029  Numeric sum = Numeric();
5030  const unsigned imax = r.shape_[0];
5031  const unsigned rstride = r.strides_[0];
5032  const Numeric* l = data_ + idx0;
5033  const Num2* ri = r.data_ + idx1;
5034  for (unsigned i = 0; i < imax; ++i)
5035  sum += l[i] * ri[i * rstride];
5036  result.data_[idx2] = sum;
5037  } else {
5038  const unsigned imax = result.shape_[level];
5039  for (unsigned i = 0; i < imax; ++i) {
5040  dotProductLoop(level + 1, idx0, idx1, idx2, r, result);
5041  idx2 += result.strides_[level];
5042  if (level < dim_ - 1)
5043  idx0 += strides_[level];
5044  else
5045  idx1 += r.strides_[level + 2 - dim_];
5046  }
5047  }
5048  }

◆ dualCircularLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, Len, Dim >::dualCircularLoop ( unsigned  level,
unsigned long  idx0,
unsigned long  idx1,
const unsigned *  thisCorner,
const unsigned *  range,
const unsigned *  otherCorner,
ArrayND< Num2, Len2, Dim2 > &  other,
Functor  binaryFunct 
)
private

Definition at line 1392 of file ArrayND.h.

1399  {
1400  const unsigned imax = range[level];
1401  const unsigned leftShift = thisCorner[level];
1402  const unsigned leftPeriod = shape_[level];
1403  const unsigned rightShift = otherCorner[level];
1404  const unsigned rightPeriod = r.shape_[level];
1405 
1406  if (level == dim_ - 1) {
1407  Numeric* left = data_ + idx0;
1408  Num2* right = r.data_ + idx1;
1409  for (unsigned i = 0; i < imax; ++i)
1410  binaryFunct(left[(i + leftShift) % leftPeriod], right[(i + rightShift) % rightPeriod]);
1411  } else {
1412  const unsigned long leftStride = strides_[level];
1413  const unsigned long rightStride = r.strides_[level];
1414  for (unsigned i = 0; i < imax; ++i)
1415  dualCircularLoop(level + 1,
1416  idx0 + ((i + leftShift) % leftPeriod) * leftStride,
1417  idx1 + ((i + rightShift) % rightPeriod) * rightStride,
1418  thisCorner,
1419  range,
1420  otherCorner,
1421  r,
1422  binaryFunct);
1423  }
1424  }

◆ dualCircularScan()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, Len, Dim >::dualCircularScan ( ArrayND< Num2, Len2, Dim2 > &  other,
const unsigned *  thisCorner,
const unsigned *  range,
const unsigned *  otherCorner,
unsigned  arrLen,
Functor  binaryFunct 
)

Method similar to "jointSubrangeScan" in which the topology of both arrays is assumed to be hypertoroidal (circular buffer in every dimension)

Definition at line 1505 of file ArrayND.h.

◆ exportMemSlice()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
void npstat::ArrayND< Numeric, StackLen, StackDim >::exportMemSlice ( Num2 *  buffer,
unsigned long  bufLen,
const unsigned *  fixedIndices,
const unsigned *  fixedIndexValues,
unsigned  nFixedIndices 
) const
inline

Convenience method for exporting a slice of this array into a memory buffer

Definition at line 710 of file ArrayND.h.

714  {
715  (const_cast<ArrayND*>(this))
717  buffer, bufLen, fixedIndices, fixedIndexValues, nFixedIndices, scast_assign_right<Numeric, Num2>());
718  }

◆ exportSlice()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
void npstat::ArrayND< Numeric, StackLen, StackDim >::exportSlice ( ArrayND< Num2, Len2, Dim2 > *  slice,
const unsigned *  fixedIndices,
const unsigned *  fixedIndexValues,
unsigned  nFixedIndices 
) const
inline

Convenience method for exporting a slice of this array

Definition at line 696 of file ArrayND.h.

699  {
700  assert(slice);
701  (const_cast<ArrayND*>(this))
702  ->jointSliceScan(*slice, fixedIndices, fixedIndexValues, nFixedIndices, scast_assign_right<Numeric, Num2>());
703  }

◆ exportSubrange()

template<typename Numeric , unsigned Len, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
void npstat::ArrayND< Numeric, Len, StackDim >::exportSubrange ( const unsigned *  fromCorner,
unsigned  lenCorner,
ArrayND< Num2, Len2, Dim2 > *  dest 
) const

Copy a hyperrectangular subrange of this array potentially completely overwriting the destination array. The starting corner in this object where copying begins is provided by the first two arguments. The subrange size is defined by the shape of the destination array.

Definition at line 5418 of file ArrayND.h.

5420  {
5421  if (!shapeIsKnown_)
5422  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"exportSubrange\"");
5423  if (dim_ != lenCorner)
5424  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::exportSubrange: incompatible corner index length");
5425  assert(out);
5426  if (!out->shapeIsKnown_)
5427  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::exportSubrange: uninitialized argument array");
5428  if (out->dim_ != dim_)
5429  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::exportSubrange: incompatible argument array rank");
5430 
5431  if (dim_) {
5432  assert(corner);
5433  if (dim_ > CHAR_BIT * sizeof(unsigned long))
5435  "In npstat::ArrayND::exportSubrange: "
5436  "array rank is too large");
5437  unsigned toBuf[CHAR_BIT * sizeof(unsigned long)];
5438  clearBuffer(toBuf, dim_);
5439  (const_cast<ArrayND*>(this))
5440  ->commonSubrangeLoop(0U, 0UL, 0UL, corner, out->shape_, toBuf, *out, scast_assign_right<Numeric, Num2>());
5441  } else
5442  out->localData_[0] = static_cast<Num2>(localData_[0]);
5443  }

◆ flatCircularLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, Len, Dim >::flatCircularLoop ( unsigned  level,
unsigned long  idx0,
unsigned long  idx1,
const unsigned *  thisCorner,
const unsigned *  range,
const unsigned *  otherCorner,
ArrayND< Num2, Len2, Dim2 > &  other,
Functor  binaryFunct 
)
private

Definition at line 1428 of file ArrayND.h.

1435  {
1436  const unsigned imax = range[level];
1437  const unsigned rightShift = otherCorner[level];
1438  const unsigned rightPeriod = r.shape_[level];
1439 
1440  if (level == dim_ - 1) {
1441  Numeric* left = data_ + (idx0 + thisCorner[level]);
1442  Numeric* const lMax = data_ + (idx0 + shape_[level]);
1443  Num2* right = r.data_ + idx1;
1444 
1445  for (unsigned i = 0; i < imax && left < lMax; ++i)
1446  binaryFunct(*left++, right[(i + rightShift) % rightPeriod]);
1447  } else {
1448  const unsigned long leftStride = strides_[level];
1449  const unsigned long leftMax = idx0 + shape_[level] * leftStride;
1450  idx0 += thisCorner[level] * leftStride;
1451  const unsigned long rightStride = r.strides_[level];
1452 
1453  for (unsigned i = 0; i < imax && idx0 < leftMax; ++i, idx0 += leftStride)
1454  flatCircularLoop(level + 1,
1455  idx0,
1456  idx1 + ((i + rightShift) % rightPeriod) * rightStride,
1457  thisCorner,
1458  range,
1459  otherCorner,
1460  r,
1461  binaryFunct);
1462  }
1463  }

◆ flatCircularScan()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, Len, Dim >::flatCircularScan ( ArrayND< Num2, Len2, Dim2 > &  other,
const unsigned *  thisCorner,
const unsigned *  range,
const unsigned *  otherCorner,
unsigned  arrLen,
Functor  binaryFunct 
)

Method similar to "jointSubrangeScan" in which the topology of this array is assumed to be flat and the other array hypertoroidal

Definition at line 1507 of file ArrayND.h.

◆ fullRange()

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayRange npstat::ArrayND< Numeric, Len, Dim >::fullRange ( ) const
inline

Get the complete range

Definition at line 2996 of file ArrayND.h.

2996  {
2997  if (!shapeIsKnown_)
2998  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"fullRange\"");
2999  ArrayRange range;
3000  if (dim_) {
3001  range.reserve(dim_);
3002  for (unsigned i = 0; i < dim_; ++i)
3003  range.push_back(Interval<unsigned>(0U, shape_[i]));
3004  }
3005  return range;
3006  }

◆ functorFill() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<class Functor >
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::functorFill ( Functor  f)

This method fills the array from a functor which takes (const unsigned* index, unsigned indexLen) arguments. There must be a conversion (static cast) from the functor result to the "Numeric" type.

◆ functorFill() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<class Functor >
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::functorFill ( Functor  f)

Definition at line 4515 of file ArrayND.h.

4515  {
4516  if (!shapeIsKnown_)
4517  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"functorFill\"");
4518  if (dim_) {
4519  unsigned localIndex[Dim];
4520  unsigned* index = makeBuffer(dim_, localIndex, Dim);
4521  functorFillLoop(0U, 0UL, f, index);
4522  destroyBuffer(index, localIndex);
4523  } else
4524  localData_[0] = static_cast<Numeric>(f(static_cast<unsigned*>(nullptr), 0U));
4525  return *this;
4526  }

◆ functorFillLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
template<class Functor >
void npstat::ArrayND< Numeric, Len, Dim >::functorFillLoop ( unsigned  level,
unsigned long  idx,
Functor  f,
unsigned *  farg 
)
private

Definition at line 4434 of file ArrayND.h.

4437  {
4438  const unsigned imax = shape_[level];
4439  if (level == dim_ - 1) {
4440  Numeric* d = &data_[idx];
4441  const unsigned* myarg = farg;
4442  for (unsigned i = 0; i < imax; ++i) {
4443  farg[level] = i;
4444  d[i] = static_cast<Numeric>(f(myarg, dim_));
4445  }
4446  } else {
4447  const unsigned long stride = strides_[level];
4448  for (unsigned i = 0; i < imax; ++i) {
4449  farg[level] = i;
4450  functorFillLoop(level + 1, idx + i * stride, f, farg);
4451  }
4452  }
4453  }

◆ importMemSlice()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
void npstat::ArrayND< Numeric, StackLen, StackDim >::importMemSlice ( const Num2 *  buffer,
unsigned long  bufLen,
const unsigned *  fixedIndices,
const unsigned *  fixedIndexValues,
unsigned  nFixedIndices 
)
inline

Convenience method for importing a slice into this array from a memory buffer

Definition at line 738 of file ArrayND.h.

742  {
743  jointMemSliceScan(const_cast<Num2*>(buffer),
744  bufLen,
745  fixedIndices,
746  fixedIndexValues,
747  nFixedIndices,
748  scast_assign_left<Numeric, Num2>());
749  }

◆ importSlice()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
void npstat::ArrayND< Numeric, StackLen, StackDim >::importSlice ( const ArrayND< Num2, Len2, Dim2 > &  slice,
const unsigned *  fixedIndices,
const unsigned *  fixedIndexValues,
unsigned  nFixedIndices 
)
inline

Convenience method for importing a slice into this array

Definition at line 722 of file ArrayND.h.

725  {
726  jointSliceScan(const_cast<ArrayND<Num2, Len2, Dim2>&>(slice),
727  fixedIndices,
728  fixedIndexValues,
729  nFixedIndices,
730  scast_assign_left<Numeric, Num2>());
731  }

◆ importSubrange()

template<typename Numeric , unsigned Len, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
void npstat::ArrayND< Numeric, Len, StackDim >::importSubrange ( const unsigned *  fromCorner,
unsigned  lenCorner,
const ArrayND< Num2, Len2, Dim2 > &  from 
)

The inverse operation to "exportSubrange"

Definition at line 5447 of file ArrayND.h.

5449  {
5450  if (!shapeIsKnown_)
5451  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"importSubrange\"");
5452  if (dim_ != lenCorner)
5453  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::importSubrange: incompatible corner index length");
5454  if (!from.shapeIsKnown_)
5455  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::importSubrange: uninitialized argument array");
5456  if (from.dim_ != dim_)
5457  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::importSubrange: incompatible argument array rank");
5458 
5459  if (dim_) {
5460  assert(corner);
5461  if (dim_ > CHAR_BIT * sizeof(unsigned long))
5463  "In npstat::ArrayND::importSubrange: "
5464  "array rank is too large");
5465  unsigned toBuf[CHAR_BIT * sizeof(unsigned long)];
5466  clearBuffer(toBuf, dim_);
5468  0UL,
5469  0UL,
5470  corner,
5471  from.shape_,
5472  toBuf,
5473  const_cast<ArrayND<Num2, Len2, Dim2>&>(from),
5474  scast_assign_left<Numeric, Num2>());
5475  } else
5476  localData_[0] = static_cast<Numeric>(from.localData_[0]);
5477  }

◆ inPlaceMul()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::inPlaceMul ( const ArrayND< Num2, Len2, Dim2 > &  r)
inline

Convenience method for element-by-element in-place multiplication

Definition at line 551 of file ArrayND.h.

551  {
552  jointScan(const_cast<ArrayND<Num2, Len2, Dim2>&>(r), multeq_left<Numeric, Num2>());
553  return *this;
554  }

◆ interpolate1()

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric npstat::ArrayND< Numeric, Len, Dim >::interpolate1 ( const double *  x,
unsigned  xDim 
) const

Multilinear interpolation. Closest value extrapolation is used in case some index is outside of the array bounds. Note that this function works only if the array dimensionality is less than CHAR_BIT*sizeof(unsigned long). x is the "coordinate" which coincides with array index for x equal to unsigned integers.

Definition at line 4211 of file ArrayND.h.

4211  {
4212  if (!shapeIsKnown_)
4213  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"interpolate1\"");
4214  if (dim != dim_)
4215  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::interpolate1: incompatible coordinate length");
4216  if (dim) {
4217  const unsigned maxdim = CHAR_BIT * sizeof(unsigned long);
4218  if (dim_ >= maxdim)
4219  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::interpolate1: array rank is too large");
4220 
4221  double dx[maxdim];
4222  unsigned ix[maxdim];
4223  for (unsigned i = 0; i < dim; ++i) {
4224  const double x = coords[i];
4225  if (x <= 0.0) {
4226  ix[i] = 0;
4227  dx[i] = 0.0;
4228  } else if (x >= static_cast<double>(shape_[i] - 1)) {
4229  ix[i] = shape_[i] - 1;
4230  dx[i] = 0.0;
4231  } else {
4232  ix[i] = static_cast<unsigned>(std::floor(x));
4233  dx[i] = x - ix[i];
4234  }
4235  }
4236 
4237  Numeric sum = Numeric();
4238  const unsigned long maxcycle = 1UL << dim;
4239  for (unsigned long icycle = 0UL; icycle < maxcycle; ++icycle) {
4240  double w = 1.0;
4241  unsigned long icell = 0UL;
4242  for (unsigned i = 0; i < dim; ++i) {
4243  if (icycle & (1UL << i)) {
4244  w *= dx[i];
4245  icell += strides_[i] * (ix[i] + 1U);
4246  } else {
4247  w *= (1.0 - dx[i]);
4248  icell += strides_[i] * ix[i];
4249  }
4250  }
4251  if (w > 0.0)
4252  sum += data_[icell] * static_cast<proper_double>(w);
4253  }
4254  return sum;
4255  } else
4256  return localData_[0];
4257  }

Referenced by npstat::Private::ArrayMapper< Num1, Len1, Dim1, Num2, Len2, Dim2 >::operator()().

◆ interpolate3()

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric npstat::ArrayND< Numeric, Len, Dim >::interpolate3 ( const double *  x,
unsigned  xDim 
) const
inline

Multicubic interpolation. Closest value extrapolation is used in case some index is outside of the array bounds. This function is much slower than "interpolate1" (in the current implementation, a recursive algorithm is used).

Definition at line 4309 of file ArrayND.h.

4309  {
4310  if (!shapeIsKnown_)
4311  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"interpolate3\"");
4312  if (dim != dim_)
4313  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::interpolate3: incompatible coordinate length");
4314  if (dim) {
4315  assert(coords);
4316  return interpolateLoop(0, coords, data_);
4317  } else
4318  return localData_[0];
4319  }

Referenced by npstat::Private::ArrayMapper< Num1, Len1, Dim1, Num2, Len2, Dim2 >::operator()().

◆ interpolateLoop()

template<typename Numeric, unsigned Len, unsigned Dim>
Numeric npstat::ArrayND< Numeric, Len, Dim >::interpolateLoop ( unsigned  level,
const double *  x,
const Numeric *  base 
) const
private

Definition at line 4260 of file ArrayND.h.

4262  {
4263  const unsigned npoints = shape_[level];
4264  const double x = coords[level];
4265 
4266  unsigned ix, npt = 1;
4267  double dx = 0.0;
4268  if (x < 0.0)
4269  ix = 0;
4270  else if (x > static_cast<double>(npoints - 1))
4271  ix = npoints - 1;
4272  else {
4273  ix = static_cast<unsigned>(std::floor(x));
4274  if (ix)
4275  --ix;
4276  unsigned imax = ix + 3;
4277  while (imax >= npoints) {
4278  if (ix)
4279  --ix;
4280  --imax;
4281  }
4282  dx = x - ix;
4283  npt = imax + 1 - ix;
4284  }
4285  assert(npt >= 1 && npt <= 4);
4286 
4287  Numeric fit[4];
4288  if (level < dim_ - 1)
4289  for (unsigned ipt = 0; ipt < npt; ++ipt)
4290  fit[ipt] = interpolateLoop(level + 1, coords, base + (ix + ipt) * strides_[level]);
4291 
4292  const Numeric* const v = (level == dim_ - 1 ? base + ix : fit);
4293  switch (npt) {
4294  case 1:
4295  return v[0];
4296  case 2:
4297  return interpolate_linear(dx, v[0], v[1]);
4298  case 3:
4299  return interpolate_quadratic(dx, v[0], v[1], v[2]);
4300  case 4:
4301  return interpolate_cubic(dx, v[0], v[1], v[2], v[3]);
4302  default:
4303  assert(0);
4304  return Numeric();
4305  }
4306  }

◆ isClose()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
bool npstat::ArrayND< Numeric, Len, Dim >::isClose ( const ArrayND< Num2, Len2, Dim2 > &  r,
double  eps 
) const

Check that all elements of this array differ from the corresponding elements of another array by at most "eps". Equivalent to maxAbsDifference(r) <= eps (but usually faster).

Definition at line 4530 of file ArrayND.h.

4530  {
4531  if (eps < 0.0)
4532  throw npstat::NpstatDomainError("In npstat::ArrayND::isClose: tolerance must not be negative");
4533  if (!isShapeCompatible(r))
4534  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::isClose: incompatible argument array shape");
4535  if (dim_) {
4536  for (unsigned long i = 0; i < len_; ++i) {
4537  const Numeric rval = r.data_[i];
4538  if (static_cast<double>(absDifference(data_[i], rval)) > eps)
4539  return false;
4540  }
4541  } else {
4542  const Numeric rval = r.localData_[0];
4543  if (static_cast<double>(absDifference(localData_[0], rval)) > eps)
4544  return false;
4545  }
4546  return true;
4547  }

◆ isCompatible()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
bool npstat::ArrayND< Numeric, StackLen, StackDim >::isCompatible ( const ArrayShape shape) const
inline

Check compatibility with another shape

Definition at line 2370 of file ArrayND.h.

2370  {
2371  if (!shapeIsKnown_)
2372  return false;
2373  if (dim_ != shape.size())
2374  return false;
2375  if (dim_) {
2376  for (unsigned i = 0; i < dim_; ++i)
2377  if (shape_[i] != shape[i])
2378  return false;
2379  } else
2380  assert(len_ == 1UL);
2381  return true;
2382  }

◆ isDensity()

template<typename Numeric , unsigned Len, unsigned Dim>
bool npstat::ArrayND< Numeric, Len, Dim >::isDensity ( ) const

This method checks whether all array elements are non-negative and, in addition, there is at least one positive element

Definition at line 3009 of file ArrayND.h.

3009  {
3010  if (!shapeIsKnown_)
3011  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"isDensity\"");
3012  const Numeric zero = Numeric();
3013  bool hasPositive = false;
3014  if (dim_)
3015  for (unsigned long i = 0; i < len_; ++i) {
3016  // Don't make comparisons whose result can be
3017  // determined in advance by assuming that Numeric
3018  // is an unsigned type. Some compilers will
3019  // complain about it when this template is
3020  // instantiated with such a type.
3021  if (data_[i] == zero)
3022  continue;
3024  hasPositive = true;
3025  else
3026  return false;
3027  }
3028  else
3030  return hasPositive;
3031  }

◆ isShapeCompatible()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
bool npstat::ArrayND< Numeric, StackLen, StackDim >::isShapeCompatible ( const ArrayND< Num2, Len2, Dim2 > &  r) const
inline

Check shape compatibility with another array. Equivalent to but faster than isCompatible(r.shape()).

Definition at line 2386 of file ArrayND.h.

2386  {
2387  if (!shapeIsKnown_)
2388  return false;
2389  if (!r.shapeIsKnown_)
2390  return false;
2391  if (dim_ != r.dim_)
2392  return false;
2393  if (len_ != r.len_)
2394  return false;
2395  if (dim_) {
2396  assert(shape_);
2397  assert(r.shape_);
2398  for (unsigned i = 0; i < dim_; ++i)
2399  if (shape_[i] != r.shape_[i])
2400  return false;
2401  } else
2402  assert(len_ == 1UL);
2403  return true;
2404  }

◆ isShapeKnown()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
bool npstat::ArrayND< Numeric, StackLen, StackDim >::isShapeKnown ( ) const
inline

Check whether the array has been initialized

Definition at line 239 of file ArrayND.h.

239 { return shapeIsKnown_; }

◆ isZero()

template<typename Numeric , unsigned Len, unsigned Dim>
bool npstat::ArrayND< Numeric, Len, Dim >::isZero ( ) const

Check if all array elements are zero

Definition at line 3034 of file ArrayND.h.

3034  {
3035  if (!shapeIsKnown_)
3036  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"isZero\"");
3037  const Numeric zero = Numeric();
3038  if (dim_) {
3039  for (unsigned long i = 0; i < len_; ++i)
3040  if (data_[i] != zero)
3041  return false;
3042  } else if (localData_[0] != zero)
3043  return false;
3044  return true;
3045  }

◆ jointMemSliceScan()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , class Functor >
void npstat::ArrayND< Numeric, StackLen, StackDim >::jointMemSliceScan ( Num2 *  buffer,
unsigned long  bufLen,
const unsigned *  fixedIndices,
const unsigned *  fixedIndexValues,
unsigned  nFixedIndices,
Functor  binaryFunct 
)

Joint cycle over a slice this array and some memory buffer. The length of the buffer must be equal to the length of the slice, as in "jointSliceScan". This method is to be used for import/export of slice data and in-place operations (addition, multiplication, etc) with memory managed not by ArrayND but in some other manner.

Definition at line 1948 of file ArrayND.h.

1953  {
1954  assert(slice);
1955  if (dim_ > CHAR_BIT * sizeof(unsigned long))
1957  "In npstat::ArrayND::jointMemSliceScan: "
1958  "rank of this array is too large");
1959  unsigned long sliceStrides[CHAR_BIT * sizeof(unsigned long)];
1960  const unsigned long idx =
1961  verifyBufferSliceCompatibility(len, fixedIndices, fixedIndexValues, nFixedIndices, sliceStrides);
1962  if (dim_ > nFixedIndices)
1963  jointSliceLoop(0U, idx, 0U, 0UL, slice, sliceStrides, fixedIndices, fixedIndexValues, nFixedIndices, binaryFunct);
1964  else
1965  binaryFunct(data_[idx], *slice);
1966  }

Referenced by npstat::ArrayND< Num1, Len1, Dim1 >::exportMemSlice(), and npstat::ArrayND< Num1, Len1, Dim1 >::importMemSlice().

◆ jointScan()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, StackLen, StackDim >::jointScan ( ArrayND< Num2, Len2, Dim2 > &  other,
Functor  binaryFunct 
)

Loop over all elements of two compatible arrays and apply a binary functor

Definition at line 2342 of file ArrayND.h.

2342  {
2343  if (!isShapeCompatible(r))
2344  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::jointScan: incompatible argument array shape");
2345  if (dim_)
2346  for (unsigned long i = 0; i < len_; ++i)
2347  binaryFunct(data_[i], r.data_[i]);
2348  else
2349  binaryFunct(localData_[0], r.localData_[0]);
2350  }

Referenced by npstat::ArrayND< Num1, Len1, Dim1 >::inPlaceMul().

◆ jointSliceLoop() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , class Op >
void npstat::ArrayND< Numeric, StackLen, StackDim >::jointSliceLoop ( const unsigned  level,
const unsigned long  idx0,
const unsigned  level1,
const unsigned long  idx1,
Num2 *  sliceData,
const unsigned long *  sliceStrides,
const unsigned *  fixedIndices,
const unsigned *  fixedIndexValues,
const unsigned  nFixedIndices,
Op  fcn 
)
private

Definition at line 1886 of file ArrayND.h.

1895  {
1896  bool fixed = false;
1897  for (unsigned j = 0; j < nFixedIndices; ++j)
1898  if (fixedIndices[j] == level) {
1899  fixed = true;
1900  break;
1901  }
1902  if (fixed)
1904  level + 1, idx0, level1, idx1, sliceData, sliceStrides, fixedIndices, fixedIndexValues, nFixedIndices, fcn);
1905  else {
1906  const unsigned imax = shape_[level];
1907  const unsigned long stride = strides_[level];
1908 
1909  if (level1 == dim_ - nFixedIndices - 1) {
1910  sliceData += idx1;
1911  Numeric* localData = data_ + idx0;
1912  for (unsigned i = 0; i < imax; ++i)
1913  fcn(localData[i * stride], sliceData[i]);
1914  } else {
1915  const unsigned long stride2 = sliceStrides[level1];
1916  for (unsigned i = 0; i < imax; ++i)
1917  jointSliceLoop(level + 1,
1918  idx0 + i * stride,
1919  level1 + 1,
1920  idx1 + i * stride2,
1921  sliceData,
1922  sliceStrides,
1923  fixedIndices,
1924  fixedIndexValues,
1925  nFixedIndices,
1926  fcn);
1927  }
1928  }
1929  }

◆ jointSliceLoop() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , class Functor >
void npstat::ArrayND< Numeric, StackLen, StackDim >::jointSliceLoop ( unsigned  level,
unsigned long  idx0,
unsigned  level1,
unsigned long  idx1,
Num2 *  sliceData,
const unsigned long *  sliceStrides,
const unsigned *  fixedIndices,
const unsigned *  fixedIndexValues,
unsigned  nFixedIndices,
Functor  binaryFunctor 
)
private

◆ jointSliceScan()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, StackLen, StackDim >::jointSliceScan ( ArrayND< Num2, Len2, Dim2 > &  slice,
const unsigned *  fixedIndices,
const unsigned *  fixedIndexValues,
unsigned  nFixedIndices,
Functor  binaryFunct 
)

Joint cycle over the data of this array and the slice. The array to which the "slice" argument refers should normally be created by the slicing constructor using this array as the argument. The "fixedIndices" argument should be the same as the "indices" argument in that constructor. This method is to be used for import/export of slice data and in-place operations (addition, multiplication, etc).

Definition at line 1933 of file ArrayND.h.

1937  {
1938  const unsigned long idx = verifySliceCompatibility(slice, fixedIndices, fixedIndexValues, nFixedIndices);
1939  if (slice.dim_)
1941  0U, idx, 0U, 0UL, slice.data_, slice.strides_, fixedIndices, fixedIndexValues, nFixedIndices, binaryFunct);
1942  else
1943  binaryFunct(data_[idx], slice.localData_[0]);
1944  }

Referenced by npstat::ArrayND< Num1, Len1, Dim1 >::exportSlice(), and npstat::ArrayND< Num1, Len1, Dim1 >::importSlice().

◆ jointSubrangeScan()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, Len, Dim >::jointSubrangeScan ( ArrayND< Num2, Len2, Dim2 > &  other,
const unsigned *  thisCorner,
const unsigned *  range,
const unsigned *  otherCorner,
unsigned  arrLen,
Functor  binaryFunct 
)

Loop over subranges in two arrays in such a way that the functor is called only if the indices on both sides are valid. The topology of both arrays is assumed to be box-like (flat). The starting corner in this object (where cycling begins) is provided by the argument "thisCorner". The "range" argument specifies the width of the processed patch in each dimension. The corner of the "other" array where cycling begins is provided by the "otherCorner" argument. The "arrLen" argument specifies the number of elements in "thisCorner", "range", and "otherCorner" arrays. It should be equal to the rank of either of the two ArrayND arrays.

Note that there is no good way for this method to assume constness of this or "other" array: this becomes apparent only after the functor has been specified. Apply const_cast judiciously as needed, other solutions of this problem are not any better.

Definition at line 1504 of file ArrayND.h.

◆ length()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
unsigned long npstat::ArrayND< Numeric, StackLen, StackDim >::length ( ) const
inline

◆ linearFill()

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > & npstat::ArrayND< Numeric, Len, Dim >::linearFill ( const double *  coeff,
unsigned  coeffLen,
double  c 
)

This method fills the array with a linear combination of the index values. For example, a 2-d array element with indices i, k will be set to (coeff[0]*i + coeff[1]*k + c). There must be a conversion (static cast) from double into "Numeric".

Definition at line 4416 of file ArrayND.h.

4418  {
4419  // Make sure the object has been initialized
4420  if (!shapeIsKnown_)
4421  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"linearFill\"");
4422  if (dim_ != dimCoeffs)
4423  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::linearFill: incompatible number of coefficients");
4424  if (dim_) {
4425  assert(coeffs);
4426  linearFillLoop(0U, 0.0, 0UL, shift, coeffs);
4427  } else
4428  localData_[0] = static_cast<Numeric>(shift);
4429  return *this;
4430  }

◆ linearFillLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
void npstat::ArrayND< Numeric, Len, Dim >::linearFillLoop ( unsigned  level,
double  s0,
unsigned long  idx,
double  shift,
const double *  coeffs 
)
private

Definition at line 4395 of file ArrayND.h.

4396  {
4397  const unsigned imax = shape_[level];
4398  const double c = coeffs[level];
4399  if (level == dim_ - 1) {
4400  Numeric* d = &data_[idx];
4401  for (unsigned i = 0; i < imax; ++i) {
4402  // Note that we want to add "shift" only at the
4403  // very end. This might improve the numerical
4404  // precision of the result.
4405  const double sum = s0 + c * i + shift;
4406  d[i] = static_cast<Numeric>(sum);
4407  }
4408  } else {
4409  const unsigned long stride = strides_[level];
4410  for (unsigned i = 0; i < imax; ++i)
4411  linearFillLoop(level + 1, s0 + c * i, idx + i * stride, shift, coeffs);
4412  }
4413  }

◆ linearIndex()

template<typename Numeric , unsigned Len, unsigned Dim>
unsigned long npstat::ArrayND< Numeric, Len, Dim >::linearIndex ( const unsigned *  idx,
unsigned  idxLen 
) const

Convert multidimensional index into linear index

Definition at line 3070 of file ArrayND.h.

3070  {
3071  if (!shapeIsKnown_)
3072  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"linearIndex\"");
3073  if (!dim_)
3075  "npstat::ArrayND::linearIndex method "
3076  "can not be used with array of 0 rank");
3077  if (idxLen != dim_)
3078  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::linearIndex: incompatible index length");
3079  assert(index);
3080 
3081  unsigned long idx = 0UL;
3082  for (unsigned i = 0; i < dim_; ++i) {
3083  if (index[i] >= shape_[i])
3084  throw npstat::NpstatOutOfRange("In npstat::ArrayND::linearIndex: index out of range");
3085  idx += index[i] * strides_[i];
3086  }
3087  return idx;
3088  }

◆ linearValue() [1/2]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::linearValue ( unsigned long  index)
inline

Element access using linear index (no bounds checking)

Definition at line 3123 of file ArrayND.h.

3123  {
3124  return data_[index];
3125  }

Referenced by npstat::HistoND< Numeric, Axis >::HistoND(), and npstat::HistoND< Numeric, Axis >::setLinearBin().

◆ linearValue() [2/2]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::linearValue ( unsigned long  index) const
inline

Definition at line 3128 of file ArrayND.h.

3128  {
3129  return data_[index];
3130  }

◆ linearValueAt() [1/2]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::linearValueAt ( unsigned long  index)
inline

Element access using linear index (with bounds checking)

Definition at line 3133 of file ArrayND.h.

3133  {
3134  if (index >= len_)
3135  throw npstat::NpstatOutOfRange("In npstat::ArrayND::linearValueAt: linear index out of range");
3136  return data_[index];
3137  }

Referenced by npstat::HistoND< Numeric, Axis >::setLinearBinAt().

◆ linearValueAt() [2/2]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::linearValueAt ( unsigned long  index) const
inline

Definition at line 3140 of file ArrayND.h.

3140  {
3141  if (index >= len_)
3142  throw npstat::NpstatOutOfRange("In npstat::ArrayND::linearValueAt: linear index out of range");
3143  return data_[index];
3144  }

◆ makeCopulaSteps()

template<typename Numeric , unsigned Len, unsigned Dim>
unsigned npstat::ArrayND< Numeric, Len, Dim >::makeCopulaSteps ( double  tolerance,
unsigned  maxIterations 
)

This method accumulates marginals and divides the array (treated as a distribution) by the product of the marginals. Several iterations like this turn the distribution into a copula. If the array contains negative elements, they are turned into zeros before the iterations are performed. The function returns the actual number of iteration performed when the given tolerance was reached for all marginals.

Definition at line 4073 of file ArrayND.h.

4073  {
4074  if (!shapeIsKnown_)
4075  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"makeCopulaSteps\"");
4076  if (nCycles == 0U)
4077  return 0U;
4078  if (!dim_)
4080  "npstat::ArrayND::makeCopulaSteps method "
4081  "can not be used with array of 0 rank");
4082 
4083  const Numeric zero = Numeric();
4084  for (unsigned long i = 0; i < len_; ++i)
4086  data_[i] = zero;
4087 
4088  std::vector<Numeric*> axesPtrBuf(dim_);
4089  Numeric** axes = &axesPtrBuf[0];
4090  const Numeric one = static_cast<Numeric>(1);
4091 
4092  // Memory for the axis accumulators
4093  unsigned idxSum = 0;
4094  for (unsigned i = 0; i < dim_; ++i)
4095  idxSum += shape_[i];
4096  std::vector<Numeric> axesBuf(idxSum);
4097  axes[0] = &axesBuf[0];
4098  for (unsigned i = 1; i < dim_; ++i)
4099  axes[i] = axes[i - 1] + shape_[i - 1];
4100 
4101  // Accumulate axis projections
4102  unsigned icycle = 0;
4103  for (; icycle < nCycles; ++icycle) {
4104  for (unsigned i = 0; i < idxSum; ++i)
4105  axesBuf[i] = zero;
4106 
4107  // Accumulate sums for each axis
4108  for (unsigned long idat = 0; idat < len_; ++idat) {
4109  unsigned long l = idat;
4110  for (unsigned i = 0; i < dim_; ++i) {
4111  const unsigned idx = l / strides_[i];
4112  l -= (idx * strides_[i]);
4113  axes[i][idx] += data_[idat];
4114  }
4115  }
4116 
4117  // Make averages out of sums
4118  bool withinTolerance = true;
4119  Numeric totalSum = zero;
4120  for (unsigned i = 0; i < dim_; ++i) {
4121  Numeric axisSum = zero;
4122  const unsigned amax = shape_[i];
4123  for (unsigned a = 0; a < amax; ++a) {
4124  if (axes[i][a] == zero)
4126  "In npstat::ArrayND::makeCopulaSteps: "
4127  "marginal density is zero");
4128  axisSum += axes[i][a];
4129  }
4130  totalSum += axisSum;
4131  const Numeric axisAverage = axisSum / static_cast<Numeric>(amax);
4132  for (unsigned a = 0; a < amax; ++a)
4133  axes[i][a] /= axisAverage;
4134  for (unsigned a = 0; a < amax && withinTolerance; ++a) {
4135  const double adelta = absDifference(axes[i][a], one);
4136  if (adelta > tolerance)
4137  withinTolerance = false;
4138  }
4139  }
4140 
4141  if (withinTolerance)
4142  break;
4143 
4144  const Numeric totalAverage = totalSum / static_cast<Numeric>(len_) / static_cast<Numeric>(dim_);
4145 
4146  // Run over all points again and divide by
4147  // the product of marginals
4148  for (unsigned long idat = 0; idat < len_; ++idat) {
4149  unsigned long l = idat;
4150  for (unsigned i = 0; i < dim_; ++i) {
4151  const unsigned idx = l / strides_[i];
4152  l -= (idx * strides_[i]);
4153  data_[idat] /= axes[i][idx];
4154  }
4155  data_[idat] /= totalAverage;
4156  }
4157  }
4158 
4159  return icycle;
4160  }

◆ makeNonNegative()

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > & npstat::ArrayND< Numeric, Len, Dim >::makeNonNegative ( )

This method turns all negative elements into zeros

Definition at line 4059 of file ArrayND.h.

4059  {
4060  if (!shapeIsKnown_)
4061  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"makeNonNegative\"");
4062  const Numeric zero = Numeric();
4063  if (dim_) {
4064  for (unsigned long i = 0; i < len_; ++i)
4066  data_[i] = zero;
4068  localData_[0] = zero;
4069  return *this;
4070  }

◆ makeUnit()

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > & npstat::ArrayND< Numeric, Len, Dim >::makeUnit ( )

This method can be used for arrays with rank of at least 2 whose length is the same in all dimensions. It puts static_cast<Numeric>(1) on the main diagonal and Numeric() everywhere else.

Definition at line 4371 of file ArrayND.h.

4371  {
4372  if (!shapeIsKnown_)
4373  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"makeUnit\"");
4374  if (dim_ < 2)
4376  "npstat::ArrayND::makeUnit method "
4377  "can not be used with arrays of rank less than 2");
4378  constFill(Numeric());
4379  unsigned long stride = 0UL;
4380  const unsigned dimlen = shape_[0];
4381  for (unsigned i = 0; i < dim_; ++i) {
4382  if (shape_[i] != dimlen)
4384  "npstat::ArrayND::makeUnit method needs "
4385  "the array span to be the same in ech dimension");
4386  stride += strides_[i];
4387  }
4388  const Numeric one(static_cast<Numeric>(1));
4389  for (unsigned i = 0; i < dimlen; ++i)
4390  data_[i * stride] = one;
4391  return *this;
4392  }

◆ marginalize() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND<Numeric, StackLen, StackDim> npstat::ArrayND< Numeric, StackLen, StackDim >::marginalize ( const ArrayND< Num2, Len2, Dim2 > &  prior,
const unsigned *  indexMap,
const unsigned  mapLen 
) const

Definition at line 1575 of file ArrayND.h.

1576  {
1577  if (!shapeIsKnown_)
1578  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"marginalize\"");
1579  if (!(prior.dim_ && prior.dim_ <= dim_))
1580  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::marginalize: incompatible argument array rank");
1581  const unsigned resultDim = dim_ - prior.dim_;
1582 
1583  // Check that the index map is reasonable
1584  if (mapLen != prior.dim_)
1585  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::marginalize: incompatible index map length");
1586  assert(indexMap);
1587  for (unsigned i = 0; i < mapLen; ++i) {
1588  const unsigned thisInd = indexMap[i];
1589  if (shape_[thisInd] != prior.shape_[i])
1591  "In npstat::ArrayND::marginalize: "
1592  "incompatible argument array dimensions");
1593  if (thisInd >= dim_)
1594  throw npstat::NpstatOutOfRange("In npstat::ArrayND::marginalize: index map entry out of range");
1595  for (unsigned j = 0; j < i; ++j)
1596  if (indexMap[j] == thisInd)
1598  "In npstat::ArrayND::marginalize: "
1599  "duplicate entry in the index map");
1600  }
1601 
1602  // Build the shape for the array of results
1603  ArrayShape newShape;
1604  newShape.reserve(resultDim);
1605  for (unsigned i = 0; i < dim_; ++i) {
1606  bool mapped = false;
1607  for (unsigned j = 0; j < mapLen; ++j)
1608  if (indexMap[j] == i) {
1609  mapped = true;
1610  break;
1611  }
1612  if (!mapped)
1613  newShape.push_back(shape_[i]);
1614  }
1615 
1616  ArrayND result(newShape);
1617  assert(result.dim_ == resultDim);
1618  bool calculated = false;
1619  if (resultDim == 0) {
1620  calculated = true;
1621  for (unsigned i = 0; i < dim_; ++i)
1622  if (indexMap[i] != i) {
1623  calculated = false;
1624  break;
1625  }
1626  if (calculated) {
1627  Numeric sum = Numeric();
1628  for (unsigned long i = 0; i < len_; ++i)
1629  sum += data_[i] * prior.data_[i];
1630  result.localData_[0] = sum;
1631  }
1632  }
1633 
1634  if (!calculated)
1635  marginalizeLoop(0U, 0UL, 0U, 0UL, prior, indexMap, result);
1636 
1637  return result;
1638  }

◆ marginalize() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND npstat::ArrayND< Numeric, StackLen, StackDim >::marginalize ( const ArrayND< Num2, Len2, Dim2 > &  prior,
const unsigned *  indexMap,
unsigned  mapLen 
) const

The intent of this method is to marginalize over a set of indices with a prior. Essentially, we are calculating integrals akin to p(y) = Integral f(y|x) g(x) dx in which all functions are represented on an equidistant grid. If needed, multiplication of the result by the grid cell size should be performed after this function. "indexMap" specifies how the indices of the prior array (which is like g(x)) are mapped into the indices of this array (which is like f(y|x)). The number of elements in the map, "mapLen", must be equal to the rank of the prior. Dimension 0 of the prior corresponds to the dimension indexMap[0] of this array, dimension 1 corresponds to indexMap[1], etc.

◆ marginalizeInnerLoop()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
Numeric npstat::ArrayND< Numeric, StackLen, StackDim >::marginalizeInnerLoop ( unsigned long  idx,
unsigned  levelPr,
unsigned long  idxPr,
const ArrayND< Num2, Len2, Dim2 > &  prior,
const unsigned *  indexMap 
) const
private

Definition at line 1512 of file ArrayND.h.

1516  {
1517  Numeric sum = Numeric();
1518  const unsigned long myStride = strides_[indexMap[levelPr]];
1519  const unsigned imax = prior.shape_[levelPr];
1520  assert(imax == shape_[indexMap[levelPr]]);
1521  if (levelPr == prior.dim_ - 1) {
1522  for (unsigned i = 0; i < imax; ++i)
1523  sum += data_[idx + i * myStride] * prior.data_[idxPr++];
1524  } else {
1525  const unsigned long priorStride = prior.strides_[levelPr];
1526  for (unsigned i = 0; i < imax; ++i) {
1527  sum += marginalizeInnerLoop(idx, levelPr + 1U, idxPr, prior, indexMap);
1528  idx += myStride;
1529  idxPr += priorStride;
1530  }
1531  }
1532  return sum;
1533  }

◆ marginalizeLoop()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
void npstat::ArrayND< Numeric, StackLen, StackDim >::marginalizeLoop ( unsigned  level,
unsigned long  idx,
unsigned  levelRes,
unsigned long  idxRes,
const ArrayND< Num2, Len2, Dim2 > &  prior,
const unsigned *  indexMap,
ArrayND< Numeric, StackLen, StackDim > &  res 
) const
private

Definition at line 1537 of file ArrayND.h.

1543  {
1544  if (level == dim_) {
1545  const Numeric res = marginalizeInnerLoop(idx, 0U, 0UL, prior, indexMap);
1546  if (result.dim_)
1547  result.data_[idxRes] = res;
1548  else
1549  result.localData_[0] = res;
1550  } else {
1551  // Check if this level is mapped or not
1552  bool mapped = false;
1553  for (unsigned i = 0; i < prior.dim_; ++i)
1554  if (level == indexMap[i]) {
1555  mapped = true;
1556  break;
1557  }
1558  if (mapped)
1559  marginalizeLoop(level + 1U, idx, levelRes, idxRes, prior, indexMap, result);
1560  else {
1561  const unsigned imax = shape_[level];
1562  const unsigned long myStride = strides_[level];
1563  const unsigned long resStride = result.strides_[levelRes];
1564  for (unsigned i = 0; i < imax; ++i) {
1565  marginalizeLoop(level + 1U, idx, levelRes + 1U, idxRes, prior, indexMap, result);
1566  idx += myStride;
1567  idxRes += resStride;
1568  }
1569  }
1570  }
1571  }

◆ max() [1/2]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric npstat::ArrayND< Numeric, Len, Dim >::max ( ) const

Maximum array element

Definition at line 4709 of file ArrayND.h.

4709  {
4710  if (!shapeIsKnown_)
4711  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"max\"");
4712  if (dim_) {
4713  Numeric maxval(data_[0]);
4714  for (unsigned long i = 1UL; i < len_; ++i)
4716  maxval = data_[i];
4717  return maxval;
4718  } else
4719  return localData_[0];
4720  }

◆ max() [2/2]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric npstat::ArrayND< Numeric, Len, Dim >::max ( unsigned *  index,
unsigned  indexLen 
) const

Maximum array element and its index

Definition at line 4723 of file ArrayND.h.

4723  {
4724  if (!shapeIsKnown_)
4725  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"max\"");
4726  if (indexLen != dim_)
4727  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::max: incompatible index length");
4728  if (dim_) {
4729  unsigned long maxind = 0UL;
4730  Numeric maxval(data_[0]);
4731  for (unsigned long i = 1UL; i < len_; ++i)
4732  if (ComplexComparesAbs<Numeric>::less(maxval, data_[i])) {
4733  maxval = data_[i];
4734  maxind = i;
4735  }
4736  convertLinearIndex(maxind, index, indexLen);
4737  return maxval;
4738  } else
4739  return localData_[0];
4740  }

◆ maxAbsDifference()

template<typename Numeric, unsigned Len, unsigned Dim>
template<unsigned Len2, unsigned Dim2>
double npstat::ArrayND< Numeric, Len, Dim >::maxAbsDifference ( const ArrayND< Numeric, Len2, Dim2 > &  r) const

Largest absolute difference with another bin-compatible array

Definition at line 3935 of file ArrayND.h.

3935  {
3936  if (!isShapeCompatible(r))
3938  "In npstat::ArrayND::maxAbsDifference: "
3939  "incompatible argument array shape");
3940  if (dim_) {
3941  double maxd = 0.0;
3942  for (unsigned long i = 0; i < len_; ++i) {
3943  const Numeric rval = r.data_[i];
3944  const double d = absDifference(data_[i], rval);
3945  if (d > maxd)
3946  maxd = d;
3947  }
3948  return maxd;
3949  } else {
3950  const Numeric rval = r.localData_[0];
3951  return absDifference(localData_[0], rval);
3952  }
3953  }

◆ maximumSpan()

template<typename Numeric , unsigned Len, unsigned Dim>
unsigned npstat::ArrayND< Numeric, Len, Dim >::maximumSpan ( ) const

Maximum span among all dimensions

Definition at line 5095 of file ArrayND.h.

5095  {
5096  unsigned maxspan = 0;
5097  for (unsigned i = 0; i < dim_; ++i)
5098  if (shape_[i] > maxspan)
5099  maxspan = shape_[i];
5100  return maxspan;
5101  }

◆ min() [1/2]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric npstat::ArrayND< Numeric, Len, Dim >::min ( ) const

Minimum array element

Definition at line 4675 of file ArrayND.h.

4675  {
4676  if (!shapeIsKnown_)
4677  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"min\"");
4678  if (dim_) {
4679  Numeric minval(data_[0]);
4680  for (unsigned long i = 1UL; i < len_; ++i)
4682  minval = data_[i];
4683  return minval;
4684  } else
4685  return localData_[0];
4686  }

◆ min() [2/2]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric npstat::ArrayND< Numeric, Len, Dim >::min ( unsigned *  index,
unsigned  indexLen 
) const

Minimum array element and its index

Definition at line 4689 of file ArrayND.h.

4689  {
4690  if (!shapeIsKnown_)
4691  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"min\"");
4692  if (indexLen != dim_)
4693  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::min: incompatible index length");
4694  if (dim_) {
4695  unsigned long minind = 0UL;
4696  Numeric minval(data_[0]);
4697  for (unsigned long i = 1UL; i < len_; ++i)
4698  if (ComplexComparesAbs<Numeric>::less(data_[i], minval)) {
4699  minval = data_[i];
4700  minind = i;
4701  }
4702  convertLinearIndex(minind, index, indexLen);
4703  return minval;
4704  } else
4705  return localData_[0];
4706  }

◆ minimumSpan()

template<typename Numeric , unsigned Len, unsigned Dim>
unsigned npstat::ArrayND< Numeric, Len, Dim >::minimumSpan ( ) const

Minimum span among all dimensions

Definition at line 5104 of file ArrayND.h.

5104  {
5105  if (dim_ == 0)
5106  return 0U;
5107  unsigned minspan = shape_[0];
5108  for (unsigned i = 1; i < dim_; ++i)
5109  if (shape_[i] < minspan)
5110  minspan = shape_[i];
5111  return minspan;
5112  }

◆ multiMirror()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
void npstat::ArrayND< Numeric, Len, Dim >::multiMirror ( ArrayND< Num2, Len2, Dim2 > *  out) const

Fill another array with all possible mirror images of this one. This other array must have twice the span in each dimension.

Definition at line 4941 of file ArrayND.h.

4941  {
4942  assert(out);
4943  if (!shapeIsKnown_)
4944  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"multiMirror\"");
4945  if (!out->shapeIsKnown_)
4946  *out = ArrayND<Num2, Len2, Dim2>(doubleShape(shape()));
4947  if (dim_ != out->dim_)
4948  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::multiMirror: incompatible argument array rank");
4949 
4950  if (dim_) {
4951  const unsigned* dshape = out->shape_;
4952  for (unsigned i = 0; i < dim_; ++i)
4953  if (dshape[i] != shape_[i] * 2U)
4955  "In npstat::ArrayND::multiMirror: "
4956  "incompatible argument array shape");
4957 
4958  if (dim_ >= CHAR_BIT * sizeof(unsigned long))
4960  "In npstat::ArrayND::multiMirror: "
4961  "array rank is too large");
4962  const unsigned long maxcycle = 1UL << dim_;
4963  std::vector<unsigned> indexbuf(dim_ * 2U);
4964  unsigned* idx = &indexbuf[0];
4965  unsigned* mirror = idx + dim_;
4966 
4967  for (unsigned long ipt = 0; ipt < len_; ++ipt) {
4968  unsigned long l = ipt;
4969  for (unsigned i = 0; i < dim_; ++i) {
4970  idx[i] = l / strides_[i];
4971  l -= (idx[i] * strides_[i]);
4972  }
4973  for (unsigned long icycle = 0UL; icycle < maxcycle; ++icycle) {
4974  for (unsigned i = 0; i < dim_; ++i) {
4975  if (icycle & (1UL << i))
4976  mirror[i] = dshape[i] - idx[i] - 1U;
4977  else
4978  mirror[i] = idx[i];
4979  }
4980  out->value(mirror, dim_) = data_[ipt];
4981  }
4982  }
4983  } else
4984  out->localData_[0] = static_cast<Num2>(localData_[0]);
4985  }

◆ multiplyBySlice()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::multiplyBySlice ( const ArrayND< Num2, Len2, Dim2 > &  slice,
const unsigned *  fixedIndices,
unsigned  nFixedIndices 
)
inline

Convenience method which multiplies the array by a scale factor which varies across the slice

Definition at line 768 of file ArrayND.h.

770  {
771  applySlice(
772  const_cast<ArrayND<Num2, Len2, Dim2>&>(slice), fixedIndices, nFixedIndices, multeq_left<Numeric, Num2>());
773  return *this;
774  }

◆ operator!=()

template<typename Numeric, unsigned Len, unsigned Dim>
template<unsigned Len2, unsigned Dim2>
bool npstat::ArrayND< Numeric, Len, Dim >::operator!= ( const ArrayND< Numeric, Len2, Dim2 > &  r) const
inline

Logical negation of operator==

Definition at line 3977 of file ArrayND.h.

3977  {
3978  return !(*this == r);
3979  }

◆ operator()() [1/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( )
inline

Fortran-style subscripting without bounds checking (of course, with indices starting at 0).

Definition at line 3227 of file ArrayND.h.

3227  {
3228  if (!shapeIsKnown_)
3229  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"operator()\"");
3230  if (dim_)
3231  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 0 array)");
3232  return localData_[0];
3233  }

◆ operator()() [2/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( ) const
inline

Definition at line 3236 of file ArrayND.h.

3236  {
3237  if (!shapeIsKnown_)
3238  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"operator()\"");
3239  if (dim_)
3240  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 0 array)");
3241  return localData_[0];
3242  }

◆ operator()() [3/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0)
inline

Definition at line 3245 of file ArrayND.h.

3245  {
3246  if (1U != dim_)
3247  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 1 array)");
3248  return data_[i];
3249  }

◆ operator()() [4/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0) const
inline

Definition at line 3252 of file ArrayND.h.

3252  {
3253  if (1U != dim_)
3254  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 1 array)");
3255  return data_[i];
3256  }

◆ operator()() [5/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1 
)
inline

Definition at line 3295 of file ArrayND.h.

3295  {
3296  if (2U != dim_)
3297  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 2 array)");
3298  return data_[i0 * strides_[0] + i1];
3299  }

◆ operator()() [6/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1 
) const
inline

Definition at line 3302 of file ArrayND.h.

3302  {
3303  if (2U != dim_)
3304  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 2 array)");
3305  return data_[i0 * strides_[0] + i1];
3306  }

◆ operator()() [7/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2 
)
inline

Definition at line 3432 of file ArrayND.h.

3432  {
3433  if (3U != dim_)
3434  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 3 array)");
3435  return data_[i0 * strides_[0] + i1 * strides_[1] + i2];
3436  }

◆ operator()() [8/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2 
) const
inline

Definition at line 3331 of file ArrayND.h.

3333  {
3334  if (3U != dim_)
3335  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 3 array)");
3336  return data_[i0 * strides_[0] + i1 * strides_[1] + i2];
3337  }

◆ operator()() [9/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3 
)
inline

Definition at line 3439 of file ArrayND.h.

3442  {
3443  if (4U != dim_)
3444  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 4 array)");
3445  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3];
3446  }

◆ operator()() [10/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3 
) const
inline

Definition at line 3340 of file ArrayND.h.

3343  {
3344  if (4U != dim_)
3345  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 4 array)");
3346  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3];
3347  }

◆ operator()() [11/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4 
)
inline

Definition at line 3449 of file ArrayND.h.

3450  {
3451  if (5U != dim_)
3452  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 5 array)");
3453  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4];
3454  }

◆ operator()() [12/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4 
) const
inline

Definition at line 3350 of file ArrayND.h.

3351  {
3352  if (5U != dim_)
3353  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 5 array)");
3354  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4];
3355  }

◆ operator()() [13/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5 
)
inline

Definition at line 3457 of file ArrayND.h.

3462  {
3463  if (6U != dim_)
3464  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 6 array)");
3465  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] + i5];
3466  }

◆ operator()() [14/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5 
) const
inline

Definition at line 3358 of file ArrayND.h.

3363  {
3364  if (6U != dim_)
3365  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 6 array)");
3366  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] + i5];
3367  }

◆ operator()() [15/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6 
)
inline

Definition at line 3469 of file ArrayND.h.

3475  {
3476  if (7U != dim_)
3477  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 7 array)");
3478  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3479  i5 * strides_[5] + i6];
3480  }

◆ operator()() [16/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6 
) const
inline

Definition at line 3370 of file ArrayND.h.

3376  {
3377  if (7U != dim_)
3378  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 7 array)");
3379  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3380  i5 * strides_[5] + i6];
3381  }

◆ operator()() [17/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7 
)
inline

Definition at line 3483 of file ArrayND.h.

3490  {
3491  if (8U != dim_)
3492  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 8 array)");
3493  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3494  i5 * strides_[5] + i6 * strides_[6] + i7];
3495  }

◆ operator()() [18/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7 
) const
inline

Definition at line 3384 of file ArrayND.h.

3391  {
3392  if (8U != dim_)
3393  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 8 array)");
3394  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3395  i5 * strides_[5] + i6 * strides_[6] + i7];
3396  }

◆ operator()() [19/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7,
unsigned  i8 
)
inline

Definition at line 3498 of file ArrayND.h.

3506  {
3507  if (9U != dim_)
3508  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 9 array)");
3509  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3510  i5 * strides_[5] + i6 * strides_[6] + i7 * strides_[7] + i8];
3511  }

◆ operator()() [20/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7,
unsigned  i8 
) const
inline

Definition at line 3399 of file ArrayND.h.

3407  {
3408  if (9U != dim_)
3409  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 9 array)");
3410  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3411  i5 * strides_[5] + i6 * strides_[6] + i7 * strides_[7] + i8];
3412  }

◆ operator()() [21/22]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7,
unsigned  i8,
unsigned  i9 
)
inline

Definition at line 3514 of file ArrayND.h.

3523  {
3524  if (10U != dim_)
3525  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 10 array)");
3526  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3527  i5 * strides_[5] + i6 * strides_[6] + i7 * strides_[7] + i8 * strides_[8] + i9];
3528  }

◆ operator()() [22/22]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::operator() ( unsigned  i0,
unsigned  i1,
unsigned  i2,
unsigned  i3,
unsigned  i4,
unsigned  i5,
unsigned  i6,
unsigned  i7,
unsigned  i8,
unsigned  i9 
) const
inline

Definition at line 3415 of file ArrayND.h.

3424  {
3425  if (10U != dim_)
3426  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::operator(): wrong # of args (not rank 10 array)");
3427  return data_[i0 * strides_[0] + i1 * strides_[1] + i2 * strides_[2] + i3 * strides_[3] + i4 * strides_[4] +
3428  i5 * strides_[5] + i6 * strides_[6] + i7 * strides_[7] + i8 * strides_[8] + i9];
3429  }

◆ operator*() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND npstat::ArrayND< Numeric, StackLen, StackDim >::operator* ( const Num2 &  r) const

multiplication by a scalar

◆ operator*() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND<Numeric, Len, Dim> npstat::ArrayND< Numeric, StackLen, StackDim >::operator* ( const Num2 &  r) const

Definition at line 3983 of file ArrayND.h.

3983  {
3984  if (!shapeIsKnown_)
3985  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"operator*\"");
3986  ArrayND<Numeric, Len, Dim> result(shape_, dim_);
3987  for (unsigned long i = 0; i < len_; ++i)
3988  result.data_[i] = data_[i] * r;
3989  return result;
3990  }

◆ operator*=() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::operator*= ( const Num2 &  r)

In-place operators. Note that these work faster than the binary versions, i.e., A += B is much faster than A = A + B.

◆ operator*=() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::operator*= ( const Num2 &  r)

Definition at line 4050 of file ArrayND.h.

4050  {
4051  if (!shapeIsKnown_)
4052  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"operator*=\"");
4053  for (unsigned long i = 0; i < len_; ++i)
4054  data_[i] *= r;
4055  return *this;
4056  }

◆ operator+() [1/3]

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > npstat::ArrayND< Numeric, Len, Dim >::operator+ ( ) const
inline

operator+ returns a copy of this array

Definition at line 4032 of file ArrayND.h.

4032  {
4033  if (!shapeIsKnown_)
4034  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"operator+\"");
4035  return *this;
4036  }

◆ operator+() [2/3]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<unsigned Len2, unsigned Dim2>
ArrayND npstat::ArrayND< Numeric, StackLen, StackDim >::operator+ ( const ArrayND< Numeric, Len2, Dim2 > &  r) const

addition of two arrays

◆ operator+() [3/3]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<unsigned Len2, unsigned Dim2>
ArrayND<Numeric, Len, Dim> npstat::ArrayND< Numeric, StackLen, StackDim >::operator+ ( const ArrayND< Numeric, Len2, Dim2 > &  r) const

Definition at line 4007 of file ArrayND.h.

4007  {
4008  if (!isShapeCompatible(r))
4010  "In npstat::ArrayND::operator+: "
4011  "incompatible argument array shape");
4012  ArrayND<Numeric, Len, Dim> result(shape_, dim_);
4013  for (unsigned long i = 0; i < len_; ++i)
4014  result.data_[i] = data_[i] + r.data_[i];
4015  return result;
4016  }

◆ operator+=() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::operator+= ( const ArrayND< Num2, Len2, Dim2 > &  r)

◆ operator+=() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::operator+= ( const ArrayND< Num2, Len2, Dim2 > &  r)

Definition at line 4176 of file ArrayND.h.

4176  {
4177  if (!isShapeCompatible(r))
4179  "In npstat::ArrayND::operator+=: "
4180  "incompatible argument array shape");
4181  for (unsigned long i = 0; i < len_; ++i)
4182  data_[i] += r.data_[i];
4183  return *this;
4184  }

◆ operator-() [1/3]

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > npstat::ArrayND< Numeric, Len, Dim >::operator- ( ) const

operator- applies the unary minus operator to every element

Definition at line 4039 of file ArrayND.h.

4039  {
4040  if (!shapeIsKnown_)
4041  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"operator-\"");
4042  ArrayND<Numeric, Len, Dim> result(shape_, dim_);
4043  for (unsigned long i = 0; i < len_; ++i)
4044  result.data_[i] = -data_[i];
4045  return result;
4046  }

◆ operator-() [2/3]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<unsigned Len2, unsigned Dim2>
ArrayND npstat::ArrayND< Numeric, StackLen, StackDim >::operator- ( const ArrayND< Numeric, Len2, Dim2 > &  r) const

subtraction of two arrays

◆ operator-() [3/3]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<unsigned Len2, unsigned Dim2>
ArrayND<Numeric, Len, Dim> npstat::ArrayND< Numeric, StackLen, StackDim >::operator- ( const ArrayND< Numeric, Len2, Dim2 > &  r) const

Definition at line 4020 of file ArrayND.h.

4020  {
4021  if (!isShapeCompatible(r))
4023  "In npstat::ArrayND::operator-: "
4024  "incompatible argument array shape");
4025  ArrayND<Numeric, Len, Dim> result(shape_, dim_);
4026  for (unsigned long i = 0; i < len_; ++i)
4027  result.data_[i] = data_[i] - r.data_[i];
4028  return result;
4029  }

◆ operator-=() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::operator-= ( const ArrayND< Num2, Len2, Dim2 > &  r)

◆ operator-=() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::operator-= ( const ArrayND< Num2, Len2, Dim2 > &  r)

Definition at line 4200 of file ArrayND.h.

4200  {
4201  if (!isShapeCompatible(r))
4203  "In npstat::ArrayND::operator-=: "
4204  "incompatible argument array shape");
4205  for (unsigned long i = 0; i < len_; ++i)
4206  data_[i] -= r.data_[i];
4207  return *this;
4208  }

◆ operator/() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND npstat::ArrayND< Numeric, StackLen, StackDim >::operator/ ( const Num2 &  r) const

division by a scalar

◆ operator/() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND<Numeric, Len, Dim> npstat::ArrayND< Numeric, StackLen, StackDim >::operator/ ( const Num2 &  r) const

Definition at line 3994 of file ArrayND.h.

3994  {
3995  if (!shapeIsKnown_)
3996  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"operator/\"");
3997  if (r == Num2())
3998  throw npstat::NpstatRuntimeError("In npstat::ArrayND::operator/: division by zero");
3999  ArrayND<Numeric, Len, Dim> result(shape_, dim_);
4000  for (unsigned long i = 0; i < len_; ++i)
4001  result.data_[i] = data_[i] / r;
4002  return result;
4003  }

◆ operator/=() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::operator/= ( const Num2 &  r)

◆ operator/=() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::operator/= ( const Num2 &  r)

Definition at line 4164 of file ArrayND.h.

4164  {
4165  if (!shapeIsKnown_)
4166  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"operator/=\"");
4167  if (r == Num2())
4168  throw npstat::NpstatRuntimeError("In npstat::ArrayND::operator/=: division by zero");
4169  for (unsigned long i = 0; i < len_; ++i)
4170  data_[i] /= r;
4171  return *this;
4172  }

◆ operator=() [1/3]

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > & npstat::ArrayND< Numeric, Len, Dim >::operator= ( const ArrayND< Numeric, StackLen, StackDim > &  r)

Assignment operator. The shape of the array on the right must be compatible with the shape of the array on the left. The only exception is when the array on the left has no shape at all (i.e., it was created by the default constructor or its "uninitialize" method was called). In this case the array on the left will assume the shape of the array on the right.

Definition at line 2914 of file ArrayND.h.

2914  {
2915  if (this == &r)
2916  return *this;
2917  if (shapeIsKnown_) {
2918  if (!r.shapeIsKnown_)
2920  "In npstat::ArrayND assignment operator: "
2921  "uninitialized argument array");
2922  if (!isShapeCompatible(r))
2924  "In npstat::ArrayND assignment operator: "
2925  "incompatible argument array shape");
2926  if (dim_)
2927  copyBuffer(data_, r.data_, len_);
2928  else
2929  localData_[0] = r.localData_[0];
2930  } else {
2931  // This object is uninitialized. If the object on the
2932  // right is itself initialized, make an in-place copy.
2933  if (r.shapeIsKnown_)
2934  new (this) ArrayND(r);
2935  }
2936  return *this;
2937  }

◆ operator=() [2/3]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::operator= ( const ArrayND< Num2, Len2, Dim2 > &  )

Converting assignment operator

◆ operator=() [3/3]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::operator= ( const ArrayND< Num2, Len2, Dim2 > &  r)

Definition at line 2941 of file ArrayND.h.

2941  {
2942  if ((void*)this == (void*)(&r))
2943  return *this;
2944  if (shapeIsKnown_) {
2945  if (!r.shapeIsKnown_)
2947  "In npstat::ArrayND assignment operator: "
2948  "uninitialized argument array");
2949  if (!isShapeCompatible(r))
2951  "In npstat::ArrayND assignment operator: "
2952  "incompatible argument array shape");
2953  if (dim_)
2954  copyBuffer(data_, r.data_, len_);
2955  else
2956  localData_[0] = static_cast<Numeric>(r.localData_[0]);
2957  } else {
2958  // This object is uninitialized. If the object on the
2959  // right is itself initialized, make an in-place copy.
2960  if (r.shapeIsKnown_)
2961  new (this) ArrayND(r);
2962  }
2963  return *this;
2964  }

◆ operator==()

template<typename Numeric, unsigned Len, unsigned Dim>
template<unsigned Len2, unsigned Dim2>
bool npstat::ArrayND< Numeric, Len, Dim >::operator== ( const ArrayND< Numeric, Len2, Dim2 > &  r) const

Compare two arrays for equality

Definition at line 3957 of file ArrayND.h.

3957  {
3958  if (shapeIsKnown_ != r.shapeIsKnown_)
3959  return false;
3960  if (r.dim_ != dim_)
3961  return false;
3962  if (r.len_ != len_)
3963  return false;
3964  for (unsigned i = 0; i < dim_; ++i)
3965  if (shape_[i] != r.shape_[i])
3966  return false;
3967  for (unsigned i = 0; i < dim_; ++i)
3968  assert(strides_[i] == r.strides_[i]);
3969  for (unsigned long j = 0; j < len_; ++j)
3970  if (data_[j] != r.data_[j])
3971  return false;
3972  return true;
3973  }

◆ outer() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND npstat::ArrayND< Numeric, StackLen, StackDim >::outer ( const ArrayND< Num2, Len2, Dim2 > &  r) const

Outer product as a method (see also the outer product constructor)

◆ outer() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
ArrayND<Numeric, Len, Dim> npstat::ArrayND< Numeric, StackLen, StackDim >::outer ( const ArrayND< Num2, Len2, Dim2 > &  r) const

Definition at line 4551 of file ArrayND.h.

4551  {
4552  return ArrayND<Numeric, Len, Dim>(*this, r);
4553  }

◆ outerProductLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num1 , unsigned Len1, unsigned Dim1, typename Num2 , unsigned Len2, unsigned Dim2>
void npstat::ArrayND< Numeric, Len, Dim >::outerProductLoop ( unsigned  level,
unsigned long  idx0,
unsigned long  idx1,
unsigned long  idx2,
const ArrayND< Num1, Len1, Dim1 > &  a1,
const ArrayND< Num2, Len2, Dim2 > &  a2 
)
private

Definition at line 2845 of file ArrayND.h.

2850  {
2851  const unsigned imax = shape_[level];
2852  if (level == dim_ - 1) {
2853  for (unsigned i = 0; i < imax; ++i)
2854  data_[idx0 + i] = a1.data_[idx1] * a2.data_[idx2 + i];
2855  } else {
2856  for (unsigned i = 0; i < imax; ++i) {
2857  outerProductLoop(level + 1, idx0, idx1, idx2, a1, a2);
2858  idx0 += strides_[level];
2859  if (level < a1.dim_)
2860  idx1 += a1.strides_[level];
2861  else
2862  idx2 += a2.strides_[level - a1.dim_];
2863  }
2864  }
2865  }

◆ processSubrange()

template<typename Numeric, unsigned Len, unsigned StackDim>
template<typename Num2 , typename Integer >
void npstat::ArrayND< Numeric, Len, StackDim >::processSubrange ( AbsArrayProjector< Numeric, Num2 > &  f,
const BoxND< Integer > &  subrange 
) const

This method runs over a subrange of the array and calls the argument functor on every point. This method will not call "clear" or "result" functions of the argument functor.

Definition at line 2447 of file ArrayND.h.

2448  {
2449  if (!shapeIsKnown_)
2450  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"processSubrange\"");
2451  if (!dim_)
2453  "npstat::ArrayND::processSubrange method "
2454  "can not be used with array of 0 rank");
2455  if (dim_ != subrange.dim())
2456  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::processSubrange: incompatible subrange rank");
2457  unsigned ibuf[StackDim];
2458  unsigned* buf = makeBuffer(dim_, ibuf, StackDim);
2459  for (unsigned i = 0; i < dim_; ++i)
2460  buf[i] = 0U;
2461  processSubrangeLoop(0U, 0UL, buf, f, subrange);
2462  destroyBuffer(buf, ibuf);
2463  }

◆ processSubrangeLoop()

template<typename Numeric, unsigned Len, unsigned Dim>
template<typename Num2 , typename Integer >
void npstat::ArrayND< Numeric, Len, Dim >::processSubrangeLoop ( unsigned  level,
unsigned long  idx0,
unsigned *  currentIndex,
AbsArrayProjector< Numeric, Num2 > &  f,
const BoxND< Integer > &  subrange 
) const
private

Definition at line 2408 of file ArrayND.h.

2412  {
2413  // Deal with possible negative limits first
2414  const Interval<Integer>& levelRange(subrange[level]);
2415  long long int iminl = static_cast<long long int>(levelRange.min());
2416  if (iminl < 0LL)
2417  iminl = 0LL;
2418  long long int imaxl = static_cast<long long int>(levelRange.max());
2419  if (imaxl < 0LL)
2420  imaxl = 0LL;
2421 
2422  // Now deal with possible out-of-range limits
2423  const unsigned imin = static_cast<unsigned>(iminl);
2424  unsigned imax = static_cast<unsigned>(imaxl);
2425  if (imax > shape_[level])
2426  imax = shape_[level];
2427 
2428  if (level == dim_ - 1) {
2429  idx0 += imin;
2430  for (unsigned i = imin; i < imax; ++i, ++idx0) {
2431  currentIndex[level] = i;
2432  f.process(currentIndex, dim_, idx0, data_[idx0]);
2433  }
2434  } else {
2435  const unsigned long stride = strides_[level];
2436  idx0 += imin * stride;
2437  for (unsigned i = imin; i < imax; ++i) {
2438  currentIndex[level] = i;
2439  processSubrangeLoop(level + 1U, idx0, currentIndex, f, subrange);
2440  idx0 += stride;
2441  }
2442  }
2443  }

◆ project() [1/2]

template<typename Numeric, unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void npstat::ArrayND< Numeric, StackLen, StackDim >::project ( ArrayND< Num2, Len2, Dim2 > *  projection,
AbsArrayProjector< Numeric, Num3 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices 
) const

This method fills a projection. The array to which "projection" argument points should normally be created by the slicing constructor using this array as an argument. "projectedIndices" should be the same as "indices" specified during the slice creation.

Definition at line 2104 of file ArrayND.h.

2107  {
2108  assert(projection);
2109  verifyProjectionCompatibility(*projection, projectedIndices, nProjectedIndices);
2110  unsigned ibuf[StackDim];
2111  unsigned* buf = makeBuffer(dim_, ibuf, StackDim);
2112  for (unsigned i = 0; i < dim_; ++i)
2113  buf[i] = 0U;
2114  projectLoop(0U,
2115  0UL,
2116  0U,
2117  0UL,
2118  buf,
2119  projection,
2120  projector,
2121  projectedIndices,
2122  nProjectedIndices,
2123  scast_assign_left<Num2, Num3>());
2124  destroyBuffer(buf, ibuf);
2125  }

◆ project() [2/2]

template<typename Numeric, unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void npstat::ArrayND< Numeric, StackLen, StackDim >::project ( ArrayND< Num2, Len2, Dim2 > *  projection,
AbsVisitor< Numeric, Num3 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices 
) const

Definition at line 2245 of file ArrayND.h.

2248  {
2249  assert(projection);
2250  verifyProjectionCompatibility(*projection, projectedIndices, nProjectedIndices);
2251  projectLoop2(
2252  0U, 0UL, 0U, 0UL, projection, projector, projectedIndices, nProjectedIndices, scast_assign_left<Num2, Num3>());
2253  }

◆ projectInnerLoop()

template<typename Numeric, unsigned StackLen, unsigned StackDim>
template<typename Num2 >
void npstat::ArrayND< Numeric, StackLen, StackDim >::projectInnerLoop ( unsigned  level,
unsigned long  idx0,
unsigned *  currentIndex,
AbsArrayProjector< Numeric, Num2 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices 
) const
private

Definition at line 1970 of file ArrayND.h.

1975  {
1976  // level : dimension number among indices which are being iterated
1977  const unsigned idx = projectedIndices[level];
1978  const unsigned imax = shape_[idx];
1979  const unsigned long stride = strides_[idx];
1980  const bool last = (level == nProjectedIndices - 1);
1981 
1982  for (unsigned i = 0; i < imax; ++i) {
1983  currentIndex[idx] = i;
1984  if (last)
1985  projector.process(currentIndex, dim_, idx0, data_[idx0]);
1986  else
1987  projectInnerLoop(level + 1, idx0, currentIndex, projector, projectedIndices, nProjectedIndices);
1988  idx0 += stride;
1989  }
1990  }

◆ projectInnerLoop2()

template<typename Numeric, unsigned StackLen, unsigned StackDim>
template<typename Num2 >
void npstat::ArrayND< Numeric, StackLen, StackDim >::projectInnerLoop2 ( unsigned  level,
unsigned long  idx0,
AbsVisitor< Numeric, Num2 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices 
) const
private

Definition at line 2179 of file ArrayND.h.

2183  {
2184  const unsigned idx = projectedIndices[level];
2185  const unsigned imax = shape_[idx];
2186  const unsigned long stride = strides_[idx];
2187  const bool last = (level == nProjectedIndices - 1);
2188 
2189  for (unsigned i = 0; i < imax; ++i) {
2190  if (last)
2191  projector.process(data_[idx0 + i * stride]);
2192  else
2193  projectInnerLoop2(level + 1, idx0 + i * stride, projector, projectedIndices, nProjectedIndices);
2194  }
2195  }

◆ projectLoop()

template<typename Numeric, unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 , class Op >
void npstat::ArrayND< Numeric, StackLen, StackDim >::projectLoop ( unsigned  level,
unsigned long  idx0,
unsigned  level1,
unsigned long  idx1,
unsigned *  currentIndex,
ArrayND< Num2, Len2, Dim2 > *  projection,
AbsArrayProjector< Numeric, Num3 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices,
Op  fcn 
) const
private

Definition at line 1994 of file ArrayND.h.

2003  {
2004  // level : dimension number in this array
2005  // level1 : dimension number in the projection
2006  // idx0 : linear index in this array
2007  // idx1 : linear index in the projection
2008  // currentIndex : cycled over in this loop with the exception of the
2009  // dimensions which are iterated over to build the
2010  // projection
2011  if (level == dim_) {
2012  assert(level1 == projection->dim_);
2013  projector.clear();
2014  projectInnerLoop(0U, idx0, currentIndex, projector, projectedIndices, nProjectedIndices);
2015  if (projection->dim_)
2016  fcn(projection->data_[idx1], projector.result());
2017  else
2018  fcn(projection->localData_[0], projector.result());
2019  } else {
2020  bool iterated = false;
2021  for (unsigned j = 0; j < nProjectedIndices; ++j)
2022  if (projectedIndices[j] == level) {
2023  iterated = true;
2024  break;
2025  }
2026  if (iterated) {
2027  // This index will be iterated over inside "projectInnerLoop"
2028  projectLoop(
2029  level + 1, idx0, level1, idx1, currentIndex, projection, projector, projectedIndices, nProjectedIndices, fcn);
2030  } else {
2031  const unsigned imax = shape_[level];
2032  const unsigned long stride = strides_[level];
2033  // We will not be able to get here if projection->dim_ is 0.
2034  // Therefore, it is safe to access projection->strides_.
2035  const unsigned long stride2 = projection->strides_[level1];
2036  for (unsigned i = 0; i < imax; ++i) {
2037  currentIndex[level] = i;
2038  projectLoop(level + 1,
2039  idx0 + i * stride,
2040  level1 + 1,
2041  idx1 + i * stride2,
2042  currentIndex,
2043  projection,
2044  projector,
2045  projectedIndices,
2046  nProjectedIndices,
2047  fcn);
2048  }
2049  }
2050  }
2051  }

◆ projectLoop2()

template<typename Numeric, unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 , class Op >
void npstat::ArrayND< Numeric, StackLen, StackDim >::projectLoop2 ( unsigned  level,
unsigned long  idx0,
unsigned  level1,
unsigned long  idx1,
ArrayND< Num2, Len2, Dim2 > *  projection,
AbsVisitor< Numeric, Num3 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices,
Op  fcn 
) const
private

Definition at line 2199 of file ArrayND.h.

2207  {
2208  if (level == dim_) {
2209  assert(level1 == projection->dim_);
2210  projector.clear();
2211  projectInnerLoop2(0U, idx0, projector, projectedIndices, nProjectedIndices);
2212  if (projection->dim_)
2213  fcn(projection->data_[idx1], projector.result());
2214  else
2215  fcn(projection->localData_[0], projector.result());
2216  } else {
2217  bool fixed = false;
2218  for (unsigned j = 0; j < nProjectedIndices; ++j)
2219  if (projectedIndices[j] == level) {
2220  fixed = true;
2221  break;
2222  }
2223  if (fixed) {
2224  projectLoop2(level + 1, idx0, level1, idx1, projection, projector, projectedIndices, nProjectedIndices, fcn);
2225  } else {
2226  const unsigned imax = shape_[level];
2227  const unsigned long stride = strides_[level];
2228  const unsigned long stride2 = projection->strides_[level1];
2229  for (unsigned i = 0; i < imax; ++i)
2230  projectLoop2(level + 1,
2231  idx0 + i * stride,
2232  level1 + 1,
2233  idx1 + i * stride2,
2234  projection,
2235  projector,
2236  projectedIndices,
2237  nProjectedIndices,
2238  fcn);
2239  }
2240  }
2241  }

◆ rank()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
unsigned npstat::ArrayND< Numeric, StackLen, StackDim >::rank ( ) const
inline

The number of array dimensions

Definition at line 242 of file ArrayND.h.

242 { return dim_; }

Referenced by npstat::LinInterpolatedTableND< Numeric, Axis >::invert1DResponse(), npstat::Private::lind_invert1DSlice(), and npstat::rescanArray().

◆ restore()

template<typename Numeric , unsigned Len, unsigned Dim>
void npstat::ArrayND< Numeric, Len, Dim >::restore ( const gs::ClassId &  id,
std::istream &  in,
ArrayND< Numeric, StackLen, StackDim > *  array 
)
static

Definition at line 5386 of file ArrayND.h.

5386  {
5387  static const gs::ClassId current(gs::ClassId::makeId<ArrayND<Numeric, Len, Dim> >());
5388  current.ensureSameId(id);
5389 
5390  ArrayShape rshape;
5391  gs::read_pod_vector(in, &rshape);
5392  if (in.fail())
5393  throw gs::IOReadFailure("In npstat::ArrayND::restore: input stream failure (checkpoint 0)");
5394 
5395  assert(array);
5396  array->uninitialize();
5397  array->dim_ = rshape.size();
5398  array->shapeIsKnown_ = true;
5399  array->len_ = 1UL;
5400  if (array->dim_) {
5401  array->shape_ = makeBuffer(array->dim_, array->localShape_, Dim);
5402  for (unsigned i = 0; i < array->dim_; ++i) {
5403  array->shape_[i] = rshape[i];
5404  assert(array->shape_[i]);
5405  array->len_ *= array->shape_[i];
5406  }
5407  array->buildStrides();
5408  array->data_ = makeBuffer(array->len_, array->localData_, Len);
5409  gs::read_array(in, array->data_, array->len_);
5410  } else
5411  gs::restore_item(in, array->localData_, false);
5412  if (in.fail())
5413  throw gs::IOReadFailure("In npstat::ArrayND::restore: input stream failure (checkpoint 1)");
5414  }

Referenced by npstat::LinInterpolatedTableND< Numeric, Axis >::read(), and npstat::HistoND< Numeric, Axis >::read().

◆ rotate()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
void npstat::ArrayND< Numeric, Len, Dim >::rotate ( const unsigned *  shifts,
unsigned  lenShifts,
ArrayND< Num2, Len2, Dim2 > *  rotated 
) const

Rotation. Place the result into another array. The elements with indices 0 in the current array will become elements with indices "shifts" in the rotated array.

Definition at line 4989 of file ArrayND.h.

4991  {
4992  assert(rotated);
4993  if (!shapeIsKnown_)
4994  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"rotate\"");
4995  // Can't rotate into itself -- it will be a mess
4996  if ((void*)rotated == (void*)this)
4997  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::rotate: can not rotate array into itself");
4998  if (!rotated->shapeIsKnown_)
4999  *rotated = *this;
5000  if (dim_ != rotated->dim_)
5001  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::rotate: incompatible argument array rank");
5002  if (lenShifts != dim_)
5003  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::rotate: incompatible dimensionality of shifts");
5004 
5005  if (dim_) {
5006  assert(shifts);
5007  if (dim_ > CHAR_BIT * sizeof(unsigned long))
5008  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::rotate: array rank is too large");
5009  unsigned buf[CHAR_BIT * sizeof(unsigned long)];
5010  clearBuffer(buf, dim_);
5011  (const_cast<ArrayND*>(this))
5012  ->flatCircularLoop(0U, 0UL, 0UL, buf, shape_, shifts, *rotated, scast_assign_right<Numeric, Num2>());
5013  } else
5014  rotated->localData_[0] = static_cast<Num2>(localData_[0]);
5015  }

◆ scaleBySliceInnerLoop()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , class Functor >
void npstat::ArrayND< Numeric, StackLen, StackDim >::scaleBySliceInnerLoop ( unsigned  level,
unsigned long  idx0,
Num2 &  scale,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices,
Functor  binaryFunct 
)
private

Definition at line 2281 of file ArrayND.h.

2286  {
2287  const unsigned idx = projectedIndices[level];
2288  const unsigned imax = shape_[idx];
2289  const unsigned long stride = strides_[idx];
2290 
2291  if (level == nProjectedIndices - 1) {
2292  Numeric* data = data_ + idx0;
2293  for (unsigned i = 0; i < imax; ++i)
2294  binaryFunct(data[i * stride], scale);
2295  } else
2296  for (unsigned i = 0; i < imax; ++i)
2297  scaleBySliceInnerLoop(level + 1, idx0 + i * stride, scale, projectedIndices, nProjectedIndices, binaryFunct);
2298  }

◆ scaleBySliceLoop()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, class Functor >
void npstat::ArrayND< Numeric, StackLen, StackDim >::scaleBySliceLoop ( unsigned  level,
unsigned long  idx0,
unsigned  level1,
unsigned long  idx1,
ArrayND< Num2, Len2, Dim2 > &  slice,
const unsigned *  fixedIndices,
unsigned  nFixedIndices,
Functor  binaryFunct 
)
private

Definition at line 2302 of file ArrayND.h.

2309  {
2310  if (level == dim_) {
2311  assert(level1 == slice.dim_);
2312  Num2& scaleFactor = slice.dim_ ? slice.data_[idx1] : slice.localData_[0];
2313  scaleBySliceInnerLoop(0U, idx0, scaleFactor, projectedIndices, nProjectedIndices, binaryFunct);
2314  } else {
2315  bool fixed = false;
2316  for (unsigned j = 0; j < nProjectedIndices; ++j)
2317  if (projectedIndices[j] == level) {
2318  fixed = true;
2319  break;
2320  }
2321  if (fixed) {
2322  scaleBySliceLoop(level + 1, idx0, level1, idx1, slice, projectedIndices, nProjectedIndices, binaryFunct);
2323  } else {
2324  const unsigned imax = shape_[level];
2325  const unsigned long stride = strides_[level];
2326  const unsigned long stride2 = slice.strides_[level1];
2327  for (unsigned i = 0; i < imax; ++i)
2328  scaleBySliceLoop(level + 1,
2329  idx0 + i * stride,
2330  level1 + 1,
2331  idx1 + i * stride2,
2332  slice,
2333  projectedIndices,
2334  nProjectedIndices,
2335  binaryFunct);
2336  }
2337  }
2338  }

◆ scanInPlace() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<class Functor >
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::scanInPlace ( Functor  f)

This method applies a single-argument functor to each element of the array. The result returned by the functor is ignored inside the scan. Depending on what the functor does, the array values may or may not be modified (they can be modified if the functor takes its argument via a non-const reference).

◆ scanInPlace() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<class Functor >
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::scanInPlace ( Functor  f)

Definition at line 4333 of file ArrayND.h.

4333  {
4334  if (!shapeIsKnown_)
4335  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"scanInPlace\"");
4336  for (unsigned long i = 0; i < len_; ++i)
4337  f(data_[i]);
4338  return *this;
4339  }

◆ setData() [1/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND<Numeric, Len, Dim>& npstat::ArrayND< Numeric, StackLen, StackDim >::setData ( const Num2 *  data,
const unsigned long  dataLength 
)
inline

Definition at line 2467 of file ArrayND.h.

2468  {
2469  if (!shapeIsKnown_)
2470  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"setData\"");
2471  if (dataLength != len_)
2472  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::setData: incompatible input data length");
2473  copyBuffer(data_, data, dataLength);
2474  return *this;
2475  }

◆ setData() [2/2]

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 >
ArrayND& npstat::ArrayND< Numeric, StackLen, StackDim >::setData ( const Num2 *  data,
unsigned long  dataLength 
)

This method modifies all the data in one statement

◆ shape()

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayShape npstat::ArrayND< Numeric, Len, Dim >::shape ( void  ) const
inline

Get the complete shape

Definition at line 2989 of file ArrayND.h.

2989  {
2990  if (!shapeIsKnown_)
2991  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"shape\"");
2992  return ArrayShape(shape_, shape_ + dim_);
2993  }

◆ shapeData()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
const unsigned* npstat::ArrayND< Numeric, StackLen, StackDim >::shapeData ( ) const
inline

Shape data as a C-style array

Definition at line 248 of file ArrayND.h.

248 { return shape_; }

◆ sliceShape()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
ArrayShape npstat::ArrayND< Numeric, StackLen, StackDim >::sliceShape ( const unsigned *  fixedIndices,
unsigned  nFixedIndices 
) const

Figure out the slice shape without actually making the slice

Definition at line 1733 of file ArrayND.h.

1734  {
1735  if (!shapeIsKnown_)
1736  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"sliceShape\"");
1737  if (nFixedIndices) {
1738  assert(fixedIndices);
1739  if (nFixedIndices > dim_)
1740  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::sliceShape: too many fixed indices");
1741  for (unsigned j = 0; j < nFixedIndices; ++j)
1742  if (fixedIndices[j] >= dim_)
1744  "In npstat::ArrayND::sliceShape: "
1745  "fixed index out of range");
1746  ArrayShape sh;
1747  sh.reserve(dim_ - nFixedIndices);
1748  for (unsigned i = 0; i < dim_; ++i) {
1749  bool fixed = false;
1750  for (unsigned j = 0; j < nFixedIndices; ++j)
1751  if (fixedIndices[j] == i) {
1752  fixed = true;
1753  break;
1754  }
1755  if (!fixed)
1756  sh.push_back(shape_[i]);
1757  }
1758  return sh;
1759  } else
1760  return ArrayShape(shape_, shape_ + dim_);
1761  }

◆ span()

template<typename Numeric , unsigned Len, unsigned Dim>
unsigned npstat::ArrayND< Numeric, Len, Dim >::span ( unsigned  dim) const
inline

Get the number of elements in some particular dimension

Definition at line 5088 of file ArrayND.h.

5088  {
5089  if (dim >= dim_)
5090  throw npstat::NpstatOutOfRange("In npstat::ArrayND::span: dimension number is out of range");
5091  return shape_[dim];
5092  }

Referenced by npstat::Private::ArrayMapper< Num1, Len1, Dim1, Num2, Len2, Dim2 >::ArrayMapper().

◆ strides()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
const unsigned long* npstat::ArrayND< Numeric, StackLen, StackDim >::strides ( ) const
inline

Get the strides

Definition at line 263 of file ArrayND.h.

263 { return strides_; }

◆ subtractFromProjection() [1/2]

template<typename Numeric, unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void npstat::ArrayND< Numeric, StackLen, StackDim >::subtractFromProjection ( ArrayND< Num2, Len2, Dim2 > *  projection,
AbsArrayProjector< Numeric, Num3 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices 
) const

Definition at line 2154 of file ArrayND.h.

2157  {
2158  assert(projection);
2159  verifyProjectionCompatibility(*projection, projectedIndices, nProjectedIndices);
2160  unsigned ibuf[StackDim];
2161  unsigned* buf = makeBuffer(dim_, ibuf, StackDim);
2162  for (unsigned i = 0; i < dim_; ++i)
2163  buf[i] = 0U;
2164  projectLoop(0U,
2165  0UL,
2166  0U,
2167  0UL,
2168  buf,
2169  projection,
2170  projector,
2171  projectedIndices,
2172  nProjectedIndices,
2173  scast_minuseq_left<Num2, Num3>());
2174  destroyBuffer(buf, ibuf);
2175  }

◆ subtractFromProjection() [2/2]

template<typename Numeric, unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2, typename Num3 >
void npstat::ArrayND< Numeric, StackLen, StackDim >::subtractFromProjection ( ArrayND< Num2, Len2, Dim2 > *  projection,
AbsVisitor< Numeric, Num3 > &  projector,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices 
) const

Definition at line 2269 of file ArrayND.h.

2272  {
2273  assert(projection);
2274  verifyProjectionCompatibility(*projection, projectedIndices, nProjectedIndices);
2275  projectLoop2(
2276  0U, 0UL, 0U, 0UL, projection, projector, projectedIndices, nProjectedIndices, scast_minuseq_left<Num2, Num3>());
2277  }

◆ sum()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 >
Num2 npstat::ArrayND< Numeric, Len, Dim >::sum ( ) const

Sum of all array elements which uses Num2 type as accumulator. Typically, the precision and dynamic range of Num2 should be suitably larger than the precision and dynamic range of Numeric. For example, if Numeric is float then Num2 should be double, etc.

Definition at line 4652 of file ArrayND.h.

4652  {
4653  if (!shapeIsKnown_)
4654  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"sum\"");
4655  Num2 sum = Num2();
4656  for (unsigned long i = 0; i < len_; ++i)
4657  sum += data_[i];
4658  return sum;
4659  }

◆ sumBelowLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Accumulator >
Accumulator npstat::ArrayND< Numeric, Len, Dim >::sumBelowLoop ( unsigned  level,
unsigned long  idx0,
const unsigned *  limit 
) const
private

Definition at line 4816 of file ArrayND.h.

4818  {
4819  Accumulator cdf = Accumulator();
4820  const unsigned imax = limit[level] + 1U;
4821  if (level == dim_ - 1) {
4822  Numeric* base = data_ + idx0;
4823  for (unsigned i = 0; i < imax; ++i)
4824  cdf += base[i];
4825  } else {
4826  const unsigned long stride = strides_[level];
4827  for (unsigned i = 0; i < imax; ++i, idx0 += stride)
4828  cdf += sumBelowLoop<Accumulator>(level + 1, idx0, limit);
4829  }
4830  return cdf;
4831  }

◆ sumsq()

template<typename Numeric , unsigned Len, unsigned Dim>
template<typename Num2 >
Num2 npstat::ArrayND< Numeric, Len, Dim >::sumsq ( ) const

Sum of absolute values squared which uses Num2 as accumulator. Function std::abs(Numeric) must exist.

Definition at line 4663 of file ArrayND.h.

4663  {
4664  if (!shapeIsKnown_)
4665  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"sumsq\"");
4666  Num2 sum = Num2();
4667  for (unsigned long i = 0; i < len_; ++i) {
4668  const Num2 absval = absValue(data_[i]);
4669  sum += absval * absval;
4670  }
4671  return sum;
4672  }

◆ transpose() [1/2]

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > npstat::ArrayND< Numeric, Len, Dim >::transpose ( ) const

Transpose without arguments can be invoked for 2-d arrays only

Definition at line 4744 of file ArrayND.h.

4744  {
4745  if (dim_ != 2)
4747  "npstat::ArrayND::transpose method "
4748  "can not be used with arrays of rank other than 2");
4749  unsigned newshape[2];
4750  newshape[0] = shape_[1];
4751  newshape[1] = shape_[0];
4752  ArrayND<Numeric, Len, Dim> result(newshape, dim_);
4753  const unsigned imax = shape_[0];
4754  const unsigned jmax = shape_[1];
4755  for (unsigned i = 0; i < imax; ++i)
4756  for (unsigned j = 0; j < jmax; ++j)
4757  result.data_[j * imax + i] = data_[i * jmax + j];
4758  return result;
4759  }

◆ transpose() [2/2]

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > npstat::ArrayND< Numeric, Len, Dim >::transpose ( unsigned  pos1,
unsigned  pos2 
) const

Transposed array

Definition at line 4912 of file ArrayND.h.

4912  {
4913  if (!shapeIsKnown_)
4914  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"transpose\"");
4915  if (!(pos1 < dim_ && pos2 < dim_ && pos1 != pos2))
4917  "In npstat::ArrayND::transpose: "
4918  "incompatible transposition indices");
4919  if (dim_ == 2)
4920  return transpose();
4921  else {
4922  // Construct the new shape
4923  unsigned newshapeBuf[Dim];
4924  unsigned* newshape = makeBuffer(dim_, newshapeBuf, Dim);
4925  copyBuffer(newshape, shape_, dim_);
4926  std::swap(newshape[pos1], newshape[pos2]);
4927 
4928  // Form the result array
4929  ArrayND<Numeric, Len, Dim> result(newshape, dim_);
4930 
4931  // Fill the result array
4932  transposeLoop(0, pos1, pos2, 0UL, 0UL, result);
4933 
4934  destroyBuffer(newshape, newshapeBuf);
4935  return result;
4936  }
4937  }

◆ transposeLoop()

template<typename Numeric , unsigned Len, unsigned Dim>
void npstat::ArrayND< Numeric, Len, Dim >::transposeLoop ( unsigned  level,
unsigned  pos1,
unsigned  pos2,
unsigned long  idxThis,
unsigned long  idxRes,
ArrayND< Numeric, StackLen, StackDim > &  result 
) const
private

Definition at line 4629 of file ArrayND.h.

4634  {
4635  const unsigned imax = shape_[level];
4636  const unsigned long mystride = strides_[level];
4637  const unsigned relevel = level == pos1 ? pos2 : (level == pos2 ? pos1 : level);
4638  const unsigned long restride = result.strides_[relevel];
4639  const bool ready = (level == dim_ - 1);
4640  for (unsigned i = 0; i < imax; ++i) {
4641  if (ready)
4642  result.data_[idxRes] = data_[idxThis];
4643  else
4644  transposeLoop(level + 1, pos1, pos2, idxThis, idxRes, result);
4645  idxThis += mystride;
4646  idxRes += restride;
4647  }
4648  }

◆ uninitialize()

template<typename Numeric , unsigned Len, unsigned Dim>
ArrayND< Numeric, Len, Dim > & npstat::ArrayND< Numeric, Len, Dim >::uninitialize ( )

The function which can "uninitialize" the array to the same state as produced by the default constructor. Can be applied in order to force the assignment operators to work.

Definition at line 4356 of file ArrayND.h.

4356  {
4360  localData_[0] = Numeric();
4361  data_ = localData_;
4362  strides_ = nullptr;
4363  shape_ = nullptr;
4364  len_ = 0;
4365  dim_ = 0;
4366  shapeIsKnown_ = false;
4367  return *this;
4368  }

◆ value() [1/2]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::value ( const unsigned *  index,
unsigned  indexLen 
)
inline

Element access using multidimensional array index (no bounds checking). The length of the index array must be equal to the rank of this object.

Definition at line 3091 of file ArrayND.h.

3091  {
3092  if (!shapeIsKnown_)
3093  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"value\"");
3094  if (dim != dim_)
3095  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::value: incompatible index length");
3096  if (dim) {
3097  assert(index);
3098  unsigned long idx = 0UL;
3099  for (unsigned i = 0; i < dim_; ++i)
3100  idx += index[i] * strides_[i];
3101  return data_[idx];
3102  } else
3103  return localData_[0];
3104  }

Referenced by average.Average::average().

◆ value() [2/2]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::value ( const unsigned *  index,
unsigned  indexLen 
) const
inline

Definition at line 3107 of file ArrayND.h.

3107  {
3108  if (!shapeIsKnown_)
3109  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"value\"");
3110  if (dim != dim_)
3111  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::value: incompatible index length");
3112  if (dim) {
3113  assert(index);
3114  unsigned long idx = 0UL;
3115  for (unsigned i = 0; i < dim_; ++i)
3116  idx += index[i] * strides_[i];
3117  return data_[idx];
3118  } else
3119  return localData_[0];
3120  }

Referenced by average.Average::average().

◆ valueAt() [1/2]

template<typename Numeric , unsigned Len, unsigned Dim>
Numeric & npstat::ArrayND< Numeric, Len, Dim >::valueAt ( const unsigned *  index,
unsigned  indexLen 
)
inline

Element access using multidimensional array index (with bounds checking)

Definition at line 3208 of file ArrayND.h.

3208  {
3209  if (!shapeIsKnown_)
3210  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"valueAt\"");
3211  if (dim != dim_)
3212  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::valueAt: incompatible index length");
3213  if (dim) {
3214  assert(index);
3215  unsigned long idx = 0UL;
3216  for (unsigned i = 0; i < dim_; ++i) {
3217  if (index[i] >= shape_[i])
3218  throw npstat::NpstatOutOfRange("In npstat::ArrayND::valueAt: index out of range");
3219  idx += index[i] * strides_[i];
3220  }
3221  return data_[idx];
3222  } else
3223  return localData_[0];
3224  }

◆ valueAt() [2/2]

template<typename Numeric , unsigned Len, unsigned Dim>
const Numeric & npstat::ArrayND< Numeric, Len, Dim >::valueAt ( const unsigned *  index,
unsigned  indexLen 
) const
inline

Definition at line 3189 of file ArrayND.h.

3189  {
3190  if (!shapeIsKnown_)
3191  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"valueAt\"");
3192  if (dim != dim_)
3193  throw npstat::NpstatInvalidArgument("In npstat::ArrayND::valueAt: incompatible index length");
3194  if (dim) {
3195  assert(index);
3196  unsigned long idx = 0UL;
3197  for (unsigned i = 0; i < dim_; ++i) {
3198  if (index[i] >= shape_[i])
3199  throw npstat::NpstatOutOfRange("In npstat::ArrayND::valueAt: index out of range");
3200  idx += index[i] * strides_[i];
3201  }
3202  return data_[idx];
3203  } else
3204  return localData_[0];
3205  }

◆ verifyBufferSliceCompatibility()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
unsigned long npstat::ArrayND< Numeric, StackLen, StackDim >::verifyBufferSliceCompatibility ( unsigned long  bufLen,
const unsigned *  fixedIndices,
const unsigned *  fixedIndexValues,
unsigned  nFixedIndices,
unsigned long *  sliceStrides 
) const
private

Definition at line 1822 of file ArrayND.h.

1826  {
1827  if (!(nFixedIndices && nFixedIndices <= dim_))
1829  "In npstat::ArrayND::verifyBufferSliceCompatibility: "
1830  "invalid number of fixed indices");
1831  if (!shapeIsKnown_)
1833  "Initialize npstat::ArrayND before calling "
1834  "method \"verifyBufferSliceCompatibility\"");
1835  assert(fixedIndices);
1836  assert(fixedIndexValues);
1837 
1838  for (unsigned j = 0; j < nFixedIndices; ++j)
1839  if (fixedIndices[j] >= dim_)
1841  "In npstat::ArrayND::verifyBufferSliceCompatibility: "
1842  "fixed index out of range");
1843 
1844  // Figure out slice shape. Store it, temporarily, in sliceStrides.
1845  unsigned long idx = 0UL;
1846  unsigned sliceDim = 0U;
1847  for (unsigned i = 0; i < dim_; ++i) {
1848  bool fixed = false;
1849  for (unsigned j = 0; j < nFixedIndices; ++j)
1850  if (fixedIndices[j] == i) {
1851  fixed = true;
1852  if (fixedIndexValues[j] >= shape_[i])
1854  "In npstat::ArrayND::verifyBufferSliceCompatibility:"
1855  " fixed index value out of range");
1856  idx += fixedIndexValues[j] * strides_[i];
1857  break;
1858  }
1859  if (!fixed)
1860  sliceStrides[sliceDim++] = shape_[i];
1861  }
1862  assert(sliceDim + nFixedIndices == dim_);
1863 
1864  // Convert the slice shape into slice strides
1865  unsigned long expectedBufLen = 1UL;
1866  if (sliceDim) {
1867  unsigned long shapeJ = sliceStrides[sliceDim - 1];
1868  sliceStrides[sliceDim - 1] = 1UL;
1869  for (unsigned j = sliceDim - 1; j > 0; --j) {
1870  const unsigned long nextStride = sliceStrides[j] * shapeJ;
1871  shapeJ = sliceStrides[j - 1];
1872  sliceStrides[j - 1] = nextStride;
1873  }
1874  expectedBufLen = sliceStrides[0] * shapeJ;
1875  }
1876  if (expectedBufLen != bufLen)
1878  "In npstat::ArrayND::verifyBufferSliceCompatibility: "
1879  "invalid memory buffer length");
1880 
1881  return idx;
1882  }

◆ verifyProjectionCompatibility()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
void npstat::ArrayND< Numeric, StackLen, StackDim >::verifyProjectionCompatibility ( const ArrayND< Num2, Len2, Dim2 > &  projection,
const unsigned *  projectedIndices,
unsigned  nProjectedIndices 
) const
private

Definition at line 2055 of file ArrayND.h.

2057  {
2058  if (!(nProjectedIndices && nProjectedIndices <= dim_))
2060  "In npstat::ArrayND::verifyProjectionCompatibility: "
2061  "invalid number of projected indices");
2062  if (!shapeIsKnown_)
2064  "Initialize npstat::ArrayND before calling "
2065  "method \"verifyProjectionCompatibility\"");
2066  if (!projection.shapeIsKnown_)
2068  "In npstat::ArrayND::verifyProjectionCompatibility: "
2069  "uninitialized argument array");
2070  if (projection.dim_ != dim_ - nProjectedIndices)
2072  "In npstat::ArrayND::verifyProjectionCompatibility: "
2073  "incompatible argument array rank");
2074  assert(projectedIndices);
2075 
2076  for (unsigned j = 0; j < nProjectedIndices; ++j)
2077  if (projectedIndices[j] >= dim_)
2079  "In npstat::ArrayND::verifyProjectionCompatibility: "
2080  "projected index out of range");
2081 
2082  // Check projection shape compatibility
2083  unsigned sliceDim = 0U;
2084  for (unsigned i = 0; i < dim_; ++i) {
2085  bool fixed = false;
2086  for (unsigned j = 0; j < nProjectedIndices; ++j)
2087  if (projectedIndices[j] == i) {
2088  fixed = true;
2089  break;
2090  }
2091  if (!fixed) {
2092  if (shape_[i] != projection.shape_[sliceDim])
2094  "In npstat::ArrayND::verifyProjectionCompatibility: "
2095  "incompatible argument array dimensions");
2096  ++sliceDim;
2097  }
2098  }
2099  assert(sliceDim == projection.dim_);
2100  }

◆ verifySliceCompatibility()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
template<typename Num2 , unsigned Len2, unsigned Dim2>
unsigned long npstat::ArrayND< Numeric, StackLen, StackDim >::verifySliceCompatibility ( const ArrayND< Num2, Len2, Dim2 > &  slice,
const unsigned *  fixedIndices,
const unsigned *  fixedIndexValues,
unsigned  nFixedIndices 
) const
private

Definition at line 1765 of file ArrayND.h.

1768  {
1769  if (!(nFixedIndices && nFixedIndices <= dim_))
1771  "In npstat::ArrayND::verifySliceCompatibility: "
1772  "invalid number of fixed indices");
1773  if (!shapeIsKnown_)
1775  "Initialize npstat::ArrayND before calling "
1776  "method \"verifySliceCompatibility\"");
1777  if (!slice.shapeIsKnown_)
1779  "In npstat::ArrayND::verifySliceCompatibility: "
1780  "uninitialized argument array");
1781  if (slice.dim_ != dim_ - nFixedIndices)
1783  "In npstat::ArrayND::verifySliceCompatibility: "
1784  "incompatible argument array rank");
1785  assert(fixedIndices);
1786  assert(fixedIndexValues);
1787 
1788  for (unsigned j = 0; j < nFixedIndices; ++j)
1789  if (fixedIndices[j] >= dim_)
1791  "In npstat::ArrayND::verifySliceCompatibility: "
1792  "fixed index out of range");
1793 
1794  // Check slice shape compatibility
1795  unsigned long idx = 0UL;
1796  unsigned sliceDim = 0U;
1797  for (unsigned i = 0; i < dim_; ++i) {
1798  bool fixed = false;
1799  for (unsigned j = 0; j < nFixedIndices; ++j)
1800  if (fixedIndices[j] == i) {
1801  fixed = true;
1802  if (fixedIndexValues[j] >= shape_[i])
1804  "In npstat::ArrayND::verifySliceCompatibility: "
1805  "fixed index value out of range");
1806  idx += fixedIndexValues[j] * strides_[i];
1807  break;
1808  }
1809  if (!fixed) {
1810  if (shape_[i] != slice.shape_[sliceDim])
1812  "In npstat::ArrayND::verifySliceCompatibility: "
1813  "incompatible argument array dimensions");
1814  ++sliceDim;
1815  }
1816  }
1817  assert(sliceDim == slice.dim_);
1818  return idx;
1819  }

◆ version()

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
static unsigned npstat::ArrayND< Numeric, StackLen, StackDim >::version ( )
inlinestatic

Definition at line 1044 of file ArrayND.h.

1044 { return 1; }

Referenced by validation.Sample::datasetpattern(), and validation.Sample::filename().

◆ write()

template<typename Numeric , unsigned StackLen, unsigned StackDim>
bool npstat::ArrayND< Numeric, StackLen, StackDim >::write ( std::ostream &  of) const

Definition at line 5378 of file ArrayND.h.

5378  {
5379  if (!shapeIsKnown_)
5380  throw npstat::NpstatInvalidArgument("Initialize npstat::ArrayND before calling method \"write\"");
5381  gs::write_pod_vector(os, shape());
5382  return !os.fail() && (dim_ ? gs::write_array(os, data_, len_) : gs::write_item(os, localData_[0], false));
5383  }

Friends And Related Function Documentation

◆ ArrayND

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
template<typename Num2 , unsigned Len2, unsigned Dim2>
friend class ArrayND
friend

Definition at line 50 of file ArrayND.h.

Member Data Documentation

◆ data_

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
Numeric* npstat::ArrayND< Numeric, StackLen, StackDim >::data_
private

◆ dim_

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
unsigned npstat::ArrayND< Numeric, StackLen, StackDim >::dim_
private

◆ len_

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
unsigned long npstat::ArrayND< Numeric, StackLen, StackDim >::len_
private

Definition at line 1057 of file ArrayND.h.

Referenced by npstat::ArrayND< Num1, Len1, Dim1 >::length().

◆ localData_

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
Numeric npstat::ArrayND< Numeric, StackLen, StackDim >::localData_[StackLen]
private

◆ localShape_

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
unsigned npstat::ArrayND< Numeric, StackLen, StackDim >::localShape_[StackDim]
private

Definition at line 1054 of file ArrayND.h.

◆ localStrides_

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
unsigned long npstat::ArrayND< Numeric, StackLen, StackDim >::localStrides_[StackDim]
private

Definition at line 1051 of file ArrayND.h.

◆ shape_

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
unsigned* npstat::ArrayND< Numeric, StackLen, StackDim >::shape_
private

◆ shapeIsKnown_

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
bool npstat::ArrayND< Numeric, StackLen, StackDim >::shapeIsKnown_
private

◆ strides_

template<typename Numeric, unsigned StackLen = 1U, unsigned StackDim = 10U>
unsigned long* npstat::ArrayND< Numeric, StackLen, StackDim >::strides_
private
personalPlayback.level
level
Definition: personalPlayback.py:22
npstat::ArrayND::localData_
Numeric localData_[StackLen]
Definition: ArrayND.h:1048
npstat::ArrayND::jointSliceScan
void jointSliceScan(ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, Functor binaryFunct)
Definition: ArrayND.h:1933
npstat::ArrayND::dualCircularLoop
void dualCircularLoop(unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
Definition: ArrayND.h:1392
npoints
static const int npoints
Definition: NuclearInteractionFTFSimulator.h:38
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
photonAnalyzer_cfi.rMax
rMax
Definition: photonAnalyzer_cfi.py:91
npstat::copyBuffer
void copyBuffer(T1 *dest, const T2 *source, const unsigned long len)
Definition: allocators.h:38
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
npstat::ArrayND::circularFlatLoop
void circularFlatLoop(unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
Definition: ArrayND.h:1467
alignBH_cfg.fixed
fixed
Definition: alignBH_cfg.py:54
testProducerWithPsetDescEmpty_cfi.i3
i3
Definition: testProducerWithPsetDescEmpty_cfi.py:47
mps_fire.i
i
Definition: mps_fire.py:428
SiPixelPI::one
Definition: SiPixelPayloadInspectorHelper.h:39
npstat::ArrayND::jointSliceLoop
void jointSliceLoop(unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, Num2 *sliceData, const unsigned long *sliceStrides, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, Functor binaryFunctor)
npstat::ComplexComparesFalse::less
static bool less(const T &l, const T &r)
Definition: ComplexComparesFalse.h:24
npstat::ArrayND::applySlice
void applySlice(ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, unsigned nFixedIndices, Functor binaryFunct)
Definition: ArrayND.h:2354
funct::false
false
Definition: Factorize.h:29
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
npstat::interpolate_cubic
T interpolate_cubic(const double x, const T &f0, const T &f1, const T &f2, const T &f3)
Definition: interpolate.h:44
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
npstat::ArrayND::outerProductLoop
void outerProductLoop(unsigned level, unsigned long idx0, unsigned long idx1, unsigned long idx2, const ArrayND< Num1, Len1, Dim1 > &a1, const ArrayND< Num2, Len2, Dim2 > &a2)
Definition: ArrayND.h:2845
npstat::ArrayND::jointScan
void jointScan(ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
Definition: ArrayND.h:2342
npstat::ArrayND::transpose
ArrayND transpose() const
Definition: ArrayND.h:4744
npstat::ArrayND::shape_
unsigned * shape_
Definition: ArrayND.h:1055
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
n0
int n0
Definition: AMPTWrapper.h:44
distTCMET_cfi.corner
corner
Definition: distTCMET_cfi.py:38
npstat::ArrayND::sum
Num2 sum() const
Definition: ArrayND.h:4652
npstat::ArrayND::projectLoop2
void projectLoop2(unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, ArrayND< Num2, Len2, Dim2 > *projection, AbsVisitor< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices, Op fcn) const
Definition: ArrayND.h:2199
to
cms::cuda::assert
assert(be >=bs)
npstat::ArrayND::verifyProjectionCompatibility
void verifyProjectionCompatibility(const ArrayND< Num2, Len2, Dim2 > &projection, const unsigned *projectedIndices, unsigned nProjectedIndices) const
Definition: ArrayND.h:2055
npstat::ArrayND::contractLoop
void contractLoop(unsigned thisLevel, unsigned resLevel, unsigned pos1, unsigned pos2, unsigned long idxThis, unsigned long idxRes, ArrayND &result) const
Definition: ArrayND.h:4556
mps_check.array
array
Definition: mps_check.py:216
npstat::ArrayND::linearFillLoop
void linearFillLoop(unsigned level, double s0, unsigned long idx, double shift, const double *coeffs)
Definition: ArrayND.h:4395
L1TowerCalibrationProducer_cfi.fit
fit
Definition: L1TowerCalibrationProducer_cfi.py:36
DDAxes::x
SiPixelPI::zero
Definition: SiPixelPayloadInspectorHelper.h:39
fcn
void fcn(int &, double *, double &, double *, int)
Definition: LASBarrelAlgorithm.cc:388
findQualityFiles.v
v
Definition: findQualityFiles.py:179
npstat::ArrayND::jointMemSliceScan
void jointMemSliceScan(Num2 *buffer, unsigned long bufLen, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, Functor binaryFunct)
Definition: ArrayND.h:1948
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
npstat::ArrayND::data_
Numeric * data_
Definition: ArrayND.h:1049
npstat::ComplexComparesAbs::less
static bool less(const T &l, const T &r)
Definition: ComplexComparesAbs.h:25
gs
Definition: AbsArchive.cc:45
npstat::ArrayND::verifySliceCompatibility
unsigned long verifySliceCompatibility(const ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices) const
Definition: ArrayND.h:1765
npstat::interpolate_quadratic
T interpolate_quadratic(const double x, const T &f0, const T &f1, const T &f2)
Definition: interpolate.h:33
testProducerWithPsetDescEmpty_cfi.a2
a2
Definition: testProducerWithPsetDescEmpty_cfi.py:35
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
npstat::ArrayShape
std::vector< unsigned > ArrayShape
Definition: ArrayShape.h:21
npstat::ArrayND::transposeLoop
void transposeLoop(unsigned level, unsigned pos1, unsigned pos2, unsigned long idxThis, unsigned long idxRes, ArrayND &result) const
Definition: ArrayND.h:4629
npstat::ArrayND::constFill
ArrayND & constFill(Numeric c)
Definition: ArrayND.h:4342
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
npstat::clearBuffer
void clearBuffer(T *buf, const unsigned long len)
Definition: allocators.h:86
npstat::ArrayND::marginalizeLoop
void marginalizeLoop(unsigned level, unsigned long idx, unsigned levelRes, unsigned long idxRes, const ArrayND< Num2, Len2, Dim2 > &prior, const unsigned *indexMap, ArrayND &res) const
Definition: ArrayND.h:1537
npstat::ArrayND::ArrayND
ArrayND()
Definition: ArrayND.h:2488
npstat::ArrayND::localShape_
unsigned localShape_[StackDim]
Definition: ArrayND.h:1054
dqmdumpme.last
last
Definition: dqmdumpme.py:56
npstat::absDifference
Private::AbsReturnType< T >::type absDifference(const T &v1, const T &v2)
Definition: absDifference.h:73
npstat::NpstatRuntimeError
Definition: NpstatException.h:46
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
npstat::ArrayND::data
const Numeric * data() const
Definition: ArrayND.h:236
w
const double w
Definition: UKUtility.cc:23
npstat::ArrayND::length
unsigned long length() const
Definition: ArrayND.h:233
npstat::ArrayND::functorFillLoop
void functorFillLoop(unsigned level, unsigned long idx, Functor f, unsigned *farg)
Definition: ArrayND.h:4434
npstat::ArrayND::verifyBufferSliceCompatibility
unsigned long verifyBufferSliceCompatibility(unsigned long bufLen, const unsigned *fixedIndices, const unsigned *fixedIndexValues, unsigned nFixedIndices, unsigned long *sliceStrides) const
Definition: ArrayND.h:1822
npstat::ArrayND::len_
unsigned long len_
Definition: ArrayND.h:1057
npstat::ArrayND::value
Numeric & value(const unsigned *index, unsigned indexLen)
Definition: ArrayND.h:3091
npstat::ArrayND::scaleBySliceLoop
void scaleBySliceLoop(unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, ArrayND< Num2, Len2, Dim2 > &slice, const unsigned *fixedIndices, unsigned nFixedIndices, Functor binaryFunct)
Definition: ArrayND.h:2302
npstat::NpstatInvalidArgument
Definition: NpstatException.h:38
npstat::ArrayND::marginalizeInnerLoop
Numeric marginalizeInnerLoop(unsigned long idx, unsigned levelPr, unsigned long idxPr, const ArrayND< Num2, Len2, Dim2 > &prior, const unsigned *indexMap) const
Definition: ArrayND.h:1512
npstat::ArrayND::buildStrides
void buildStrides()
Definition: ArrayND.h:2478
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
npstat::ArrayND::scaleBySliceInnerLoop
void scaleBySliceInnerLoop(unsigned level, unsigned long idx0, Num2 &scale, const unsigned *projectedIndices, unsigned nProjectedIndices, Functor binaryFunct)
Definition: ArrayND.h:2281
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
npstat::ArrayND::coordToIndex
unsigned coordToIndex(double coord, unsigned idim) const
Definition: ArrayND.h:3147
npstat::ArrayND::copyRangeLoopFunct
void copyRangeLoopFunct(unsigned level, unsigned long idx0, unsigned long idx1, const ArrayND< Num2, Len2, Dim2 > &r, const ArrayRange &range, Functor f)
Definition: ArrayND.h:2565
npstat::ArrayND::interpolateLoop
Numeric interpolateLoop(unsigned level, const double *x, const Numeric *base) const
Definition: ArrayND.h:4260
npstat::doubleShape
ArrayShape doubleShape(const ArrayShape &inputShape)
Definition: ArrayShape.cc:148
a
double a
Definition: hdecay.h:119
runTheMatrix.mapped
mapped
Definition: runTheMatrix.py:343
npstat::ArrayND::projectInnerLoop2
void projectInnerLoop2(unsigned level, unsigned long idx0, AbsVisitor< Numeric, Num2 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
Definition: ArrayND.h:2179
recoMuon::in
Definition: RecoMuonEnumerators.h:6
npstat::destroyBuffer
void destroyBuffer(T *thisBuffer, const T *stackBuffer)
Definition: allocators.h:31
npstat::ArrayND::isShapeCompatible
bool isShapeCompatible(const ArrayND< Num2, Len2, Dim2 > &r) const
Definition: ArrayND.h:2386
npstat::ArrayND::commonSubrangeLoop
void commonSubrangeLoop(unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
Definition: ArrayND.h:1359
EmbeddingLHEProducer_cfi.mirror
mirror
Definition: EmbeddingLHEProducer_cfi.py:9
tolerance
const double tolerance
Definition: HGCalGeomParameters.cc:26
npstat::ArrayND::proper_double
ProperDblFromCmpl< Numeric >::type proper_double
Definition: ArrayND.h:54
npstat::absValue
Private::AbsReturnType< T >::type absValue(const T &v1)
Definition: absDifference.h:82
callgraph.farg
farg
Definition: callgraph.py:6
npstat::ArrayND::dim_
unsigned dim_
Definition: ArrayND.h:1058
npstat::ProperDblFromCmpl::type
double type
Definition: ProperDblFromCmpl.h:20
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
npstat::ArrayND::convertLinearIndex
void convertLinearIndex(unsigned long l, unsigned *index, unsigned indexLen) const
Definition: ArrayND.h:3048
npstat::ArrayND::dotProductLoop
void dotProductLoop(unsigned level, unsigned long idx0, unsigned long idx1, unsigned long idx2, const ArrayND< Num2, Len2, Dim2 > &r, ArrayND &result) const
Definition: ArrayND.h:5019
npstat::ArrayND::shapeIsKnown_
bool shapeIsKnown_
Definition: ArrayND.h:1060
res
Definition: Electron.h:6
npstat::ArrayND::strides_
unsigned long * strides_
Definition: ArrayND.h:1052
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
npstat::NpstatDomainError
Definition: NpstatException.h:54
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
alignCSCRings.r
r
Definition: alignCSCRings.py:93
L1DTConfigBti_cff.LL
LL
Definition: L1DTConfigBti_cff.py:25
npstat::NpstatOutOfRange
Definition: NpstatException.h:30
npstat::ArrayND::shape
ArrayShape shape() const
Definition: ArrayND.h:2989
remoteMonitoring_LED_IterMethod_cfg.limit
limit
Definition: remoteMonitoring_LED_IterMethod_cfg.py:427
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
npstat::ArrayND::projectLoop
void projectLoop(unsigned level, unsigned long idx0, unsigned level1, unsigned long idx1, unsigned *currentIndex, ArrayND< Num2, Len2, Dim2 > *projection, AbsArrayProjector< Numeric, Num3 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices, Op fcn) const
Definition: ArrayND.h:1994
multiplicitycorr_cfi.scaleFactor
scaleFactor
Definition: multiplicitycorr_cfi.py:7
npstat::makeBuffer
T * makeBuffer(unsigned sizeNeeded, T *stackBuffer, unsigned sizeofStackBuffer)
Definition: allocators.h:22
npstat::ComplexComparesAbs::more
static bool more(const T &l, const T &r)
Definition: ComplexComparesAbs.h:27
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
bookConverter.prior
prior
Definition: bookConverter.py:146
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
npstat::ArrayND::flatCircularLoop
void flatCircularLoop(unsigned level, unsigned long idx0, unsigned long idx1, const unsigned *thisCorner, const unsigned *range, const unsigned *otherCorner, ArrayND< Num2, Len2, Dim2 > &other, Functor binaryFunct)
Definition: ArrayND.h:1428
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ztail.d
d
Definition: ztail.py:151
mps_fire.result
result
Definition: mps_fire.py:311
npstat::interpolate_linear
T interpolate_linear(const double x, const T &f0, const T &f1)
Definition: interpolate.h:23
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
npstat::ArrayND::projectInnerLoop
void projectInnerLoop(unsigned level, unsigned long idx0, unsigned *currentIndex, AbsArrayProjector< Numeric, Num2 > &projector, const unsigned *projectedIndices, unsigned nProjectedIndices) const
Definition: ArrayND.h:1970
newFWLiteAna.base
base
Definition: newFWLiteAna.py:92
npstat::ArrayND::processSubrangeLoop
void processSubrangeLoop(unsigned level, unsigned long idx0, unsigned *currentIndex, AbsArrayProjector< Numeric, Num2 > &f, const BoxND< Integer > &subrange) const
Definition: ArrayND.h:2408
mergeAndRegister.slice
slice
Definition: mergeAndRegister.py:121
PVValHelper::dx
Definition: PVValidationHelpers.h:48
fit
Definition: CombinedChiSquaredLikelihood.h:6
npstat::ArrayND::buildFromShapePtr
void buildFromShapePtr(const unsigned *, unsigned)
Definition: ArrayND.h:1641
npstat::ArrayND::localStrides_
unsigned long localStrides_[StackDim]
Definition: ArrayND.h:1051
Accumulator
Definition: Accumulator.h:12