de.jstacs.algorithms.graphs.tensor
Class SubTensor

java.lang.Object
  extended by de.jstacs.algorithms.graphs.tensor.Tensor
      extended by de.jstacs.algorithms.graphs.tensor.SubTensor

public class SubTensor
extends Tensor

This Tensor can be used to extract or use only a part of a complete Tensor.

Author:
Jens Keilwagen

Field Summary
 
Fields inherited from class de.jstacs.algorithms.graphs.tensor.Tensor
L, order, powers
 
Constructor Summary
SubTensor(Tensor t, int offset, int length)
          This constructor creates a SubTensor using the Tensor t for the nodes offset, offset+1, ..., offset+length-1.
 
Method Summary
 int[] getMaximalEdgeFor(byte k, int child, int... parents)
          Returns the edge permute(parents[0],...,parents[k-1]) -> child that maximizes the score.
 double getRootValue(int child)
          Returns the value for child as root.
 double getValue(byte k, int child, int... parents)
          Returns the value for the edge parents[0],...,parents[k-1] -> child.
 void resetValue(byte k, int child, int... parents)
          Sets the value for the edge parents[0],...,parents[k-1] -> child to Double.NEGATIVE_INFINITY.
 void setRootValue(int child, double val)
          Sets the value val for the root node child.
 void setValue(byte k, double val, int child, int... parents)
          Sets the value for the edge parents[0],...,parents[k-1] -> child.
 
Methods inherited from class de.jstacs.algorithms.graphs.tensor.Tensor
getAsymIndex, getNumberOfNodes, getOrder, readTensorFromFile, toDouble3DArray, writeTensorToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SubTensor

public SubTensor(Tensor t,
                 int offset,
                 int length)
This constructor creates a SubTensor using the Tensor t for the nodes offset, offset+1, ..., offset+length-1.

Parameters:
t - the underlying Tensor
offset - the offset in the nodes, i.e., all nodes smaller than offset will not be used
length - the number of nodes which will be used starting at offset
Method Detail

getMaximalEdgeFor

public int[] getMaximalEdgeFor(byte k,
                               int child,
                               int... parents)
Description copied from class: Tensor
Returns the edge permute(parents[0],...,parents[k-1]) -> child that maximizes the score.

Specified by:
getMaximalEdgeFor in class Tensor
Parameters:
k - the number of parents to be used
child - the child node
parents - the parent nodes (only the first k will be used)
Returns:
the edge permute(parents[0],...,parents[k-1]) -> child that maximizes the score

getRootValue

public double getRootValue(int child)
Description copied from class: Tensor
Returns the value for child as root.

Specified by:
getRootValue in class Tensor
Parameters:
child - the name of the node
Returns:
the value for the node

getValue

public double getValue(byte k,
                       int child,
                       int... parents)
Description copied from class: Tensor
Returns the value for the edge parents[0],...,parents[k-1] -> child.

Specified by:
getValue in class Tensor
Parameters:
k - the number of parents to be used
child - the child node
parents - the parent nodes (only the first k will be used)
Returns:
the value for the edge parents[0],...,parents[k-1] -> child

resetValue

public void resetValue(byte k,
                       int child,
                       int... parents)
Description copied from class: Tensor
Sets the value for the edge parents[0],...,parents[k-1] -> child to Double.NEGATIVE_INFINITY.

Specified by:
resetValue in class Tensor
Parameters:
k - the number of parents to be used
child - the child node
parents - the parent nodes (only the first k will be used)

setRootValue

public void setRootValue(int child,
                         double val)
Description copied from class: Tensor
Sets the value val for the root node child.

Specified by:
setRootValue in class Tensor
Parameters:
child - the name of the node
val - the value for the node

setValue

public void setValue(byte k,
                     double val,
                     int child,
                     int... parents)
Description copied from class: Tensor
Sets the value for the edge parents[0],...,parents[k-1] -> child.

Specified by:
setValue in class Tensor
Parameters:
k - the number of parents to be used
val - the new value
child - the child node
parents - the parent nodes (only the first k will be used)