本文整理汇总了Java中org.jtransforms.utils.CommonUtils.setThreadsBeginN_2D方法的典型用法代码示例。如果您正苦于以下问题:Java CommonUtils.setThreadsBeginN_2D方法的具体用法?Java CommonUtils.setThreadsBeginN_2D怎么用?Java CommonUtils.setThreadsBeginN_2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jtransforms.utils.CommonUtils
的用法示例。
在下文中一共展示了CommonUtils.setThreadsBeginN_2D方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseArguments
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
public static void parseArguments(String[] args)
{
if (args.length > 0) {
nthread = Integer.parseInt(args[0]);
threadsBegin2D = Integer.parseInt(args[1]);
threadsBegin3D = Integer.parseInt(args[2]);
niter = Integer.parseInt(args[3]);
doWarmup = Boolean.parseBoolean(args[4]);
doScaling = Boolean.parseBoolean(args[5]);
nsize = Integer.parseInt(args[6]);
sizes1D = new long[nsize];
sizes2D = new long[nsize];
sizes3D = new long[nsize];
for (int i = 0; i < nsize; i++) {
sizes1D[i] = Integer.parseInt(args[7 + i]);
}
for (int i = 0; i < nsize; i++) {
sizes2D[i] = Integer.parseInt(args[7 + nsize + i]);
}
for (int i = 0; i < nsize; i++) {
sizes3D[i] = Integer.parseInt(args[7 + nsize + nsize + i]);
}
} else {
System.out.println("Default settings are used.");
}
ConcurrencyUtils.setNumberOfThreads(nthread);
CommonUtils.setThreadsBeginN_2D(threadsBegin2D);
CommonUtils.setThreadsBeginN_3D(threadsBegin3D);
System.out.println("nthred = " + nthread);
System.out.println("threadsBegin2D = " + threadsBegin2D);
System.out.println("threadsBegin3D = " + threadsBegin3D);
System.out.println("niter = " + niter);
System.out.println("doWarmup = " + doWarmup);
System.out.println("doScaling = " + doScaling);
System.out.println("nsize = " + nsize);
System.out.println("sizes1D[] = " + Arrays.toString(sizes1D));
System.out.println("sizes2D[] = " + Arrays.toString(sizes2D));
System.out.println("sizes3D[] = " + Arrays.toString(sizes3D));
}
示例2: DoubleFFT_2DTest
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Creates a new instance of this test.
*
* @param numRows
* number of rows
* @param numColumns
* number of columns
* @param numThreads
* the number of threads to be used
* @param seed
* the seed of the random generator
*/
public DoubleFFT_2DTest(final int numRows, final int numColumns,
final int numThreads, final long seed)
{
this.numRows = numRows;
this.numCols = numColumns;
LargeArray.setMaxSizeOf32bitArray(1);
this.rfft = new DoubleFFT_1D(numColumns);
this.cfft = new DoubleFFT_1D(numRows);
this.fft = new DoubleFFT_2D(numRows, numColumns);
this.random = new Random(seed);
ConcurrencyUtils.setNumberOfThreads(numThreads);
CommonUtils.setThreadsBeginN_2D(4);
this.numThreads = ConcurrencyUtils.getNumberOfThreads();
}
示例3: FloatFFT_2DTest
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Creates a new instance of this test.
*
* @param numRows
* number of rows
* @param numColumns
* number of columns
* @param numThreads
* the number of threads to be used
* @param seed
* the seed of the random generator
*/
public FloatFFT_2DTest(final int numRows, final int numColumns,
final int numThreads, final long seed)
{
this.numRows = numRows;
this.numCols = numColumns;
LargeArray.setMaxSizeOf32bitArray(1);
this.rfft = new FloatFFT_1D(numColumns);
this.cfft = new FloatFFT_1D(numRows);
this.fft = new FloatFFT_2D(numRows, numColumns);
this.random = new Random(seed);
ConcurrencyUtils.setNumberOfThreads(numThreads);
CommonUtils.setThreadsBeginN_2D(4);
this.numThreads = ConcurrencyUtils.getNumberOfThreads();
}
示例4: DoubleDST_2DTest
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Creates a new instance of this test.
*
* @param numRows
* number of rows
* @param numColumns
* number of columns
* @param numThreads
* the number of threads to be used
* @param seed
* the seed of the random generator
*/
public DoubleDST_2DTest(final int numRows, final int numColumns,
final int numThreads, final long seed)
{
this.numRows = numRows;
this.numCols = numColumns;
LargeArray.setMaxSizeOf32bitArray(1);
this.dst = new DoubleDST_2D(numRows, numCols);
this.random = new Random(seed);
ConcurrencyUtils.setNumberOfThreads(numThreads);
CommonUtils.setThreadsBeginN_2D(4096);
this.numThreads = ConcurrencyUtils.getNumberOfThreads();
}
示例5: FloatDST_2DTest
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Creates a new instance of this test.
*
* @param numRows
* number of rows
* @param numColumns
* number of columns
* @param numThreads
* the number of threads to be used
* @param seed
* the seed of the random generator
*/
public FloatDST_2DTest(final int numRows, final int numColumns,
final int numThreads, final long seed)
{
this.numRows = numRows;
this.numCols = numColumns;
LargeArray.setMaxSizeOf32bitArray(1);
this.dst = new FloatDST_2D(numRows, numCols);
this.random = new Random(seed);
ConcurrencyUtils.setNumberOfThreads(numThreads);
CommonUtils.setThreadsBeginN_2D(4096);
this.numThreads = ConcurrencyUtils.getNumberOfThreads();
}
示例6: DoubleDCT_2DTest
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Creates a new instance of this test.
*
* @param numRows number of rows
* @param numColumns number of columns
* @param numThreads the number of threads to be used
* @param seed the seed of the random generator
*/
public DoubleDCT_2DTest(final int numRows, final int numColumns,
final int numThreads, final long seed)
{
this.numRows = numRows;
this.numCols = numColumns;
LargeArray.setMaxSizeOf32bitArray(1);
this.dct = new DoubleDCT_2D(numRows, numCols);
this.random = new Random(seed);
ConcurrencyUtils.setNumberOfThreads(numThreads);
CommonUtils.setThreadsBeginN_2D(4096);
this.numThreads = ConcurrencyUtils.getNumberOfThreads();
}
示例7: FloatDCT_2DTest
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Creates a new instance of this test.
*
* @param numRows
* number of rows
* @param numColumns
* number of columns
* @param numThreads
* the number of threads to be used
* @param seed
* the seed of the random generator
*/
public FloatDCT_2DTest(final int numRows, final int numColumns,
final int numThreads, final long seed)
{
this.numRows = numRows;
this.numCols = numColumns;
LargeArray.setMaxSizeOf32bitArray(1);
this.dct = new FloatDCT_2D(numRows, numCols);
this.random = new Random(seed);
ConcurrencyUtils.setNumberOfThreads(numThreads);
CommonUtils.setThreadsBeginN_2D(4096);
this.numThreads = ConcurrencyUtils.getNumberOfThreads();
}
示例8: FloatDHT_2DTest
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Creates a new instance of this test.
*
* @param numRows
* number of rows
* @param numColumns
* number of columns
* @param numThreads
* the number of threads to be used
* @param seed
* the seed of the random generator
*/
public FloatDHT_2DTest(final int numRows, final int numColumns,
final int numThreads, final long seed)
{
this.numRows = numRows;
this.numCols = numColumns;
LargeArray.setMaxSizeOf32bitArray(1);
this.dht = new FloatDHT_2D(numRows, numCols);
this.random = new Random(seed);
ConcurrencyUtils.setNumberOfThreads(numThreads);
CommonUtils.setThreadsBeginN_2D(4096);
this.numThreads = ConcurrencyUtils.getNumberOfThreads();
}
示例9: DoubleDHT_2DTest
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Creates a new instance of this test.
*
* @param numRows
* number of rows
* @param numColumns
* number of columns
* @param numThreads
* the number of threads to be used
* @param seed
* the seed of the random generator
*/
public DoubleDHT_2DTest(final int numRows, final int numColumns,
final int numThreads, final long seed)
{
this.numRows = numRows;
this.numCols = numColumns;
LargeArray.setMaxSizeOf32bitArray(1);
this.dht = new DoubleDHT_2D(numRows, numCols);
this.random = new Random(seed);
ConcurrencyUtils.setNumberOfThreads(numThreads);
CommonUtils.setThreadsBeginN_2D(4096);
this.numThreads = ConcurrencyUtils.getNumberOfThreads();
}
示例10: initialiseKernel
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
/**
* Initialise the kernel FHT. It is recreated only if the target size has changed.
*
* @param maxx
* the width of the target image
* @param maxy
* the height of the target image
*/
public void initialiseKernel(int maxx, int maxy)
{
int maxN = Maths.nextPow2(Maths.max(maxx, maxy, kN));
if (tmp == null || tmp.length != maxN * maxN)
tmp = new float[maxN * maxN];
if (kernelFht != null && maxN == kernelFht.getWidth())
// Already initialised
return;
int size = maxN * maxN;
// No window function for the kernel so just create a new FHT
float[] data;
if (kw < maxN || kh < maxN)
{
// Too small so insert in the middle
data = new float[size];
int x = getInsert(maxN, kw);
int y = getInsert(maxN, kh);
insert(kernel, kw, data, maxN, x, y);
}
else
{
// Clone to avoid destroying data
data = kernel.clone();
}
// Do the transform using JTransforms as it is faster. Do not allow multi-threading.
long begin = CommonUtils.getThreadsBeginN_2D();
CommonUtils.setThreadsBeginN_2D(Long.MAX_VALUE);
dht = new FloatDHT_2D(maxN, maxN);
CommonUtils.setThreadsBeginN_2D(begin);
dht.forward(data);
kernelFht = new FHT2(data, maxN, true);
//kernelFht = new FHT2(data, maxN, false);
//kernelFht.transform();
if (operation == Operation.DECONVOLUTION)
kernelFht.initialiseFastOperations();
else
kernelFht.initialiseFastMultiply();
// This is used for the output complex multiple of the two FHTs
tmp = new float[size];
}
示例11: jTransforms2DDHTIsFasterThanFHT2
import org.jtransforms.utils.CommonUtils; //导入方法依赖的package包/类
@Test
public void jTransforms2DDHTIsFasterThanFHT2()
{
// Test the forward DHT of data. and reverse transform or the pre-computed correlation.
int size = 256;
int w = size / 4;
RandomGenerator r = new Well19937c(30051977);
RandomDataGenerator rdg = new RandomDataGenerator(r);
// Blob in the centre
FloatProcessor fp = createProcessor(size, size / 2 - w / 2, size / 2 - w / 2, w, w, null);
FHT2 fht2 = new FHT2((float[]) fp.getPixels(), size, false);
fht2.transform();
fht2.initialiseFastMultiply();
// Random blobs, original and correlated
int N = 40;
float[][] data = new float[N * 2][];
int lower = w;
int upper = size - w;
for (int i = 0, j = 0; i < N; i++)
{
int x = rdg.nextInt(lower, upper);
int y = rdg.nextInt(lower, upper);
fp = createProcessor(size, x, y, w, w, r);
float[] pixels = (float[]) fp.getPixels();
data[j++] = pixels.clone();
FHT2 fht1 = new FHT2(pixels, size, false);
fht1.copyTables(fht2);
fht2.transform();
float[] pixels2 = new float[pixels.length];
fht2.conjugateMultiply(fht2, pixels2);
data[j++] = pixels2;
}
//CommonUtils.setThreadsBeginN_1D_FFT_2Threads(Long.MAX_VALUE);
//CommonUtils.setThreadsBeginN_1D_FFT_4Threads(Long.MAX_VALUE);
CommonUtils.setThreadsBeginN_2D(Long.MAX_VALUE);
TimingService ts = new TimingService();
ts.execute(new IJFHTSpeedTask(size, data));
ts.execute(new IJFHT2SpeedTask(size, data));
ts.execute(new JTransformsDHTSpeedTask(size, data));
ts.repeat();
ts.report();
Assert.assertTrue(ts.get(-1).getMean() < ts.get(-2).getMean());
}