Blender V4.3
libmv::ArrayND< T, N > Class Template Reference

A multidimensional array class. More...

#include <array_nd.h>

Inherits libmv::BaseArray.

Public Types

typedef T Scalar
 
typedef Tuple< int, NIndex
 Type for the multidimensional indices.
 

Public Member Functions

 ArrayND ()
 Create an empty array.
 
 ArrayND (const Index &shape)
 Create an array with the specified shape.
 
 ArrayND (int *shape)
 Create an array with the specified shape.
 
 ArrayND (const ArrayND< T, N > &b)
 Copy constructor.
 
 ArrayND (int s0)
 
 ArrayND (int s0, int s1)
 
 ArrayND (int s0, int s1, int s2)
 
 ArrayND (T *data, int s0, int s1, int s2)
 
 ~ArrayND ()
 Destructor deletes pixel data.
 
ArrayNDoperator= (const ArrayND< T, N > &b)
 Assignation copies pixel data.
 
const IndexShapes () const
 
const IndexStrides () const
 
void Resize (const Index &new_shape)
 Create an array of shape s.
 
template<typename D >
void ResizeLike (const ArrayND< D, N > &other)
 
void Resize (const int *new_shape_array)
 Resizes the array to shape s. All data is lost.
 
void Resize (int s0)
 Resize a 1D array to length s0.
 
void Resize (int s0, int s1)
 Resize a 2D array to shape (s0,s1).
 
void resize (int rows, int cols)
 
void Resize (int s0, int s1, int s2)
 Resize a 3D array to shape (s0,s1,s2).
 
template<typename D >
void CopyFrom (const ArrayND< D, N > &other)
 
void Fill (T value)
 
void fill (T value)
 
const IndexShape () const
 Return a tuple containing the length of each axis.
 
int Shape (int axis) const
 Return the length of an axis.
 
int Stride (int axis) const
 Return the distance between neighboring elements along axis.
 
int Size () const
 Return the number of elements of the array.
 
int MemorySizeInBytes () const
 Return the total amount of memory used by the array.
 
TData ()
 Pointer to the first element of the array.
 
const TData () const
 Constant pointer to the first element of the array.
 
int Offset (const Index &index) const
 Distance between the first element and the element at position index.
 
int Offset (int i0) const
 1D specialization.
 
int Offset (int i0, int i1) const
 2D specialization.
 
int Offset (int i0, int i1, int i2) const
 3D specialization.
 
Toperator() (const Index &index)
 Return a reference to the element at position index.
 
Toperator() (int i0)
 1D specialization.
 
Toperator() (int i0, int i1)
 2D specialization.
 
Toperator() (int i0, int i1, int i2)
 3D specialization.
 
const Toperator() (const Index &index) const
 Return a constant reference to the element at position index.
 
const Toperator() (int i0) const
 1D specialization.
 
const Toperator() (int i0, int i1) const
 2D specialization.
 
const Toperator() (int i0, int i1, int i2) const
 3D specialization.
 
bool Contains (const Index &index) const
 True if index is inside array.
 
bool Contains (int i0) const
 1D specialization.
 
bool Contains (int i0, int i1) const
 2D specialization.
 
bool Contains (int i0, int i1, int i2) const
 3D specialization.
 
bool operator== (const ArrayND< T, N > &other) const
 
bool operator!= (const ArrayND< T, N > &other) const
 
ArrayND< T, Noperator* (const ArrayND< T, N > &other) const
 

Protected Attributes

Index shape_
 The number of element in each dimension.
 
Index strides_
 How to jump to neighbors in each dimension.
 
Tdata_
 Pointer to the first element of the array.
 
bool own_data_
 Flag if this Array either own or reference the data.
 

Detailed Description

template<typename T, int N>
class libmv::ArrayND< T, N >

A multidimensional array class.

Definition at line 36 of file array_nd.h.

Member Typedef Documentation

◆ Index

template<typename T , int N>
typedef Tuple<int, N> libmv::ArrayND< T, N >::Index

Type for the multidimensional indices.

Definition at line 41 of file array_nd.h.

◆ Scalar

template<typename T , int N>
typedef T libmv::ArrayND< T, N >::Scalar

Definition at line 38 of file array_nd.h.

Constructor & Destructor Documentation

◆ ArrayND() [1/8]

template<typename T , int N>
libmv::ArrayND< T, N >::ArrayND ( )
inline

Create an empty array.

Definition at line 44 of file array_nd.h.

References libmv::ArrayND< T, N >::Resize().

◆ ArrayND() [2/8]

template<typename T , int N>
libmv::ArrayND< T, N >::ArrayND ( const Index & shape)
inline

Create an array with the specified shape.

Definition at line 47 of file array_nd.h.

References libmv::ArrayND< T, N >::Resize().

◆ ArrayND() [3/8]

template<typename T , int N>
libmv::ArrayND< T, N >::ArrayND ( int * shape)
inline

Create an array with the specified shape.

Definition at line 50 of file array_nd.h.

References libmv::ArrayND< T, N >::Resize().

◆ ArrayND() [4/8]

template<typename T , int N>
libmv::ArrayND< T, N >::ArrayND ( const ArrayND< T, N > & b)
inline

Copy constructor.

Definition at line 53 of file array_nd.h.

References b, libmv::ArrayND< T, N >::Data(), and libmv::ArrayND< T, N >::ResizeLike().

◆ ArrayND() [5/8]

template<typename T , int N>
libmv::ArrayND< T, N >::ArrayND ( int s0)
inline

Definition at line 58 of file array_nd.h.

References libmv::ArrayND< T, N >::Resize().

◆ ArrayND() [6/8]

template<typename T , int N>
libmv::ArrayND< T, N >::ArrayND ( int s0,
int s1 )
inline

Definition at line 59 of file array_nd.h.

References libmv::ArrayND< T, N >::Resize().

◆ ArrayND() [7/8]

template<typename T , int N>
libmv::ArrayND< T, N >::ArrayND ( int s0,
int s1,
int s2 )
inline

Definition at line 60 of file array_nd.h.

References libmv::ArrayND< T, N >::Resize().

◆ ArrayND() [8/8]

template<typename T , int N>
libmv::ArrayND< T, N >::ArrayND ( T * data,
int s0,
int s1,
int s2 )
inline

Definition at line 64 of file array_nd.h.

References libmv::ArrayND< T, N >::Resize().

◆ ~ArrayND()

template<typename T , int N>
libmv::ArrayND< T, N >::~ArrayND ( )
inline

Destructor deletes pixel data.

Definition at line 70 of file array_nd.h.

References libmv::ArrayND< T, N >::data_, and libmv::ArrayND< T, N >::own_data_.

Member Function Documentation

◆ Contains() [1/4]

template<typename T , int N>
bool libmv::ArrayND< T, N >::Contains ( const Index & index) const
inline

True if index is inside array.

Definition at line 264 of file array_nd.h.

References N, and libmv::ArrayND< T, N >::Shape().

◆ Contains() [2/4]

template<typename T , int N>
bool libmv::ArrayND< T, N >::Contains ( int i0) const
inline

1D specialization.

Definition at line 274 of file array_nd.h.

References libmv::ArrayND< T, N >::Shape().

◆ Contains() [3/4]

template<typename T , int N>
bool libmv::ArrayND< T, N >::Contains ( int i0,
int i1 ) const
inline

2D specialization.

Definition at line 277 of file array_nd.h.

References libmv::ArrayND< T, N >::Shape().

◆ Contains() [4/4]

template<typename T , int N>
bool libmv::ArrayND< T, N >::Contains ( int i0,
int i1,
int i2 ) const
inline

3D specialization.

Definition at line 282 of file array_nd.h.

References libmv::ArrayND< T, N >::Shape().

◆ CopyFrom()

template<typename T , int N>
template<typename D >
void libmv::ArrayND< T, N >::CopyFrom ( const ArrayND< D, N > & other)
inline

◆ Data() [1/2]

◆ Data() [2/2]

template<typename T , int N>
const T * libmv::ArrayND< T, N >::Data ( ) const
inline

Constant pointer to the first element of the array.

Definition at line 190 of file array_nd.h.

References libmv::ArrayND< T, N >::data_.

◆ Fill()

template<typename T , int N>
void libmv::ArrayND< T, N >::Fill ( T value)
inline

Definition at line 152 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), and libmv::ArrayND< T, N >::Size().

◆ fill()

template<typename T , int N>
void libmv::ArrayND< T, N >::fill ( T value)
inline

Definition at line 159 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), and libmv::ArrayND< T, N >::Size().

◆ MemorySizeInBytes()

template<typename T , int N>
int libmv::ArrayND< T, N >::MemorySizeInBytes ( ) const
inline

Return the total amount of memory used by the array.

Definition at line 184 of file array_nd.h.

References libmv::ArrayND< T, N >::Size(), and T.

◆ Offset() [1/4]

◆ Offset() [2/4]

template<typename T , int N>
int libmv::ArrayND< T, N >::Offset ( int i0) const
inline

1D specialization.

Definition at line 202 of file array_nd.h.

References N, and libmv::ArrayND< T, N >::Stride().

◆ Offset() [3/4]

template<typename T , int N>
int libmv::ArrayND< T, N >::Offset ( int i0,
int i1 ) const
inline

2D specialization.

Definition at line 208 of file array_nd.h.

References N, and libmv::ArrayND< T, N >::Stride().

◆ Offset() [4/4]

template<typename T , int N>
int libmv::ArrayND< T, N >::Offset ( int i0,
int i1,
int i2 ) const
inline

3D specialization.

Definition at line 214 of file array_nd.h.

References N, and libmv::ArrayND< T, N >::Stride().

◆ operator!=()

template<typename T , int N>
bool libmv::ArrayND< T, N >::operator!= ( const ArrayND< T, N > & other) const
inline

Definition at line 302 of file array_nd.h.

◆ operator()() [1/8]

template<typename T , int N>
T & libmv::ArrayND< T, N >::operator() ( const Index & index)
inline

Return a reference to the element at position index.

Definition at line 220 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), and libmv::ArrayND< T, N >::Offset().

◆ operator()() [2/8]

template<typename T , int N>
const T & libmv::ArrayND< T, N >::operator() ( const Index & index) const
inline

Return a constant reference to the element at position index.

Definition at line 244 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), and libmv::ArrayND< T, N >::Offset().

◆ operator()() [3/8]

template<typename T , int N>
T & libmv::ArrayND< T, N >::operator() ( int i0)
inline

1D specialization.

Definition at line 226 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), and libmv::ArrayND< T, N >::Offset().

◆ operator()() [4/8]

template<typename T , int N>
const T & libmv::ArrayND< T, N >::operator() ( int i0) const
inline

1D specialization.

Definition at line 249 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), and libmv::ArrayND< T, N >::Offset().

◆ operator()() [5/8]

template<typename T , int N>
T & libmv::ArrayND< T, N >::operator() ( int i0,
int i1 )
inline

2D specialization.

Definition at line 229 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), libmv::ArrayND< T, N >::Offset(), and libmv::ArrayND< T, N >::Shape().

◆ operator()() [6/8]

template<typename T , int N>
const T & libmv::ArrayND< T, N >::operator() ( int i0,
int i1 ) const
inline

2D specialization.

Definition at line 252 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), libmv::ArrayND< T, N >::Offset(), and libmv::ArrayND< T, N >::Shape().

◆ operator()() [7/8]

template<typename T , int N>
T & libmv::ArrayND< T, N >::operator() ( int i0,
int i1,
int i2 )
inline

3D specialization.

Definition at line 236 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), libmv::ArrayND< T, N >::Offset(), and libmv::ArrayND< T, N >::Shape().

◆ operator()() [8/8]

template<typename T , int N>
const T & libmv::ArrayND< T, N >::operator() ( int i0,
int i1,
int i2 ) const
inline

3D specialization.

Definition at line 259 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), and libmv::ArrayND< T, N >::Offset().

◆ operator*()

template<typename T , int N>
ArrayND< T, N > libmv::ArrayND< T, N >::operator* ( const ArrayND< T, N > & other) const
inline

◆ operator=()

template<typename T , int N>
ArrayND & libmv::ArrayND< T, N >::operator= ( const ArrayND< T, N > & b)
inline

Assignation copies pixel data.

Definition at line 77 of file array_nd.h.

References b, libmv::ArrayND< T, N >::Data(), and libmv::ArrayND< T, N >::ResizeLike().

◆ operator==()

template<typename T , int N>
bool libmv::ArrayND< T, N >::operator== ( const ArrayND< T, N > & other) const
inline

◆ Resize() [1/5]

◆ Resize() [2/5]

template<typename T , int N>
void libmv::ArrayND< T, N >::Resize ( const int * new_shape_array)
inline

Resizes the array to shape s. All data is lost.

Definition at line 114 of file array_nd.h.

References libmv::ArrayND< T, N >::Resize().

Referenced by libmv::ArrayND< T, N >::Resize().

◆ Resize() [3/5]

template<typename T , int N>
void libmv::ArrayND< T, N >::Resize ( int s0)
inline

Resize a 1D array to length s0.

Definition at line 117 of file array_nd.h.

References N, and libmv::ArrayND< T, N >::Resize().

◆ Resize() [4/5]

template<typename T , int N>
void libmv::ArrayND< T, N >::Resize ( int s0,
int s1 )
inline

Resize a 2D array to shape (s0,s1).

Definition at line 124 of file array_nd.h.

References N, and libmv::ArrayND< T, N >::Resize().

◆ Resize() [5/5]

template<typename T , int N>
void libmv::ArrayND< T, N >::Resize ( int s0,
int s1,
int s2 )
inline

Resize a 3D array to shape (s0,s1,s2).

Definition at line 136 of file array_nd.h.

References N, and libmv::ArrayND< T, N >::Resize().

◆ resize()

template<typename T , int N>
void libmv::ArrayND< T, N >::resize ( int rows,
int cols )
inline

Definition at line 133 of file array_nd.h.

References libmv::ArrayND< T, N >::Resize().

◆ ResizeLike()

◆ Shape() [1/2]

◆ Shape() [2/2]

template<typename T , int N>
int libmv::ArrayND< T, N >::Shape ( int axis) const
inline

Return the length of an axis.

Definition at line 169 of file array_nd.h.

References libmv::ArrayND< T, N >::shape_.

◆ Shapes()

template<typename T , int N>
const Index & libmv::ArrayND< T, N >::Shapes ( ) const
inline

Definition at line 84 of file array_nd.h.

References libmv::ArrayND< T, N >::shape_.

◆ Size()

◆ Stride()

template<typename T , int N>
int libmv::ArrayND< T, N >::Stride ( int axis) const
inline

Return the distance between neighboring elements along axis.

Definition at line 172 of file array_nd.h.

References libmv::ArrayND< T, N >::strides_.

Referenced by libmv::ArrayND< T, N >::Offset(), libmv::ArrayND< T, N >::Offset(), libmv::ArrayND< T, N >::Offset(), and libmv::ArrayND< T, N >::Offset().

◆ Strides()

template<typename T , int N>
const Index & libmv::ArrayND< T, N >::Strides ( ) const
inline

Definition at line 86 of file array_nd.h.

References libmv::ArrayND< T, N >::strides_.

Member Data Documentation

◆ data_

template<typename T , int N>
T* libmv::ArrayND< T, N >::data_
protected

Pointer to the first element of the array.

Definition at line 324 of file array_nd.h.

Referenced by libmv::ArrayND< T, N >::Data(), libmv::ArrayND< T, N >::Data(), libmv::ArrayND< T, N >::Resize(), and libmv::ArrayND< T, N >::~ArrayND().

◆ own_data_

template<typename T , int N>
bool libmv::ArrayND< T, N >::own_data_
protected

Flag if this Array either own or reference the data.

Definition at line 327 of file array_nd.h.

Referenced by libmv::ArrayND< T, N >::Resize(), and libmv::ArrayND< T, N >::~ArrayND().

◆ shape_

template<typename T , int N>
Index libmv::ArrayND< T, N >::shape_
protected

◆ strides_

template<typename T , int N>
Index libmv::ArrayND< T, N >::strides_
protected

How to jump to neighbors in each dimension.

Definition at line 321 of file array_nd.h.

Referenced by libmv::ArrayND< T, N >::operator==(), libmv::ArrayND< T, N >::Resize(), libmv::ArrayND< T, N >::Stride(), and libmv::ArrayND< T, N >::Strides().


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