typename Matrix::value_type norm( const Matrix& A, const std::size_t n ) { typedef typename Matrix::value_type value_type; if ( 1 == n ) { std::vector<value_type> m( A.col() ); for ( std::size_t i = 0; i != A.col(); ++i ) m[i] = std::accumulate( A.col_cbegin(i), A.col_cend(i), value_type(0), []( value_type u, value_type v ) { return u + std::abs(v); } ); return *(std::max_element( m.begin(), m.end() )); } if ( 2 == n ) { return std::sqrt(eigen_power_iteration( A )); } assert( !"norm:: other norm algorithm has not been implemented!" ); return value_type(0); }
typename Matrix::value_type norm_2( const Matrix& A ) { return std::sqrt(eigen_power_iteration( A )); }
T eigen_power_iteration( const matrix<std::complex<T>,D,A_>& A, const T eps = T(1.0e-5) ) { matrix<std::complex<T>,D,A_> b( A.col(), 1 ); return eigen_power_iteration(A, b.begin(), eps); }