Package cc.mallet.types

Examples of cc.mallet.types.Matrix


  private Factor sliceForAlpha (Assignment assn)
  {
    double alph = assn.getDouble (alpha);
    int[] sizes = sizesFromVarSet (xs);
    Matrix diag = Matrices.diag (sizes, alph);
    Matrix matrix = Matrices.constant (sizes, -alph);
    matrix.plusEquals (diag);
    return LogTableFactor.makeFromLogMatrix (xs.toVariableArray (), (SparseMatrixn) matrix);
  }
View Full Code Here


                                                 Variable v1, Variable v2)
  {
    int max1 = v1.getNumOutcomes();
    int max2 = v2.getNumOutcomes();

    Matrix phi = new Matrixn(new int[]{max1, max2});
    for (int i = 0; i < v1.getNumOutcomes(); i++) {
      for (int j = 0; j < v2.getNumOutcomes(); j++) {
        phi.setValue(new int[]{i, j}, r.nextDouble ()); // rescale(r.nextDouble()));
      }
    }
    return new TableFactor
            (new Variable[]{v1, v2}, phi);
  }
View Full Code Here

  private static TableFactor randomNodePotential(Random r, Variable v)
  {
    int max = v.getNumOutcomes();

    Matrix phi = new Matrixn(new int[]{max});
    for (int i = 0; i < v.getNumOutcomes(); i++) {
      phi.setSingleValue(i, rescale(r.nextDouble()));
    }
    return new TableFactor
            (new Variable[]{v}, phi);
  }
View Full Code Here

  }

  private void timesEqualsLog (double logV)
  {
    Flops.increment (probs.numLocations ());
    Matrix other = (Matrix) probs.cloneMatrix ();
    other.setAll (logV);
    probs.plusEquals (other);
  }
View Full Code Here

    return new LogTableFactor (vars, logValues);
  }

  public static LogTableFactor makeFromLogMatrix (Variable[] vars, Matrix values)
  {
    Matrix logValues = (Matrix) values.cloneMatrix ();
    return new LogTableFactor (vars, logValues);
  }
View Full Code Here

    return makeFromLogValues (new Variable[]{v}, vals);
  }

  public Matrix getValueMatrix ()
  {
    Matrix logProbs = (Matrix) probs.cloneMatrix ();
    for (int loc = 0; loc < probs.numLocations (); loc++) {
      logProbs.setValueAtLocation (loc, Math.exp (logProbs.valueAtLocation (loc)));
    }
    Flops.exp (probs.numLocations ());
    return logProbs;
  }
View Full Code Here

  }

  public Matrix getLogValueMatrix ()
  {
    Flops.log (probs.numLocations ());
    Matrix logProbs = (Matrix) probs.cloneMatrix ();
    for (int loc = 0; loc < probs.numLocations (); loc++) {
      logProbs.setValueAtLocation (loc, Math.log (logProbs.valueAtLocation (loc)));
    }
    return logProbs;
  }
View Full Code Here

TOP

Related Classes of cc.mallet.types.Matrix

Copyright © 2018 www.massapicom. 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.