Blaze  3.6
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 
47 
48 
49 namespace blaze {
50 
51 //=================================================================================================
52 //
53 // UTILITY FUNCTIONS
54 //
55 //=================================================================================================
56 
57 //*************************************************************************************************
64 template< typename Type >
65 inline size_t nonZeros( initializer_list<Type> list ) noexcept
66 {
67  size_t nonzeros( 0UL );
68 
69  for( const Type& element : list ) {
70  if( !isDefault<strict>( element ) )
71  ++nonzeros;
72  }
73 
74  return nonzeros;
75 }
76 //*************************************************************************************************
77 
78 
79 //*************************************************************************************************
86 template< typename Type >
87 inline size_t nonZeros( initializer_list< initializer_list<Type> > list ) noexcept
88 {
89  size_t nonzeros( 0UL );
90 
91  for( const auto& rowList : list ) {
92  nonzeros += nonZeros( rowList );
93  }
94 
95  return nonzeros;
96 }
97 //*************************************************************************************************
98 
99 
100 //*************************************************************************************************
107 template< typename Type >
108 inline constexpr size_t determineColumns( initializer_list< initializer_list<Type> > list ) noexcept
109 {
110  size_t cols( 0UL );
111 
112  for( const auto& rowList : list )
113  cols = max( cols, rowList.size() );
114 
115  return cols;
116 }
117 //*************************************************************************************************
118 
119 } // namespace blaze
120 
121 #endif
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Header file for the initializer_list template.
Headerfile for the generic max algorithm.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
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:1198
Header file for the relaxation flag types.
Header file for the isDefault shim.
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:108