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


Java ConcurrencyUtils.isPowerOf2方法代码示例

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


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

示例1: FloatFFT_2D

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * Creates new instance of FloatFFT_2D.
 * 
 * @param rows
 *            number of rows
 * @param columns
 *            number of columns
 */
public FloatFFT_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 = 8 * oldNthreads * rows;
        if (2 * columns == 4 * oldNthreads) {
            nt >>= 1;
        } else if (2 * columns < 4 * oldNthreads) {
            nt >>= 2;
        }
        t = new float[nt];
    }
    fftRows = new FloatFFT_1D(rows);
    if (rows == columns) {
        fftColumns = fftRows;
    } else {
        fftColumns = new FloatFFT_1D(columns);
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:FloatFFT_2D.java

示例2: DoubleFFT_2D

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * Creates new instance of DoubleFFT_2D.
 * 
 * @param rows
 *            number of rows
 * @param columns
 *            number of columns
 */
public DoubleFFT_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 = 8 * oldNthreads * rows;
        if (2 * columns == 4 * oldNthreads) {
            nt >>= 1;
        } else if (2 * columns < 4 * oldNthreads) {
            nt >>= 2;
        }
        t = new double[nt];
    }
    fftRows = new DoubleFFT_1D(rows);
    if (rows == columns) {
        fftColumns = fftRows;
    } else {
        fftColumns = new DoubleFFT_1D(columns);
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:DoubleFFT_2D.java

示例3: DoubleDST_2D

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * Creates new instance of DoubleDST_2D.
 * 
 * @param rows
 *            number of rows
 * @param columns
 *            number of columns
 */
public DoubleDST_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()) {
        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 double[nt];
    }
    dstColumns = new DoubleDST_1D(columns);
    if (columns == rows) {
        dstRows = dstColumns;
    } else {
        dstRows = new DoubleDST_1D(rows);
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:DoubleDST_2D.java

示例4: FloatDST_2D

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * Creates new instance of FloatDST_2D.
 * 
 * @param rows
 *            number of rows
 * @param columns
 *            number of columns
 */
public FloatDST_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()) {
        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];
    }
    dstColumns = new FloatDST_1D(columns);
    if (columns == rows) {
        dstRows = dstColumns;
    } else {
        dstRows = new FloatDST_1D(rows);
    }
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:FloatDST_2D.java

示例5: testRealInverseScaled1dInput

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * A test of {@link DoubleFFT_2D#realInverse(double[], boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled1dInput() {
	if (!ConcurrencyUtils.isPowerOf2(numRows)) {
		return;
	}
	if (!ConcurrencyUtils.isPowerOf2(numCols)) {
		return;
	}
	final double rel = 1E-9;
	final double x0 = 1E-14;
	final double abs = rel * x0;
	final FloatingPointEqualityChecker checker = createEqualityChecker(rel,
			abs);
	final double[] actual = new double[numRows * numCols];
	final double[] expected = new double[actual.length];
	for (int i = 0; i < actual.length; i++) {
		final double rnd = random.nextDouble();
		actual[i] = rnd;
		expected[i] = rnd;
	}
	fft.realForward(actual);
	fft.realInverse(actual, true);
	for (int i = 0; i < actual.length; i++) {
		final double exp = expected[i];
		final double act = actual[i];
		checker.assertEquals("[" + i + "]", exp, act);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:33,代码来源:DoubleFFT_2DTest.java

示例6: 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

示例7: testRealInverseScaled1fInput

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_2D#realInverse(float[], boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled1fInput() {
	final float rel = 5E-4f;
	final float x0 = 5E-3f;
	final float abs = rel * x0;
	final FloatingPointEqualityChecker checker = createEqualityChecker(rel,
			abs);
	if (!ConcurrencyUtils.isPowerOf2(numRows)) {
		return;
	}
	if (!ConcurrencyUtils.isPowerOf2(numCols)) {
		return;
	}
	final float[] actual = new float[numRows * numCols];
	final float[] expected = new float[actual.length];
	for (int i = 0; i < actual.length; i++) {
		final float rnd = random.nextFloat();
		actual[i] = rnd;
		expected[i] = rnd;
	}
	fft.realForward(actual);
	fft.realInverse(actual, true);
	for (int i = 0; i < actual.length; i++) {
		final float exp = expected[i];
		final float act = actual[i];
		checker.assertEquals("[" + i + "]", exp, act);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:33,代码来源:FloatFFT_2DTest.java

示例8: testRealInverseScaled2fInput

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_2D#realInverse(float[][], boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled2fInput() {
	final float rel = 5E-4f;
	final float x0 = 5E-3f;
	final float abs = rel * x0;
	final FloatingPointEqualityChecker checker = createEqualityChecker(rel,
			abs);
	if (!ConcurrencyUtils.isPowerOf2(numRows)) {
		return;
	}
	if (!ConcurrencyUtils.isPowerOf2(numCols)) {
		return;
	}
	final float[][] actual = new float[numRows][numCols];
	final float[][] expected = new float[numRows][numCols];
	for (int r = 0; r < numRows; r++) {
		for (int c = 0; c < numCols; c++) {
			final float rnd = random.nextFloat();
			actual[r][c] = rnd;
			expected[r][c] = rnd;
		}
	}
	fft.realForward(actual);
	fft.realInverse(actual, true);
	for (int r = 0; r < numRows; r++) {
		for (int c = 0; c < numCols; c++) {
			final float exp = expected[r][c];
			final float act = actual[r][c];
			checker.assertEquals("[" + r + "][" + c + "]", exp, act);
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:37,代码来源:FloatFFT_2DTest.java

示例9: testRealInverseScaled1fInput

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_3D#realInverse(float[], boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled1fInput() {
	if (!ConcurrencyUtils.isPowerOf2(numRows)) {
		return;
	}
	if (!ConcurrencyUtils.isPowerOf2(numCols)) {
		return;
	}
	if (!ConcurrencyUtils.isPowerOf2(numSlices)) {
		return;
	}
	final float rel = 2E-4f;
	final float x0 = 5E-3f;
	final float abs = rel * x0;
	final FloatingPointEqualityChecker checker = createEqualityChecker(rel,
			abs);
	final float[] actual = new float[numRows * numCols * numSlices];
	final float[] expected = new float[actual.length];
	for (int i = 0; i < actual.length; i++) {
		final float rnd = random.nextFloat();
		actual[i] = rnd;
		expected[i] = rnd;
	}
	fft.realForward(actual);
	fft.realInverse(actual, true);
	for (int i = 0; i < actual.length; i++) {
		final float exp = expected[i];
		final float act = actual[i];
		checker.assertEquals("[" + i + "]", exp, act);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:FloatFFT_3DTest.java

示例10: testRealInverseScaled1dInput

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * A test of {@link DoubleFFT_3D#realInverse(double[], boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled1dInput() {
	if (!ConcurrencyUtils.isPowerOf2(numRows)) {
		return;
	}
	if (!ConcurrencyUtils.isPowerOf2(numCols)) {
		return;
	}
	if (!ConcurrencyUtils.isPowerOf2(numSlices)) {
		return;
	}
	final double rel = 1E-9;
	final double x0 = 3E-7;
	final double abs = rel * x0;
	final FloatingPointEqualityChecker checker = createEqualityChecker(rel,
			abs);
	final double[] actual = new double[numRows * numCols * numSlices];
	final double[] expected = new double[actual.length];
	for (int i = 0; i < actual.length; i++) {
		final double rnd = random.nextDouble();
		actual[i] = rnd;
		expected[i] = rnd;
	}
	fft.realForward(actual);
	fft.realInverse(actual, true);
	for (int i = 0; i < actual.length; i++) {
		final double exp = expected[i];
		final double act = actual[i];
		checker.assertEquals("[" + i + "]", exp, act);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:36,代码来源:DoubleFFT_3DTest.java

示例11: DoubleFFT_3D

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * Creates new instance of DoubleFFT_3D.
 * 
 * @param slices
 *            number of slices
 * @param rows
 *            number of rows
 * @param columns
 *            number of columns
 * 
 */
public DoubleFFT_3D(int slices, int rows, int columns) {
    if (slices <= 1 || rows <= 1 || columns <= 1) {
        throw new IllegalArgumentException("slices, rows and columns must be greater than 1");
    }
    this.slices = slices;
    this.rows = rows;
    this.columns = columns;
    this.sliceStride = rows * columns;
    this.rowStride = columns;
    if (slices * rows * columns >= ConcurrencyUtils.getThreadsBeginN_3D()) {
        this.useThreads = true;
    }
    if (ConcurrencyUtils.isPowerOf2(slices) && ConcurrencyUtils.isPowerOf2(rows) && ConcurrencyUtils.isPowerOf2(columns)) {
        isPowerOfTwo = true;
        oldNthreads = ConcurrencyUtils.getNumberOfThreads();
        nt = slices;
        if (nt < rows) {
            nt = rows;
        }
        nt *= 8;
        if (oldNthreads > 1) {
            nt *= oldNthreads;
        }
        if (2 * columns == 4) {
            nt >>= 1;
        } else if (2 * columns < 4) {
            nt >>= 2;
        }
        t = new double[nt];
    }
    fftSlices = new DoubleFFT_1D(slices);
    if (slices == rows) {
        fftRows = fftSlices;
    } else {
        fftRows = new DoubleFFT_1D(rows);
    }
    if (slices == columns) {
        fftColumns = fftSlices;
    } else if (rows == columns) {
        fftColumns = fftRows;
    } else {
        fftColumns = new DoubleFFT_1D(columns);
    }

}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:57,代码来源:DoubleFFT_3D.java

示例12: FloatFFT_3D

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * Creates new instance of FloatFFT_3D.
 *
 * @param slices
 *            number of slices
 * @param rows
 *            number of rows
 * @param columns
 *            number of columns
 *
 */
public FloatFFT_3D(int slices, int rows, int columns) {
    if (slices <= 1 || rows <= 1 || columns <= 1) {
        throw new IllegalArgumentException("slices, rows and columns must be greater than 1");
    }
    this.slices = slices;
    this.rows = rows;
    this.columns = columns;
    this.sliceStride = rows * columns;
    this.rowStride = columns;
    if (slices * rows * columns >= ConcurrencyUtils.getThreadsBeginN_3D()) {
        this.useThreads = true;
    }
    if (ConcurrencyUtils.isPowerOf2(slices) && ConcurrencyUtils.isPowerOf2(rows) && ConcurrencyUtils.isPowerOf2(columns)) {
        isPowerOfTwo = true;
        oldNthreads = ConcurrencyUtils.getNumberOfThreads();
        nt = slices;
        if (nt < rows) {
            nt = rows;
        }
        nt *= 8;
        if (oldNthreads > 1) {
            nt *= oldNthreads;
        }
        if (2 * columns == 4) {
            nt >>= 1;
        } else if (2 * columns < 4) {
            nt >>= 2;
        }
        t = new float[nt];
    }
    fftSlices = new FloatFFT_1D(slices);
    if (slices == rows) {
        fftRows = fftSlices;
    } else {
        fftRows = new FloatFFT_1D(rows);
    }
    if (slices == columns) {
        fftColumns = fftSlices;
    } else if (rows == columns) {
        fftColumns = fftRows;
    } else {
        fftColumns = new FloatFFT_1D(columns);
    }

}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:57,代码来源:FloatFFT_3D.java

示例13: FloatDST_3D

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

示例14: DoubleDST_3D

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

示例15: testRealInverseScaled3fInput

import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_3D#realInverse(float[][][], boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled3fInput() {
	if (!ConcurrencyUtils.isPowerOf2(numRows)) {
		return;
	}
	if (!ConcurrencyUtils.isPowerOf2(numCols)) {
		return;
	}
	if (!ConcurrencyUtils.isPowerOf2(numSlices)) {
		return;
	}
	final float rel = 2E-4f;
	final float x0 = 5E-3f;
	final float abs = rel * x0;
	final FloatingPointEqualityChecker checker = createEqualityChecker(rel,
			abs);
	final float[][][] actual = new float[numSlices][numRows][numCols];
	final float[][][] expected = new float[numSlices][numRows][numCols];
	for (int s = 0; s < numSlices; s++) {
		for (int r = 0; r < numRows; r++) {
			for (int c = 0; c < numCols; c++) {
				final float rnd = random.nextFloat();
				actual[s][r][c] = rnd;
				expected[s][r][c] = rnd;
			}
		}
	}
	fft.realForward(actual);
	fft.realInverse(actual, true);
	for (int s = 0; s < numSlices; s++) {
		for (int r = 0; r < numRows; r++) {
			for (int c = 0; c < numCols; c++) {
				final float exp = expected[s][r][c];
				final float act = actual[s][r][c];
				checker.assertEquals("[" + s + "][" + r + "][" + c + "]",
						exp, act);
			}
		}
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:45,代码来源:FloatFFT_3DTest.java


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