Skip to content

Function Reference

njpipeorgan edited this page Aug 10, 2018 · 9 revisions

List of the functions

Functions

Member functions

Macros


Functions

bool has_abort()

  • Checks whether Abort[] is called from the Wolfram Kernel.

std::ostream& log_stringstream_t::operator<<(Any&&)

  • Outputs any to wll::global_log, a log string stream.
  • For example, wll::global_log << "some message";.

"wll_exception_msg"

  • This is a LibraryLink function, which is loaded by the Wolfram Kernel.
  • When it is called, it will return the recent exception message as a string.

"wll_log_content"

  • This is a LibraryLink function, which is loaded by the Wolfram Kernel.
  • When it is called, it will return the log content as a string.

"wll_log_clear"

  • This is a LibraryLink function, which is loaded by the Wolfram Kernel.
  • When it is called, it will clear all log content.

Member functions

tensor<T,R>::tensor(_dims_t, memory_type)

  • Constructs the tensor with an std::array as the dimensions, and an optional memory_type.
  • The size of the dimensions array should be equal to the rank of the tensor, and second argument should be memory_type::owned(default) or memory_type::manual.

tensor<T,R>::tensor(_init_dims_t, memory_type)

  • Constructs the tensor with an initializer list of size_t as the dimensions, and an optional memory_type.
  • The size of the dimensions initializer list should be equal to the rank of the tensor, and the second argument should be memory_type::owned(default) or memory_type::manual.

tensor<T,R>::tensor(_dims_t, const _init_data_t& data, memory_type)

  • Constructs the tensor with an std::array as the dimensions, an initializer list as initial data, and an optional memory_type.
  • The size of the dimensions array should be equal to the rank of the tensor, and second argument should be memory_type::owned(default) or memory_type::manual.

tensor<T,R>::tensor(_init_dims_t, const _init_data_t& data, memory_type)

  • Constructs the tensor with an initializer list of size_t as the dimensions, an initializer list as initial data, and an optional memory_type.
  • If the first argument is not a zero-length initializer list, the constructed tensor will take it as the dimensions. Otherwise, initial data will determine the dimensions of the tensor.
  • The second argument should be memory_type::owned(default) or memory_type::manual.

tensor<T,R>::tensor(const tensor&)

  • Constructs the tensor to be the same as another tensor of the same type.

tensor<T,R>::tensor(tensor&&)

  • Constructs the tensor to be the same as another rvalue tensor of the same type.

tensor<T,R>::tensor(const tensor<U, _rank>&)

  • Constructs the tensor to be the same as another tensor with the same rank but a different value type.

tensor<T,R>::tensor(tensor<U, _rank>&&)

  • Constructs the tensor to be the same as another rvalue tensor with the same rank but a different value type.

tensor& tensor<T,R>::operator=(const tensor&)

  • Copies the values from another tensor of the same type.
  • The dimensions of the tensors should be identical.

tensor& tensor<T,R>::operator=(tensor&&)

  • Copies the values from another movable tensor of the same type.
  • The dimensions of the tensors should be identical.

tensor& tensor<T,R>::operator=(const tensor<U, _rank>&)

  • Copies the values from another tensor with the same rank but a different value type.
  • The dimensions of the tensors should be identical.

tensor& tensor<T,R>::operator=(tensor<U, _rank>&&)

  • Copies the values from another movable tensor with the same rank but a different value type.
  • The dimensions of the tensors should be identical.

tensor tensor<T,R>::clone(memory_type) const

  • Gets a copy of the tensor. The copy will have the given memory_type, which is optional. The memory_type should be memory_type::owned(default) or memory_type::manual.

constexpr size_t tensor<T,R>::rank() const

  • Returns the rank of the tensor.

size_t tensor<T,R>::size() const

  • Returns the total number of elements in the tensor.

_dims_t tensor<T,R>::dimensions() const

  • Returns the dimensions of the tensor as an std::array.

size_t tensor<T,R>::dimension(size_t) const

  • Returns the dimension of the tensor at the i-th level. The first and last level corresponds to i being equal to 0 and _rank - 1.

_ptr_t tensor<T,R>::data()

  • Returns a pointer pointing to the first element in the tensor.

_const_ptr_t tensor<T,R>::data() const

  • Returns a const pointer pointing to the first element in the tensor.

bool tensor<T,R>::operator==(const tensor&) const

  • Checks whether two tensors are equal in terms of their data.

value_type tensor<T,R>::at(Idx...) const

  • Returns the value at a certain position.
  • The indices should be of integral types, and the number of them should be equal to the rank of the tensor.

value_type& tensor<T,R>::at(Idx...)

  • Returns a reference to the value at a certain position.
  • The indices should be of integral types, and the number of them should be equal to the rank of the tensor.

value_type tensor<T,R>::operator()(Idx...) const

  • Is equivalent to at(...) const, but has undefined behavior when "out of range" happens.

value_type& tensor<T,R>::operator()(Idx...)

  • Is equivalent to at(...), but has undefined behavior when "out of range" happens.

value_type tensor<T,R>::operator[](size_t) const

  • Returns the i-th value of the tensor, as if it is a 1-dimensional array.

value_type& tensor<T,R>::operator[](size_t)

  • Returns a reference to the i-th value of the tensor, as if it is a 1-dimensional array.

_const_ptr_t tensor<T,R>::cbegin() const

_const_ptr_t tensor<T,R>::cend() const

_const_ptr_t tensor<T,R>::begin() const

_const_ptr_t tensor<T,R>::end() const

  • Returns the begin and end const pointer of the tensor, as if it is a 1-dimensional array.

_ptr_t tensor<T,R>::begin()

_ptr_t tensor<T,R>::end()

  • Returns the begin and end pointer of the tensor, as if it is a 1-dimensional array.

void tensor<T,R>::copy_data_from(InputIter, size_t)

  • Copies the data from the input iterator, with an optional size. If the size is specified, it should be equal to the flattened size of the tensor.

void tensor<T,R>::copy_data_to(OutputIter, size_t)

  • Copies the data to the output iterator, with an optional size. If the size is specified, it should be equal to the flattened size of the tensor.

sparse_array<T,R>::sparse_array(_dims_t, value_type)

  • Constructs the sparse array with an std::array as the dimensions. The optional value will be the implicit value of the sparse array, which will be zero if not explicitly given.

sparse_array<T,R>::sparse_array(_init_dims_t, value_type)

  • Constructs the sparse array with an initializer list of size_t as the dimensions. The optional value will be the implicit value of the sparse array, which will be zero if not explicitly given.

sparse_array<T,R>::sparse_array(const tensor<value_type, _rank>&, value_type, double)

  • Constructs the sparse array to be equivalent to the given tensor, and takes the optional second argument as the implicit value. The optional third argument is the explicit value density hint.
  • The explicit value density hint is a real number that ranges from 0 to 1. The constructor will reserved that much space for explicit values, and expand it if not enough. If the density hint is not given, a default scheme will be applied.

sparse_array<T,R>::sparse_array(_dims_t, _init_data_t, value_type)

  • Constructs the sparse array with an std::array as the dimensions. The explicit values in the sparse array is given by initial data, and the optional value will be the implicit value.
  • The initial data is a list of rules of form wll::pos(i0, i1, ...) = value.

sparse_array<T,R>::sparse_array(_init_dims_t, _init_data_t, value_type)

  • Constructs the sparse array with an initializer list of size_t as the dimensions if it is not left blank. Otherwise the minimal size that can hold all explicit values will be taken. The explicit values in the sparse array is given by initial data, and the optional third argument will be the implicit value.
  • The initial data is a list of rules of form wll::pos(i0, i1, ...) = value.

sparse_array<T,R>::sparse_array(const sparse_array&)

  • Constructs the sparse array to be the same as another sparse array of the same type.

sparse_array<T,R>::sparse_array(sparse_array&&)

  • Constructs the tensor to be the same as another rvalue sparse array of the same type.

sparse_array<T,R>::sparse_array(const sparse_array<U, _rank>&)

  • Constructs the sparse array to be the same as another sparse array with the same rank but a different value type.

sparse_array<T,R>::sparse_array(sparse_array<U, _rank>&&)

  • Constructs the tensor to be the same as another rvalue sparse array with the same rank but a different value type.

sparse_array& sparse_array<T,R>::operator=(const sparse_array&)

  • Copies the values from another sparse array of the same type.
  • The dimensions of the sparse arrays should be identical.

sparse_array& sparse_array<T,R>::operator=(sparse_array&&)

  • Copies the values from another movable sparse array of the same type.
  • The dimensions of the tensors should be identical.

sparse_array& sparse_array<T,R>::operator=(const sparse_array<U, _rank>&)

  • Copies the values from another sparse array with the same rank but a different value type.
  • The dimensions of the sparse arrays should be identical.

sparse_array& sparse_array<T,R>::operator=(sparse_array<U, _rank>&&)

  • Copies the values from another movable sparse array with the same rank but a different value type.
  • The dimensions of the sparse arrays should be identical.

constexpr size_t sparse_array<T,R>::rank() const

  • Returns the rank of the sparse array.

size_t sparse_array<T,R>::size() const

  • Returns the total number of (explicit and implicit) elements in the sparse array.

_dims_t sparse_array<T,R>::dimensions() const

  • Returns the dimensions of the sparse array as an std::array.

size_t sparse_array<T,R>::dimension(size_t) const

  • Returns the dimension of the sparse array at the i-th level. The first and last level corresponds to i being equal to 0 and _rank - 1.

value_type sparse_array<T,R>::implicit_value() const

  • Returns the implicit value of the sparse array.

const _column_t* sparse_array<T,R>::columns_pointer() const

  • Returns the pointer pointing to the first column element.
  • A column element is an std::array with size equal to _rank - 1 when _rank > 1 or 1 when _rank == 1.

const value_type* sparse_array<T,R>::values_pointer() const

  • Returns the pointer pointing to the first element in the explicit value array.

const size_t* sparse_array<T,R>::row_indices_pointer() const

  • Returns the pointer pointing to the first element in the row indices array.

bool sparse_array<T,R>::operator==(const sparse_array&)

  • Checks whether two sparse arrays compare to equal, i.e. has the same values on the same positions.

value_type sparse_array<T,R>::at(Idx...) const

  • Returns the value at a certain position.
  • The indices should be of integral types, and the number of them should be equal to the rank of the sparse array.

reference sparse_array<T,R>::at(Idx...)

  • Returns a reference to the value at a certain position.
  • The indices should be of integral types, and the number of them should be equal to the rank of the sparse array.

value_type sparse_array<T,R>::operator()(Idx...) const

  • Is equivalent to at(...) const, but has undefined behavior when "out of range" happens.

reference sparse_array<T,R>::operator()(Idx...)

  • Is equivalent to at(...), but has undefined behavior when "out of range" happens.

const_iterator sparse_array<T,R>::cbegin() const

const_iterator sparse_array<T,R>::cend() const

const_iterator sparse_array<T,R>::begin() const

const_iterator sparse_array<T,R>::end() const

  • Returns the begin and end const iterator of the sparse array, as if it is a 1-dimensional array.

iterator sparse_array<T,R>::begin()

iterator sparse_array<T,R>::end()

  • Returns the begin and end iterator of the sparse array, as if it is a 1-dimensional array.

void sparse_array<T,R>::refresh_implicit()

  • Removes any explicit value entry that has the same value as the implicit value.
  • It may need to be called when one or more explicit values are set to be the implicit value.

void sparse_array<T,R>::transform<bool>(Fn)

  • Transforms all elements in the sparse array by the function. transform accepts an optional template parameter, indicating whether the "refresh implicit" operation needs to be done (false by default).
  • The transforming function are typically required to be stateless.

operator sparse_array<T,R>::tensor<value_type, _rank>() const

  • Converts the sparse array to a tensor with the same value type and rank.

Macros

DEFINE_WLL_FUNCTION(fn)

  • Defines a LibraryLink function wll_fn, which handles argument passing and returning the result to the Wolfram Kernel.

MType_Void

  • Expands to -1.

WLL_DEBUG_EXECUTE(expr)

  • If NDEBUG is not defined, expands to (expr), otherwise, does nothing.

WLL_ASSERT(expr)

  • If NDEBUG is not defined, expands to assert((expr)), otherwise, does nothing.
Clone this wiki locally