本文整理汇总了Java中gnu.trove.iterator.TLongFloatIterator类的典型用法代码示例。如果您正苦于以下问题:Java TLongFloatIterator类的具体用法?Java TLongFloatIterator怎么用?Java TLongFloatIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TLongFloatIterator类属于gnu.trove.iterator包,在下文中一共展示了TLongFloatIterator类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: mutiplyMatrix
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
public SparseMatrix mutiplyMatrix(SparseMatrix a){
int m = this.size()[0];
int n = a.size()[1];
int dim[]={m,n};
SparseMatrix matrix = new SparseMatrix(dim);
TLongFloatIterator it = this.vector.iterator();
TLongFloatIterator ita = a.vector.iterator();
for (int i = this.vector.size(); i-- > 0;)
{
it.advance();
ita = a.vector.iterator();
for(int j = a.vector.size(); j-- > 0;)
{
ita.advance();
if(this.getIndices(it.key())[1]==a.getIndices(ita.key())[0])
{
int []indices = {this.getIndices(it.key())[0],a.getIndices(ita.key())[1]};
matrix.set(indices, matrix.elementAt(indices)+it.value()*ita.value());
}
}
}
return matrix;
}
开发者ID:FudanNLP,项目名称:fnlp,代码行数:24,代码来源:SparseMatrix.java
示例2: updateW
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
SparseMatrix updateW() {
int[] dimVWH = { m, n };
int[] dimWVWHH = { m, r };
SparseMatrix matrixVWH = new SparseMatrix(dimVWH);
SparseMatrix matrixWVWHH = new SparseMatrix(dimWVWHH);
SparseMatrix matrixWH = w.mutiplyMatrix(h);
TLongFloatIterator itV = v.vector.iterator();
TLongFloatIterator itW = w.vector.iterator();
for (int i = v.vector.size(); i-- > 0;) {
itV.advance();
matrixVWH.set(itV.key(),
itV.value() / (matrixWH.elementAt(itV.key()) + eps));
}
SparseMatrix matrixTranH = h.trans();
SparseMatrix matrixVWHH = matrixVWH.mutiplyMatrix(matrixTranH);
for (int i = w.vector.size(); i-- > 0;) {
itW.advance();
matrixWVWHH.set(itW.key(),
itW.value() * matrixVWHH.elementAt(itW.key()));
}
return matrixWVWHH;
}
开发者ID:FudanNLP,项目名称:fnlp,代码行数:26,代码来源:Nmf.java
示例3: normalized
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
/**
* 矩阵归一化
*
* @param matrix
* @return 归一化后矩阵
*/
SparseMatrix normalized(SparseMatrix matrix) {
int ySize = matrix.size()[1];
float ySum[] = new float[ySize];
TLongFloatIterator it = matrix.vector.iterator();
for (int i = matrix.vector.size(); i-- > 0;) {
it.advance();
ySum[matrix.getIndices(it.key())[1]] += it.value();
}
it = matrix.vector.iterator();
for (int i = matrix.vector.size(); i-- > 0;) {
it.advance();
matrix.set(it.key(), it.value()
/ (ySum[matrix.getIndices(it.key())[1]] + eps));
}
return matrix;
}
开发者ID:FudanNLP,项目名称:fnlp,代码行数:23,代码来源:Nmf.java
示例4: minus
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
/**
* @param mat
* Sep 6, 2009
*/
public void minus(SparseMatrix mat) {
TLongFloatIterator it = mat.vector.iterator();
for (int i = mat.vector.size(); i-- > 0;)
{
it.advance();
vector.put(it.key(),vector.get(it.key()) - it.value());
}
}
开发者ID:FudanNLP,项目名称:fnlp,代码行数:14,代码来源:SparseMatrix.java
示例5: add
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
public void add(SparseMatrix mat) {
TLongFloatIterator it = mat.vector.iterator();
for (int i = mat.vector.size(); i-- > 0;)
{
it.advance();
vector.put(it.key(),vector.get(it.key()) + it.value());
}
}
开发者ID:FudanNLP,项目名称:fnlp,代码行数:10,代码来源:SparseMatrix.java
示例6: l1Norm
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
public float l1Norm() {
float norm = 0;
TLongFloatIterator it = vector.iterator();
for (int i = vector.size(); i-- > 0;) {
it.advance();
norm += Math.abs(it.value());
}
return norm;
}
开发者ID:FudanNLP,项目名称:fnlp,代码行数:10,代码来源:SparseMatrix.java
示例7: l2Norm
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
public float l2Norm() {
float norm = 0;
TLongFloatIterator it = vector.iterator();
for (int i = vector.size(); i-- > 0;) {
it.advance();
norm += it.value()*it.value();
}
return (float) Math.sqrt(norm);
}
开发者ID:FudanNLP,项目名称:fnlp,代码行数:10,代码来源:SparseMatrix.java
示例8: infinityNorm
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
public float infinityNorm() {
float norm = 0;
TLongFloatIterator it = vector.iterator();
for (int i = vector.size(); i-- > 0;) {
it.advance();
if (Math.abs(it.value()) > norm)
norm = Math.abs(it.value());
}
it=null;
return norm;
}
开发者ID:FudanNLP,项目名称:fnlp,代码行数:12,代码来源:SparseMatrix.java
示例9: trans
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
/**
* @return
* Sep 6, 2009
*/
public SparseMatrix trans() {
int []newdim = {dim[1],dim[0]};
SparseMatrix newmat = new SparseMatrix(newdim);
TLongFloatIterator itW = vector.iterator();
for (int i = vector.size(); i-- > 0;)
{
itW.advance();
int x = getIndices(itW.key())[0];
int y = getIndices(itW.key())[1];
int []TranWIndices = {y,x};
newmat.set(TranWIndices,itW.value());
}
return newmat;
}
开发者ID:FudanNLP,项目名称:fnlp,代码行数:19,代码来源:SparseMatrix.java
示例10: updateH
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
SparseMatrix updateH() {
int[] dimWH = { m, n };
int[] dimVWH = { m, n };
int[] dimHWVWH = { r, n };
SparseMatrix matrixWH = new SparseMatrix(dimWH);
SparseMatrix matrixVWH = new SparseMatrix(dimVWH);
SparseMatrix matrixHWVWH = new SparseMatrix(dimHWVWH);
matrixWH = w.mutiplyMatrix(h);
TLongFloatIterator itV = v.vector.iterator();
TLongFloatIterator itH = h.vector.iterator();
for (int i = v.vector.size(); i-- > 0;) {
itV.advance();
matrixVWH.set(itV.key(),
itV.value() / (matrixWH.elementAt(itV.key()) + eps));
}
SparseMatrix matrixTranW = w.trans();
SparseMatrix matrixWVWH = matrixTranW.mutiplyMatrix(matrixVWH);
for (int i = h.vector.size(); i-- > 0;) {
itH.advance();
matrixHWVWH.set(itH.key(),
itH.value() * matrixWVWH.elementAt(itH.key()));
}
return matrixHWVWH;
}
开发者ID:FudanNLP,项目名称:fnlp,代码行数:31,代码来源:Nmf.java
示例11: iterator
import gnu.trove.iterator.TLongFloatIterator; //导入依赖的package包/类
public TLongFloatIterator iterator() {
return container.iterator();
}
开发者ID:bacta,项目名称:pre-cu,代码行数:4,代码来源:AutoDeltaLongFloatMap.java
注:本文中的gnu.trove.iterator.TLongFloatIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论