
Orbital library  
PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
public interface Tensor
Represents a tensor t∈R^{n0×n1×…×nr1} of dimensions n_{0}×n_{1}×…×n_{r1} and rank r.
If you intend to use mutable arithmetic elements, note the discussion of
mutations per reference vs. explicit cloning in set(int[],Arithmetic)
which generally holds for all operations that set component values.
Also note that some few methods will change its instance and explicitly return this
to allow chaining of structural changes,
whilst arithmetic methods will leave a tensor unchanged but return a modified version.
Refer to the documentation of the individual methods for details.
ValueFactory.tensor(Arithmetic[])
,
ValueFactory.tensor(Arithmetic[][])
,
ValueFactory.tensor(Arithmetic[][][])
,
ValueFactory.tensor(Object)
Field Summary 

Fields inherited from interface orbital.math.Arithmetic 

numerical 
Method Summary  

Tensor 
add(Tensor b)
Adds two tensors returning a tensor. 
java.lang.Object 
clone()

int[] 
dimensions()
Returns the dimensions of the tensor. 
java.util.Iterator 
entries()
Returns an iterator over our (relevant) entries (index, coefficient)pairs. 
Arithmetic 
get(int[] i)
Get the component specified by index. 
java.util.Iterator 
indices()
Returns an iterator over the (relevant) indices. 
java.util.ListIterator 
iterator()
Returns an iterator over all components. 
Tensor 
multiply(Tensor b)
Inner product of a tensor with a tensor returning a tensor. 
int 
rank()
Get the rank of the tensor. 
void 
set(int[] i,
Arithmetic vi)
Sets the component specified by index. 
void 
setSubTensor(int level,
int index,
Tensor part)
Sets a part of lesser rank in this tensor. 
Tensor 
subTensor(int[] i1,
int[] i2)
Get a subtensor view ranging (i1:i2) inclusive. 
Tensor 
subTensor(int level,
int index)
Get a view on a part of the tensor of a lesser rank. 
Tensor 
subTensorTransposed(int[] permutation)
Returns a view on this tensor transposed. 
Tensor 
subtract(Tensor b)
Subtracts two tensors returning a tensor. 
Tensor 
tensor(Tensor b)
Tensor product of a tensor with a tensor returning a tensor. 
Methods inherited from interface orbital.math.Arithmetic 

add, divide, equals, inverse, isOne, isZero, minus, multiply, one, power, scale, subtract, toString, valueFactory, zero 
Methods inherited from interface orbital.math.Normed 

norm 
Method Detail 

java.lang.Object clone()
int rank()
Matrix.linearRank()
int[] dimensions()
If n_{0}×n_{1}×…×n_{r1} are the dimensions of this tensor of rank r, then all (valid) indices i∈N^{r} to this tensor satisfy ∀k i_{k}∈{0,…,n_{k}1}.
Arithmetic get(int[] i)
Of course, this method only has a meaning for tensors of free modules like vector spaces.
i
 the index i of the component value to get.
void set(int[] i, Arithmetic vi) throws java.lang.UnsupportedOperationException
Of course, this method only has a meaning for tensors of free modules like vector spaces.
Depending upon the implementation, the value vi might be kept per reference, if possible. However, whether it is kept per reference is a matter of performance and subject to free interpretation by the implementation class. So if vi is mutable, and a tensor implementation decides to keep it per reference, any modifications of vi would also appear in that tensor, rendering it useless. Since every implementation is allowed to choose the tensor's internal data representation freely, you should not rely on such behaviour of mutable arithmetic objects to provoke inner state changes. Instead you should carefully avoid setting a value by reference without cloning, if you intend to change its state, afterwards. Explicitly cloning vi prior to setting it as an element of this tensor is always safe (provided that you do not keep additional references to it). If, however, vi is immutable (which should be the usual case), no such sources of mistakes exist.
i
 the index i of the component value to set.vi
 the value to set for the component v_{i} at position i.
java.lang.UnsupportedOperationException
 if this tensor is constant and does not allow modifications.java.util.ListIterator iterator()
Note: the list iterator returned is not required to support
ListIterator.nextIndex()
and ListIterator.previousIndex()
,
or ListIterator.add(Object)
and ListIterator.remove()
,
and won't usually do so. The reason is that onedimensional indices are meaningless
for tensors of rank r>1 and that adding a single component to a tensor is not allowed
as it would destroy its rectangular form.
Nevertheless, vectors (rank 1) may support those operations.
java.util.Iterator indices()
The order of this iterator is not generally defined, but should be deterministic. Particularly, the iterator may  but need not  be restricted to occurring indices with coefficients ≠0.
java.util.Iterator entries()
The order of this iterator is not generally defined, but should be deterministic. Particularly, the iterator may  but need not  be restricted to occurring indices with coefficients ≠0.
Tensor subTensor(int[] i1, int[] i2)
The resulting tensor is a (sub)view of this tensor. Therefore, the returned tensor is backed by this tensor, so changes in the returned tensor are reflected in this tensor, and viceversa.
The semantics of the tensor returned by this method becomes undefined if the backing tensor (i.e., this object) is structurally modified in any way other than via the returned tensor. (Structural modifications are those that change the dimensions, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)
The resulting tensor is structurally unmodifiable
in order to prevent it from inducing undefined behaviour on its backing tensor.
Query operations on the returned tensor "read through" to this object,
and attempts to structurally modify the returned vector, whether direct or via its iterator,
result in an UnsupportedOperationException
.
However, setting single components will "write through" to the this object.
t_{(i1:i2)} = (m_{l})_{l∈{l∈Nr ¦ ∀k i1[k]≤l[k]≤i2[k]}} 
Tensor subTensor(int level, int index)
The returned tensor is a structurally unmodifiable view.
level
 the level l of indices to fix for this view.index
 the index c_{l} of the tensor part view at the levelth index.
setSubTensor(int,int,Tensor)
,
Functionals.bindFirst(orbital.logic.functor.BinaryFunction, Object)
,
Functionals.bindSecond(orbital.logic.functor.BinaryFunction, Object)
void setSubTensor(int level, int index, Tensor part)
subTensor(int,int)
Tensor subTensorTransposed(int[] permutation)
The returned tensor is a view.
permutation
 the mapping table of a permutation σ∈S_{rank()}
mapping i↦permutation[i] for permuting the indices.
Tensor add(Tensor b)
Tensor subtract(Tensor b)
Tensor multiply(Tensor b)
·  R^{n0×…×nr1×h}×R^{h×m0×…×ms1}  →  R^{n0×…×nr1×h}×R^{h×m0×…×ms1} 
((a_{i0,…,ir1,ir})_{i0,…,ir1,ir} , (b_{j1,j0,…,js1})_{j1,j0,…,js1})  ↦  (∑_{ν=0}^{h1} a_{i0,…,ir1,ν}⋅b_{ν,j0,…,js1})_{i0,…,ir1,j0,…,js1} 
Tensor tensor(Tensor b)
⊗  R^{n0×…×nr1}×R^{m0×…×ms1}  →  R^{n0×…×nr1×m0×…×ms1} 
((a_{i0,…,ir1})_{i0,…,ir1} , (b_{j0,…,js1})_{j0,…,js1}) =(a,b) 
↦  (a_{i0,…,ir1}⋅b_{j0,…,js1})_{i0,…,ir1,j0,…,js1} =̂ (a_{i0,…,ir1}·b)_{i0,…,ir1} 
inner product
which therefore plays the role of
the default (though partial) ring multiplication.

Orbital library 1.3.0: 11 Apr 2009 

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 