Tensor

template<class T>
class zhetapi::Tensor

Public Functions

Tensor()

Default constructor.

Tensor(const Tensor&)

Homogenous (with respect to the component type) copy constructor.

Parameters

other – the reference vector (to be copied from).

template<class A>
Tensor(const Tensor<A>&)

Heterogenous (with respect to the component type) copy constructor.

Parameters

other – the reference vector (to be copied from).

Tensor(size_t, size_t*, size_t, T*, bool = true)

Full slice constructor. Makes a Tensor out of existing (previously allocated memory), and the ownership can be decided. By default, the Tensor does not gain ownership over the memory. Note that the sizes given are not checked for validity.

Parameters
  • dims – the number of dimensions to slice.

  • dim – the dimension size array.

  • size – the size of the Tensor.

  • array – the components of the Tensor.

  • slice – the slice flag. Set to true to make sure the memory is not deallocated by the resulting Tensor, and false otherwise.

__cuda_dual__ size_t size () const

Returns the size of the tensor.

Returns

the size of the tensor (number of components in the tensor).

__cuda_dual__ size_t dimensions () const

Returns the number of dimensions in the tensor.

Returns

the number of dimensions in the tensor.

__cuda_dual__ size_t dim_size (size_t) const

Returns the size of a specific dimension. Does not check bounds.

Parameters

i – the desired index.

Returns

the size of dimension i.

__cuda_dual__ size_t safe_dim_size (size_t) const

Returns the size of a specific dimension. If the index is out of bounds of the number of dimensions, then 1 is returned.

Parameters

i – the desired index.

Returns

the size of dimension i.

~Tensor()

Deconstructor.

class bad_dimensions
class dimension_mismatch