Package cc.mallet.types

Examples of cc.mallet.types.SparseVector.dotProduct()


    }
  }

  public void testDotProduct () {
    SparseVector t1 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
    assertEquals (0.6, t1.dotProduct (s1), 0.00001);
    assertEquals (0.6, s1.dotProduct (t1), 0.00001);
   
    assertEquals (19.0, s1.dotProduct (s2), 0.00001);
    assertEquals (19.0, s2.dotProduct (s1), 0.00001);
View Full Code Here


    // test dotproduct when vector with more locations has a lower
    //   max-index than short vector
    SparseVector t2 = new SparseVector (new int[] { 3, 30 }, new double[] { 0.2, 3.5 });
    SparseVector t3 = new SparseVector (null, new double[] { 1, 1, 1, 1, });
    assertEquals (0.2, t3.dotProduct (t2), 0.00001);
  }

  public void testIncrementValue ()
  {
    SparseVector s = (SparseVector) s1.cloneMatrix ();
View Full Code Here

  }

  public void testDenseSparseVector ()
  {
    SparseVector svDense = new SparseVector (null, dbl3);
    double sdot = svDense.dotProduct (svDense);
    double ddot = d1.dotProduct (d1);
    assertEquals (sdot, ddot, 0.0001);

    svDense.plusEqualsSparse (s1);
    checkAnswer (svDense, new double[] { 2.0, 2.5, 3.0, 5.7, 3.5,
View Full Code Here

                                             false, false, false);
    SparseVector binary2 = new SparseVector (idx2, null, idx2.length, idx2.length,
                                            false, false, false);

    assertEquals (3, binary1.dotProduct (binary2), 0.0001);
    assertEquals (3, binary2.dotProduct (binary1), 0.0001);

    assertEquals (15.0, binary1.dotProduct (s1), 0.0001);
    assertEquals (15.0, s1.dotProduct (binary1), 0.0001);

    assertEquals (9.0, binary2.dotProduct (s1), 0.0001);
View Full Code Here

    assertEquals (3, binary2.dotProduct (binary1), 0.0001);

    assertEquals (15.0, binary1.dotProduct (s1), 0.0001);
    assertEquals (15.0, s1.dotProduct (binary1), 0.0001);

    assertEquals (9.0, binary2.dotProduct (s1), 0.0001);
    assertEquals (9.0, s1.dotProduct (binary2), 0.0001);

    SparseVector dblVec = (SparseVector) s1.cloneMatrix ();
    dblVec.plusEqualsSparse (binary1);
    checkAnswer (dblVec, new double[] { 2, 3, 4, 5, 6 });
View Full Code Here

  public void testExtendedDotProduct () {
    SparseVector v1 = new SparseVector (null, dbl3);
    SparseVector vInf = new SparseVector (null, dbl4);
    double dp = v1.dotProduct (vInf);
    assertTrue (!Double.isNaN(dp));
    dp = vInf.dotProduct (v1);
    assertTrue (!Double.isNaN(dp));
  }
 
  public static Test suite ()
  {
View Full Code Here

        for (int i = 0; i < theseWeights.length; i++) {
          int wi = theseWeights[i];
          SparseVector w = crf.parameters.weights[wi];

          buf.append ("WEIGHTS <br />\n" + crf.parameters.weightAlphabet.lookupObject (wi) + "<br />\n");
          buf.append ("  d.p. = "+f.format (w.dotProduct (input))+"<br />\n");

          double[] vals = new double[input.numLocations ()];
          double[] absVals = new double[input.numLocations ()];
          for (int k = 0; k < vals.length; k++) {
            int index = input.indexAtLocation (k);
View Full Code Here

        for (int i = 0; i < theseWeights.length; i++) {
          int wi = theseWeights[i];
          SparseVector w = crf.parameters.weights[wi];

          buf.append ("WEIGHTS <br />\n" + crf.parameters.weightAlphabet.lookupObject (wi) + "<br />\n");
          buf.append ("  d.p. = "+f.format (w.dotProduct (input))+"<br />\n");

          double[] vals = new double[input.numLocations ()];
          double[] absVals = new double[input.numLocations ()];
          for (int k = 0; k < vals.length; k++) {
            int index = input.indexAtLocation (k);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.