Did I find the right examples for you? yes no      Crawl my project      Python Jobs

# matutil.eye

All Samples(3)  |  Call(2)  |  Derive(0)  |  Import(1)
```Creates an nxn unit matirx

The unit matrix is a diagonal matrix whose diagonal is composed of
identity elements.  For example, unit_matrix(3) returns the matrix

1 0 0
0 1 0
0 0 1
```

```        def unit_matrix(n):
"""Creates an nxn unit matirx

The unit matrix is a diagonal matrix whose diagonal is composed of
identity elements.  For example, unit_matrix(3) returns the matrix

1 0 0
0 1 0
0 0 1
"""
m = Matrix(n)
for i in xrange(m.rows()):
m[(i,i)] = m.identity_element
return m
```

```
import matutil
from matutil import E_X, E_Y, Matrix, scale_matrix, rotation_matrix, eye, translation_matrix

TRANSFORM_MATRIX_PAT = r"matrix\(([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)\)"
```
```    def __init__(self, matrix=None):
if not matrix:
matrix = eye(3)
self._matrix = matrix

```
```        except:
pass
return Transform(eye(3))

def calc_scale(base_width, base_height, width, height):
```