当前位置: 首页>>代码示例>>Java>>正文


Java ConcurrencyUtils类代码示例

本文整理汇总了Java中edu.emory.mathcs.utils.ConcurrencyUtils的典型用法代码示例。如果您正苦于以下问题:Java ConcurrencyUtils类的具体用法?Java ConcurrencyUtils怎么用?Java ConcurrencyUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConcurrencyUtils类属于edu.emory.mathcs.utils包,在下文中一共展示了ConcurrencyUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ddxt2d0_subth

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
private void ddxt2d0_subth(final int isgn, final double[][] a, final boolean scale) {
    final int nthreads = ConcurrencyUtils.getNumberOfThreads() > rows ? rows : ConcurrencyUtils.getNumberOfThreads();

    Future<?>[] futures = new Future[nthreads];

    for (int i = 0; i < nthreads; i++) {
        final int n0 = i;
        futures[i] = ConcurrencyUtils.submit(new Runnable() {

            @Override
public void run() {
                if (isgn == -1) {
                    for (int r = n0; r < rows; r += nthreads) {
                        dctColumns.forward(a[r], scale);
                    }
                } else {
                    for (int r = n0; r < rows; r += nthreads) {
                        dctColumns.inverse(a[r], scale);
                    }
                }
            }
        });
    }
    ConcurrencyUtils.waitForCompletion(futures);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:DoubleDCT_2D.java

示例2: FloatDCT_1D

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
/**
 * Creates new instance of FloatDCT_1D.
 * 
 * @param n
 *            size of data
 */
public FloatDCT_1D(int n) {
    if (n < 1) {
        throw new IllegalArgumentException("n must be greater than 0");
    }
    this.n = n;
    if (ConcurrencyUtils.isPowerOf2(n)) {
        this.isPowerOfTwo = true;
        this.ip = new int[(int) Math.ceil(2 + (1 << (int) (Math.log(n / 2 + 0.5) / Math.log(2)) / 2))];
        this.w = new float[n * 5 / 4];
        nw = ip[0];
        if (n > (nw << 2)) {
            nw = n >> 2;
            makewt(nw);
        }
        nc = ip[1];
        if (n > nc) {
            nc = n;
            makect(nc, w, nw);
        }
    } else {
        this.w = makect(n);
        fft = new FloatFFT_1D(2 * n);
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:31,代码来源:FloatDCT_1D.java

示例3: ddxt2d0_subth

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
private void ddxt2d0_subth(final int isgn, final double[][] a, final boolean scale) {
    final int nthreads = ConcurrencyUtils.getNumberOfThreads() > rows ? rows : ConcurrencyUtils.getNumberOfThreads();

    Future<?>[] futures = new Future[nthreads];

    for (int i = 0; i < nthreads; i++) {
        final int n0 = i;
        futures[i] = ConcurrencyUtils.submit(new Runnable() {

            @Override
public void run() {
                if (isgn == -1) {
                    for (int r = n0; r < rows; r += nthreads) {
                        dstColumns.forward(a[r], scale);
                    }
                } else {
                    for (int r = n0; r < rows; r += nthreads) {
                        dstColumns.inverse(a[r], scale);
                    }
                }
            }
        });
    }
    ConcurrencyUtils.waitForCompletion(futures);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:DoubleDST_2D.java

示例4: ddxt2d0_subth

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
private void ddxt2d0_subth(final int isgn, final float[] a, final boolean scale) {
    final int nthreads = ConcurrencyUtils.getNumberOfThreads() > rows ? rows : ConcurrencyUtils.getNumberOfThreads();

    Future<?>[] futures = new Future[nthreads];

    for (int i = 0; i < nthreads; i++) {
        final int n0 = i;
        futures[i] = ConcurrencyUtils.submit(new Runnable() {

            @Override
public void run() {
                if (isgn == -1) {
                    for (int r = n0; r < rows; r += nthreads) {
                        dstColumns.forward(a, r * columns, scale);
                    }
                } else {
                    for (int r = n0; r < rows; r += nthreads) {
                        dstColumns.inverse(a, r * columns, scale);
                    }
                }
            }
        });
    }
    ConcurrencyUtils.waitForCompletion(futures);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:FloatDST_2D.java

示例5: ddxt2d0_subth

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
private void ddxt2d0_subth(final int isgn, final float[][] a, final boolean scale) {
    final int nthreads = ConcurrencyUtils.getNumberOfThreads() > rows ? rows : ConcurrencyUtils.getNumberOfThreads();

    Future<?>[] futures = new Future[nthreads];

    for (int i = 0; i < nthreads; i++) {
        final int n0 = i;
        futures[i] = ConcurrencyUtils.submit(new Runnable() {

            @Override
public void run() {
                if (isgn == -1) {
                    for (int r = n0; r < rows; r += nthreads) {
                        dhtColumns.forward(a[r]);
                    }
                } else {
                    for (int r = n0; r < rows; r += nthreads) {
                        dhtColumns.inverse(a[r], scale);
                    }
                }
            }
        });
    }
    ConcurrencyUtils.waitForCompletion(futures);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:26,代码来源:FloatDHT_2D.java

示例6: DoubleDCT_1D

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
/**
 * Creates new instance of DoubleDCT_1D.
 * 
 * @param n
 *            size of data
 */
public DoubleDCT_1D(int n) {
    if (n < 1) {
        throw new IllegalArgumentException("n must be greater than 0");
    }
    this.n = n;
    if (ConcurrencyUtils.isPowerOf2(n)) {
        this.isPowerOfTwo = true;
        this.ip = new int[(int) Math.ceil(2 + (1 << (int) (Math.log(n / 2 + 0.5) / Math.log(2)) / 2))];
        this.w = new double[n * 5 / 4];
        nw = ip[0];
        if (n > (nw << 2)) {
            nw = n >> 2;
            makewt(nw);
        }
        nc = ip[1];
        if (n > nc) {
            nc = n;
            makect(nc, w, nw);
        }
    } else {
        this.w = makect(n);
        fft = new DoubleFFT_1D(2 * n);
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:31,代码来源:DoubleDCT_1D.java

示例7: runAll

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
public void runAll() throws Exception {
	List<AbstractMatrix2DBenchmark> benchmarks = getDenseBenchmarks();

	UJMPSettings.getInstance().setNumberOfThreads(getConfig().getNumberOfThreads());
	ConcurrencyUtils.setNumberOfThreads(getConfig().getNumberOfThreads());
	System.setProperty("ATLAS_NUM_THREADS", "" + getConfig().getNumberOfThreads());

	if (getConfig().isShuffle()) {
		Collections.shuffle(benchmarks);
	}
	if (getConfig().isReverse()) {
		Collections.reverse(benchmarks);
	}

	long t0 = System.currentTimeMillis();

	for (int j = 0; j < benchmarks.size(); j++) {
		AbstractMatrix2DBenchmark benchmark = benchmarks.get(j);
		benchmark.run();
	}

	long t1 = System.currentTimeMillis();

	System.out.println();
	System.out.println("Finished.");
	System.out.println("Total Time: " + StringUtil.duration(t1 - t0));
	System.out.println();
	System.out.println();
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:30,代码来源:CompleteMatrixBenchmark.java

示例8: initCheck

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
public static void initCheck(Frame input, int width, int height, int depth) {
  ConcurrencyUtils.setNumberOfThreads(1);
  if (width < 1 || height < 1 || depth < 1)
    throw new H2OIllegalArgumentException("dimensions must be >= 1");
  if (width*height*depth != input.numCols())
    throw new H2OIllegalArgumentException("dimensions HxWxD must match the # columns of the frame");
  for (Vec v : input.vecs()) {
    if (v.naCnt() > 0)
      throw new H2OIllegalArgumentException("DCT can not be computed on rows with missing values");
    if (!v.isNumeric())
      throw new H2OIllegalArgumentException("DCT can only be computed on numeric columns");
  }
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:14,代码来源:MathUtils.java

示例9: FloatDCT_2D

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
/**
 * Creates new instance of FloatDCT_2D.
 * 
 * @param rows
 *            number of rows
 * @param columns
 *            number of columns
 */
public FloatDCT_2D(int rows, int columns) {
    if (rows <= 1 || columns <= 1) {
        throw new IllegalArgumentException("rows and columns must be greater than 1");
    }
    this.rows = rows;
    this.columns = columns;
    if (rows * columns >= ConcurrencyUtils.getThreadsBeginN_2D()) {
        this.useThreads = true;
    }
    if (ConcurrencyUtils.isPowerOf2(rows) && ConcurrencyUtils.isPowerOf2(columns)) {
        isPowerOfTwo = true;
        oldNthreads = ConcurrencyUtils.getNumberOfThreads();
        nt = 4 * oldNthreads * rows;
        if (columns == 2 * oldNthreads) {
            nt >>= 1;
        } else if (columns < 2 * oldNthreads) {
            nt >>= 2;
        }
        t = new float[nt];
    }
    dctColumns = new FloatDCT_1D(columns);
    if (columns == rows) {
        dctRows = dctColumns;
    } else {
        dctRows = new FloatDCT_1D(rows);
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:FloatDCT_2D.java

示例10: realForwardFull

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
/**
 * Computes 2D forward DFT of real data leaving the result in <code>a</code>
 * . This method computes full real forward transform, i.e. you will get the
 * same result as from <code>complexForward</code> called with all imaginary
 * part equal 0. Because the result is stored in <code>a</code>, the input
 * array must be of size rows*2*columns, with only the first rows*columns
 * elements filled with real data. To get back the original data, use
 * <code>complexInverse</code> on the output of this method.
 * 
 * @param a
 *            data to transform
 */
public void realForwardFull(float[] a) {
    if (isPowerOfTwo) {
        int nthreads;

        nthreads = ConcurrencyUtils.getNumberOfThreads();
        if (nthreads != oldNthreads) {
            nt = 8 * nthreads * rows;
            if (columns == 4 * nthreads) {
                nt >>= 1;
            } else if (columns < 4 * nthreads) {
                nt >>= 2;
            }
            t = new float[nt];
            oldNthreads = nthreads;
        }
        if ((nthreads > 1) && useThreads) {
            xdft2d0_subth1(1, 1, a, true);
            cdft2d_subth(-1, a, true);
            rdft2d_sub(1, a);
        } else {
            for (int r = 0; r < rows; r++) {
                fftColumns.realForward(a, r * columns);
            }
            cdft2d_sub(-1, a, true);
            rdft2d_sub(1, a);
        }
        fillSymmetric(a);
    } else {
        mixedRadixRealForwardFull(a);
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:44,代码来源:FloatFFT_2D.java

示例11: createEqualityChecker

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
public FloatingPointEqualityChecker createEqualityChecker(final float rel,
		final float abs)
{
	final String msg = String.format(DEFAULT_MESSAGE,
			ConcurrencyUtils.getNumberOfThreads(), numRows, numCols);
	return new FloatingPointEqualityChecker(msg, 0d, 0d, rel, abs);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:8,代码来源:FloatFFT_2DTest.java

示例12: realInverseFull

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
/**
 * Computes 2D inverse DFT of real data leaving the result in <code>a</code>
 * . This method computes full real inverse transform, i.e. you will get the
 * same result as from <code>complexInverse</code> called with all imaginary
 * part equal 0. Because the result is stored in <code>a</code>, the input
 * array must be of size rows*2*columns, with only the first rows*columns
 * elements filled with real data.
 * 
 * @param a
 *            data to transform
 * 
 * @param scale
 *            if true then scaling is performed
 */
public void realInverseFull(float[] a, boolean scale) {
    if (isPowerOfTwo) {
        int nthreads;

        nthreads = ConcurrencyUtils.getNumberOfThreads();
        if (nthreads != oldNthreads) {
            nt = 8 * nthreads * rows;
            if (columns == 4 * nthreads) {
                nt >>= 1;
            } else if (columns < 4 * nthreads) {
                nt >>= 2;
            }
            t = new float[nt];
            oldNthreads = nthreads;
        }
        if ((nthreads > 1) && useThreads) {
            xdft2d0_subth2(1, -1, a, scale);
            cdft2d_subth(1, a, scale);
            rdft2d_sub(1, a);
        } else {
            for (int r = 0; r < rows; r++) {
                fftColumns.realInverse2(a, r * columns, scale);
            }
            cdft2d_sub(1, a, scale);
            rdft2d_sub(1, a);
        }
        fillSymmetric(a);
    } else {
        mixedRadixRealInverseFull(a, scale);
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:46,代码来源:FloatFFT_2D.java

示例13: xdft2d0_subth1

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
private void xdft2d0_subth1(final int icr, final int isgn, final float[] a, final boolean scale) {
    final int nthreads = ConcurrencyUtils.getNumberOfThreads() > rows ? rows : ConcurrencyUtils.getNumberOfThreads();

    Future<?>[] futures = new Future[nthreads];
    for (int i = 0; i < nthreads; i++) {
        final int n0 = i;
        futures[i] = ConcurrencyUtils.submit(new Runnable() {
            @Override
public void run() {
                if (icr == 0) {
                    if (isgn == -1) {
                        for (int r = n0; r < rows; r += nthreads) {
                            fftColumns.complexForward(a, r * columns);
                        }
                    } else {
                        for (int r = n0; r < rows; r += nthreads) {
                            fftColumns.complexInverse(a, r * columns, scale);
                        }
                    }
                } else {
                    if (isgn == 1) {
                        for (int r = n0; r < rows; r += nthreads) {
                            fftColumns.realForward(a, r * columns);
                        }
                    } else {
                        for (int r = n0; r < rows; r += nthreads) {
                            fftColumns.realInverse(a, r * columns, scale);
                        }
                    }
                }
            }
        });
    }
    ConcurrencyUtils.waitForCompletion(futures);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:FloatFFT_2D.java

示例14: createEqualityChecker

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
public FloatingPointEqualityChecker createEqualityChecker(final double rel,
		final double abs)
{
	final String msg = String.format(DEFAULT_MESSAGE,
			ConcurrencyUtils.getNumberOfThreads(), numRows, numCols);
	return new FloatingPointEqualityChecker(msg, rel, abs, 0f, 0f);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:8,代码来源:DoubleFFT_2DTest.java

示例15: xdft2d0_subth2

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入依赖的package包/类
private void xdft2d0_subth2(final int icr, final int isgn, final float[][] a, final boolean scale) {
    final int nthreads = ConcurrencyUtils.getNumberOfThreads() > rows ? rows : ConcurrencyUtils.getNumberOfThreads();

    Future<?>[] futures = new Future[nthreads];
    for (int i = 0; i < nthreads; i++) {
        final int n0 = i;
        futures[i] = ConcurrencyUtils.submit(new Runnable() {
            @Override
public void run() {
                if (icr == 0) {
                    if (isgn == -1) {
                        for (int r = n0; r < rows; r += nthreads) {
                            fftColumns.complexForward(a[r]);
                        }
                    } else {
                        for (int r = n0; r < rows; r += nthreads) {
                            fftColumns.complexInverse(a[r], scale);
                        }
                    }
                } else {
                    if (isgn == 1) {
                        for (int r = n0; r < rows; r += nthreads) {
                            fftColumns.realForward(a[r]);
                        }
                    } else {
                        for (int r = n0; r < rows; r += nthreads) {
                            fftColumns.realInverse2(a[r], 0, scale);
                        }
                    }
                }
            }
        });
    }
    ConcurrencyUtils.waitForCompletion(futures);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:FloatFFT_2D.java


注:本文中的edu.emory.mathcs.utils.ConcurrencyUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。