Advertisement
Guest User

Untitled

a guest
May 31st, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. class ctype_csr_mat(object):
  2. def __init__(self, arr_in):
  3. self.csr = spsp.csr_matrix(arr_in)
  4. c_type = c_float
  5. dtype = np.single
  6.  
  7. self.csr.data.astype(dtype)
  8.  
  9. self.c_data = self.csr.data.ctypes.data_as(POINTER(c_type)) #*self.csr.data.size
  10.  
  11. def show(self, indent=4):
  12. sp = ' '*indent
  13. to_print = [ self.c_data[0:self.csr.data.size]]
  14. name = ['c_data']
  15. for i in range(1):
  16. print sp + name[i] + ': ' + str(to_print[i])
  17. def test():
  18. # Make Test Data
  19. Ao = [[1,0,0],
  20. [1,1,1],
  21. [0,0,1]]
  22. AA = np.array(Ao, dtype=np.single) # save the original matrix
  23. A = ctype_csr_mat(Ao)
  24. A.show()
  25.  
  26. test()
  27.  
  28. c_data:
  29. [1.401298464324817e-45,
  30. 0.0,
  31. 1.401298464324817e-45,
  32. 0.0,
  33. 1.401298464324817e-45]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement