Blender  V3.3
Public Types | Public Member Functions | Protected Attributes | List of all members
libmv::ArrayND< T, N > Class Template Reference

A multidimensional array class. More...

#include <array_nd.h>

Inheritance diagram for libmv::ArrayND< T, N >:
libmv::BaseArray

Public Types

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

Public Member Functions

 ArrayND ()
 Create an empty array. More...
 
 ArrayND (const Index &shape)
 Create an array with the specified shape. More...
 
 ArrayND (int *shape)
 Create an array with the specified shape. More...
 
 ArrayND (const ArrayND< T, N > &b)
 Copy constructor. More...
 
 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. More...
 
ArrayNDoperator= (const ArrayND< T, N > &b)
 Assignation copies pixel data. More...
 
const IndexShapes () const
 
const IndexStrides () const
 
void Resize (const Index &new_shape)
 Create an array of shape s. More...
 
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. More...
 
void Resize (int s0)
 Resize a 1D array to length s0. More...
 
void Resize (int s0, int s1)
 Resize a 2D array to shape (s0,s1). More...
 
void resize (int rows, int cols)
 
void Resize (int s0, int s1, int s2)
 Resize a 3D array to shape (s0,s1,s2). More...
 
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. More...
 
int Shape (int axis) const
 Return the length of an axis. More...
 
int Stride (int axis) const
 Return the distance between neighboring elements along axis. More...
 
int Size () const
 Return the number of elements of the array. More...
 
int MemorySizeInBytes () const
 Return the total amount of memory used by the array. More...
 
TData ()
 Pointer to the first element of the array. More...
 
const TData () const
 Constant pointer to the first element of the array. More...
 
int Offset (const Index &index) const
 Distance between the first element and the element at position index. More...
 
int Offset (int i0) const
 1D specialization. More...
 
int Offset (int i0, int i1) const
 2D specialization. More...
 
int Offset (int i0, int i1, int i2) const
 3D specialization. More...
 
Toperator() (const Index &index)
 Return a reference to the element at position index. More...
 
Toperator() (int i0)
 1D specialization. More...
 
Toperator() (int i0, int i1)
 2D specialization. More...
 
Toperator() (int i0, int i1, int i2)
 3D specialization. More...
 
const Toperator() (const Index &index) const
 Return a constant reference to the element at position index. More...
 
const Toperator() (int i0) const
 1D specialization. More...
 
const Toperator() (int i0, int i1) const
 2D specialization. More...
 
const Toperator() (int i0, int i1, int i2) const
 3D specialization. More...
 
bool Contains (const Index &index) const
 True if index is inside array. More...
 
bool Contains (int i0) const
 1D specialization. More...
 
bool Contains (int i0, int i1) const
 2D specialization. More...
 
bool Contains (int i0, int i1, int i2) const
 3D specialization. More...
 
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. More...
 
Index strides_
 How to jump to neighbors in each dimension. More...
 
Tdata_
 Pointer to the first element of the array. More...
 
bool own_data_
 Flag if this Array either own or reference the data. More...
 

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

◆ 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 262 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 270 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 273 of file array_nd.h.

References i1, and 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 278 of file array_nd.h.

References i1, and 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]

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

◆ 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 189 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 183 of file array_nd.h.

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

◆ Offset() [1/4]

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

Distance between the first element and the element at position index.

Definition at line 192 of file array_nd.h.

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

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

◆ Offset() [2/4]

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

1D specialization.

Definition at line 200 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 206 of file array_nd.h.

References i1, 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 212 of file array_nd.h.

References i1, 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 295 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 218 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 242 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 224 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 247 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 227 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), i1, 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 250 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), i1, 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 234 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), i1, 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 257 of file array_nd.h.

References libmv::ArrayND< T, N >::Data(), i1, 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 usdtokens::b(), libmv::ArrayND< T, N >::Data(), libmv::ArrayND< T, N >::ResizeLike(), libmv::ArrayND< T, N >::Size(), and T.

◆ operator==()

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

◆ Resize() [1/5]

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

◆ 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()

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().

◆ 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().

◆ ResizeLike()

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

◆ Shape() [1/2]

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

◆ 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()

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

◆ 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::Convolve(), 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 317 of file array_nd.h.

Referenced by 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 320 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

The number of element in each dimension.

Definition at line 311 of file array_nd.h.

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

◆ strides_

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

How to jump to neighbors in each dimension.

Definition at line 314 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: