当前位置: 首页>>代码示例>>Java>>正文


Java AMatrix.rowCount方法代码示例

本文整理汇总了Java中mikera.matrixx.AMatrix.rowCount方法的典型用法代码示例。如果您正苦于以下问题:Java AMatrix.rowCount方法的具体用法?Java AMatrix.rowCount怎么用?Java AMatrix.rowCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mikera.matrixx.AMatrix的用法示例。


在下文中一共展示了AMatrix.rowCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
 * If needed declares and sets up internal data structures.
 *
 * @param A Matrix being decomposed.
 */
public void init( AMatrix A ) {
    if( A.rowCount() != A.columnCount())
        throw new IllegalArgumentException("Must be square");

    if( A.columnCount() != N ) {
        N = A.columnCount();

        if( w.length < N ) {
            w = new double[ N ];
            gammas = new double[N];
            b = new double[N];
        }
    }

    QT = Matrix.create(A);
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:22,代码来源:TridiagonalDecompositionHouseholder.java

示例2: innerProduct

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
@Override
public AVector innerProduct(AMatrix m) {
	int rc=m.rowCount();
	int cc=m.columnCount();
	this.checkLength(rc);
	AVector r=Vector.createLength(cc);
	List<AVector> cols=m.getColumns();
	for (int i=0; i<cc; i++) {
		AVector col=cols.get(i);
		r.unsafeSet(i, value*col.elementSum());
	}
	return r;
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:14,代码来源:RepeatedElementVector.java

示例3: decomposeNonZero

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
 * Computes the singular value decomposition, keeping only non-zero singular values
 * @param A
 * @return
 */
public static ISVDResult decomposeNonZero(AMatrix A) {
	ISVDResult svd=decomposeCompact(A);
	
	AVector svs=svd.getSingularValues();
	int m=A.rowCount();
	int n=A.columnCount();
	int s=svs.length(); // length of singular values vector
	
	// count non-zero singular values
	int svNumber=(int)svs.nonZeroCount();
	
	if (svNumber<s) {
		int[] ixs=new int[svNumber];
		int ix=0;
		for (int i=0; i<s; i++) {
			if (svs.unsafeGet(i)==0.0) continue;
			ixs[ix++]=i;
		}
		
		AVector newSvs=svs.selectClone(ixs); // truncated vector of singular values
		
		// copy columns corresponding to non-zero singular values
		AMatrix U=svd.getU();
		AMatrix V=svd.getV();
		AMatrix cU=Matrix.create(m, svNumber);
		AMatrix cV=Matrix.create(n, svNumber);
		for (int i=0; i<svNumber; i++) {
			int si=ixs[i]; // index of non-zero singular value
			cU.setColumn(i, U.getColumn(si));
			cV.setColumn(i, V.getColumn(si));
		}
		
		AMatrix cS=DiagonalMatrix.create(newSvs);
		return new SVDResult(cU,cS,cV,newSvs);	
	} else {
		return svd;
	}
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:44,代码来源:SVD.java

示例4: decompose

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
 * <p>
 * In order to decompose the matrix 'A' it must have full rank.  'A' is a 'm' by 'n' matrix.
 * It requires about 2n*m<sup>2</sup>-2m<sup>2</sup>/3 flops.
 * </p>
 *
 * <p>
 * The matrix provided here can be of different
 * dimension than the one specified in the constructor.  It just has to be smaller than or equal
 * to it.
 * </p>
 */
@Override
public QRResult decompose( AMatrix A ) {
    error = false;

    this.numCols = A.columnCount();
    this.numRows = A.rowCount();
    minLength = Math.min(numRows,numCols);
    int maxLength = Math.max(numRows,numCols);

    QR = Matrix.create(A);
    u = new double[ maxLength ];
    v = new double[ maxLength ];

    dataQR = QR.data;

    gammas = new double[ minLength ];
    
    for( int j = 0; j < minLength; j++ ) {
        householder(j);
        updateA(j);
    }
    
    // if (error) return null; // TODO: figure out how to handle

    return new QRResult(getQ(), getR());
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:39,代码来源:HouseholderQR.java

示例5: addCopy

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
@Override
public AMatrix addCopy(AMatrix a) {
	if (a.isDiagonal()) {
		if (a.rowCount()!=dimensions) throw new IllegalArgumentException(ErrorMessages.incompatibleShapes(this,a));
		DiagonalMatrix m=DiagonalMatrix.create(this.getLeadingDiagonal());
		a.getLeadingDiagonal().addToArray(m.data,0);
		return m;
	} else {
		return a.addCopy(this);
	}
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:12,代码来源:ADiagonalMatrix.java

示例6: MatrixElementIterator

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
public MatrixElementIterator(AMatrix source) {
	this.source=source;
	
	// hack for matrices with zero elements
	if (source.elementCount()==0) {
		row=source.rowCount();
	}
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:9,代码来源:MatrixElementIterator.java

示例7: innerProduct

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
 * Computes the inner product of this vector with a matrix
 * @param m
 * @return a vector representing the inner product
 */
public AVector innerProduct(AMatrix m) {
	int cc=m.columnCount();
	int rc=m.rowCount();
	checkLength(rc);
	Vector r=Vector.createLength(cc);
	List<AVector> cols=m.getColumns();
	for (int i=0; i<cc; i++) {
		double v=this.dotProduct(cols.get(i));
		r.unsafeSet(i,v);
	}
	return r;		
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:18,代码来源:AVector.java

示例8: innerProduct

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
@Override
public AVector innerProduct(AMatrix m) {
	if (m instanceof SparseRowMatrix) {
		return this.innerProduct((SparseRowMatrix) m);
	}
	if (m instanceof SparseColumnMatrix) {
		return this.innerProduct((SparseColumnMatrix) m);
	}
	int cc = m.columnCount();
	int rc = m.rowCount();
	checkLength(rc);
	AVector result = SparseIndexedVector.createLength(cc);
	int nzc = 0;
	for (int i = 0; i < cc; i++) {
		double v=this.dotProduct(m.getColumn(i));
		if (v==0.0) continue;
		
		nzc++;
		if ((i>20)&&(nzc>(i/4))) {
			// switch to dense vector
			result=result.toVector();
		}
		
		result.unsafeSet(i, v);
	}
	return result;
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:28,代码来源:SparseIndexedVector.java

示例9: setA

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
public LUPResult setA(AMatrix A) {
    if(!A.isSquare())
        throw new IllegalArgumentException("Input must be a square matrix.");
    this.A = A;
    this.numRows = A.rowCount();
    this.numCols = A.columnCount();
    decomp = new AltLU();
    result = decomp._decompose(A);
    return result;
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:11,代码来源:LUSolver.java

示例10: initFromData

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
public void initFromData(AVector strengths, AMatrix vectors)
{
    //System.out.println("starting init from data");
    strengthList.clear();
    vectorList.clear();
    for(int i = 0; i < strengths.length(); i++)
        strengthList.add(strengths.get(i));
    for(int i = 0; i < vectors.rowCount(); i++)
        vectorList.add(vectors.getRow(i));
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:11,代码来源:FragmentedNeuralQueue.java

示例11: blockedMultiply

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
 * Performs fast matrix multiplication using temporary working storage for the second matrix
 * @param a
 * @param b
 * @return
 */
public static Matrix blockedMultiply(Matrix a, AMatrix b) {
	int rc=a.rowCount();
	int cc=b.columnCount();
	int ic=a.columnCount();
	
	if ((ic!=b.rowCount())) {
		throw new IllegalArgumentException(ErrorMessages.incompatibleShapes(a,b));
	}		

	Matrix result=Matrix.create(rc, cc);
	if (ic==0) return result;
	
	int block=(WORKING_SET_TARGET/ic)+1;
	// working set stores up to <block> number of columns from second matrix
	Matrix wsb=Matrix.create(Math.min(block,cc), ic);
	
	for (int bj=0; bj<cc; bj+=block) {
		int bjsize=Math.min(block, cc-bj);
		
		// copy columns into working set
		for (int t=0; t<bjsize; t++) {
			b.copyColumnTo(bj+t,wsb.data,t*ic);
		}
		
		for (int bi=0; bi<rc; bi+=block) {
			int bisize=Math.min(block, rc-bi);
			
			// compute inner block
			for (int i=bi; i<(bi+bisize); i++) {
				int aDataOffset=i*ic;
				for (int j=bj; j<(bj+bjsize); j++) {
					double val=DoubleArrays.dotProduct(a.data, aDataOffset, wsb.data, ic*(j-bj), ic);
					result.unsafeSet(i, j, val);
				}
			}
		}
	}
	return result;
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:46,代码来源:Multiplications.java

示例12: create

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
public static SparseColumnMatrix create(AMatrix source) {
	if (source instanceof SparseRowMatrix) return ((SparseRowMatrix)source).toSparseColumnMatrix();
	int cc=source.columnCount();
	int rc=source.rowCount();
	AVector[] data = new AVector[cc];
	for (int i=0; i<cc; i++) {
		AVector col = source.getColumn(i);
		if (!col.isZero())
		    data[i] = Vectorz.createSparse(col);
	}
	return new SparseColumnMatrix(data,rc,cc);
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:13,代码来源:SparseColumnMatrix.java

示例13: innerProduct

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
@Override
public AMatrix innerProduct(AMatrix m) {
	if (dimensions!=m.rowCount()) throw new IllegalArgumentException(ErrorMessages.incompatibleShapes(this, m));
	return m.innerProduct(scale);
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:6,代码来源:ScalarMatrix.java

示例14: isSameShape

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
@Override
public boolean isSameShape(AMatrix m) {
	return (dimensions==m.rowCount())&&(dimensions==m.columnCount());
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:5,代码来源:ADiagonalMatrix.java

示例15: TransposedMatrix

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
private TransposedMatrix(AMatrix source) {
	super(source.columnCount(),source.rowCount(),source);
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:4,代码来源:TransposedMatrix.java


注:本文中的mikera.matrixx.AMatrix.rowCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。