Exemple #1
0
 public static RInt expandXVector(IntImpl xarg, int xsize, int count) {
     int nsize = xsize * count;
     int[] x = xarg.getContent();
     int[] res = new int[nsize];
     int offset = 0;
     for (int rep = 0; rep < count; rep++) {
         System.arraycopy(x, 0, res, offset, xsize);
         offset += xsize;
     }
     return RInt.RIntFactory.getFor(res);
 }
Exemple #2
0
    public static RInt expandYVector(IntImpl yarg, int ysize, int count) {
        int size = ysize;
        int nsize = size * count;
        int[] y = yarg.getContent();

        int[] res = new int[nsize];
        int offset = 0;
        for (int elem = 0; elem < size; elem++) {
            int v = y[elem];
            Arrays.fill(res, offset, offset + count, v);
            offset += count;
        }
        return RInt.RIntFactory.getFor(res);
    }
Exemple #3
0
 // an attempt for performance improvement: but does not seem faster for now
 public static RInt expandXVectorCacheFriendly(IntImpl xarg, int xsize, int count) {
     int nsize = xsize * count;
     int[] x = xarg.getContent();
     int[] res = new int[nsize];
     int offset = 0;
     int rep = 0;
     int lastOffset = 0;
     if (rep < count) {
         System.arraycopy(x, 0, res, offset, xsize);
         lastOffset = offset;
         offset += xsize;
     }
     for (rep = 1; rep < count; rep++) {
         System.arraycopy(res, lastOffset, res, offset, xsize);
         lastOffset = offset;
         offset += xsize;
     }
     return RInt.RIntFactory.getFor(res);
 }