tensor-0.1.0
|
An N-dimensional array of numbers. More...
Public Member Functions | |
elt_t & | at (index i) |
Return a mutable reference to an element of a 1D Tensor. More... | |
elt_t & | at (index row, index col) |
Return a mutable reference to an element of a 2D Tensor. More... | |
elt_t & | at (index d1, index d2, index d3) |
Return a mutable reference to an element of a 3D Tensor. More... | |
elt_t & | at (index d1, index d2, index d3, index d4) |
Return a mutable reference to an element of a 4D Tensor. More... | |
elt_t & | at (index d1, index d2, index d3, index d4, index d5) |
Return a mutable reference to an element of a 5D Tensor. More... | |
elt_t & | at (index d1, index d2, index d3, index d4, index d5, index d6) |
Return a mutable reference to an element of 6D Tensor. More... | |
mutable_view | at (PRange r) |
Mutable slice from a 1D Tensor. More... | |
mutable_view | at (PRange r1, PRange r2) |
Mutable slice from a 2D Tensor. More... | |
mutable_view | at (PRange r1, PRange r2, PRange r3) |
Mutable slice from a 3D Tensor. More... | |
mutable_view | at (PRange r1, PRange r2, PRange r3, PRange r4) |
Mutable slice from a 4D Tensor. More... | |
mutable_view | at (PRange r1, PRange r2, PRange r3, PRange r4, PRange r5) |
Mutable slice from a 5D Tensor. More... | |
mutable_view | at (PRange r1, PRange r2, PRange r3, PRange r4, PRange r5, PRange r6) |
Mutable slice from a 6D Tensor. More... | |
elt_t & | at_seq (index i) |
Return a mutable reference to the i-th element of a Tensor, in column major order. More... | |
iterator | begin () |
Iterator at the beginning. More... | |
const_iterator | begin () const |
Iterator at the beginning. More... | |
const_iterator | begin_const () const |
Iterator at the beginning for const objects. More... | |
index | columns () const |
Query the size of 2nd index. More... | |
const Tensor< elt_t > | diag (int which=0, int ndx1=0, int ndx2=-1) |
Take a diagonal from a tensor. More... | |
index | dimension (int which) const |
Length of a given Tensor index. More... | |
const Indices & | dimensions () const |
Return Tensor dimensions. More... | |
const_iterator | end () const |
Iterator at the end for const objects. More... | |
iterator | end () |
Iterator at the end. More... | |
const_iterator | end_const () const |
Iterator at the end for const objects. More... | |
void | fill_with (const elt_t &e) |
Fill with an element. More... | |
void | fill_with_zeros () |
Fill with zeros. More... | |
void | get_dimensions (index *length) const |
Query dimensions of 1D Tensor. More... | |
void | get_dimensions (index *rows, index *cols) const |
Query dimensions of 2D Tensor. More... | |
void | get_dimensions (index *d0, index *d1, index *d2) const |
Query dimensions of 3D Tensor. More... | |
void | get_dimensions (index *d0, index *d1, index *d2, index *d3) const |
Query dimensions of 4D Tensor. More... | |
void | get_dimensions (index *d0, index *d1, index *d2, index *d3, index *d4) const |
Query dimensions of 5D Tensor. More... | |
void | get_dimensions (index *d0, index *d1, index *d2, index *d3, index *d4, index *d5) const |
Query dimensions of 6D Tensor. More... | |
bool | is_empty () const |
Does the tensor have elements? | |
const elt_t & | operator() (index i) const |
Return an element of a 1D Tensor. More... | |
const elt_t & | operator() (index row, index col) const |
Return an element of a 2D Tensor. More... | |
const elt_t & | operator() (index d0, index d1, index d2) const |
Return an element of a 3D Tensor. More... | |
const elt_t & | operator() (index d0, index d1, index d2, index d3) const |
Return an element of a 4D Tensor. More... | |
const elt_t & | operator() (index d0, index d1, index d2, index d3, index d4) const |
Return an element of a 5D Tensor. More... | |
const elt_t & | operator() (index d0, index d1, index d2, index d3, index d4, index d5w) const |
Return an element of a 6D Tensor. More... | |
const view | operator() (PRange r) const |
Extracts a slice from a 1D Tensor. More... | |
const view | operator() (PRange r1, PRange r2) const |
Extracts a slice from a 2D Tensor. More... | |
const view | operator() (PRange r1, PRange r2, PRange r3) const |
Extracts a slice from a 3D Tensor. More... | |
const view | operator() (PRange r1, PRange r2, PRange r3, PRange r4) const |
Extracts a slice from a 4D Tensor. More... | |
const view | operator() (PRange r1, PRange r2, PRange r3, PRange r4, PRange r5) const |
Extracts a slice from a 5D Tensor. More... | |
const view | operator() (PRange r1, PRange r2, PRange r3, PRange r4, PRange r5, PRange r6) const |
Extracts a slice from a 6D Tensor. More... | |
const Tensor & | operator= (const Tensor< elt_t > &other) |
Assignment operator. More... | |
const elt_t & | operator[] (index i) const |
Return the i-th element, accessed in column major order. More... | |
void | randomize () |
Fills with random numbers. More... | |
int | rank () const |
Number of Tensor indices. More... | |
void | reshape (const Indices &new_dims) |
Change the dimensions, while keeping the data. More... | |
index | rows () const |
Query then size of 1st index. More... | |
index | size () const |
Returns total number of elements in Tensor. More... | |
Tensor () | |
Constructs an empty Tensor. More... | |
Tensor (const Indices &new_dims) | |
Constructs an unitialized N-D Tensor given the dimensions. More... | |
Tensor (const Indices &new_dims, const Tensor< elt_t > &data) | |
Consturcts an N-D Tensor with given initial data. More... | |
Tensor (const Vector< elt_t > &data) | |
Constructs a 1-D Tensor from a vector. More... | |
Tensor (const std::vector< elt_t > &data) | |
Constructs a 1-D Tensor from a vector. More... | |
Tensor (const Tensor &other) | |
Optimized copy constructor (See Optimal copy). More... | |
template<typename e2 > | |
Tensor (const Tensor< e2 > &other) | |
Implicit coercion. More... | |
template<size_t n> | |
Tensor (const StaticVector< elt_t, n > &t) | |
Create a one-dimensional tensor from data created with "gen" expressions. More... | |
template<size_t n> | |
Tensor (const StaticVector< elt_t, n > &t, const Indices &d) | |
Create a general tensor from data created with "gen" expressions. More... | |
Tensor (index length) | |
Build a 1D Tensor or vector. More... | |
Tensor (index rows, index cols) | |
Build a 2D Tensor or matrix. More... | |
Tensor (index d1, index d2, index d3) | |
Build a 3D Tensor. More... | |
Tensor (index d1, index d2, index d3, index d4) | |
Build a 4D Tensor. More... | |
Tensor (index d1, index d2, index d3, index d4, index d5) | |
Build a 5D Tensor. More... | |
Tensor (index d1, index d2, index d3, index d4, index d5, index d6) | |
Build a 6D Tensor. More... | |
Static Public Member Functions | |
static const Tensor< elt_t > | eye (index rows) |
Identity matrix. More... | |
static const Tensor< elt_t > | eye (index rows, index cols) |
Rectangular identity matrix. More... | |
static const Tensor< elt_t > | ones (index rows) |
Matrix of ones. More... | |
static const Tensor< elt_t > | ones (index rows, index cols) |
Matrix of ones. More... | |
static const Tensor< elt_t > | ones (const Indices &dimensions) |
Tensor of ones. More... | |
static const Tensor< elt_t > | random (index length) |
Build a random 1D Tensor. More... | |
static const Tensor< elt_t > | random (index rows, index cols) |
Build a random 2D Tensor. More... | |
static const Tensor< elt_t > | random (index d1, index d2, index d3) |
Build a random 3D Tensor. More... | |
static const Tensor< elt_t > | random (index d1, index d2, index d3, index d4) |
Build a random 4D Tensor. More... | |
static const Tensor< elt_t > | random (index d1, index d2, index d3, index d4, index d5) |
Build a random 5D Tensor. More... | |
static const Tensor< elt_t > | random (index d1, index d2, index d3, index d4, index d5, index d6) |
Build a random 6D Tensor. More... | |
static const Tensor< elt_t > | random (const Indices &dimensions) |
Build a random Tensor with arbitrary dimensions. More... | |
static const Tensor< elt_t > | zeros (index rows) |
Matrix of zeros. More... | |
static const Tensor< elt_t > | zeros (index rows, index cols) |
Matrix of zeros. More... | |
static const Tensor< elt_t > | zeros (index d1, index d2, index d3) |
4D Tensor of zeros. More... | |
static const Tensor< elt_t > | zeros (index d1, index d2, index d3, index d4) |
4D Tensor of zeros. More... | |
static const Tensor< elt_t > | zeros (index d1, index d2, index d3, index d4, index d5) |
5D Tensor of zeros. More... | |
static const Tensor< elt_t > | zeros (index d1, index d2, index d3, index d4, index d5, index d6) |
6D Tensor of zeros. More... | |
static const Tensor< elt_t > | zeros (const Indices &dimensions) |
Tensor of zeros. More... | |
An N-dimensional array of numbers.
A Tensor is a multidimensional array of numbers. Their behavior is similar to Matlab's arrays in that they can store only numbers, be accessed with one or more indices using the () or [] syntaxes, reshaped, sliced, and all that with an automated memory management.