|
MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
|
#include <array>#include <cassert>#include <cstddef>#include <functional>#include <stdexcept>#include <type_traits>#include <mtl/array/ndarray.hpp>#include <mtl/detail/exceptions.hpp>#include <mtl/array/shape.hpp>#include <mtl/vec/dense_vector.hpp>#include <mtl/mat/dense2D.hpp>Namespaces | |
| namespace | mtl |
| namespace | mtl::array |
| namespace | mtl::array::detail_interop |
Functions | |
| void | mtl::array::detail_interop::require (bool ok, const char *what) |
| A precondition of the zero-copy views, checked in every build: a strided array aliased as a dense vector or matrix reads the wrong elements (#856: it was an assert). | |
| template<typename Value, typename Params> | |
| ndarray< Value, 1, c_order > | mtl::array::as_ndarray (vec::dense_vector< Value, Params > &v) |
| Create a 1D ndarray view over a dense_vector (zero-copy). | |
| template<typename Value, typename Params> | |
| ndarray< const Value, 1, c_order > | mtl::array::as_ndarray (const vec::dense_vector< Value, Params > &v) |
| template<typename Value, typename Params> | |
| auto | mtl::array::as_ndarray (mat::dense2D< Value, Params > &m) |
| Create a 2D ndarray view over a dense2D matrix (zero-copy). | |
| template<typename Value, typename Params> | |
| auto | mtl::array::as_ndarray (const mat::dense2D< Value, Params > &m) |
| template<typename Value, typename Order> | |
| vec::dense_vector< Value > | mtl::array::as_vector (ndarray< Value, 1, Order > &a) |
| Create a dense_vector view over a 1D ndarray (zero-copy). | |
| template<typename Value, typename Order> | |
| vec::dense_vector< const Value > | mtl::array::as_vector (const ndarray< Value, 1, Order > &a) |
| template<typename Value, typename Order> requires std::is_same_v<Order, c_order> | |
| mat::dense2D< Value > | mtl::array::as_matrix (ndarray< Value, 2, Order > &a) |
| Create a dense2D view over a 2D ndarray (zero-copy). | |
| template<typename Value, typename Order> requires std::is_same_v<Order, c_order> | |
| mat::dense2D< const Value > | mtl::array::as_matrix (const ndarray< Value, 2, Order > &a) |
| template<typename V, std::size_t N, typename O, typename F> | |
| ndarray< std::remove_cv_t< V >, N, O > | mtl::array::transform (const ndarray< V, N, O > &a, F &&f) |
| Element-wise transform: apply f to every element of a, writing to out. | |
| template<typename V, std::size_t N, typename O, typename F> | |
| void | mtl::array::transform_inplace (ndarray< V, N, O > &a, F &&f) |
| In-place transform: apply f to every element. | |
| template<typename V, std::size_t N, typename O, typename T, typename BinOp> | |
| T | mtl::array::reduce (const ndarray< V, N, O > &a, T init, BinOp op) |
| Reduce all elements with a binary operation and initial value. | |
| template<typename V, std::size_t N, typename O> | |
| ndarray< std::remove_cv_t< V >, 1, c_order > | mtl::array::flatten (const ndarray< V, N, O > &a) |
| Flatten any ndarray to a contiguous 1D ndarray (always copies for safety), in the array's own order: the same elements, in the same order, as a.reshape({a.size()}) views when a is contiguous in that order. | |