57 template <ArrayOfRank<1> A>
58 double norm(A
const &a,
double p = 2.0) {
61 if (p == 2.0) [[likely]] {
66 }
else if (p == 1.0) {
68 }
else if (p == 0.0) {
70 for (
long i = 0; i < a.size(); ++i) {
74 }
else if (p == std::numeric_limits<double>::infinity()) {
76 }
else if (p == -std::numeric_limits<double>::infinity()) {
79 return std::pow(
sum(
pow(
abs(a), p)), 1.0 / p);
Provides various algorithms to be used with nda::Array objects.
Provides basic functions to create and manipulate arrays and views.
Provides a generic interface to the BLAS dot routine.
Check if a given type satisfies the memory array concept.
Check if a given type is either an arithmetic or complex type.
Provides concepts for the nda library.
auto max_element(A const &a)
Find the maximum element of an array.
auto min_element(A const &a)
Find the minimum element of an array.
auto sum(A const &a)
Sum all the elements of an nda::Array object.
decltype(auto) make_regular(A &&a)
Make a given object regular.
auto abs(A &&a)
Lazy, coefficient-wise abs function for nda::Array types.
T pow(T x, int n)
Calculate the integer power of an integer.
std::decay_t< decltype(get_first_element(std::declval< A const >()))> get_value_t
Get the value type of an array/view or a scalar type.
auto dotc(X const &x, Y const &y)
Interface to the BLAS dotc routine.
Provides lazy, coefficient-wise array operations of standard mathematical functions.
Provides type traits for the nda library.