Path: | rdoc/tensor.rdoc |
Last Update: | Sun Nov 14 22:53:48 +0000 2010 |
The tensor library is developed by J. Burguet and distributed as an add-on package of GSL. See here and here.
Create a tensor of rank rank and dimension dimention.
Creates a tensor of rank rank and dimension dimention, and initializes all the elements to zero.
Create a tensor copying the existing tensor tensor.
Copies the tensor src to another dest. The two tensors must have the same shape.
Exchanges the elements of the tensor a and b.
Sets all the element of the tensor self to zero.
Sets all the element of the tensor self to x.
Sets the element of the given indices to x.
Returns the tensor element. If the number of indices given is smaller than the rank of the tensor, the method GSL::Tensor#subtensor is called.
Ex:
>> t = Tensor.new(2, 3) => #<GSL::Tensor:0x762ae8> >> t.set(1, 2, 2, 123) => #<GSL::Tensor:0x762ae8> >> t.get(1, 2, 2) => 123.0 >> t[0, 0, 2] = 456 => 456 >> t[0, 0, 2] => 456.0
Return a subtensor.
Ex:
>> require("gsl") => true >> t = Vector[1..125].to_tensor(3, 5) => GSL::Tensor: [ 1.000e+00 2.000e+00 3.000e+00 4.000e+00 5.000e+00 6.000e+00 7.000e+00 ... ] >> t[0] => GSL::Tensor::View: [ 1.000e+00 2.000e+00 3.000e+00 4.000e+00 5.000e+00 6.000e+00 7.000e+00 8.000e+00 9.000e+00 1.000e+01 1.100e+01 1.200e+01 1.300e+01 1.400e+01 1.500e+01 1.600e+01 1.700e+01 1.800e+01 1.900e+01 2.000e+01 2.100e+01 2.200e+01 2.300e+01 2.400e+01 2.500e+01 ] >> t[0,2] => GSL::Tensor::View: [ 1.100e+01 1.200e+01 1.300e+01 1.400e+01 1.500e+01 ] >> t[3,1] => GSL::Tensor::View: [ 8.100e+01 8.200e+01 8.300e+01 8.400e+01 8.500e+01 ] >> t[1][2] => GSL::Tensor::View: [ 3.600e+01 3.700e+01 3.800e+01 3.900e+01 4.000e+01 ]
Returns the data as GSL::Vector::View.
Creates a new vector from the tensor.
Converts the tensor of rank 1 into a GSL::Vector::View object.
Converts the tensor of rank 2 into a GSL::Matrix::View object.
Creates a new tensor adding two tensors self and b.
Adds the element of tensor b to the elements of self , in-place.
Creates a new tensor subtracting the tensors b from self.
Subtracts the element of tensor b from the elements of self , in-place.
This calculate element-by-element multiplication of self and b, and returns a new tensor.
Multiplies the elements of tensor self to the elements of b , in-place.
This calculate element-by-element division of self and b, and returns a new tensor. Multiplies the elements of tensor b to the elements of self , in-place.
Divides the elements of tensor self to the elements of b , in-place.
Creates a new tensor adding the constant x to the tensor self.
Adds the constant x to the elements of tensor self , in-place.
Creates a new tensor scaling the tensor self by the constant x.
Multiplies the constant x to the elements of tensor self , in-place.
Creates a new tensor adding the constant x to the diagonal elements of the tensor self.
Adds the constant x to the diagonal elements of tensor self , in-place.
Calculate tensorian product of self and b.
Returns true if the tensors have same size and elements equal to absolute accurary eps for all the indices, and false otherwise.
Returns 1 if all the elements of the tensor are zero, and 0 otherwise.
Returns true if all the elements of the tensor are zero, and false otherwise.
Returns the rank
Returns the dimension
Returns the size