本文整理了Java中cern.colt.matrix.linalg.Algebra.norm2()
方法的一些代码示例,展示了Algebra.norm2()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Algebra.norm2()
方法的具体详情如下:
包路径:cern.colt.matrix.linalg.Algebra
类名称:Algebra
方法名:norm2
Algebra.norm2介绍
[英]Returns the two-norm (aka euclidean norm) of vector x; equivalent to mult(x,x).
[中]返回向量x的两个范数(也称为欧几里德范数);等价于mult(x,x)。
代码示例
代码示例来源:origin: com.blazegraph/colt
public double dnrm2(DoubleMatrix1D x) {
return Math.sqrt(Algebra.DEFAULT.norm2(x));
}
public void drot(DoubleMatrix1D x, DoubleMatrix1D y, double c, double s) {
代码示例来源:origin: blazegraph/database
public double dnrm2(DoubleMatrix1D x) {
return Math.sqrt(Algebra.DEFAULT.norm2(x));
}
public void drot(DoubleMatrix1D x, DoubleMatrix1D y, double c, double s) {
代码示例来源:origin: cmu-phil/tetrad
public static double norm2(DoubleMatrix1D vec){
//return Math.sqrt(vec.copy().assign(Functions.pow(2)).zSum());
return Math.sqrt(new Algebra().norm2(vec));
}
}
代码示例来源:origin: cmu-phil/tetrad
private static double norm2(DoubleMatrix1D vec){
//return Math.sqrt(vec.copy().assign(Functions.pow(2)).zSum());
return Math.sqrt(new Algebra().norm2(vec));
}
代码示例来源:origin: cmu-phil/tetrad
private static double norm2(DoubleMatrix2D mat){
//return Math.sqrt(mat.copy().assign(Functions.pow(2)).zSum());
Algebra al = new Algebra();
//norm found by svd so we need rows >= cols
if(mat.rows() return al.norm2(al.transpose(mat));
}
return al.norm2(mat);
}
代码示例来源:origin: com.github.vincentk/joptimizer
@Override
protected boolean checkCustomExitConditions(DoubleMatrix1D Y){
DoubleMatrix1D X = Y.viewPart(0, getDim()-1);
//equalities
DoubleMatrix1D originalRPriX = F1.make(0);
if(getA()!=null){
//originalRPriX = originalProblem.getA().zMult(X, originalProblem.getB().copy(), 1., -1., false);
originalRPriX = ColtUtils.zMult(originalProblem.getA(), X, originalProblem.getB(), -1.);
}
boolean b2 = Math.sqrt(ALG.norm2(originalRPriX))
//inequalities
boolean b1 = !Double.isNaN(originalProblem.getBarrierFunction().value(X.toArray())) || Y.get(Y.size()-1)<0;
log.debug("checkCustomExitConditions: " + (b1 && b2));
return b1 && b2;
}
}
代码示例来源:origin: com.github.vincentk/joptimizer
@Override
protected boolean checkCustomExitConditions(DoubleMatrix1D Y){
DoubleMatrix1D X = Y.viewPart(0, getDim()-1);
DoubleMatrix1D ineqX = originalProblem.getFi(X);
int ineqMaxIndex = Utils.getMaxIndex(ineqX);
boolean isInternal = (ineqX.get(ineqMaxIndex) + getTolerance() <0) || Y.get(Y.size()-1)<0;
log.info("isInternal : " + isInternal);
if(!isInternal){
return false;
}
DoubleMatrix1D originalRPriX = F1.make(0);
if(getA()!=null){
//originalRPriX = originalProblem.getA().zMult(X, originalProblem.getB().copy(), 1., -1., false);
originalRPriX = ColtUtils.zMult(originalProblem.getA(), X, originalProblem.getB(), -1);
}
boolean isPrimalFeas = Math.sqrt(ALG.norm2(originalRPriX)) log.info("isPrimalFeas: " + isPrimalFeas);
log.info("checkCustomExitConditions: " + (isInternal && isPrimalFeas));
return isInternal && isPrimalFeas;
}
}
代码示例来源:origin: com.github.vincentk/joptimizer
@Override
protected boolean checkCustomExitConditions(DoubleMatrix1D Xs){
DoubleMatrix1D X = Xs.viewPart(0, getDim()-1);
DoubleMatrix1D ineqX = originalProblem.getFi(X);
int ineqMaxIndex = Utils.getMaxIndex(ineqX);
//log.debug("ineqMaxIndex: " + ineqMaxIndex);
//log.debug("ineqMaxValue: " + ineqX.get(ineqMaxIndex));
boolean isInternal = (ineqX.get(ineqMaxIndex) + getTolerance() <0) || Xs.get(Xs.size()-1)<0;
log.info("isInternal : " + isInternal);
if(!isInternal){
return false;
}
DoubleMatrix1D originalRPriX = F1.make(0);
if(getA()!=null){
//originalRPriX = originalProblem.getA().zMult(X, originalProblem.getB().copy(), 1., -1., false);
originalRPriX = ColtUtils.zMult(originalProblem.getA(), X, originalProblem.getB(), -1);
}
boolean isPrimalFeas = Math.sqrt(ALG.norm2(originalRPriX)) log.info("isPrimalFeas: " + isPrimalFeas);
log.info("checkCustomExitConditions: " + (isInternal && isPrimalFeas));
return isInternal && isPrimalFeas;
}
代码示例来源:origin: cmu-phil/tetrad
thetaNorms += weightMat.get(i, p+j)*Math.sqrt(alg.norm2(tempVec));
代码示例来源:origin: blazegraph/database
try { values.add(String.valueOf(norm2(matrix)));}
catch (IllegalArgumentException exc) { values.add(unknown+exc.getMessage()); }
代码示例来源:origin: com.blazegraph/colt
try { values.add(String.valueOf(norm2(matrix)));}
catch (IllegalArgumentException exc) { values.add(unknown+exc.getMessage()); }
代码示例来源:origin: com.github.vincentk/joptimizer
final double rPriX0Norm = (X0 != null)? Math.sqrt(ALG.norm2(rPri(X0))) : 0d;
if (X0 == null || rPriX0Norm > getTolerance()) {
DoubleMatrix2D hessX = getHessF0(X);
double gradXNorm = Math.sqrt(ALG.norm2(gradX));
if(gradXNorm response.setReturnCode(OptimizationResponse.SUCCESS);
代码示例来源:origin: com.github.vincentk/joptimizer
double rPriXNorm = Math.sqrt(ALG.norm2(rPriX));
double rDualXVNorm = Math.sqrt(ALG.norm2(rDualXV));
log.debug("rPriXNorm : "+rPriXNorm);
log.debug("rDualXVNorm: "+rDualXVNorm);
rDualX1V1 = rDual(X1, V1, gradX1);
rPriX1V1 = rPri(X1);
double normRX1V1 = Math.sqrt(ALG.norm2(rDualX1V1) + ALG.norm2(rPriX1V1));
if (normRX1V1 <= (1 - getAlpha() * s) * rXVNorm) {
break;
代码示例来源:origin: cmu-phil/tetrad
double thetaScale = Math.max(0, 1 - tlam.get(1) * weightMat.get(i, p+j)/norm2(tempVec));
tempVec.assign(Functions.mult(thetaScale));
thetaNorms += weightMat.get(i, p+j)*Math.sqrt(alg.norm2(tempVec));
代码示例来源:origin: cmu-phil/tetrad
double normXY = alg.norm2(XmY);
if(normXY==0)
break;
代码示例来源:origin: com.github.vincentk/joptimizer
double norm = Math.sqrt(ALG.norm2(originalRPriX0));
log.debug("norm: " + norm);
if(norm > originalProblem.getToleranceFeas()){
代码示例来源:origin: com.github.vincentk/joptimizer
double norm = Math.sqrt(ALG.norm2(originalRPriX0));
log.debug("norm: " + norm);
if(norm > originalProblem.getToleranceFeas()){
代码示例来源:origin: com.github.vincentk/joptimizer
if(Math.sqrt(ALG.norm2(originalRPriX0)) > originalProblem.getToleranceFeas()){
throw new Exception("The initial point for Basic Phase I Method must be equalities-feasible");
代码示例来源:origin: cmu-phil/tetrad
grad.betad.set(i, -n / (2.0 * par.betad.get(i)) + alg.norm2(negLoss.viewColumn(i)) / 2.0 -
alg.mult(negLoss.viewColumn(i), xBeta.viewColumn(i).copy().assign(dTheta.viewColumn(i), Functions.plus)));
代码示例来源:origin: cmu-phil/tetrad
gradOut.betad.set(i, -n / (2.0 * par.betad.get(i)) + alg.norm2(tempLoss.viewColumn(i)) / 2.0 -
alg.mult(tempLoss.viewColumn(i), xBeta.viewColumn(i).copy().assign(dTheta.viewColumn(i), Functions.plus)));