Jama.Matrix.plus()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(173)

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

Matrix.plus介绍

暂无

代码示例

代码示例来源:origin: percyliang/fig

public void add(SuffStats _stats) { // Add several data points
 MultGaussianSuffStats stats = (MultGaussianSuffStats)_stats;
 // TODO : in place for efficiency
 sum = sum.plus(stats.sum);
 outerproducts = outerproducts.plus(stats.outerproducts);
 n += stats.n;
}
public void sub(double[] _x) { // Remove a data point

代码示例来源:origin: net.sf.meka/meka

/**
 * Update - Carry out one epoch of CD, update W.
 * We use dW_ to manage momentum.
 * <br>
 * TODO weight decay SHOULD NOT BE APPLIED TO BIASES
 * @param    X     X
 */
public void update(Matrix X) {
  Matrix CD = epoch(X);
  Matrix dW = (CD.minusEquals(this.W.times(COST))).timesEquals(LEARNING_RATE); 	// with COST
  this.W.plusEquals(dW.plus(this.dW_.timesEquals(MOMENTUM)));                  	// with MOMENTUM.
  this.dW_ = dW;																	// for the next update
}

代码示例来源:origin: stackoverflow.com

Matrix x,y,z;
x=Matrix.getMatrix(3,3);
y=Matrix.getMatrix(3,3);
z=x.plus(y);
z.print();

代码示例来源:origin: Waikato/meka

/**
 * Update - Carry out one epoch of CD, update W.
 * We use dW_ to manage momentum.
 * <br>
 * TODO weight decay SHOULD NOT BE APPLIED TO BIASES
 * @param    X     X
 */
public void update(Matrix X) {
  Matrix CD = epoch(X);
  Matrix dW = (CD.minusEquals(this.W.times(COST))).timesEquals(LEARNING_RATE); 	// with COST
  this.W.plusEquals(dW.plus(this.dW_.timesEquals(MOMENTUM)));                  	// with MOMENTUM.
  this.dW_ = dW;																	// for the next update
}

代码示例来源:origin: percyliang/fig

public void add(double[] _x) { // Add a data point
 Matrix x = new Matrix(_x, _x.length);
 // TODO : in place for efficiency
 sum = sum.plus(x); 
 outerproducts = outerproducts.plus(x.times(x.transpose()));
 n++;
}
public void add(SuffStats _stats) { // Add several data points

代码示例来源:origin: net.sf.meka/meka

/**
 * Update - Carry out one epoch of CD, update W.
 * <br>
 * TODO    combine with above fn.
 * @param    X     X
 * @param    s    multiply the gradient by this scalar
 */
public void update(Matrix X, double s) {
  Matrix CD = epoch(X);
  Matrix dW = (CD.minusEquals(this.W.times(COST))).timesEquals(LEARNING_RATE); 	// with COST
  dW = dW.times(s); // *scaling factor
  this.W.plusEquals(dW.plus(this.dW_.timesEquals(MOMENTUM)));                  	// with MOMENTUM.
  this.dW_ = dW;																	// for the next update
}

代码示例来源:origin: lessthanoptimal/Java-Matrix-Benchmark

@Override
  public long process(BenchmarkMatrix[] inputs, BenchmarkMatrix[] outputs, long numTrials) {
    Matrix matA = inputs[0].getOriginal();
    Matrix matB = inputs[1].getOriginal();
    Matrix result = null;
    long prev = System.nanoTime();
    for( long i = 0; i < numTrials; i++ ) {
      result = matA.plus(matB);
    }
    long elapsed = System.nanoTime()-prev;
    if( outputs != null ) {
      outputs[0] = new JamaBenchmarkMatrix(result);
    }
    return elapsed;
  }
}

代码示例来源:origin: Waikato/meka

/**
 * Update - Carry out one epoch of CD, update W.
 * <br>
 * TODO    combine with above fn.
 * @param    X     X
 * @param    s    multiply the gradient by this scalar
 */
public void update(Matrix X, double s) {
  Matrix CD = epoch(X);
  Matrix dW = (CD.minusEquals(this.W.times(COST))).timesEquals(LEARNING_RATE); 	// with COST
  dW = dW.times(s); // *scaling factor
  this.W.plusEquals(dW.plus(this.dW_.timesEquals(MOMENTUM)));                  	// with MOMENTUM.
  this.dW_ = dW;																	// for the next update
}

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

@Override
public double[] sample(Random rng) {
  final Matrix vec = new Matrix(N, 1);
  for (int i = 0; i < N; i++)
    vec.set(i, 0, rng.nextGaussian());
  final Matrix result = this.mean.plus(chol.times(vec).transpose());
  return result.getArray()[0];
}

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

public LinearDynamicSystem addFullStateFeedback(Matrix matrixK) {
  if (matrixB == null) {
    throw new RuntimeException("Matrix B must not be null for addFullStateFeedback!");
  }
  Matrix newMatrixA = matrixA.plus(matrixB.times(matrixK.times(-1.0)));
  Matrix newMatrixB = matrixB.copy();
  Matrix newMatrixC = null,
      newMatrixD = null;
  if (matrixC != null) {
    newMatrixC = matrixC;
    if (matrixD != null) {
      newMatrixC = matrixC.plus(matrixD.times(matrixK.times(-1.0)));
      newMatrixD = matrixD.copy();
    }
  }
  return new LinearDynamicSystem(newMatrixA, newMatrixB, newMatrixC, newMatrixD);
}

代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit

public LinearDynamicSystem addFullStateFeedback(Matrix matrixK) {
  if (matrixB == null) {
    throw new RuntimeException("Matrix B must not be null for addFullStateFeedback!");
  }
  Matrix newMatrixA = matrixA.plus(matrixB.times(matrixK.times(-1.0)));
  Matrix newMatrixB = matrixB.copy();
  Matrix newMatrixC = null,
      newMatrixD = null;
  if (matrixC != null) {
    newMatrixC = matrixC;
    if (matrixD != null) {
      newMatrixC = matrixC.plus(matrixD.times(matrixK.times(-1.0)));
      newMatrixD = matrixD.copy();
    }
  }
  return new LinearDynamicSystem(newMatrixA, newMatrixB, newMatrixC, newMatrixD);
}

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

Matrix calcShape3D(Matrix plocal) {
  assert ((plocal.getRowDimension() == _E.getColumnDimension()) && (plocal
      .getColumnDimension() == 1));
  Matrix s = _M.plus(_V.times(plocal));
  return s;
}

代码示例来源:origin: org.openimaj/FaceTracker

Matrix calcShape3D(Matrix plocal) {
  assert ((plocal.getRowDimension() == _E.getColumnDimension()) && (plocal
      .getColumnDimension() == 1));
  Matrix s = _M.plus(_V.times(plocal));
  return s;
}

代码示例来源:origin: org.ujmp/ujmp-jama

public Matrix plus(Matrix m) {
  if (m instanceof JamaDenseDoubleMatrix2D) {
    Matrix result = new JamaDenseDoubleMatrix2D(matrix.plus(((JamaDenseDoubleMatrix2D) m).matrix));
    MapMatrix<String, Object> a = getMetaData();
    if (a != null) {
      result.setMetaData(a.clone());
    }
    return result;
  } else {
    return super.plus(m);
  }
}

代码示例来源:origin: ujmp/universal-java-matrix-package

public Matrix plus(Matrix m) {
  if (m instanceof JamaDenseDoubleMatrix2D) {
    Matrix result = new JamaDenseDoubleMatrix2D(matrix.plus(((JamaDenseDoubleMatrix2D) m).matrix));
    MapMatrix<String, Object> a = getMetaData();
    if (a != null) {
      result.setMetaData(a.clone());
    }
    return result;
  } else {
    return super.plus(m);
  }
}

代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit

public double[][] simulateInitialConditions(double[] initialConditions, double stepSize, int numTicks) {
  int order = matrixA.getRowDimension();
  if (initialConditions.length != order) {
    throw new RuntimeException("initialConditions.length != order");
  }
  // Just use Euler integrations for now:
  double[][] ret   = new double[numTicks][order];
  Matrix     state = new Matrix(order, 1);
  copyArray(initialConditions, state);
  for (int i = 0; i < numTicks; i++) {
    copyArray(state, ret[i]);
    Matrix aTimesX              = matrixA.times(state);
    Matrix aTimesXTimesStepSize = aTimesX.times(stepSize);
    state = state.plus(aTimesXTimesStepSize);
  }
  return ret;
}

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

@Override
public double[] sample(Random rng) {
  final int N = mean.getColumnDimension();
  final Matrix chol = getCovariance().chol().getL();
  final Matrix vec = new Matrix(N, 1);
  for (int i = 0; i < N; i++)
    vec.set(i, 0, rng.nextGaussian());
  final Matrix result = this.mean.plus(chol.times(vec).transpose());
  return result.getArray()[0];
}

代码示例来源:origin: sc.fiji/TrackMate_

/**
 * Runs the prediction step of the Kalman filter and returns the state
 * predicted by the evolution process.
 * 
 * @return a new <code>double[]</code> of 6 elements containing the
 *         predicted state: <code>x, y, z, vx, vy, vz</code> with velocity
 *         in <code>length/frame</code> units.
 * 
 */
public double[] predict()
{
  Xp = A.times( X );
  P = A.times( P.times( A.transpose() ) ).plus( Q );
  return Xp.getColumnPackedCopy();
}

代码示例来源:origin: fiji/TrackMate

/**
 * Runs the prediction step of the Kalman filter and returns the state
 * predicted by the evolution process.
 * 
 * @return a new <code>double[]</code> of 6 elements containing the
 *         predicted state: <code>x, y, z, vx, vy, vz</code> with velocity
 *         in <code>length/frame</code> units.
 * 
 */
public double[] predict()
{
  Xp = A.times( X );
  P = A.times( P.times( A.transpose() ) ).plus( Q );
  return Xp.getColumnPackedCopy();
}

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

@Override
  protected void mstep(EMGMM gmm, GaussianMixtureModelEM learner, Matrix X, Matrix responsibilities,
      Matrix weightedXsum,
      double[] norm)
{
    final Matrix avgX2uw = responsibilities.transpose().times(X.arrayTimes(X));
    for (int i = 0; i < gmm.gaussians.length; i++) {
      final Matrix weightedXsumi = new Matrix(new double[][] { weightedXsum.getArray()[i] });
      final Matrix avgX2uwi = new Matrix(new double[][] { avgX2uw.getArray()[i] });
      final Matrix avgX2 = avgX2uwi.times(norm[i]);
      final Matrix mu = ((AbstractMultivariateGaussian) gmm.gaussians[i]).mean;
      final Matrix avgMeans2 = MatrixUtils.pow(mu, 2);
      final Matrix avgXmeans = mu.arrayTimes(weightedXsumi).times(norm[i]);
      final Matrix covar = MatrixUtils.plus(avgX2.minus(avgXmeans.times(2)).plus(avgMeans2),
          learner.minCovar);
      ((DiagonalMultivariateGaussian) gmm.gaussians[i]).variance = covar.getArray()[0];
    }
  }
},

相关文章