Exemple #1
0
  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < matrix.getNumberOfRows(); i++) {
      for (int j = 0; j < matrix.getNumberOfColumns(); j++) {

        sb.append(matrix.get(i, j) + "\t");
      }
      sb.append('\n');
    }
    return sb.toString();
  }
Exemple #2
0
  @Override
  public IMatrix times(IMatrix m) {
    if (m instanceof JsMatrix) {

      if (m instanceof JsComplexMatrix || this instanceof JsComplexMatrix) {
        return new JsComplexMatrix(ComplexMatrix.valueOf(matrix.times(((JsMatrix) m).matrix)));
      } else {
        return new JsRealMatrix(Float64Matrix.valueOf(matrix.times(((JsMatrix) m).matrix)));
      }
    }

    return null;
  }
  @Override
  protected Pair<Vector<Float64>, Vector<Float64>> transformOriginalToInternState(
      List<Vector<Float64>> hist, Vector<Float64> target) {
    Vector<Float64> v = transformOriginalToInternState(hist);

    DataEntry lastState = new DataEntry(hist.get(hist.size() - 1));
    Vector<Float64> trans = lastState.getPos();
    Matrix<Float64> rot = lastState.getRotation();

    DataEntry t = new DataEntry(target);
    Vector<Float64> pos = rot.times(t.getPos().minus(trans));
    Vector<Float64> vel = rot.times(t.getVel());

    Vector<Float64> intern = Float64Vector.valueOf(pos.get(0), pos.get(1), vel.get(0), vel.get(1));

    return new Pair<Vector<Float64>, Vector<Float64>>(v, intern);
  }
  @Override
  protected Vector<Float64> transformInternToOriginalState(
      List<Vector<Float64>> history, Vector<Float64> state) {

    DataEntry lastState = new DataEntry(history.get(history.size() - 1));
    Vector<Float64> trans = lastState.getPos(); // NOPMD
    Matrix<Float64> rot = lastState.getRotation();

    DenseVector<Float64> pos = Float64Vector.valueOf(state.get(0), state.get(1));
    Float64Vector vel =
        Float64Vector.valueOf(state.get(2).doubleValue(), state.get(3).doubleValue());

    Vector<Float64> newPos = rot.inverse().times(pos).plus(trans);
    Float64 v = vel.norm();

    return Float64Vector.valueOf(
        newPos.get(0), newPos.get(1), vel.get(0).divide(v), vel.get(1).divide(v), v);
  }
  @Override
  protected Vector<Float64> transformOriginalToInternState(List<Vector<Float64>> data) {
    DataEntry lastState = new DataEntry(data.get(data.size() - 1));
    data.remove(data.size() - 1);

    Vector<Float64> trans = lastState.getPos();
    Matrix<Float64> rot = lastState.getRotation();

    List<Float64> concated = new ArrayList<Float64>(getHistorySize() * 4);

    concated.add(Float64.valueOf(lastState.getV()));

    for (Vector<Float64> v : data) {
      DataEntry d = new DataEntry(v);

      Vector<Float64> pos = rot.times(d.getPos().minus(trans));
      Vector<Float64> vel = rot.times(d.getVel());

      concated.addAll(
          Lists.newArrayList(
              pos.get(0), pos.get(1), vel.get(0), vel.get(1), Float64.valueOf(d.getV())));
    }
    return Float64Vector.valueOf(concated);
  }