paratec::tensor - simple tensors for use with paratec
Implements tensors
Creates a tensor object. Overloads arithmetic operators so you can easily do arithmetic, and also allows you to transpose and calculate the inverse easily. It is heavily unoptimized, but how long can it take to deal with a 3x3 matrix?
use paratec::tensor;
Makes the methods and overloaded operators of this module available to your program.
$input = new paratec::tensor;
Create a new identity tensor.
$input = new paratec::tensor(1,2,3);
Create a diagonal tensor with elements 1, 2 and 3 along the
diagonal.
$input = new paratec::tensor($vector);
Create a diagonal tensor with $vector elements along the diagonal.
$input = new paratec::tensor($vector1, $vector2);
Create a tensor having the value of the tensor product of $vector1
and $vector2.
$input = new paratec::tensor($vector1, $vector2, $vector3);
Create a tensor with row vectors corresponding to $vector1, $vector2
and $vector3.
$volume = det($tensor);
Calculate the determinant of a given tensor.
All the ordinary arithmetic operators work as you would expect on tensors and vectors.
$inverse = 1/$tensor;
Calculate the inverse of a given tensor.
$newvector = $oldvector/$tensor;
Multiply a vector by the inverse of a tensor. This works out such that the following is true:
$vector == $tensor*$vector/$tensor;
$tensortensor = $oldtensor/$tensor;
Multiply a tensor by the inverse of a tensor. One could either multiply on the left or on the right. I multiply with the inverse on the left, such that the following is true:
$A == $B*$A/$B;
paratec::vector.
This man page documents paratec::tensor version 0.1.
David Roundy <droundy@physics.berkeley.edu>.
Thanks to Gilles Santi, for giving me the idea of writing this.
Copyright (c) 2000, David Roundy. All rights reserved.
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.