Package cc.mallet.types

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


    s.plusEqualsSparse (s4, 1.0);
    checkAnswer (s, new double[] { 3, 5, 7.2, 6.8, 8.2 })

    SparseVector s5 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
    s5.plusEqualsSparse (s1);
    for (int i = 0; i < s5.numLocations(); i++) {
      assertEquals (7, s5.indexAtLocation (i));
      assertEquals (3.2, s5.valueAtLocation (i), 0.0);
    }

    SparseVector s6 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
View Full Code Here


      assertEquals (3.2, s5.valueAtLocation (i), 0.0);
    }

    SparseVector s6 = new SparseVector (new int[] { 7 }, new double[] { 0.2 });
    s6.plusEqualsSparse (s1, 3.5);
    for (int i = 0; i < s6.numLocations(); i++) {
      assertEquals (7, s6.indexAtLocation (i));
      assertEquals (10.7, s6.valueAtLocation (i), 0.0);
    }
  }
View Full Code Here

  {
    SparseVector s = (SparseVector) s1.cloneMatrix ();
    s.incrementValue (5, 0.75);

    double[] ans = new double[] {1, 2.75, 3, 4, 5};
    for (int i = 0; i < s.numLocations(); i++) {
      assertTrue (s.valueAtLocation (i) == ans[i]);
    }
  }

 
View Full Code Here

  {
    SparseVector s = (SparseVector) s1.cloneMatrix ();
    s.setValue (5, 0.3);

    double[] ans = new double[] {1, 0.3, 3, 4, 5};
    for (int i = 0; i < s.numLocations(); i++) {
      assertTrue (s.valueAtLocation (i) == ans[i]);
    }
  }

  public void testDenseSparseVector ()
View Full Code Here

  }
 
  public void testCloneMatrixZeroed ()
  {
    SparseVector s = (SparseVector) s1.cloneMatrixZeroed ();
    for (int i = 0; i < s.numLocations(); i++) {
      assertTrue (s.valueAtLocation (i) == 0.0);
      assertTrue (s.indexAtLocation (i) == idxs [i]);
    }
  }
View Full Code Here

    ArrayList<Instance> instances = new ArrayList<Instance>(instList.size());
    for (int i = 0; i < instList.size(); i++) {
      Instance ins = instList.get(i);
      SparseVector sparse = (SparseVector) ins.getData();
      if (sparse.numLocations() == 0)
        continue;

      instances.add(ins);
    }
View Full Code Here

      out.println ("\n\n*** CRF WEIGHTS ***");
      for (int widx = 0; widx < parameters.weights.length; widx++) {
        out.println ("WEIGHTS NAME = " + parameters.weightAlphabet.lookupObject (widx));
        out.print (": <DEFAULT_FEATURE> = "); out.print (parameters.defaultWeights[widx]); out.print ('\n');
        SparseVector transitionWeights = parameters.weights[widx];
        if (transitionWeights.numLocations () == 0)
          continue;
        RankedFeatureVector rfv = new RankedFeatureVector (inputAlphabet, transitionWeights);
        for (int m = 0; m < rfv.numLocations (); m++) {
          double v = rfv.getValueAtRank (m);
          //int index = rfv.indexAtLocation (rfv.getIndexAtRank (m));  // This doesn't make any sense.  How did this ever work?  -akm 12/2007
View Full Code Here

      out.println ("\n\n*** CRF WEIGHTS ***");
      for (int widx = 0; widx < parameters.weights.length; widx++) {
        out.println ("WEIGHTS NAME = " + parameters.weightAlphabet.lookupObject (widx));
        out.print (": <DEFAULT_FEATURE> = "); out.print (parameters.defaultWeights[widx]); out.print ('\n');
        SparseVector transitionWeights = parameters.weights[widx];
        if (transitionWeights.numLocations () == 0)
          continue;
        RankedFeatureVector rfv = new RankedFeatureVector (inputAlphabet, transitionWeights);
        for (int m = 0; m < rfv.numLocations (); m++) {
          double v = rfv.getValueAtRank (m);
          //int index = rfv.indexAtLocation (rfv.getIndexAtRank (m));  // This doesn't make any sense.  How did this ever work?  -akm 12/2007
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.