|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.jagrlib.DefaultProperty
cz.cuni.jagrlib.Piece
cz.cuni.jagrlib.piece.IntervalArray
public class IntervalArray
Entropy histogram implementation: map of cummulative frequency interval trees.
Nested Class Summary | |
---|---|
protected class |
IntervalArray.CFTree
Cummulative frequency interval tree. |
Field Summary | |
---|---|
protected static java.lang.String |
CATEGORY
Object category. |
protected IntMap<IntervalArray.CFTree> |
contexts
All open contexts. |
protected IntervalArray.CFTree |
ctx
The actual context. |
protected int |
ctxId
Identifier of the actual context. |
protected boolean |
defaultNonZero
Default non-zero flag. |
protected long |
defaultSumLimit
Default frequency sum limit. |
protected int |
defaultSymbols
Default number of symbols. |
static RegPiece |
reg
Static registration instance for this class. |
protected static java.lang.String |
TEMPLATE_NAME
Object template identifier. |
Fields inherited from class cz.cuni.jagrlib.Piece |
---|
channels, info, pl, plugs, TEMPLATE_TYPE, userBreak |
Fields inherited from interface cz.cuni.jagrlib.iface.Property |
---|
LOGGING, STATISTICS, TEXT_DESCRIPTION |
Constructor Summary | |
---|---|
IntervalArray()
|
Method Summary | |
---|---|
int |
convert(long cf)
Converts a frequency sum to the corresponding symbol. |
void |
decimate()
Divides each frequency in the current context by 2. |
long |
get(int s)
Returns the frequency of the given symbol. |
java.lang.Object |
get(java.lang.String key)
Gets the given property. |
int |
getContext()
Returns the current context. |
boolean |
getNonZero()
Read non-zero attribute for the current context |
long |
getSumLimit()
Returns the frequency sum limit for the current context. |
int |
getSymbols()
Returns the number of symbols in the current context. |
void |
inc(int s)
Increments a single symbol's frequency by 1 . |
void |
inc(int symbol,
long _freq)
Increments a single symbol's frequency. |
void |
inc(long[] f)
Increments frequencies of all symbols in the current context. |
void |
init(int _defaultSymbols,
long _defaultSumLimit,
boolean _defaultNonZero,
int _ctxId)
Histogram (re-)initialization. |
long |
left(int s)
Returns the start of the symbol's cummulative frequency interval (the frequency sum of all preceding symbols). |
protected void |
printStatistics()
|
void |
set(int symbol,
long _freq)
Sets a single symbol's frequency. |
void |
set(long[] f)
Sets frequencies of all symbols in the current context. |
void |
set(java.lang.String key,
java.lang.Object value)
Sets the given property. |
int |
setContext(int _ctxId)
Sets the given context as current. |
void |
setDefaultNonZero(boolean b)
Set non-zero attribute: keep frequencies non-zero at all times? |
void |
setDefaultSumLimit(long l)
Sets the new default frequency sum limit for new contexts. |
void |
setDefaultSymbols(int i)
Sets the new default number of symbols for new contexts. |
void |
setNonZero(boolean b)
Set non-zero attribute for the current context: keep frequencies non-zero at all times? |
void |
setSumLimit(long l)
Changes the frequency sum limit for the current context. |
void |
setSymbols(int i)
Changes the number of symbols in the current context. |
static int |
setTemplate(Template t,
int ord)
General-purpose registration routine. |
long |
total()
Returns the frequency sum of all symbols in the current context. |
Methods inherited from class cz.cuni.jagrlib.Piece |
---|
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, init, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplateDynamic, stop |
Methods inherited from class cz.cuni.jagrlib.DefaultProperty |
---|
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, stringProperty |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface cz.cuni.jagrlib.iface.Property |
---|
commit |
Field Detail |
---|
protected int ctxId
protected IntervalArray.CFTree ctx
protected IntMap<IntervalArray.CFTree> contexts
protected int defaultSymbols
protected long defaultSumLimit
protected boolean defaultNonZero
protected static final java.lang.String TEMPLATE_NAME
protected static final java.lang.String CATEGORY
public static final RegPiece reg
Constructor Detail |
---|
public IntervalArray()
Method Detail |
---|
public void init(int _defaultSymbols, long _defaultSumLimit, boolean _defaultNonZero, int _ctxId)
init
in interface EntropyHistogram
_defaultSymbols
- Default number of symbols for new contexts._defaultSumLimit
- Default frequency sum limit for new contexts (0
for no bounds)._defaultNonZero
- Keeps frequencies non-zero at all times.
Default frequencies are the lowest possible._ctxId
- The initial context.setDefaultSymbols(int)
,
setDefaultSumLimit(long)
,
setDefaultNonZero(boolean)
,
decimate()
public void setDefaultSymbols(int i)
setDefaultSymbols
in interface EntropyHistogram
i
- New default number of symbols.init(int, long, boolean, int)
,
setSymbols(int)
,
getSymbols()
public void setSymbols(int i)
setSymbols
in interface WheelOfFortune
i
- New number of symbols.setDefaultSymbols(int)
,
getSymbols()
,
decimate()
public int getSymbols()
getSymbols
in interface WheelOfFortune
setDefaultSymbols(int)
,
setSymbols(int)
public void setDefaultSumLimit(long l)
setDefaultSumLimit
in interface EntropyHistogram
l
- New default frequency sum limit (0
for no bounds).init(int, long, boolean, int)
,
setSumLimit(long)
,
getSumLimit()
,
total()
public void setSumLimit(long l)
setSumLimit
in interface EntropyHistogram
l
- New frequency sum limit (0
for no bounds).init(int, long, boolean, int)
,
setDefaultSumLimit(long)
,
getSumLimit()
,
decimate()
,
total()
public long getSumLimit()
getSumLimit
in interface EntropyHistogram
0
for no bounds).init(int, long, boolean, int)
,
setDefaultSumLimit(long)
,
setSumLimit(long)
,
total()
public void setDefaultNonZero(boolean b)
setDefaultNonZero
in interface EntropyHistogram
b
- Non-zero attribute for new contexts.init(int, long, boolean, int)
,
setNonZero(boolean)
,
getNonZero()
public void setNonZero(boolean b)
setNonZero
in interface EntropyHistogram
b
- Non-zero attribute for the current context.init(int, long, boolean, int)
,
setDefaultNonZero(boolean)
,
getNonZero()
,
decimate()
public boolean getNonZero()
getNonZero
in interface EntropyHistogram
init(int, long, boolean, int)
,
setDefaultNonZero(boolean)
,
setNonZero(boolean)
public int setContext(int _ctxId)
setContext
in interface EntropyHistogram
_ctxId
- Identifier of the new context.
init(int, long, boolean, int)
,
setDefaultSymbols(int)
,
setDefaultSumLimit(long)
,
getContext()
public int getContext()
getContext
in interface EntropyHistogram
setContext(int)
public void decimate()
decimate
in interface EntropyHistogram
init(int, long, boolean, int)
,
setDefaultSumLimit(long)
,
setSumLimit(long)
,
getSumLimit()
,
setDefaultNonZero(boolean)
,
setNonZero(boolean)
,
getNonZero()
,
total()
public void set(long[] f)
null
parameter).
set
in interface WheelOfFortune
f
- Array of new frequencies.
Can be null
for context re-initialization.set(int,long)
,
decimate()
public void set(int symbol, long _freq)
set
in interface WheelOfFortune
symbol
- Symbol code._freq
- New frequency of the symbol.set(long[])
,
decimate()
public void inc(long[] f)
inc
in interface EntropyHistogram
f
- Array of frequency increments.inc(int,long)
,
inc(int)
,
decimate()
public void inc(int symbol, long _freq)
inc
in interface EntropyHistogram
symbol
- Symbol code._freq
- Frequency increment of the symbol.inc(long[])
,
inc(int)
,
decimate()
public void inc(int s)
1
.
inc
in interface EntropyHistogram
s
- Symbol code.inc(int,long)
,
inc(long[])
,
decimate()
public long total()
left( getSymbols() )
, but might be more effective.
total
in interface WheelOfFortune
left(int)
,
get(int)
,
convert(long)
public long left(int s)
left
in interface WheelOfFortune
s
- Symbol code.
total()
,
get(int)
,
convert(long)
public long get(int s)
left( _symbol + 1 ) - left( _symbol )
.
get
in interface WheelOfFortune
s
- Symbol code.
total()
,
left(int)
,
convert(long)
public int convert(long cf)
convert
in interface WheelOfFortune
cf
- Frequency sum of the unknown symbol.
_sum
in it's cummulative frequency interval.total()
,
left(int)
,
get(int)
protected void printStatistics()
public void set(java.lang.String key, java.lang.Object value)
set
in interface Property
set
in class DefaultProperty
key
- Key string.value
- The new value.Property.commit()
public java.lang.Object get(java.lang.String key)
get
in interface Property
get
in class DefaultProperty
key
- Key string.
null
.public static int setTemplate(Template t, int ord)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |