mikera.transformz.impl.SubsetTransform Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vectorz Show documentation
Show all versions of vectorz Show documentation
Fast double-precision vector and matrix maths library for Java, supporting N-dimensional numeric arrays.
package mikera.transformz.impl;
import mikera.indexz.Index;
import mikera.transformz.ATransform;
import mikera.vectorz.AVector;
/**
* Transform wrapper that produces a subset of the output components of another transform
*
* @author Mike
*/
public final class SubsetTransform extends ATransform {
private ATransform source;
private Index components;
private SubsetTransform(ATransform trans, Index components) {
this.source=trans;
this.components=components;
}
public static SubsetTransform create(ATransform trans, Index components) {
if (trans instanceof SubsetTransform) {
return create((SubsetTransform)trans, components);
}
return new SubsetTransform(trans,components);
}
public static SubsetTransform create(SubsetTransform trans, Index components) {
return new SubsetTransform(trans.source,components.compose(trans.components));
}
@Override
public double calculateElement(int i, AVector source) {
return this.source.calculateElement(components.get(i),source);
}
@Override
public void transform(AVector source, AVector dest) {
AVector v=this.source.transform(source);
dest.set(v,components);
}
@Override
public int inputDimensions() {
return source.inputDimensions();
}
@Override
public int outputDimensions() {
return components.length();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy