|
NumericAL
A header-only C++20 lexer built on REAL
|
A dense, value-semantic vector over a scalar type. More...
#include <algorithm>#include <cmath>#include <complex>#include <cstddef>#include <functional>#include <initializer_list>#include <limits>#include <memory>#include <numeric>#include <stdexcept>#include <string>#include <type_traits>#include <utility>#include <vector>#include "buffer.hpp"Go to the source code of this file.
Classes | |
| class | numerical::dimension_error |
| Thrown when an operation's operands have incompatible shapes. More... | |
| class | numerical::vector< T > |
A dense vector of T with value semantics. More... | |
Namespaces | |
| namespace | numerical |
| The NumericAL public API. | |
| namespace | numerical::detail |
Functions | |
| std::size_t | numerical::detail::checked_mul (std::size_t a, std::size_t b) |
a * b, throwing numerical::dimension_error if the product overflows std::size_t. Guards dimension/shape products (element counts, allocation sizes) against silent wraparound on absurd inputs. The a != 0 guard also keeps the max / a division well-defined. | |
| template<typename It > | |
| std::size_t | numerical::detail::element_count (It first, It last) |
The elements a shape's extents [first, last) hold: 0 where one of them is 0, whatever the others, else their product (checked_mul). The extents a tensor keeps, past one it holds 0 of, may multiply past std::size_t: a result of them is empty, not of a wrapped size. | |
| template<typename T > | |
| vector< T > | numerical::operator+ (const vector< T > &a, const vector< T > &b) |
| Element-wise sum. | |
| template<typename T > | |
| vector< T > | numerical::operator- (const vector< T > &a, const vector< T > &b) |
| Element-wise difference. | |
| template<typename T > | |
| vector< T > | numerical::operator* (const T &scalar, const vector< T > &v) |
| Scalar times vector. | |
| template<typename T > | |
| vector< T > | numerical::operator* (const vector< T > &v, const T &scalar) |
| Vector times scalar. | |
| template<typename T > | |
| T | numerical::dot (const vector< T > &a, const vector< T > &b) |
| Dot product. | |
| template<typename T > | |
| bool | numerical::approx_equal (const vector< T > &a, const vector< T > &b, double tolerance=1e-9) |
| Element-wise closeness within a tolerance (for inexact scalars). | |
A dense, value-semantic vector over a scalar type.
numerical::vector is generic over its element type T (the scalar): any type closed under the operations used — int, double, std::complex<double>, a rational, … NumericAL is a leaf library: it knows nothing of expressions or any symbolic layer, only concrete numeric data. Operations that need matching shapes throw numerical::dimension_error on a mismatch.
Definition in file vector.hpp.