本文整理汇总了Java中cc.mallet.types.Matrix类的典型用法代码示例。如果您正苦于以下问题:Java Matrix类的具体用法?Java Matrix怎么用?Java Matrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Matrix类属于cc.mallet.types包,在下文中一共展示了Matrix类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: diag
import cc.mallet.types.Matrix; //导入依赖的package包/类
public static Matrix diag (int[] sizes, double v)
{
int maxN = MatrixOps.max (sizes);
double[] vals = new double[maxN];
Arrays.fill (vals, v);
/* Compute indices of diagonals */
int[] idxs = new int [maxN];
for (int i = 0; i < idxs.length; i++) {
int[] oneIdx = new int [sizes.length];
Arrays.fill (oneIdx, i);
idxs[i] = Matrixn.singleIndex (sizes, oneIdx);
}
return new SparseMatrixn (sizes, idxs, vals);
}
开发者ID:mimno,项目名称:GRMM,代码行数:17,代码来源:Matrices.java
示例2: timesEqualsLog
import cc.mallet.types.Matrix; //导入依赖的package包/类
private void timesEqualsLog (double logV)
{
Flops.increment (probs.numLocations ());
Matrix other = (Matrix) probs.cloneMatrix ();
other.setAll (logV);
probs.plusEquals (other);
}
开发者ID:mimno,项目名称:GRMM,代码行数:8,代码来源:LogTableFactor.java
示例3: getValueMatrix
import cc.mallet.types.Matrix; //导入依赖的package包/类
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;
}
开发者ID:mimno,项目名称:GRMM,代码行数:10,代码来源:LogTableFactor.java
示例4: getLogValueMatrix
import cc.mallet.types.Matrix; //导入依赖的package包/类
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;
}
开发者ID:mimno,项目名称:GRMM,代码行数:10,代码来源:TableFactor.java
示例5: sliceForAlpha
import cc.mallet.types.Matrix; //导入依赖的package包/类
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);
}
开发者ID:mimno,项目名称:GRMM,代码行数:10,代码来源:PottsTableFactor.java
示例6: constant
import cc.mallet.types.Matrix; //导入依赖的package包/类
public static Matrix constant (int[] sizes, double v)
{
int singleSize = 1;
for (int i = 0; i < sizes.length; i++) {
singleSize *= sizes[i];
}
double[] vals = new double [singleSize];
Arrays.fill (vals, v);
return new SparseMatrixn (sizes, vals);
}
开发者ID:mimno,项目名称:GRMM,代码行数:13,代码来源:Matrices.java
示例7: randomEdgePotential
import cc.mallet.types.Matrix; //导入依赖的package包/类
private static TableFactor randomEdgePotential(Random r,
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);
}
开发者ID:mimno,项目名称:GRMM,代码行数:16,代码来源:TestInference.java
示例8: randomNodePotential
import cc.mallet.types.Matrix; //导入依赖的package包/类
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);
}
开发者ID:mimno,项目名称:GRMM,代码行数:12,代码来源:TestInference.java
示例9: arrayCopyFrom
import cc.mallet.types.Matrix; //导入依赖的package包/类
public final int arrayCopyFrom (int i, Matrix m) {
if (m instanceof BigDenseVector) {
System.arraycopy (((BigDenseVector)m).values, 0, values, i, ((BigDenseVector)m).values.length);
return i + ((BigDenseVector)m).values.length;
} else if (m instanceof Matrix2) {
((Matrix2)m).arrayCopyInto (values, i);
return i + m.singleSize();
} else {
for (int j = 0; j < m.singleSize(); j++)
values[i++] = m.singleValue (j);
return i;
}
}
开发者ID:sameeraxiomine,项目名称:largelda,代码行数:14,代码来源:BigDenseVector.java
示例10: arrayCopyTo
import cc.mallet.types.Matrix; //导入依赖的package包/类
public final int arrayCopyTo (int i, Matrix m) {
if (m instanceof BigDenseVector) {
System.arraycopy (values, i, ((BigDenseVector)m).values, 0, ((BigDenseVector)m).values.length);
return i + ((BigDenseVector)m).values.length;
} else if (m instanceof Matrix2) {
((Matrix2)m).arrayCopyFrom (values, i);
return i + m.singleSize();
} else {
for (int j = 0; j < m.singleSize(); j++)
m.setSingleValue (j, values[i++]);
return i;
}
}
开发者ID:sameeraxiomine,项目名称:largelda,代码行数:14,代码来源:BigDenseVector.java
注:本文中的cc.mallet.types.Matrix类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论