A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Public Member Functions | Data Fields
dim4 Class Reference
ArrayFire Classes

Generic object that represents size and shape. More...

`#include <dim4.hpp>`

## Public Member Functions
| dim4 ()
| Default constructor. Creates an invalid dim4 object.
| dim4 (dim_t first, dim_t second=1, dim_t third=1, dim_t fourth=1)
| Creates an new dim4 given a set of dimension.
| dim4 (const dim4 &other)
| Copy constructor.
| dim4 (const unsigned ndims, const dim_t *const dims)
| Constructs a dim4 object from a C array of dim_t objects.
dim_t | elements ()
| Returns the number of elements represented by this dim4.
dim_t | elements () const
| Returns the number of elements represented by this dim4.
dim_t | ndims ()
| Returns the number of axis whose values are greater than one.
dim_t | ndims () const
| Returns the number of axis whose values are greater than one.
bool | operator== (const dim4 &other) const
| Returns true if the two dim4 represent the same shape.
bool | operator!= (const dim4 &other) const
| Returns true if two dim4s store different values.
dim4 & | operator*= (const dim4 &other)
| Element-wise multiplication of the dim4 objects.
dim4 & | operator+= (const dim4 &other)
| Element-wise addition of the dim4 objects.
dim4 & | operator-= (const dim4 &other)
| Element-wise subtraction of the dim4 objects.
dim_t & | operator[] (const unsigned dim)
| Returns the reference to the element at a give index.
const dim_t & | operator[] (const unsigned dim) const
| Returns the reference to the element at a give index.
dim_t * | get ()
| Returns the underlying pointer to the dim4 object.
const dim_t * | get () const
| Returns the underlying pointer to the dim4 object.

## Data Fields
dim_t | dims [4]

## Detailed Description

Generic object that represents size and shape.

Examples
  computer_vision/matching.cpp, financial/black_scholes_options.cpp, graphics/fractal.cpp, graphics/gravity_sim.cpp, graphics/surface.cpp, helloworld/helloworld.cpp, image_processing/brain_segmentation.cpp, image_processing/morphing.cpp, image_processing/optical_flow.cpp, machine_learning/geneticalgorithm.cpp, machine_learning/rbm.cpp, pde/swe.cpp, and unified/basic.cpp.

Definition at line 25 of file dim4.hpp.

## Constructor & Destructor Documentation

## ◆ dim4() [1/4]

dim4 | ( |  | ) |

Default constructor. Creates an invalid dim4 object.

## ◆ dim4() [2/4]

dim4 | ( | dim_t | first,
|  | dim_t | second = 1,
|  | dim_t | third = 1,
|  | dim_t | fourth = 1 )

Creates an new dim4 given a set of dimension.

## ◆ dim4() [3/4]

dim4 | ( | const dim4 & | other | ) |

Copy constructor.

Parameters

  [in] | other | The dim4 that will be copied

## ◆ dim4() [4/4]

dim4 | ( | const unsigned | ndims,
|  | const dim_t *const | dims )

Constructs a dim4 object from a C array of dim_t objects.

Creates a new dim4 from a C array. If the C array is less than 4, all values past `ndims` will be assigned the value 1.

Parameters

  [in] | ndims | The number of elements in the C array. Must be less than 4
  [in] | dims | The values to assign to each element of dim4

## Member Function Documentation

## ◆ elements() [1/2]

dim_t elements | ( |  | ) |

Returns the number of elements represented by this dim4.

## ◆ elements() [2/2]

dim_t elements | ( |  | ) | const

Returns the number of elements represented by this dim4.

## ◆ get() [1/2]

dim_t * get | ( |  | ) |
| inline

Returns the underlying pointer to the dim4 object.

Definition at line 103 of file dim4.hpp.

103{ return dims; }
af::dim4::dims
dim_t dims[4]
Definition dim4.hpp:28

## ◆ get() [2/2]

const dim_t * get | ( |  | ) | const
| inline

Returns the underlying pointer to the dim4 object.

Definition at line 106 of file dim4.hpp.

106{ return dims; }

## ◆ ndims() [1/2]

dim_t ndims | ( |  | ) |

Returns the number of axis whose values are greater than one.

## ◆ ndims() [2/2]

dim_t ndims | ( |  | ) | const

Returns the number of axis whose values are greater than one.

## ◆ operator!=()

bool operator!= | ( | const dim4 & | other | ) | const

Returns true if two dim4s store different values.

## ◆ operator*=()

dim4 & operator*= | ( | const dim4 & | other | ) |

Element-wise multiplication of the dim4 objects.

## ◆ operator+=()

dim4 & operator+= | ( | const dim4 & | other | ) |

Element-wise addition of the dim4 objects.

## ◆ operator-=()

dim4 & operator-= | ( | const dim4 & | other | ) |

Element-wise subtraction of the dim4 objects.

## ◆ operator==()

bool operator== | ( | const dim4 & | other | ) | const

Returns true if the two dim4 represent the same shape.

## ◆ operator[]() [1/2]

dim_t & operator[] | ( | const unsigned | dim | ) |

Returns the reference to the element at a give index.

(Must be less than 4)

## ◆ operator[]() [2/2]

const dim_t & operator[] | ( | const unsigned | dim | ) | const

Returns the reference to the element at a give index.

(Must be less than 4)

## Field Documentation

## ◆ dims

dim_t dims[4]

Definition at line 28 of file dim4.hpp.

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

- dim4.hpp