Clapack.java

package org.mklab.sdpj.gpack.lapackwrap;

import org.mklab.nfc.matrix.ComplexNumericalMatrix;
import org.mklab.nfc.matrix.RealNumericalMatrix;
import org.mklab.nfc.scalar.ComplexNumericalScalar;
import org.mklab.nfc.scalar.RealNumericalScalar;


/**
 * @author koga
 * @version $Revision$, 2009/04/24
 */
public class Clapack {
  private static DlamchWrapper dlamchWrapper; 

  /**
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param ispec ispec
   * @param name name
   * @param opts opts
   * @param n1 n1
   * @param n2 n2
   * @param n3 n3
   * @param n4 n4
   * @param name_len name_len
   * @param opts_len opts_len
   * @param unit unit
   * @return ilaenv
   */
  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 ilaenv(
      int ispec, String name, String opts, int n1, int n2, int n3, int n4, int name_len, int opts_len, RS unit) {
    return new Ilaenv<RS,RM,CS,CM>().execute(ispec, name, opts, n1, n2, n3, n4, name_len, opts_len, unit);
  }

  /**
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param uplo uplo
   * @param n n
   * @param a a
   * @param lda lda
   * @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 dpotrf(
      String uplo, int n, RS[] a, int lda) {
    return new Dpotrf<RS,RM,CS,CM>().execute(uplo, n, a, lda);
  }

  /**
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param uplo uplo
   * @param n n
   * @param a a
   * @param lda lda
   * @return dpotf2
   */
  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 dpotf2(
      String uplo, int n, RS[] a, int lda) {
    return new Dpotf2<RS,RM,CS,CM>().execute(uplo, n, a, lda);
  }

  /**
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param compz compz
   * @param n n
   * @param d d
   * @param e e
   * @param z z
   * @param ldz ldz
   * @param work work
   * @return dsteqr
   */
  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 dsteqr(
      String compz, int n, RS[] d, RS[] e, RS[] z, int ldz, RS[] work) {
    return new Dsteqr<RS,RM,CS,CM>().execute(compz, n, d, e, z, ldz, work);
  }

  /**
   * 実対称行列のすべての固有値と固有ベクトルを求める
   * 
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param jobz jobz
   * @param uplo uplo
   * @param n n
   * @param a a
   * @param lda lda
   * @param w w
   * @param work work
   * @param lwork lwork
   * @return dsyev
   */
  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 dsyev(
      String jobz, String uplo, int n, RS[] a, int lda, RS[] w, RS[] work, int lwork) {
    return new Dsyev<RS,RM,CS,CM>().execute(jobz, uplo, n, a, lda, w, work, lwork);
  }

  /**
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param uplo uplo
   * @param n n
   * @param a a
   * @param lda lda
   * @param tau tau
   * @param work work
   * @param lwork lwork
   * @return dorgtr
   */
  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 dorgtr(
      String uplo, int n, RS[] a, int lda, RS[] tau, RS[] work, int lwork) {
    return new Dorgtr<RS,RM,CS,CM>().execute(uplo, n, a, lda, tau, work, lwork);
  }

  /**
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param n n
   * @param d d
   * @param e e
   * @return dsterf
   */
  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 dsterf(
      int n, RS[] d, RS[] e) {
    return new Dsterf<RS,RM,CS,CM>().execute(n, d, e);
  }

  /**
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param uplo uplo
   * @param n n
   * @param a a
   * @param lda lda
   * @param d d
   * @param e e
   * @param tau tau
   * @param work work
   * @param lwork lwork
   * @return dsytrd
   */
  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 dsytrd(
      String uplo, int n, RS[] a, int lda, RS[] d, RS[] e, RS[] tau, RS[] work, int lwork) {
    return new Dsytrd<RS,RM,CS,CM>().execute(uplo, n, a, lda, d, e, tau, work, lwork);
  }

  //  /**
  //   * @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 uplo uplo
  //   * @param n n
  //   * @param a a
  //   * @param lda lda
  //   * @param d d
  //   * @param e e
  //   * @param tau tau
  //   * @param work work
  //   * @param lwork lwork
  //   * @return dsytrd
  //   */
  //  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 dsytrd(
  //      String uplo, int n, RS[] a, int lda, RS[] d, RS[] e, RS[] tau, RS[] work, int lwork) {
  //    return new Dsytrd<RS,RM,CS,CM>().execute(uplo, n, a, lda, d, e, tau, work, lwork);
  //  }

  /**
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param norm norm
   * @param uplo uplo
   * @param n n
   * @param a a
   * @param lda lda
   * @param work work
   * @return dlansy
   */
  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 dlansy(
      String norm, String uplo, int n, RS[] a, int lda, RS[] work) {
    RS value = new Dlansy<RS,RM,CS,CM>().execute(norm, uplo, n, a, lda, work);
    return value;
  }

  /**
   * @param <RS> 実スカラーの型
   * @param <RM> 実行列の型
   * @param <CS> 複素スカラーの型
   * @param <CM> 複素行列の型
   * @param type type
   * @param kl kl
   * @param ku ku
   * @param cfrom cform
   * @param cto cto
   * @param m m
   * @param n2 n2
   * @param a a
   * @param lda lda
   * @return dlascl
   */
  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 dlascl(
      String type, int kl, int ku, RS cfrom, RS cto, int m, int n2, RS[] a, int lda) {
    return new Dlascl<RS,RM,CS,CM>().execute(type, kl, ku, cfrom, cto, m, n2, a, lda);
  }

  /**
   * @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 string string
   * @param unit RS
   * @return dlmach
   */
  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 dlamch(
      String string, RS unit) {
    if (Clapack.dlamchWrapper == null) {
      DlamchWrapper<RS, RM, CS, CM> wrapper = new DlamchWrapper<>();
      Clapack.dlamchWrapper = wrapper;
    }
    
    return (RS)Clapack.dlamchWrapper.execute(string, unit);
  }

  /**
   * @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 x x
   * @param y y
   * @return dlapy2
   */
  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 dlapy2(
      RS x, RS y) {
    return new Dlapy2<RS,RM,CS,CM>().execute(x, y);
  }

  /**
   * @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 f f
   * @param g g
   * @return dlartg
   */
  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[] dlartg(
      RS f, RS g) {
    return new Dlartg<>(f).execute(f, g);
  }

  /**
   * @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 c c
   * @return dlaev2
   */
  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[] dlaev2(
      RS a, RS b, RS c) {
    return new Dlaev2<RS,RM,CS,CM>().execute(a, b, c);
  }

  /**
   * @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 c c
   * @return dlae2
   */
  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[] dlae2(
      RS a, RS b, RS c) {
    RS[] temp = new Dlae2<RS,RM,CS,CM>().execute(a, b, c);
    return temp;
  }

  /**
   * @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 uplo uplo
   * @param n n
   * @param a a
   * @param lda lda
   * @param d d
   * @param e e
   * @param tau tau
   * @return dsytd2
   */
  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 dsytd2(
      String uplo, int n, RS[] a, int lda, RS[] d, RS[] e, RS[] tau) {
    return new Dsytd2<RS,RM,CS,CM>().execute(uplo, n, a, lda, d, e, tau);
  }

  /**
   * @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 uplo uplo
   * @param n n
   * @param nb nb
   * @param a a
   * @param lda lda
   * @param e e
   * @param tau tau
   * @param w w
   * @param ldw ldw
   * @return dlatrd
   */
  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 dlatrd(
      String uplo, int n, int nb, RS[] a, int lda, RS[] e, RS[] tau, RS[] w, int ldw) {
    return new Dlatrd<RS,RM,CS,CM>().execute(uplo, n, nb, a, lda, e, tau, w, ldw);
  }

  /**
   * @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 n input
   * @param x input
   * @param incx input
   * @param scale input/output
   * @param sumsq input/output
   * @return dlassq
   */
  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[] dlassq(
      int n, RS[] x, int incx, RS scale, RS sumsq) {
    return new Dlassq<RS,RM,CS,CM>().execute(n, x, incx, scale, sumsq);
  }

  /**
   * @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 norm input
   * @param n input
   * @param d input
   * @param e input
   * @return dlanst
   */
  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 dlanst(
      String norm, int n, RS[] d, RS[] e) {
    return new Dlanst<RS,RM,CS,CM>().execute(norm, n, d, e);
  }

  /**
   * @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 n n
   * @param alpha alpha
   * @param x x
   * @param incx incx
   * @param tau tau
   * @return dlarfg
   */
  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[] dlarfg(
      int n, RS alpha, RS[] x, int incx, RS tau) {
    return new Dlarfg<RS,RM,CS,CM>().execute(n, alpha, x, incx, tau);
  }

  /**
   * @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 id id
   * @param n n
   * @param d d
   * @return dlasrt
   */
  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 dlasrt(
      String id, int n, RS[] d) {
    return new Dlasrt<RS,RM,CS,CM>().execute(id, n, d);
  }

  /**
   * @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 uplo uplo
   * @param m m
   * @param n n
   * @param alpha alpha
   * @param beta beta
   * @param a a
   * @param lda lda
   * @return dlaset
   */
  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 dlaset(
      String uplo, int m, int n, RS alpha, RS beta, RS[] a, int lda) {
    return new Dlaset<RS,RM,CS,CM>().execute(uplo, m, n, alpha, beta, a, lda);
  }

  /**
   * @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 side input
   * @param pivot input
   * @param direct input
   * @param m input
   * @param n input
   * @param c input
   * @param s input
   * @param a input/output
   * @param lda input
   * @return dlasr
   */
  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 dlasr(
      String side, String pivot, String direct, int m, int n, RS[] c, RS[] s, RS[] a, int lda) {
    return new Dlasr<RS,RM,CS,CM>().execute(side, pivot, direct, m, n, c, s, a, lda);
  }

  /**
   * @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 side side
   * @param trans trans
   * @param direct direct
   * @param storev storev
   * @param m m
   * @param n n
   * @param k k
   * @param vin vin
   * @param ldv ldv
   * @param tin tin
   * @param ldt ldt
   * @param c__in c__in
   * @param ldc ldc
   * @param workin workin
   * @param ldwork ldwork
   * @return dlarfb
   */
  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 dlarfb(
      String side, String trans, String direct, String storev, int m, int n, int k, RS[] vin, int ldv, RS[] tin, int ldt, RS[] c__in, int ldc, RS[] workin, int ldwork) {
    return new Dlarfb<RS,RM,CS,CM>().execute(side, trans, direct, storev, m, n, k, vin, ldv, tin, ldt, c__in, ldc, workin, ldwork);
  }
}