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


Java DoubleMatrix2D.viewColumn方法代码示例

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


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

示例1: 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

示例2: 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

示例3: quickSort

import cern.colt.matrix.DoubleMatrix2D; //导入方法依赖的package包/类
/**
Sorts the matrix rows into ascending order, according to the <i>natural ordering</i> of the matrix values in the given column.
The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa.
To sort ranges use sub-ranging views. To sort columns by rows, use dice views. To sort descending, use flip views ...
<p>
<b>Example:</b> 
<table border="1" cellspacing="0">
  <tr nowrap> 
	<td valign="top"><tt>4 x 2 matrix: <br>
	  7, 6<br>
	  5, 4<br>
	  3, 2<br>
	  1, 0 <br>
	  </tt></td>
	<td align="left" valign="top"> 
	  <p><tt>column = 0;<br>
		view = quickSort(matrix,column);<br>
		System.out.println(view); </tt><tt><br>
		==> </tt></p>
	  </td>
	<td valign="top"> 
	  <p><tt>4 x 2 matrix:<br>
		1, 0<br>
		3, 2<br>
		5, 4<br>
		7, 6</tt><br>
		The matrix IS NOT SORTED.<br>
		The new VIEW IS SORTED.</p>
	  </td>
  </tr>
</table>

@param matrix the matrix to be sorted.
@param column the index of the column inducing the order.
@return a new matrix view having rows sorted by the given column.
		<b>Note that the original matrix is left unaffected.</b>
@throws IndexOutOfBoundsException if <tt>column < 0 || column >= matrix.columns()</tt>.
*/
public DoubleMatrix2D sort(DoubleMatrix2D matrix, int column) {
	if (column < 0 || column >= matrix.columns()) throw new IndexOutOfBoundsException("column="+column+", matrix="+Formatter.shape(matrix));

	int[] rowIndexes = new int[matrix.rows()]; // row indexes to reorder instead of matrix itself
	for (int i=rowIndexes.length; --i >= 0; ) rowIndexes[i] = i;

	final DoubleMatrix1D col = matrix.viewColumn(column);
	IntComparator comp = new IntComparator() {  
		public int compare(int a, int b) {
			double av = col.getQuick(a);
			double bv = col.getQuick(b);
			if (av!=av || bv!=bv) return compareNaN(av,bv); // swap NaNs to the end
			return av<bv ? -1 : (av==bv ? 0 : 1);
		}
	};

	runSort(rowIndexes,0,rowIndexes.length,comp);

	// view the matrix according to the reordered row indexes
	// take all columns in the original order
	return matrix.viewSelection(rowIndexes,null);
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:61,代码来源:Sorting.java


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