@Override
 public void serialize(BserWriter writer) throws IOException {
   writer.writeInt(1, this.w);
   writer.writeInt(2, this.h);
   if (this.getUnmappedObjects() != null) {
     SparseArray<Object> unmapped = this.getUnmappedObjects();
     for (int i = 0; i < unmapped.size(); i++) {
       int key = unmapped.keyAt(i);
       writer.writeUnmapped(key, unmapped.get(key));
     }
   }
 }
Exemplo n.º 2
0
    /** For debugging purposes. */
    @Override
    public String toString() {
      if (wordIndices == null) {
        return "";
      }

      StringWriter sw = new StringWriter();
      TabularOutput t = new TabularOutput(sw);
      t.flushEvery(Integer.MAX_VALUE);
      t.addColumn("#");
      t.addColumn("wordIndices");
      t.addColumn("=>words").alignLeft();
      t.addColumn("tf");
      t.addColumn("tfByDocument").alignLeft();

      for (int i = 0; i < wordIndices.length; i++, t.nextRow()) {
        t.rowData(
            i,
            Arrays.toString(wordIndices[i]).replace(" ", ""),
            getPhrase(i),
            tf[i],
            SparseArray.sparseToString(tfByDocument[i]));
      }

      t.flush();
      sw.append("\n");
      return sw.toString();
    }
Exemplo n.º 3
0
    /** For debugging purposes. */
    @Override
    public String toString() {
      StringWriter sw = new StringWriter();
      TabularOutput t = new TabularOutput(sw);
      t.flushEvery(Integer.MAX_VALUE);
      t.addColumn("#");
      t.addColumn("stem");
      t.addColumn("mostFrqWord");
      t.addColumn("=>mostFrqWord").alignLeft();
      t.addColumn("tf");
      t.addColumn("tfByDocument").alignLeft();
      t.addColumn("fieldIndices");

      for (int i = 0; i < image.length; i++, t.nextRow()) {
        t.rowData(
            i,
            image[i] == null ? "<null>" : new String(image[i]),
            mostFrequentOriginalWordIndex[i],
            new String(allWords.image[mostFrequentOriginalWordIndex[i]]),
            tf[i],
            SparseArray.sparseToString(tfByDocument[i]),
            Arrays.toString(toFieldIndexes(fieldIndices[i])).replace(" ", ""));
      }

      t.flush();
      sw.append("\n");
      return sw.toString();
    }
  private double getImaginaryElementAtSparseIndex(int sparseIndex) {
    double val = 0;
    if (!_array.isReal() && sparseIndex >= 0) {
      val = _array._imagValues[sparseIndex];
    }

    return val;
  }
  @Override
  public MatlabDouble getElementAtIndices(int row, int column) {
    int sparseIndex = _array.getSparseIndexForIndices(row, column);

    return new MatlabDouble(
        this.getRealElementAtSparseIndex(sparseIndex),
        this.getImaginaryElementAtSparseIndex(sparseIndex));
  }
  @Override
  public MatlabDouble getElementAtLinearIndex(int linearIndex) {
    int sparseIndex = _array.getSparseIndexForLinearIndex(linearIndex);

    return new MatlabDouble(
        this.getRealElementAtSparseIndex(sparseIndex),
        this.getImaginaryElementAtSparseIndex(sparseIndex));
  }
Exemplo n.º 7
0
 @Override
 public void serialize(BserWriter writer) throws IOException {
   if (this.command == null) {
     throw new IOException();
   }
   writer.writeString(1, this.command);
   if (this.args == null) {
     throw new IOException();
   }
   writer.writeString(2, this.args);
   if (this.getUnmappedObjects() != null) {
     SparseArray<Object> unmapped = this.getUnmappedObjects();
     for (int i = 0; i < unmapped.size(); i++) {
       int key = unmapped.keyAt(i);
       writer.writeUnmapped(key, unmapped.get(key));
     }
   }
 }
  @Override
  public boolean equals(Object obj) {
    boolean equal = false;
    if (this == obj) {
      equal = true;
    } else if (obj != null && this.getClass().equals(obj.getClass())) {
      MatlabDoubleSparseMatrix other = (MatlabDoubleSparseMatrix) obj;
      equal = _array.equals(other._array);
    }

    return equal;
  }
Exemplo n.º 9
0
    /** For debugging purposes. */
    @Override
    public String toString() {
      StringWriter sw = new StringWriter();
      TabularOutput t = new TabularOutput(sw);
      t.flushEvery(Integer.MAX_VALUE);
      t.addColumn("#");
      t.addColumn("image").alignLeft();
      t.addColumn("type");
      t.addColumn("tf");
      t.addColumn("tfByDocument").alignLeft();
      t.addColumn("fieldIndices");

      if (stemIndex != null) {
        t.addColumn("stemIndex");
        t.addColumn("=>stem").alignLeft();
      }

      for (int i = 0; i < image.length; i++, t.nextRow()) {
        t.rowData(
            i,
            image[i] == null ? "<null>" : new String(image[i]),
            type[i],
            tf[i],
            SparseArray.sparseToString(tfByDocument[i]));

        t.rowData(Arrays.toString(toFieldIndexes(fieldIndices[i])).replace(" ", ""));

        if (stemIndex != null) {
          t.rowData(stemIndex[i]);
          t.rowData(new String(allStems.image[stemIndex[i]]));
        }
      }

      t.flush();
      sw.append("\n");
      return sw.toString();
    }
 @Override
 public double getRealElementAtIndices(int row, int column) {
   return this.getRealElementAtSparseIndex(_array.getSparseIndexForIndices(row, column));
 }
 @Override
 public double getImaginaryElementAtLinearIndex(int linearIndex) {
   return this.getImaginaryElementAtSparseIndex(_array.getSparseIndexForLinearIndex(linearIndex));
 }
 @Override
 public int hashCode() {
   return _array.hashCode();
 }