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


Java AMatrix.copyColumnTo方法代码示例

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


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

示例1: directMultiply

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
public static Matrix directMultiply(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);
		double[] tmp=new double[ic];
		for (int j=0; j<cc; j++) {
			b.copyColumnTo(j, tmp, 0);
			
			for (int i=0; i<rc; i++) {
//				double acc=0.0;
//				for (int k=0; k<ic; k++) {
//					acc+=a.unsafeGet(i, k)*tmp[k];
//				}
				double acc=DoubleArrays.dotProduct(a.data, i*ic, tmp, 0, ic);
				result.unsafeSet(i,j,acc);
			}
		}
		return result;		
	}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:26,代码来源:Multiplications.java

示例2: 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

示例3: set

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
@Override 
public void set(AMatrix m) {
	checkSameShape(m);
	for (int i=0; i<cols; i++) {
		m.copyColumnTo(i, data, index(0,i));
	}
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:8,代码来源:DenseColumnMatrix.java

示例4: doubleBlockedMultiply

import mikera.matrixx.AMatrix; //导入方法依赖的package包/类
/**
 * Performs fast matrix multiplication using temporary working storage for both matrices
 * @param a
 * @param b
 * @return
 */
public static Matrix doubleBlockedMultiply(AMatrix 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 sets stores up to <block> number of columns from each matrix
	Matrix wsa=Matrix.create(Math.min(block,rc), ic);
	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);
			
			// copy columns into working set
			for (int t=0; t<bisize; t++) {
				b.copyRowTo(bi+t,wsa.data,t*ic);
			}
			
			// compute inner block
			for (int i=bi; i<(bi+bisize); i++) {
				for (int j=bj; j<(bj+bjsize); j++) {
					double val=DoubleArrays.dotProduct(wsa.data, ic*(i-bi), wsb.data, ic*(j-bj), ic);
					result.unsafeSet(i, j, val);
				}
			}
		}
	}
	return result;
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:51,代码来源:Multiplications.java


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