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


Java CommonUtils.isPowerOf2方法代码示例

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


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

示例1: FloatFFT_2D

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Creates new instance of FloatFFT_2D.
 *  
 * @param rows    number of rows
 * @param columns number of columns
 */
public FloatFFT_2D(long rows, long columns)
{
    if (rows <= 1 || columns <= 1) {
        throw new IllegalArgumentException("rows and columns must be greater than 1");
    }

    this.rows = (int) rows;
    this.columns = (int) columns;
    this.rowsl = rows;
    this.columnsl = columns;
    if (rows * columns >= CommonUtils.getThreadsBeginN_2D()) {
        this.useThreads = true;
    }
    if (CommonUtils.isPowerOf2(rows) && CommonUtils.isPowerOf2(columns)) {
        isPowerOfTwo = true;
    }
    CommonUtils.setUseLargeArrays(2 * rows * columns > LargeArray.getMaxSizeOf32bitArray());
    fftRows = new FloatFFT_1D(rows);
    if (rows == columns) {
        fftColumns = fftRows;
    } else {
        fftColumns = new FloatFFT_1D(columns);
    }
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:31,代码来源:FloatFFT_2D.java

示例2: testRealForwardLarge

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link DoubleFFT_2D#realForward(DoubleLargeArray)}.
 */
@Test
public void testRealForwardLarge()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numCols)) {
        return;
    }
    final DoubleLargeArray actual = new DoubleLargeArray(2 * numRows * numCols);
    final DoubleLargeArray expected = new DoubleLargeArray(numRows * 2 * numCols);
    for (int r = 0; r < numRows; r++) {
        for (int c = 0; c < numCols; c++) {
            final double rnd = random.nextDouble();
            actual.setDouble(r * numCols + c, rnd);
            expected.setDouble(r * 2 * numCols + 2 * c, rnd);
        }
    }
    fft.realForward(actual);
    fft.complexForward(expected);
    fillSymmetric(actual, numRows, numCols);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:28,代码来源:DoubleFFT_2DTest.java

示例3: testRealForward2dInput

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_2D#realForward(float[][])}.
 */
@Test
public void testRealForward2dInput()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numCols)) {
        return;
    }
    final float[][] actual = new float[numRows][2 * numCols];
    final float[][] expected = new float[numRows][2 * 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][2 * c] = rnd;
        }
    }
    fft.realForward(actual);
    complexForward(expected);
    fillSymmetric(actual, numRows, numCols);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);

}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:29,代码来源:FloatFFT_2DTest.java

示例4: testRealInverseScaled2dInput

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link DoubleFFT_2D#realInverse(double[][], boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled2dInput()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numCols)) {
        return;
    }
    final double[][] actual = new double[numRows][numCols];
    final double[][] expected = new double[numRows][numCols];
    for (int r = 0; r < numRows; r++) {
        for (int c = 0; c < numCols; c++) {
            final double rnd = random.nextDouble();
            actual[r][c] = rnd;
            expected[r][c] = rnd;
        }
    }
    fft.realForward(actual);
    fft.realInverse(actual, true);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:28,代码来源:DoubleFFT_2DTest.java

示例5: testRealInverseScaledLarge

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_3D#realInverse(FloatLargeArray, boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaledLarge()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numCols)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numSlices)) {
        return;
    }
    final FloatLargeArray actual = new FloatLargeArray(numRows * numCols * numSlices);
    final FloatLargeArray expected = new FloatLargeArray(actual.length());
    for (int i = 0; i < actual.length(); i++) {
        final float rnd = random.nextFloat();
        actual.setFloat(i, rnd);
        expected.setFloat(i, rnd);
    }
    fft.realForward(actual);
    fft.realInverse(actual, true);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numSlices, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:29,代码来源:FloatFFT_3DTest.java

示例6: DoubleDCT_2D

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Creates new instance of DoubleDCT_2D.
 *  
 * @param rows    number of rows
 * @param columns number of columns
 */
public DoubleDCT_2D(long rows, long columns)
{
    if (rows <= 1 || columns <= 1) {
        throw new IllegalArgumentException("rows and columns must be greater than 1");
    }
    this.rows = (int) rows;
    this.columns = (int) columns;
    this.rowsl = rows;
    this.columnsl = columns;
    if (rows * columns >= CommonUtils.getThreadsBeginN_2D()) {
        this.useThreads = true;
    }
    if (CommonUtils.isPowerOf2(rows) && CommonUtils.isPowerOf2(columns)) {
        isPowerOfTwo = true;
    }
    CommonUtils.setUseLargeArrays(rows * columns > LargeArray.getMaxSizeOf32bitArray());
    dctRows = new DoubleDCT_1D(rows);
    if (rows == columns) {
        dctColumns = dctRows;
    } else {
        dctColumns = new DoubleDCT_1D(columns);
    }
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:30,代码来源:DoubleDCT_2D.java

示例7: testRealInverseScaled1dInput

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_2D#realInverse(float[], boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled1dInput()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.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);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:26,代码来源:FloatFFT_2DTest.java

示例8: testRealInverseUnscaled

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * This is a test of {@link FloatFFT_1D#realInverse(float[], boolean)}, with
 * the second parameter set to <code>false</code>.
 */
@Test
public void testRealInverseUnscaled()
{
    final float[] actual = new float[n];
    final float[] expected = new float[n];
    for (int i = 0; i < n; i++) {
        actual[i] = 2.f * random.nextFloat() - 1.f;
        expected[i] = actual[i];
    }
    fft.realForward(actual);
    fft.realInverse(actual, false);
    float s;
    if (CommonUtils.isPowerOf2(n) && n > 1) {
        s = 2.f / (float) n;
    } else {
        s = 1.f / (float) n;
    }
    for (int i = 0; i < actual.length; i++) {
        actual[i] = s * actual[i];
    }
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, n) + ", rmse = " + rmse, 0.0, rmse, EPS_UNSCALED);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:28,代码来源:FloatFFT_1DTest.java

示例9: testRealForwardLarge

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_2D#realForward(FloatLargeArray)}.
 */
@Test
public void testRealForwardLarge()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numCols)) {
        return;
    }
    final FloatLargeArray actual = new FloatLargeArray(2 * numRows * numCols);
    final FloatLargeArray expected = new FloatLargeArray(numRows * 2 * numCols);
    for (int r = 0; r < numRows; r++) {
        for (int c = 0; c < numCols; c++) {
            final float rnd = random.nextFloat();
            actual.setDouble(r * numCols + c, rnd);
            expected.setDouble(r * 2 * numCols + 2 * c, rnd);
        }
    }
    fft.realForward(actual);
    fft.complexForward(expected);
    fillSymmetric(actual, numRows, numCols);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:28,代码来源:FloatFFT_2DTest.java

示例10: testRealInverseScaled1dInput

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link DoubleFFT_2D#realInverse(double[], boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled1dInput()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numCols)) {
        return;
    }
    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);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:26,代码来源:DoubleFFT_2DTest.java

示例11: testRealInverseScaled1dInput

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_3D#realInverse(float[], boolean)}, with the
 * second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled1dInput()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numCols)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numSlices)) {
        return;
    }
    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);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numSlices, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:29,代码来源:FloatFFT_3DTest.java

示例12: FloatDCT_1D

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Creates new instance of FloatDCT_1D.
 *  
 * @param n size of data
 *
 */
public FloatDCT_1D(long n)
{
    if (n < 1) {
        throw new IllegalArgumentException("n must be greater than 0");
    }

    this.n = (int) n;
    if (true) {
        if (n > (1 << 28)) {
            throw new IllegalArgumentException("n must be smaller or equal to " + (1 << 28) + " when useLargeArrays argument is set to false");
        }
        if (CommonUtils.isPowerOf2(n)) {
            this.isPowerOfTwo = true;
            this.ip = new int[(int) ceil(2 + (1 << (int) (log(n / 2 + 0.5) / log(2)) / 2))];
            this.w = new float[this.n * 5 / 4];
            nw = ip[0];
            if (n > (nw << 2)) {
                nw = this.n >> 2;
                CommonUtils.makewt(nw, ip, w);
            }
            nc = ip[1];
            if (n > nc) {
                nc = this.n;
                CommonUtils.makect(nc, w, nw, ip);
            }
        } else {
            throw new IllegalStateException();
        }
    }
}
 
开发者ID:pmarks-net,项目名称:chromadoze,代码行数:37,代码来源:FloatDCT_1D.java

示例13: testRealForward3dInput

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_3D#realForward(float[][][])}.
 */
@Test
public void testRealForward3dInput()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numCols)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numSlices)) {
        return;
    }
    final float[][][] actual = new float[numSlices][numRows][2 * numCols];
    final float[][][] expected = new float[numSlices][numRows][2 * 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][2 * c] = rnd;
            }
        }
    }
    fft.realForward(actual);
    fft.complexForward(expected);
    fillSymmetric(actual, numSlices, numRows, numCols);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numSlices, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:33,代码来源:FloatFFT_3DTest.java

示例14: testRealInverseScaled3dInput

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link DoubleFFT_3D#realInverse(double[][][], boolean)}, with
 * the second parameter set to <code>true</code>.
 */
@Test
public void testRealInverseScaled3dInput()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numCols)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numSlices)) {
        return;
    }
    final double[][][] actual = new double[numSlices][numRows][numCols];
    final double[][][] expected = new double[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 double rnd = random.nextDouble();
                actual[s][r][c] = rnd;
                expected[s][r][c] = rnd;
            }
        }
    }
    fft.realForward(actual);
    fft.realInverse(actual, true);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numSlices, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:33,代码来源:DoubleFFT_3DTest.java

示例15: testRealForwardLarge

import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * A test of {@link FloatFFT_3D#realForward(FloatLargeArray)}.
 */
@Test
public void testRealForwardLarge()
{
    if (!CommonUtils.isPowerOf2(numRows)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numCols)) {
        return;
    }
    if (!CommonUtils.isPowerOf2(numSlices)) {
        return;
    }
    int index;
    final FloatLargeArray actual = new FloatLargeArray(numSlices * numRows * 2 * numCols);
    final FloatLargeArray expected = new FloatLargeArray(numSlices * numRows * 2 * numCols);
    for (int s = 0; s < numSlices; s++) {
        for (int r = 0; r < numRows; r++) {
            for (int c = 0; c < numCols; c++) {
                index = c + numCols * (r + numRows * s);
                final float rnd = random.nextFloat();
                actual.setFloat(index, rnd);
                expected.setFloat(s * 2 * numRows * numCols + r * 2 * numCols + 2 * c, rnd);
            }
        }
    }
    fft.realForward(actual);
    fft.complexForward(expected);
    fillSymmetric(actual, numSlices, numRows, numCols);
    double rmse = IOUtils.computeRMSE(actual, expected);
    Assert.assertEquals(String.format(DEFAULT_MESSAGE, numThreads, numSlices, numRows, numCols) + ", rmse = " + rmse, 0.0, rmse, EPS);
}
 
开发者ID:wendykierp,项目名称:JTransforms,代码行数:35,代码来源:FloatFFT_3DTest.java


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