NEML2 2.0.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Tensor creation API

Functions

static Derived empty_like (const Derived &other)
 
static Derived zeros_like (const Derived &other)
 Zero tensor like another, i.e. same batch and base shapes, same tensor options, etc.
 
static Derived ones_like (const Derived &other)
 Unit tensor like another, i.e. same batch and base shapes, same tensor options, etc.
 
static Derived full_like (const Derived &other, Real init)
 
static Derived linspace (const Derived &start, const Derived &end, Size nstep, Size dim=0)
 Create a new tensor by adding a new batch dimension with linear spacing between start and end.
 
static Derived logspace (const Derived &start, const Derived &end, Size nstep, Size dim=0, Real base=10)
 log-space equivalent of the linspace named constructor
 

Detailed Description

Function Documentation

◆ empty_like()

template<class Derived>
Derived empty_like ( const Derived & other)
staticnodiscard

Empty tensor like another, i.e. same batch and base shapes, same tensor options, etc.

◆ full_like()

template<class Derived>
Derived full_like ( const Derived & other,
Real init )
staticnodiscard

Full tensor like another, i.e. same batch and base shapes, same tensor options, etc., but filled with a different value

◆ linspace()

template<class Derived>
Derived linspace ( const Derived & start,
const Derived & end,
Size nstep,
Size dim = 0 )
staticnodiscard

Create a new tensor by adding a new batch dimension with linear spacing between start and end.

start and end must be broadcastable. The new batch dimension will be added at the user-specified dimension dim which defaults to 0.

For example, if start has shape (3, 2; 5, 5) and end has shape (3, 1; 5, 5), then

linspace(start, end, 100, 1);
static Derived linspace(const Derived &start, const Derived &end, Size nstep, Size dim=0)
Create a new tensor by adding a new batch dimension with linear spacing between start and end.
Definition TensorBaseImpl.h:102

will have shape (3, 100, 2; 5, 5), note the location of the new dimension and the broadcasting.

Parameters
startThe starting tensor
endThe ending tensor
nstepThe number of steps with even spacing along the new dimension
dimWhere to insert the new dimension
Returns
Tensor Linearly spaced tensor

◆ logspace()

template<class Derived>
Derived logspace ( const Derived & start,
const Derived & end,
Size nstep,
Size dim = 0,
Real base = 10 )
staticnodiscard

log-space equivalent of the linspace named constructor

◆ ones_like()

template<class Derived>
Derived ones_like ( const Derived & other)
staticnodiscard

Unit tensor like another, i.e. same batch and base shapes, same tensor options, etc.

◆ zeros_like()

template<class Derived>
Derived zeros_like ( const Derived & other)
staticnodiscard

Zero tensor like another, i.e. same batch and base shapes, same tensor options, etc.