com.expleague.commons.math.vectors.impl.mx.MxByRowsBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Utilities including math, charsequence based text processing, sequences etc.
package com.expleague.commons.math.vectors.impl.mx;
import com.expleague.commons.math.vectors.Mx;
import com.expleague.commons.math.vectors.MxBuilder;
import com.expleague.commons.math.vectors.Vec;
import com.expleague.commons.math.vectors.VecTools;
import java.util.LinkedList;
import java.util.List;
/**
* User: qdeee
* Date: 20.03.15
*/
public class MxByRowsBuilder implements MxBuilder {
private final List vecs = new LinkedList<>();
@Override
public MxBuilder add(final Vec vec) {
this.vecs.add(vec);
return this;
}
@Override
public MxBuilder addAll(final List vecs) {
this.vecs.addAll(vecs);
return this;
}
@Override
public Mx build() {
if (vecs.isEmpty()) {
throw new IllegalStateException("Mx builder is empty");
}
final Vec joinedVec = VecTools.join(vecs);
return new VecBasedMx(vecs.get(0).dim(), joinedVec);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy