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


Java DoubleMatrix1D.setQuick方法代码示例

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


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

示例1: testBuildMatrix4

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
@Test
public final void testBuildMatrix4()
{
	LearnerGraph gr=buildLearnerGraph("A-a->B\nA-b->C\nD-a->C",	"testBuildMatrix4",config,converter);
	final int size =4*5/2; 
	DoubleMatrix2D matrix=createIdentity(size);
	DoubleMatrix1D row=DoubleFactory1D.dense.make(size, 0);
	matrix.setQuick(2, 2, 1);matrix.setQuick(4, 4, 1);matrix.setQuick(5, 5, 1);// pairs with zero total outgoing transitions.
	matrix.setQuick(0, 0, 2*2);matrix.setQuick(0, 2, -k);matrix.setQuick(0, 5, -k);row.setQuick(0, 2);
	matrix.setQuick(1, 1, 2*2);
	matrix.setQuick(3, 3, 2*2);
	matrix.setQuick(6, 6, 2*2);

	matrix.setQuick(9, 5, -k);row.setQuick(9, 1);
	matrix.setQuick(6, 4, -k);row.setQuick(6, 1);
			
	checkBuildMatrix(gr,matrix,row);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:19,代码来源:TestMatrixComputationWithMultipleThreads.java

示例2: testBuildMatrix5

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
@Test
public final void testBuildMatrix5()
{
	LearnerGraph gr=buildLearnerGraph("A-a->B\nA-b->C\nD-a->C\nD-b->C","testBuildMatrix5",config,converter);
	final int size =4*5/2; 
	DoubleMatrix2D matrix=createIdentity(size);
	DoubleMatrix1D row=DoubleFactory1D.dense.make(size, 0);
	matrix.setQuick(2, 2, 1);matrix.setQuick(4, 4, 1);matrix.setQuick(5, 5, 1);// pairs with zero total outgoing transitions.
	matrix.setQuick(0, 0, 2*2);matrix.setQuick(0, 2, -k);matrix.setQuick(0, 5, -k);row.setQuick(0, 2);
	matrix.setQuick(1, 1, 2*2);
	matrix.setQuick(3, 3, 2*2);
	matrix.setQuick(6, 6, 2*2);

	matrix.setQuick(9, 5, -2*k);row.setQuick(9, 2);
	matrix.setQuick(6, 4, -k);matrix.setQuick(6, 5, -k);row.setQuick(6, 2);
	matrix.setQuick(9, 9, 2*2);
	matrix.setQuick(8, 8, 2*2);
	matrix.setQuick(7, 7, 2*2);
	matrix.setQuick(6, 6, 2*2);
	
	checkBuildMatrix(gr,matrix,row);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:23,代码来源:TestMatrixComputationWithMultipleThreads.java

示例3: testBuildMatrix6

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
@Test
public final void testBuildMatrix6()
{
	LearnerGraph gr=buildLearnerGraph("A-a->B\nA-b->C\nD-a->C\nD-b->C\nD-c->A","testBuildMatrix6",config,converter);
	final int size =4*5/2; 
	DoubleMatrix2D matrix=createIdentity(size);
	DoubleMatrix1D row=DoubleFactory1D.dense.make(size, 0);
	matrix.setQuick(2, 2, 1);matrix.setQuick(4, 4, 1);matrix.setQuick(5, 5, 1);// pairs with zero total outgoing transitions.
	matrix.setQuick(0, 0, 2*2);matrix.setQuick(0, 2, -k);matrix.setQuick(0, 5, -k);row.setQuick(0, 2);
	matrix.setQuick(1, 1, 2*2);
	matrix.setQuick(3, 3, 2*2);
	matrix.setQuick(6, 6, 2*2);

	matrix.setQuick(9, 5, -2*k);matrix.setQuick(9, 0, -k);row.setQuick(9, 3);
	matrix.setQuick(6, 4, -k);matrix.setQuick(6, 5, -k);row.setQuick(6, 2);
	matrix.setQuick(9, 9, 3*2);
	matrix.setQuick(8, 8, 3*2);
	matrix.setQuick(7, 7, 3*2);
	matrix.setQuick(6, 6, 3*2);
	
	checkBuildMatrix(gr,matrix,row);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:23,代码来源:TestMatrixComputationWithMultipleThreads.java

示例4: testBuildMatrix7

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
@Test
public final void testBuildMatrix7()
{
	LearnerGraph gr=buildLearnerGraph("A-a->B\nA-b->C\nA-c->C\nD-a->C\nD-b->C\nD-c->A","testBuildMatrix7",config,converter);

	final int size =4*5/2; 
	DoubleMatrix2D matrix=createIdentity(size);
	DoubleMatrix1D row=DoubleFactory1D.dense.make(size, 0);
	matrix.setQuick(2, 2, 1);matrix.setQuick(4, 4, 1);matrix.setQuick(5, 5, 1);// pairs with zero total outgoing transitions.
	matrix.setQuick(0, 0, 3*2);matrix.setQuick(0, 2, -k);matrix.setQuick(0, 5, -2*k);row.setQuick(0, 3);
	matrix.setQuick(1, 1, 3*2);
	matrix.setQuick(3, 3, 3*2);
	matrix.setQuick(6, 6, 3*2);

	matrix.setQuick(9, 5, -2*k);matrix.setQuick(9, 0, -k);row.setQuick(9, 3);
	matrix.setQuick(6, 4, -k);matrix.setQuick(6, 5, -k);matrix.setQuick(6, 3, -k);row.setQuick(6, 3);
	matrix.setQuick(9, 9, 3*2);
	matrix.setQuick(8, 8, 3*2);
	matrix.setQuick(7, 7, 3*2);
	matrix.setQuick(6, 6, 3*2);
	
	checkBuildMatrix(gr,matrix,row);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:24,代码来源:TestMatrixComputationWithMultipleThreads.java

示例5: testBuildMatrix8

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
@Test
public final void testBuildMatrix8()
{
	LearnerGraph gr=buildLearnerGraph("A-a->B\nA-b->C\nA-c->C\nD-a->C\nD-b->C\nD-d->C\nD-c->A","testBuildMatrix8",config,converter);

	final int size =4*5/2; 
	DoubleMatrix2D matrix=createIdentity(size);
	DoubleMatrix1D row=DoubleFactory1D.dense.make(size, 0);
	matrix.setQuick(2, 2, 1);matrix.setQuick(4, 4, 1);matrix.setQuick(5, 5, 1);// pairs with zero total outgoing transitions.
	matrix.setQuick(0, 0, 3*2);matrix.setQuick(0, 2, -k);matrix.setQuick(0, 5, -2*k);row.setQuick(0, 3);
	matrix.setQuick(1, 1, 3*2);
	matrix.setQuick(3, 3, 3*2);
	matrix.setQuick(6, 6, 3*2);

	matrix.setQuick(9, 5, -3*k);matrix.setQuick(9, 0, -k);row.setQuick(9, 4);
	matrix.setQuick(6, 4, -k);matrix.setQuick(6, 5, -k);matrix.setQuick(6, 3, -k);row.setQuick(6, 3);
	matrix.setQuick(9, 9, 4*2);
	matrix.setQuick(8, 8, 4*2);
	matrix.setQuick(7, 7, 4*2);
	matrix.setQuick(6, 6, 4*2);
	
	checkBuildMatrix(gr,matrix,row);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:24,代码来源:TestMatrixComputationWithMultipleThreads.java

示例6: computeLogMi

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
static boolean computeLogMi(FeatureGenerator featureGen, double lambda[], 
        DoubleMatrix2D Mi_YY,
        DoubleMatrix1D Ri_Y, boolean takeExp,boolean reuseM, boolean initMDone) {
    
    if (reuseM && initMDone) {
        Mi_YY = null;
    } else {
        initMDone = false;
    }
    if (Mi_YY != null) Mi_YY.assign(0);
    Ri_Y.assign(0);
    initMDone = computeLogMiInitDone(featureGen,lambda,Mi_YY,Ri_Y,0);
    if (takeExp) {
        for(int r = Ri_Y.size()-1; r >= 0; r--) {
            Ri_Y.setQuick(r,expE(Ri_Y.getQuick(r)));
            if (Mi_YY != null)
                for(int c = Mi_YY.columns()-1; c >= 0; c--) {
                    Mi_YY.setQuick(r,c,expE(Mi_YY.getQuick(r,c)));
                }
        }
    }
    return initMDone;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:24,代码来源:Trainer.java

示例7: dsymv

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的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

示例8: getExpectedMatrix1DSlowly

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
protected DoubleMatrix1D getExpectedMatrix1DSlowly(LearnerGraph gr)
{
	int size=gr.getStateNumber()*(gr.getStateNumber()+1)/2;
	DoubleMatrix1D result = DoubleFactory1D.dense.make(size);
	StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
	GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
	DetermineDiagonalAndRightHandSide ddrhInstance = ndGraph.new DDRH_default();
	for(Entry<CmpVertex,Map<Label,List<CmpVertex>>> entryA:ndGraph.matrixForward.transitionMatrix.entrySet())
	{
		// Now iterate through states
		Iterator<Entry<CmpVertex,Map<Label,List<CmpVertex>>>> stateB_It = ndGraph.matrixForward.transitionMatrix.entrySet().iterator();
		while(stateB_It.hasNext())
		{
			Entry<CmpVertex,Map<Label,List<CmpVertex>>> stateB = stateB_It.next();

			int currentStatePair = ndGraph.vertexToIntNR(stateB.getKey(),entryA.getKey());
			ddrhInstance.compute(entryA.getKey(),stateB.getKey(),entryA.getValue(),stateB.getValue());
			result.setQuick(currentStatePair, ddrhInstance.getRightHandSide());
			
			if (stateB.getKey().equals(entryA.getKey())) break; // we only process a triangular subset.
		}
	}
	
	return result;
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:26,代码来源:TestMatrixComputationWithMultipleThreads.java

示例9: testBuildMatrix3

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
@Test
public final void testBuildMatrix3()
{
	LearnerGraph gr=buildLearnerGraph("A-a->B\nC-a->D",	"testBuildMatrix3",config,converter);
	final int size =4*5/2; 
	DoubleMatrix2D matrix=createIdentity(size);
	DoubleMatrix1D row=DoubleFactory1D.dense.make(size, 0);
	matrix.setQuick(2, 2, 1);matrix.setQuick(7, 7, 1);matrix.setQuick(9, 9, 1);// pairs with zero total outgoing transitions.
	matrix.setQuick(0, 2, -k);row.setQuick(0, 1);
	matrix.setQuick(5, 9, -k);row.setQuick(5, 1);
	matrix.setQuick(3, 7, -k);row.setQuick(3, 1);
	
	checkBuildMatrix(gr,matrix,row);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:15,代码来源:TestMatrixComputationWithMultipleThreads.java

示例10: zMult

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
/**
 * Linear algebraic matrix-vector multiplication; <tt>z = A * y</tt>.
 * <tt>z[i] = alpha*Sum(A[i,j] * y[j]) + beta*z[i], i=0..A.rows()-1, j=0..y.size()-1</tt>.
 * Where <tt>A == this</tt>.
 * @param y the source vector.
 * @param z the vector where results are to be stored.
 * 
 * @throws IllegalArgumentException if <tt>A.columns() != y.size() || A.rows() > z.size())</tt>.
 */
protected void zMult(final DoubleMatrix1D y, final DoubleMatrix1D z, cern.colt.list.IntArrayList nonZeroIndexes, DoubleMatrix1D[] allRows, final double alpha, final double beta) {
	if (columns != y.size() || rows > z.size())	
		throw new IllegalArgumentException("Incompatible args: "+toStringShort()+", "+y.toStringShort()+", "+z.toStringShort());

	z.assign(cern.jet.math.Functions.mult(beta/alpha));
	for (int i = indexes.length; --i >= 0; ) {
		if (indexes[i] != null) {
			for (int k = indexes[i].size(); --k >= 0; ) {
				int j = indexes[i].getQuick(k);
				double value = values[i].getQuick(k);
				z.setQuick(i,z.getQuick(i) + value * y.getQuick(j));
			}
		}
	}
		
	z.assign(cern.jet.math.Functions.mult(alpha));
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:27,代码来源:RCMDoubleMatrix2D.java

示例11: dtrmv

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的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

示例12: laplacianScore

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的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

示例13: doRR1

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
private static void doRR1(int L, DoubleMatrix1D w, double[][] x, double[] y, double[] c, double lambda) {
    int N = x.length;
    int K = x[0].length;
    
    double[] e = new double[N];
    for (int i = 0; i < N; i++) {
        double pred = 0.0;
        for (int k = 0; k < K; k++) {
            pred += w.getQuick(k) * x[i][k];
        }
        e[i] = y[i] - pred;
    }

    for (int l = 0; l < L; l++) {
        for (int k = 0; k < K; k++) {
            for (int i = 0; i < N; i++) {
                e[i] += w.getQuick(k) * x[i][k];
            }
            double a = 0.0;
            double d = 0.0;
            for (int i = 0; i < N; i++) {
                a += c[i] * x[i][k] * x[i][k];
                d += c[i] * x[i][k] * e[i];
            }
            w.setQuick(k, d / (lambda + a));
            for (int i = 0; i < N; i++) {
                e[i] -= w.getQuick(k) * x[i][k];
            }
        }
    }

}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:33,代码来源:PZTFactorizer.java

示例14: testExternalSolver1

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
@Test
public final void testExternalSolver1()
{
	LSolver s = new LSolver(testMatrix,DoubleFactory1D.dense.make(new double[]{8., 45., -3., 3., 19.}));
	DoubleMatrix1D x = DoubleFactory1D.dense.make(testMatrix.rows());
	for(int i=0;i<s.j_b.length;++i) x.setQuick(i, s.j_b[i]);
	
	// Test 1
	s.solveExternally(1);
	for(int i=0;i<testMatrix.rows();++i)
		Assert.assertEquals(i+1, s.j_x[i],Configuration.fpAccuracy);
	verifyAxb(s);
	
	// Test 2
	LUDecompositionQuick solver = new LUDecompositionQuick();
	solver.decompose(testMatrix);solver.setLU(testMatrix);
	solver.solve(x);
	for(int i=0;i<testMatrix.rows();++i)
		Assert.assertEquals(i+1, x.getQuick(i),Configuration.fpAccuracy);
	verifyAxb(s);

	// Test 3
	for(int i=0;i<testMatrix.rows();++i) s.j_x[i]=0;
	s.solveUsingColt();
	for(int i=0;i<testMatrix.rows();++i)
		Assert.assertEquals(i+1, s.j_x[i],Configuration.fpAccuracy);
	verifyAxb(s);
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:29,代码来源:TestSolver.java

示例15: testExternalSolver_fail6

import cern.colt.matrix.DoubleMatrix1D; //导入方法依赖的package包/类
@Test
public final void testExternalSolver_fail6()
{
	final int size = testMatrix.rows();
	final DoubleMatrix2D matrix = DoubleFactory2D.sparse.make(size,size);
	final LSolver solver = new LSolver(matrix,DoubleFactory1D.dense.make(new double[]{8., 45., -3., 3., 19.}));
	final DoubleMatrix1D x = DoubleFactory1D.dense.make(testMatrix.rows());
	
	for(int i=0;i<solver.j_b.length;++i) x.setQuick(i, solver.j_b[i]);
	
	checkForCorrectException(new whatToRun() {
		public @Override void run() throws NumberFormatException {
			solver.solveExternally(1);
		}
	}, IllegalArgumentException.class,"singular");		

	checkForCorrectException(new whatToRun() {
		public @Override void run() throws NumberFormatException {
			LUDecompositionQuick coltSolver = new LUDecompositionQuick();
			coltSolver.decompose(matrix);coltSolver.setLU(matrix);
			coltSolver.solve(x);
		}
	}, IllegalArgumentException.class,"singular");		

	checkForCorrectException(new whatToRun() {
		public @Override void run() throws NumberFormatException {
			for(int i=0;i<testMatrix.rows();++i) solver.j_x[i]=0;
			solver.solveUsingColt();
		}
	}, IllegalArgumentException.class,"singular");		
}
 
开发者ID:kirilluk,项目名称:statechum,代码行数:32,代码来源:TestSolver.java


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