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


Java DoubleMatrix2D.viewDice方法代码示例

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


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

示例1: doubleTest8

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 */
public static void doubleTest8() {
int rows = 2;
int columns = 3; // make a 4*5 matrix
DoubleMatrix2D master = Factory2D.ascending(rows,columns);
//master.assign(1); // set all cells to 1
System.out.println("\n"+master);
//master.viewPart(2,0,2,3).assign(2); // set [2,1] .. [3,3] to 2
//System.out.println("\n"+master);

DoubleMatrix2D view1 = master.viewDice();
System.out.println("view1="+view1);
DoubleMatrix2D view2 = view1.viewDice();
System.out.println("view2="+view2);

view2.assign(-1);
System.out.println("master replaced"+master);
System.out.println("flip1 replaced"+view1);
System.out.println("flip2 replaced"+view2);

}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:23,代码来源:TestMatrix2D.java

示例2: dsymv

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public void dsymv(boolean isUpperTriangular, double alpha, DoubleMatrix2D A, DoubleMatrix1D x, double beta, DoubleMatrix1D y) {
	if (isUpperTriangular) A = A.viewDice();
	Property.DEFAULT.checkSquare(A);
	int size = A.rows();
	if (size != x.size() || size!=y.size()) {
		throw new IllegalArgumentException(A.toStringShort() + ", " + x.toStringShort() + ", " + y.toStringShort());
	}
	DoubleMatrix1D tmp = x.like();
	for (int i = 0; i < size; i++) {
		double sum = 0;
		for (int j = 0; j <= i; j++) {
			sum += A.getQuick(i,j) * x.getQuick(j);
		}
		for (int j = i + 1; j < size; j++) {
			sum += A.getQuick(j,i) * x.getQuick(j);
		}
		tmp.setQuick(i, alpha * sum + beta * y.getQuick(i));
	}
	y.assign(tmp);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:21,代码来源:SeqBlas.java

示例3: dtrmv

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public void dtrmv(boolean isUpperTriangular, boolean transposeA, boolean isUnitTriangular, DoubleMatrix2D A, DoubleMatrix1D x) {
	if (transposeA) {
		A = A.viewDice();
		isUpperTriangular = !isUpperTriangular;
	}
	
	Property.DEFAULT.checkSquare(A);
	int size = A.rows();
	if (size != x.size()) {
		throw new IllegalArgumentException(A.toStringShort() + ", " + x.toStringShort());
	}
	    
	DoubleMatrix1D b = x.like();
	DoubleMatrix1D y = x.like();
	if (isUnitTriangular) {
		y.assign(1);
	}
	else {
		for (int i = 0; i < size; i++) {
			y.setQuick(i, A.getQuick(i,i));
		}
	}
	
	for (int i = 0; i < size; i++) {
		double sum = 0;
		if (!isUpperTriangular) {
			for (int j = 0; j < i; j++) {
				sum += A.getQuick(i,j) * x.getQuick(j);
			}
			sum += y.getQuick(i) * x.getQuick(i);
		}
		else {
			sum += y.getQuick(i) * x.getQuick(i);
			for (int j = i + 1; j < size; j++) {
				sum += A.getQuick(i,j) * x.getQuick(j);			}
		}
		b.setQuick(i,sum);
	}
	x.assign(b);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:41,代码来源:SeqBlas.java

示例4: zMult

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public DoubleMatrix2D zMult(DoubleMatrix2D B, DoubleMatrix2D C, final double alpha, double beta, boolean transposeA, boolean transposeB) {
	if (transposeB) B = B.viewDice();
	int m = rows;
	int n = columns;
	if (transposeA) {
		m = columns;
		n = rows;
	}
	int p = B.columns;
	boolean ignore = (C==null);
	if (C==null) C = new DenseDoubleMatrix2D(m,p);

	if (B.rows != n)
		throw new IllegalArgumentException("Matrix2D inner dimensions must agree:"+toStringShort()+", "+ (transposeB ? B.viewDice() : B).toStringShort());
	if (C.rows != m || C.columns != p)
		throw new IllegalArgumentException("Incompatibel result matrix: "+toStringShort()+", "+ (transposeB ? B.viewDice() : B).toStringShort()+", "+C.toStringShort());
	if (this == C || B == C)
		throw new IllegalArgumentException("Matrices must not be identical");
	
	if (!ignore) C.assign(cern.jet.math.Functions.mult(beta));

	// cache views	
	final DoubleMatrix1D[] Brows = new DoubleMatrix1D[n];
	for (int i=n; --i>=0; ) Brows[i] = B.viewRow(i);
	final DoubleMatrix1D[] Crows = new DoubleMatrix1D[m];
	for (int i=m; --i>=0; ) Crows[i] = C.viewRow(i);

	final cern.jet.math.PlusMult fun = cern.jet.math.PlusMult.plusMult(0);

	int[] idx = indexes.elements();
	double[] vals = values.elements();
	for (int i=starts.length-1; --i >= 0; ) {
		int low = starts[i];
		for (int k=starts[i+1]; --k >= low; ) {
			int j = idx[k];
			fun.multiplicator = vals[k]*alpha;
			if (!transposeA)
				Crows[i].assign(Brows[j],fun);
			else
				Crows[j].assign(Brows[i],fun);
		}
	}

	return C;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:46,代码来源:RCDoubleMatrix2D.java

示例5: O

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
Constructs and returns a new view which is the transposition of the given matrix <tt>A</tt>.
Equivalent to {@link DoubleMatrix2D#viewDice A.viewDice()}.
This is a zero-copy transposition, taking O(1), i.e. constant time.
The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa. 
Use idioms like <tt>result = transpose(A).copy()</tt> to generate an independent matrix.
<p> 
<b>Example:</b> 
<table border="0">
  <tr nowrap> 
	<td valign="top">2 x 3 matrix: <br>
	  1, 2, 3<br>
	  4, 5, 6 </td>
	<td>transpose ==></td>
	<td valign="top">3 x 2 matrix:<br>
	  1, 4 <br>
	  2, 5 <br>
	  3, 6</td>
	<td>transpose ==></td>
	<td valign="top">2 x 3 matrix: <br>
	  1, 2, 3<br>
	  4, 5, 6 </td>
  </tr>
</table>
@return a new transposed view. 
*/
public DoubleMatrix2D transpose(DoubleMatrix2D A) {
	return A.viewDice();
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:30,代码来源:Algebra.java


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