Open vkostyukov opened 10 years ago
An example of usage:
Matrix a = ...
Matrix b = a.pipeTo(LinearAlgebra.GAUSS_JORDAN).invert();
Matrix a = ...
// GAUSS_JORDAN is no longe a factory in an operation from Matrix to MatrixInverter
MatrixInverter = a.pipeTo(LinearAlgebra.GAUSS_JORDAN);
// A typical use-case
Matrix b = a.pipeTo(LinearAlgebra.GAUSS_JORDAN).invert();
// Or in-place:
Matrix b = a.pipeTo(LinearAlgebra.GAUSS_JORDAN).invertInPlace();
// Or do it in a single line
Matrix b = a.pipeAndApplyTo(LinearAlgebra.GAUSS_JORDAN);
// Or in-place
Matrix b = a.pipeAndApplyInPlaceTo(LinearAlgebra.GAUSS_JORDAN);
Everything is an operation: Iverter, Decompisitor, LinearSolver. And pipeTo
is a core routin to work with it. This should be refactored in this release. For now, only oo-place operations for complex things.
Just curring:
// we didn't pass vector to a MatrixVectorOration, so it returned a curried operation;
// we still have troubles here since we want to cache the LU between calls to solver.apply().
VectorOperation<Vector> solver = a.pipeTo(LinearAlgebra.FORWARD_BACK_SUBST);
solver.apply(Vector);
// we might want to pass a factory
Matrix b = a.pipeTo(LinearAlgebra.GAUSS_JORDAN);
// GAUSS_JORDAN is an operation factory
A matrix-operation-factory concept
MatrixOperationFactory<T> {
MatrixOperation<T> apply(Factory factory)
}
In a base class:
public <T> pipeTo<T>(MatrixOperationFactory<T> operation) {
return pipeTo(operation.apply(factory))
}
The overall picture for decomposers should looks like:
Matrix lup[] = a.pipeTo(LinearAlgebra.LU);
I'm thinking of using
pipeTo
method name istead ofwithSolver
,withDecompositor
,withInverter
: