本文整理汇总了Java中gnu.trove.iterator.TLongFloatIterator.advance方法的典型用法代码示例。如果您正苦于以下问题:Java TLongFloatIterator.advance方法的具体用法?Java TLongFloatIterator.advance怎么用?Java TLongFloatIterator.advance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.iterator.TLongFloatIterator
的用法示例。
在下文中一共展示了TLongFloatIterator.advance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}