(dok)
return [A, JA, IA, shape]
Converts a sparse matrix to Compressed Sparse Row (CSR) format.

    Parameters
    ==========

    A : contains non-zero elements sorted by key (row, column)
    JA : JA[i] is the column corresponding to A[i]
    IA : IA[i] contains the index in A for the first non-zero element
        of row[i]. Thus IA[i+1] - IA[i] gives number of non-zero
        elements row[i]. The length of IA is always 1 more than the
        number of rows in the matrix.
Converts a sparse matrix to Compressed Sparse Row (CSR) format.
Converts a sparse matrix to Compressed Sparse Row ( CSR ) format .
def _doktocsr(dok):
    """Converts a sparse matrix to Compressed Sparse Row (CSR) format.

    Parameters
    ==========

    A : contains non-zero elements sorted by key (row, column)
    JA : JA[i] is the column corresponding to A[i]
    IA : IA[i] contains the index in A for the first non-zero element
        of row[i]. Thus IA[i+1] - IA[i] gives number of non-zero
        elements row[i]. The length of IA is always 1 more than the
        number of rows in the matrix.
    """
    row, JA, A = [list(i) for i in zip(*dok.row_list())]
    IA = [0]*((row[0] if row else 0) + 1)
    for i, r in enumerate(row):
        IA.extend([i]*(r - row[i - 1]))  # if i = 0 nothing is extended
    IA.extend([len(A)]*(dok.rows - len(IA) + 1))
    shape = [dok.rows, dok.cols]
    return [A, JA, IA, shape]
def _doktocsr ( dok ) : row , JA , A = [ list ( i ) for i in zip ( * dok . row_list ( ) ) ] IA = [ 0 ] * ( ( row [ 0 ] if row else 0 ) + 1 ) for i , r in enumerate ( row ) : IA . extend ( [ i ] * ( r - row [ i - 1 ] ) ) # if i = 0 nothing is extended IA . extend ( [ len ( A ) ] * ( dok . rows - len ( IA ) + 1 ) ) shape = [ dok . rows , dok . cols ] return [ A , JA , IA , shape ]