当前位置: 首页>>代码示例>>Java>>正文


Java LocalizedFormats.DIMENSIONS_MISMATCH_2x2方法代码示例

本文整理汇总了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)  );
        }
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:40,代码来源:MatrixUtils.java

示例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)  );
        }
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:40,代码来源:MatrixUtils.java

示例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 });
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:17,代码来源:MatrixDimensionMismatchException.java


注:本文中的org.apache.commons.math3.exception.util.LocalizedFormats.DIMENSIONS_MISMATCH_2x2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。