<s> """<STR_LIT>""" <EOL> from __future__ import division , print_function , absolute_import <EOL> import numpy as np <EOL> try : <EOL> import scipy . sparse . linalg <EOL> import scipy . sparse <EOL> except ImportError : <EOL> pass <EOL> from . common import Benchmark <EOL> class BenchmarkOneNormEst ( Benchmark ) : <EOL> params = [ <EOL> [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:10> , <NUM_LIT:30> , <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1000> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> ] <EOL> param_names = [ '<STR_LIT:n>' , '<STR_LIT>' ] <EOL> def setup ( self , n , solver ) : <EOL> np . random . seed ( <NUM_LIT> ) <EOL> nrepeats = <NUM_LIT:100> <EOL> shape = ( n , n ) <EOL> if n <= <NUM_LIT:1000> : <EOL> self . matrices = [ ] <EOL> for i in range ( nrepeats ) : <EOL> M = np . random . randn ( * shape ) <EOL> self . matrices . append ( M ) <EOL> else : <EOL> if solver == '<STR_LIT>' : <EOL> raise NotImplementedError ( ) <EOL> max_nnz = <NUM_LIT> <EOL> nrepeats = <NUM_LIT:1> <EOL> self . matrices = [ ] <EOL> for i in range ( nrepeats ) : <EOL> M = scipy . sparse . rand ( shape [ <NUM_LIT:0> ] , shape [ <NUM_LIT:1> ] , min ( max_nnz / ( shape [ <NUM_LIT:0> ] * shape [ <NUM_LIT:1> ] ) , <NUM_LIT> ) ) <EOL> self . matrices . append ( M ) <EOL> def time_onenormest ( self , n , solver ) : <EOL> if solver == '<STR_LIT>' : <EOL> for M in self . matrices : <EOL> M . dot ( M ) <EOL> scipy . sparse . linalg . matfuncs . _onenorm ( M ) <EOL> elif solver == '<STR_LIT>' : <EOL> for M in self . matrices : <EOL> scipy . sparse . linalg . matfuncs . _onenormest_matrix_power ( M , <NUM_LIT:2> ) </s>
