Lines Matching +refs:data +refs:shape
47 def __init__(self, args=None, shape=None, dtype=None, copy=False): argument
49 if shape is None:
51 self.data = np.array([], dtype=complex)
53 self.indptr = np.zeros(shape[0]+1, dtype=np.int32)
54 self._shape = tuple(int(s) for s in shape)
57 if args[0].shape[0] and args[0].dtype != complex:
59 if args[1].shape[0] and args[1].dtype != np.int32:
61 if args[2].shape[0] and args[1].dtype != np.int32:
63 self.data = np.array(args[0], dtype=complex, copy=copy)
66 if shape is None:
69 self._shape = tuple(int(s) for s in shape)
89 indptr = np.empty(self.indptr.shape, dtype=idx_dtype)
94 data = np.empty(maxnnz, dtype=np.bool_)
96 data = np.empty(maxnnz, dtype=upcast(self.dtype, other.dtype))
98 fn(self.shape[0], self.shape[1],
101 self.data,
104 other.data,
105 indptr, indices, data)
109 data = data[:actual_nnz]
113 data = data.copy()
115 A = fast_csr_matrix((data, indices, indptr), dtype=data.dtype, shape=self.shape)
117 A = csr_matrix((data, indices, indptr), dtype=data.dtype, shape=self.shape)
129 if self.shape == other.shape:
134 elif other.shape == (1,1):
136 elif self.shape == (1,1):
139 elif self.shape[1] == other.shape[0] and self.shape[1] == 1:
141 elif self.shape[0] == other.shape[1] and self.shape[0] == 1:
144 elif other.shape[0] == 1 and self.shape[1] == other.shape[1]:
146 shape=(other.shape[1], other.shape[1]))
149 elif self.shape[0] == 1 and self.shape[1] == other.shape[1]:
151 shape=(self.shape[1], self.shape[1]))
154 elif other.shape[1] == 1 and self.shape[0] == other.shape[0]:
156 shape=(other.shape[0], other.shape[0]))
159 elif self.shape[1] == 1 and self.shape[0] == other.shape[0]:
161 shape=(self.shape[0], self.shape[0]))
167 if self.shape == other.shape:
169 ret.data = np.multiply(ret.data, other[ret.row, ret.col]
183 M, _ = self.shape
184 _, N = other.shape
225 data = np.empty(nnz, dtype=upcast(self.dtype, other.dtype))
233 self.data,
236 other.data,
237 indptr, indices, data)
238 A = csr_matrix((data, indices, indptr), shape=(M, N))
246 res = self._with_data(op(self.data, other), copy=True)
254 return csr_matrix(self.shape, dtype=np.bool_)
259 all_true = _all_true(self.shape)
272 if self.shape != other.shape:
277 all_true = _all_true(self.shape)
288 all_true = _all_true(self.shape)
293 all_true = _all_true(self.shape)
304 if self.shape != other.shape:
319 other_arr = np.empty(self.shape, dtype=np.result_type(other))
331 if self.shape != other.shape:
340 all_true = _all_true(self.shape)
346 def _with_data(self,data,copy=True): argument
353 data = np.asarray(data, dtype=complex)
355 return fast_csr_matrix((data,self.indices.copy(),self.indptr.copy()),
356 shape=self.shape,dtype=data.dtype)
358 return fast_csr_matrix((data,self.indices,self.indptr),
359 shape=self.shape,dtype=data.dtype)
392 return fast_csr_matrix((A.data,A.indices,A.indptr),
393 shape=A.shape,copy=copy)
402 data = np.ones(N, dtype=complex)
406 return fast_csr_matrix((data,ind,ptr),shape=(N,N))
412 def _all_true(shape): argument
413 A = csr_matrix((np.ones(np.prod(shape), dtype=np.bool_),
414 np.tile(np.arange(shape[1],dtype=np.int32),shape[0]),
415 np.arange(0,np.prod(shape)+1,shape[1],dtype=np.int32)),
416 shape=shape)