cern.colt.matrix.linalg.Algebra.multOuter()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中cern.colt.matrix.linalg.Algebra.multOuter()方法的一些代码示例,展示了Algebra.multOuter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Algebra.multOuter()方法的具体详情如下:
包路径:cern.colt.matrix.linalg.Algebra
类名称:Algebra
方法名:multOuter

Algebra.multOuter介绍

[英]Outer product of two vectors; Sets A[i,j] = x[i] * y[j].
[中]两个向量的外积;设置A[i,j]=x[i]*y[j]。

代码示例

代码示例来源:origin: blazegraph/database

/**
 * Outer product of two vectors; Returns a matrix with <tt>A[i,j] = x[i] * y[j]</tt>.
 *
 * @param x the first source vector.
 * @param y the second source vector.
 * @return the outer product </tt>A</tt>.
 */
private DoubleMatrix2D xmultOuter(DoubleMatrix1D x, DoubleMatrix1D y) {
  DoubleMatrix2D A = x.like2D(x.size(),y.size());
  multOuter(x,y,A);
  return A;
}
/**

代码示例来源:origin: com.blazegraph/colt

/**
 * Outer product of two vectors; Returns a matrix with <tt>A[i,j] = x[i] * y[j]</tt>.
 *
 * @param x the first source vector.
 * @param y the second source vector.
 * @return the outer product </tt>A</tt>.
 */
private DoubleMatrix2D xmultOuter(DoubleMatrix1D x, DoubleMatrix1D y) {
  DoubleMatrix2D A = x.like2D(x.size(),y.size());
  multOuter(x,y,A);
  return A;
}
/**

代码示例来源:origin: cmu-phil/tetrad

public static TetradMatrix multOuter(TetradVector v1, TetradVector v2) {
  DoubleMatrix2D m = new Algebra().multOuter(new DenseDoubleMatrix1D(v1.toArray()),
      new DenseDoubleMatrix1D(v2.toArray()), null);
  return new TetradMatrix(m.toArray());
}

代码示例来源:origin: cmu-phil/tetrad

DoubleMatrix2D weightMat = alg.multOuter(weights,
    weights, null);

代码示例来源:origin: cmu-phil/tetrad

DoubleMatrix2D weightMat = alg.multOuter(weights,
    weights, null);
DoubleMatrix2D betaWeight = weightMat.viewPart(0, 0, p, p);

代码示例来源:origin: com.github.vincentk/joptimizer

@Override
public double[][] hessian(double[] X) {
  DoubleMatrix1D x = DoubleFactory1D.dense.make(X);
  DoubleMatrix1D g = ALG.mult(A, x).assign(b, Functions.plus).assign(Functions.exp);
  double den = g.zSum();
  DoubleMatrix1D r = DoubleFactory1D.dense.make(dim);
  for(int i=0; i<dim; i++){
    double d = 0d;
    for(int k=0; k<A.rows(); k++){
      d += g.get(k) * A.get(k, i);
    }
    r.set(i, d);
  }
  
  DoubleMatrix2D ret = DoubleFactory2D.dense.make(dim, dim);
  ret.assign(ALG.multOuter(r, r, null).assign(Mult.mult(-1d/Math.pow(den, 2))), Functions.plus);
  for(int k=0; k<A.rows(); k++){
    ret.assign(ALG.multOuter(A.viewRow(k), A.viewRow(k), null).assign(Mult.mult(g.get(k))).assign(Mult.mult(1d/den)), Functions.plus);
  }
  return ret.toArray();
}

代码示例来源:origin: cmu-phil/tetrad

DoubleMatrix2D weightMat = alg.multOuter(weights,
    weights, null);
DoubleMatrix2D betaWeight = weightMat.viewPart(0, 0, p, p);

代码示例来源:origin: com.github.vincentk/joptimizer

@Override
public double[][] hessian(double[] X) {
  DoubleMatrix2D HessSum = F2.make(new double[getDim()][getDim()]);
  DoubleMatrix2D GradSum = F2.make(new double[getDim()][getDim()]);
  for (int j = 0; j < fi.length; j++) {
    double ineqValuejX = fi[j].value(X);
    double[][] fijHessianX = fi[j].hessian(X);
    DoubleMatrix2D ineqHessjX = (fijHessianX!=FunctionsUtils.ZEROES_2D_ARRAY_PLACEHOLDER)? F2.make(fijHessianX) : FunctionsUtils.ZEROES_MATRIX_PLACEHOLDER;
    DoubleMatrix1D ineqGradjX = F1.make(fi[j].gradient(X));
    if(ineqHessjX!=FunctionsUtils.ZEROES_MATRIX_PLACEHOLDER){
      HessSum.assign(ineqHessjX.assign(Mult.mult(-1./ineqValuejX)), Functions.plus);
    }
    GradSum.assign(ALG.multOuter(ineqGradjX, ineqGradjX, null).assign(Mult.mult(1. / Math.pow(ineqValuejX, 2))), Functions.plus);
  }
  return HessSum.assign(GradSum, Functions.plus).toArray();
}

代码示例来源:origin: RankSys/RankSys

A2P[iidx] = new DenseDoubleMatrix2D(K, K);
  DoubleMatrix1D qi = q.viewRow(iidx);
  ALG.multOuter(qi, qi, A2P[iidx]);
});

相关文章