Exemple #1
0
 def __init__(self,size=0,dim=0,ldb=None):
     self._inverted=False
     self._original=None
     if ldb:
         self.ldb=ldb
     else:
         self.ldb = sa.listdb_create(size,dim)
Exemple #2
0
def ndarray_to_listdb(arr):
    ldb = sa.listdb_create(arr.shape[0], arr.shape[1])
    for i,row in enumerate(arr):
        for j,item in enumerate(row):
            if item != 0:
                ldb.push(int(i), int(j), int(round(item * 100000000)))
    return SMH(ldb=ldb)
Exemple #3
0
def csr_to_listdb(csr):
    ldb = sa.listdb_create(csr.shape[0], csr.shape[1])
    coo = csr.tocoo()    
    for i,j,v in itertools.izip(coo.row, coo.col, coo.data):
        ldb.push(int(i), int(j), int(round(v * 100000000)))

    return SMH(ldb=ldb)
Exemple #4
0
def ndarray_to_listdb(arr):
    """
    Converts a numpy multidimensional array to a ListDB structure
    """
    ldb = sa.listdb_create(arr.shape[0], arr.shape[1])
    for i,row in enumerate(arr):
        for j,v in enumerate(row):
            if v != 0:
                ldb.push(int(i), int(j), int(round(v)))
    return ListDB(ldb=ldb)
Exemple #5
0
def csr_to_listdb(csr):
    """
    Converts a Compressed Sparse Row (CSR) matrix to a ListDB structure
    """
    ldb = sa.listdb_create(csr.shape[0], csr.shape[1])
    coo = csr.tocoo()    
    for i,j,v in itertools.izip(coo.row, coo.col, coo.data):
        ldb.push(int(i), int(j), int(round(v)))

    return ListDB(ldb=ldb)
Exemple #6
0
def ndarray_to_listdb(arr):
    """
    Converts a numpy multidimensional array to a ListDB structure
    """
    ldb = sa.listdb_create(arr.shape[0], arr.shape[1])
    for i,row in enumerate(arr):
        for j,v in enumerate(row):
            if v != 0:
                ldb.push(int(i), int(j), int(round(v)))
    return ListDB(ldb=ldb)
Exemple #7
0
def csr_to_listdb(csr):
    """
    Converts a Compressed Sparse Row (CSR) matrix to a ListDB structure
    """
    ldb = sa.listdb_create(csr.shape[0], csr.shape[1])
    coo = csr.tocoo()    
    for i,j,v in itertools.izip(coo.row, coo.col, coo.data):
        ldb.push(int(i), int(j), int(round(v)))

    return ListDB(ldb=ldb)
Exemple #8
0
 def __init__(self, size = 0, dim = 0, ldb = None):
     """
     Initializes class with ListDB structure
     """
     if ldb:
         self.ldb=ldb
     elif size == 0 and dim == 0:
         self.ldb = sa.ListDB()
         sa.listdb_init(self.ldb)
     else:
         self.ldb = sa.listdb_create(size, dim)
Exemple #9
0
 def __init__(self, size = 0, dim = 0, ldb = None):
     """
     Initializes class with ListDB structure
     """
     if ldb:
         self.ldb=ldb
     elif size == 0 and dim == 0:
         self.ldb = sa.ListDB()
         sa.listdb_init(self.ldb)
     else:
         self.ldb = sa.listdb_create(size, dim)