Package Scientific :: Package Geometry :: Class Tensor

[frames] | no frames]

# Class Tensor

Tensor in 3D space

Tensors support the usual arithmetic operations ('t1', 't2': tensors, 'v': vector, 's': scalar):

- 't1+t2' (addition)
- 't1-t2' (subtraction)
- 't1*t2' (tensorial (outer) product)
- 't1*v' (contraction with a vector, same as t1.dot(v.asTensor()))
- 's*t1', 't1*s' (multiplication with a scalar)
- 't1/s' (division by a scalar)

The coordinates can be extracted by indexing; a tensor of rank N can be indexed like an array of dimension N.

Tensors are immutable, i.e. their elements cannot be changed.

Tensor elements can be any objects on which the standard arithmetic operations are defined. However, eigenvalue calculation is supported only for float elements.

Instance Methods

__add__(self, other) |

__cmp__(self, other) |

__div__(self, other) |

__getitem__(self, index) |

__init__(self, elements, nocheck=None) |

__len__(self) |

__mul__(self, other) |

__neg__(self) |

__radd__(self, other) |

__rdiv__(self, other) |

__repr__(self) |

__rmul__(self, other) |

__rsub__(self, other) |

__str__(self) |

__sub__(self, other) |

Scientific.Geometry.Vector

asVector(self) Returns: an equivalent vector object |

Tensor

asymmetricalPart(self) Returns: the asymmetrical part of the tensor |

diagonal(self, axis1=0, axis2=1) |

(`Numeric.array`, Tensor)

diagonalization(self) Returns: the eigenvalues of the tensor and a tensor representing the rotation matrix to the diagonal form |

Tensor

dot(self, other) Returns: the contraction with other |

`Numeric.array`

eigenvalues(self) Returns: the eigenvalues of the tensor |

Tensor

inverse(self) Returns: the inverse of the tensor |

Tensor

symmetricalPart(self) Returns: the symmetrical part of the tensor |

type of tensor elements

trace(self, axis1=0, axis2=1) Returns: the trace of the tensor |

Tensor

transpose(self) Returns: the transposed (index reversed) tensor |

Class Variables
| is_tensor = `1`

Method Details

### __init__(self, elements, nocheck=None)
(Constructor)

Parameters:
  - `elements` (`Numeric.array` or `list`) - 2D array or nested list specifying the nine tensor components [[xx, xy, xz], [yx, yy, yz], [zx, zy, zz]]

### asVector(self)

Returns: Scientific.Geometry.Vector
  an equivalent vector object
Raises:
  - `ValueError` - if rank > 1

### asymmetricalPart(self)

Returns: Tensor
  the asymmetrical part of the tensor
Raises:
  - `ValueError` - if rank !=2

### diagonalization(self)

Returns: (`Numeric.array`, Tensor)
  the eigenvalues of the tensor and a tensor representing the rotation matrix to the diagonal form
Raises:
  - `ValueError` - if rank !=2

### dot(self, other)

Returns: Tensor
  the contraction with other

### eigenvalues(self)

Returns: `Numeric.array`
  the eigenvalues of the tensor
Raises:
  - `ValueError` - if rank !=2

### inverse(self)

Returns: Tensor
  the inverse of the tensor
Raises:
  - `ValueError` - if rank !=2

### symmetricalPart(self)

Returns: Tensor
  the symmetrical part of the tensor
Raises:
  - `ValueError` - if rank !=2

### trace(self, axis1=0, axis2=1)

Returns: type of tensor elements
  the trace of the tensor
Raises:
  - `ValueError` - if rank !=2

### transpose(self)

Returns: Tensor
  the transposed (index reversed) tensor