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


Java Matrix.get方法代码示例

本文整理汇总了Java中no.uib.cipr.matrix.Matrix.get方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.get方法的具体用法?Java Matrix.get怎么用?Java Matrix.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在no.uib.cipr.matrix.Matrix的用法示例。


在下文中一共展示了Matrix.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: multAdd

import no.uib.cipr.matrix.Matrix; //导入方法依赖的package包/类
@Override
public Matrix multAdd(double alpha, Matrix B, Matrix C) {
    checkMultAdd(B, C);
    if (alpha == 0)
        return C;
    for (int i = 0; i < numRows; i++) {
        Node row = links.startOfRow(i);
        if (row != null)
            for (int j = 0; j < B.numColumns(); j++) {
                Node node = row;
                double v = 0;
                while (node != null && node.row == i) {
                    v += (B.get(node.col, j) * node.val);
                    node = node.rowTail;
                }
                if (v != 0)
                    C.add(i, j, alpha * v);
            }
    }
    return C;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:22,代码来源:LinkedSparseMatrix.java

示例2: transBmultAdd

import no.uib.cipr.matrix.Matrix; //导入方法依赖的package包/类
@Override
public Matrix transBmultAdd(double alpha, Matrix B, Matrix C) {
    checkTransBmultAdd(B, C);
    if (alpha == 0)
        return C;
    for (int i = 0; i < numRows; i++) {
        Node row = links.startOfRow(i);
        if (row != null)
            for (int j = 0; j < B.numRows(); j++) {
                Node node = row;
                double v = 0;
                while (node != null && node.row == i) {
                    v += (B.get(j, node.col) * node.val);
                    node = node.rowTail;
                }
                if (v != 0)
                    C.add(i, j, alpha * v);
            }
    }
    return C;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:22,代码来源:LinkedSparseMatrix.java

示例3: transAmultAdd

import no.uib.cipr.matrix.Matrix; //导入方法依赖的package包/类
@Override
public Matrix transAmultAdd(double alpha, Matrix B, Matrix C) {
    checkTransAmultAdd(B, C);
    if (alpha == 0)
        return C;
    for (int i = 0; i < numColumns; i++) {
        Node row = links.startOfCol(i);
        if (row != null)
            for (int j = 0; j < B.numColumns(); j++) {
                Node node = row;
                double v = 0;
                while (node != null && node.col == i) {
                    v += (B.get(node.row, j) * node.val);
                    node = node.colTail;
                }
                if (v != 0)
                    C.add(i, j, alpha * v);
            }
    }
    return C;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:22,代码来源:LinkedSparseMatrix.java

示例4: transABmultAdd

import no.uib.cipr.matrix.Matrix; //导入方法依赖的package包/类
@Override
public Matrix transABmultAdd(double alpha, Matrix B, Matrix C) {
    checkTransABmultAdd(B, C);
    if (alpha == 0)
        return C;
    for (int i = 0; i < numColumns; i++) {
        Node row = links.startOfCol(i);
        if (row != null)
            for (int j = 0; j < B.numRows(); j++) {
                Node node = row;
                double v = 0;
                while (node != null && node.col == i) {
                    v += (B.get(j, node.row) * node.val);
                    node = node.colTail;
                }
                if (v != 0)
                    C.add(i, j, alpha * v);
            }
    }
    return C;
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:22,代码来源:LinkedSparseMatrix.java

示例5: setMatrix

import no.uib.cipr.matrix.Matrix; //导入方法依赖的package包/类
public void setMatrix(Matrix A) {
    if (A.numRows() != invdiag.length)
        throw new IllegalArgumentException(
                "Matrix size differs from preconditioner size");

    for (int i = 0; i < invdiag.length; ++i) {
        invdiag[i] = A.get(i, i);
        if (invdiag[i] == 0) // Avoid zero-division
            throw new RuntimeException("Zero diagonal on row " + (i + 1));
        else
            invdiag[i] = 1 / invdiag[i];
    }
}
 
开发者ID:opprop-benchmarks,项目名称:matrix-toolkits-java,代码行数:14,代码来源:DiagonalPreconditioner.java

示例6: testHessian

import no.uib.cipr.matrix.Matrix; //导入方法依赖的package包/类
/**
 * http://www.otago.ac.nz/sas/ormp/chap5/sect28.htm
 * @throws Exception
 */
@Test
public void testHessian() throws Exception {
	if (f == null) {
		Assert.fail("Functional has not been set");
	}
	if (!f.hasHessian()) {
		return;
	}
	if (hds == null) {
		Assert.fail("No HalfEdgedatastructure has been set");
	}
	if (xHess == null) {
		System.out.println("No hessian test point set in " + getClass().getSimpleName());
		return;
	}
	int n = f.getDimension(hds);
	int[][] nz = f.getNonZeroPattern(hds);
	Matrix H = new CompRowMatrix(n, n, nz);
	MyHessian hessian = new MyHessian(H);
	MyEnergy y = new MyEnergy();
	f.evaluate(hds, xHess, y, null, hessian);
	
	double normDif = 0.0;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			double fdHessian = 0.0;
			double xi = xHess.get(i);
			double xj = xHess.get(j);
			if (i == j) {
				MyEnergy iPlus = new MyEnergy(); 
				MyEnergy iMinus = new MyEnergy();
				MyEnergy i2Plus = new MyEnergy(); 
				MyEnergy i2Minus = new MyEnergy();			
				
				xHess.set(i, xi + eps);
				f.evaluate(hds, xHess, iPlus, null, null);
				xHess.set(i, xi + 2*eps);
				f.evaluate(hds, xHess, i2Plus, null, null);	
				xHess.set(i, xi - eps);
				f.evaluate(hds, xHess, iMinus, null, null);
				xHess.set(i, xi - 2*eps);
				f.evaluate(hds, xHess, i2Minus, null, null);
				
				fdHessian = (-i2Plus.E/eps + 16*iPlus.E/eps - 30*y.E/eps + 16*iMinus.E/eps - i2Minus.E/eps) / (12 * eps);
			} else {
				MyEnergy iPlusjPlus = new MyEnergy();
				MyEnergy iPlusjMinus = new MyEnergy();
				MyEnergy iMinusjPlus = new MyEnergy();
				MyEnergy iMinusjMinus = new MyEnergy();
				
				xHess.set(i, xi + eps);
				xHess.set(j, xj + eps);
				f.evaluate(hds, xHess, iPlusjPlus, null, null);
				xHess.set(i, xi + eps);
				xHess.set(j, xj - eps);
				f.evaluate(hds, xHess, iPlusjMinus, null, null);
				xHess.set(i, xi - eps);
				xHess.set(j, xj + eps);
				f.evaluate(hds, xHess, iMinusjPlus, null, null);
				xHess.set(i, xi - eps);
				xHess.set(j, xj - eps);
				f.evaluate(hds, xHess, iMinusjMinus, null, null);

				fdHessian = (iPlusjPlus.E/eps - iPlusjMinus.E/eps - iMinusjPlus.E/eps + iMinusjMinus.E/eps) / (4 * eps);
			}
			log.info("fdHess["+i+","+j+"] = " +fdHessian+ "; G["+i+","+j+"] = " + H.get(i,j));
			normDif += (fdHessian - H.get(i,j)) * (fdHessian - H.get(i,j));
			xHess.set(i, xi);
			xHess.set(j, xj);
		}
	}
	normDif = sqrt(normDif);
	
	double normHC = H.norm(Frobenius);
	double ratio = normDif / normHC;
	Assert.assertEquals(0.0, ratio, error);
}
 
开发者ID:sechel,项目名称:jtem-halfedgetools,代码行数:82,代码来源:FunctionalTest.java


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