Calculates the cartesian coordinate of the given pixel index pair.

 @param [Integer] i the image column index
 @param [Integer] j the image row index
 @return [Coordinate] the cartesian coordinate of the pixel
190706
def coordinate(i, j)
      x = @pos.x + (i * @delta_col * @cosines[0]) + (j * @delta_row * @cosines[3])
      y = @pos.y + (i * @delta_col * @cosines[1]) + (j * @delta_row * @cosines[4])
      z = @pos.z + (i * @delta_col * @cosines[2]) + (j * @delta_row * @cosines[5])
      Coordinate.new(x, y, z)
    end
1179117
def compute_coordinate(self, index):
        ''''''
        j = index%self.board_size
        i = (index - j) // self.board_size
        return (i, j)
936340
private static boolean inCone(int i, int j, int n, int[] verts, int[] indices) {
        int pi = (indices[i] & 0x0fffffff) * 4;
        int pj = (indices[j] & 0x0fffffff) * 4;
        int pi1 = (indices[next(i, n)] & 0x0fffffff) * 4;
        int pin1 = (indices[prev(i, n)] & 0x0fffffff) * 4;
        // If P[i] is a convex vertex [ i+1 left or on (i-1,i) ].
        if (leftOn(verts, pin1, pi, pi1)) {
            return left(verts, pi, pj, pin1) && left(verts, pj, pi, pi1);
        }
        // Assume (i-1,i,i+1) not collinear.
        // else P[i] is reflex.
        return !(leftOn(verts, pi, pj, pi1) && leftOn(verts, pj, pi, pin1));
    }
1220964
def _ixs(self, i, axis=0):
        
        label = self.index[i]
        if isinstance(label, Index):
            return self.take(i, axis=axis)
        else:
            return self._get_val_at(i)
576421
function (x0, y0, x1, y1, color, c)
    {
        PixelArt.put(x, y, color, c)
        var dx = x1 - x0;
        var dy = y1 - y0;
        var adx = Math.abs(dx);
        var ady = Math.abs(dy);
        var eps = 0;
        var sx = dx > 0 ? 1 : -1;
        var sy = dy > 0 ? 1 : -1;
        if (adx > ady)
        {
            for (var x = x0, y = y0; sx < 0 ? x >= x1 : x <= x1; x += sx)
            {
                PixelArt.put(x, y)
                eps += ady;
                if ((eps << 1) >= adx)
                {
                    y += sy;
                    eps -= adx;
                }
            }
        } else
        {
            for (var x = x0, y = y0; sy < 0 ? y >= y1 : y <= y1; y += sy)
            {
                PixelArt.put(x, y)
                eps += adx;
                if ((eps << 1) >= ady)
                {
                    x += sx;
                    eps -= ady;
                }
            }
        }
    }
37890
def _J(self, theta):
        
        if self.order == 0:
            return np.pi - theta
        elif self.order == 1:
            return tf.sin(theta) + (np.pi - theta) * tf.cos(theta)
        elif self.order == 2:
            return 3. * tf.sin(theta) * tf.cos(theta) + \
                   (np.pi - theta) * (1. + 2. * tf.cos(theta) ** 2)
2388
private int nAdjacentCentres(int i) {
        int n = 0;
        for (IAtom atom : tetrahedralElements[i].getLigands())
            if (tetrahedralElements[atomToIndex.get(atom)] != null) n++;
        return n;
    }
1173208
public void swapColumns(int i, int j) {
        if (i != j) {
            Vector ii = getColumn(i);
            Vector jj = getColumn(j);

            setColumn(i, jj);
            setColumn(j, ii);
        }
    }
799553
def pixel(self, x, y, size=None):
        """"""
        if (size is None):
            size = self.sz
        # Have we go to the smallest element?
        if (size <= 3):
            if (_not_diagonal(x, y)):
                return None
            else:
                return (0, 0, 0)
        divisor = size // 3
        if (_not_diagonal(x // divisor, y // divisor)):
            return None
        return self.pixel(x % divisor, y % divisor, divisor)
313556
function (hash, val) {
		var key,
			value,
			i,
			element = this.element || {},
			elemStyle = element.style,
			nodeName = element.nodeName,
			renderer = this.renderer,
			symbolName = this.symbolName,
			childNodes,
			hasSetSymbolSize,
			shadows = this.shadows,
			skipAttr,
			ret = this;

		// single key-value pair
		if (isString(hash) && defined(val)) {
			key = hash;
			hash = {};
			hash[key] = val;
		}

		// used as a getter, val is undefined
		if (isString(hash)) {
			key = hash;
			if (key === 'strokeWidth' || key === 'stroke-width') {
				ret = this.strokeweight;
			} else {
				ret = this[key];
			}

		// setter
		} else {
			for (key in hash) {
				value = hash[key];
				skipAttr = false;

				// prepare paths
				// symbols
				if (symbolName && /^(x|y|r|start|end|width|height|innerR)/.test(key)) {
					// if one of the symbol size affecting parameters are changed,
					// check all the others only once for each call to an element's
					// .attr() method
					if (!hasSetSymbolSize) {
						this.symbolAttr(hash);

						hasSetSymbolSize = true;
					}

					skipAttr = true;

				} else if (key === 'd') {
					value = value || [];
					this.d = value.join(' '); // used in getter for animation

					// convert paths
					i = value.length;
					var convertedPath = [];
					while (i--) {

						// Multiply by 10 to allow subpixel precision.
						// Substracting half a pixel seems to make the coordinates
						// align with SVG, but this hasn't been tested thoroughly
						if (isNumber(value[i])) {
							convertedPath[i] = mathRound(value[i] * 10) - 5;
						} else if (value[i] === 'Z') { // close the path
							convertedPath[i] = 'x';
						} else {
							convertedPath[i] = value[i];
						}

					}
					value = convertedPath.join(' ') || 'x';
					element.path = value;

					// update shadows
					if (shadows) {
						i = shadows.length;
						while (i--) {
							shadows[i].path = value;
						}
					}
					skipAttr = true;

				// directly mapped to css
				} else if (key === 'zIndex' || key === 'visibility') {

					// issue 61 workaround
					if (docMode8 && key === 'visibility' && nodeName === 'DIV') {
						element.gVis = value;
						childNodes = element.childNodes;
						i = childNodes.length;
						while (i--) {
							css(childNodes[i], { visibility: value });
						}
						if (value === VISIBLE) { // issue 74
							value = null;
						}
					}

					if (value) {
						elemStyle[key] = value;
					}



					skipAttr = true;

				// width and height
				} else if (/^(width|height)$/.test(key)) {

					this[key] = value; // used in getter

					// clipping rectangle special
					if (this.updateClipping) {
						this[key] = value;
						this.updateClipping();

					} else {
						// normal
						elemStyle[key] = value;
					}

					skipAttr = true;

				// x and y
				} else if (/^(x|y)$/.test(key)) {

					this[key] = value; // used in getter

					if (element.tagName === 'SPAN') {
						this.updateTransform();

					} else {
						elemStyle[{ x: 'left', y: 'top' }[key]] = value;
					}

				// class name
				} else if (key === 'class') {
					// IE8 Standards mode has problems retrieving the className
					element.className = value;

				// stroke
				} else if (key === 'stroke') {

					value = renderer.color(value, element, key);

					key = 'strokecolor';

				// stroke width
				} else if (key === 'stroke-width' || key === 'strokeWidth') {
					element.stroked = value ? true : false;
					key = 'strokeweight';
					this[key] = value; // used in getter, issue #113
					if (isNumber(value)) {
						value += PX;
					}

				// dashStyle
				} else if (key === 'dashstyle') {
					var strokeElem = element.getElementsByTagName('stroke')[0] ||
						createElement(renderer.prepVML(['<stroke/>']), null, null, element);
					strokeElem[key] = value || 'solid';
					this.dashstyle = value; /* because changing stroke-width will change the dash length
						and cause an epileptic effect */
					skipAttr = true;

				// fill
				} else if (key === 'fill') {

					if (nodeName === 'SPAN') { // text color
						elemStyle.color = value;
					} else {
						element.filled = value !== NONE ? true : false;

						value = renderer.color(value, element, key);

						key = 'fillcolor';
					}

				// translation for animation
				} else if (key === 'translateX' || key === 'translateY' || key === 'rotation' || key === 'align') {
					if (key === 'align') {
						key = 'textAlign';
					}
					this[key] = value;
					this.updateTransform();

					skipAttr = true;
				} else if (key === 'text') { // text for rotated and non-rotated elements
					this.bBox = null;
					element.innerHTML = value;
					skipAttr = true;
				}


				// let the shadow follow the main element
				if (shadows && key === 'visibility') {
					i = shadows.length;
					while (i--) {
						shadows[i].style[key] = value;
					}
				}



				if (!skipAttr) {
					if (docMode8) { // IE8 setAttribute bug
						element[key] = value;
					} else {
						attr(element, key, value);
					}
				}
			}
		}
		return ret;
	}
5686
def relayIndextoCoord(self, i):
    
    x = i % self.relayWidth
    y = i / self.relayWidth
    return x, y
142713
def diagonalColumnRow(d, i)
      {
        'column' => (d.to_i < 0 ? i : d.to_i + i).to_i,
        'row' => (d.to_i < 0 ? d.to_i.abs + i : i).to_i
      }
    end
1295132
def jac(self, xy=None):
        
        if xy is not None:
            self.set_xy(xy)

        ux = numpy.dot(self.ax, self.xy_list[: len(self.ax)])
        vx = numpy.dot(self.bx, self.xy_list[: len(self.bx)])
        uy = numpy.dot(self.ay, self.xy_list[: len(self.ay)])
        vy = numpy.dot(self.by, self.xy_list[: len(self.by)])

        ux_dx = numpy.dot(self.ax, self.dx_list[: len(self.ax)])
        vx_dx = numpy.dot(self.bx, self.dx_list[: len(self.bx)])
        uy_dx = numpy.dot(self.ay, self.dx_list[: len(self.ay)])
        vy_dx = numpy.dot(self.by, self.dx_list[: len(self.by)])

        ux_dy = numpy.dot(self.ax, self.dy_list[: len(self.ax)])
        vx_dy = numpy.dot(self.bx, self.dy_list[: len(self.bx)])
        uy_dy = numpy.dot(self.ay, self.dy_list[: len(self.ay)])
        vy_dy = numpy.dot(self.by, self.dy_list[: len(self.by)])

        jac = numpy.array(
            [
                [
                    (ux_dx * vx - vx_dx * ux) / vx ** 2,
                    (ux_dy * vx - vx_dy * ux) / vx ** 2,
                ],
                [
                    (uy_dx * vy - vy_dx * uy) / vy ** 2,
                    (uy_dy * vy - vy_dy * uy) / vy ** 2,
                ],
            ]
        )
        return jac
625165
function findLargestInRow (M, i) {
  // get the row:
  const m = M.elements;
  const n = M.dimension;
  const offset = i;

  let j = 0;
  let lrgElem = _Math.abs(m[offset]);
  let lrgCol = j;
  for (j = 1; j < n; ++j) {
    const val = _Math.abs(m[offset + j * n]);
    if (val > lrgElem) {
      lrgCol = j;
      lrgElem = val;
    }
  }
  return lrgCol;
}
1373707
public Stream<IntPair> adjacent8Points(final int i, final int j) {
        final IntPair up = i == 0 ? null : IntPair.of(i - 1, j);
        final IntPair right = j == cols - 1 ? null : IntPair.of(i, j + 1);
        final IntPair down = i == rows - 1 ? null : IntPair.of(i + 1, j);
        final IntPair left = j == 0 ? null : IntPair.of(i, j - 1);

        final IntPair leftUp = i > 0 && j > 0 ? IntPair.of(i - 1, j - 1) : null;
        final IntPair rightUp = i > 0 && j < cols - 1 ? IntPair.of(i - 1, j + 1) : null;
        final IntPair rightDown = i < rows - 1 && j < cols - 1 ? IntPair.of(j + 1, j + 1) : null;
        final IntPair leftDown = i < rows - 1 && j > 0 ? IntPair.of(i + 1, j - 1) : null;

        return Stream.of(leftUp, up, rightUp, right, rightDown, down, leftDown, left);
    }
526434
function swapRowsInPlace (M, i, j) {
  const me = M.elements;
  let a1 = me[i];
  let a2 = me[i + 3];
  let a3 = me[i + 6];

  me[i] = me[j];
  me[i + 3] = me[j + 3];
  me[i + 6] = me[j + 6];

  me[j] = a1;
  me[j + 3] = a2;
  me[j + 6] = a3;
}
484198
private void process(int[] srcImage, int[] dstImage, int x, int y)
    {
        final int a = getSourcePixel(srcImage, x - 1, y - 1);
        final int b = getSourcePixel(srcImage, x, y - 1);
        final int c = getSourcePixel(srcImage, x + 1, y - 1);
        final int d = getSourcePixel(srcImage, x - 1, y);
        final int e = getSourcePixel(srcImage, x, y);
        final int f = getSourcePixel(srcImage, x + 1, y);
        final int g = getSourcePixel(srcImage, x - 1, y + 1);
        final int h = getSourcePixel(srcImage, x, y + 1);
        final int i = getSourcePixel(srcImage, x + 1, y + 1);
        int e0 = e;
        int e1 = e;
        int e2 = e;
        int e3 = e;
        int e4 = e;
        int e5 = e;
        int e6 = e;
        int e7 = e;
        int e8 = e;

        if (b != h && d != f)
        {
            e0 = computeE0(b, d, e);
            e1 = computeE1(a, b, c, d, e, f);
            e2 = computeE2(b, e, f);
            e3 = computeE3(a, b, d, e, g, h);
            e4 = e;
            e5 = computeE5(b, c, e, f, h, i);
            e6 = computeE6(d, e, h);
            e7 = computeE7(d, e, f, g, h, i);
            e8 = computeE8(e, f, h);
        }

        setDestPixel(dstImage, x * SCALE, y * SCALE, e0);
        setDestPixel(dstImage, x * SCALE + 1, y * SCALE, e1);
        setDestPixel(dstImage, x * SCALE + 2, y * SCALE, e2);
        setDestPixel(dstImage, x * SCALE, y * SCALE + 1, e3);
        setDestPixel(dstImage, x * SCALE + 1, y * SCALE + 1, e4);
        setDestPixel(dstImage, x * SCALE + 2, y * SCALE + 1, e5);
        setDestPixel(dstImage, x * SCALE, y * SCALE + 2, e6);
        setDestPixel(dstImage, x * SCALE + 1, y * SCALE + 2, e7);
        setDestPixel(dstImage, x * SCALE + 2, y * SCALE + 2, e8);
    }