XY positions of the DUs, given by the DOMs on floor 1.
170058
def xy_positions(self):
        """"""
        if self._xy_positions is None or len(self._xy_positions) == 0:
            xy_pos = []
            for dom_id, pos in self.dom_positions.items():
                if self.domid2floor(dom_id) == 1:
                    xy_pos.append(np.array([pos[0], pos[1]]))
            self._xy_positions = np.array(xy_pos)
        return self._xy_positions
1030638
def x_pos(self, xval):
        ""
        off = self.x_coord.get_canvas_pos(self.size[0], xval,
                                          self.x_range[0], self.x_range[1])
        return self.loc[0] + off
922425
private void calculateOutside(int spanStart, int spanEnd, CfgParseChart chart, double[] newValues) {
    Factor parentOutside = chart.getOutsideEntries(spanStart, spanEnd);
    Tensor parentWeights = parentOutside.coerceToDiscrete().getWeights();

    Tensor binaryDistributionWeights = binaryDistribution.coerceToDiscrete().getWeights();
    int parentIndex = Ints.indexOf(binaryDistributionWeights.getDimensionNumbers(), parentVar.getOnlyVariableNum());
    int leftIndex = Ints.indexOf(binaryDistributionWeights.getDimensionNumbers(), leftVar.getOnlyVariableNum());
    int rightIndex = Ints.indexOf(binaryDistributionWeights.getDimensionNumbers(), rightVar.getOnlyVariableNum());

    int length = newValues.length;
    double[] binaryDistributionValues = binaryDistributionWeights.getValues();
    for (int i = 0; i < spanEnd - spanStart; i++) {
      double[] leftInside = chart.getInsideEntriesArray(spanStart, spanStart + i);
      double[] rightInside = chart.getInsideEntriesArray(spanStart + i + 1, spanEnd);

      for (int j = 0; j < length; j++) {
        newValues[j] = binaryDistributionValues[j] * parentWeights.get(binaryDistributionWeights.indexToPartialDimKey(j, parentIndex));
        newValues[j] *= rightInside[binaryDistributionWeights.indexToPartialDimKey(j, rightIndex)];
      }
      chart.updateOutsideEntry(spanStart, spanStart + i, newValues, binaryDistribution, leftVar);
      
      for (int j = 0; j < length; j++) {
        newValues[j] *= leftInside[binaryDistributionWeights.indexToPartialDimKey(j, leftIndex)];
      }
      chart.updateBinaryRuleExpectations(newValues);

      for (int j = 0; j < length; j++) {
        if (newValues[j] != 0.0) {
          newValues[j] = newValues[j] / rightInside[binaryDistributionWeights.indexToPartialDimKey(j, rightIndex)];
        }
      }
      chart.updateOutsideEntry(spanStart + i + 1, spanEnd, newValues, binaryDistribution, rightVar);
    }
  }
4449
private DoubleMatrix1D rDual(DoubleMatrix1D X, DoubleMatrix1D V, DoubleMatrix1D gradX) {
		if(getA()==null){
			return gradX;
		}
		//return getAT().zMult(V, gradX.copy(), 1., 1, false);
		return ColtUtils.zMult(getAT(), V, gradX, 1);
	}
1321172
private void fillKsubMatrix( Coordinate[] controlPoints, GeneralMatrix L ) {
        double alfa = 0;
        int controlPointsNum = controlPoints.length;
        for( int i = 0; i < controlPointsNum; i++ ) {
            for( int j = i + 1; j < controlPointsNum; j++ ) {
                double u = calculateFunctionU(controlPoints[i], controlPoints[j]);
                L.setElement(i, j, u);
                L.setElement(j, i, u);
                alfa = alfa + (u * 2); // same for upper and lower part
            }
        }

        alfa = alfa / (controlPointsNum * controlPointsNum);
    }
848470
function getPiecesWhereCanIGo(board, positions) {
    return positions.map(position => {
        const { x, y, isBlack } = position;
        return {
            x, y, isBlack,
            whereCanIGo: getPositionsWhereCanIGo(board, position)
        };
    });
}
726614
def mpfr_floordiv(rop, x, y, rnd):
    
    # Algorithm notes
    # ---------------
    # A simple and obvious approach is to compute floor(x / y) exactly, and
    # then round to the nearest representable value using the given rounding
    # mode.  This requires computing x / y to a precision sufficient to ensure
    # that floor(x / y) is exactly representable.  If abs(x / y) < 2**r, then
    # abs(floor(x / y)) <= 2**r, and so r bits of precision is enough.
    # However, for large quotients this is impractical, and we need some other
    # method.  For x / y sufficiently large, it's possible to show that x / y
    # and floor(x / y) are indistinguishable, in the sense that both quantities
    # round to the same value.  More precisely, we have the following theorem:
    #
    # Theorem.  Suppose that x and y are nonzero finite binary floats
    # representable with p and q bits of precision, respectively.  Let R be any
    # of the IEEE 754 standard rounding modes, and choose a target precision r.
    # Write rnd for the rounding operation from Q to precision-r binary floats
    # with rounding mode R.  Write bin(x) for the binade of a nonzero float x.
    #
    # If R is a round-to-nearest rounding mode, and either
    #
    # (1) p <= q + r and |x / y| >= 2^(q + r), or
    # (2) p > q + r and bin(x) - bin(y) >= p
    #
    # then
    #
    #    rnd(floor(x / y)) == rnd(x / y)
    #
    # Conversely, if R is a directed rounding mode, and either
    #
    # (1) p < q + r and |x / y| >= 2^(q + r - 1), or
    # (2) p >= q + r and bin(x) - bin(y) >= p
    #
    # then again
    #
    #    rnd(floor(x / y)) == rnd(x / y).
    #
    # Proof.  See separate notes and Coq proof in the float-proofs
    # repository.
    #
    # Rather than distinguish between the various cases (R directed
    # or not, p large versus p small) above, we use a weaker but
    # simpler amalgamation of the above result:
    #
    # Corollary 1. With x, y, p, q, R, r and rnd as above, if
    #
    #     |x / y| >= 2^max(q + r, p)
    #
    # then
    #
    #     rnd(floor(x / y)) == rnd(x / y).
    #
    # Proof. Note that |x / y| >= 2^p implies bin(x) - bin(y) >= p,
    # so it's enough that |x / y| >= 2^max(p, q + r) in the case of
    # a round-to-nearest mode, and that |x / y| >= 2^max(p, q + r - 1)
    # in the case of a directed rounding mode.

    # In special cases, it's safe to defer to mpfr_div: the result in
    # these cases is always 0, infinity, or nan.
    if not mpfr.mpfr_regular_p(x) or not mpfr.mpfr_regular_p(y):
        return mpfr.mpfr_div(rop, x, y, rnd)

    e = _quotient_exponent(x, y)

    p = mpfr.mpfr_get_prec(x)
    q = mpfr.mpfr_get_prec(y)
    r = mpfr.mpfr_get_prec(rop)

    # If e - 1 >= max(p, q+r) then |x / y| >= 2^(e-1) >= 2^max(p, q+r),
    # so by the above theorem, round(floordiv(x, y)) == round(div(x, y)).
    if e - 1 >= max(p, q + r):
        return mpfr.mpfr_div(rop, x, y, rnd)

    # Slow version: compute to sufficient bits to get integer precision.  Given
    # that 2**(e-1) <= x / y < 2**e, need >= e bits of precision.
    z_prec = max(e, 2)
    z = mpfr.Mpfr_t()
    mpfr.mpfr_init2(z, z_prec)

    # Compute the floor exactly. The division may set the
    # inexact flag, so we save its state first.
    old_inexact = mpfr.mpfr_inexflag_p()
    mpfr.mpfr_div(z, x, y, mpfr.MPFR_RNDD)
    if not old_inexact:
        mpfr.mpfr_clear_inexflag()

    # Floor result should be exactly representable, so any rounding mode will
    # do.
    ternary = mpfr.mpfr_rint_floor(z, z, rnd)
    assert ternary == 0

    # ... and round to the given rounding mode.
    return mpfr.mpfr_set(rop, z, rnd)
813726
def step(self, x, y):
        
        up_left = self.solid(x - 1, y - 1)
        up_right = self.solid(x, y - 1)
        down_left = self.solid(x - 1, y)
        down_right = self.solid(x, y)

        state = 0
        self.prev = self.next
        # which cells are filled?
        if up_left:
            state |= 1
        if up_right:
            state |= 2
        if down_left:
            state |= 4
        if down_right:
            state |= 8

        # what is the next step?
        if state in [1, 5, 13]:
            self.next = self.UP
        elif state in [2, 3, 7]:
            self.next = self.RIGHT
        elif state in [4, 12, 14]:
            self.next = self.LEFT
        elif state in [8, 10, 11]:
            self.next = self.DOWN
        elif state == 6:
            if self.prev == self.UP:
                self.next = self.LEFT
            else:
                self.next = self.RIGHT
        elif state == 9:
            if self.prev == self.RIGHT:
                self.next = self.UP
            else:
                self.next = self.DOWN
        else:
            self.next = self.NOWHERE
        return
405716
function reflexRight(right, p, i0, i1) {
    for(var i=i0; i<i1; ++i) {
      var a = right[i]
      var b = right[i+1]
      if(orient(p, a, b) <= 0) {
        cells.push([p[2], a[2], b[2]])
      } else {
        return i
      }
    }
    return i1
  }
1043500
private void calculateInside(int spanStart, int spanEnd, CfgParseChart chart, double[] newValues) {
    double[] binaryRuleValues = binaryDistributionWeights.getValues();
    
    int leftIndex = Ints.indexOf(binaryDistributionWeights.getDimensionNumbers(), leftVar.getOnlyVariableNum());
    int rightIndex = Ints.indexOf(binaryDistributionWeights.getDimensionNumbers(), rightVar.getOnlyVariableNum());
    
    for (int i = 0; i < spanEnd - spanStart; i++) {
      double[] left = chart.getInsideEntriesArray(spanStart, spanStart + i);
      double[] right = chart.getInsideEntriesArray(spanStart + i + 1, spanEnd);

      for (int j = 0; j < newValues.length; j++) {
        newValues[j] = binaryRuleValues[j] * left[binaryDistributionWeights.indexToPartialDimKey(j, leftIndex)]
            * right[binaryDistributionWeights.indexToPartialDimKey(j, rightIndex)];
      }

      chart.updateInsideEntry(spanStart, spanEnd, i, newValues, binaryDistribution);
    }
  }
169796
def _vertex_one_color_qubo(x_vars):
    
    Q = {}
    for v in x_vars:
        for color in x_vars[v]:
            idx = x_vars[v][color]
            Q[(idx, idx)] = -1

        for color0, color1 in itertools.combinations(x_vars[v], 2):
            idx0 = x_vars[v][color0]
            idx1 = x_vars[v][color1]

            Q[(idx0, idx1)] = 2

    return Q
675863
function GCD_(x,y) {
    var i,xp,yp,A,B,C,D,q,sing,qp;
    if (T.length!=x.length)
      T=dup(x);

    sing=1;
    while (sing) { //while y has nonzero elements other than y[0]
      sing=0;
      for (i=1;i<y.length;i++) //check if y has nonzero elements other than 0
        if (y[i]) {
          sing=1;
          break;
        }
      if (!sing) break; //quit when y all zero elements except possibly y[0]

      for (i=x.length;!x[i] && i>=0;i--);  //find most significant element of x
      xp=x[i];
      yp=y[i];
      A=1; B=0; C=0; D=1;
      while ((yp+C) && (yp+D)) {
        q =Math.floor((xp+A)/(yp+C));
        qp=Math.floor((xp+B)/(yp+D));
        if (q!=qp)
          break;
        t= A-q*C;   A=C;   C=t;    //  do (A,B,xp, C,D,yp) = (C,D,yp, A,B,xp) - q*(0,0,0, C,D,yp)      
        t= B-q*D;   B=D;   D=t;
        t=xp-q*yp; xp=yp; yp=t;
      }
      if (B) {
        copy_(T,x);
        linComb_(x,y,A,B); //x=A*x+B*y
        linComb_(y,T,D,C); //y=D*y+C*T
      } else {
        mod_(x,y);
        copy_(T,x);
        copy_(x,y);
        copy_(y,T);
      } 
    }
    if (y[0]==0)
      return;
    t=modInt(x,y[0]);
    copyInt_(x,y[0]);
    y[0]=t;
    while (y[0]) {
      x[0]%=y[0];
      t=x[0]; x[0]=y[0]; y[0]=t;
    }
  }
1216054
function floor(out, a) {
  out[0] = Math.floor(a[0]);
  out[1] = Math.floor(a[1]);
  out[2] = Math.floor(a[2]);
  return out;
}
175880
def recursive_division(self, cells, min_size, width, height, x=0, y=0, depth=0):
        
        assert isinstance(cells, list)
        assert isinstance(min_size, int) or isinstance(min_size, float)
        assert isinstance(width, int) or isinstance(width, float)
        assert isinstance(height, int) or isinstance(height, float)
        assert isinstance(x, int) or isinstance(x, float)
        assert isinstance(y, int) or isinstance(y, float)
        assert isinstance(depth, int)

        if width <= min_size or height <= min_size:
            return

        # Choose axis to divide
        if width < height:
            axis = VERTICAL
        elif height < width:
            axis = HORIZONTAL
        else:
            axis = randint(0,1)

        cut_size = height
        gap_size = width
        if axis == HORIZONTAL:
            cut_size = width
            gap_size = height

        if cut_size-min_size < min_size:
            #print('min cut')
            return
        if gap_size-min_size < min_size:
            #print('min gap')
            return

        # Random division and doorway
        cut = randint(min_size, cut_size-min_size)
        gap = randint(min_size, gap_size-min_size)

        if not (cut > 0 and gap > 0):
            #print('Reached zero sized cell')
            return

        # Check if next tile is a doorway
        def dodge_doors(cut):
            assert isinstance(cut, int) or isinstance(cut, float)

            empty = False
            if axis == HORIZONTAL:
                idx = x+gap_size
                #print(idx,y+cut)
                door = cells[idx][y+cut]
                empty = empty or not door or not door.tile
                #door.tile = cells[49][1].tile

                idx = x
                #print(idx,y+cut)
                door = cells[idx][y+cut]
                empty = empty or not door or not door.tile
                #door.tile = cells[49][0].tile
            else:
                idx = y+gap_size
                #print(x+cut, idx)
                door = cells[x+cut][idx]
                empty = empty or not door or not door.tile
                #door.tile = cells[49][0].tile
                idx = y
                #print(x+cut,idx)
                door = cells[x+cut][idx]
                empty = empty or not door or not door.tile
                #door.tile = cells[49][1].tile

            # Try again on longest side
            if empty:
                #print('Door', idx, cut)
                if gap + (min_size / 2) > (gap_size / 2) - (min_size / 2):
                    cut -= 1
                else:
                    cut += 1

                if cut < min_size or cut > cut_size-min_size:
                    #print('Reached minimum size')
                    return None
                else:
                    return dodge_doors(cut)

            return cut

        # Skip doors check first time around
        if depth > 0:
            cut = dodge_doors(cut)
            if cut is None:
                #print('No viable cut found')
                return None
        depth += 1

        # Create new wall tiles
        for i in xrange(0, gap_size):
            if abs(gap - i) > 0:
                # Copy wall tile from (0,0)
                if axis == HORIZONTAL:
                    cells[x+i][y+cut].tile = cells[0][0].tile
                else:
                    cells[x+cut][y+i].tile = cells[0][0].tile

        # Recurse into each half
        #print(x, y, [cut, gap], [cut_size, gap_size], 'H' if (axis == HORIZONTAL) else 'V')

        # N
        nx, ny = x, y
        w, h = [cut, height] if (axis == HORIZONTAL) else [width, cut]
        self.recursive_division(cells, min_size, w, h, nx, ny, depth)

        # S
        nx, ny = [x+cut, y] if (axis != HORIZONTAL) else [x, y+cut]
        w, h = [cut_size-cut, height] if (axis == HORIZONTAL) else [width, cut_size-cut]
        self.recursive_division(cells, min_size, w, h, nx, ny, depth)
195338
function wRectangleTiles (z, wr) {
    const [wMinx, wMiny, wMaxx, wMaxy] = wr;
    const n = (1 << z); // for 0 <= z <= 30 equals Math.pow(2, z)

    const clamp = x => Math.min(Math.max(x, 0), n - 1);
    // compute tile coordinate ranges
    const tMinx = clamp(Math.floor(n * (wMinx + 1) * 0.5));
    const tMaxx = clamp(Math.ceil(n * (wMaxx + 1) * 0.5) - 1);
    const tMiny = clamp(Math.floor(n * (1 - wMaxy) * 0.5));
    const tMaxy = clamp(Math.ceil(n * (1 - wMiny) * 0.5) - 1);
    let tiles = [];
    for (let x = tMinx; x <= tMaxx; ++x) {
        for (let y = tMiny; y <= tMaxy; ++y) {
            tiles.push({ x: x, y: y, z: z });
        }
    }
    return tiles;
}
1309206
function dist_p_sep() {
    i = s[q]
    gi = array[ptr+i]
    gu = v
    var t = bisect(f, i, u+1, 0.25)
    return Math.floor(t)
  }
416755
public static FloatMatrix floori(FloatMatrix x) { 
		/*# mapfct('Math.floor') #*/
//RJPP-BEGIN------------------------------------------------------------
	   for (int i = 0; i < x.length; i++)
	      x.put(i, (float) Math.floor(x.get(i)));
	   return x;
//RJPP-END--------------------------------------------------------------
	}