Examples of dotProduct()


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

  public void testEmptyLocations ()
  {
    IndexedSparseVector s = new IndexedSparseVector (new int[0], new double [0]);
    assertEquals (0.0, s.value (38), 1e-10);
    assertEquals (0.0, s.dotProduct (s1), 1e-10);
  }

  public void testSerializable () throws IOException, ClassNotFoundException
  {
    IndexedSparseVector s = (IndexedSparseVector) s1.cloneMatrix ();
View Full Code Here

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

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

    // 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

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

  }

  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

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

                                             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

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

    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

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

  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

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

        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

Examples of edu.stanford.nlp.sempre.FeatureVector.dotProduct()

              fv = getFullMatrixFeatures(sourceTokenVec, targetTokenVec);
            else if(vsmSimilarityFunc==SimilarityFunc.DIAGNONAL)
              fv = getDiagonalMatrixFeatures(sourceTokenVec, targetTokenVec);
            else
              fv = getDotProductFeature(sourceTokenVec, targetTokenVec);
            double score = fv.dotProduct(params);
            scoreList.add(Pair.newPair(paraExample.sourceInfo.tokens.get(i)+","+paraExample.targetInfo.tokens.get(j), alpha*score));
          }
        }
      }
    }
View Full Code Here

Examples of gov.sandia.cognition.math.matrix.Vector.dotProduct()

      /*
       * 1. Update the sigma2 sufficient stats.
       */
      final double newN = sigma2SS.getShape() + 1d;
      final double d = sigma2SS.getScale() + xHdiff.dotProduct(xHdiff);
      sigma2SS.setScale(d);
      sigma2SS.setShape(newN);
     
      /*
       * 2. Update psi sufficient stats. (i.e. offset and AR(1)).
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.