예제 #1
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;
  }
예제 #2
0
  protected static JsComplexMatrix makeComplex(JsRealMatrix matrix) {
    Float64Matrix realMatrix = (Float64Matrix) matrix.matrix;
    int m = realMatrix.getRow(0).getDimension();
    int n = realMatrix.getColumn(0).getDimension();

    Complex[][] values = new Complex[m][n];

    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        values[i][j] = Complex.valueOf(realMatrix.get(i, j).doubleValue(), 0);
      }
    }

    return new JsComplexMatrix(ComplexMatrix.valueOf(values));
  }