Example #1
0
 // doesn't currently guard under/overflow
 static long float32_pack(float val) {
   int sign = 0;
   int exp;
   int mant;
   if (val < 0) {
     sign = 0x80000000;
     val = -val;
   }
   exp = (int) Math.floor(Math.log(val) / Math.log(2));
   mant = (int) Math.rint(Math.pow(val, (VQ_FMAN - 1) - exp));
   exp = (exp + VQ_FEXP_BIAS) << VQ_FMAN;
   return (sign | exp | mant);
 }
Example #2
0
  Object look(DspState vd, InfoMode vm, Object vr) {
    InfoResidue0 info = (InfoResidue0) vr;
    LookResidue0 look = new LookResidue0();
    int acc = 0;
    int dim;
    int maxstage = 0;
    look.info = info;
    look.map = vm.mapping;

    look.parts = info.partitions;
    look.fullbooks = vd.fullbooks;
    look.phrasebook = vd.fullbooks[info.groupbook];

    dim = look.phrasebook.dim;

    look.partbooks = new int[look.parts][];

    for (int j = 0; j < look.parts; j++) {
      int i = info.secondstages[j];
      int stages = Util.ilog(i);
      if (stages != 0) {
        if (stages > maxstage) maxstage = stages;
        look.partbooks[j] = new int[stages];
        for (int k = 0; k < stages; k++) {
          if ((i & (1 << k)) != 0) {
            look.partbooks[j][k] = info.booklist[acc++];
          }
        }
      }
    }

    look.partvals = (int) Math.rint(Math.pow(look.parts, dim));
    look.stages = maxstage;
    look.decodemap = new int[look.partvals][];
    for (int j = 0; j < look.partvals; j++) {
      int val = j;
      int mult = look.partvals / look.parts;
      look.decodemap[j] = new int[dim];

      for (int k = 0; k < dim; k++) {
        int deco = val / mult;
        val -= deco * mult;
        mult /= look.parts;
        look.decodemap[j][k] = deco;
      }
    }
    return (look);
  }