本文整理了Java中org.apache.mahout.math.Matrix.getQuick()
方法的一些代码示例,展示了Matrix.getQuick()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.getQuick()
方法的具体详情如下:
包路径:org.apache.mahout.math.Matrix
类名称:Matrix
方法名:getQuick
[英]Return the value at the given indexes, without checking bounds
[中]返回给定索引处的值,不检查边界
代码示例来源:origin: apache/mahout
/**
* Return the value at the given indexes, without checking bounds
*
* @param row an int row index
* @param column an int column index
* @return the double at the index
*/
@Override
public double getQuick(int row, int column) {
return base.getQuick(rowPivot[row], columnPivot[column]);
}
代码示例来源:origin: apache/mahout
/**
* Return the value at the given index, without checking bounds
*
* @param index an int index
* @return the double at the index
*/
@Override
public double getQuick(int index) {
return matrix.getQuick(row + rowStride * index, column + columnStride * index);
}
代码示例来源:origin: apache/mahout
@Test
public void createMiIi() {
Vector f1 = new DenseVector(new double[] { 1, 2, 3 });
Vector f2 = new DenseVector(new double[] { 4, 5, 6 });
Matrix miIi = AlternatingLeastSquaresSolver.createMiIi(Arrays.asList(f1, f2), 3);
assertEquals(1.0, miIi.getQuick(0, 0), EPSILON);
assertEquals(2.0, miIi.getQuick(1, 0), EPSILON);
assertEquals(3.0, miIi.getQuick(2, 0), EPSILON);
assertEquals(4.0, miIi.getQuick(0, 1), EPSILON);
assertEquals(5.0, miIi.getQuick(1, 1), EPSILON);
assertEquals(6.0, miIi.getQuick(2, 1), EPSILON);
}
代码示例来源:origin: apache/mahout
public JacobiConditioner(Matrix a) {
if (a.numCols() != a.numRows()) {
throw new IllegalArgumentException("Matrix must be square.");
}
inverseDiagonal = new DenseVector(a.numCols());
for (int i = 0; i < a.numCols(); ++i) {
inverseDiagonal.setQuick(i, 1.0 / a.getQuick(i, i));
}
}
代码示例来源:origin: apache/mahout
@Test
public void testAssignColumn() {
double[] data = {2.1, 3.2, 4.3};
test.assignColumn(1, new DenseVector(data));
assertEquals("test[0][1]", 2.1, test.getQuick(0, 1), EPSILON);
assertEquals("test[1][1]", 3.2, test.getQuick(1, 1), EPSILON);
assertEquals("test[2][1]", 4.3, test.getQuick(2, 1), EPSILON);
}
代码示例来源:origin: apache/mahout
@Test
public void testAssignColumn() {
double[] data = {2.1, 3.2, 4.3};
test.assignColumn(1, new DenseVector(data));
assertEquals("test[0][1]", 2.1, test.getQuick(0, 1), EPSILON);
assertEquals("test[1][1]", 3.2, test.getQuick(1, 1), EPSILON);
assertEquals("test[2][1]", 4.3, test.getQuick(2, 1), EPSILON);
}
代码示例来源:origin: apache/mahout
@Test
public void testAssignRow() {
double[] data = {2.1, 3.2};
test.assignRow(1, new DenseVector(data));
assertEquals("test[1][0]", 2.1, test.getQuick(1, 0), EPSILON);
assertEquals("test[1][1]", 3.2, test.getQuick(1, 1), EPSILON);
}
代码示例来源:origin: apache/mahout
@Test
public void testCopy() {
Matrix copy = test.clone();
assertTrue("wrong class", copy instanceof MatrixView);
for (int row = 0; row < test.rowSize(); row++) {
for (int col = 0; col < test.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']',
test.getQuick(row, col), copy.getQuick(row, col), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testGetQuick() {
for (int row = 0; row < test.rowSize(); row++) {
for (int col = 0; col < test.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']', values[row][col], test
.getQuick(row, col), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testAssignDouble() {
test.assign(4.53);
for (int row = 0; row < test.rowSize(); row++) {
for (int col = 0; col < test.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']', 4.53, test.getQuick(
row, col), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testAssignDoubleArrayArray() {
test.assign(new double[3][2]);
for (int row = 0; row < test.rowSize(); row++) {
for (int col = 0; col < test.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']', 0.0, test.getQuick(row,
col), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testAssignUnaryFunction() {
test.assign(Functions.NEGATE);
for (int row = 0; row < test.rowSize(); row++) {
for (int col = 0; col < test.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']',
-values[row + 1][col + 1], test.getQuick(row, col), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testAssignDoubleArrayArray() {
test.assign(new double[3][2]);
for (int row = 0; row < test.rowSize(); row++) {
for (int col = 0; col < test.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']', 0.0, test.getQuick(row,
col), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testMinus() {
Matrix value = test.minus(test);
for (int row = 0; row < test.rowSize(); row++) {
for (int col = 0; col < test.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']', 0.0, value.getQuick(
row, col), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testViewPart() {
int[] offset = {1, 1};
int[] size = {2, 1};
Matrix view = test.viewPart(offset, size);
for (int row = 0; row < view.rowSize(); row++) {
for (int col = 0; col < view.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']',
values[row + 2][col + 2], view.getQuick(row, col), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testAssignDouble() {
test.assign(4.53);
for (int row = 0; row < test.rowSize(); row++) {
for (int col = 0; col < test.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']', 4.53, test.getQuick(
row, col), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testPlusMatrix() {
Matrix value = test.plus(test);
for (int row = 0; row < test.rowSize(); row++) {
for (int col = 0; col < test.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']', values[row][col] * 2,
value.getQuick(row, col), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testTranspose() {
Matrix transpose = test.transpose();
assertEquals("rows", test.columnSize(), transpose.rowSize());
assertEquals("cols", test.rowSize(), transpose.columnSize());
for (int row = 0; row < test.rowSize(); row++) {
for (int col = 0; col < test.columnSize(); col++) {
assertEquals("value[" + row + "][" + col + ']',
test.getQuick(row, col), transpose.getQuick(col, row), EPSILON);
}
}
}
代码示例来源:origin: apache/mahout
@Test
public void testViewRow() {
Vector row = test.viewRow(1);
assertEquals("row size", 2, row.getNumNondefaultElements());
//create a matrix with an unassigned row 0
Matrix matrix = new SparseMatrix(1, 1);
Vector view = matrix.viewRow(0);
final double value = 1.23;
view.assign(value);
//test whether the update in the view is reflected in the matrix
assertEquals("Matrix value", view.getQuick(0), matrix.getQuick(0, 0), EPSILON);
}
代码示例来源:origin: apache/mahout
@Test
public void testCrossProduct() {
Matrix result = test.cross(test);
assertEquals("row size", test.size(), result.rowSize());
assertEquals("col size", test.size(), result.columnSize());
for (int row = 0; row < result.rowSize(); row++) {
for (int col = 0; col < result.columnSize(); col++) {
assertEquals("cross[" + row + "][" + col + ']', test.getQuick(row)
* test.getQuick(col), result.getQuick(row, col), EPSILON);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!