Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.jstacs.algorithms.graphs.tensor
Class SymmetricTensor

    java.lang.Object
      de.jstacs.algorithms.graphs.tensor.Tensor
          de.jstacs.algorithms.graphs.tensor.SymmetricTensor

    public class SymmetricTensor

extends Tensor

This class can be used for `Tensor`s with a special symmetry property. This property states that for a given target node and for all permutations of parent nodes the edge weight is constant. This is very helpful to save storage and time in some algorithms. Since it is very useful it also enables you to use this class if your tensor does not fulfill this property. For that case the tensor saves only the maximum edge weight and the permutation of the parent nodes.

Author:
  Jens Keilwagen
See Also:
  `Tensor`, `AsymmetricTensor`

Field Summary

Fields inherited from class de.jstacs.algorithms.graphs.tensor.Tensor
`L, order, powers`

Constructor Summary
`SymmetricTensor(AsymmetricTensor asym_tensor)` This constructor creates and checks a filled asymmetric tensor from an `AsymmetricTensor` instance.
`SymmetricTensor(double[][][] asym_tensor, int N, byte k)` This constructor creates and checks a filled asymmetric tensor with given dimension.
`SymmetricTensor(int n, byte k)` This constructor creates an empty symmetric tensor with given dimension.
`SymmetricTensor(SymmetricTensor[] parts, double[] weights)` The constructor can be used creating a new `SymmetricTensor` as weighted sum of `SymmetricTensor`s.

Method Summary
`double` | `getBest(int child, int[] par, byte k)` Returns the maximal weight which can be reached for an edge from `k` nodes from the (encoded) set `par` to the node `child`.
`int[]` | `getEdgeFromIndex(int idx, int k)` This method decodes an index in an edge.
`int[]` | `getMaximalEdgeFor(byte k, int child, int... parents)` Returns the edge `permute(parents[0],...`
`double` | `getRootValue(int child)` Returns the value for `child` as root.
`int` | `getTrueIndexForLastGetBest()` Returns the edge from `getBest(int, int[], byte)` in an encoded index.
`double` | `getValue(byte k, int child, int... parents)` Returns the value for the edge `parents[0],...`
`void` | `resetValue(byte k, int child, int... parents)` Sets the value for the edge `parents -> child` to `Double.NEGATIVE_INFTINITY`.
`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 if it is bigger than the current value and keeps the parents information.

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

### SymmetricTensor

    public SymmetricTensor(int n,
                           byte k)

  This constructor creates an empty symmetric tensor with given dimension.

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

### SymmetricTensor

    public SymmetricTensor(SymmetricTensor[] parts,
                           double[] weights)
                    throws IllegalArgumentException

  The constructor can be used creating a new `SymmetricTensor` as weighted sum of `SymmetricTensor`s.

  Parameters:
    `parts` - the `SymmetricTensor`s
    `weights` - the weight for each `SymmetricTensor`
  Throws:
    `IllegalArgumentException` - if something went wrong
  See Also:
    `SymmetricTensor(int, byte)`

### SymmetricTensor

    public SymmetricTensor(AsymmetricTensor asym_tensor)

  This constructor creates and checks a filled asymmetric tensor from an `AsymmetricTensor` instance.

  Parameters:
    `asym_tensor` - the asymmetric instance
  See Also:
    `AsymmetricTensor`, `SymmetricTensor(double[][][], int, byte)`

### SymmetricTensor

    public SymmetricTensor(double[][][] asym_tensor,
                           int N,
                           byte k)

  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
  See Also:
    `SymmetricTensor(int, byte)`

Method Detail

### getBest

    public double getBest(int child,
                          int[] par,
                          byte k)

  Returns the maximal weight which can be reached for an edge from `k` nodes from the (encoded) set `par` to the node `child`.

  Parameters:
    `child` - the target node
    `par` - an encoded set, elements are sorted and for all elements `e >= child` the real value is `(e+1)`, e.g. `child = 3` and possible parents `= {5,2,0,6,1}` then `par = {0,1,2,4,5}`
    `k` - the number of parents used from par
  Returns:
    the best (=maximal) weight

### getEdgeFromIndex

    public int[] getEdgeFromIndex(int idx,
                                  int k)

  This method decodes an index in an edge.

  Parameters:
    `idx` - the encoded index
    `k` - the order
  Returns:
    the edge

### 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

### getTrueIndexForLastGetBest

    public int getTrueIndexForLastGetBest()

  Returns the edge from `getBest(int, int[], byte)` in an encoded index.

  Returns:
    the edge from `getBest(int, int[], byte)` in an encoded index
  See Also:
    `getBest(int, int[], byte)`

### 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)

  Sets the value for the edge `parents -> child` to `Double.NEGATIVE_INFTINITY`.

  Specified by:
    `resetValue` in class `Tensor`
  Parameters:
    `k` - the order
    `child` - the index of the child node
    `parents` - the indices of the parent nodes

### 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)

  Sets the value if it is bigger than the current value and keeps the parents information.

  Specified by:
    `setValue` in class `Tensor`
  Parameters:
    `k` - the order
    `val` - the value to be set
    `child` - the index of the child node
    `parents` - the indices of the parent nodes

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD