use of org.ejml.simple.SimpleMatrix in project CoreNLP by stanfordnlp.
the class SentimentPipeline method outputTreeScores.
/**
* Outputs the scores from the tree. Counts the tree nodes the
* same as setIndexLabels.
*/
private static int outputTreeScores(PrintStream out, Tree tree, int index) {
if (tree.isLeaf()) {
return index;
}
out.print(" " + index + ':');
SimpleMatrix vector = RNNCoreAnnotations.getPredictions(tree);
for (int i = 0; i < vector.getNumElements(); ++i) {
out.print(" " + NF.format(vector.get(i)));
}
out.println();
index++;
for (Tree child : tree.children()) {
index = outputTreeScores(out, child, index);
}
return index;
}
use of org.ejml.simple.SimpleMatrix in project CoreNLP by stanfordnlp.
the class SentimentPipeline method outputTreeVectors.
/**
* Outputs the vectors from the tree. Counts the tree nodes the
* same as setIndexLabels.
*/
private static int outputTreeVectors(PrintStream out, Tree tree, int index) {
if (tree.isLeaf()) {
return index;
}
out.print(" " + index + ':');
SimpleMatrix vector = RNNCoreAnnotations.getNodeVector(tree);
for (int i = 0; i < vector.getNumElements(); ++i) {
out.print(" " + NF.format(vector.get(i)));
}
out.println();
index++;
for (Tree child : tree.children()) {
index = outputTreeVectors(out, child, index);
}
return index;
}
use of org.ejml.simple.SimpleMatrix in project CoreNLP by stanfordnlp.
the class NeuralUtilsTest method testIsZero.
@Test
public void testIsZero() {
double[][] values = new double[][] { { 0.1, 0.2, 0.3, 0.4, 0.5 }, { 0.0, 0.0, 0.0, 0.0, 0.0 } };
SimpleMatrix vector1 = new SimpleMatrix(values);
assertFalse(NeuralUtils.isZero(vector1));
values = new double[][] { { 0.0, 0.0, 0.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0, 0.0, 0.0 } };
vector1 = new SimpleMatrix(values);
assertTrue(NeuralUtils.isZero(vector1));
}
use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.
the class RectifyFundamental method computeG.
private SimpleMatrix computeG(Point3D_F64 epipole, int x0, int y0) {
double x = epipole.x / epipole.z - x0;
double y = epipole.y / epipole.z - y0;
double f = Math.sqrt(x * x + y * y);
SimpleMatrix G = SimpleMatrix.identity(3);
G.set(2, 0, -1.0 / f);
return G;
}
use of org.ejml.simple.SimpleMatrix in project BoofCV by lessthanoptimal.
the class RectifyFundamental method computeAffineH.
/**
* Finds the values of a,b,c which minimize
*
* sum (a*x(+)_i + b*y(+)_i + c - x(-)_i)^2
*
* See page 306
*
* @return Affine transform
*/
private SimpleMatrix computeAffineH(List<AssociatedPair> observations, DMatrixRMaj H, DMatrixRMaj Hzero) {
SimpleMatrix A = new SimpleMatrix(observations.size(), 3);
SimpleMatrix b = new SimpleMatrix(A.numRows(), 1);
Point2D_F64 c = new Point2D_F64();
Point2D_F64 k = new Point2D_F64();
for (int i = 0; i < observations.size(); i++) {
AssociatedPair a = observations.get(i);
GeometryMath_F64.mult(Hzero, a.p1, k);
GeometryMath_F64.mult(H, a.p2, c);
A.setRow(i, 0, k.x, k.y, 1);
b.set(i, 0, c.x);
}
SimpleMatrix x = A.solve(b);
SimpleMatrix Ha = SimpleMatrix.identity(3);
Ha.setRow(0, 0, x.getDDRM().data);
return Ha;
}
Aggregations