Lines Matching +refs:data +refs:shape
8 def _add_at(add_at, x, row, col, data): argument
9 assert data.size > 0
10 last_nz = data.size - (data != 0)[::-1].argmax()
11 add_at(x, (row[:last_nz], col[:last_nz]), data[:last_nz])
43 def __init__(self, data, row, col, shape, order=None, argument
45 if not (1 <= data.ndim <= 2):
47 if not (data.ndim == row.ndim == col.ndim):
49 if len(shape) != 2:
51 if not (shape[0] > 0 and shape[1] > 0):
56 self.data = chainer.Variable(data, requires_grad=requires_grad)
59 self.shape = shape # (row, col)
66 data = self.data
67 if data.ndim == 1:
68 shape = self.shape
69 elif data.ndim == 2:
70 shape = (data.shape[0], *self.shape)
74 xp = data.xp
75 x = xp.zeros(shape, dtype=data.dtype)
77 if data.size > 0:
85 data = data.array
86 if data.ndim == 1:
87 _add_at(add_at, x, row, col, data)
88 elif data.ndim == 2:
89 for i in range(data.shape[0]):
90 _add_at(add_at, x[i], row[i], col[i], data[i])
138 data = xp.zeros((ldnz), dtype=x.dtype)
141 data[:nnz] = x[_row, _col]
144 shape = x.shape
145 return CooMatrix(data, row, col, shape,
149 nb = x.shape[0]
154 data = xp.empty((nb, ldnz), dtype=x.dtype)
159 data[i] = coo.data.data
162 shape = x.shape[1:]
163 return CooMatrix(data, row, col, shape,
193 if row.shape != col.shape:
196 for i in range(row.shape[0]):
205 if _row.shape[0] <= 1:
207 row_diff = xp.zeros(_row.shape, dtype=_row.dtype)
211 col_diff = xp.zeros(_col.shape, dtype=_col.dtype)