/*
Computes the circular convolution of the given real vectors. Each vector's length must be the same.
495166
private static void convolve(double[] x, double[] y, double[] out) {
//        if (x.length != y.length || x.length != out.length)
//                throw new IllegalArgumentException("Mismatched lengths");
        int n = x.length;
        convolve(x, new double[n], y, new double[n], out, new double[n]);
    }
965806
function (inData, outData, width, height) {
        convolve5x5(inData, outData, width, height,
            [
                [-1, -1, -1, -1, -1],
                [-1, -1, -1, -1, -1],
                [-1, -1, 24, -1, -1],
                [-1, -1, -1, -1, -1],
                [-1, -1, -1, -1, -1]
            ],
            false, true, true);
    }
39414
@Override
	public void compute(int x, int y, Point2D_F64 out ) {
		// grab precomputed normalized image coordinate at canonical location
		Point3D_F64 v = vectors[y*outWidth+x];
		// move to requested orientation
		GeometryMath_F64.mult(R,v,n); // TODO make faster by not using an array based matrix

		// compute pixel coordinate
		tools.normToEquiFV(n.x,n.y,n.z,out);
	}
684377
public static void convolve(Kernel2D_S32 kernel, GrayS16 src, GrayI16 dst ) {
		InputSanityCheck.checkSameShape(src, dst);

		boolean processed = BOverrideConvolveImageNormalized.invokeNativeConvolve(kernel,src,dst);
		
		if( !processed ) {
			if( kernel.width >= src.width || kernel.width >= src.height ) {
				ConvolveNormalizedNaive_SB.convolve(kernel, src, dst);
			} else {
				ConvolveImageNoBorder.convolve(kernel, src, dst, kernel.computeSum(), null);
				ConvolveNormalized_JustBorder_SB.convolve(kernel, src, dst);
			}
		}
	}
472157
public static int cudnnConvolutionForward(
        cudnnHandle handle, 
        Pointer alpha, 
        cudnnTensorDescriptor xDesc, 
        Pointer x, 
        cudnnFilterDescriptor wDesc, 
        Pointer w, 
        cudnnConvolutionDescriptor convDesc, 
        int algo, 
        Pointer workSpace, 
        long workSpaceSizeInBytes, 
        Pointer beta, 
        cudnnTensorDescriptor yDesc, 
        Pointer y)
    {
        return checkResult(cudnnConvolutionForwardNative(handle, alpha, xDesc, x, wDesc, w, convDesc, algo, workSpace, workSpaceSizeInBytes, beta, yDesc, y));
    }
796257
public static void multiplyRealComplex( GrayF32 realA ,
											InterleavedF32 complexB , InterleavedF32 complexC ) {

		checkImageArguments(realA,complexB);

		InputSanityCheck.checkSameShape( complexB,complexC);

		for( int y = 0; y < realA.height; y++ ) {

			int indexA = realA.startIndex + y*realA.stride;
			int indexB = complexB.startIndex + y*complexB.stride;
			int indexC = complexC.startIndex + y*complexC.stride;

			for( int x = 0; x < realA.width; x++, indexA++ , indexB += 2  ,indexC += 2 ) {

				float real = realA.data[indexA];
				float realB = complexB.data[indexB];
				float imgB = complexB.data[indexB+1];

				complexC.data[indexC] = real*realB;
				complexC.data[indexC+1] = real*imgB;
			}
		}
	}
480571
public static <T extends ImageBase<T>>
	boolean invokeNativeGaussian(T input, T output, double sigma , int radius, T storage) {
		boolean processed = false;
		if( BOverrideBlurImageOps.gaussian != null ) {
			try {
				BOverrideBlurImageOps.gaussian.processGaussian(input,output,sigma,radius,storage);
				processed = true;
			} catch( RuntimeException ignore ) {}
		}
		return processed;
	}
201636
def _fft_convolve_numpy(data, h, plan = None,
                        kernel_is_fft = False,
                        kernel_is_fftshifted = False):
    

    if data.shape != h.shape:
        raise ValueError("data and kernel must have same size! %s vs %s "%(str(data.shape),str(h.shape)))

    
    data_g = OCLArray.from_array(data.astype(np.complex64))

    if not kernel_is_fftshifted:
        h = np.fft.fftshift(h)

    
    h_g = OCLArray.from_array(h.astype(np.complex64))
    res_g = OCLArray.empty_like(data_g)
    
    _fft_convolve_gpu(data_g,h_g,res_g = res_g,
                      plan = plan,
                      kernel_is_fft = kernel_is_fft)

    res =  abs(res_g.get())

    del data_g
    del h_g
    del res_g
    
    return res
1281248
public void convolveDerivOrder() {
		T blur = GeneralizedImageOps.createSingleBand(imageType, width, height);
		T blurDeriv = GeneralizedImageOps.createSingleBand(imageType, width, height);
		T deriv = GeneralizedImageOps.createSingleBand(imageType, width, height);
		T derivBlur = GeneralizedImageOps.createSingleBand(imageType, width, height);

		BlurStorageFilter<T> funcBlur = FactoryBlurFilter.gaussian(ImageType.single(imageType),sigma,radius);
		ImageGradient<T,T> funcDeriv = FactoryDerivative.three(imageType,imageType);

		funcBlur.process(input,blur);
		funcDeriv.process(blur,blurDeriv,derivY);

		funcDeriv.process(input,deriv,derivY);
		funcBlur.process(deriv,derivBlur);

		printIntensity("Blur->Deriv",blurDeriv);
		printIntensity("Deriv->Blur",blurDeriv);
	}
1107715
function calcLayerRect(iCanvas, layer) {
    var rect = transformRect(iCanvas, layer);
    rect = rectIntersect(rect, {x: 0, y: 0, width: iCanvas.width, height: iCanvas.height});
    return { x: Math.round(rect.x),
        y: Math.round(rect.y),
        width: Math.ceil(rect.width),
        height: Math.ceil(rect.height)};
}
638105
public void inverse(double[] a) {
        int n = a.length;

        if (!Math.isPower2(n)) {
            throw new IllegalArgumentException("The data vector size is not a power of 2.");
        }

        if (n < ncof) {
            throw new IllegalArgumentException("The data vector size is less than wavelet coefficient size.");
        }

        int start = n >> (int) Math.floor(Math.log2(n/(ncof-1)));
        for (int nn = start; nn <= n; nn <<= 1) {
            backward(a, nn);
        }
    }
273360
public static void computeRowOfV( final int blockLength ,
                                      final DSubmatrixD1 A ,
                                      final DSubmatrixD1 V ,
                                      int row ,
                                      double gamma )
    {
        // val=(y^T*u)
        double val = BlockHouseHolder_DDRB.innerProdRow(blockLength,A,row,V,row,1);

        // take in account the one
        double before = A.get(row,row+1);
        A.set(row,row+1,1);

        // v = y - (1/2)gamma*val * u
        VectorOps_DDRB.add_row(blockLength,V,row,1,A,row,-0.5*gamma*val,V,row,row+1,A.col1-A.col0);

        A.set(row,row+1,before);
    }
417270
public void mul(double b, IVector result) {
        if (result.size != size) result.reshape(size);

        int i;
        for (i = 0; i < size; i++) {
            result.realvector[i] = realvector[i] * b;
            result.imagvector[i] = imagvector[i] * b;
        }
    }
1038838
function (inData, outData, width, height) {
        var c = 1 / 25;
        convolve5x5(inData, outData, width, height,
            [
                [c, c, c, c, c],
                [c, c, c, c, c],
                [c, c, c, c, c],
                [c, c, c, c, c],
                [c, c, c, c, c]
            ]);
    }
408852
public void computeDescriptor( int cx , int cy , TupleDesc_F64 desc  ) {

		desc.fill(0);

		int widthPixels = widthSubregion*widthGrid;
		int radius = widthPixels/2;

		for (int i = 0; i < widthPixels; i++) {
			int angleIndex = (cy-radius+i)*savedAngle.width + (cx-radius);

			float subY = i/(float)widthSubregion;

			for (int j = 0; j < widthPixels; j++, angleIndex++ ) {
				float subX = j/(float)widthSubregion;

				double angle = savedAngle.data[angleIndex];

				float weightGaussian = gaussianWeight[i*widthPixels+j];
				float weightGradient = savedMagnitude.data[angleIndex];

				// trilinear interpolation intro descriptor
				trilinearInterpolation(weightGaussian*weightGradient,subX,subY,angle,desc);
			}
		}

		normalizeDescriptor(desc,maxDescriptorElementValue);
	}
219520
def convolve( filter )
      filter = Node.match( filter, typecode ).new filter unless filter.matched?
      array = self
      (dimension - filter.dimension).times { array = array.roll }
      array.table(filter) { |a,b| a * b }.diagonal { |s,x| s + x }
    end
792790
function isCyclic (data) {
    
    // Create an array that will store the nodes of the array that have already been iterated over
    let seenObjects = [];

    function detect (data) {
        // If the data pass is an object
        if (data && getType(data) === "Object") {
            
            // If the data is already in the seen nodes array then we know there is a circular reference
            // Therefore return true
            if (seenObjects.indexOf(data) !== -1) {
                return true;
            }

            // Add the data to the seen objects array
            seenObjects.push(data);

            // Begin iterating through the data passed to the method
            for (var key in data) {
                // Recall this method with the objects key
                if (data.hasOwnProperty(key) === true && detect(data[key])) {
                    return true;
                }
            }
        }
        return false;
    }

    // Return the method
    return detect(data);
}