示例#1
0
  @Override
  public void assign(DataBuffer data) {
    if (data.length() != length())
      throw new IllegalArgumentException(
          "Unable to assign buffer of length "
              + data.length()
              + " to this buffer of length "
              + length());

    for (int i = 0; i < data.length(); i++) {
      put(i, data.getDouble(i));
    }
  }
示例#2
0
  @Override
  public DataBuffer dup() {
    DataBuffer ret = create(length);
    for (int i = 0; i < ret.length(); i++) ret.put(i, getDouble(i));

    return ret;
  }
示例#3
0
  @Override
  public boolean equals(Object o) {
    if (o instanceof DataBuffer) {
      DataBuffer d = (DataBuffer) o;
      if (d.length() != length()) return false;
      for (int i = 0; i < length(); i++) {
        double eps = Math.abs(getDouble(i) - d.getDouble(i));
        if (eps > Nd4j.EPS_THRESHOLD) return false;
      }
    }

    return true;
  }
示例#4
0
  @Override
  public boolean equals(Object o) {
    // FIXME: this is BAD. it takes too long to work, and it breaks general equals contract
    if (o instanceof DataBuffer) {
      DataBuffer d = (DataBuffer) o;
      if (d.length() != length()) return false;
      for (int i = 0; i < length(); i++) {
        double eps = Math.abs(getDouble(i) - d.getDouble(i));
        if (eps > 1e-12) return false;
      }
    }

    return true;
  }
示例#5
0
  @Override
  public DataBuffer dup() {
    if (floatData != null) {
      return create(floatData);
    } else if (doubleData != null) {
      return create(doubleData);
    } else if (intData != null) {
      return create(intData);
    }

    DataBuffer ret = create(length);
    for (int i = 0; i < ret.length(); i++) ret.put(i, getDouble(i));

    return ret;
  }