Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)