Example usage for org.apache.mahout.math Vector viewPart

List of usage examples for org.apache.mahout.math Vector viewPart

Introduction

In this page you can find the example usage for org.apache.mahout.math Vector viewPart.

Prototype

Vector viewPart(int offset, int length);

Source Link

Document

Return a new vector containing the subset of the recipient

Usage

From source file:org.qcri.pca.MeanAndSpanJobTest.java

License:Apache License

private void verifyMapperOutput(DummyRecordWriter<IntWritable, VectorWritable> writer) {
    Assert.assertEquals("Each mapper should output three keys!", 3, writer.getKeys().size());
    for (IntWritable key : writer.getKeys()) {
        List<VectorWritable> list = writer.getValue(key);
        assertEquals("Mapper did not combine the results!", 1, list.size());
        Vector v = list.get(0).get();
        switch (key.get()) {
        case MeanAndSpanJob.MEANVECTOR:
            Assert.assertEquals("MeanVector size does not match!", v.size(), cols + 1);
            Assert.assertEquals("MeanVector count does not match!", rows, v.get(0), EPSILON);
            verifySum(inputVectors, v.viewPart(1, cols));
            break;
        case MeanAndSpanJob.MINVECTOR:
            Assert.assertEquals("MinVector size does not match!", v.size(), cols);
            verifyMin(inputVectors, v);/*from  ww w . ja  va2 s .  c om*/
            break;
        case MeanAndSpanJob.MAXVECTOR:
            Assert.assertEquals("MaxVector size does not match!", v.size(), cols);
            verifyMax(inputVectors, v);
            break;
        default:
            Assert.fail("Unknown key from mapper");
        }
    }
}