Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ctype_csr_mat(object):
- def __init__(self, arr_in):
- self.csr = spsp.csr_matrix(arr_in)
- c_type = c_float
- dtype = np.single
- self.csr.data.astype(dtype)
- self.c_data = self.csr.data.ctypes.data_as(POINTER(c_type)) #*self.csr.data.size
- def show(self, indent=4):
- sp = ' '*indent
- to_print = [ self.c_data[0:self.csr.data.size]]
- name = ['c_data']
- for i in range(1):
- print sp + name[i] + ': ' + str(to_print[i])
- def test():
- # Make Test Data
- Ao = [[1,0,0],
- [1,1,1],
- [0,0,1]]
- AA = np.array(Ao, dtype=np.single) # save the original matrix
- A = ctype_csr_mat(Ao)
- A.show()
- test()
- c_data:
- [1.401298464324817e-45,
- 0.0,
- 1.401298464324817e-45,
- 0.0,
- 1.401298464324817e-45]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement