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


Java DoubleMatrix1D.index方法代码示例

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


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

示例1: zMult

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
public DoubleMatrix1D zMult(DoubleMatrix1D y, DoubleMatrix1D z, double alpha, double beta, final boolean transposeA) {
	int m = rows;
	int n = columns;
	if (transposeA) {
		m = columns;
		n = rows;
	}

	boolean ignore = (z==null);
	if (z==null) z = new DenseDoubleMatrix1D(m);
	
	if (!(this.isNoView && y instanceof DenseDoubleMatrix1D && z instanceof DenseDoubleMatrix1D)) {
		return super.zMult(y,z,alpha,beta,transposeA);
	}

	if (n != y.size() || m > z.size())	
		throw new IllegalArgumentException("Incompatible args: "+ ((transposeA ? viewDice() : this).toStringShort()) +", "+y.toStringShort()+", "+z.toStringShort());

	if (!ignore) z.assign(cern.jet.math.Functions.mult(beta/alpha));
	
	DenseDoubleMatrix1D zz = (DenseDoubleMatrix1D) z;
	final double[] zElements = zz.elements;
	final int zStride = zz.stride;
	final int zi = z.index(0);
	
	DenseDoubleMatrix1D yy = (DenseDoubleMatrix1D) y;
	final double[] yElements = yy.elements;
	final int yStride = yy.stride;
	final int yi = y.index(0);

	if (yElements==null || zElements==null) throw new InternalError();

	forEachNonZero(
		new cern.colt.function.IntIntDoubleFunction() {
			public double apply(int i, int j, double value) {
				if (transposeA) { int tmp=i; i=j; j=tmp; }
				zElements[zi + zStride*i] += value * yElements[yi + yStride*j];
				//z.setQuick(row,z.getQuick(row) + value * y.getQuick(column));
				//System.out.println("["+i+","+j+"]-->"+value);
				return value;
			}
		}
	);
	
	if (alpha!=1) z.assign(cern.jet.math.Functions.mult(alpha));
	return z;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:48,代码来源:TridiagonalDoubleMatrix2D.java

示例2: zMult

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
public DoubleMatrix1D zMult(DoubleMatrix1D y, DoubleMatrix1D z, double alpha, double beta, final boolean transposeA) {
	int m = rows;
	int n = columns;
	if (transposeA) {
		m = columns;
		n = rows;
	}

	boolean ignore = (z==null);
	if (z==null) z = new DenseDoubleMatrix1D(m);
	
	if (!(this.isNoView && y instanceof DenseDoubleMatrix1D && z instanceof DenseDoubleMatrix1D)) {
		return super.zMult(y,z,alpha,beta,transposeA);
	}

	if (n != y.size() || m > z.size())	
		throw new IllegalArgumentException("Incompatible args: "+ ((transposeA ? viewDice() : this).toStringShort()) +", "+y.toStringShort()+", "+z.toStringShort());

	if (!ignore) z.assign(cern.jet.math.Functions.mult(beta/alpha));
	
	DenseDoubleMatrix1D zz = (DenseDoubleMatrix1D) z;
	final double[] zElements = zz.elements;
	final int zStride = zz.stride;
	final int zi = z.index(0);
	
	DenseDoubleMatrix1D yy = (DenseDoubleMatrix1D) y;
	final double[] yElements = yy.elements;
	final int yStride = yy.stride;
	final int yi = y.index(0);

	if (yElements==null || zElements==null) throw new InternalError();

	this.elements.forEachPair(
		new cern.colt.function.IntDoubleProcedure() {
			public boolean apply(int key, double value) {
				int i = key/columns;
				int j = key%columns;
				if (transposeA) { int tmp=i; i=j; j=tmp; }
				zElements[zi + zStride*i] += value * yElements[yi + yStride*j];
				//System.out.println("["+i+","+j+"]-->"+value);
				return true;
			}
		}
	);
	
	/*
	forEachNonZero(
		new cern.colt.function.IntIntDoubleFunction() {
			public double apply(int i, int j, double value) {
				if (transposeA) { int tmp=i; i=j; j=tmp; }
				zElements[zi + zStride*i] += value * yElements[yi + yStride*j];
				//z.setQuick(row,z.getQuick(row) + value * y.getQuick(column));
				//System.out.println("["+i+","+j+"]-->"+value);
				return value;
			}
		}
	);
	*/
	
	if (alpha!=1) z.assign(cern.jet.math.Functions.mult(alpha));
	return z;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:63,代码来源:SparseDoubleMatrix2D.java


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