<s> import numpy <EOL> import logging <EOL> import sys <EOL> import scipy . sparse <EOL> from cvxopt import spmatrix <EOL> from pysparse import spmatrix <EOL> from apgl . util import * <EOL> logging . basicConfig ( stream = sys . stdout , level = logging . INFO ) <EOL> class SparseMatrixProfile ( object ) : <EOL> def __init__ ( self ) : <EOL> self . n = <NUM_LIT> <EOL> self . m = <NUM_LIT> <EOL> def profileCvxoptSparseAssign ( self ) : <EOL> W = spmatrix ( <NUM_LIT:0> , [ ] , [ ] , size = ( self . n , self . n ) ) <EOL> V = numpy . random . randint ( <NUM_LIT:0> , self . n , ( self . m , <NUM_LIT:2> ) ) <EOL> u = numpy . random . rand ( self . m ) <EOL> def runAdd ( ) : <EOL> for i in range ( self . m ) : <EOL> W [ int ( V [ i , <NUM_LIT:0> ] ) , int ( V [ i , <NUM_LIT:1> ] ) ] = u [ i ] <EOL> ProfileUtils . profile ( '<STR_LIT>' , globals ( ) , locals ( ) ) <EOL> def profileScipySparseAssign ( self ) : <EOL> W = scipy . sparse . lil_matrix ( ( self . n , self . n ) ) <EOL> V = numpy . random . randint ( <NUM_LIT:0> , self . n , ( self . m , <NUM_LIT:2> ) ) <EOL> u = numpy . random . rand ( self . m ) <EOL> def runAdd ( ) : <EOL> for i in range ( self . m ) : <EOL> W [ V [ i , <NUM_LIT:0> ] , V [ i , <NUM_LIT:1> ] ] = u [ i ] <EOL> ProfileUtils . profile ( '<STR_LIT>' , globals ( ) , locals ( ) ) <EOL> def profilePySparseAssign ( self ) : <EOL> W = spmatrix . ll_mat ( self . n , self . n ) <EOL> V = numpy . random . randint ( <NUM_LIT:0> , self . n , ( self . m , <NUM_LIT:2> ) ) <EOL> u = numpy . random . rand ( self . m ) <EOL> def runAdd ( ) : <EOL> for i in range ( self . m ) : <EOL> W [ int ( V [ i , <NUM_LIT:0> ] ) , int ( V [ i , <NUM_LIT:1> ] ) ] = u [ i ] <EOL> ProfileUtils . profile ( '<STR_LIT>' , globals ( ) , locals ( ) ) <EOL> def profilePySparseKeys ( self ) : <EOL> """<STR_LIT>""" <EOL> W = spmatrix . ll_mat ( self . n , self . n ) <EOL> V = numpy . random . randint ( <NUM_LIT:0> , self . n , ( self . m , <NUM_LIT:2> ) ) <EOL> u = numpy . random . rand ( self . m ) <EOL> for i in range ( self . m ) : <EOL> W [ int ( V [ i , <NUM_LIT:0> ] ) , int ( V [ i , <NUM_LIT:1> ] ) ] = u [ i ] <EOL> def runKeys ( ) : <EOL> for i in range ( self . m ) : <EOL> for j in range ( self . n ) : <EOL> neighbours = W [ j , : ] <EOL> print ( "<STR_LIT>" ) <EOL> runKeys ( ) <EOL> profiler = SparseMatrixProfile ( ) <EOL> profiler . profilePySparseKeys ( ) </s>
