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


Java Matrix.getQuick方法代码示例

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


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

示例1: updateXtXAndYtx

import org.apache.mahout.math.Matrix; //导入方法依赖的package包/类
/***
 * Mi = (Yi-Ym)' x (Xi-Xm) = Yi' x (Xi-Xm) - Ym' x (Xi-Xm)
 * 
 * M = Sum(Mi) = Sum(Yi' x (Xi-Xm)) - Ym' x (Sum(Xi)-N*Xm)
 * 
 * The second part is done in this function
 */

public static Matrix updateXtXAndYtx(Matrix realCentralYtx,
		Vector realCentralSumX, Vector ym, Vector xm, int nRows) {
	for (int yRow = 0; yRow < ym.size(); yRow++) {
		double scale = ym.getQuick(yRow);
		for (int xCol = 0; xCol < realCentralSumX.size(); xCol++) {
			double centeredValue = realCentralSumX.getQuick(xCol) - nRows
					* xm.getQuick(xCol);
			double currValue = realCentralYtx.getQuick(yRow, xCol);
			currValue -= centeredValue * scale;
			realCentralYtx.setQuick(yRow, xCol, currValue);
		}
	}
	return realCentralYtx;
}
 
开发者ID:SiddharthMalhotra,项目名称:sPCA,代码行数:23,代码来源:PCAUtils.java

示例2: sparseVectorTimesMatrix

import org.apache.mahout.math.Matrix; //导入方法依赖的package包/类
/**
 * multiply a sparse vector by a matrix
 * @param sparseVector
 * @param matrix
 * @param resArray
 */

static void sparseVectorTimesMatrix(org.apache.spark.mllib.linalg.Vector sparseVector, Matrix matrix,
		double[] resArray) {
	int matrixCols = matrix.numCols();
	int[] indices;
	for (int col = 0; col < matrixCols; col++) 
	{
		indices=((SparseVector)sparseVector).indices();
		int index = 0, i=0;
		double value = 0;
		double dotRes = 0;
		for(i=0; i <indices.length; i++)
		{
			index=indices[i];
			value=sparseVector.apply(index);
			dotRes += matrix.getQuick(index,col) * value;
		}
		resArray[col] = dotRes;
	}
}
 
开发者ID:SiddharthMalhotra,项目名称:sPCA,代码行数:27,代码来源:PCAUtils.java

示例3: denseVectorTimesMatrix

import org.apache.mahout.math.Matrix; //导入方法依赖的package包/类
static Vector denseVectorTimesMatrix(DenseVector vector, Matrix matrix,
    DenseVector resVector) {
  int nRows = matrix.numRows();
  int nCols = matrix.numCols();
  for (int c = 0; c < nCols; c++) {
    double dotres = 0;
    for (int r = 0; r < nRows; r++)
      dotres += vector.getQuick(r) * matrix.getQuick(r, c);
    resVector.set(c, dotres);
  }
  return resVector;
}
 
开发者ID:SiddharthMalhotra,项目名称:sPCA,代码行数:13,代码来源:PCACommon.java

示例4: vectorTimesMatrixTranspose

import org.apache.mahout.math.Matrix; //导入方法依赖的package包/类
static Vector vectorTimesMatrixTranspose(Vector vector,
    Matrix matrix, DenseVector resVector) {
  int nRows = matrix.numRows();
  int nCols = matrix.numCols();
  for (int r = 0; r < nRows; r++) {
    double dotres = 0;
    for (int c = 0; c < nCols; c++)
      dotres += vector.getQuick(c) * matrix.getQuick(r, c);
    resVector.set(r, dotres);
  }
  return resVector;
}
 
开发者ID:SiddharthMalhotra,项目名称:sPCA,代码行数:13,代码来源:PCACommon.java

示例5: denseVectorTimesMatrix

import org.apache.mahout.math.Matrix; //导入方法依赖的package包/类
/**
 * multiply a dense vector by a matrix
 * @param xm_mahout: result vector
 * @return
 */
static Vector denseVectorTimesMatrix(Vector vector, Matrix matrix,
		Vector xm_mahout) {
	int nRows = matrix.numRows();
	int nCols = matrix.numCols();
	for (int c = 0; c < nCols; c++) {
		double dotres = 0;
		for (int r = 0; r < nRows; r++)
			dotres += vector.getQuick(r) * matrix.getQuick(r, c);
		xm_mahout.set(c, dotres);
	}
	return xm_mahout;
}
 
开发者ID:SiddharthMalhotra,项目名称:sPCA,代码行数:18,代码来源:PCAUtils.java

示例6: vectorTimesMatrixTranspose

import org.apache.mahout.math.Matrix; //导入方法依赖的package包/类
/**
 * multiply a dense vector by the transpose of a matrix
 * @param resArray: result array
 * @return
 */
static double[] vectorTimesMatrixTranspose(Vector vector, Matrix matrix,
		double[] resArray) {
	int nRows = matrix.numRows();
	int nCols = matrix.numCols();
	for (int r = 0; r < nRows; r++) {
		double dotres = 0;
		for (int c = 0; c < nCols; c++)
			dotres += vector.getQuick(c) * matrix.getQuick(r, c);
		resArray[r] = dotres;
	}
	return resArray;
}
 
开发者ID:SiddharthMalhotra,项目名称:sPCA,代码行数:18,代码来源:PCAUtils.java


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