Did I find the right examples for you? yes no

# dia.dia_matrix

All Samples(11)  |  Call(6)  |  Derive(0)  |  Import(5)

```from .base import spmatrix, isspmatrix, SparseEfficiencyWarning
from .data import _data_matrix, _minmax_mixin
from .dia import dia_matrix
from . import sparsetools
from .sputils import upcast, upcast_char, to_native, isdense, isshape, \
```
```            # Row vector times matrix. other is a row.
elif other.shape[0] == 1 and self.shape[1] == other.shape[1]:
other = dia_matrix((other.toarray().ravel(), [0]),
shape=(other.shape[1], other.shape[1]))
return self._mul_sparse_matrix(other)
# self is a row.
elif self.shape[0] == 1 and self.shape[1] == other.shape[1]:
copy = dia_matrix((self.toarray().ravel(), [0]),
```
```            # Column vector times matrix. other is a column.
elif other.shape[1] == 1 and self.shape[0] == other.shape[0]:
other = dia_matrix((other.toarray().ravel(), [0]),
shape=(other.shape[0], other.shape[0]))
return other._mul_sparse_matrix(self)
# self is a column.
elif self.shape[1] == 1 and self.shape[0] == other.shape[0]:
copy = dia_matrix((self.toarray().ravel(), [0]),
```

```    def todia(self):
from .dia import dia_matrix

ks = self.col - self.row  # the diagonal for each nonzero
diags = np.unique(ks)
```
```            data[np.searchsorted(diags,ks), self.col] = self.data

return dia_matrix((data,diags), shape=self.shape)

def todok(self):
```

```    def todia(self):
from dia import dia_matrix

ks = self.col - self.row  #the diagonal for each nonzero
diags = np.unique(ks)
```
```        data[ np.searchsorted(diags,ks), self.col ] = self.data

return dia_matrix((data,diags), shape=self.shape)

def todok(self):
```

```from .coo import coo_matrix
from .lil import lil_matrix
from .dia import dia_matrix

from .base import issparse
```

```from coo import coo_matrix