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 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // UTILITY FUNCTIONS
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
63 template< typename Type >
64 inline size_t nonZeros( initializer_list<Type> list ) noexcept
65 {
66  size_t nonzeros( 0UL );
67 
68  for( const Type& element : list ) {
69  if( !isDefault( element ) )
70  ++nonzeros;
71  }
72 
73  return nonzeros;
74 }
75 //*************************************************************************************************
76 
77 
78 //*************************************************************************************************
85 template< typename Type >
86 inline 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 //*************************************************************************************************
106 template< typename Type >
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
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:560
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 initializer_list template.
Headerfile for the generic max algorithm.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
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
Header file for the isDefault shim.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628