本文整理汇总了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);
}
示例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);
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}