vt::astensor#
-
template<typename T>
Tensor<T, 1> vt::astensor(const std::vector<T> &vector, const Order order = Order::C)# Copy std::vector to the tensor.
- Template Parameters:
T – Data type of the tensor.
- Parameters:
vector – std::vector object.
order – Order of the tensor.
- Returns:
Tensor: The tensor from std::vector.
-
template<typename T, size_t N, xt::layout_type L>
Tensor<T, N> vt::astensor(const xt::xarray<T, L> &arr)# Copy xarray to the tensor.
- Template Parameters:
T – Data type of the tensor.
L – Layout type of the xarray.
N – Number of dimensions of the tensor.
- Parameters:
arr – The xarray object.
- Returns:
Tensor: The tensor from the xarray.
-
template<typename T>
Tensor<T, 1> vt::astensor(const T *ptr, const size_t size, const Order order = Order::C)# Copy the raw pointer to the tensor.
- Template Parameters:
T – Data type of the tensor.
- Parameters:
ptr – The raw pointer.
size – The size of the tensor.
order – Order of the tensor.
- Returns:
Tensor: The tensor from the raw pointer.
-
template<typename T, size_t N>
Tensor<T, N> vt::astensor(const T *ptr, const Shape<N> shape, const Order order = Order::C)# Copy the raw pointer to the tensor.
- Template Parameters:
T – Data type of the tensor.
N – Number of dimensions of the tensor.
- Parameters:
ptr – The raw pointer.
shape – The shape of the tensor.
order – Order of the tensor.
- Returns:
Tensor: The tensor from the raw pointer.