no.uib.cipr.matrix.Vector.scale()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(125)

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

Vector.scale介绍

[英]x=alpha*x
[中]

代码示例

代码示例来源:origin: gov.sandia.foundry/gov-sandia-cognition-common-core

@Override
public void scaleEquals(
  final double scaleFactor)
{
  this.internalVector.scale( scaleFactor );   
}

代码示例来源:origin: algorithmfoundry/Foundry

@Override
public void scaleEquals(
  final double scaleFactor)
{
  this.internalVector.scale( scaleFactor );   
}

代码示例来源:origin: algorithmfoundry/Foundry

@Override
public void scaleEquals(
  final double scaleFactor)
{
  this.internalVector.scale( scaleFactor );   
}

代码示例来源:origin: de.tudarmstadt.ukp.similarity.algorithms/de.tudarmstadt.ukp.similarity.algorithms.vsm-asl

@Override
public Vector get()
{
  return super.get().scale(1./count);
}

代码示例来源:origin: org.dkpro.similarity/dkpro-similarity-algorithms-vsm-asl

private void normalize(Vector scv)
{
  double norm = normalizationMode.apply(scv);
  if (norm == 0.0) {
    return;
  }
  scv.scale(1 / norm);
}

代码示例来源:origin: dkpro/dkpro-similarity

@Override
public Vector get()
{
  return super.get().scale(1./count);
}

代码示例来源:origin: de.tudarmstadt.ukp.similarity.algorithms/de.tudarmstadt.ukp.similarity.algorithms.vsm-asl

private void normalize(Vector scv)
{
  double norm = normalizationMode.apply(scv);
  if (norm == 0.0) {
    return;
  }
  scv.scale(1 / norm);
}

代码示例来源:origin: org.dkpro.similarity/dkpro-similarity-algorithms-vsm-asl

@Override
public Vector get()
{
  return super.get().scale(1./count);
}

代码示例来源:origin: dkpro/dkpro-similarity

private void normalize(Vector scv)
{
  double norm = normalizationMode.apply(scv);
  if (norm == 0.0) {
    return;
  }
  scv.scale(1 / norm);
}

代码示例来源:origin: fommil/matrix-toolkits-java

@Override
public Vector multAdd(double alpha, Vector x, Vector y) {
  if (!(x instanceof DenseVector) || !(y instanceof DenseVector))
    return super.multAdd(alpha, x, y);
  checkMultAdd(x, y);
  double[] xd = ((DenseVector) x).getData(), yd = ((DenseVector) y)
      .getData();
  // y = 1/alpha * y
  y.scale(1 / alpha);
  // y = A*x + y
  for (int i = 0; i < numColumns; ++i)
    for (int j = columnPointer[i]; j < columnPointer[i + 1]; ++j)
      yd[rowIndex[j]] += data[j] * xd[i];
  // y = alpha*y = alpha*A*x + y
  return y.scale(alpha);
}

代码示例来源:origin: com.googlecode.matrix-toolkits-java/mtj

@Override
public Vector transMultAdd(double alpha, Vector x, Vector y) {
  if (!(x instanceof DenseVector) || !(y instanceof DenseVector))
    return super.transMultAdd(alpha, x, y);
  checkTransMultAdd(x, y);
  double[] xd = ((DenseVector) x).getData();
  double[] yd = ((DenseVector) y).getData();
  // y = 1/alpha * y
  y.scale(1. / alpha);
  // y = A'x + y
  for (int i = 0; i < numRows; ++i)
    for (int j = rowPointer[i]; j < rowPointer[i + 1]; ++j)
      yd[columnIndex[j]] += data[j] * xd[i];
  // y = alpha*y = alpha*A'x + y
  return y.scale(alpha);
}

代码示例来源:origin: fommil/matrix-toolkits-java

@Override
public Vector transMultAdd(double alpha, Vector x, Vector y) {
  if (!(x instanceof DenseVector) || !(y instanceof DenseVector))
    return super.transMultAdd(alpha, x, y);
  checkTransMultAdd(x, y);
  double[] xd = ((DenseVector) x).getData();
  double[] yd = ((DenseVector) y).getData();
  // y = 1/alpha * y
  y.scale(1. / alpha);
  // y = A'x + y
  for (int i = 0; i < numRows; ++i)
    for (int j = rowPointer[i]; j < rowPointer[i + 1]; ++j)
      yd[columnIndex[j]] += data[j] * xd[i];
  // y = alpha*y = alpha*A'x + y
  return y.scale(alpha);
}

代码示例来源:origin: com.googlecode.matrix-toolkits-java/mtj

@Override
public Vector multAdd(double alpha, Vector x, Vector y) {
  if (!(x instanceof DenseVector) || !(y instanceof DenseVector))
    return super.multAdd(alpha, x, y);
  checkMultAdd(x, y);
  double[] xd = ((DenseVector) x).getData(), yd = ((DenseVector) y)
      .getData();
  // y = 1/alpha * y
  y.scale(1 / alpha);
  // y = A*x + y
  for (int i = 0; i < numColumns; ++i)
    for (int j = columnPointer[i]; j < columnPointer[i + 1]; ++j)
      yd[rowIndex[j]] += data[j] * xd[i];
  // y = alpha*y = alpha*A*x + y
  return y.scale(alpha);
}

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

private Vector project(Vector v, Vector u){
  return u.copy().scale((v.dot(u) / u.dot(u)));
}

代码示例来源:origin: com.googlecode.matrix-toolkits-java/mtj

@Override
public Vector transMultAdd(double alpha, Vector x, Vector y) {
  if (!(x instanceof DenseVector) || !(y instanceof DenseVector))
    return super.transMultAdd(alpha, x, y);
  checkTransMultAdd(x, y);
  double[] xd = ((DenseVector) x).getData(), yd = ((DenseVector) y)
      .getData();
  // y = 1/alpha * y
  y.scale(1. / alpha);
  // y = A'x + y
  for (int i = 0; i < numRows; ++i) {
    SparseVector v = rowD[i];
    int[] index = v.getIndex();
    double[] data = v.getData();
    int length = v.getUsed();
    for (int j = 0; j < length; ++j)
      yd[index[j]] += data[j] * xd[i];
  }
  // y = alpha*y = alpha * A'x + y
  return y.scale(alpha);
}

代码示例来源:origin: fommil/matrix-toolkits-java

@Override
public Vector multAdd(double alpha, Vector x, Vector y) {
  if (!(x instanceof DenseVector) || !(y instanceof DenseVector))
    return super.multAdd(alpha, x, y);
  checkMultAdd(x, y);
  double[] xd = ((DenseVector) x).getData();
  double[] yd = ((DenseVector) y).getData();
  // y = 1/alpha * y
  y.scale(1. / alpha);
  // y = A*x + y
  for (int i = 0; i < numColumns; ++i) {
    SparseVector v = colD[i];
    int[] index = v.getIndex();
    double[] data = v.getData();
    int length = v.getUsed();
    for (int j = 0; j < length; ++j)
      yd[index[j]] += data[j] * xd[i];
  }
  // y = alpha*y = alpha * A'x + y
  return y.scale(alpha);
}

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

@Override
public Vector[] apply(double[] in) {
  Vector[] vmat = new Vector[in.length];
  
  vmat[0] = new DenseVector(in);
  double norm = vmat[0].norm(Norm.Two);
  vmat[0].scale(1/norm);
  for (int j = 1; j < in.length; j++) {
    Vector randvec = randvec(vmat[0].size(),norm);
    vmat[j] = new DenseVector(vmat[0]).add(randvec);
    for (int i = 0; i < j; i++) {
      vmat[j].add(-1, project(vmat[j],vmat[i]));
    }
    vmat[j].scale(1/vmat[j].norm(Norm.Two));
  }
  return vmat;
}

代码示例来源:origin: nz.ac.waikato.cms.weka/discriminantAnalysis

/**
 * Computes the mean vector for the given dataset.
 */
protected Vector computeMean(Instances data, double[] totalWeight, int aI) {
 Vector meanVector = new DenseVector(data.numAttributes() - 1);
 totalWeight[aI] = 0;
 for (Instance inst : data) {
  if (!inst.classIsMissing()) {
   meanVector.add(inst.weight(), instanceToVector(inst));
   totalWeight[aI] += inst.weight();
  }
 }
 meanVector.scale(1.0 / totalWeight[aI]);
 return meanVector;
}

代码示例来源:origin: fommil/matrix-toolkits-java

public Vector solve(Matrix A, Vector b, Vector x)
    throws IterativeSolverNotConvergedException {
  checkSizes(A, b, x);
  double alpha = 0, beta = 0, c = 0, d = 0;
  A.multAdd(-1, x, r.set(b));
  c = (eigmax - eigmin) / 2.0;
  d = (eigmax + eigmin) / 2.0;
  for (iter.setFirst(); !iter.converged(r, x); iter.next()) {
    M.apply(r, z);
    if (iter.isFirst()) {
      p.set(z);
      alpha = 2.0 / d;
    } else {
      beta = (alpha * c) / 2.0;
      beta *= beta;
      alpha = 1.0 / (d - beta);
      p.scale(beta).add(z);
    }
    A.mult(p, q);
    x.add(alpha, p);
    r.add(-alpha, q);
  }
  return x;
}

代码示例来源:origin: com.googlecode.matrix-toolkits-java/mtj

public Vector solve(Matrix A, Vector b, Vector x)
    throws IterativeSolverNotConvergedException {
  checkSizes(A, b, x);
  double alpha = 0, beta = 0, rho = 0, rho_1 = 0;
  A.multAdd(-1, x, r.set(b));
  for (iter.setFirst(); !iter.converged(r, x); iter.next()) {
    M.apply(r, z);
    rho = r.dot(z);
    if (iter.isFirst())
      p.set(z);
    else {
      beta = rho / rho_1;
      p.scale(beta).add(z);
    }
    A.mult(p, q);
    alpha = rho / p.dot(q);
    x.add(alpha, p);
    r.add(-alpha, q);
    rho_1 = rho;
  }
  return x;
}

相关文章