Package org.renjin.eval

Examples of org.renjin.eval.EvalException


    return s.asReal();
  }


  public static void error(String message, Object... args) {
    throw new EvalException(String.format(message, args));
  }
View Full Code Here


    public final String getName() {
      return name;
    }

    public SEXP query(GraphicsDevice dd) {
      throw new EvalException("implement me: " + getName());
    }
View Full Code Here

    public SEXP query(GraphicsDevice dd) {
      throw new EvalException("implement me: " + getName());
    }

    public void specify(Context context, GraphicsDevice dd, SEXP exp) {
      throw new EvalException("implement me" + getName());
    }
View Full Code Here

      specify(context, dd, null);
    }

    protected final Color toColor(Context context, GraphicsDevice dd, SEXP exp) {
      if(!(exp instanceof Vector) || exp.length() < 1) {
        throw new EvalException("invalid rgb specification: " + exp.toString());
      }
      return Color.fromExp(context.getSession().getSingleton(ColorPalette.class),
                           dd.getParameters().getBackground(),
                            (Vector)exp, 0);
    }
View Full Code Here

                            (Vector)exp, 0);
    }
   
    protected final double toDouble(SEXP exp) {
      if(!(exp instanceof Vector) || exp.length() < 1) {
        throw new EvalException("invalid par value for '%s'", getName());
      }
      return ((Vector)exp).getElementAsDouble(0);
    }
View Full Code Here

   */
  @DotCall()
  public static DoubleVector chol2inv(DoubleVector a, int sz) {

    if(IntVector.isNA(sz) || sz < 1) {
      throw new EvalException("'size' argument must be a positive integer");
    }

    int m = 1, n = 1;

    if (sz == 1 && !Types.isMatrix(a)) {
      /* nothing to do; m = n = 1; ... */
      return a;

    } else if (Types.isMatrix(a)) {
      Vector adims = a.getAttributes().getDim();
      m = adims.getElementAsInt(0);
      n = adims.getElementAsInt(1);
    } else {
      throw new EvalException("'a' must be a numeric matrix");
    }

    if (sz > n) {
      throw new EvalException("'size' cannot exceed ncol(x) = %d", n);
    }
    if (sz > m) {
      throw new EvalException("'size' cannot exceed nrow(x) = %d", m);
    }
   
    double result[] = new double[sz * sz];
    for (int j = 0; j < sz; j++) {
      for (int i = 0; i <= j; i++) {
        result[i + j * sz] = a.getElementAsDouble(i + j * m);
      }
    }
   
    intW resultCode = new intW(0);
    LAPACK.getInstance().dpotri("Upper", sz, result, sz, resultCode);
   
    if (resultCode.val != 0) {
      if (resultCode.val > 0) {
        throw new EvalException("element (%d, %d) is zero, so the inverse cannot be computed",
            resultCode.val, resultCode.val);
      } else {
        throw new EvalException("argument %d of Lapack routine %s had invalid value", -resultCode.val, "dpotri");
      }
    }
   
    for (int j = 0; j < sz; j++) {
      for (int i = j+1; i < sz; i++) {
View Full Code Here

    int lwork = -1;
    intW info = new intW(0);
    lapack.dgesdd(jobu, n, p, xvals, n,  s, u, ldu, v, ldvt, tmp, lwork, iwork, info);
   
    if (info.val != 0) {
      throw new EvalException("error code %d from Lapack routine '%s'", info.val, "dgesdd");
    }
    
    lwork = (int) tmp[0];
    double work[] = new double[lwork];
   
View Full Code Here

  public static SEXP dgesv(DoubleVector A, DoubleVector B, double tolerance) {
    double anorm;
    doubleW rcond = new doubleW(0);

    if (!Types.isMatrix(A)) {
      throw new EvalException("'a' must be a numeric matrix");
    }
    if (!Types.isMatrix(B)) {
      throw new EvalException("'b' must be a numeric matrix");
    }
   
    Vector Adims = A.getAttributes().getDim();
    Vector Bdims = B.getAttributes().getDim();

    int n = Adims.getElementAsInt(0);
    if (n == 0) {
      throw new EvalException("'a' is 0-diml");
    }
    int p = Bdims.getElementAsInt(1);
    if (p == 0) {
      throw new EvalException("no right-hand side in 'b'");
    }
    if (Adims.getElementAsInt(1) != n) {
      throw new EvalException("'a' (" + n + " x " + Adims.getElementAsInt(1) + ") must be square");
    }
    if (Bdims.getElementAsInt(0) != n) {
      throw new EvalException("'b' (" + Bdims.getElementAsInt(0) + " x " + p + ") must be compatible with 'a' (" + n + " x " + n + ")");
    }

    int ipiv[] = new int[n];
    double avals[] = A.toDoubleArray();
   
    LAPACK lapack = LAPACK.getInstance();
    intW info = new intW(0);
   
    double[] result = B.toDoubleArray();
   
    lapack.dgesv(n, p, avals, n, ipiv, result, n, info);

    if (info.val < 0) {
      throw new EvalException("argument -" + info.val + " of Lapack routine 'dgsv' had invalid value");
    }
    if (info.val > 0) {
      throw new EvalException("Lapack routine dgesv: system is exactly singular");
    }

    anorm = lapack.dlange("1", n, n, A.toDoubleArray(), n, null);

    double[] arrWork = new double[4 * n];
    lapack.dgecon("1", n, avals, n, anorm, rcond, arrWork, ipiv, info);

    if (rcond.val < tolerance) {
      throw new EvalException("system is computationally singular: reciprocal condition number = " + rcond.val);
    }
    return DoubleArrayVector.unsafe(result, B.getAttributes());
  }
View Full Code Here

    lapack.dsyevr(jobv, range, uplo, n, rx, n,
                       vl, vu, il, iu, abstol, m, rvalues,
                       rz, n, isuppz,
                       tmp, lwork, itmp, liwork, info);
      if (info.val != 0)
        throw new EvalException("error code %d from Lapack routine '%s'", info, "dsyevr");
     
      lwork = (int) tmp[0];
      liwork = itmp[0];
 
      double work[] new double[lwork];
      int iwork[] = new int[liwork];

      lapack.dsyevr(jobv, range, uplo, n, rx, n,
                       vl, vu, il, iu, abstol, m, rvalues,
                       rz, n, isuppz,
                       work, lwork, iwork, liwork, info);
      if (info.val != 0)
        throw new EvalException("error code %d from Lapack routine '%s'", info, "dsyevr");
 
      ListVector.NamedBuilder ret = ListVector.newNamedBuilder();
      ret.add("values", new DoubleArrayVector(rvalues));
      if (!ov) {
        ret.add("vectors", DoubleArrayVector.newMatrix(rz, n, n));
View Full Code Here

  @Override
  public MemberBinding getMemberBinding(Symbol name) {
    MemberBinding memberBinding = members.get(name);
    if(memberBinding == null) {
      throw new EvalException("Instance of class %s has no member named '%s'",
          getBoundClass().getName(), name.getPrintName());
    }
    return memberBinding;
  }
View Full Code Here

TOP

Related Classes of org.renjin.eval.EvalException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.