Package org.apache.mahout.math

Examples of org.apache.mahout.math.Matrix.assign()


      Matrix emissionMatrix = iteration.getEmissionMatrix();
      Matrix transitionMatrix = iteration.getTransitionMatrix();

      // first, assign the pseudo count
      emissionMatrix.assign(pseudoCount);
      transitionMatrix.assign(pseudoCount);

      // now count the transitions
      countTransitions(transitionMatrix, emissionMatrix, observedSequence,
          viterbiPath);
View Full Code Here


  @Test
  public void testGivensQR() throws Exception {
    // DenseMatrix m = new DenseMatrix(dims<<2,dims);
    Matrix m = new DenseMatrix(3, 3);
    m.assign(new DoubleFunction() {
      private final Random rnd = RandomUtils.getRandom();
      @Override
      public double apply(double arg0) {
        return rnd.nextDouble() * SCALE;
      }
View Full Code Here

   *
   * @return D
   */
  public Matrix getD() {
    Matrix x = new DenseMatrix(n, n);
    x.assign(0);
    x.viewDiagonal().assign(d);
    for (int i = 0; i < n; i++) {
      double v = e.getQuick(i);
      if (v > 0) {
        x.setQuick(i, i + 1, v);
View Full Code Here

          bTmp.readFields(in);
        } finally {
          in.close();
        }

        b2.assign(bTmp.get().times(bTmp.get().transpose()), Functions.PLUS);
      }
    }
    l2 = new CholeskyDecomposition(b2);
    svd = new SingularValueDecomposition(l2.getL());
  }
View Full Code Here

   * @param vectorSize initial vector size
   * @return a projection matrix
   */
  public static Matrix generateBasisNormal(int projectedVectorSize, int vectorSize) {
    Matrix basisMatrix = new DenseMatrix(projectedVectorSize, vectorSize);
    basisMatrix.assign(new Normal());
    for (MatrixSlice row : basisMatrix) {
      row.vector().assign(row.normalize());
    }
    return basisMatrix;
  }
View Full Code Here

      // size of previous layer
      int row = isFinalLayer ? actualSize : actualSize - 1;
      Matrix weightMatrix = new DenseMatrix(row, sizePrevLayer);
      // initialize weights
      final RandomWrapper rnd = RandomUtils.getRandom();
      weightMatrix.assign(new DoubleFunction() {
        @Override
        public double apply(double value) {
          return rnd.nextDouble() - 0.5;
        }
      });
View Full Code Here

        bbtSquare.assign(mC, Functions.MINUS);
        bbtSquare.assign(mC.transpose(), Functions.MINUS);
        mC = null;

        Matrix outerSq = sq.cross(sq);
        outerSq.assign(Functions.mult(xisquaredlen));
        bbtSquare.assign(outerSq, Functions.PLUS);

      }

      EigenSolverWrapper eigenWrapper = new EigenSolverWrapper(SSVDHelper.extractRawData(bbtSquare));
View Full Code Here

          bTmp.readFields(in);
        } finally {
          in.close();
        }

        b2.assign(bTmp.get().times(bTmp.get().transpose()), Functions.PLUS);
      }
    }
    l2 = new CholeskyDecomposition(b2);
    svd = new SingularValueDecomposition(l2.getL());
  }
View Full Code Here

   *
   * @return D
   */
  public Matrix getD() {
    Matrix x = new DenseMatrix(n, n);
    x.assign(0);
    x.viewDiagonal().assign(d);
    for (int i = 0; i < n; i++) {
      final double v = e.getQuick(i);
      if (v > 0) {
        x.setQuick(i, i + 1, v);
View Full Code Here

      Matrix emissionMatrix = iteration.getEmissionMatrix();
      Matrix transitionMatrix = iteration.getTransitionMatrix();

      // first, assign the pseudo count
      emissionMatrix.assign(pseudoCount);
      transitionMatrix.assign(pseudoCount);

      // now count the transitions
      countTransitions(transitionMatrix, emissionMatrix, observedSequence,
          viterbiPath);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.