本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.DIMENSIONS_MISMATCH_2x2方法的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.DIMENSIONS_MISMATCH_2x2方法的具体用法?Java LocalizedFormats.DIMENSIONS_MISMATCH_2x2怎么用?Java LocalizedFormats.DIMENSIONS_MISMATCH_2x2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.DIMENSIONS_MISMATCH_2x2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: solveLowerTriangularSystem
import org.apache.commons.math3.exception.util.LocalizedFormats; //导入方法依赖的package包/类
/**Solve a system of composed of a Lower Triangular Matrix
* {@link RealMatrix}.
* <p>
* This method is called to solve systems of equations which are
* of the lower triangular form. The matrix {@link RealMatrix}
* is assumed, though not checked, to be in lower triangular form.
* The vector {@link RealVector} is overwritten with the solution.
* The matrix is checked that it is square and its dimensions match
* the length of the vector.
* </p>
* @param rm RealMatrix which is lower triangular
* @param b RealVector this is overwritten
* @exception IllegalArgumentException if the matrix and vector are not conformable
* @exception ArithmeticException there is a zero or near zero on the diagonal of rm
*/
public static void solveLowerTriangularSystem( RealMatrix rm, RealVector b){
if ((rm == null) || (b == null) || ( rm.getRowDimension() != b.getDimension())) {
throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
(rm == null) ? 0 : rm.getRowDimension(),
(b == null) ? 0 : b.getDimension());
}
if( rm.getColumnDimension() != rm.getRowDimension() ){
throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
rm.getRowDimension(),rm.getRowDimension(),
rm.getRowDimension(),rm.getColumnDimension());
}
int rows = rm.getRowDimension();
for( int i = 0 ; i < rows ; i++ ){
double diag = rm.getEntry(i, i);
if( FastMath.abs(diag) < Precision.SAFE_MIN ){
throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
}
double bi = b.getEntry(i)/diag;
b.setEntry(i, bi );
for( int j = i+1; j< rows; j++ ){
b.setEntry(j, b.getEntry(j)-bi*rm.getEntry(j,i) );
}
}
}
示例2: solveUpperTriangularSystem
import org.apache.commons.math3.exception.util.LocalizedFormats; //导入方法依赖的package包/类
/** Solver a system composed of an Upper Triangular Matrix
* {@link RealMatrix}.
* <p>
* This method is called to solve systems of equations which are
* of the lower triangular form. The matrix {@link RealMatrix}
* is assumed, though not checked, to be in upper triangular form.
* The vector {@link RealVector} is overwritten with the solution.
* The matrix is checked that it is square and its dimensions match
* the length of the vector.
* </p>
* @param rm RealMatrix which is upper triangular
* @param b RealVector this is overwritten
* @exception IllegalArgumentException if the matrix and vector are not conformable
* @exception ArithmeticException there is a zero or near zero on the diagonal of rm
*/
public static void solveUpperTriangularSystem( RealMatrix rm, RealVector b){
if ((rm == null) || (b == null) || ( rm.getRowDimension() != b.getDimension())) {
throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
(rm == null) ? 0 : rm.getRowDimension(),
(b == null) ? 0 : b.getDimension());
}
if( rm.getColumnDimension() != rm.getRowDimension() ){
throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
rm.getRowDimension(),rm.getRowDimension(),
rm.getRowDimension(),rm.getColumnDimension());
}
int rows = rm.getRowDimension();
for( int i = rows-1 ; i >-1 ; i-- ){
double diag = rm.getEntry(i, i);
if( FastMath.abs(diag) < Precision.SAFE_MIN ){
throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
}
double bi = b.getEntry(i)/diag;
b.setEntry(i, bi );
for( int j = i-1; j>-1; j-- ){
b.setEntry(j, b.getEntry(j)-bi*rm.getEntry(j,i) );
}
}
}
示例3: MatrixDimensionMismatchException
import org.apache.commons.math3.exception.util.LocalizedFormats; //导入方法依赖的package包/类
/**
* Construct an exception from the mismatched dimensions.
*
* @param wrongRowDim Wrong row dimension.
* @param wrongColDim Wrong column dimension.
* @param expectedRowDim Expected row dimension.
* @param expectedColDim Expected column dimension.
*/
public MatrixDimensionMismatchException(int wrongRowDim,
int wrongColDim,
int expectedRowDim,
int expectedColDim) {
super(LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
new Integer[] { wrongRowDim, wrongColDim },
new Integer[] { expectedRowDim, expectedColDim });
}