Package gnu.trove.list.array

Examples of gnu.trove.list.array.TDoubleArrayList


     * specified capacity.
     *
     * @param capacity the initial depth of the stack
     */
    public TDoubleArrayStack( int capacity ) {
        _list = new TDoubleArrayList( capacity );
    }
View Full Code Here


     *
     * @param capacity the initial depth of the stack
     * @param no_entry_value value that represents null
     */
    public TDoubleArrayStack( int capacity, double no_entry_value ) {
        _list = new TDoubleArrayList( capacity, no_entry_value );
    }
View Full Code Here

     * @param stack the instance to copy
     */
    public TDoubleArrayStack( TDoubleStack stack ) {
        if ( stack instanceof TDoubleArrayStack ) {
            TDoubleArrayStack array_stack = ( TDoubleArrayStack ) stack;
            this._list = new TDoubleArrayList( array_stack._list );
        } else {
            throw new UnsupportedOperationException( "Only support TDoubleArrayStack" );
        }
    }
View Full Code Here

   * @param line Line to process
   */
  protected void parseLineInternal(String line) {
    List<String> entries = tokenize(line);
    // Split into numerical attributes and labels
    TDoubleArrayList attributes = new TDoubleArrayList(entries.size());
    LabelList labels = null;

    Iterator<String> itr = entries.iterator();
    for(int i = 0; itr.hasNext(); i++) {
      String ent = itr.next();
      if(!labelIndices.get(i)) {
        try {
          double attribute = Double.parseDouble(ent);
          attributes.add(attribute);
          continue;
        }
        catch(NumberFormatException e) {
          // Ignore attempt, add to labels below.
        }
View Full Code Here

    List<LabelList> labels = new ArrayList<LabelList>();
    try {
      for(String line; (line = reader.readLine()) != null; lineNumber++) {
        if(!line.startsWith(COMMENT) && line.length() > 0) {
          List<String> entries = tokenize(line);
          TDoubleList attributes = new TDoubleArrayList(entries.size());
          LabelList labellist = null;
          for(String entry : entries) {
            try {
              double attribute = Double.parseDouble(entry);
              attributes.add(attribute);
            }
            catch(NumberFormatException e) {
              if(labellist == null) {
                labellist = new LabelList(1);
              }
              labellist.add(entry);
            }
          }

          if(dimensionality < 0) {
            dimensionality = attributes.size();
          }
          else if(dimensionality != attributes.size()) {
            throw new IllegalArgumentException("Differing dimensionality in line " + lineNumber + ":" + attributes.size() + " != " + dimensionality);
          }
          vectors.add(ParameterizationFunction.STATIC.newNumberVector(attributes, ArrayLikeUtil.TDOUBLELISTADAPTER));
          labels.add(labellist);
        }
      }
View Full Code Here

    this.newGrad = zeros;
    this.dir = zeros;
    this.steepestDescDir = newGrad;

    this.alphas = new double[m];
    this.roList = new TDoubleArrayList(m);
    this.costs = new TDoubleArrayList(m);
    this.sList = new ArrayList<>();
    this.yList = new ArrayList<>();

    this.value = evaluateL1(f);
    this.grad = newGrad;
View Full Code Here

  public static Tuple3<List<String>, DenseDoubleVector, String[]> readTwentyNewsgroups(
      File directory) {
    String[] classList = directory.list();
    Arrays.sort(classList);
    List<String> docList = new ArrayList<>();
    TDoubleArrayList prediction = new TDoubleArrayList();
    String[] nameMapping = new String[classList.length];
    int classIndex = 0;
    for (String classDirString : classList) {
      File classDir = new File(directory, classDirString);
      String[] fileList = classDir.list();
      for (String fileDoc : fileList) {
        try (BufferedReader br = new BufferedReader(new FileReader(new File(
            classDir, fileDoc)))) {
          StringBuilder document = new StringBuilder();
          String l = null;
          while ((l = br.readLine()) != null) {
            document.append(l);
          }
          docList.add(document.toString());
          prediction.add(classIndex);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      nameMapping[classIndex++] = classDirString;
    }

    return new Tuple3<>(docList, new DenseDoubleVector(prediction.toArray()),
        nameMapping);
  }
View Full Code Here

        return result;
    }

    @Override
    public TDoubleList getAsDoubleArray() {
        TDoubleList result = new TDoubleArrayList(size());
        for (JsonElement element : array) {
            result.add(element.getAsDouble());
        }
        return result;
    }
View Full Code Here

        return data.getStringList();
    }

    @Override
    public TDoubleList getAsDoubleArray() {
        TDoubleList result = new TDoubleArrayList(data.getDoubleCount());
        for (int i = 0; i < data.getDoubleCount(); ++i) {
            result.add(data.getDouble(i));
        }
        return result;
    }
View Full Code Here

    protected abstract TObjectDoubleMap<String> gatherMetrics();

    private void displayMetrics(TObjectDoubleMap<String> metrics, StringBuilder builder) {
        final List<String> activities = Lists.newArrayList();
        final TDoubleList values = new TDoubleArrayList();
        sortMetrics(metrics, activities, values);

        for (int i = 0; i < limit && i < activities.size(); ++i) {
            builder.append(activities.get(i));
            builder.append(": ");
            builder.append(format.format(values.get(i)));
            builder.append(unit);
            builder.append("\n");
        }
    }
View Full Code Here

TOP

Related Classes of gnu.trove.list.array.TDoubleArrayList

Copyright © 2018 www.massapicom. 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.