Compute E3 pixel.

@param a The a value.
@param b The b value.
@param d The d value.
@param e The e value.
@param g The g value.
@param h The h value.
@return The computed value.
1614
private static int computeE3(int a, int b, int d, int e, int g, int h)
    {
        if (d == b && e != g || d == h && e != a)
        {
            return d;
        }
        return e;
    }
920692
public static void elementMultConjB( InterleavedF64 a , InterleavedF64 b , InterleavedF64 output ) {
		for( int y = 0; y < a.height; y++ ) {

			int index = a.startIndex + y*a.stride;

			for( int x = 0; x < a.width; x++, index += 2 ) {

				double realA = a.data[index];
				double imgA = a.data[index+1];
				double realB = b.data[index];
				double imgB = b.data[index+1];

				output.data[index] = realA*realB + imgA*imgB;
				output.data[index+1] = -realA*imgB + imgA*realB;
			}
		}
	}
644905
public static double euclidean(TupleDesc_F64 a, TupleDesc_F64 b) {
		final int N = a.value.length;
		double total = 0;
		for( int i = 0; i < N; i++ ) {
			double d = a.value[i]-b.value[i];
			total += d*d;
		}

		return Math.sqrt(total);
	}
1053305
public static void ge_scalarmult_base(ge_p3 h, byte[] a) {
        byte[] e = new byte[64];
        byte carry;
        ge_p1p1 r = new ge_p1p1();
        ge_p2 s = new ge_p2();
        ge_precomp t = new ge_precomp();
        int i;

        for (i = 0; i < 32; ++i) {
            e[2 * i + 0] = (byte) ((a[i] >>> 0) & 15);
            e[2 * i + 1] = (byte) ((a[i] >>> 4) & 15);
        }
  /* each e[i] is between 0 and 15 */
  /* e[63] is between 0 and 7 */

        carry = 0;
        for (i = 0; i < 63; ++i) {
            e[i] += carry;
            carry = (byte) (e[i] + 8);
            carry >>= 4;
            e[i] -= carry << 4;
        }
        e[63] += carry;
  /* each e[i] is between -8 and 8 */

        ge_p3_0.ge_p3_0(h);
        for (i = 1; i < 64; i += 2) {
            select(t, i / 2, e[i]);
            ge_madd.ge_madd(r, h, t);
            ge_p1p1_to_p3.ge_p1p1_to_p3(h, r);
        }

        ge_p3_dbl.ge_p3_dbl(r, h);
        ge_p1p1_to_p2.ge_p1p1_to_p2(s, r);
        ge_p2_dbl.ge_p2_dbl(r, s);
        ge_p1p1_to_p2.ge_p1p1_to_p2(s, r);
        ge_p2_dbl.ge_p2_dbl(r, s);
        ge_p1p1_to_p2.ge_p1p1_to_p2(s, r);
        ge_p2_dbl.ge_p2_dbl(r, s);
        ge_p1p1_to_p3.ge_p1p1_to_p3(h, r);

        for (i = 0; i < 64; i += 2) {
            select(t, i / 2, e[i]);
            ge_madd.ge_madd(r, h, t);
            ge_p1p1_to_p3.ge_p1p1_to_p3(h, r);
        }
    }
175014
public static byte[] getPixelsBGR(BufferedImage img, int y, int w, byte[] array, int[] temp) {
    final int x = 0;
    final int h = 1;

    assert array.length == temp.length * nrChannels(img);
    assert (temp.length == w);

    int imageType = img.getType();
    Raster raster;
    switch (imageType) {
      case BufferedImage.TYPE_3BYTE_BGR:
      case BufferedImage.TYPE_4BYTE_ABGR:
      case BufferedImage.TYPE_4BYTE_ABGR_PRE:
      case BufferedImage.TYPE_BYTE_GRAY:
        raster = img.getRaster();
        //int ttype= raster.getTransferType();
        raster.getDataElements(x, y, w, h, array);
        break;
      case BufferedImage.TYPE_INT_BGR:
        raster = img.getRaster();
        raster.getDataElements(x, y, w, h, temp);
        ints2bytes(temp, array, 0, 1, 2);  // bgr -->  bgr
        break;
      case BufferedImage.TYPE_INT_RGB:
        raster = img.getRaster();
        raster.getDataElements(x, y, w, h, temp);
        ints2bytes(temp, array, 2, 1, 0);  // rgb -->  bgr
        break;
      case BufferedImage.TYPE_INT_ARGB:
      case BufferedImage.TYPE_INT_ARGB_PRE:
        raster = img.getRaster();
        raster.getDataElements(x, y, w, h, temp);
        ints2bytes(temp, array, 2, 1, 0, 3);  // argb -->  abgr
        break;
      case BufferedImage.TYPE_CUSTOM: // TODO: works for my icon image loader, but else ???
        img.getRGB(x, y, w, h, temp, 0, w);
        ints2bytes(temp, array, 2, 1, 0, 3);  // argb -->  abgr
        break;
      default:
        img.getRGB(x, y, w, h, temp, 0, w);
        ints2bytes(temp, array, 2, 1, 0);  // rgb -->  bgr
        break;
    }

    return array;
  }
1247445
public void set(double a, double b, double c, double d) {
		this.aProperty.set(a);
		this.bProperty.set(b);
		this.cProperty.set(c);
		this.dProperty.set(d);
		clearBufferedValues();
	}
361938
public static int fromHSV(float h, float s, float v, int a) {
        float r = v;
        float g = v;
        float b = v;

        int i;
        float f, p, q, t;

        if (s == 0) {
            // achromatic (grey)
            int ri = (int) (r * 0xff);
            int gi = (int) (g * 0xff);
            int bi = (int) (b * 0xff);

            return getRGB(ri, gi, bi);
        }

        h /= 60;            // sector 0 to 5
        i = (int) Math.floor(h);
        f = h - i;            // factorial part of h
        p = v * (1 - s);
        q = v * (1 - s * f);
        t = v * (1 - s * (1 - f));

        switch (i) {
            case 0:
                r = v;
                g = t;
                b = p;
                break;
            case 1:
                r = q;
                g = v;
                b = p;
                break;
            case 2:
                r = p;
                g = v;
                b = t;
                break;
            case 3:
                r = p;
                g = q;
                b = v;
                break;
            case 4:
                r = t;
                g = p;
                b = v;
                break;
            // case 5:
            default:
                r = v;
                g = p;
                b = q;
                break;
        }

        int ri = (int) (r * 0xff);
        int gi = (int) (g * 0xff);
        int bi = (int) (b * 0xff);

        return getARGB(ri, gi, bi, a);
    }
1158312
private static void compute(Kernel kernel, int[] in, int[] out, int width, int height, boolean alpha, int edge)
    {
        final float[] matrix = kernel.getMatrix();
        final int cols = kernel.getWidth();
        final int cols2 = cols / 2;

        for (int y = 0; y < height; y++)
        {
            int index = y;
            final int ioffset = y * width;
            for (int x = 0; x < width; x++)
            {
                compute(matrix, in, out, x, index, ioffset, cols2, width, alpha, edge);
                index += height;
            }
        }
    }
678530
private void process(int x,int y)
    {
        int A = getSourcePixel(x-1,y-1);
        int B = getSourcePixel(x,y-1);
        int C = getSourcePixel(x+1,y-1);
        int D = getSourcePixel(x-1,y);
        int E = getSourcePixel(x,y);
        int F = getSourcePixel(x+1,y);
        int G = getSourcePixel(x-1,y+1);
        int H = getSourcePixel(x,y+1);
        int I = getSourcePixel(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 (different(B,H) && different(D,F)) {
            E0 = !different(D,B) ? D : E;
            E1 = ((!different(D,B)) && different(E,C)) || ((!different(B,F)) && different(E,A)) ? B : E;
            E2 = !different(B,F) ? F : E;
            E3 = ((!different(D,B)) && different(E,G)) || ((!different(D,H)) && different(E,A)) ? D : E;
            E4 = E;
            E5 = ((!different(B,F)) && different(E,I)) || ((!different(H,F)) && different(E,C)) ? F : E;
            E6 = !different(D,H) ? D : E;
            E7 = ((!different(D,H)) && different(E,I)) || ((!different(H,F)) && different(E,G)) ? H : E;
            E8 = !different(H,F) ? F : E;
        }
        
        setDestPixel((x*3),(y*3),E0);
        setDestPixel((x*3)+1,(y*3),E1);
        setDestPixel((x*3)+2,(y*3),E2);
        setDestPixel((x*3),(y*3)+1,E3);
        setDestPixel((x*3)+1,(y*3)+1,E4);
        setDestPixel((x*3)+2,(y*3)+1,E5);
        setDestPixel((x*3),(y*3)+2,E6);
        setDestPixel((x*3)+1,(y*3)+2,E7);
        setDestPixel((x*3)+2,(y*3)+2,E8);
    }
193798
public static int pixelTypeToGL(
    final JCGLPixelFormat p)
  {
    switch (p) {
      case PIXEL_COMPONENT_BYTE:
        return GL.GL_BYTE;
      case PIXEL_COMPONENT_FLOAT:
        return GL.GL_FLOAT;
      case PIXEL_COMPONENT_INT:
        return GL2ES2.GL_INT;
      case PIXEL_COMPONENT_SHORT:
        return GL.GL_SHORT;
      case PIXEL_COMPONENT_UNSIGNED_BYTE:
        return GL.GL_UNSIGNED_BYTE;
      case PIXEL_COMPONENT_UNSIGNED_INT:
        return GL.GL_UNSIGNED_INT;
      case PIXEL_COMPONENT_UNSIGNED_SHORT:
        return GL.GL_UNSIGNED_SHORT;
      case PIXEL_PACKED_UNSIGNED_INT_1010102:
        return GL2ES2.GL_UNSIGNED_INT_10_10_10_2;
      case PIXEL_PACKED_UNSIGNED_SHORT_4444:
        return GL.GL_UNSIGNED_SHORT_4_4_4_4;
      case PIXEL_PACKED_UNSIGNED_SHORT_5551:
        return GL.GL_UNSIGNED_SHORT_5_5_5_1;
      case PIXEL_PACKED_UNSIGNED_SHORT_565:
        return GL.GL_UNSIGNED_SHORT_5_6_5;
      case PIXEL_COMPONENT_HALF_FLOAT:
        return GL.GL_HALF_FLOAT;
      case PIXEL_PACKED_UNSIGNED_INT_24_8:
        return GL.GL_UNSIGNED_INT_24_8;
    }

    throw new UnreachableCodeException();
  }
436888
static private boolean PE_EQ(double a, double b) {
		return (a == b)
				|| PE_ABS(a - b) <= PE_EPS * (1 + (PE_ABS(a) + PE_ABS(b)) / 2);
	}
795199
public static void rgbToHsv( double r , double g , double b , double []hsv ) {
		// Maximum value
		double max = r > g ? ( r > b ? r : b) : ( g > b ? g : b );
		// Minimum value
		double min = r < g ? ( r < b ? r : b) : ( g < b ? g : b );
		double delta = max - min;

		hsv[2] = max;

		if( max != 0 )
			hsv[1] = delta / max;
		else {
			hsv[0] = Double.NaN;
			hsv[1] = 0;
			return;
		}

		double h;
		if( r == max )
			h = ( g - b ) / delta;
		else if( g == max )
			h = 2 + ( b - r ) / delta;
		else
			h = 4 + ( r - g ) / delta;

		h *= d60_F64;
		if( h < 0 )
			h += PI2_F64;

		hsv[0] = h;
	}
309565
@Override
    public double compute(double a, double b) {
        if (Op.isEq(Op.min(a, b), 0.0)) {
            return Op.max(a, b);
        }
        return 1.0;
    }
1327164
public static int fromHSL(float h, float s, float l, int a) {
        int r, g, b;

        if (s == 0) {
            r = g = b = (int) (l * MAX);
        } else {
            float v1, v2;
            float hue = h / 360f;

            v2 = (l < 0.5) ? (l * (1 + s)) : ((l + s) - (l * s));
            v1 = 2 * l - v2;

            r = (int) (MAX * HueToRGB(v1, v2, hue + (1.0f / 3)));
            g = (int) (MAX * HueToRGB(v1, v2, hue));
            b = (int) (MAX * HueToRGB(v1, v2, hue - (1.0f / 3)));
        }

        return getARGB(r, g, b, a);
    }
554458
public static void srgbToXyz( double r , double g , double b , double xyz[] ) {
		xyz[0] = 0.412453*r + 0.35758*g + 0.180423*b;
		xyz[1] = 0.212671*r + 0.71516*g + 0.072169*b;
		xyz[2] = 0.019334*r + 0.119193*g + 0.950227*b;
	}
228927
public static int[] RGBtoHSV (float r, float g, float b) {
		float h, s, v;
		float min, max, delta;

		min = Math.min(Math.min(r, g), b);
		max = Math.max(Math.max(r, g), b);
		v = max;

		delta = max - min;

		if (max != 0)
			s = delta / max;
		else {
			s = 0;
			h = 0;
			return new int[]{MathUtils.round(h), MathUtils.round(s), MathUtils.round(v)};
		}

		if (delta == 0)
			h = 0;
		else {

			if (r == max)
				h = (g - b) / delta;
			else if (g == max)
				h = 2 + (b - r) / delta;
			else
				h = 4 + (r - g) / delta;
		}

		h *= 60;
		if (h < 0)
			h += 360;

		s *= 100;
		v *= 100;

		return new int[]{MathUtils.round(h), MathUtils.round(s), MathUtils.round(v)};
	}
948849
public ColorPixel add(double r, double g, double b){
		return setRGB_fromDouble_preserveAlpha(r+r_asDouble(), g+g_asDouble(), b+b_asDouble());
	}