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


Java DoubleMatrix2D.columns方法代码示例

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


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

示例1: save

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 * Saves a graph to a file
 * @see edu.uci.ics.jung.io.GraphFile#save(edu.uci.ics.jung.graph.Graph, java.lang.String)
 */
public void save(Graph<V,E> graph, String filename) {
	try {
		BufferedWriter writer =
			new BufferedWriter(new FileWriter(filename));
		DoubleMatrix2D matrix = GraphMatrixOperations.<V,E>graphToSparseMatrix(graph,
				mWeightKey);
		for (int i=0;i<matrix.rows();i++) {
			for (int j=0;j<matrix.columns();j++) {
				writer.write(String.format("%4.2f ", matrix.getQuick(i,j)));
			}
			writer.write("\n");
		}
		writer.close();
	} catch (Exception e) {
		throw new RuntimeException("Error saving file: " + filename, e);
	}
}
 
开发者ID:modsim,项目名称:vizardous,代码行数:22,代码来源:MatrixFile.java

示例2: Mult

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
static DoubleMatrix1D Mult(DoubleMatrix2D M, DoubleMatrix1D y, DoubleMatrix1D z, double alpha, double beta, boolean transposeA, EdgeGenerator edgeGen) {
    // z = alpha * A * y + beta*z
    for (int i = 0; i < z.size(); z.set(i,z.get(i)*beta),i++);
    for (int j = 0; j < M.columns(); j++) {
        for (int i = (edgeGen==null)?j:edgeGen.first(j); i < M.rows(); i = (edgeGen==null)?i+1:edgeGen.next(j,i)) {
            int r = i;
            int c = j;
            if (transposeA) {
                r = j;
                c = i;
            }
            z.set(r, z.getQuick(r) + M.getQuick(i,j)*y.getQuick(c)*alpha);
        }
    }
    return z;
}
 
开发者ID:fauconnier,项目名称:LaToe,代码行数:17,代码来源:RobustMath.java

示例3: computeLogMi

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

示例4: correlation

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 * Modifies the given covariance matrix to be a correlation matrix (in-place).
 * The correlation matrix is a square, symmetric matrix consisting of nothing but correlation coefficients.
 * The rows and the columns represent the variables, the cells represent correlation coefficients. 
 * The diagonal cells (i.e. the correlation between a variable and itself) will equal 1, for the simple reason that the correlation coefficient of a variable with itself equals 1. 
 * The correlation of two column vectors x and y is given by <tt>corr(x,y) = cov(x,y) / (stdDev(x)*stdDev(y))</tt> (Pearson's correlation coefficient).
 * A correlation coefficient varies between -1 (for a perfect negative relationship) to +1 (for a perfect positive relationship). 
 * See the <A HREF="http://www.cquest.utoronto.ca/geog/ggr270y/notes/not05efg.html"> math definition</A>
 * and <A HREF="http://www.stat.berkeley.edu/users/stark/SticiGui/Text/gloss.htm#correlation_coef"> another def</A>.
 * Compares two column vectors at a time. Use dice views to compare two row vectors at a time.
 * 
 * @param covariance a covariance matrix, as, for example, returned by method {@link #covariance(DoubleMatrix2D)}.
 * @return the modified covariance, now correlation matrix (for convenience only).
 */
public static DoubleMatrix2D correlation(DoubleMatrix2D covariance) {
	for (int i=covariance.columns(); --i >= 0; ) {
		for (int j=i; --j >= 0; ) {
			double stdDev1 = Math.sqrt(covariance.getQuick(i,i));
			double stdDev2 = Math.sqrt(covariance.getQuick(j,j));
			double cov = covariance.getQuick(i,j);
			double corr = cov / (stdDev1*stdDev2);
			
			covariance.setQuick(i,j,corr);
			covariance.setQuick(j,i,corr); // symmetric
		}
	}
	for (int i=covariance.columns(); --i >= 0; ) covariance.setQuick(i,i,1);

	return covariance;	
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:31,代码来源:Statistic.java

示例5: getSumDeviations

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static double getSumDeviations(DoubleMatrix2D proj, int[] groups) {

        int idx = 0;
        int currGroup;

        double[][] projD = proj.toArray();

        do {
            double[] avgGroup = new double[proj.columns()];
            int grpSize = 0;
            currGroup = groups[idx];
            while (idx < groups.length && groups[idx] == currGroup) {
                avgGroup = MatrixOp.sum(avgGroup, projD[idx]);
                idx++;
                grpSize++;
            }

            idx -= grpSize;
            MatrixOp.mult(avgGroup, 1.0 / (double) grpSize);

            while (idx < groups.length && groups[idx] == currGroup) {
                projD[idx] = MatrixOp.diff(projD[idx], avgGroup);
                idx++;
            }
        } while (idx < groups.length);

        double sumSqLen = 0;
        for (double[] ds : projD) {
            sumSqLen += asinh(MatrixOp.mult(ds, ds));
        }
        return sumSqLen;
    }
 
开发者ID:nolanlab,项目名称:vortex,代码行数:33,代码来源:Trajectories_MDSJ.java

示例6: getMedianDev

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static double getMedianDev(DoubleMatrix2D proj, int[] groups) {

        int idx = 0;
        int currGroup;

        double[][] projD = proj.toArray();

        do {
            double[] avgGroup = new double[proj.columns()];
            int grpSize = 0;
            currGroup = groups[idx];
            while (idx < groups.length && groups[idx] == currGroup) {
                avgGroup = MatrixOp.sum(avgGroup, projD[idx]);
                idx++;
                grpSize++;
            }

            idx -= grpSize;
            MatrixOp.mult(avgGroup, 1.0 / (double) grpSize);

            while (idx < groups.length && groups[idx] == currGroup) {
                projD[idx] = MatrixOp.diff(projD[idx], avgGroup);
                idx++;
            }
        } while (idx < groups.length);

        double[] len = new double[groups.length];
        for (int i = 0; i < groups.length; i++) {
            len[i] = Math.sqrt(MatrixOp.mult(projD[i], projD[i]));
        }
        Arrays.sort(len);
        return len[len.length / 2];
    }
 
开发者ID:nolanlab,项目名称:vortex,代码行数:34,代码来源:Trajectories_MDSJ.java

示例7: addRandom

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public static void addRandom(DoubleMatrix2D in, DoubleMatrix2D out, double temperature) {
    out.assign(in);
    int randomIndexX = (int) (Math.random() * in.columns());
    int randomIndexY = (int) (Math.random() * in.rows());
    out.setQuick(randomIndexX, randomIndexY, in.getQuick(randomIndexX, randomIndexY) + ((Math.random() - 0.5) * temperature));

}
 
开发者ID:nolanlab,项目名称:vortex,代码行数:8,代码来源:Trajectories_Correl.java

示例8: assertColtMatrixEquals

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
private void assertColtMatrixEquals(final DoubleMatrix2D m1, final com.opengamma.analytics.math.matrix.DoubleMatrix2D m2) {
  final int m = m1.rows();
  final int n = m1.columns();
  assertEquals(m, m2.getNumberOfRows());
  assertEquals(n, m2.getNumberOfColumns());
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      assertEquals(m1.get(i, j), m2.getEntry(i, j), EPS);
    }
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:12,代码来源:SVDecompositionColtResultTest.java

示例9: normalizePiz

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 * Normalizes matrix of p(i|z) such that \forall_z: \sum_i p(i|z) = 1.
 *
 * @param piz normalized matrix of p(i|z)
 */
@Override
protected void normalizePiz(DoubleMatrix2D piz) {
    for (int i = 0; i < piz.columns(); i++) {
        DoubleMatrix1D tmp = piz.viewColumn(i);
        double norm = tmp.aggregate(Functions.plus, Functions.identity);
        if (norm != 0.0) {
            tmp.assign(Functions.mult(1 / norm));
        }
    }
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:16,代码来源:CPLSAIAFactorizationModelFactory.java

示例10: normalizePuz

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 * Normalizes matrix of p(z|u) such that \forall_z: \sum_u p(z|u) = 1.
 *
 * @param pu_z normalized matrix of p(z|u)
 */
protected void normalizePuz(DoubleMatrix2D pu_z) {
    for (int z = 0; z < pu_z.columns(); z++) {
        final DoubleMatrix1D pu_Z = pu_z.viewColumn(z);
        pu_Z.assign(mult(1 / pu_Z.aggregate(plus, identity)));
    }
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:12,代码来源:PLSAFactorizer.java

示例11: ColtDenseDoubleMatrix2D

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public ColtDenseDoubleMatrix2D(DoubleMatrix2D m) {
	super(m.rows(), m.columns());
	if (m instanceof DenseDoubleMatrix2D) {
		this.matrix = (DenseDoubleMatrix2D) m;
	} else {
		this.matrix = new DenseDoubleMatrix2D(m.toArray());
	}
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:9,代码来源:ColtDenseDoubleMatrix2D.java

示例12: isNonNegative

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 * A matrix <tt>A</tt> is <i>non-negative</i> if <tt>A[i,j] &gt;= 0</tt> holds for all cells.
 * <p>
 * Note: Ignores tolerance.
 */
public boolean isNonNegative(DoubleMatrix2D A) {
	int rows = A.rows();
	int columns = A.columns();
	for (int row = rows; --row >=0; ) {
		for (int column = columns; --column >= 0; ) {
			if (! (A.getQuick(row,column) >= 0)) return false;
		}
	}
	return true;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:16,代码来源:Property.java

示例13: writeMatrix

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
public void writeMatrix(DoubleMatrix2D matrix) throws IOException {
	this.out.write("[");
	for (int i = 0; i < matrix.rows(); i++) {
		if (i > 0) {
			this.out.write(";\n");
		}
		for (int j = 0; j < matrix.columns(); j++) {
			if (j > 0) {
				this.out.write(", ");
			}
			this.out.write(Double.toString(matrix.getQuick(i, j)));
		}
	}
	this.out.write("];");
}
 
开发者ID:appliedtopology,项目名称:javaplex,代码行数:16,代码来源:MatlabWriter.java

示例14: isLowerTriangular

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 * A matrix <tt>A</tt> is <i>lower triangular</i> if <tt>A[i,j]==0</tt> whenever <tt>i &lt; j</tt>.
 * Matrix may but need not be square.
 */
public boolean isLowerTriangular(DoubleMatrix2D A) {
	double epsilon = tolerance();
	int rows = A.rows();
	int columns = A.columns();
	for (int column = columns; --column >= 0; ) {
		for (int row = Math.min(column,rows); --row >= 0; ) {
			//if (A.getQuick(row,column) != 0) return false;
			if (!(Math.abs(A.getQuick(row,column)) <= epsilon)) return false;
		}
	}
	return true;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:17,代码来源:Property.java

示例15: isUpperTriangular

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
 * A matrix <tt>A</tt> is <i>upper triangular</i> if <tt>A[i,j]==0</tt> whenever <tt>i &gt; j</tt>.
 * Matrix may but need not be square.
 */
public boolean isUpperTriangular(DoubleMatrix2D A) {
	double epsilon = tolerance();
	int rows = A.rows();
	int columns = A.columns();
	for (int column = columns; --column >= 0; ) {
		for (int row = rows; --row > column; ) {
			//if (A.getQuick(row,column) != 0) return false;
			if (!(Math.abs(A.getQuick(row,column)) <= epsilon)) return false;
		}
	}
	return true;
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:17,代码来源:Property.java


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