本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.TOO_LARGE_CUTOFF_SINGULAR_VALUE属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.TOO_LARGE_CUTOFF_SINGULAR_VALUE属性的具体用法?Java LocalizedFormats.TOO_LARGE_CUTOFF_SINGULAR_VALUE怎么用?Java LocalizedFormats.TOO_LARGE_CUTOFF_SINGULAR_VALUE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.TOO_LARGE_CUTOFF_SINGULAR_VALUE属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCovariance
/**
* Returns the n × n covariance matrix.
* <p>The covariance matrix is V × J × V<sup>T</sup>
* where J is the diagonal matrix of the inverse of the squares of
* the singular values.</p>
* @param minSingularValue value below which singular values are ignored
* (a 0 or negative value implies all singular value will be used)
* @return covariance matrix
* @exception IllegalArgumentException if minSingularValue is larger than
* the largest singular value, meaning all singular values are ignored
*/
public RealMatrix getCovariance(final double minSingularValue) {
// get the number of singular values to consider
final int p = singularValues.length;
int dimension = 0;
while (dimension < p &&
singularValues[dimension] >= minSingularValue) {
++dimension;
}
if (dimension == 0) {
throw new NumberIsTooLargeException(LocalizedFormats.TOO_LARGE_CUTOFF_SINGULAR_VALUE,
minSingularValue, singularValues[0], true);
}
final double[][] data = new double[dimension][p];
getVT().walkInOptimizedOrder(new DefaultRealMatrixPreservingVisitor() {
/** {@inheritDoc} */
@Override
public void visit(final int row, final int column,
final double value) {
data[row][column] = value / singularValues[row];
}
}, 0, dimension - 1, 0, p - 1);
RealMatrix jv = new Array2DRowRealMatrix(data, false);
return jv.transpose().multiply(jv);
}