de.jstacs.algorithms.graphs.tensor
Class AsymmetricTensor

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

public class AsymmetricTensor
extends Tensor

This class can be used for Tensors which are not symmetric, as opposed to the symmetry defined in SymmetricTensor.

Author:
Jens Keilwagen
See Also:
Tensor, SymmetricTensor

Field Summary
protected  double[][][] tensor
          The internal tensor.
 
Fields inherited from class de.jstacs.algorithms.graphs.tensor.Tensor
L, order, powers
 
Constructor Summary
AsymmetricTensor(double[][][] asym_tensor, int n, byte k)
          This constructor creates and checks a filled asymmetric tensor with given dimension.
AsymmetricTensor(int n, byte k)
          This constructor creates an empty asymmetric tensor with given dimension.
 
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
 

Field Detail

tensor

protected double[][][] tensor
The internal tensor.

Constructor Detail

AsymmetricTensor

public AsymmetricTensor(int n,
                        byte k)
This constructor creates an empty asymmetric tensor with given dimension.

Parameters:
n - the number of nodes
k - the order
See Also:
Tensor.Tensor(int, byte)

AsymmetricTensor

public AsymmetricTensor(double[][][] asym_tensor,
                        int n,
                        byte k)
                 throws IllegalArgumentException
This constructor creates and checks a filled asymmetric tensor with given dimension.

Parameters:
asym_tensor - the tensor weights
n - the number of nodes
k - the order
Throws:
IllegalArgumentException - if n < 0 or k < 1 or the given tensor has a wrong dimension
See Also:
Tensor.Tensor(int, byte)
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

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)

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)