Blaze 3.9
InitializerList.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_INITIALIZERLIST_H_
36#define _BLAZE_MATH_INITIALIZERLIST_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
46
47
48namespace blaze {
49
50//=================================================================================================
51//
52// UTILITY FUNCTIONS
53//
54//=================================================================================================
55
56//*************************************************************************************************
63template< typename Type >
64inline size_t nonZeros( initializer_list<Type> list ) noexcept
65{
66 size_t nonzeros( 0UL );
67
68 for( const Type& element : list ) {
69 if( !isDefault<strict>( element ) )
70 ++nonzeros;
71 }
72
73 return nonzeros;
74}
75//*************************************************************************************************
76
77
78//*************************************************************************************************
85template< typename Type >
86inline size_t nonZeros( initializer_list< initializer_list<Type> > list ) noexcept
87{
88 size_t nonzeros( 0UL );
89
90 for( const auto& rowList : list ) {
91 nonzeros += nonZeros( rowList );
92 }
93
94 return nonzeros;
95}
96//*************************************************************************************************
97
98
99//*************************************************************************************************
106template< typename Type >
107constexpr size_t determineColumns( initializer_list< initializer_list<Type> > list ) noexcept
108{
109 size_t cols( 0UL );
110
111 for( const auto& rowList : list )
112 cols = max( cols, rowList.size() );
113
114 return cols;
115}
116//*************************************************************************************************
117
118} // namespace blaze
119
120#endif
Header file for the isDefault shim.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1375
constexpr size_t determineColumns(initializer_list< initializer_list< Type > > list) noexcept
Determines the maximum number of columns specified by the given initializer list.
Definition: InitializerList.h:107
size_t nonZeros(initializer_list< initializer_list< Type > > list) noexcept
Determines the number of non-zero elements contained in the given initializer list.
Definition: InitializerList.h:86
Header file for the initializer_list template.
Header file for the generic max algorithm.