コード例 #1
0
    public RRaw op(RRaw a, RRaw b, ASTNode ast) {
      int na = a.size();
      int nb = b.size();
      int[] dimensions = Arithmetic.resultDimensions(ast, a, b);
      Names names = Arithmetic.resultNames(ast, a, b);
      if (na == 0 || nb == 0) {
        return RRaw.EMPTY;
      }

      int n = (na > nb) ? na : nb;
      byte[] content = new byte[n];
      int ai = 0;
      int bi = 0;

      for (int i = 0; i < n; i++) {
        byte araw = a.getRaw(ai++);
        if (ai == na) {
          ai = 0;
        }
        byte braw = b.getRaw(bi++);
        if (bi == nb) {
          bi = 0;
        }
        content[i] = op(araw, braw);
      }

      if (ai != 0 || bi != 0) {
        RContext.warning(ast, RError.LENGTH_NOT_MULTI);
      }
      return RRaw.RRawFactory.getFor(content, dimensions, names);
    }
コード例 #2
0
ファイル: RDouble.java プロジェクト: nunb/fastr
 public static RRaw doubleToRaw(
     RDouble value, ConversionStatus warn) { // eager to keep error semantics eager
   int size = value.size();
   byte[] content = new byte[size];
   for (int i = 0; i < size; i++) {
     double dval = value.getDouble(i);
     content[i] = Convert.double2raw(dval, warn);
   }
   return RRaw.RRawFactory.getFor(content, value.dimensions(), value.names());
 }