Example usage for org.apache.commons.math3.linear RealVector equals

List of usage examples for org.apache.commons.math3.linear RealVector equals

Introduction

In this page you can find the example usage for org.apache.commons.math3.linear RealVector equals.

Prototype

@Override
public boolean equals(Object other) throws MathUnsupportedOperationException 

Source Link

Document

Test for the equality of two real vectors.

Usage

From source file:org.lambda3.indra.benchmark.BenchmarkRunner.java

private void run(String file, IndraAnalyzer analyzer, VectorSpace vs1, VectorSpace vs2) {
    Set<String> words = loadWordSet(file);

    List<AnalyzedTerm> analyzedTerms = new LinkedList<>();
    for (String term : words) {
        analyzedTerms.add(new AnalyzedTerm(term, analyzer.analyze(term)));
    }/*from   w ww.j ava  2  s. com*/

    double start1 = System.currentTimeMillis();
    Map<String, RealVector> vectors1 = vs1.getVectors(analyzedTerms, new SumVectorComposer());
    double end1 = System.currentTimeMillis();

    double start2 = System.currentTimeMillis();
    Map<String, RealVector> vectors2 = vs2.getVectors(analyzedTerms, new SumVectorComposer());
    double end2 = System.currentTimeMillis();

    this.report.addInfo(file, vs1.getClass().getSimpleName(), end1 - start1, vs2.getClass().getSimpleName(),
            end2 - start2);

    if (vectors1.size() == vectors2.size()) {
        for (String term : vectors1.keySet()) {
            RealVector v1 = vectors1.get(term);
            RealVector v2 = vectors2.get(term);

            if (!((v1 == null && v2 == null) || v1.equals(v2))) {
                System.out.println(String.format("ERROR: %s - %s", v1, v2));
                System.exit(-7);
            }
        }
    } else {
        System.out.println(String.format("ERROR: different size %d - %d", vectors1.size(), vectors2.size()));
    }
}