|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.jstacs.algorithms.graphs.tensor.Tensor
public abstract class Tensor
This is the super class for any tensor. The tensor may be symmetric or asymmetric.
Field Summary | |
---|---|
protected int |
L
|
protected byte |
order
|
protected int[] |
powers
|
Constructor Summary | |
---|---|
Tensor(int n,
byte k)
Creates a new Tensor for n nodes and order k . |
Method Summary | |
---|---|
protected int |
getAsymIndex(int child,
int[] parents,
byte k)
|
abstract int[] |
getMaximalEdgeFor(byte k,
int child,
int... parents)
Returns the edge permute(parents[0],... |
int |
getNumberOfNodes()
Returns the number of nodes. |
byte |
getOrder()
Returns the order. |
abstract double |
getRootValue(int child)
Returns the value for child as root. |
abstract double |
getValue(byte k,
int child,
int... parents)
Returns the value for the edge parents[0],... |
static Tensor |
readTensorFromFile(String fname,
boolean asym)
The opposite of the method writeTensorToFile . |
abstract void |
resetValue(byte k,
int child,
int... parents)
Sets the value for the edge parents[0],... |
abstract void |
setRootValue(int child,
double val)
Sets the value val for the root node child . |
abstract void |
setValue(byte k,
double val,
int child,
int... parents)
Sets the value for the edge parents[0],... |
double[][][] |
toDouble3DArray()
|
void |
writeTensorToFile(String fname,
OutputStream desc)
This method writes a Tensor in the exchange format in a specified file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int[] powers
protected int L
protected byte order
Constructor Detail |
---|
public Tensor(int n, byte k) throws IllegalArgumentException
n
nodes and order k
.
n
- the number of nodesk
- the order
IllegalArgumentException
- if n < 0 or l < 1Method Detail |
---|
public abstract int[] getMaximalEdgeFor(byte k, int child, int... parents)
permute(parents[0],...,parents[k-1]) -> child
that maximizes the score.
public int getNumberOfNodes()
public byte getOrder()
public abstract double getRootValue(int child)
child
as root.
child
- the name of the node
public abstract double getValue(byte k, int child, int... parents)
parents[0],...,parents[k-1] -> child
.
k
- the number parents to be usedchild
- the child nodeparents
- the parents nodes (only the first k
will be used
parents[0],...,parents[k-1] -> child
public abstract void setRootValue(int child, double val)
val
for the root node child
.
child
- the name of the nodeval
- the value for the nodepublic abstract void setValue(byte k, double val, int child, int... parents)
parents[0],...,parents[k-1] -> child
.
k
- the number parents to be usedval
- the new valuechild
- the child nodeparents
- the parents nodes (only the first k
will be usedpublic abstract void resetValue(byte k, int child, int... parents)
parents[0],...,parents[k-1] -> child
to Double.NEGATIVE_INFINITY.
k
- the number parents to be usedchild
- the child nodeparents
- the parents nodes (only the first k
will be usedpublic void writeTensorToFile(String fname, OutputStream desc) throws IOException
fname
- the file namedesc
- gives you the possibility to write the description of the tensor file
IOException
- if something went wrong with the filepublic static Tensor readTensorFromFile(String fname, boolean asym) throws NumberFormatException, IOException
writeTensorToFile
.
fname
- the file nameasym
- true
generates a AsymmetricTensor, otherwise a SymmetricTensor
IOException
- if something with the file went wrong
NumberFormatException
- if the file could not be parsed correctlypublic double[][][] toDouble3DArray()
protected int getAsymIndex(int child, int[] parents, byte k)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |