com.meliorbis.numerics.convergence.DoubleCriterion Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Numerics Show documentation
Show all versions of Numerics Show documentation
A library for working with large multi-dimensional arrays and the functions they represent
/**
*
*/
package com.meliorbis.numerics.convergence;
/**
* @author Tobias Grasl
*
*/
public class DoubleCriterion implements Criterion
{
private final double _val;
private final String _label;
private final String _formatString;
public DoubleCriterion(double val_)
{
this(null,val_);
}
public DoubleCriterion(String label_, double val_)
{
_label = label_;
_val = val_;
if(_label != null) {
_formatString = "%s: %.2e";
} else {
_formatString = "%2$.2e";
}
}
/* (non-Javadoc)
* @see com.meliorbis.numerics.convergence.Criterion#getValue()
*/
@Override
public double getValue()
{
return _val;
}
@Override
public String toString()
{
return String.format(_formatString,_label, _val);
}
static public DoubleCriterion of(double val_)
{
return new DoubleCriterion(val_);
}
}