35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATNORMEXPR_H_ 36 #define _BLAZE_MATH_EXPRESSIONS_SMATNORMEXPR_H_ 104 inline decltype(
auto) norm_backend( const SparseMatrix<MT,SO>& sm, Abs
abs, Power power, Root root )
106 using CT = CompositeType_<MT>;
107 using ET = ElementType_<MT>;
108 using RT = decltype(
evaluate( root( std::declval<ET>() ) ) );
110 using ConstIterator = ConstIterator_< RemoveReference_<CT> >;
112 if( (~sm).
rows() == 0UL || (~sm).
columns() == 0UL )
return RT();
116 const size_t N( IsRowMajorMatrix<MT>::value ? tmp.rows(): tmp.columns() );
120 for(
size_t i=0UL; i<N; ++i )
125 norm = power(
abs( element->value() ) );
127 norm += power(
abs( element->value() ) );
152 template<
typename MT
178 template<
typename MT
204 template<
typename MT
210 return norm_backend( ~sm, Abs(),
Noop(),
Noop() );
230 template<
typename MT
256 template<
typename MT
262 return norm_backend( ~sm, Abs(),
Pow3(),
Cbrt() );
282 template<
typename MT
313 template<
typename MT
355 using Norm =
typename TypeAt< Norms,
min( P-1UL, 4UL ) >::Type;
357 return Norm()( ~sm );
377 template<
typename MT
decltype(auto) sqrNorm(const DenseMatrix< MT, SO > &dm)
Computes the squared L2 norm for the given dense matrix.
Definition: DMatNormExpr.h:504
Header file for the Sqrt functor.
Header file for auxiliary alias declarations.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Generic wrapper for the cbrt() function.
Definition: Cbrt.h:62
Header file for the Pow4 functor.
Header file for basic type definitions.
decltype(auto) l3Norm(const DenseMatrix< MT, SO > &dm)
Computes the L3 norm for the given dense matrix.
Definition: DMatNormExpr.h:582
Header file for the Pow2 functor.
decltype(auto) l2Norm(const DenseMatrix< MT, SO > &dm)
Computes the L2 norm for the given dense matrix.
Definition: DMatNormExpr.h:556
decltype(auto) l4Norm(const DenseMatrix< MT, SO > &dm)
Computes the L4 norm for the given dense matrix.
Definition: DMatNormExpr.h:608
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1903
Generic wrapper for the pow() function with fixed exponent.
Definition: Forward.h:119
decltype(auto) lpNorm(const DenseMatrix< MT, SO > &dm, ST p)
Computes the Lp norm for the given dense matrix.
Definition: DMatNormExpr.h:640
Header file for the invert shim.
typename MultTrait< T1, T2 >::Type MultTrait_
Auxiliary alias declaration for the MultTrait class template.The MultTrait_ alias declaration provide...
Definition: MultTrait.h:291
Generic wrapper for the qdrt() function.
Definition: Qdrt.h:61
#define BLAZE_STATIC_ASSERT_MSG(expr, msg)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:123
const MT::ResultType evaluate(const Matrix< MT, SO > &matrix)
Evaluates the given matrix expression.
Definition: Matrix.h:888
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1950
Header file for the Cbrt functor.
Header file for the LpNorm functor.
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:129
Header file for the SparseMatrix base class.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:670
Generic wrapper for the sqrt() function.
Definition: Sqrt.h:62
Header file for the multiplication trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the L4Norm functor.
Header file for the UnderlyingBuiltin type trait.
decltype(auto) l1Norm(const DenseMatrix< MT, SO > &dm)
Computes the L1 norm for the given dense matrix.
Definition: DMatNormExpr.h:530
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
Header file for the isZero shim.
decltype(auto) inv(const DenseMatrix< MT, SO > &dm)
Calculation of the inverse of the given dense matrix.
Definition: DMatInvExpr.h:423
Header file for the L2Norm functor.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
Implementation of a type list.The TypeList class template represents a list of data types of arbitrar...
Definition: TypeList.h:119
Generic wrapper for the null function.
Definition: Noop.h:59
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:430
Header file for the Abs functor.
decltype(auto) abs(const DenseMatrix< MT, SO > &dm)
Applies the abs() function to each single element of the dense matrix dm.
Definition: DMatMapExpr.h:1176
decltype(auto) maxNorm(const DenseMatrix< MT, SO > &dm)
Computes the maximum norm for the given dense matrix.
Definition: DMatNormExpr.h:703
Generic wrapper for the pow4() function.
Definition: Pow4.h:61
Header file for the evaluate shim.
Generic wrapper for the pow2() function.
Definition: Pow2.h:61
Header file for run time assertion macros.
Indexing a type list.The TypeAt class can be used to access a type list at a specified position to qu...
Definition: TypeAt.h:76
Header file for the Unique class template.
Header file for the UnaryPow functor.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for the isDefault shim.
Header file for the Noop functor.
Header file for the RemoveReference type trait.
decltype(auto) norm(const DenseMatrix< MT, SO > &dm)
Computes the L2 norm for the given dense matrix.
Definition: DMatNormExpr.h:478
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
Generic wrapper for the pow3() function.
Definition: Pow3.h:61
Header file for the L3Norm functor.
Header file for the IsRowMajorMatrix type trait.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
Header file for the L1Norm functor.
Header file for the Qdrt functor.
Header file for the IsResizable type trait.
Header file for the Pow3 functor.
Header file for the function trace functionality.