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


Java DoubleMatrix2D.zMult方法代码示例

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


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

示例1: doubleTest28

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 */
public static void doubleTest28() {
	double[] data={1,2,3,4,5,6};
	double[][] arrMatrix = 
	{ 
		{ 1, 2, 3, 4, 5, 6},
		{ 2, 3, 4, 5, 6, 7}
	};
	DoubleFactory2D f = DoubleFactory2D.dense;
	DoubleMatrix1D vector = new DenseDoubleMatrix1D(data);
	DoubleMatrix2D matrix = f.make(arrMatrix);
	DoubleMatrix1D res = vector.like(matrix.rows());
	
	matrix.zMult(vector,res);

	System.out.println(res);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:19,代码来源:TestMatrix2D.java

示例2: doubleTest29

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 */
public static void doubleTest29(DoubleFactory2D f) {
	double[][] data = 
	{ 
		{ 6, 5, 4 },
		{ 7, 6, 3 },
		{ 6, 5, 4 },
		{ 7, 6, 3 },
		{ 6, 5, 4 },
		{ 7, 6, 3 }
	};
	
	double[][] arrMatrix = 
	{ 
		{ 1, 2, 3, 4, 5, 6},
		{ 2, 3, 4, 5, 6, 7}
	};
	
	DoubleMatrix2D x = new DenseDoubleMatrix2D(data);
	DoubleMatrix2D matrix = f.make(arrMatrix);
	
	DoubleMatrix2D res = matrix.zMult(x,null);

	System.out.println(res);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:27,代码来源:TestMatrix2D.java

示例3: doubleTest34

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 */
public static void doubleTest34() {
	double[][] data = 
	{ 
		{ 3, 0, 0, 0 },
		{ 0, 4, 2, 0 },
		{ 0, 0, 0, 0 },
		{ 0, 0, 0, 0 },
	};
	
	DoubleMatrix2D A = new DenseDoubleMatrix2D(data);
	Property.DEFAULT.generateNonSingular(A);
	DoubleMatrix2D inv = Algebra.DEFAULT.inverse(A);


	System.out.println("\n\n\n"+A);
	System.out.println("\n"+inv);
	DoubleMatrix2D B = A.zMult(inv,null);
	System.out.println(B);
	if (!(B.equals(DoubleFactory2D.dense.identity(A.rows)))) {
		throw new InternalError();
	}
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:25,代码来源:TestMatrix2D.java

示例4: checkBuildMatrix

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/** Tests matrix construction for a supplied graph and matrix builder. 
 * Since it messes up the configuration of the graph, it has to be run at the end of every test method rather than multiple times. 
 */
protected void checkBuildMatrix(LearnerGraph gr, DoubleMatrix2D expectedAx, DoubleMatrix1D expectedB)
{
	GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
	LSolver solver = ndGraph.buildMatrix(threadNumber);
	DoubleMatrix2D Ax=solver.toDoubleMatrix2D();
	Assert.assertEquals(getExpectedMatrix2DSlowly(gr),Ax);
	if (expectedAx != null) Assert.assertEquals(expectedAx, Ax);
	DoubleMatrix1D b=solver.toDoubleMatrix1D();
	if (expectedB != null) Assert.assertEquals(expectedB, b);Assert.assertEquals(getExpectedMatrix1DSlowly(gr),b);
	solver.solveExternally(1);// check if we have a solution, just in case it fails.

	// Now check consistency.
	gr.config.setAttenuationK_testOnly(1);DoubleMatrix2D Ax1 = ndGraph.buildMatrix(threadNumber).toDoubleMatrix2D();
	gr.config.setAttenuationK(0);DoubleMatrix2D Ax0 = ndGraph.buildMatrix(threadNumber).toDoubleMatrix2D();
	DoubleMatrix1D one = DoubleFactory1D.dense.make(Ax1.rows(), 1), a=DoubleFactory1D.dense.make(Ax.rows(), 0);
	
	// check A(1)*one >= 0
	Ax1.zMult(one, a);for(int i=0;i<a.size();++i) Assert.assertTrue(a.getQuick(i)>=0);
	
	// check (A(1)-A(0))*one = b
	Ax1.assign(Ax0, cern.jet.math.Functions.minus);
	Ax1.zMult(one, a);for(int i=0;i<a.size();++i) Assert.assertTrue(a.getQuick(i) == -b.getQuick(i));
	
	// Finally, we check that neither states are incompatible (there are no reject states so there should not be any)
	int pairNumber [] = new int[gr.getStateNumber()*(gr.getStateNumber()+1)/2];
	ndGraph.findIncompatiblePairs(pairNumber, threadNumber);GDLearnerGraph.numberNonNegativeElements(pairNumber);
	for(int i=0;i<pairNumber.length;++i) pairNumber[i]=i;
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:32,代码来源:TestMatrixComputationWithMultipleThreads.java

示例5: laplacianScore

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public int[] laplacianScore(int numK, String type, double[] weights) {
		if (this.fMat == null) {
			logger.warning("No feature loaded");
			return null;
		}
		System.out.println("computeLaplacian");
		computeLaplacian(numK, type);
		DoubleMatrix2D diagSum = new SparseDoubleMatrix2D(fMat.rows(), fMat.rows()); 
		for (int i = 0; i < fMat.rows(); ++i) {
			diagSum.setQuick(i, i, sumRow[i]);
		}
		diagSum.trimToSize();

		DenseDoubleMatrix1D  onesVector = new DenseDoubleMatrix1D (fMat.rows());
		onesVector.assign(1);
		DenseDoubleMatrix1D  zerosVector = new DenseDoubleMatrix1D (fMat.rows());
		zerosVector.assign(0);

		// f = f - \frac{f^T D 1}{1^T D 1} 1
		System.out.println("compute weight");
//		DoubleMatrix1D[] trans_vec = new DoubleMatrix1D[fMat.columns()];
//		for (int i = 0; i < fMat.columns(); i++)
//		{
//			trans_vec[i] = fMat.viewColumn(i).copy();
//		}
		for (int i = 0; i < fMat.columns(); ++i) {
			if (i % 100 == 0)
				System.out.println("have handle " + i + " feature");
			DoubleMatrix1D colVector = null;
//			colVector = trans_vec[i];
			colVector = fMat.viewColumn(i).copy();
			DoubleMatrix1D tempVector = null;
			
			// potential problem: diagSum.zMult(onesVector, tempVector) will lead tempVector as null!!
			tempVector = diagSum.zMult(onesVector, tempVector);
			double temp1 = colVector.zDotProduct(tempVector);
			double temp2 = onesVector.zDotProduct(onesVector);
			
			for (int j = 0; j < colVector.size(); ++j) {
				double temp3 = colVector.getQuick(j);
				double temp4 = temp3 - temp1/temp2;
				colVector.setQuick(j, temp4);
			}
			
			Laplacian.zMult(colVector, tempVector);
			temp1 = colVector.zDotProduct(tempVector);
			diagSum.zMult(colVector, tempVector);
			temp2 = colVector.zDotProduct(tempVector);
			
			lScore.insert(i, temp1/(temp2+Double.MIN_VALUE));
			weights[i] = temp1/(temp2+Double.MIN_VALUE);
		}
		int[] sortedIndices = MaxHeap.heapSort(lScore);
		//reverse array
//		sortedIndices = lScore.getIndices();
//		double[] scores = lScore.getValues();
//		for (double score: scores)
//				System.out.print(score + " ");
//		System.out.println();
		return sortedIndices;
		
	}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:63,代码来源:LaplacianScore.java

示例6: multiplyMatrix

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
static DoubleMatrix2D multiplyMatrix(DoubleMatrix2D A, DoubleMatrix2D B) {
        DoubleMatrix2D C = new SparseDoubleMatrix2D(A.rows(), B.columns());
        A.zMult(B, C);
        return C;
}
 
开发者ID:santiontanon,项目名称:RHOG,代码行数:6,代码来源:KashimaKernelSparse.java

示例7: dgemm

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public void dgemm(boolean transposeA, boolean transposeB, double alpha, DoubleMatrix2D A, DoubleMatrix2D B, double beta, DoubleMatrix2D C) {
	A.zMult(B,C,alpha,beta,transposeA,transposeB);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:4,代码来源:SeqBlas.java

示例8: dgemv

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public void dgemv(boolean transposeA, double alpha, DoubleMatrix2D A, DoubleMatrix1D x, double beta, DoubleMatrix1D y) {
	A.zMult(x,y,alpha,beta,transposeA);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:4,代码来源:SeqBlas.java

示例9: multiplyMatrix

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 * Multiply matrix.
 * 
 * @param A
 *            the a
 * @param B
 *            the b
 * @return the double matrix2 d
 */
static DoubleMatrix2D multiplyMatrix(DoubleMatrix2D A, DoubleMatrix2D B) {
	DoubleMatrix2D C = new SparseDoubleMatrix2D(A.rows(), B.columns());
	A.zMult(B, C);
	return C;
}
 
开发者ID:santiontanon,项目名称:fterm,代码行数:15,代码来源:KashimaKernelSparse.java

示例10: verifyAxb

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/** Checks that the supplied arguments satisfy the <em>Ax=b</em> equation. 
 * 
 * @param A
 * @param b
 * @param x
 */
public static final void verifyAxb(DoubleMatrix2D A, DoubleMatrix1D b, DoubleMatrix1D x)
{
	DoubleMatrix1D result = A.zMult(x, b);for(int i=0;i<b.size();++i) Assert.assertEquals(b.getQuick(i),result.getQuick(i),Configuration.fpAccuracy);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:11,代码来源:TestSolver.java

示例11: mult

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 * Linear algebraic matrix-vector multiplication; <tt>z = A * y</tt>.
 * <tt>z[i] = Sum(A[i,j] * y[j]), i=0..A.rows()-1, j=0..y.size()-1</tt>.
 * @param A the source matrix.
 * @param y the source vector.
 * @return <tt>z</tt>; a new vector with <tt>z.size()==A.rows()</tt>.
 * 
 * @throws IllegalArgumentException if <tt>A.columns() != y.size()</tt>.
 */
public DoubleMatrix1D mult(DoubleMatrix2D A, DoubleMatrix1D y) {
	return A.zMult(y,null);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:13,代码来源:Algebra.java


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