de.citec.tcs.alignment.ParallelRawDerivativeEngine Maven / Gradle / Ivy
/*
* TCS Alignment Toolbox
*
* Copyright (C) 2013-2015
* Benjamin Paaßen, Georg Zentgraf
* AG Theoretical Computer Science
* Centre of Excellence Cognitive Interaction Technology (CITEC)
* University of Bielefeld
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package de.citec.tcs.alignment;
import de.citec.tcs.alignment.comparators.DerivableComparator;
import java.util.Map;
import java.util.concurrent.Callable;
/**
* This allows parallel processing of derivative calculations.
*
* @author Benjamin Paassen - [email protected]
*/
public class ParallelRawDerivativeEngine extends AbstractParallelDerivativeEngine {
private final DerivableComparator, ?> comparator;
private final String keyword;
public ParallelRawDerivativeEngine(
Map derivableMatrixEntries,
int M, int N, DerivableComparator, ?> comparator,
String keyword) {
super(derivableMatrixEntries, M, N, double[].class);
this.comparator = comparator;
this.keyword = keyword;
}
public ParallelRawDerivativeEngine(AlignmentDerivativeAlgorithm[][] derivableMatrixEntries,
DerivableComparator, ?> comparator, String keyword) {
super(derivableMatrixEntries, double[].class);
this.comparator = comparator;
this.keyword = keyword;
}
/**
* {@inheritDoc }
*/
@Override
public Callable createCallableWithAlgorithm(AlignmentDerivativeAlgorithm algo) {
return new RawDerivativeCallable(algo);
}
private class RawDerivativeCallable implements Callable {
private final AlignmentDerivativeAlgorithm algo;
public RawDerivativeCallable(AlignmentDerivativeAlgorithm algo) {
this.algo = algo;
}
@Override
public double[] call() throws Exception {
return algo.calculateRawParameterDerivative(comparator, keyword);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy