CPD Results

The following document contains the results of PMD's CPD 6.13.0.

Duplications

File Line
org/mklab/sdpj/algebra/Algebra.java 324
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 459
    for (int i = 0; i < a.getBlockSize(); ++i) {
      ans = ans.add(getInnerProduct(a.getBlock(i), b.getBlock(i)));
    }
    return ans;
  }

  /**
   * getCholesky(retMat,aMat)をret=getCholesky(aMat)に変更
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a 元になる行列
   * @return ret 結果retMatと同じ
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> getCholesky(DenseMatrix<RS,RM,CS,CM> a) {
    final RS unit = a.getElementUnit();

    DenseMatrix<RS,RM,CS,CM> ans;
    switch (a.getDenseOrDiagonal()) {
      case DENSE:
        ans = a.createClone();
        int info = Clapack.dpotrf("Lower", ans.getRowSize(), ans.denseElements, ans.getRowSize()); //$NON-NLS-1$

        if (info != 0) {
          throw new RuntimeException("cannot cholesky decomposition\n" + "Could you try with smaller gammaStar?"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        // Make matrix as lower triangular matrix
        for (int j = 0; j < ans.getColumnSize(); ++j) {
          int shou = j / 4;
          int amari = j % 4;
          for (int i = 0; i < amari; ++i) {
            ans.denseElements[i + ans.getColumnSize() * j] = unit.create(0);
          }
          int i;
          int count;
          for (i = amari, count = 0; count < shou; ++count, i += 4) {
            ans.denseElements[i + ans.getColumnSize() * j] = unit.create(0);
            ans.denseElements[i + 1 + ans.getColumnSize() * j] = unit.create(0);
            ans.denseElements[i + 2 + ans.getColumnSize() * j] = unit.create(0);
            ans.denseElements[i + 3 + ans.getColumnSize() * j] = unit.create(0);
          }
        }
        return ans;
      case DIAGONAL:
        ans = new DenseMatrix<>(a.getRowSize(), a.getColumnSize(), a.getDenseOrDiagonal(), unit);

        int shou = a.getColumnSize() / 4;
        int amari = a.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = a.diagonalElements[j].sqrt();
        }

        int j;
        int count;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = a.diagonalElements[j].sqrt();
          ans.diagonalElements[j + 1] = a.diagonalElements[j + 1].sqrt();
          ans.diagonalElements[j + 2] = a.diagonalElements[j + 2].sqrt();
          ans.diagonalElements[j + 3] = a.diagonalElements[j + 3].sqrt();
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @return retMatのコピー
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> getInvLowTriangularMatrix(DenseMatrix<RS,RM,CS,CM> a) {
    final RS unit = a.getElementUnit();

    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), a.getColumnSize(), a.getDenseOrDiagonal(), unit);

    switch (ans.getDenseOrDiagonal()) {
      case DENSE:
        ans.setIdentity(unit.create(1));

        int nRow = a.getRowSize();
        int nCol = a.getColumnSize();
        int retnRow = ans.getRowSize();
        BLAS.dtrsm("Left", "Lower", "NoTraspose", "NonUnitDiagonal", nRow, nCol, unit.create(1), a.denseElements, nRow, ans.denseElements, retnRow); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
        return ans;
      case DIAGONAL:
        int shou = a.getColumnSize() / 4;
        int amari = a.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = unit.create(1).divide(a.diagonalElements[j]);
        }
        for (int j = amari, counter = 0; counter < shou; ++counter, j += 4) {
          ans.diagonalElements[j] = unit.create(1).divide(a.diagonalElements[j]);// 1.0
          ans.diagonalElements[j + 1] = unit.create(1).divide(a.diagonalElements[j + 1]);
          ans.diagonalElements[j + 2] = unit.create(1).divide(a.diagonalElements[j + 2]);
          ans.diagonalElements[j + 3] = unit.create(1).divide(a.diagonalElements[j + 3]);
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @return コレスキー分解と逆行列
   */
  @SuppressWarnings("unchecked")
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM>[] getCholeskyAndInv(BlockDenseMatrix<RS,RM,CS,CM> a) {
    BlockDenseMatrix<RS,RM,CS,CM> choleskyMat = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());
    BlockDenseMatrix<RS,RM,CS,CM> inverseMat = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> ans1 = getCholesky(a.getBlock(i));
      choleskyMat.setBlock(i, ans1);
      DenseMatrix<RS,RM,CS,CM> ans2 = getInvLowTriangularMatrix(ans1);
      inverseMat.setBlock(i, ans2);
    }

    return new BlockDenseMatrix[] {choleskyMat, inverseMat};
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> void getSymmetrize(DenseMatrix<RS,RM,CS,CM> a) {
    final RS unit = a.getElementUnit();

    //int index = 0;
    switch (a.getDenseOrDiagonal()) {
      case DENSE:
        if (a.getRowSize() != a.getColumnSize()) {
          throw new RuntimeException("getSymmetrize:: different memory size"); //$NON-NLS-1$
        }
        for (int index = 0; index < a.getRowSize() - 1; ++index) {
          int index1 = index + index * a.getRowSize() + 1;
          int index2 = index + (index + 1) * a.getRowSize();
          int length = a.getRowSize() - 1 - index;
          // aMat.de_ele[index1] += aMat.de_ele[index2]

          RS[] aMat_index2 = unit.createArray(a.denseElements.length - index2);
          RS[] aMat_index1 = unit.createArray(a.denseElements.length - index1);

          System.arraycopy(a.denseElements, index1, aMat_index1, 0, aMat_index1.length);
          System.arraycopy(a.denseElements, index2, aMat_index2, 0, aMat_index2.length);
          //BLAS.daxpy(length, unit.create(1), aMat_index2, a.getRowSize(), aMat_index1, 1);
          BLAS.dxpy(length, aMat_index2, a.getRowSize(), aMat_index1, 1);
          System.arraycopy(aMat_index1, 0, a.denseElements, index1, aMat_index1.length);

          // aMat.de_ele[index1] /= 2.0

          RS half = unit.create(5).multiply(unit.create(10).power(-1));
          System.arraycopy(a.denseElements, index1, aMat_index1, 0, aMat_index1.length);
          BLAS.dscal(length, half, aMat_index1, 1);
          System.arraycopy(aMat_index1, 0, a.denseElements, index1, aMat_index1.length);

          // aMat.de_ele[index2] = aMat.de_ele[index1]
          RS[] A1 = unit.createArray(a.denseElements.length - index1);
          System.arraycopy(a.denseElements, index1, A1, 0, A1.length);
          RS[] A2 = unit.createArray(a.denseElements.length - index2);
          System.arraycopy(a.denseElements, index2, A2, 0, A2.length);
          BLAS.dcopy(length, A1, 1, A2, a.getRowSize());
          System.arraycopy(A2, 0, a.denseElements, index2, A2.length);
        }
        break;
      case DIAGONAL:
        // Nothing needs.
        break;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> void getSymmetrize(BlockDenseMatrix<RS,RM,CS,CM> a) {
    for (int i = 0; i < a.getBlockSize(); ++i) {
      getSymmetrize(a.getBlock(i));
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @return 転置行列
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> getTranspose(DenseMatrix<RS,RM,CS,CM> a) {
    if (a.getRowSize() != a.getColumnSize()) {
      throw new RuntimeException("getTranspose:: different memory size"); //$NON-NLS-1$
      // Of course, a non-symmetric matrix has its transposed matrix,
      // but in this algorithm we have to make transposed matrix only when symmetric matrix.
    }
    DenseMatrix<RS,RM,CS,CM> ans = a.createClone();

    switch (a.getDenseOrDiagonal()) {
      case DENSE:
        for (int i = 0; i < a.getRowSize(); ++i) {
          int shou = (i + 1) / 4;
          int amari = (i + 1) / 4;
          for (int j = 0; j < amari; ++j) {
            int index1 = i + a.getColumnSize() * j;
            int index2 = j + a.getColumnSize() * i;
            ans.denseElements[index1] = a.denseElements[index2];
            ans.denseElements[index2] = a.denseElements[index1];
          }
          int counter, j;
          for (j = amari, counter = 0; counter < shou; ++counter, j += 4) {
            int index1 = i + a.getColumnSize() * j;
            int index_1 = j + a.getColumnSize() * i;
            ans.denseElements[index1] = a.denseElements[index_1];
            ans.denseElements[index_1] = a.denseElements[index1];
            int index2 = i + a.getColumnSize() * (j + 1);
            int index_2 = (j + 1) + a.getColumnSize() * i;
            ans.denseElements[index2] = a.denseElements[index_2];
            ans.denseElements[index_2] = a.denseElements[index2];
            int index3 = i + a.getColumnSize() * (j + 2);
            int index_3 = (j + 2) + a.getColumnSize() * i;
            ans.denseElements[index3] = a.denseElements[index_3];
            ans.denseElements[index_3] = a.denseElements[index3];
            int index4 = i + a.getColumnSize() * (j + 3);
            int index_4 = (j + 3) + a.getColumnSize() * i;
            ans.denseElements[index4] = a.denseElements[index_4];
            ans.denseElements[index_4] = a.denseElements[index4];
          }
        }
        return ans;
      case DIAGONAL:
        throw new IllegalArgumentException();
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
     * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @return ブロック転置行列
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> getTranspose(BlockDenseMatrix<RS,RM,CS,CM> a) {
    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = getTranspose(a.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @return 計算が正常終了したならばtrue
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> boolean choleskyFactorWithAdjust(DenseMatrix<RS,RM,CS,CM> a) {
    int rowSize = a.getRowSize();

    //int info = new Dpotrf<RS>().rATL_dpotrfL(rowSize, a.denseElements, rowSize);
    //a.setRowSize(rowSize);

    int info = Clapack.dpotrf("Lower", rowSize, a.denseElements, rowSize); //$NON-NLS-1$
    a.setRowSize(rowSize);

    if (info < 0) {
      System.err.println("cholesky argument is wrong " + (-info)); //$NON-NLS-1$
      return false;
    } else if (info > 0) {
      System.err.println("cholesky miss condition :: not positive definite" + " :: info = " + info); //$NON-NLS-1$ //$NON-NLS-2$
      return false;
    }
    return true;
  }

  /**
   * solve aMat * xVec = bVec aMat must be Cholesky Factorized. aMat must have done Cholesky factorized.
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b b
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> solveSystems(DenseMatrix<RS,RM,CS,CM> a, Vector<RS,RM,CS,CM> b) {
    if (a.getRowSize() != b.getDimension() || a.getRowSize() != a.getColumnSize()) {
      throw new RuntimeException("solveSystems:: different memory size"); //$NON-NLS-1$
    }
    if (a.isDense() == false) {
      throw new RuntimeException("solveSystems:: matrix type must be DENSE"); //$NON-NLS-1$
    }
    Vector<RS,RM,CS,CM> x = b.createClone();
    BLAS.dtrsv("Lower", "NoTranspose", "NonUnit", a.getRowSize(), a.denseElements, a.getColumnSize(), x.getElements(), 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    BLAS.dtrsv("Lower", "Transpose", "NonUnit", a.getRowSize(), a.denseElements, a.getColumnSize(), x.getElements(), 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    return x;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getColumnSize() != b.getRowSize() || a.getDenseOrDiagonal() != b.getDenseOrDiagonal()) {
      throw new RuntimeException("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), b.getColumnSize(), a.getDenseOrDiagonal(), unit);

    switch (ans.getDenseOrDiagonal()) {
      case DENSE:
        BLAS.dgemm(
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.diagonalElements[j]));
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.diagonalElements[j]));
          ans.diagonalElements[j + 1] = scalar.multiply(a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]));
          ans.diagonalElements[j + 2] = scalar.multiply(a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]));
          ans.diagonalElements[j + 3] = scalar.multiply(a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]));
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
    if (a.getColumnSize() != b.getRowSize()) {
      throw new RuntimeException("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), b.getColumnSize(), a.getDenseOrDiagonal(), unit);

    switch (ans.getDenseOrDiagonal()) {
      case DENSE:
        BLAS.dgemm(
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), unit.create(1), a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
          ans.diagonalElements[j + 1] = a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]);
          ans.diagonalElements[j + 2] = a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]);
          ans.diagonalElements[j + 3] = a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]);
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * Dense=Sparse*Dense
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getColumnSize() != b.getRowSize()) {
      throw new RuntimeException("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = b.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), b.getColumnSize(), b.getDenseOrDiagonal(), unit);

    switch (a.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        if (ans.isDense() == false || b.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }
        for (int index = 0; index < a.nonZeroCount; ++index) {
          int i = a.rowIndex[index];
          int j = a.columnIndex[index];
          RS value = a.getSparseElement(index).multiply(scalar);
          if (i != j) {
            RS[] bMat_j = unit.createArray(b.denseElements.length - j);
            System.arraycopy(b.denseElements, j, bMat_j, 0, bMat_j.length);
            RS[] retMat_i = unit.createArray(ans.denseElements.length - i);
            System.arraycopy(ans.denseElements, i, retMat_i, 0, retMat_i.length);
            BLAS.daxpy(b.getColumnSize(), value, bMat_j, b.getRowSize(), retMat_i, ans.getRowSize());
            System.arraycopy(retMat_i, 0, ans.denseElements, i, retMat_i.length);

            RS[] bMat_i = unit.createArray(b.denseElements.length - i);
            System.arraycopy(b.denseElements, i, bMat_i, 0, bMat_i.length);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - j);
            System.arraycopy(ans.denseElements, j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, bMat_i, b.getRowSize(), retMat_j, ans.getRowSize());
            System.arraycopy(retMat_j, 0, ans.denseElements, j, retMat_j.length);
          } else {
            RS[] bMat_j = unit.createArray(b.denseElements.length - j);
            System.arraycopy(b.denseElements, j, bMat_j, 0, bMat_j.length);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - j);
            System.arraycopy(ans.denseElements, j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, bMat_j, b.getRowSize(), retMat_j, ans.getRowSize());
            System.arraycopy(retMat_j, 0, ans.denseElements, j, retMat_j.length);
          }
        }
        return ans;
      case DENSE:
        if (ans.isDense() == false || b.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }
        BLAS.dgemm(
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        if (ans.isDiagonal() == false || b.isDiagonal() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = scalar.multiply(a.getDiagonalElement(j).multiply(b.diagonalElements[j]));
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = scalar.multiply(a.getDiagonalElement(j)).multiply(b.diagonalElements[j]);
          ans.diagonalElements[j + 1] = scalar.multiply(a.getDiagonalElement(j + 1).multiply(b.diagonalElements[j + 1]));
          ans.diagonalElements[j + 2] = scalar.multiply(a.getDiagonalElement(j + 2).multiply(b.diagonalElements[j + 2]));
          ans.diagonalElements[j + 3] = scalar.multiply(a.getDiagonalElement(j + 3).multiply(b.diagonalElements[j + 3]));
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * TODO TODO Dense=Sparse*Dense
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
    if (a.getColumnSize() != b.getRowSize()) {
      throw new RuntimeException("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = b.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), b.getColumnSize(), b.getDenseOrDiagonal(), unit);

    switch (a.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        if (ans.isDense() == false || b.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        for (int index = 0; index < a.nonZeroCount; ++index) {
          int i = a.rowIndex[index];
          int j = a.columnIndex[index];
          RS value = a.getSparseElement(index);
          if (i != j) {
            RS[] bMat_j = unit.createArray(b.denseElements.length - j);
            System.arraycopy(b.denseElements, j, bMat_j, 0, bMat_j.length);
            RS[] retMat_i = unit.createArray(ans.denseElements.length - i);
            System.arraycopy(ans.denseElements, i, retMat_i, 0, retMat_i.length);
            BLAS.daxpy(b.getColumnSize(), value, bMat_j, b.getRowSize(), retMat_i, ans.getRowSize());
            System.arraycopy(retMat_i, 0, ans.denseElements, i, retMat_i.length);

            RS[] bMat_i = unit.createArray(b.denseElements.length - i);
            System.arraycopy(b.denseElements, i, bMat_i, 0, bMat_i.length);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - j);
            System.arraycopy(ans.denseElements, j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, bMat_i, b.getRowSize(), retMat_j, ans.getRowSize());
            System.arraycopy(retMat_j, 0, ans.denseElements, j, retMat_j.length);
          } else {
            RS[] bMat_j = unit.createArray(b.denseElements.length - j);
            System.arraycopy(b.denseElements, j, bMat_j, 0, bMat_j.length);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - j);
            System.arraycopy(ans.denseElements, j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, bMat_j, b.getRowSize(), retMat_j, ans.getRowSize());
            System.arraycopy(retMat_j, 0, ans.denseElements, j, retMat_j.length);
          }
        }
        return ans;
      case DENSE:
        if (ans.isDense() == false || b.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }
        BLAS.dgemm(
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), unit.create(1), a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        if (ans.isDiagonal() == false || b.isDiagonal() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = a.getDiagonalElement(j).multiply(b.diagonalElements[j]);
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = a.getDiagonalElement(j).multiply(b.diagonalElements[j]);
          ans.diagonalElements[j + 1] = a.getDiagonalElement(j + 1).multiply(b.diagonalElements[j + 1]);
          ans.diagonalElements[j + 2] = a.getDiagonalElement(j + 2).multiply(b.diagonalElements[j + 2]);
          ans.diagonalElements[j + 3] = a.getDiagonalElement(j + 3).multiply(b.diagonalElements[j + 3]);
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * TODO MULTIPLY_NON_ATLASがFalseの場合でやるのもいいかも。 falseの場合でやると、配列のコピーの回数がここの分だけ減る。 Dense=Dense*Sparse
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, SparseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getColumnSize() != b.getRowSize()) {
      throw new RuntimeException("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), b.getColumnSize(), a.getDenseOrDiagonal(), unit);

    switch (b.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        if (ans.isDense() == false || a.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        for (int index = 0; index < b.nonZeroCount; ++index) {
          int i = b.rowIndex[index];
          int j = b.columnIndex[index];
          RS value = b.getSparseElement(index).multiply(scalar);
          if (i != j) {
            RS[] aMat_i = unit.createArray(a.denseElements.length - a.getRowSize() * i);
            System.arraycopy(a.denseElements, a.getRowSize() * i, aMat_i, 0, aMat_i.length);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - ans.getRowSize() * j);
            System.arraycopy(ans.denseElements, ans.getRowSize() * j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, aMat_i, 1, retMat_j, 1);
            System.arraycopy(retMat_j, 0, ans.denseElements, ans.getRowSize() * j, retMat_j.length);

            RS[] aMat_j = unit.createArray(a.denseElements.length - a.getRowSize() * j);
            System.arraycopy(a.denseElements, a.getRowSize() * j, aMat_j, 0, aMat_j.length);
            RS[] retMat_i = unit.createArray(ans.denseElements.length - ans.getRowSize() * i);
            System.arraycopy(ans.denseElements, ans.getRowSize() * i, retMat_i, 0, retMat_i.length);
            BLAS.daxpy(b.getColumnSize(), value, aMat_j, 1, retMat_i, 1);
            System.arraycopy(retMat_i, 0, ans.denseElements, ans.getRowSize() * i, retMat_i.length);
          } else {
            RS[] aMat_j = unit.createArray(a.denseElements.length - a.getRowSize() * j);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - ans.getRowSize() * j);
            System.arraycopy(a.denseElements, a.getRowSize() * j, aMat_j, 0, aMat_j.length);
            System.arraycopy(ans.denseElements, ans.getRowSize() * j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, aMat_j, 1, retMat_j, 1);
            System.arraycopy(retMat_j, 0, ans.denseElements, ans.getRowSize() * j, retMat_j.length);
          }
        }
        return ans;
      case DENSE:
        if (ans.isDense() == false || a.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        BLAS.dgemm(
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        if (ans.isDiagonal() == false || a.isDiagonal() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.getDiagonalElement(j)));
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.getDiagonalElement(j)));
          ans.diagonalElements[j + 1] = scalar.multiply(a.diagonalElements[j + 1].multiply(b.getDiagonalElement(j + 1)));
          ans.diagonalElements[j + 2] = scalar.multiply(a.diagonalElements[j + 2].multiply(b.getDiagonalElement(j + 2)));
          ans.diagonalElements[j + 3] = scalar.multiply(a.diagonalElements[j + 3].multiply(b.getDiagonalElement(j + 3)));
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * TODO MULTIPLY_NON_ATLASがFalseの場合でやるのもいいかも。 falseの場合でやると、配列のコピーの回数がここの分だけ減る。 Dense=Dense*Sparse
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, SparseMatrix<RS,RM,CS,CM> b) {
    if (a.getColumnSize() != b.getRowSize()) {
      throw new RuntimeException("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), b.getColumnSize(), a.getDenseOrDiagonal(), unit);

    switch (b.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        if (ans.isDense() == false || a.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        for (int index = 0; index < b.nonZeroCount; ++index) {
          int i = b.rowIndex[index];
          int j = b.columnIndex[index];
          RS value = b.getSparseElement(index);
          if (i != j) {
            RS[] aMat_j = unit.createArray(a.denseElements.length - a.getRowSize() * j);
            System.arraycopy(a.denseElements, a.getRowSize() * j, aMat_j, 0, aMat_j.length);
            RS[] retMat_i = unit.createArray(ans.denseElements.length - ans.getRowSize() * i);
            System.arraycopy(ans.denseElements, ans.getRowSize() * i, retMat_i, 0, retMat_i.length);
            BLAS.daxpy(b.getColumnSize(), value, aMat_j, 1, retMat_i, 1);
            System.arraycopy(retMat_i, 0, ans.denseElements, ans.getRowSize() * i, retMat_i.length);

            RS[] aMat_i = unit.createArray(a.denseElements.length - a.getRowSize() * i);
            System.arraycopy(a.denseElements, a.getRowSize() * i, aMat_i, 0, aMat_i.length);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - ans.getRowSize() * j);
            System.arraycopy(ans.denseElements, ans.getRowSize() * j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, aMat_i, 1, retMat_j, 1);
            System.arraycopy(retMat_j, 0, ans.denseElements, ans.getRowSize() * j, retMat_j.length);
          } else {
            RS[] aMat_j = unit.createArray(a.denseElements.length - a.getRowSize() * j);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - ans.getRowSize() * j);
            System.arraycopy(a.denseElements, a.getRowSize() * j, aMat_j, 0, aMat_j.length);
            System.arraycopy(ans.denseElements, ans.getRowSize() * j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, aMat_j, 1, retMat_j, 1);
            System.arraycopy(retMat_j, 0, ans.denseElements, ans.getRowSize() * j, retMat_j.length);
          }
        }
        return ans;
      case DENSE:
        if (ans.isDense() == false || a.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }
        BLAS.dgemm(
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), unit.create(1), a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        if (ans.isDiagonal() == false || a.isDiagonal() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.getDiagonalElement(j));
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.getDiagonalElement(j));
          ans.diagonalElements[j + 1] = a.diagonalElements[j + 1].multiply(b.getDiagonalElement(j + 1));
          ans.diagonalElements[j + 2] = a.diagonalElements[j + 2].multiply(b.getDiagonalElement(j + 2));
          ans.diagonalElements[j + 3] = a.diagonalElements[j + 3].multiply(b.getDiagonalElement(j + 3));
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, RS scalar) {
    DenseMatrix<RS,RM,CS,CM> ans = a.createClone();

    switch (ans.getDenseOrDiagonal()) {
      case DENSE:
        int length = ans.getRowSize() * ans.getColumnSize();
        BLAS.dscal(length, scalar, ans.denseElements, 1);
        return ans;
      case DIAGONAL:
        BLAS.dscal(ans.getColumnSize(), scalar, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, RS scalar) {
    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> multiply(Vector<RS,RM,CS,CM> a, RS scalar) {
    Vector<RS,RM,CS,CM> ans = a.createClone();
    BLAS.dscal(ans.getDimension(), scalar, ans.getElements(), 1);
    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockVector<RS,RM,CS,CM> multiply(BlockVector<RS,RM,CS,CM> a, RS scalar) {
    BlockVector<RS,RM,CS,CM> ans = a.createClone();

    for (int i = 0; i < a.getBlockSize(); ++i) {
      Vector<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b b
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, Vector<RS,RM,CS,CM> b) {
    if (a.getColumnSize() != b.getDimension()) {
      throw new RuntimeException("multiply :: different matrix size"); //$NON-NLS-1$
    }

    Vector<RS,RM,CS,CM> ans = b.createClone();

    final RS unit = a.getElementUnit();

    switch (a.getDenseOrDiagonal()) {
      case DENSE:
        BLAS.dgemv("NoTranspose", a.getRowSize(), a.getColumnSize(), unit.create(1), a.denseElements, a.getRowSize(), b.getElements(), 1, unit.create(0), ans.getElements(), 1); //$NON-NLS-1$
        return ans;
      case DIAGONAL:
        int shou = ans.getDimension() / 4;
        int amari = ans.getDimension() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.setElement(j, a.diagonalElements[j].multiply(b.getElement(j)));
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.setElement(j, a.diagonalElements[j].multiply(b.getElement(j)));
          ans.setElement(j + 1, a.diagonalElements[j + 1].multiply(b.getElement(j + 1)));
          ans.setElement(j + 2, a.diagonalElements[j + 2].multiply(b.getElement(j + 2)));
          ans.setElement(j + 3, a.diagonalElements[j + 3].multiply(b.getElement(j + 3)));
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b b
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, Vector<RS,RM,CS,CM> b, RS scalar) {
    if (a.getColumnSize() != b.getDimension()) {
      throw new RuntimeException("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    Vector<RS,RM,CS,CM> ans = new Vector<>(a.getRowSize(), unit);

    switch (a.getDenseOrDiagonal()) {
      case DENSE:
        BLAS.dgemv("NoTranspose", a.getRowSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.getElements(), 1, unit.create(0), ans.getElements(), 1); //$NON-NLS-1$
        return ans;
      case DIAGONAL:
        int shou = ans.getDimension() / 4;
        int amari = ans.getDimension() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.setElement(j, scalar.multiply(a.diagonalElements[j].multiply(b.getElement(j))));
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.setElement(j, scalar.multiply(a.diagonalElements[j].multiply(b.getElement(j))));
          ans.setElement(j + 1, scalar.multiply(a.diagonalElements[j + 1].multiply(b.getElement(j + 1))));
          ans.setElement(j + 2, scalar.multiply(a.diagonalElements[j + 2].multiply(b.getElement(j + 2))));
          ans.setElement(j + 3, scalar.multiply(a.diagonalElements[j + 3].multiply(b.getElement(j + 3))));
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b b
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockVector<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockVector<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    BlockVector<RS,RM,CS,CM> ans = new BlockVector<>(a.getBlockSize(), a.getBlockStructs(), unit);

    for (int i = 0; i < a.getBlockSize(); ++i) {
      Vector<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b b
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockVector<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockVector<RS,RM,CS,CM> b) {
    if (b.getBlockSize() != a.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockVector<RS,RM,CS,CM> ans = b.createClone();

    for (int i = 0; i < b.getBlockSize(); ++i) {
      Vector<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = a.createClone();

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(b.getBlockSize(), b.getBlockStructs(), b.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(b.getBlockSize(), b.getBlockStructs(), b.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockSparseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockSparseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = aMat**T * bMat
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> tran_multiply(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getRowSize() != b.getRowSize() || a.getDenseOrDiagonal() != b.getDenseOrDiagonal()) {
      Tools.error("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getColumnSize(), b.getColumnSize(), a.getDenseOrDiagonal(), unit);

    switch (ans.getDenseOrDiagonal()) {
      case DENSE:
        BLAS.dgemm(
            "Transpose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getColumnSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:

        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.diagonalElements[j]));
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.diagonalElements[j]));
          ans.diagonalElements[j + 1] = scalar.multiply(a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]));
          ans.diagonalElements[j + 2] = scalar.multiply(a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]));
          ans.diagonalElements[j + 3] = scalar.multiply(a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]));
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = aMat**T * bMat
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> tran_multiply(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
    if (a.getRowSize() != b.getRowSize() || a.getDenseOrDiagonal() != b.getDenseOrDiagonal()) {
      Tools.error("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getColumnSize(), b.getColumnSize(), a.getDenseOrDiagonal(), unit);

    switch (ans.getDenseOrDiagonal()) {
      case DENSE:
        BLAS.dgemm(
            "Transpose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), unit.create(1), a.denseElements, a.getColumnSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
          ans.diagonalElements[j + 1] = a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]);
          ans.diagonalElements[j + 2] = a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]);
          ans.diagonalElements[j + 3] = a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]);
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> tran_multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = tran_multiply(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> tran_multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = tran_multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = aMat * bMat**T
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply_tran(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getColumnSize() != b.getColumnSize() || a.getDenseOrDiagonal() != b.getDenseOrDiagonal()) {
      Tools.error("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), b.getRowSize(), a.getDenseOrDiagonal(), unit);

    switch (ans.getDenseOrDiagonal()) {
      case DENSE:
        // The Point is the first argument is "NoTranspose".
        BLAS.dgemm(
            "NoTranspose", "Transpose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.denseElements, b.getColumnSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.diagonalElements[j]));
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.diagonalElements[j]));
          ans.diagonalElements[j + 1] = scalar.multiply(a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]));
          ans.diagonalElements[j + 2] = scalar.multiply(a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]));
          ans.diagonalElements[j + 3] = scalar.multiply(a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]));
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = aMat * bMat**T
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply_tran(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
    if (a.getColumnSize() != b.getColumnSize()) {
      Tools.error("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), b.getRowSize(), a.getDenseOrDiagonal(), unit);

    switch (ans.getDenseOrDiagonal()) {
      case DENSE:
        // The Point is the first argument is "NoTranspose".
        BLAS.dgemm(
            "NoTranspose", "Transpose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), unit.create(1), a.denseElements, a.getRowSize(), b.denseElements, b.getColumnSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
          ans.diagonalElements[j + 1] = a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]);
          ans.diagonalElements[j + 2] = a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]);
          ans.diagonalElements[j + 3] = a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]);
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply_tran(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply_tran(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply_tran(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    RS scalar = null;
    BlockDenseMatrix<RS,RM,CS,CM> ans = multiply_tran(a, b, scalar);
    return ans;
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param b b
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> plus(Vector<RS,RM,CS,CM> a, Vector<RS,RM,CS,CM> b, RS scalar) {
    if (a.getDimension() != b.getDimension()) {
      throw new RuntimeException("plus :: different matrix size"); //$NON-NLS-1$
    }

    Vector<RS,RM,CS,CM> ans = a.createClone();
    BLAS.daxpy(ans.getDimension(), scalar, b.getElements(), 1, ans.getElements(), 1);
    return ans;
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param b b
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> plus(Vector<RS,RM,CS,CM> a, Vector<RS,RM,CS,CM> b) {
    if (a.getDimension() != b.getDimension()) {
      throw new RuntimeException("plus :: different matrix size"); //$NON-NLS-1$
    }

    Vector<RS,RM,CS,CM> ans = a.createClone();
    BLAS.dxpy(ans.getDimension(), b.getElements(), 1, ans.getElements(), 1);
    return ans;
  }

  /**
   * ans = a - b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param b b
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> minus(Vector<RS,RM,CS,CM> a, Vector<RS,RM,CS,CM> b) {
    if (a.getDimension() != b.getDimension()) {
      throw new RuntimeException("minus :: different matrix size"); //$NON-NLS-1$
    }

    Vector<RS,RM,CS,CM> ans = a.createClone();
    BLAS.dxmy(ans.getDimension(), b.getElements(), 1, ans.getElements(), 1);
    return ans;
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize() || a.getDenseOrDiagonal() != b.getDenseOrDiagonal()) {
      throw new RuntimeException("plus :: different matrix size"); //$NON-NLS-1$
    }

    DenseMatrix<RS,RM,CS,CM> ans = a.createClone();

    switch (a.getDenseOrDiagonal()) {
      case DENSE:
        int length = a.getRowSize() * a.getColumnSize();
        BLAS.daxpy(length, scalar, b.denseElements, 1, ans.denseElements, 1);
        return ans;
      case DIAGONAL:
        BLAS.daxpy(ans.getColumnSize(), scalar, b.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize() || a.getDenseOrDiagonal() != b.getDenseOrDiagonal()) {
      throw new RuntimeException("plus :: different matrix size"); //$NON-NLS-1$
    }

    final DenseMatrix<RS,RM,CS,CM> ans;

    switch (a.getDenseOrDiagonal()) {
      case DENSE:
        int length = a.getRowSize() * a.getColumnSize();
        ans = a.createClone();
        BLAS.dxpy(length, b.denseElements, 1, ans.denseElements, 1);
        return ans;
      case DIAGONAL:
        ans = a.createClone();
        BLAS.dxpy(ans.getColumnSize(), b.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a - b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> minus(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize() || a.getDenseOrDiagonal() != b.getDenseOrDiagonal()) {
      throw new RuntimeException("minus :: different matrix size"); //$NON-NLS-1$
    }

    final DenseMatrix<RS,RM,CS,CM> ans;

    switch (a.getDenseOrDiagonal()) {
      case DENSE:
        int length = a.getRowSize() * a.getColumnSize();
        ans = a.createClone();
        BLAS.dxmy(length, b.denseElements, 1, ans.denseElements, 1);
        return ans;
      case DIAGONAL:
        ans = a.createClone();
        BLAS.dxmy(ans.getColumnSize(), b.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize()) {
      throw new RuntimeException("plus :: different matrix size"); //$NON-NLS-1$
    }

    // ret = (*scalar) * b
    DenseMatrix<RS,RM,CS,CM> ans = multiply(b, scalar);

    // ret += a

    switch (a.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        if (ans.isDense() == false || b.isDense() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }

        int shou = a.nonZeroCount / 4;
        int amari = a.nonZeroCount % 4;
        for (int index = 0; index < amari; ++index) {
          int i = a.rowIndex[index];
          int j = a.columnIndex[index];
          RS value = a.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].add(value);
            ans.denseElements[ji] = ans.denseElements[ji].add(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].add(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = a.rowIndex[index];
          int j1 = a.columnIndex[index];
          RS value1 = a.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].add(value1);
            ans.denseElements[ji] = ans.denseElements[ji].add(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].add(value1);
          }
          int i2 = a.rowIndex[index + 1];
          int j2 = a.columnIndex[index + 1];
          RS value2 = a.getSparseElement(index + 1);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].add(value2);
            ans.denseElements[ji] = ans.denseElements[ji].add(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].add(value2);
          }
          int i3 = a.rowIndex[index + 2];
          int j3 = a.columnIndex[index + 2];
          RS value3 = a.getSparseElement(index + 2);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].add(value3);
            ans.denseElements[ji] = ans.denseElements[ji].add(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].add(value3);
          }
          int i4 = a.rowIndex[index + 3];
          int j4 = a.columnIndex[index + 3];
          RS value4 = a.getSparseElement(index + 3);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].add(value4);
            ans.denseElements[ji] = ans.denseElements[ji].add(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].add(value4);
          }
        }
        return ans;
      case DENSE:
        if (ans.isDense() == false || b.isDense() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }
        int length = ans.getRowSize() * ans.getColumnSize();
        BLAS.dxpy(length, a.denseElements, 1, ans.denseElements, 1);
        return ans;
      case DIAGONAL:
        if (ans.isDiagonal() == false || b.isDiagonal() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }
        BLAS.dxpy(ans.getColumnSize(), a.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize()) {
      throw new RuntimeException("plus :: different matrix size"); //$NON-NLS-1$
    }

    DenseMatrix<RS,RM,CS,CM> ans = b.createClone();

    switch (a.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        if (b.isDense() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }

        int shou = a.nonZeroCount / 4;
        int amari = a.nonZeroCount % 4;
        for (int index = 0; index < amari; ++index) {
          int i = a.rowIndex[index];
          int j = a.columnIndex[index];
          RS value = a.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].add(value);
            ans.denseElements[ji] = ans.denseElements[ji].add(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].add(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = a.rowIndex[index];
          int j1 = a.columnIndex[index];
          RS value1 = a.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].add(value1);
            ans.denseElements[ji] = ans.denseElements[ji].add(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].add(value1);
          }
          int i2 = a.rowIndex[index + 1];
          int j2 = a.columnIndex[index + 1];
          RS value2 = a.getSparseElement(index + 1);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].add(value2);
            ans.denseElements[ji] = ans.denseElements[ji].add(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].add(value2);
          }
          int i3 = a.rowIndex[index + 2];
          int j3 = a.columnIndex[index + 2];
          RS value3 = a.getSparseElement(index + 2);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].add(value3);
            ans.denseElements[ji] = ans.denseElements[ji].add(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].add(value3);
          }
          int i4 = a.rowIndex[index + 3];
          int j4 = a.columnIndex[index + 3];
          RS value4 = a.getSparseElement(index + 3);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].add(value4);
            ans.denseElements[ji] = ans.denseElements[ji].add(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].add(value4);
          }
        }
        return ans;
      case DENSE:
        if (b.isDense() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }
        int length = ans.getRowSize() * ans.getColumnSize();
        BLAS.dxpy(length, a.denseElements, 1, ans.denseElements, 1);
        return ans;
      case DIAGONAL:
        if (b.isDiagonal() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }
        BLAS.dxpy(ans.getColumnSize(), a.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a - b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> minus(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize()) {
      throw new RuntimeException("minus :: different matrix size"); //$NON-NLS-1$
    }

    DenseMatrix<RS,RM,CS,CM> ans = b.createClone();

    switch (a.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        if (b.isDense() == false) {
          throw new RuntimeException("minus :: different matrix type"); //$NON-NLS-1$
        }

        int shou = a.nonZeroCount / 4;
        int amari = a.nonZeroCount % 4;
        for (int index = 0; index < amari; ++index) {
          int i = a.rowIndex[index];
          int j = a.columnIndex[index];
          RS value = a.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = a.rowIndex[index];
          int j1 = a.columnIndex[index];
          RS value1 = a.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value1);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value1);
          }
          int i2 = a.rowIndex[index + 1];
          int j2 = a.columnIndex[index + 1];
          RS value2 = a.getSparseElement(index + 1);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value2);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value2);
          }
          int i3 = a.rowIndex[index + 2];
          int j3 = a.columnIndex[index + 2];
          RS value3 = a.getSparseElement(index + 2);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value3);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value3);
          }
          int i4 = a.rowIndex[index + 3];
          int j4 = a.columnIndex[index + 3];
          RS value4 = a.getSparseElement(index + 3);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value4);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value4);
          }
        }
        return ans;
      case DENSE:
        if (b.isDense() == false) {
          throw new RuntimeException("minus :: different matrix type"); //$NON-NLS-1$
        }
        int length = ans.getRowSize() * ans.getColumnSize();
        BLAS.dxmy(length, a.denseElements, 1, ans.denseElements, 1);
        return ans;
      case DIAGONAL:
        if (b.isDiagonal() == false) {
          throw new RuntimeException("minus :: different matrix type"); //$NON-NLS-1$
        }
        BLAS.dxmy(ans.getColumnSize(), a.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(DenseMatrix<RS,RM,CS,CM> a, SparseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize()) {
      throw new RuntimeException("plus :: different matrix size"); //$NON-NLS-1$
    }

    // ret = a
    DenseMatrix<RS,RM,CS,CM> ans = a.createClone();

    //ret += (*scalar) * b

    switch (b.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        if (ans.isDense() == false || a.isDense() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }
        int shou = b.nonZeroCount / 4;
        int amari = b.nonZeroCount % 4;
        for (int index = 0; index < amari; ++index) {
          int i = b.rowIndex[index];
          int j = b.columnIndex[index];
          RS value = b.getSparseElement(index).multiply(scalar);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].add(value);
            ans.denseElements[ji] = ans.denseElements[ji].add(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].add(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = b.rowIndex[index];
          int j1 = b.columnIndex[index];
          RS value1 = b.getSparseElement(index).multiply(scalar);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].add(value1);
            ans.denseElements[ji] = ans.denseElements[ji].add(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].add(value1);
          }
          int i2 = b.rowIndex[index + 1];
          int j2 = b.columnIndex[index + 1];
          RS value2 = b.getSparseElement(index + 1).multiply(scalar);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].add(value2);
            ans.denseElements[ji] = ans.denseElements[ji].add(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].add(value2);
          }
          int i3 = b.rowIndex[index + 2];
          int j3 = b.columnIndex[index + 2];
          RS value3 = b.getSparseElement(index + 2).multiply(scalar);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].add(value3);
            ans.denseElements[ji] = ans.denseElements[ji].add(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].add(value3);
          }
          int i4 = b.rowIndex[index + 3];
          int j4 = b.columnIndex[index + 3];
          RS value4 = b.getSparseElement(index + 3).multiply(scalar);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].add(value4);
            ans.denseElements[ji] = ans.denseElements[ji].add(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].add(value4);
          }
        }
        return ans;
      case DENSE:
        if (ans.isDense() == false || a.isDense() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }
        int length = ans.getRowSize() * ans.getColumnSize();
        BLAS.daxpy(length, scalar, b.denseElements, 1, ans.denseElements, 1);
        return ans;
      case DIAGONAL:
        if (ans.isDiagonal() == false || a.isDiagonal() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }
        BLAS.daxpy(ans.getColumnSize(), scalar, b.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(DenseMatrix<RS,RM,CS,CM> a, SparseMatrix<RS,RM,CS,CM> b) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize()) {
      throw new RuntimeException("plus :: different matrix size"); //$NON-NLS-1$
    }

    // ans = a
    DenseMatrix<RS,RM,CS,CM> ans = a.createClone();

    // ans += (*scalar) * b

    switch (b.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        int shou = b.nonZeroCount / 4;
        int amari = b.nonZeroCount % 4;
        for (int index = 0; index < amari; ++index) {
          int i = b.rowIndex[index];
          int j = b.columnIndex[index];
          RS value = b.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].add(value);
            ans.denseElements[ji] = ans.denseElements[ji].add(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].add(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = b.rowIndex[index];
          int j1 = b.columnIndex[index];
          RS value1 = b.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].add(value1);
            ans.denseElements[ji] = ans.denseElements[ji].add(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].add(value1);
          }
          int i2 = b.rowIndex[index + 1];
          int j2 = b.columnIndex[index + 1];
          RS value2 = b.getSparseElement(index + 1);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].add(value2);
            ans.denseElements[ji] = ans.denseElements[ji].add(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].add(value2);
          }
          int i3 = b.rowIndex[index + 2];
          int j3 = b.columnIndex[index + 2];
          RS value3 = b.getSparseElement(index + 2);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].add(value3);
            ans.denseElements[ji] = ans.denseElements[ji].add(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].add(value3);
          }
          int i4 = b.rowIndex[index + 3];
          int j4 = b.columnIndex[index + 3];
          RS value4 = b.getSparseElement(index + 3);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].add(value4);
            ans.denseElements[ji] = ans.denseElements[ji].add(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].add(value4);
          }
        }
        return ans;
      case DENSE:
        int length = ans.getRowSize() * ans.getColumnSize();
        BLAS.dxpy(length, b.denseElements, 1, ans.denseElements, 1);
        return ans;
      case DIAGONAL:
        BLAS.dxpy(ans.getColumnSize(), b.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a - b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> minus(DenseMatrix<RS,RM,CS,CM> a, SparseMatrix<RS,RM,CS,CM> b) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize()) {
      throw new RuntimeException("minus :: different matrix size"); //$NON-NLS-1$
    }

    DenseMatrix<RS,RM,CS,CM> ans = a.createClone();

    switch (b.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        int shou = b.nonZeroCount / 4;
        int amari = b.nonZeroCount % 4;
        for (int index = 0; index < amari; ++index) {
          int i = b.rowIndex[index];
          int j = b.columnIndex[index];
          RS value = b.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = b.rowIndex[index];
          int j1 = b.columnIndex[index];
          RS value1 = b.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value1);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value1);
          }
          int i2 = b.rowIndex[index + 1];
          int j2 = b.columnIndex[index + 1];
          RS value2 = b.getSparseElement(index + 1);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value2);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value2);
          }
          int i3 = b.rowIndex[index + 2];
          int j3 = b.columnIndex[index + 2];
          RS value3 = b.getSparseElement(index + 2);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value3);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value3);
          }
          int i4 = b.rowIndex[index + 3];
          int j4 = b.columnIndex[index + 3];
          RS value4 = b.getSparseElement(index + 3);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value4);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value4);
          }
        }
        return ans;
      case DENSE:
        int length = ans.getRowSize() * ans.getColumnSize();
        BLAS.dxmy(length, b.denseElements, 1, ans.denseElements, 1);
        return ans;
      case DIAGONAL:
        BLAS.dxmy(ans.getColumnSize(), b.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param b b
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockVector<RS,RM,CS,CM> plus(BlockVector<RS,RM,CS,CM> a, BlockVector<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    RS unit = a.getElementUnit();
    BlockVector<RS,RM,CS,CM> ans = new BlockVector<>(a.getBlockSize(), a.getBlockStructs(), unit);

    for (int i = 0; i < a.getBlockSize(); ++i) {
      Vector<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param b b
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockVector<RS,RM,CS,CM> plus(BlockVector<RS,RM,CS,CM> a, BlockVector<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    RS unit = a.getElementUnit();
    BlockVector<RS,RM,CS,CM> ans = new BlockVector<>(a.getBlockSize(), a.getBlockStructs(), unit);

    for (int i = 0; i < a.getBlockSize(); ++i) {
      Vector<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());
    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a - b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> minus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("minus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());
    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = minus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(b.getBlockSize(), b.getBlockStructs(), b.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(b.getBlockSize(), b.getBlockStructs(), b.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a - b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> minus(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("minus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(b.getBlockSize(), b.getBlockStructs(), b.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = minus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans + a * b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockSparseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockSparseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a - b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> minus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockSparseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("minus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = minus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a '*' (*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param operator 演算子
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> let(Vector<RS,RM,CS,CM> a, final char operator, RS scalar) {
    switch (operator) {
      case '*':
        Vector<RS,RM,CS,CM> ans = multiply(a, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '*' (*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param operator 演算子
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockVector<RS,RM,CS,CM> let(BlockVector<RS,RM,CS,CM> a, final char operator, RS scalar) {
    switch (operator) {
      case '*':
        BlockVector<RS,RM,CS,CM> ans = multiply(a, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '*' (*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, RS scalar) {
    switch (operator) {
      case '*':
        BlockDenseMatrix<RS,RM,CS,CM> ans = multiply(a, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param operator 演算子
   * @param b b
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> let(Vector<RS,RM,CS,CM> a, final char operator, Vector<RS,RM,CS,CM> b, RS scalar) {
    Vector<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param operator 演算子
   * @param b b
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> let(Vector<RS,RM,CS,CM> a, final char operator, Vector<RS,RM,CS,CM> b) {
    Vector<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' 't' 'T' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(DenseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
      case 't':
        // ret = aMat**T * bMat
        ans = tran_multiply(a, b, scalar);
        return ans;
      case 'T':
        // ret = aMat * bMat**T
        ans = multiply_tran(a, b, scalar);
        return ans;
      default:
        throw new IllegalArgumentException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' 't' 'T' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(DenseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b) {
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b);
        return ans;
      case 't':
        // ret = aMat**T * bMat
        ans = tran_multiply(a, b);
        return ans;
      case 'T':
        // ret = aMat * bMat**T
        ans = multiply_tran(a, b);
        return ans;
      default:
        throw new IllegalArgumentException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(SparseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(SparseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b) {
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(DenseMatrix<RS,RM,CS,CM> a, final char operator, SparseMatrix<RS,RM,CS,CM> b, RS scalar) {
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(DenseMatrix<RS,RM,CS,CM> a, final char operator, SparseMatrix<RS,RM,CS,CM> b) {
    DenseMatrix<RS,RM,CS,CM> ans;

    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' 't' 'T' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    BlockDenseMatrix<RS,RM,CS,CM> ans;

    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
      case 't':
        // ret = aMat**T * bMat
        ans = tran_multiply(a, b, scalar);
        return ans;
      case 'T':
        // ret = aMat * bMat**T
        ans = multiply_tran(a, b, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' 't' 'T' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b) {
    BlockDenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b);
        return ans;
      case 't':
        // ret = aMat**T * bMat
        ans = tran_multiply(a, b);
        return ans;
      case 'T':
        // ret = aMat * bMat**T
        ans = multiply_tran(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockSparseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    BlockDenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockSparseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b) {
    BlockDenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockSparseMatrix<RS,RM,CS,CM> b, RS scalar) {
    BlockDenseMatrix<RS,RM,CS,CM> ans;

    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockSparseMatrix<RS,RM,CS,CM> b) {
    BlockDenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = aMat '*' '/' bVec
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b b
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> let(DenseMatrix<RS,RM,CS,CM> a, final char operator, Vector<RS,RM,CS,CM> b) {
    Vector<RS,RM,CS,CM> ans;
    switch (operator) {
      case '*':
        ans = multiply(a, b);
        return ans;
      case '/':
        // ret = aMat^{-1} * bVec;
        // aMat is positive definite and already cholesky factorized.
        ans = solveSystems(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param operator 演算子
   * @param b b
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(Vector<RS,RM,CS,CM> a, final char operator, Vector<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(DenseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(DenseMatrix<RS,RM,CS,CM> a, final char operator, SparseMatrix<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(b, a);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(SparseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param operator 演算子
   * @param b b
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(BlockVector<RS,RM,CS,CM> a, final char operator, BlockVector<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(BlockSparseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockSparseMatrix<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(b, a);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }
}
File Line
org/mklab/sdpj/algebra/Algebra.java 149
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 192
    for (int i = 0; i < a.getBlockSize(); ++i) {
      ret = ret.add(getInnerProduct(a.getBlock(i), b.getBlock(i)));
    }
    return ret;
  }

  /**
   * 内積の計算を行います。 AI.getInnerProduct(ret,aVec,bVec)をAI.ret=getInnerProduct(aVec,bVec)に変更。
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return aMat bMatの内積
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getInnerProduct(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize()) {
      throw new RuntimeException("getInnerProduct:: different memory size"); //$NON-NLS-1$
    }

    switch (a.getDenseOrDiagonal()) {
      case DENSE:
        int length = a.getRowSize() * a.getColumnSize();
        return BLAS.<RS,RM,CS,CM> ddot(length, a.denseElements, 1, b.denseElements, 1);
      case DIAGONAL:
        return BLAS.ddot(a.getColumnSize(), a.diagonalElements, 1, b.diagonalElements, 1);
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * 内積の計算を行います。 Al.getInnerProduct(ret,aVec,bVec)をret=Al.getInnerProduct(aVec,bVec)に変更。
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 内積
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getInnerProduct(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
    if (a.getRowSize() != b.getRowSize() || a.getColumnSize() != b.getColumnSize()) {
      throw new RuntimeException("getInnerProduct:: different memory size"); //$NON-NLS-1$
    }

    final RS unit = b.getElementUnit();
    int index = 0;
    int counter = 0;
    RS ans;

    switch (a.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        // Attension: in SPARSE case, only half elements
        // are stored. And bMat must be DENSE case.
        ans = unit.create(0);
        int amari = a.nonZeroCount % 4;
        int shou = a.nonZeroCount / 4;
        for (index = 0; index < amari; ++index) {
          int i = a.rowIndex[index];
          int j = a.columnIndex[index];
          RS value = a.getSparseElement(index);
          if (i == j) {
            ans = ans.add(value.multiply(b.denseElements[i + b.getRowSize() * j]));
          } else {
            ans = ans.add(value.multiply((b.denseElements[i + b.getRowSize() * j].add(b.denseElements[j + b.getRowSize() * i]))));
          }
        }

        index = amari;
        counter = 0;
        for (counter = 0; counter < shou; ++counter) {
          int i1 = a.rowIndex[index];
          int j1 = a.columnIndex[index];
          RS value1 = a.getSparseElement(index);
          RS ans1;
          if (i1 == j1) {
            ans1 = value1.multiply(b.denseElements[i1 + b.getRowSize() * j1]);
          } else {
            ans1 = value1.multiply((b.denseElements[i1 + b.getRowSize() * j1].add(b.denseElements[j1 + b.getRowSize() * i1])));
          }

          int i2 = a.rowIndex[index + 1];
          int j2 = a.columnIndex[index + 1];
          RS value2 = a.getSparseElement(index + 1);
          RS ans2;
          if (i2 == j2) {
            ans2 = value2.multiply(b.denseElements[i2 + b.getRowSize() * j2]);
          } else {
            ans2 = value2.multiply((b.denseElements[i2 + b.getRowSize() * j2].add(b.denseElements[j2 + b.getRowSize() * i2])));

          }

          int i3 = a.rowIndex[index + 2];
          int j3 = a.columnIndex[index + 2];
          RS value3 = a.getSparseElement(index + 2);
          RS ans3;
          if (i3 == j3) {
            ans3 = value3.multiply(b.denseElements[i3 + b.getRowSize() * j3]);
          } else {
            ans3 = value3.multiply((b.denseElements[i3 + b.getRowSize() * j3].add(b.denseElements[j3 + b.getRowSize() * i3])));
          }

          int i4 = a.rowIndex[index + 3];
          int j4 = a.columnIndex[index + 3];
          RS value4 = a.getSparseElement(index + 3);
          RS ans4;
          if (i4 == j4) {
            ans4 = value4.multiply(b.denseElements[i4 + b.getRowSize() * j4]);
          } else {
            ans4 = value4.multiply((b.denseElements[i4 + b.getRowSize() * j4].add(b.denseElements[j4 + b.getRowSize() * i4])));
          }

          index += 4;
          ans = ans.add(ans1.add(ans2).add(ans3).add(ans4));
          //20090120修正したけど 不具合でたらここもチェックで。
        }
        return ans;
      case DENSE:
        int length = a.getRowSize() * a.getColumnSize();
        return BLAS.ddot(length, a.denseElements, 1, b.denseElements, 1);
      case DIAGONAL:
        return BLAS.ddot(a.getColumnSize(), a.diagonalElements, 1, b.diagonalElements, 1);
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * 内積の計算を行います Al.getInnerProduct(ret,aVec,bVec)をret=Al.getInnerProduct(aVec,bVec)に変更。
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 内積
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getInnerProduct(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("getInnerProduct:: different memory size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    RS ans = unit.create(0);
File Line
org/mklab/sdpj/algebra/Algebra.java 1898
org/mklab/sdpj/algebra/Algebra.java 2010
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2032
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2144
        if (ans.isDense() == false || b.isDense() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }

        int shou = a.nonZeroCount / 4;
        int amari = a.nonZeroCount % 4;
        for (int index = 0; index < amari; ++index) {
          int i = a.rowIndex[index];
          int j = a.columnIndex[index];
          RS value = a.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].add(value);
            ans.denseElements[ji] = ans.denseElements[ji].add(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].add(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = a.rowIndex[index];
          int j1 = a.columnIndex[index];
          RS value1 = a.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].add(value1);
            ans.denseElements[ji] = ans.denseElements[ji].add(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].add(value1);
          }
          int i2 = a.rowIndex[index + 1];
          int j2 = a.columnIndex[index + 1];
          RS value2 = a.getSparseElement(index + 1);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].add(value2);
            ans.denseElements[ji] = ans.denseElements[ji].add(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].add(value2);
          }
          int i3 = a.rowIndex[index + 2];
          int j3 = a.columnIndex[index + 2];
          RS value3 = a.getSparseElement(index + 2);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].add(value3);
            ans.denseElements[ji] = ans.denseElements[ji].add(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].add(value3);
          }
          int i4 = a.rowIndex[index + 3];
          int j4 = a.columnIndex[index + 3];
          RS value4 = a.getSparseElement(index + 3);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].add(value4);
            ans.denseElements[ji] = ans.denseElements[ji].add(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].add(value4);
          }
        }
        return ans;
      case DENSE:
        if (ans.isDense() == false || b.isDense() == false) {
File Line
org/mklab/sdpj/algebra/Algebra.java 27
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 37
public class Algebra<RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> {

  /**
   * 最小固有値の計算を行います aMat is rewritten. aMat must be symmetric. eigenVec is the space of eigen values and needs memory of length aMat.nRow workVec is temporary space and needs 3*aMat.nRow-1 length
   * memory.
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param eigenValues 固有値
   * @param workVec 作業領域
   * @return 最小固有値
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getMinEigenValue(DenseMatrix<RS,RM,CS,CM> a, Vector<RS,RM,CS,CM> eigenValues, Vector<RS,RM,CS,CM> workVec) {
    final RS unit = a.getElementUnit();

    int n = a.getRowSize();

    switch (a.getDenseOrDiagonal()) {
      case DENSE:
        int lwork = 3 * n - 1;
        // "N" means that we need not eigen vectors
        // "L" means that we refer only lower triangular.
        int info = Clapack.dsyev("NonVectors", "Lower", n, a.denseElements, n, eigenValues.getElements(), workVec.getElements(), lwork); //$NON-NLS-1$ //$NON-NLS-2$
        if (info != 0) {
          return unit.createZero();
        }
        return eigenValues.getElements()[0];
      case DIAGONAL:
        RS minimumEigenValue = a.diagonalElements[0];
        eigenValues.getElements()[0] = a.diagonalElements[0];
        for (int i = 1; i < n; ++i) {
          eigenValues.getElements()[i] = a.diagonalElements[i];
          if (a.diagonalElements[i].isLessThan(minimumEigenValue)) {
            minimumEigenValue = a.diagonalElements[i];
          }
        }
        return minimumEigenValue;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * 最小固有値の計算を行います。
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param eigenVec 固有ベクトル
   * @param workVec 作業領域
   * @return 最小固有値
   */
  static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getMinEigenValue(BlockDenseMatrix<RS,RM,CS,CM> a, BlockVector<RS,RM,CS,CM> eigenVec, BlockVector<RS,RM,CS,CM> workVec) {
    int n = a.getBlock(0).getRowSize();
    if (eigenVec.getBlock(0).getDimension() != n) {
      throw new RuntimeException("getMinEigenValue:: different memory size"); //$NON-NLS-1$
    }
    if (workVec.getBlock(0).getDimension() != 3 * n - 1) {
      throw new RuntimeException("getMinEigenValue:: different memory size"); //$NON-NLS-1$
    }
    RS min_eigen = getMinEigenValue(a.getBlock(0), eigenVec.getBlock(0), workVec.getBlock(0));

    for (int l = 1; l < a.getBlockSize(); ++l) {
      n = a.getBlock(l).getRowSize();
      if (eigenVec.getBlock(l).getDimension() != n) {
        throw new RuntimeException("getMinEigenValue:: different memory size"); //$NON-NLS-1$
      }
      if (workVec.getBlock(l).getDimension() != 3 * n - 1) {
        throw new RuntimeException("getMinEigenValue:: different memory size"); //$NON-NLS-1$
      }
      RS tmp_eigen = getMinEigenValue(a.getBlock(l), eigenVec.getBlock(l), workVec.getBlock(l));
      if (tmp_eigen.isLessThan(min_eigen)) {
        min_eigen = tmp_eigen;
      }
    }
    return min_eigen;
  }

  /**
   * 内積の計算を行います。
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param b b
   * @return aVecとbVecの内積
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getInnerProduct(Vector<RS,RM,CS,CM> a, Vector<RS,RM,CS,CM> b) {
    int size = a.getDimension();
    if (size != b.getDimension()) {
      throw new RuntimeException("getInnerProduct:: different memory size"); //$NON-NLS-1$
    }
File Line
org/mklab/sdpj/algebra/Algebra.java 764
org/mklab/sdpj/algebra/Algebra.java 849
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 898
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 983
          RS value = a.getSparseElement(index).multiply(scalar);
          if (i != j) {
            RS[] bMat_j = unit.createArray(b.denseElements.length - j);
            System.arraycopy(b.denseElements, j, bMat_j, 0, bMat_j.length);
            RS[] retMat_i = unit.createArray(ans.denseElements.length - i);
            System.arraycopy(ans.denseElements, i, retMat_i, 0, retMat_i.length);
            BLAS.daxpy(b.getColumnSize(), value, bMat_j, b.getRowSize(), retMat_i, ans.getRowSize());
            System.arraycopy(retMat_i, 0, ans.denseElements, i, retMat_i.length);

            RS[] bMat_i = unit.createArray(b.denseElements.length - i);
            System.arraycopy(b.denseElements, i, bMat_i, 0, bMat_i.length);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - j);
            System.arraycopy(ans.denseElements, j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, bMat_i, b.getRowSize(), retMat_j, ans.getRowSize());
            System.arraycopy(retMat_j, 0, ans.denseElements, j, retMat_j.length);
          } else {
            RS[] bMat_j = unit.createArray(b.denseElements.length - j);
            System.arraycopy(b.denseElements, j, bMat_j, 0, bMat_j.length);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - j);
            System.arraycopy(ans.denseElements, j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, bMat_j, b.getRowSize(), retMat_j, ans.getRowSize());
            System.arraycopy(retMat_j, 0, ans.denseElements, j, retMat_j.length);
          }
        }
        return ans;
      case DENSE:
        if (ans.isDense() == false || b.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }
        BLAS.dgemm(
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
File Line
org/mklab/sdpj/gpack/blaswrap/Dtrmm.java 16
org/mklab/sdpj/gpack/blaswrap/Dtrsm.java 17
public class Dtrmm<RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> {

  /*  Purpose   
  =======   
  DTRMM  performs one of the matrix-matrix operations   
     B := alpha*op( A )*B,   or   B := alpha*B*op( A ),   
  where  alpha  is a scalar,  B  is an m by n matrix,  A  is a unit, or   
  non-unit,  upper or lower triangular matrix  and  op( A )  is one  of   
     op( A ) = A   or   op( A ) = A'.   
  Parameters   
  ==========   
  SIDE   - CHARACTER*1.   
           On entry,  SIDE specifies whether  op( A ) multiplies B from   
           the left or right as follows:   
              SIDE = 'L' or 'l'   B := alpha*op( A )*B.   
              SIDE = 'R' or 'r'   B := alpha*B*op( A ).   
           Unchanged on exit.   
  UPLO   - CHARACTER*1.   
           On entry, UPLO specifies whether the matrix A is an upper or   
           lower triangular matrix as follows:   
              UPLO = 'U' or 'u'   A is an upper triangular matrix.   
              UPLO = 'L' or 'l'   A is a lower triangular matrix.   
           Unchanged on exit.   
  TRANSA - CHARACTER*1.   
           On entry, TRANSA specifies the form of op( A ) to be used in   
           the matrix multiplication as follows:   
              TRANSA = 'N' or 'n'   op( A ) = A.   
              TRANSA = 'T' or 't'   op( A ) = A'.   
              TRANSA = 'C' or 'c'   op( A ) = A'.   
           Unchanged on exit.   
  DIAG   - CHARACTER*1.   
           On entry, DIAG specifies whether or not A is unit triangular   
           as follows:   
              DIAG = 'U' or 'u'   A is assumed to be unit triangular.   
              DIAG = 'N' or 'n'   A is not assumed to be unit   
                                  triangular.   
           Unchanged on exit.   
  M      - INTEGER.   
           On entry, M specifies the number of rows of B. M must be at   
           least zero.   
           Unchanged on exit.   
  N      - INTEGER.   
           On entry, N specifies the number of columns of B.  N must be   
           at least zero.   
           Unchanged on exit.   
  ALPHA  - DOUBLE PRECISION.   
           On entry,  ALPHA specifies the scalar  alpha. When  alpha is   
           zero then  A is not referenced and  B need not be set before   
           entry.   
           Unchanged on exit.   
  A      - DOUBLE PRECISION array of DIMENSION ( LDA, k ), where k is m   
           when  SIDE = 'L' or 'l'  and is  n  when  SIDE = 'R' or 'r'.   
           Before entry  with  UPLO = 'U' or 'u',  the  leading  k by k   
           upper triangular part of the array  A must contain the upper   
           triangular matrix  and the strictly lower triangular part of   
           A is not referenced.   
           Before entry  with  UPLO = 'L' or 'l',  the  leading  k by k   
           lower triangular part of the array  A must contain the lower   
           triangular matrix  and the strictly upper triangular part of   
           A is not referenced.   
           Note that when  DIAG = 'U' or 'u',  the diagonal elements of   
           A  are not referenced either,  but are assumed to be  unity.   
           Unchanged on exit.   
  LDA    - INTEGER.   
           On entry, LDA specifies the first dimension of A as declared   
           in the calling (sub) program.  When  SIDE = 'L' or 'l'  then   
           LDA  must be at least  max( 1, m ),  when  SIDE = 'R' or 'r'   
           then LDA must be at least max( 1, n ).   
           Unchanged on exit.   
  B      - DOUBLE PRECISION array of DIMENSION ( LDB, n ).   
           Before entry,  the leading  m by n part of the array  B must   
           contain the matrix  B,  and  on exit  is overwritten  by the   
           transformed matrix.   
  LDB    - INTEGER.   
           On entry, LDB specifies the first dimension of B as declared   
           in  the  calling  (sub)  program.   LDB  must  be  at  least   
           max( 1, m ).   
           Unchanged on exit.   
  Level 3 Blas routine.   
  -- Written on 8-February-1989.   
     Jack Dongarra, Argonne National Laboratory.   
     Iain Duff, AERE Harwell.   
     Jeremy Du Croz, Numerical Algorithms Group Ltd.   
     Sven Hammarling, Numerical Algorithms Group Ltd.   
     Test the input parameters.   
     Parameter adjustments */

  /**
   * @param side side
   * @param uplo uplo
   * @param transa transa
   * @param diag diag
   * @param m m
   * @param n n
   * @param alpha alpha
   * @param a a
   * @param lda lda
   * @param b b
   * @param ldb ldb
   * @return result
   */
  public int execute(String side, String uplo, String transa, String diag, int m, int n, RS alpha, RS[] a, int lda, RS[] b, int ldb) {
    final RS unit = a[0].createUnit();

    int a_dim1 = lda;
    int a_offset = 1 + a_dim1 * 1;
    int pointer_a = -a_offset;

    int b_dim1 = ldb;
    int b_offset = 1 + b_dim1 * 1;
    int pointer_b = -b_offset;

    boolean lside = BLAS.lsame(side, "L"); //$NON-NLS-1$
    int nrowa;
    if (lside) {
      nrowa = m;
    } else {
      nrowa = n;
    }
    boolean nounit = BLAS.lsame(diag, "N"); //$NON-NLS-1$
    boolean upper = BLAS.lsame(uplo, "U"); //$NON-NLS-1$
    int info = 0;
    if (!lside && !BLAS.lsame(side, "R")) { //$NON-NLS-1$
      info = 1;
    } else if (!upper && !BLAS.lsame(uplo, "L")) { //$NON-NLS-1$
      info = 2;
    } else if (!BLAS.lsame(transa, "N") && !BLAS.lsame(transa, "T") && !BLAS.lsame(transa, "C")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      info = 3;
    } else if (!BLAS.lsame(diag, "U") && !BLAS.lsame(diag, "N")) { //$NON-NLS-1$ //$NON-NLS-2$
      info = 4;
    } else if (m < 0) {
      info = 5;
    } else if (n < 0) {
      info = 6;
    } else if (lda < Math.max(1, nrowa)) {
      info = 9;
    } else if (ldb < Math.max(1, m)) {
      info = 11;
    }
    if (info != 0) {
      BLAS.xerbla("DTRMM ", info); //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 670
org/mklab/sdpj/algebra/Algebra.java 1461
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 804
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1595
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.diagonalElements[j]));
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.diagonalElements[j]));
          ans.diagonalElements[j + 1] = scalar.multiply(a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]));
          ans.diagonalElements[j + 2] = scalar.multiply(a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]));
          ans.diagonalElements[j + 3] = scalar.multiply(a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]));
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/gpack/blaswrap/Dsyr2k.java 177
org/mklab/sdpj/gpack/blaswrap/Dsyrk.java 151
    if (n == 0 || (alpha.isZero() || k == 0) && beta.equals(unit.create(1))) {
      return 0;
    }
    // And when  alpha.eq.zero.
    if (alpha.isZero()) {
      if (upper) {
        if (beta.isZero()) {
          for (int j = 1; j <= n; ++j) {
            for (int i = 1; i <= j; ++i) {
              c[j * c_dim1 + i + pointer_c] = unit.createZero();
            }
          }
        } else {
          for (int j = 1; j <= n; ++j) {
            for (int i = 1; i <= j; ++i) {
              int p = j * c_dim1 + i + pointer_c;
              c[p] = beta.multiply(c[p]);
            }
          }
        }
      } else {
        if (beta.isZero()) {
          for (int j = 1; j <= n; ++j) {
            for (int i = j; i <= n; ++i) {
              c[j * c_dim1 + i + pointer_c] = unit.createZero();
            }
          }
        } else {
          for (int j = 1; j <= n; ++j) {
            for (int i = j; i <= n; ++i) {
              int p = j * c_dim1 + i + pointer_c;
              c[p] = beta.multiply(c[p]);
            }
          }
        }
      }
      return 0;
    }

    if (BLAS.lsame(trans, "N")) { //$NON-NLS-1$
      // Form  C := alpha*A*B' + alpha*B*A' + C.
      if (upper) {
        for (int j = 1; j <= n; ++j) {
          if (beta.isZero()) {
            for (int i = 1; i <= j; ++i) {
              c[j * c_dim1 + i + pointer_c] = unit.createZero();
            }
          } else if (!beta.equals(unit.createUnit())) {
File Line
org/mklab/sdpj/algebra/Algebra.java 670
org/mklab/sdpj/algebra/Algebra.java 1461
org/mklab/sdpj/algebra/Algebra.java 1603
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 804
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1595
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1737
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.diagonalElements[j]));
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.diagonalElements[j]));
          ans.diagonalElements[j + 1] = scalar.multiply(a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]));
          ans.diagonalElements[j + 2] = scalar.multiply(a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]));
          ans.diagonalElements[j + 3] = scalar.multiply(a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]));
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 713
org/mklab/sdpj/algebra/Algebra.java 1507
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 847
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1641
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), unit.create(1), a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
          ans.diagonalElements[j + 1] = a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]);
          ans.diagonalElements[j + 2] = a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]);
          ans.diagonalElements[j + 3] = a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]);
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * Dense=Sparse*Dense
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1507
org/mklab/sdpj/algebra/Algebra.java 1649
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1641
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1783
            "Transpose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), unit.create(1), a.denseElements, a.getColumnSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
          ans.diagonalElements[j + 1] = a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]);
          ans.diagonalElements[j + 2] = a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]);
          ans.diagonalElements[j + 3] = a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]);
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> tran_multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 713
org/mklab/sdpj/algebra/Algebra.java 1649
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 847
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1783
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), unit.create(1), a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
        }
        int count;
        int j;
        for (j = amari, count = 0; count < shou; ++count, j += 4) {
          ans.diagonalElements[j] = a.diagonalElements[j].multiply(b.diagonalElements[j]);
          ans.diagonalElements[j + 1] = a.diagonalElements[j + 1].multiply(b.diagonalElements[j + 1]);
          ans.diagonalElements[j + 2] = a.diagonalElements[j + 2].multiply(b.diagonalElements[j + 2]);
          ans.diagonalElements[j + 3] = a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]);
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * Dense=Sparse*Dense
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 356
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 368
    } else if (sname && LibF77.compare(c2, "OR", 2, 2) == 0) { //$NON-NLS-1$
      if (c3[0] == 'G') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
          nb = 32;
        }
      } else if (c3[0] == 'M') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
          nb = 32;
        }
      }
    } else if (cname && LibF77.compare(c2, "UN", 2, 2) == 0) { //$NON-NLS-1$
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 488
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 500
    } else if (sname && LibF77.compare(c2, "OR", 2, 2) == 0) { //$NON-NLS-1$
      if (c3[0] == 'G') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
          nbmin = 2;
        }
      } else if (c3[0] == 'M') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
          nbmin = 2;
        }
      }
    } else if (cname && LibF77.compare(c2, "UN", 2, 2) == 0) { //$NON-NLS-1$
File Line
org/mklab/sdpj/gpack/blaswrap/Dtrmv.java 16
org/mklab/sdpj/gpack/blaswrap/Dtrsv.java 17
public class Dtrmv<RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> {

  /*  Purpose   
  =======   
  DTRMV  performs one of the matrix-vector operations   
     x := A*x,   or   x := A'*x,   
  where x is an n element vector and  A is an n by n unit, or non-unit,   
  upper or lower triangular matrix.   
  Parameters   
  ==========   
  UPLO   - CHARACTER*1.   
           On entry, UPLO specifies whether the matrix is an upper or   
           lower triangular matrix as follows:   
              UPLO = 'U' or 'u'   A is an upper triangular matrix.   
              UPLO = 'L' or 'l'   A is a lower triangular matrix.   
           Unchanged on exit.   
  TRANS  - CHARACTER*1.   
           On entry, TRANS specifies the operation to be performed as   
           follows:   
              TRANS = 'N' or 'n'   x := A*x.   
              TRANS = 'T' or 't'   x := A'*x.   
              TRANS = 'C' or 'c'   x := A'*x.   
           Unchanged on exit.   
  DIAG   - CHARACTER*1.   
           On entry, DIAG specifies whether or not A is unit   
           triangular as follows:   
              DIAG = 'U' or 'u'   A is assumed to be unit triangular.   
              DIAG = 'N' or 'n'   A is not assumed to be unit   
                                  triangular.   
           Unchanged on exit.   
  N      - INTEGER.   
           On entry, N specifies the order of the matrix A.   
           N must be at least zero.   
           Unchanged on exit.   
  A      - DOUBLE PRECISION array of DIMENSION ( LDA, n ).   
           Before entry with  UPLO = 'U' or 'u', the leading n by n   
           upper triangular part of the array A must contain the upper   
           triangular matrix and the strictly lower triangular part of   
           A is not referenced.   
           Before entry with UPLO = 'L' or 'l', the leading n by n   
           lower triangular part of the array A must contain the lower   
           triangular matrix and the strictly upper triangular part of   
           A is not referenced.   
           Note that when  DIAG = 'U' or 'u', the diagonal elements of   
           A are not referenced either, but are assumed to be unity.   
           Unchanged on exit.   
  LDA    - INTEGER.   
           On entry, LDA specifies the first dimension of A as declared   
           in the calling (sub) program. LDA must be at least   
           max( 1, n ).   
           Unchanged on exit.   
  X      - DOUBLE PRECISION array of dimension at least   
           ( 1 + ( n - 1 )*abs( INCX ) ).   
           Before entry, the incremented array X must contain the n   
           element vector x. On exit, X is overwritten with the   
           tranformed vector x.   
  INCX   - INTEGER.   
           On entry, INCX specifies the increment for the elements of   
           X. INCX must not be zero.   
           Unchanged on exit.   
  Level 2 Blas routine.   
  -- Written on 22-October-1986.   
     Jack Dongarra, Argonne National Lab.   
     Jeremy Du Croz, Nag Central Office.   
     Sven Hammarling, Nag Central Office.   
     Richard Hanson, Sandia National Labs.   
     Test the input parameters.   
     Parameter adjustments */

  /**
   * @param uplo uplo
   * @param trans trans
   * @param diag diag
   * @param n n
   * @param a a
   * @param lda lda
   * @param x x
   * @param incx incx
   * @return result
   */
  public int execute(String uplo, String trans, String diag, int n, RS[] a, int lda, RS[] x, int incx) {
    int a_dim1 = lda;
    int a_offset = 1 + a_dim1 * 1;
    int pointer_a = -a_offset;

    int info = 0;
    if (!BLAS.lsame(uplo, "U") && !BLAS.lsame(uplo, "L")) { //$NON-NLS-1$ //$NON-NLS-2$
      info = 1;
    } else if (!BLAS.lsame(trans, "N") && !BLAS.lsame(trans, "T") && !BLAS.lsame(trans, "C")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      info = 2;
    } else if (!BLAS.lsame(diag, "U") && !BLAS.lsame(diag, "N")) { //$NON-NLS-1$ //$NON-NLS-2$
      info = 3;
    } else if (n < 0) {
      info = 4;
    } else if (lda < Math.max(1, n)) {
      info = 6;
    } else if (incx == 0) {
      info = 8;
    }
    if (info != 0) {
      BLAS.xerbla("DTRMV ", info); //$NON-NLS-1$
File Line
org/mklab/sdpj/tool/Sedumi2.java 115
org/mklab/sdpj/tool/Sedumi2.java 216
    Solver<MPFloat,MPFloatMatrix,MPFloatComplexNumber,MPFloatComplexMatrix> solver = new Solver<>(new MPFloat(1));

    solver.setProblem(problem);
    solver.setOutFile("out.txt"); //$NON-NLS-1$
    solver.setPrintStreamForDisplay(System.out);
    solver.run();
    //   solver.solve(problem, "out.txt", System.out, com); //$NON-NLS-1$
    Solution<RS,RM,CS,CM> s = (Solution<RS, RM, CS, CM>)solver.getSolution();

    MatxList ml = new MatxList();
    Vector<RS,RM,CS,CM> y = s.getYvec();
    ml.add(y.getElement(0).createGrid(y.getElements()));
    DenseMatrix<RS,RM,CS,CM> x = s.getXmat().getBlock(0);
    if (x.isDense()) {
      ml.add(x.denseElements[0].createGrid(x.denseElements));
    } else {
      ml.add(x.diagonalElements[0].createGrid(x.diagonalElements));
    }
    DenseMatrix<RS,RM,CS,CM> z = s.getZmat().getBlock(0);
    if (z.isDense()) {
      ml.add(z.denseElements[0].createGrid(z.denseElements));
    } else {
      ml.add(z.diagonalElements[0].createGrid(z.diagonalElements));
    }

    return ml;
  }
File Line
org/mklab/sdpj/gpack/lapackwrap/Dsteqr.java 777
org/mklab/sdpj/gpack/lapackwrap/Dsterf.java 480
  }

  /**
   * @param type type
   * @param kl kl
   * @param ku ku
   * @param cfrom cfrom
   * @param cto cto
   * @param m m
   * @param n2 n2
   * @param aIndex d
   * @param lda lda
   * @return result
   */
  private int dlascl_d(String type, int kl, int ku, RS cfrom, RS cto, int m, int n2, int aIndex, int lda) {
    final RS unit = cfrom.createUnit();
    RS[] aTemp = unit.createArray(this.d.length - aIndex);
    System.arraycopy(this.d, aIndex, aTemp, 0, aTemp.length);
    int info = Clapack.dlascl(type, kl, ku, cfrom, cto, m, n2, aTemp, lda);
    System.arraycopy(aTemp, 0, this.d, aIndex, aTemp.length);
    return info;
  }

  /**
   * @param type type
   * @param kl kl
   * @param ku ku
   * @param cfrom cfrom
   * @param cto cto
   * @param m m
   * @param n2 n2
   * @param aIndex e
   * @param lda lda
   * @return result
   */
  private int dlascl_e(String type, int kl, int ku, RS cfrom, RS cto, int m, int n2, int aIndex, int lda) {
    final RS unit = cfrom.createUnit();
    RS[] aTemp = unit.createArray(this.e.length - aIndex);
    System.arraycopy(this.e, aIndex, aTemp, 0, aTemp.length);
    int info = Clapack.dlascl(type, kl, ku, cfrom, cto, m, n2, aTemp, lda);
    System.arraycopy(aTemp, 0, this.e, aIndex, aTemp.length);
    return info;
  }
File Line
org/mklab/sdpj/algorithm/StepLength.java 129
org/mklab/sdpj/algorithm/StepLength.java 209
    this.dual = this.unit.create(9).divide(10);

    if (phase.getValue() == PhaseType.noINFO || phase.getValue() == PhaseType.dFEAS) {
      if (this.primal.isGreaterThan(1)) {// primal is infeasible
        this.primal = createUnit();
      }
    } else {// when primal is feasible,check stepP1 is effective or not.
      RS incPrimalObj = Algebra.run(C, '.', newton.getDxMat());
      if (incPrimalObj.isGreaterThan(0)) {
        if (this.primal.isGreaterThan(this.dual)) {
          this.primal = this.dual;
        }
        if (this.primal.isGreaterThan(1)) {
          this.primal = createUnit();
        }
      }
    }
    if (phase.getValue() == PhaseType.noINFO || phase.getValue() == PhaseType.pFEAS) {
      if (this.dual.isGreaterThan(1)) {
        // dual is infeasible
        this.dual = createUnit();
      }
    } else {
      // when dual is feasible,check stepD1 is effective or not.
      RS incDualObj = Algebra.run(b, '.', newton.getDyVec());
      if (incDualObj.isLessThan(0)) {
        if (this.dual.isGreaterThan(this.primal)) {
          this.dual = this.primal;
        }
        if (this.dual.isGreaterThan(1)) {
          this.dual = createUnit();
        }
      }
    }
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlarfb.java 317
org/mklab/sdpj/gpack/lapackwrap/Dlarfb.java 574
          this.arraycopyWorkTempOffsetForWork();

          for (int j = 1; j <= k; ++j) {
            for (int i = 1; i <= m; ++i) {
              this.c[j * c_dim1 + i + pointer_c] = this.c[j * c_dim1 + i + pointer_c].subtract(this.work[j * work_dim1 + i + pointer_work]);
              /* L50: */
            }
            /* L60: */
          }
        }

      } else {
        /* Let  V =  ( V1 )   
                     ( V2 )    (last K rows)   
           where  V2  is unit upper triangular. */

        if (BLAS.lsame(side, "L")) { //$NON-NLS-1$

          /* Form  H * C  or  H' * C  where  C = ( C1 )   
                                                 ( C2 )   
          
             W := C' * V  =  (C1'*V1 + C2'*V2)  (stored in WORK)   
             W := C2' */

          for (int j = 1; j <= k; ++j) {
            RS[] cTemp = unit.createArray(n);
            RS[] workTemp = unit.createArray(n);
            System.arraycopy(this.c, c_dim1 + m - k + j + pointer_c, cTemp, 0, n);
            System.arraycopy(this.work, j * work_dim1 + 1 + pointer_work, workTemp, 0, n);

            BLAS.dcopy(n, cTemp, ldc, workTemp, 1);

            System.arraycopy(cTemp, 0, this.c, c_dim1 + m - k + j + pointer_c, n);
            System.arraycopy(workTemp, 0, this.work, j * work_dim1 + 1 + pointer_work, n);
            /* L70: */
          }

          //配列をコピー work-->workTempOffset c-->cTempOffset
          this.arraycopyWorkForWorkTempOffset();
File Line
org/mklab/sdpj/convert/SDPAM.java 103
org/mklab/sdpj/convert/SDPAM.java 174
  public String getSDPADatSString() {
    final StringWriter sw = new StringWriter();
    try (final PrintWriter pw = new PrintWriter(new BufferedWriter(sw))) {

      pw.print(this.mDIM);
      pw.println("=mDIM"); //$NON-NLS-1$
      pw.print(this.nBLOCK);
      pw.println("=nBLOCK"); //$NON-NLS-1$

      if (this.bLOCKsTRUCT.size() > 1) {
        pw.print("("); //$NON-NLS-1$
        for (int i = 0; i < this.bLOCKsTRUCT.size(); i++) {
          pw.print(this.bLOCKsTRUCT.get(i));
          if (i == this.bLOCKsTRUCT.size() - 1) {
            pw.print(")"); //$NON-NLS-1$
          } else {
            pw.print(","); //$NON-NLS-1$
          }
        }
      } else {
        pw.print(this.bLOCKsTRUCT.get(0));
      }

      pw.println("=bLOCKsTRUCT"); //$NON-NLS-1$
      pw.print("{"); //$NON-NLS-1$

      for (int i = 0; i < this.c.length; i++) {
        pw.print(this.c[i]);
        if (i == this.c.length - 1) {
          pw.println("}"); //$NON-NLS-1$
        } else {
          pw.print(","); //$NON-NLS-1$
        }
      }

      int x = this.sdpamF[0].length;
File Line
org/mklab/sdpj/algebra/Algebra.java 1301
org/mklab/sdpj/algebra/Algebra.java 1399
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1435
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1533
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 2603
org/mklab/sdpj/algebra/Algebra.java 2759
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2737
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2893
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dsteqr.java 729
org/mklab/sdpj/gpack/lapackwrap/Dsterf.java 522
  }

  /**
   * @param id id
   * @param n n
   * @param dIndex dIndex
   * @return result
   */
  private int dlasrt(String id, int n, int dIndex) {
    final RS unit = this.d[0].createUnit();
    RS[] dTemp = unit.createArray(this.d.length - dIndex);
    System.arraycopy(this.d, dIndex, dTemp, 0, dTemp.length);
    int info = Clapack.dlasrt(id, n, dTemp);
    System.arraycopy(dTemp, 0, this.d, dIndex, dTemp.length);
    return info;
  }

  /**
   * @param norm input
   * @param n input
   * @param dIndex d input
   * @param eIndex e input
   * @return ans output
   */
  private RS dlanst(String norm, int n, int dIndex, int eIndex) {
    final RS unit = this.d[0].createUnit();
    RS[] dTemp = unit.createArray(this.d.length - dIndex);
    RS[] eTemp = unit.createArray(this.e.length - eIndex);
    System.arraycopy(this.d, dIndex, dTemp, 0, dTemp.length);
    System.arraycopy(this.e, eIndex, eTemp, 0, eTemp.length);
    return Clapack.dlanst(norm, n, dTemp, eTemp);
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlasrt.java 170
org/mklab/sdpj/gpack/lapackwrap/Dlasrt.java 207
            } while (d[pointer_d + i].isGreaterThan(dmnmx));
            if (i < j) {
              RS tmp = d[pointer_d + i];
              d[pointer_d + i] = d[pointer_d + j];
              d[pointer_d + j] = tmp;
            }
          } while (i < j);

          if (j - start > endd - j - 1) {
            ++stkpnt;
            stack[(stkpnt) * 2 + 1 - 3 + pointer_stack] = start;
            stack[(stkpnt) * 2 + 2 - 3 + pointer_stack] = j;
            ++stkpnt;
            stack[(stkpnt) * 2 + 1 - 3 + pointer_stack] = j + 1;
            stack[(stkpnt) * 2 + 2 - 3 + pointer_stack] = endd;
          } else {
            ++stkpnt;
            stack[(stkpnt) * 2 + 1 - 3 + pointer_stack] = j + 1;
            stack[(stkpnt) * 2 + 2 - 3 + pointer_stack] = endd;
            ++stkpnt;
            stack[(stkpnt) * 2 + 1 - 3 + pointer_stack] = start;
            stack[(stkpnt) * 2 + 2 - 3 + pointer_stack] = j;
          }
        } else {
File Line
org/mklab/sdpj/algebra/Algebra.java 2629
org/mklab/sdpj/algebra/Algebra.java 2785
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2763
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2919
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());
    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a - b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> minus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 949
org/mklab/sdpj/algebra/Algebra.java 1035
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1083
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1169
            System.arraycopy(retMat_i, 0, ans.denseElements, ans.getRowSize() * i, retMat_i.length);
          } else {
            RS[] aMat_j = unit.createArray(a.denseElements.length - a.getRowSize() * j);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - ans.getRowSize() * j);
            System.arraycopy(a.denseElements, a.getRowSize() * j, aMat_j, 0, aMat_j.length);
            System.arraycopy(ans.denseElements, ans.getRowSize() * j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, aMat_j, 1, retMat_j, 1);
            System.arraycopy(retMat_j, 0, ans.denseElements, ans.getRowSize() * j, retMat_j.length);
          }
        }
        return ans;
      case DENSE:
        if (ans.isDense() == false || a.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        BLAS.dgemm(
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
File Line
org/mklab/sdpj/algebra/Algebra.java 299
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 368
    for (int i = 0; i < a.getBlockSize(); ++i) {
      ans = ans.add(getInnerProduct(a.getBlock(i), b.getBlock(i)));
    }
    return ans;
  }

  /**
   * 内積の計算を行います。 Al.getInnerProduct(ret,aVec,bVec)をret=Al.getInnerProduct(aVec,bVec)に変更。
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 内積
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getInnerProduct(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("getInnerProduct:: different memory size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();

    RS ans = unit.create(0);
File Line
org/mklab/sdpj/gpack/blaswrap/Dtrsm.java 278
org/mklab/sdpj/gpack/blaswrap/Dtrsm.java 307
            for (int k = 1; k <= j - 1; ++k) {
              int ap = j * a_dim1 + k + pointer_a;
              if (!a[ap].equals(unit.create(0), unit.getMachineEpsilon())) {
                for (int i = 1; i <= m; ++i) {
                  // b_ref(i, j) = b_ref(i, j) - a_ref(k, j) * b_ref(i,k);
                  int bp = j * b_dim1 + i + pointer_b;
                  b[bp] = b[bp].subtract(a[ap].multiply(b[k * b_dim1 + i + pointer_b]));
                }
              }
            }
            if (nounit) {
              RS temp = unit.create(1).divide(a[j * a_dim1 + j + pointer_a]);

              for (int i = 1; i <= m; ++i) {
                // b_ref(i, j) = temp * b_ref(i, j);
                int p = j * b_dim1 + i + pointer_b;
                b[p] = temp.multiply(b[p]);
              }
            }
          }
        } else {
File Line
org/mklab/sdpj/algebra/Algebra.java 291
org/mklab/sdpj/algebra/Algebra.java 316
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getInnerProduct(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("getInnerProduct:: different memory size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    RS ans = unit.create(0);

    for (int i = 0; i < a.getBlockSize(); ++i) {
      ans = ans.add(getInnerProduct(a.getBlock(i), b.getBlock(i)));
    }
    return ans;
  }

  /**
   * 内積の計算を行います。 Al.getInnerProduct(ret,aVec,bVec)をret=Al.getInnerProduct(aVec,bVec)に変更。
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 内積
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getInnerProduct(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlarfb.java 381
org/mklab/sdpj/gpack/lapackwrap/Dlarfb.java 632
          System.arraycopy(vTemp, 0, this.v, v_dim1 + m - k + 1 + pointer_v, vTemp.length);
          /* C2 := C2 - W' */

          //配列を元に戻す。
          this.arraycopyCTempOffsetForC();
          this.arraycopyWorkTempOffsetForWork();

          for (int j = 1; j <= k; ++j) {
            for (int i = 1; i <= n; ++i) {
              this.c[i * c_dim1 + m - k + j + pointer_c] = this.c[i * c_dim1 + m - k + j + pointer_c].subtract(this.work[j * work_dim1 + i + pointer_work]);
              /* L80: */
            }
            /* L90: */
          }

        } else if (BLAS.lsame(side, "R")) { //$NON-NLS-1$

          /* Form  C * H  or  C * H'  where  C = ( C1  C2 )   
             W := C * V  =  (C1*V1 + C2*V2)  (stored in WORK)   
             W := C2 */

          for (int j = 1; j <= k; ++j) {
            RS[] cTemp = unit.createArray(m);
            RS[] workTemp = unit.createArray(m);
            System.arraycopy(this.c, (n - k + j) * c_dim1 + 1 + pointer_c, cTemp, 0, m);
File Line
org/mklab/sdpj/algebra/Algebra.java 3041
org/mklab/sdpj/algebra/Algebra.java 3104
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3175
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3238
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(SparseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(SparseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 3248
org/mklab/sdpj/algebra/Algebra.java 3311
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3382
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3445
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockSparseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    BlockDenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockSparseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/benchmark/Sdplib.java 338
org/mklab/sdpj/benchmark/Sdplib.java 452
      this.target = "0"; //$NON-NLS-1$
      String replacement = "100"; //$NON-NLS-1$
      for (Integer i = 0; i < 13; i++) {
        if (i == 0) {
          this.run(replacement);
          this.target = replacement;
        }
        if (i > 0 && i <= 4) {
          replacement = "124-" + i.toString(); //$NON-NLS-1$
          this.run(replacement);
          this.target = replacement;
        }
        if (i > 4 && i <= 8) {
          replacement = "250-" + Integer.valueOf(i - 4).toString(); //$NON-NLS-1$
          this.run(replacement);
          this.target = replacement;
        }
        if (i > 8 && i <= 12) {
          replacement = "500-" + Integer.valueOf(i - 8).toString(); //$NON-NLS-1$
          this.run(replacement);
          this.target = replacement;
        }
      }
    }
  }

  /**
   * test solver SDPJ with using problems of infp
   * 
   * @param name name of problem folder
   * @throws IOException 読み込めない場合
   */
  @SuppressWarnings("boxing")
  private void testInfp(String name) throws IOException {
File Line
org/mklab/sdpj/gpack/blaswrap/Dsyr2k.java 144
org/mklab/sdpj/gpack/blaswrap/Dsyrk.java 121
    int c_dim1 = ldc;
    int c_offset = 1 + c_dim1 * 1;
    int pointer_c = -c_offset;

    int nrowa;
    if (BLAS.lsame(trans, "N")) { //$NON-NLS-1$
      nrowa = n;
    } else {
      nrowa = k;
    }
    boolean upper = BLAS.lsame(uplo, "U"); //$NON-NLS-1$

    int info = 0;
    if (!upper && !BLAS.lsame(uplo, "L")) { //$NON-NLS-1$
      info = 1;
    } else if (!BLAS.lsame(trans, "N") && !BLAS.lsame(trans, "T") && !BLAS.lsame(trans, "C")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
      info = 2;
    } else if (n < 0) {
      info = 3;
    } else if (k < 0) {
      info = 4;
    } else if (lda < Math.max(1, nrowa)) {
      info = 7;
    } else if (ldb < Math.max(1, nrowa)) {
File Line
org/mklab/sdpj/algebra/Algebra.java 124
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 150
      throw new RuntimeException("getInnerProduct:: different memory size"); //$NON-NLS-1$
    }
    return BLAS.<RS,RM,CS,CM> ddot(size, a.getElements(), 1, b.getElements(), 1);
  }

  /**
   * 内積の計算を行います。 Al.getInnerProduct(ret,aVec,bVec)をret=Al.getInnerProduct(aVec,bVec)に変更。
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param b b
   * @return 最小固有値
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getInnerProduct(BlockVector<RS,RM,CS,CM> a, BlockVector<RS,RM,CS,CM> b) {
    // 内積=Al.getInnerProduct(vec1,vec2);に書き換えたほうがいいかもね!
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("getInnerProduct:: different memory size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();

    RS ret = unit.create(0);
File Line
org/mklab/sdpj/algebra/Algebra.java 2246
org/mklab/sdpj/algebra/Algebra.java 2357
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2380
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2491
          RS value = b.getSparseElement(index).multiply(scalar);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].add(value);
            ans.denseElements[ji] = ans.denseElements[ji].add(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].add(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = b.rowIndex[index];
          int j1 = b.columnIndex[index];
          RS value1 = b.getSparseElement(index).multiply(scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 748
org/mklab/sdpj/algebra/Algebra.java 832
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 882
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 966
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getColumnSize() != b.getRowSize()) {
      throw new RuntimeException("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = b.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), b.getColumnSize(), b.getDenseOrDiagonal(), unit);

    switch (a.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        if (ans.isDense() == false || b.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }
        for (int index = 0; index < a.nonZeroCount; ++index) {
          int i = a.rowIndex[index];
          int j = a.columnIndex[index];
          RS value = a.getSparseElement(index).multiply(scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 918
org/mklab/sdpj/algebra/Algebra.java 1004
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1052
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1138
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, SparseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getColumnSize() != b.getRowSize()) {
      throw new RuntimeException("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getRowSize(), b.getColumnSize(), a.getDenseOrDiagonal(), unit);

    switch (b.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        if (ans.isDense() == false || a.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        for (int index = 0; index < b.nonZeroCount; ++index) {
          int i = b.rowIndex[index];
          int j = b.columnIndex[index];
          RS value = b.getSparseElement(index).multiply(scalar);
File Line
org/mklab/sdpj/algorithm/StepLength.java 307
org/mklab/sdpj/algorithm/StepLength.java 354
    RS[][] matrixdA = newton.getDzMat().getArrayOfElements();

   //NumericalMatrix<RS> A = new BaseNumericalMatrix<>(matrixA);    
    RM A = matrixA[0][0].createGrid(matrixA);
    //NumericalMatrix<RS> dA = new BaseNumericalMatrix<>(matrixdA);
    RM dA = matrixdA[0][0].createGrid(matrixdA);

    double alpha = 0.1;
    for (int i = 1; i <= 10; i++) {
      alpha *= i;
      dA =dA.multiply(alpha);
      A =A.add(dA);

      RS minimumEigenValue;
      if (guarantee) {
        MPFloatRumpMethod verifier = new MPFloatRumpMethod((MPFloatMatrix)A.multiply(alpha));
        Guarantor<MPFloatRumpMethod> guarantor = new Guarantor<>(verifier);
        guarantor.solveWithEffectiveDigits(26);
        MPFloatRumpMethod guranteedVerifier = guarantor.getGuranteedVerifier();
        minimumEigenValue  = (RS)guranteedVerifier.getEigenValue().getInfimum().getRealPart().min();
      } else {
        CM eigenValue = A.eigenValue();
File Line
org/mklab/sdpj/algebra/Algebra.java 3135
org/mklab/sdpj/algebra/Algebra.java 3279
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3269
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3413
    DenseMatrix<RS,RM,CS,CM> ans;

    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' 't' 'T' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlatrd.java 328
org/mklab/sdpj/gpack/lapackwrap/Dlatrd.java 447
  private int dsymv(String uplo, int n, RS alpha, int aIndex, int lda, int xIndex, int incx, RS beta, int yIndex, int incy) {
    final RS unit = alpha.createUnit();
    RS[] aTemp = unit.createArray(this.a.length - aIndex);
    RS[] x = unit.createArray(this.a.length - xIndex);
    RS[] y = unit.createArray(this.w.length - yIndex);
    System.arraycopy(this.a, aIndex, aTemp, 0, aTemp.length);
    System.arraycopy(this.a, xIndex, x, 0, x.length);
    System.arraycopy(this.w, yIndex, y, 0, y.length);
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 366
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 498
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 561
        }
      }
    } else if (cname && LibF77.compare(c2, "UN", 2, 2) == 0) { //$NON-NLS-1$
      if (c3[0] == 'G') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 355
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 487
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 555
      }
    } else if (sname && LibF77.compare(c2, "OR", 2, 2) == 0) { //$NON-NLS-1$
      if (c3[0] == 'G') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
File Line
org/mklab/sdpj/algorithm/Newton.java 345
org/mklab/sdpj/algorithm/Newton.java 400
            if (i != j) {
              this.bMat.denseElements[i + this.bMat.getColumnSize() * j] = this.bMat.denseElements[i + this.bMat.getColumnSize() * j].add(value);
              this.bMat.denseElements[j + this.bMat.getColumnSize() * i] = this.bMat.denseElements[j + this.bMat.getColumnSize() * i].add(value);
            } else {
              this.bMat.denseElements[i + this.bMat.getColumnSize() * i] = this.bMat.denseElements[i + this.bMat.getColumnSize() * i].add(value);
            }
          }
        }
      } else {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlasr.java 255
org/mklab/sdpj/gpack/lapackwrap/Dlasr.java 269
          for (int j = 1; j <= n - 1; ++j) {
            RS ctemp = c[pointer_c + j];
            RS stemp = s[pointer_s + j];
            if (!ctemp.isUnit() || !stemp.isZero()) {
              for (int i = 1; i <= m; ++i) {
                int p1 = (j) * a_dim1 + i + pointer_a;
                int p2 = (j + 1) * a_dim1 + i + pointer_a;
                RS temp = a[p2];
                a[p2] = (ctemp.multiply(temp)).subtract(stemp.multiply(a[p1]));
                a[p1] = (stemp.multiply(temp)).add(ctemp.multiply(a[p1]));
              }
            }
          }
        } else if (BLAS.lsame(direct, "B")) { //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 937
org/mklab/sdpj/algebra/Algebra.java 1030
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1071
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1164
            RS[] aMat_i = unit.createArray(a.denseElements.length - a.getRowSize() * i);
            System.arraycopy(a.denseElements, a.getRowSize() * i, aMat_i, 0, aMat_i.length);
            RS[] retMat_j = unit.createArray(ans.denseElements.length - ans.getRowSize() * j);
            System.arraycopy(ans.denseElements, ans.getRowSize() * j, retMat_j, 0, retMat_j.length);
            BLAS.daxpy(b.getColumnSize(), value, aMat_i, 1, retMat_j, 1);
            System.arraycopy(retMat_j, 0, ans.denseElements, ans.getRowSize() * j, retMat_j.length);
File Line
org/mklab/sdpj/algebra/Algebra.java 944
org/mklab/sdpj/algebra/Algebra.java 1023
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1078
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1157
            RS[] aMat_j = unit.createArray(a.denseElements.length - a.getRowSize() * j);
            System.arraycopy(a.denseElements, a.getRowSize() * j, aMat_j, 0, aMat_j.length);
            RS[] retMat_i = unit.createArray(ans.denseElements.length - ans.getRowSize() * i);
            System.arraycopy(ans.denseElements, ans.getRowSize() * i, retMat_i, 0, retMat_i.length);
            BLAS.daxpy(b.getColumnSize(), value, aMat_j, 1, retMat_i, 1);
            System.arraycopy(retMat_i, 0, ans.denseElements, ans.getRowSize() * i, retMat_i.length);
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlasr.java 192
org/mklab/sdpj/gpack/lapackwrap/Dlasr.java 206
          for (int j = 2; j <= m; ++j) {
            RS ctemp = c[pointer_c + j - 1];
            RS stemp = s[pointer_s + j - 1];
            if (!ctemp.isUnit() || !stemp.isZero()) {
              for (int i = 1; i <= n; ++i) {
                int p1 = i * a_dim1 + 1 + pointer_a;
                int p2 = i * a_dim1 + j + pointer_a;
                RS temp = a[p2];
                a[p2] = (ctemp.multiply(temp)).subtract(stemp.multiply(a[p1]));
                a[p1] = (stemp.multiply(temp)).add(ctemp.multiply(a[p1]));
              }
            }
          }
        } else if (BLAS.lsame(direct, "B")) { //$NON-NLS-1$
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlasr.java 285
org/mklab/sdpj/gpack/lapackwrap/Dlasr.java 299
          for (int j = 2; j <= n; ++j) {
            RS ctemp = c[pointer_c + j - 1];
            RS stemp = s[pointer_s + j - 1];
            if (!ctemp.isUnit() || !stemp.isZero()) {
              for (int i = 1; i <= m; ++i) {
                int p1 = a_dim1 + i + pointer_a;
                int p2 = (j) * a_dim1 + i + pointer_a;
                RS temp = a[p2];
                a[p2] = (ctemp.multiply(temp)).subtract(stemp.multiply(a[p1]));
                a[p1] = (stemp.multiply(temp)).add(ctemp.multiply(a[p1]));
              }
            }
          }
        } else if (BLAS.lsame(direct, "B")) { //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 2263
org/mklab/sdpj/algebra/Algebra.java 2374
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2397
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2508
          RS value1 = b.getSparseElement(index).multiply(scalar);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].add(value1);
            ans.denseElements[ji] = ans.denseElements[ji].add(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].add(value1);
          }
          int i2 = b.rowIndex[index + 1];
          int j2 = b.columnIndex[index + 1];
          RS value2 = b.getSparseElement(index + 1).multiply(scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 2275
org/mklab/sdpj/algebra/Algebra.java 2386
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2409
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2520
          RS value2 = b.getSparseElement(index + 1).multiply(scalar);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].add(value2);
            ans.denseElements[ji] = ans.denseElements[ji].add(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].add(value2);
          }
          int i3 = b.rowIndex[index + 2];
          int j3 = b.columnIndex[index + 2];
          RS value3 = b.getSparseElement(index + 2).multiply(scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 2287
org/mklab/sdpj/algebra/Algebra.java 2398
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2421
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2532
          RS value3 = b.getSparseElement(index + 2).multiply(scalar);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].add(value3);
            ans.denseElements[ji] = ans.denseElements[ji].add(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].add(value3);
          }
          int i4 = b.rowIndex[index + 3];
          int j4 = b.columnIndex[index + 3];
          RS value4 = b.getSparseElement(index + 3).multiply(scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 1907
org/mklab/sdpj/algebra/Algebra.java 2019
org/mklab/sdpj/algebra/Algebra.java 2357
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2041
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2153
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2491
          RS value = a.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].add(value);
            ans.denseElements[ji] = ans.denseElements[ji].add(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].add(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = a.rowIndex[index];
File Line
org/mklab/sdpj/algebra/Algebra.java 2131
org/mklab/sdpj/algebra/Algebra.java 2459
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2265
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2593
          RS value = a.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = a.rowIndex[index];
File Line
org/mklab/sdpj/algebra/Algebra.java 3042
org/mklab/sdpj/algebra/Algebra.java 3105
org/mklab/sdpj/algebra/Algebra.java 3249
org/mklab/sdpj/algebra/Algebra.java 3312
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3176
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3239
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3383
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3446
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(SparseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlasr.java 222
org/mklab/sdpj/gpack/lapackwrap/Dlasr.java 236
          for (int j = 1; j <= m - 1; ++j) {
            RS ctemp = c[pointer_c + j];
            RS stemp = s[pointer_s + j];
            if (!ctemp.isUnit() || !stemp.isZero()) {
              for (int i = 1; i <= n; ++i) {
                int p1 = i * a_dim1 + m + pointer_a;
                int p2 = i * a_dim1 + j + pointer_a;
                RS temp = a[p2];
                a[p2] = (stemp.multiply(a[p1])).add(ctemp.multiply(temp));
                a[p1] = (ctemp.multiply(a[p1])).subtract(stemp.multiply(temp));
              }
            }
          }
        } else if (BLAS.lsame(direct, "B")) { //$NON-NLS-1$
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 556
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 563
    } else if (sname && LibF77.compare(c2, "OR", 2, 2) == 0) { //$NON-NLS-1$
      if (c3[0] == 'G') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
          nx = 128;
        }
      }
    } else if (cname && LibF77.compare(c2, "UN", 2, 2) == 0) { //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 2342
org/mklab/sdpj/algebra/Algebra.java 2447
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2476
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2581
      throw new RuntimeException("plus :: different matrix size"); //$NON-NLS-1$
    }

    // ans = a
    DenseMatrix<RS,RM,CS,CM> ans = a.createClone();

    // ans += (*scalar) * b

    switch (b.getSparseOrDenseOrDiagonal()) {
      case SPARSE:
        int shou = b.nonZeroCount / 4;
        int amari = b.nonZeroCount % 4;
        for (int index = 0; index < amari; ++index) {
          int i = b.rowIndex[index];
          int j = b.columnIndex[index];
          RS value = b.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].add(value);
File Line
org/mklab/sdpj/algebra/Algebra.java 3071
org/mklab/sdpj/algebra/Algebra.java 3134
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3205
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3268
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(SparseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b) {
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(DenseMatrix<RS,RM,CS,CM> a, final char operator, SparseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 3278
org/mklab/sdpj/algebra/Algebra.java 3342
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3412
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3476
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockSparseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b) {
    BlockDenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockSparseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/main/SdpjParameters.java 155
org/mklab/sdpj/main/SdpjParameters.java 197
        if (target.equals("-pt") && i + 1 < argc) { //$NON-NLS-1$
          int tmp = atoi(arguments[i + 1]);
          switch (tmp) {
            case 0:
              this.parameterType = ParameterType.PARAMETER_DEFAULT;
              break;
            case 1:
              this.parameterType = ParameterType.PARAMETER_AGGRESSIVE;
              break;
            case 2:
              this.parameterType = ParameterType.PARAMETER_STABLE;
              break;
            case 3:
              this.parameterType = ParameterType.PARAMETER_MP115_DEFAULT;
              break;
            case 4:
              this.parameterType = ParameterType.PARAMETER_MP115_STABLE;
              break;
            default:
              this.parameterType = ParameterType.PARAMETER_DEFAULT;
          }
          if (tmp == 3 || tmp == 4) {
            this.dataType = "mpfloat"; //$NON-NLS-1$
          } else {
            this.dataType = "double"; //$NON-NLS-1$
          }
          i++;
          this.paraFile = null;
          this.isParameter = false;
File Line
org/mklab/sdpj/algebra/Algebra.java 1306
org/mklab/sdpj/algebra/Algebra.java 1355
org/mklab/sdpj/algebra/Algebra.java 1404
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1440
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1489
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1538
    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 2608
org/mklab/sdpj/algebra/Algebra.java 2685
org/mklab/sdpj/algebra/Algebra.java 2764
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2742
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2819
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2898
    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/gpack/blaswrap/Dtrmm.java 290
org/mklab/sdpj/gpack/blaswrap/Dtrmm.java 312
            for (int j = 1; j <= k - 1; ++j) {
              if (!a[k * a_dim1 + j + pointer_a].isZero()) {
                RS temp = alpha.multiply(a[k * a_dim1 + j + pointer_a]);
                for (int i = 1; i <= m; ++i) {
                  int p = j * b_dim1 + i + pointer_b;
                  b[p] = b[p].add(temp.multiply(b[k * b_dim1 + i + pointer_b]));
                }
              }
            }
            RS temp = alpha;
            if (nounit) {
              temp = temp.multiply(a[k * a_dim1 + k + pointer_a]);
            }
            if (!temp.equals(unit.create(1))) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1907
org/mklab/sdpj/algebra/Algebra.java 2019
org/mklab/sdpj/algebra/Algebra.java 2246
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2041
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2153
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2380
          RS value = a.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].add(value);
            ans.denseElements[ji] = ans.denseElements[ji].add(value);
          } else {
            int ii = i + ans.getColumnSize() * i;
            ans.denseElements[ii] = ans.denseElements[ii].add(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = a.rowIndex[index];
File Line
org/mklab/sdpj/gpack/blaswrap/Dsyr2.java 154
org/mklab/sdpj/gpack/blaswrap/Dsyr2.java 185
            for (int i = 1; i <= j; ++i) {
              int p = j * a_dim1 + i + pointer_a;
              a[p] = a[p].add(x[i - 1].multiply(temp1)).add(y[i - 1].multiply(temp2));
            }
          }
        }
      } else {
        for (int j = 1; j <= n; ++j) {
          if (!x[jx - 1].isZero() || !y[jy - 1].isZero()) {
            RS temp1 = alpha.multiply(y[jy - 1]);
            RS temp2 = alpha.multiply(x[jx - 1]);
            int ix = kx;
File Line
org/mklab/sdpj/gpack/blaswrap/Dsyr2k.java 240
org/mklab/sdpj/gpack/blaswrap/Dsyrk.java 209
                c[ci] = c[ci].add(a[ai].multiply(temp1)).add(b[bi].multiply(temp2));
              }
            }
          }
        }
      } else {
        for (int j = 1; j <= n; ++j) {
          if (beta.isZero()) {
            for (int i = j; i <= n; ++i) {
              c[j * c_dim1 + i + pointer_c] = unit.createZero();
            }
          } else if (!beta.equals(unit.createUnit())) {
            for (int i = j; i <= n; ++i) {
              int p = j * c_dim1 + i + pointer_c;
              c[p] = beta.multiply(c[p]);
            }
          }
          for (int l = 1; l <= k; ++l) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dorgtr.java 600
org/mklab/sdpj/gpack/lapackwrap/Dorgtr.java 619
    if (BLAS.lsame(side, "L")) { //$NON-NLS-1$
      /* Form  H * C */
      if (!tau.isZero()) {
        //array copy
        RS[] cTemp = unit.createArray(c.length - (c_offset + pointer_c));
        RS[] workTemp = unit.createArray(this.work.length - (1 + pointer_work));
        RS[] vTemp = unit.createArray(v.length - (1 + pointer_v));
        System.arraycopy(c, c_offset + pointer_c, cTemp, 0, cTemp.length);
        System.arraycopy(this.work, 1 + pointer_work, workTemp, 0, workTemp.length);
        System.arraycopy(v, 1 + pointer_v, vTemp, 0, vTemp.length);

        /* w := C' * v */
        BLAS.dgemv("Transpose", m, n, c_b4, cTemp, ldc, vTemp, incv, c_b5, workTemp, 1); //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 2634
org/mklab/sdpj/algebra/Algebra.java 2711
org/mklab/sdpj/algebra/Algebra.java 2790
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2768
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2845
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2924
    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());
    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a - b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> minus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 2659
org/mklab/sdpj/algebra/Algebra.java 2737
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2793
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2871
    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());
    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = minus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlarfb.java 281
org/mklab/sdpj/gpack/lapackwrap/Dlarfb.java 296
          BLAS.dtrmm("Right", "Lower", "No transpose", "Unit", m, k, c_b14, this.vTempOffset, ldv, this.workTempOffset, ldwork); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$

          if (n > k) {
            /* W := W + C2 * V2 */
            RS[] vTemp = unit.createArray(this.v.length - (v_dim1 + k + 1 + pointer_v));
            RS[] cTemp = unit.createArray(this.c.length - ((k + 1) * c_dim1 + 1 + pointer_c));
            System.arraycopy(this.v, v_dim1 + k + 1 + pointer_v, this.v, 0, vTemp.length);
            System.arraycopy(this.c, (k + 1) * c_dim1 + 1 + pointer_c, cTemp, 0, cTemp.length);

            BLAS.dgemm("No transpose", "No transpose", m, k, n - k, c_b14, cTemp, ldc, vTemp, ldv, c_b14, this.workTempOffset, ldwork); //$NON-NLS-1$ //$NON-NLS-2$
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 356
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 500
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 563
    } else if (sname && LibF77.compare(c2, "OR", 2, 2) == 0) { //$NON-NLS-1$
      if (c3[0] == 'G') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 368
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 488
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 556
    } else if (cname && LibF77.compare(c2, "UN", 2, 2) == 0) { //$NON-NLS-1$
      if (c3[0] == 'G') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 2654
org/mklab/sdpj/algebra/Algebra.java 2811
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2788
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2945
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> minus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("minus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());
    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = minus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }
File Line
org/mklab/sdpj/algebra/Algebra.java 1330
org/mklab/sdpj/algebra/Algebra.java 1379
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1464
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1513
    BlockDenseMatrix<RS,RM,CS,CM> ans = a.createClone();

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/gpack/blaswrap/Dsyrk.java 241
org/mklab/sdpj/gpack/blaswrap/Dsyrk.java 257
          for (int i = 1; i <= j; ++i) {
            RS temp = unit.createZero();
            for (int l = 1; l <= k; ++l) {
              int p = i * a_dim1 + l + pointer_a;
              temp = temp.add(a[p].multiply(a[j * a_dim1 + l + pointer_a]));
            }
            int p = j * c_dim1 + i + pointer_c;
            if (beta.isZero()) {
              c[p] = alpha.multiply(temp);
            } else {
              c[p] = (alpha.multiply(temp)).add(beta.multiply(c[p]));
            }
          }
        }
      } else {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlae2.java 17
org/mklab/sdpj/gpack/lapackwrap/Dlaev2.java 17
public class Dlae2<RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> {

  /**
   * -- LAPACK auxiliary routine (version 3.0) -- Univ. of Tennessee, Univ. of
   * California Berkeley, NAG Ltd., Courant Institute, Argonne National Lab, and
   * Rice University October 31, 1992
   * <p>
   * <p>
   * Purpose ======= DLAE2 computes the eigenvalues of a 2-by-2 symmetric matrix
   * [ A B ] [ B C ]. On return, RT1 is the eigenvalue of larger absolute value,
   * and RT2 is the eigenvalue of smaller absolute value. Arguments ========= A
   * (input) DOUBLE PRECISION The (1,1) element of the 2-by-2 matrix. B (input)
   * DOUBLE PRECISION The (1,2) and (2,1) elements of the 2-by-2 matrix. C
   * (input) DOUBLE PRECISION The (2,2) element of the 2-by-2 matrix. RT1
   * (output) DOUBLE PRECISION The eigenvalue of larger absolute value. RT2
   * (output) DOUBLE PRECISION The eigenvalue of smaller absolute value. Further
   * Details =============== RT1 is accurate to a few ulps barring
   * over/underflow. RT2 may be inaccurate if there is massive cancellation in
   * the determinant A*C-B*B; higher precision or correctly rounded or correctly
   * truncated arithmetic would be needed to compute RT2 accurately in all
   * cases. Overflow is possible only if RT1 is within a factor of 5 of
   * overflow. Underflow is harmless if the input data is 0 or exceeds
   * underflow_threshold / macheps.
   * =====================================================================
   */
  /**
   * @param a a
   * @param b b
   * @param c c
   * @return {rt1, rt2}
   */
  RS[] execute(RS a, RS b, RS c) {
    final RS unit = a.createUnit();

    RS sm = a.add(c);
    RS df = a.subtract(c);
    RS adf = df.abs();
    RS tb = b.add(b);
    RS ab = tb.abs();

    RS acmn;
File Line
org/mklab/sdpj/iocenter/SolverIO.java 346
org/mklab/sdpj/iocenter/SolverIO.java 351
        this.Display.printf("%2d %s %s %s %s %s %s %s %s\n", this.pIteration, this.mu.getValue().toString("%4.2e"), this.theta.getDual().toString("%4.2e"), this.theta.getPrimal().toString("%4.2e"), //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
            this.solveInfo.getObjValDual().unaryMinus().toString("%+7.2e"), //$NON-NLS-1$
            this.solveInfo.getObjValPrimal().unaryMinus().toString("%+7.2e"), this.alpha.getDual().toString("%4.2e"), this.alpha.getPrimal().toString("%4.2e"), this.beta.getValue().toString("%4.2e")); //$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
      }
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 361
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 373
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 493
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 505
        }
      } else if (c3[0] == 'M') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 1450
org/mklab/sdpj/algebra/Algebra.java 1496
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1584
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1630
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> tran_multiply(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getRowSize() != b.getRowSize() || a.getDenseOrDiagonal() != b.getDenseOrDiagonal()) {
      Tools.error("multiply :: different matrix size"); //$NON-NLS-1$
    }

    final RS unit = a.getElementUnit();
    DenseMatrix<RS,RM,CS,CM> ans = new DenseMatrix<>(a.getColumnSize(), b.getColumnSize(), a.getDenseOrDiagonal(), unit);

    switch (ans.getDenseOrDiagonal()) {
      case DENSE:
        BLAS.dgemm(
            "Transpose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getColumnSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
File Line
org/mklab/sdpj/gpack/blaswrap/Dsyr2k.java 277
org/mklab/sdpj/gpack/blaswrap/Dsyr2k.java 294
          for (int i = 1; i <= j; ++i) {
            RS temp1 = unit.createZero();
            RS temp2 = unit.createZero();
            for (int l = 1; l <= k; ++l) {
              temp1 = temp1.add(a[i * a_dim1 + l + pointer_a].multiply(b[j * b_dim1 + l + pointer_b]));
              temp2 = temp2.add(b[i * b_dim1 + l + pointer_b].multiply(a[j * a_dim1 + l + pointer_a]));
            }
            int p = j * c_dim1 + i + pointer_c;
            if (beta.isZero()) {
              c[p] = (alpha.multiply(temp1)).add(alpha.multiply(temp2));
File Line
org/mklab/sdpj/algebra/Algebra.java 3072
org/mklab/sdpj/algebra/Algebra.java 3135
org/mklab/sdpj/algebra/Algebra.java 3279
org/mklab/sdpj/algebra/Algebra.java 3343
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3206
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3269
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3413
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3477
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b);
        return ans;
      case '-':
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(DenseMatrix<RS,RM,CS,CM> a, final char operator, SparseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1284
org/mklab/sdpj/algebra/Algebra.java 1382
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1418
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1516
      Vector<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1960
org/mklab/sdpj/algebra/Algebra.java 2299
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2094
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2433
          RS value4 = a.getSparseElement(index + 3);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].add(value4);
            ans.denseElements[ji] = ans.denseElements[ji].add(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].add(value4);
          }
        }
        return ans;
      case DENSE:
        if (ans.isDense() == false || b.isDense() == false) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1379
org/mklab/sdpj/algebra/Algebra.java 1428
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1513
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1562
    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(b.getBlockSize(), b.getBlockStructs(), b.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockSparseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/datastructure/BlockDenseMatrix.java 124
org/mklab/sdpj/datastructure/BlockDenseMatrix.java 450
      int columnNumber = matrix.getColumnSize();

      switch (matrix.getDenseOrDiagonal()) {
        case DENSE:
          for (int i = 0; i < rowNumber; ++i) {
            for (int j = 0; j < columnNumber; ++j) {
              data[i + shift][j + shift] = matrix.denseElements[i + columnNumber * j];
            }
          }
          break;
        case DIAGONAL:
          for (int j = 0; j < columnNumber; ++j) {
            data[j + shift][j + shift] = matrix.diagonalElements[j];
          }
          break;
        default:
          throw new UnsupportedOperationException();
      }
    }
File Line
org/mklab/sdpj/algebra/Algebra.java 1301
org/mklab/sdpj/algebra/Algebra.java 1540
org/mklab/sdpj/algebra/Algebra.java 1682
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1435
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1674
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1816
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i), scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 3402
org/mklab/sdpj/algebra/Algebra.java 3424
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3536
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3558
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(Vector<RS,RM,CS,CM> a, final char operator, Vector<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(DenseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 3424
org/mklab/sdpj/algebra/Algebra.java 3468
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3558
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3602
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(DenseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(DenseMatrix<RS,RM,CS,CM> a, final char operator, SparseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 3490
org/mklab/sdpj/algebra/Algebra.java 3534
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3624
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3668
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(BlockVector<RS,RM,CS,CM> a, final char operator, BlockVector<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 3512
org/mklab/sdpj/algebra/Algebra.java 3534
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3646
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3668
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b) {
    switch (operator) {
      case '.':
        RS ans = getInnerProduct(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = inner_product(a,b) // op = '.'
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS run(BlockSparseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/gpack/blaswrap/Dsyr2k.java 225
org/mklab/sdpj/gpack/blaswrap/Dsyr2k.java 252
            for (int i = 1; i <= j; ++i) {
              int p = j * c_dim1 + i + pointer_c;
              c[p] = beta.multiply(c[p]);
            }
          }
          for (int l = 1; l <= k; ++l) {
            int aj = l * a_dim1 + j + pointer_a;
            int bj = l * b_dim1 + j + pointer_b;
            if (!a[aj].isZero() || !b[bj].isZero()) {
              RS temp1 = alpha.multiply(b[bj]);
              RS temp2 = alpha.multiply(a[aj]);
              for (int i = 1; i <= j; ++i) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 357
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 362
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 369
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 374
      if (c3[0] == 'G') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
          nb = 32;
        }
      } else if (c3[0] == 'M') {
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 489
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 494
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 501
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 506
      if (c3[0] == 'G') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
          nbmin = 2;
        }
      } else if (c3[0] == 'M') {
File Line
org/mklab/sdpj/problem/ProblemCreater.java 235
org/mklab/sdpj/problem/ProblemCreaterOnMemory.java 172
            if (i <= j && !tmp.isZero()) {
              SparseMatrix<RS,RM,CS,CM> target = this.C.getBlock(k);
              int count = target.nonZeroCount;
              target.rowIndex[count] = i;
              target.columnIndex[count] = j;
              // C must be opposite sign.
              target.sparseElements[count] = tmp.unaryMinus();
              target.nonZeroCount++;
              if (i == j) {
                target.nonZeroEffect++;
              } else {
                target.nonZeroEffect += 2;
              }
            }
          }
        }
      } else {
        for (int j = 0; j < -size; ++j) {
          RS tmp = this.unit.valueOf(F[0][counter]);
File Line
org/mklab/sdpj/algebra/Algebra.java 1801
org/mklab/sdpj/algebra/Algebra.java 2322
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1935
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2456
        BLAS.daxpy(ans.getColumnSize(), scalar, b.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1960
org/mklab/sdpj/algebra/Algebra.java 2072
org/mklab/sdpj/algebra/Algebra.java 2410
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2094
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2206
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2544
          RS value4 = a.getSparseElement(index + 3);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].add(value4);
            ans.denseElements[ji] = ans.denseElements[ji].add(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].add(value4);
          }
        }
        return ans;
      case DENSE:
File Line
org/mklab/sdpj/algebra/Algebra.java 1980
org/mklab/sdpj/algebra/Algebra.java 2092
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2114
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2226
        if (ans.isDiagonal() == false || b.isDiagonal() == false) {
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }
        BLAS.dxpy(ans.getColumnSize(), a.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 2184
org/mklab/sdpj/algebra/Algebra.java 2512
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2318
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2646
          RS value4 = a.getSparseElement(index + 3);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value4);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value4);
          }
        }
        return ans;
      case DENSE:
File Line
org/mklab/sdpj/problem/ProblemCreater.java 270
org/mklab/sdpj/problem/ProblemCreaterOnMemory.java 206
              if (i <= j && !tmp.isZero()) {
                SparseMatrix<RS,RM,CS,CM> target = this.A[k].getBlock(p);
                int count = target.nonZeroCount;
                target.rowIndex[count] = i;
                target.columnIndex[count] = j;
                target.sparseElements[count] = tmp;
                target.nonZeroCount++;
                if (i == j) {
                  target.nonZeroEffect++;
                } else {
                  target.nonZeroEffect += 2;
                }
              }
            }
          }
        } else {
          for (int j = 0; j < -size; ++j) {
            RS tmp = this.unit.valueOf(F[k + 1][counter]);
File Line
org/mklab/sdpj/algebra/Algebra.java 1330
org/mklab/sdpj/algebra/Algebra.java 1428
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1464
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1562
    BlockDenseMatrix<RS,RM,CS,CM> ans = a.createClone();

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/gpack/blaswrap/Dcopy.java 27
org/mklab/sdpj/gpack/blaswrap/Dcopy.java 57
  void dcopy(int size, double[] x, int incx, double[] y, int incy) {
    if (incx == 1 && incy == 1) {
      System.arraycopy(x, 0, y, 0, size);
      return;
    }

    int ix = 0;
    int iy = 0;
    if (incx < 0) {
      ix = (-(size) + 1) * incx;
    }
    if (incy < 0) {
      iy = (-(size) + 1) * incy;
    }
    for (int i = 1; i <= size; ++i) {
      y[iy] = x[ix];
      ix += incx;
      iy += incy;
    }
  }
File Line
org/mklab/sdpj/algebra/Algebra.java 1834
org/mklab/sdpj/algebra/Algebra.java 2427
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1968
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2561
        BLAS.dxpy(ans.getColumnSize(), b.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a - b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> minus(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1867
org/mklab/sdpj/algebra/Algebra.java 1983
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2001
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2117
        BLAS.dxmy(ans.getColumnSize(), b.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 2207
org/mklab/sdpj/algebra/Algebra.java 2322
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2341
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2456
        BLAS.dxmy(ans.getColumnSize(), a.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(DenseMatrix<RS,RM,CS,CM> a, SparseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/datastructure/DenseMatrix.java 141
org/mklab/sdpj/datastructure/SparseMatrix.java 136
        buff.append("{"); //$NON-NLS-1$
        for (int i = 0; i < this.rowSize - 1; ++i) {
          if (i == 0) {
            buff.append(" "); //$NON-NLS-1$
          } else {
            buff.append("  "); //$NON-NLS-1$
          }
          buff.append("{"); //$NON-NLS-1$
          for (int j = 0; j < this.columnSize - 1; ++j) {
            buff.append(this.denseElements[i + this.columnSize * j] + ","); //$NON-NLS-1$
          }
          buff.append(this.denseElements[i + this.columnSize * (getColumnSize() - 1)] + " },\n"); //$NON-NLS-1$
        }
        if (getRowSize() > 1) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1936
org/mklab/sdpj/algebra/Algebra.java 2048
org/mklab/sdpj/algebra/Algebra.java 2386
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2070
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2182
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2520
          RS value2 = a.getSparseElement(index + 1);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].add(value2);
            ans.denseElements[ji] = ans.denseElements[ji].add(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].add(value2);
          }
          int i3 = a.rowIndex[index + 2];
File Line
org/mklab/sdpj/algebra/Algebra.java 1948
org/mklab/sdpj/algebra/Algebra.java 2060
org/mklab/sdpj/algebra/Algebra.java 2398
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2082
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2194
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2532
          RS value3 = a.getSparseElement(index + 2);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].add(value3);
            ans.denseElements[ji] = ans.denseElements[ji].add(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].add(value3);
          }
          int i4 = a.rowIndex[index + 3];
File Line
org/mklab/sdpj/algebra/Algebra.java 2160
org/mklab/sdpj/algebra/Algebra.java 2488
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2294
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2622
          RS value2 = a.getSparseElement(index + 1);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value2);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value2);
          }
          int i3 = a.rowIndex[index + 2];
File Line
org/mklab/sdpj/algebra/Algebra.java 2172
org/mklab/sdpj/algebra/Algebra.java 2500
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2306
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2634
          RS value3 = a.getSparseElement(index + 2);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value3);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value3);
          }
          int i4 = a.rowIndex[index + 3];
File Line
org/mklab/sdpj/algebra/Algebra.java 2072
org/mklab/sdpj/algebra/Algebra.java 2299
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2206
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2433
          RS value4 = a.getSparseElement(index + 3);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].add(value4);
            ans.denseElements[ji] = ans.denseElements[ji].add(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].add(value4);
          }
        }
        return ans;
      case DENSE:
        if (b.isDense() == false) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 357
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 369
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 494
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 506
      if (c3[0] == 'G') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
File Line
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 362
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 374
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 489
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 501
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 557
org/mklab/sdpj/gpack/lapackwrap/Ilaenv.java 564
      } else if (c3[0] == 'M') {
        if (LibF77.compare(c4, "QR", 2, 2) == 0 || LibF77.compare(c4, "RQ", 2, 2) == 0 || LibF77.compare(c4, "LQ", 2, 2) == 0 || LibF77.compare(c4, "QL", 2, 2) == 0 || LibF77.compare(c4, "HR", 2, 2) == 0 || LibF77.compare(c4, "TR", 2, 2) == 0 //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
            || LibF77.compare(c4, "BR", 2, 2) == 0) { //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 174
org/mklab/sdpj/algebra/Algebra.java 272
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 217
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 315
        return BLAS.<RS,RM,CS,CM> ddot(length, a.denseElements, 1, b.denseElements, 1);
      case DIAGONAL:
        return BLAS.ddot(a.getColumnSize(), a.diagonalElements, 1, b.diagonalElements, 1);
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * 内積の計算を行います。 Al.getInnerProduct(ret,aVec,bVec)をret=Al.getInnerProduct(aVec,bVec)に変更。
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 内積
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getInnerProduct(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 794
org/mklab/sdpj/algebra/Algebra.java 879
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 928
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1013
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        if (ans.isDiagonal() == false || b.isDiagonal() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = scalar.multiply(a.getDiagonalElement(j).multiply(b.diagonalElements[j]));
File Line
org/mklab/sdpj/algebra/Algebra.java 966
org/mklab/sdpj/algebra/Algebra.java 1051
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1100
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1185
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), scalar, a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        if (ans.isDiagonal() == false || a.isDiagonal() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }

        int shou = ans.getColumnSize() / 4;
        int amari = ans.getColumnSize() % 4;
        for (int j = 0; j < amari; ++j) {
          ans.diagonalElements[j] = scalar.multiply(a.diagonalElements[j].multiply(b.getDiagonalElement(j)));
File Line
org/mklab/sdpj/algebra/Algebra.java 1924
org/mklab/sdpj/algebra/Algebra.java 2036
org/mklab/sdpj/algebra/Algebra.java 2374
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2058
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2170
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2508
          RS value1 = a.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].add(value1);
            ans.denseElements[ji] = ans.denseElements[ji].add(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].add(value1);
          }
          int i2 = a.rowIndex[index + 1];
File Line
org/mklab/sdpj/algebra/Algebra.java 2148
org/mklab/sdpj/algebra/Algebra.java 2476
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2282
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2610
          RS value1 = a.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].subtract(value1);
            ans.denseElements[ji] = ans.denseElements[ji].subtract(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].subtract(value1);
          }
          int i2 = a.rowIndex[index + 1];
File Line
org/mklab/sdpj/algebra/Algebra.java 2299
org/mklab/sdpj/algebra/Algebra.java 2410
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2433
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2544
          RS value4 = b.getSparseElement(index + 3).multiply(scalar);
          if (i4 != j4) {
            int ij = i4 + ans.getColumnSize() * j4;
            int ji = j4 + ans.getColumnSize() * i4;
            ans.denseElements[ij] = ans.denseElements[ij].add(value4);
            ans.denseElements[ji] = ans.denseElements[ji].add(value4);
          } else {
            int ii = i4 + ans.getColumnSize() * i4;
            ans.denseElements[ii] = ans.denseElements[ii].add(value4);
          }
        }
        return ans;
      case DENSE:
File Line
org/mklab/sdpj/algebra/Algebra.java 2548
org/mklab/sdpj/algebra/Algebra.java 2575
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2682
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2709
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockVector<RS,RM,CS,CM> plus(BlockVector<RS,RM,CS,CM> a, BlockVector<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    RS unit = a.getElementUnit();
    BlockVector<RS,RM,CS,CM> ans = new BlockVector<>(a.getBlockSize(), a.getBlockStructs(), unit);

    for (int i = 0; i < a.getBlockSize(); ++i) {
      Vector<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i), scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 2885
org/mklab/sdpj/algebra/Algebra.java 2913
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3019
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3047
        BlockDenseMatrix<RS,RM,CS,CM> ans = multiply(a, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param operator 演算子
   * @param b b
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> let(Vector<RS,RM,CS,CM> a, final char operator, Vector<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 3084
org/mklab/sdpj/algebra/Algebra.java 3115
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3218
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3249
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(DenseMatrix<RS,RM,CS,CM> a, final char operator, SparseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 3148
org/mklab/sdpj/algebra/Algebra.java 3188
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3282
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3322
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' 't' 'T' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 3228
org/mklab/sdpj/algebra/Algebra.java 3259
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3362
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3393
        ans = multiply_tran(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockSparseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 3291
org/mklab/sdpj/algebra/Algebra.java 3323
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3425
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3457
        ans = multiply(a, b);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockSparseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlatrd.java 340
org/mklab/sdpj/gpack/lapackwrap/Dsytd2.java 332
  }

  /**
   * @param n n
   * @param alpha a[?]
   * @param xIndex a
   * @param incx indx
   * @param tau tau
   * @return result
   */
  private RS[] dlarfg(int n, RS alpha, int xIndex, int incx, RS tau) {
    final RS unit = alpha.createUnit();
    RS[] x = unit.createArray(this.a.length - xIndex);
    System.arraycopy(this.a, xIndex, x, 0, x.length);
    RS[] ans = Clapack.dlarfg(n, alpha, x, incx, tau);
    System.arraycopy(x, 0, this.a, xIndex, x.length);
    return ans;
  }
File Line
org/mklab/sdpj/algebra/Algebra.java 1284
org/mklab/sdpj/algebra/Algebra.java 1333
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1418
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1467
      Vector<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 2584
org/mklab/sdpj/algebra/Algebra.java 2740
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2718
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2874
      Vector<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1924
org/mklab/sdpj/algebra/Algebra.java 2036
org/mklab/sdpj/algebra/Algebra.java 2263
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2058
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2170
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2397
          RS value1 = a.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].add(value1);
            ans.denseElements[ji] = ans.denseElements[ji].add(value1);
          } else {
            int ii = i1 + ans.getColumnSize() * i1;
            ans.denseElements[ii] = ans.denseElements[ii].add(value1);
          }
          int i2 = a.rowIndex[index + 1];
File Line
org/mklab/sdpj/algebra/Algebra.java 1936
org/mklab/sdpj/algebra/Algebra.java 2048
org/mklab/sdpj/algebra/Algebra.java 2275
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2070
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2182
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2409
          RS value2 = a.getSparseElement(index + 1);
          if (i2 != j2) {
            int ij = i2 + ans.getColumnSize() * j2;
            int ji = j2 + ans.getColumnSize() * i2;
            ans.denseElements[ij] = ans.denseElements[ij].add(value2);
            ans.denseElements[ji] = ans.denseElements[ji].add(value2);
          } else {
            int ii = i2 + ans.getColumnSize() * i2;
            ans.denseElements[ii] = ans.denseElements[ii].add(value2);
          }
          int i3 = a.rowIndex[index + 2];
File Line
org/mklab/sdpj/algebra/Algebra.java 1948
org/mklab/sdpj/algebra/Algebra.java 2060
org/mklab/sdpj/algebra/Algebra.java 2287
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2082
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2194
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2421
          RS value3 = a.getSparseElement(index + 2);
          if (i3 != j3) {
            int ij = i3 + ans.getColumnSize() * j3;
            int ji = j3 + ans.getColumnSize() * i3;
            ans.denseElements[ij] = ans.denseElements[ij].add(value3);
            ans.denseElements[ji] = ans.denseElements[ji].add(value3);
          } else {
            int ii = i3 + ans.getColumnSize() * i3;
            ans.denseElements[ii] = ans.denseElements[ii].add(value3);
          }
          int i4 = a.rowIndex[index + 3];
File Line
org/mklab/sdpj/gpack/lapackwrap/Dlasr.java 165
org/mklab/sdpj/gpack/lapackwrap/Dlasr.java 179
            if (!ctemp.isUnit() || stemp.isZero()) {
              for (int i = 1; i <= n; ++i) {
                int p1 = i * a_dim1 + j + pointer_a;
                int p2 = i * a_dim1 + j + 1 + pointer_a;
                RS temp = a[p2];
                a[p2] = (ctemp.multiply(temp)).subtract(stemp.multiply(a[p1]));
                a[p1] = (stemp.multiply(temp)).add(ctemp.multiply(a[p1]));
              }
            }
          }
        } else if (BLAS.lsame(direct, "B")) { //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 2584
org/mklab/sdpj/algebra/Algebra.java 2636
org/mklab/sdpj/algebra/Algebra.java 2714
org/mklab/sdpj/algebra/Algebra.java 2793
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2718
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2770
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2848
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2927
      Vector<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 366
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 456
      return (RS)result.toMPFloatWithDefaultPrecision();
    }
    for (int i = 0; i < a.getBlockSize(); ++i) {
      ans = ans.add(getInnerProduct(a.getBlock(i), b.getBlock(i)));
    }
    return ans;
  }

  /**
   * 内積の計算を行います。 Al.getInnerProduct(ret,aVec,bVec)をret=Al.getInnerProduct(aVec,bVec)に変更。
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 内積
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> RS getInnerProduct(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/gpack/blaswrap/BLAS.java 133
org/mklab/sdpj/gpack/blaswrap/BLAS.java 449
    return new Ddot<RS,RM,CS,CM>().ddot(n, dx, incx, dy, incy);
  }

  /**
   * C := alpha*op(A)*op(B)+beta*C
   * 
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param transa transa
   * @param transb transb
   * @param m op(A)とCの列数
   * @param n op(B)とCの行数
   * @param k op(A)の行数と op(B)の列数
   * @param alpha alpha
   * @param a a
   * @param lda transa = 'n' then max(1,m),otherwise max(1,k)
   * @param b b
   * @param ldb transb = 'n' then max(1,k), otherwise max(1,n)
   * @param beta beta
   * @param c c
   * @param ldc max(1,m)
   * @return result
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> int dgemm(String transa, String transb, int m, int n, int k, RS alpha, RS[] a, int lda, RS[] b, int ldb, RS beta, RS[] c, int ldc) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dpotf2.java 88
org/mklab/sdpj/gpack/lapackwrap/Dpotrf.java 85
    RS c_b12 = unit.create(1);

    int a_dim1 = lda;
    int a_offset = 1 + a_dim1 * 1;
    int pointer_a = -a_offset;

    /* Function Body */
    int info = 0;
    boolean upper = BLAS.lsame(uplo, "U"); //$NON-NLS-1$
    if (!upper && !BLAS.lsame(uplo, "L")) { //$NON-NLS-1$
      info = -1;
    } else if (n < 0) {
      info = -2;
    } else if (lda < Math.max(1, n)) {
      info = -4;
    }

    if (info != 0) {
      BLAS.xerbla("DPOTF2", -info); //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 728
org/mklab/sdpj/algebra/Algebra.java 813
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 862
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 947
          ans.diagonalElements[j + 3] = a.diagonalElements[j + 3].multiply(b.diagonalElements[j + 3]);
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * Dense=Sparse*Dense
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(SparseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 898
org/mklab/sdpj/algebra/Algebra.java 985
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1032
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1119
          ans.diagonalElements[j + 3] = a.getDiagonalElement(j + 3).multiply(b.diagonalElements[j + 3]);
        }
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * TODO MULTIPLY_NON_ATLASがFalseの場合でやるのもいいかも。 falseの場合でやると、配列のコピーの回数がここの分だけ減る。 Dense=Dense*Sparse
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> multiply(DenseMatrix<RS,RM,CS,CM> a, SparseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1284
org/mklab/sdpj/algebra/Algebra.java 1309
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1418
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1443
      Vector<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1301
org/mklab/sdpj/algebra/Algebra.java 1399
org/mklab/sdpj/algebra/Algebra.java 1423
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1435
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1533
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1557
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i), scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 1333
org/mklab/sdpj/algebra/Algebra.java 1358
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1467
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1492
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1350
org/mklab/sdpj/algebra/Algebra.java 1374
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1484
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1508
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(b.getBlockSize(), b.getBlockStructs(), b.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i), scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 1382
org/mklab/sdpj/algebra/Algebra.java 1407
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1516
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1541
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockSparseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1540
org/mklab/sdpj/algebra/Algebra.java 1564
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1674
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1698
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> tran_multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = tran_multiply(a.getBlock(i), b.getBlock(i), scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 1899
org/mklab/sdpj/algebra/Algebra.java 2011
org/mklab/sdpj/algebra/Algebra.java 2123
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2033
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2145
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2257
          throw new RuntimeException("plus :: different matrix type"); //$NON-NLS-1$
        }

        int shou = a.nonZeroCount / 4;
        int amari = a.nonZeroCount % 4;
        for (int index = 0; index < amari; ++index) {
          int i = a.rowIndex[index];
          int j = a.columnIndex[index];
          RS value = a.getSparseElement(index);
          if (i != j) {
            int ij = i + ans.getColumnSize() * j;
            int ji = j + ans.getColumnSize() * i;
            ans.denseElements[ij] = ans.denseElements[ij].add(value);
File Line
org/mklab/sdpj/algebra/Algebra.java 2584
org/mklab/sdpj/algebra/Algebra.java 2611
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2718
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2745
      Vector<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 2603
org/mklab/sdpj/algebra/Algebra.java 2629
org/mklab/sdpj/algebra/Algebra.java 2759
org/mklab/sdpj/algebra/Algebra.java 2785
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2737
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2763
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2893
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2919
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i), scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 2661
org/mklab/sdpj/algebra/Algebra.java 2688
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2795
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2822
      DenseMatrix<RS,RM,CS,CM> blockAns = minus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans = a + b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 2680
org/mklab/sdpj/algebra/Algebra.java 2706
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2814
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2840
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockSparseMatrix<RS,RM,CS,CM> a, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("plus:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(b.getBlockSize(), b.getBlockStructs(), b.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = plus(a.getBlock(i), b.getBlock(i), scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 2740
org/mklab/sdpj/algebra/Algebra.java 2767
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2874
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2901
      DenseMatrix<RS,RM,CS,CM> blockAns = minus(a.getBlock(i), b.getBlock(i));
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * ans + a * b*scalar
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> plus(BlockDenseMatrix<RS,RM,CS,CM> a, BlockSparseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 2963
org/mklab/sdpj/algebra/Algebra.java 3169
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3097
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3303
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
      case 't':
        // ret = aMat**T * bMat
        ans = tran_multiply(a, b, scalar);
        return ans;
      case 'T':
        // ret = aMat * bMat**T
        ans = multiply_tran(a, b, scalar);
        return ans;
      default:
        throw new IllegalArgumentException("let:: operator error"); //$NON-NLS-1$
File Line
org/mklab/sdpj/algebra/Algebra.java 3188
org/mklab/sdpj/algebra/Algebra.java 3323
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3322
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3457
        ans = multiply_tran(a, b, scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' 't' 'T' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/iocenter/SolverIO.java 358
org/mklab/sdpj/iocenter/SolverIO.java 363
        this.Display.printf("%2d  %s  %s  %s  %s  %s  %s  %s  %s\n", this.pIteration, this.mu.getValue().toString(), this.theta.getPrimal().toString(), this.theta.getDual().toString(), //$NON-NLS-1$
            this.solveInfo.getObjValPrimal().toString(), this.solveInfo.getObjValDual().toString(), this.alpha.getPrimal().toString(), this.alpha.getDual().toString(),
            this.beta.getValue().toString());
      }
File Line
org/mklab/sdpj/algebra/Algebra.java 1115
org/mklab/sdpj/algebra/Algebra.java 1150
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1249
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1284
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), scalar);
      ans.setBlock(i, blockAns);
    }

    return ans;
  }

  /**
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a a
   * @param scalar スカラー
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> Vector<RS,RM,CS,CM> multiply(Vector<RS,RM,CS,CM> a, RS scalar) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1399
org/mklab/sdpj/algebra/Algebra.java 1540
org/mklab/sdpj/algebra/Algebra.java 1682
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1533
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1674
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1816
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> multiply(BlockDenseMatrix<RS,RM,CS,CM> a, BlockSparseMatrix<RS,RM,CS,CM> b, RS scalar) {
    if (a.getBlockSize() != b.getBlockSize()) {
      throw new RuntimeException("multiply:: different nBlock size"); //$NON-NLS-1$
    }

    BlockDenseMatrix<RS,RM,CS,CM> ans = new BlockDenseMatrix<>(a.getBlockSize(), a.getBlockStructs(), a.getUnit());

    for (int i = 0; i < a.getBlockSize(); ++i) {
      DenseMatrix<RS,RM,CS,CM> blockAns = multiply(a.getBlock(i), b.getBlock(i), scalar);
File Line
org/mklab/sdpj/algebra/Algebra.java 1801
org/mklab/sdpj/algebra/Algebra.java 2207
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1935
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2341
        BLAS.daxpy(ans.getColumnSize(), scalar, b.diagonalElements, 1, ans.diagonalElements, 1);
        return ans;
      default:
        throw new IllegalArgumentException();
    }
  }

  /**
   * ans = a + b
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param b B
   * @return 解
   */
  private static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> plus(DenseMatrix<RS,RM,CS,CM> a, DenseMatrix<RS,RM,CS,CM> b) {
File Line
org/mklab/sdpj/algebra/Algebra.java 1915
org/mklab/sdpj/algebra/Algebra.java 2027
org/mklab/sdpj/algebra/Algebra.java 2139
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2049
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2161
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2273
            ans.denseElements[ii] = ans.denseElements[ii].add(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = a.rowIndex[index];
          int j1 = a.columnIndex[index];
          RS value1 = a.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].add(value1);
File Line
org/mklab/sdpj/algebra/Algebra.java 2365
org/mklab/sdpj/algebra/Algebra.java 2467
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2499
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 2601
            ans.denseElements[ii] = ans.denseElements[ii].add(value);
          }
        }

        int index;
        int counter;
        for (index = amari, counter = 0; counter < shou; ++counter, index += 4) {
          int i1 = b.rowIndex[index];
          int j1 = b.columnIndex[index];
          RS value1 = b.getSparseElement(index);
          if (i1 != j1) {
            int ij = i1 + ans.getColumnSize() * j1;
            int ji = j1 + ans.getColumnSize() * i1;
            ans.denseElements[ij] = ans.denseElements[ij].add(value1);
File Line
org/mklab/sdpj/algebra/Algebra.java 2962
org/mklab/sdpj/algebra/Algebra.java 3041
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3096
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3175
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(DenseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    DenseMatrix<RS,RM,CS,CM> ans;
    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
File Line
org/mklab/sdpj/algebra/Algebra.java 3168
org/mklab/sdpj/algebra/Algebra.java 3248
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3302
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3382
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> BlockDenseMatrix<RS,RM,CS,CM> let(BlockDenseMatrix<RS,RM,CS,CM> a, final char operator, BlockDenseMatrix<RS,RM,CS,CM> b, RS scalar) {
    BlockDenseMatrix<RS,RM,CS,CM> ans;

    switch (operator) {
      case '+':
        ans = plus(a, b, scalar);
        return ans;
      case '-':
        final RS minus_scalar = scalar.unaryMinus();
        ans = plus(a, b, minus_scalar);
        return ans;
      case '*':
        ans = multiply(a, b, scalar);
        return ans;
File Line
org/mklab/sdpj/gpack/blaswrap/Dgemm.java 129
org/mklab/sdpj/gpack/blaswrap/Dsyr2k.java 133
  int dgemm(String transa, String transb, int m, int n, int k, RS alpha, RS[] a, int lda, RS[] b, int ldb, RS beta, RS[] c, int ldc) {
    final RS unit = a[0].createUnit();

    int a_dim1 = lda;
    int a_offset = 1 + a_dim1 * 1;
    int pointer_a = -a_offset;

    int b_dim1 = ldb;
    int b_offset = 1 + b_dim1 * 1;
    int pointer_b = -b_offset;

    int c_dim1 = ldc;
    int c_offset = 1 + c_dim1 * 1;
    int pointer_c = -c_offset;
File Line
org/mklab/sdpj/algebra/Algebra.java 875
org/mklab/sdpj/algebra/Algebra.java 1047
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1009
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 1181
        if (ans.isDense() == false || b.isDense() == false) {
          throw new RuntimeException("multiply :: different matrix type"); //$NON-NLS-1$
        }
        BLAS.dgemm(
            "NoTranspose", "NoTranspose", ans.getRowSize(), ans.getColumnSize(), a.getColumnSize(), unit.create(1), a.denseElements, a.getRowSize(), b.denseElements, b.getRowSize(), unit.create(0), ans.denseElements, //$NON-NLS-1$ //$NON-NLS-2$
            ans.getRowSize());
        return ans;
      case DIAGONAL:
        if (ans.isDiagonal() == false || b.isDiagonal() == false) {
File Line
org/mklab/sdpj/algebra/Algebra.java 2939
org/mklab/sdpj/algebra/Algebra.java 3084
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3073
org/mklab/sdpj/algebra/AlgebraWithEFFloat.java 3218
        ans = minus(a, b);
        //final RS unit = a.getElementUnit();
        //final RS minus_scalar = unit.create(-1);
        //ans = plus(a, b, minus_scalar);
        return ans;
      default:
        throw new RuntimeException("let:: operator error"); //$NON-NLS-1$
    }
  }

  /**
   * ans = a '+' '-' '*' 't' 'T' b*(*scalar)
   * 
   * @param <RS> type of real scalar
   * @param <RM> type of real matrix
   * @param <CS> type of complex scalar
   * @param <CM> type of complex Matrix
   * @param a A
   * @param operator 演算子
   * @param b B
   * @param scalar スカラー
   * @return 解
   */
  public static <RS extends RealNumericalScalar<RS, RM, CS, CM>, RM extends RealNumericalMatrix<RS, RM, CS, CM>, CS extends ComplexNumericalScalar<RS, RM, CS, CM>, CM extends ComplexNumericalMatrix<RS, RM, CS, CM>> DenseMatrix<RS,RM,CS,CM> let(DenseMatrix<RS,RM,CS,CM> a, final char operator, DenseMatrix<RS,RM,CS,CM> b, RS scalar) {
File Line
org/mklab/sdpj/gpack/lapackwrap/Dorgtr.java 291
org/mklab/sdpj/gpack/lapackwrap/Dorgtr.java 732
    if (m < 0) {
      info = -1;
    } else if (n < 0 || n > m) {
      info = -2;
    } else if (k < 0 || k > n) {
      info = -3;
    } else if (lda < Math.max(1, m)) {
      info = -5;
    } else if (lwork < Math.max(1, n) && !lquery) {
      info = -8;
    }
    if (info != 0) {
      BLAS.xerbla("DORGQL", -info); //$NON-NLS-1$