本文整理汇总了Java中edu.emory.mathcs.utils.ConcurrencyUtils.getNumberOfThreads方法的典型用法代码示例。如果您正苦于以下问题:Java ConcurrencyUtils.getNumberOfThreads方法的具体用法?Java ConcurrencyUtils.getNumberOfThreads怎么用?Java ConcurrencyUtils.getNumberOfThreads使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.emory.mathcs.utils.ConcurrencyUtils
的用法示例。
在下文中一共展示了ConcurrencyUtils.getNumberOfThreads方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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) {
dctColumns.forward(a, r * columns, scale);
}
} else {
for (int r = n0; r < rows; r += nthreads) {
dctColumns.inverse(a, r * columns, scale);
}
}
}
});
}
ConcurrencyUtils.waitForCompletion(futures);
}
示例2: 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);
}
示例3: 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 by 2*columns, with only the first rows by
* 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(double[][] 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 double[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]);
}
cdft2d_sub(-1, a, true);
rdft2d_sub(1, a);
}
fillSymmetric(a);
} else {
mixedRadixRealForwardFull(a);
}
}
示例4: 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 by 2*columns, with only the first rows by
* 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]);
}
cdft2d_sub(-1, a, true);
rdft2d_sub(1, a);
}
fillSymmetric(a);
} else {
mixedRadixRealForwardFull(a);
}
}
示例5: cftbsub
import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
private void cftbsub(int n, double[] a, int offa, int[] ip, int nw, double[] w) {
if (n > 8) {
if (n > 32) {
cftb1st(n, a, offa, w, nw - (n >> 2));
if ((ConcurrencyUtils.getNumberOfThreads() > 1) && (n > ConcurrencyUtils.getThreadsBeginN_1D_FFT_2Threads())) {
cftrec4_th(n, a, offa, nw, w);
} else if (n > 512) {
cftrec4(n, a, offa, nw, w);
} else if (n > 128) {
cftleaf(n, 1, a, offa, nw, w);
} else {
cftfx41(n, a, offa, nw, w);
}
bitrv2conj(n, ip, a, offa);
} else if (n == 32) {
cftf161(a, offa, w, nw - 8);
bitrv216neg(a, offa);
} else {
cftf081(a, offa, w, 0);
bitrv208neg(a, offa);
}
} else if (n == 8) {
cftb040(a, offa);
} else if (n == 4) {
cftx020(a, offa);
}
}
示例6: 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);
}
}
示例7: realInverseFull
import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
* Computes 3D 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 slices by rows by 2*columns, with only the first slices by rows by
* 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 = ConcurrencyUtils.getNumberOfThreads();
if (nthreads != oldNthreads) {
nt = slices;
if (nt < rows) {
nt = rows;
}
nt *= 8;
if (nthreads > 1) {
nt *= nthreads;
}
if (columns == 4) {
nt >>= 1;
} else if (columns < 4) {
nt >>= 2;
}
t = new float[nt];
oldNthreads = nthreads;
}
if ((nthreads > 1) && useThreads) {
xdft3da_subth2(1, 1, a, scale);
cdft3db_subth(1, a, scale);
rdft3d_sub(1, a);
} else {
xdft3da_sub2(1, 1, a, scale);
cdft3db_sub(1, a, scale);
rdft3d_sub(1, a);
}
fillSymmetric(a);
} else {
mixedRadixRealInverseFull(a, scale);
}
}
示例8: 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]);
}
} 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.realInverse(a[r], scale);
}
}
}
}
});
}
ConcurrencyUtils.waitForCompletion(futures);
}
示例9: realForwardFull
import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
* Computes 3D 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 slices*rows*2*columns, with only the first slices*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(double[] a) {
if (isPowerOfTwo) {
int nthreads = ConcurrencyUtils.getNumberOfThreads();
if (nthreads != oldNthreads) {
nt = slices;
if (nt < rows) {
nt = rows;
}
nt *= 8;
if (nthreads > 1) {
nt *= nthreads;
}
if (columns == 4) {
nt >>= 1;
} else if (columns < 4) {
nt >>= 2;
}
t = new double[nt];
oldNthreads = nthreads;
}
if ((nthreads > 1) && useThreads) {
xdft3da_subth2(1, -1, a, true);
cdft3db_subth(-1, a, true);
rdft3d_sub(1, a);
} else {
xdft3da_sub2(1, -1, a, true);
cdft3db_sub(-1, a, true);
rdft3d_sub(1, a);
}
fillSymmetric(a);
} else {
mixedRadixRealForwardFull(a);
}
}
示例10: scale
import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
private void scale(final double m, final double[] a, int offa, boolean complex) {
final double norm = (1.0 / m);
int n2;
if (complex) {
n2 = 2 * n;
} else {
n2 = n;
}
int nthreads = ConcurrencyUtils.getNumberOfThreads();
if ((nthreads > 1) && (n2 >= ConcurrencyUtils.getThreadsBeginN_1D_FFT_2Threads())) {
final int k = n2 / nthreads;
Future<?>[] futures = new Future[nthreads];
for (int i = 0; i < nthreads; i++) {
final int firstIdx = offa + i * k;
final int lastIdx = (i == (nthreads - 1)) ? offa + n2 : firstIdx + k;
futures[i] = ConcurrencyUtils.submit(new Runnable() {
@Override
public void run() {
for (int i = firstIdx; i < lastIdx; i++) {
a[i] *= norm;
}
}
});
}
ConcurrencyUtils.waitForCompletion(futures);
} else {
for (int i = offa; i < offa + n2; i++) {
a[i] *= norm;
}
}
}
示例11: realInverseFull
import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
* Computes 3D 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 slices by rows by 2*columns, with only the first slices by rows by
* columns elements filled with real data.
*
* @param a
* data to transform
* @param scale
* if true then scaling is performed
*/
public void realInverseFull(double[][][] a, boolean scale) {
if (isPowerOfTwo) {
int nthreads = ConcurrencyUtils.getNumberOfThreads();
if (nthreads != oldNthreads) {
nt = slices;
if (nt < rows) {
nt = rows;
}
nt *= 8;
if (nthreads > 1) {
nt *= nthreads;
}
if (columns == 4) {
nt >>= 1;
} else if (columns < 4) {
nt >>= 2;
}
t = new double[nt];
oldNthreads = nthreads;
}
if ((nthreads > 1) && useThreads) {
xdft3da_subth2(1, 1, a, scale);
cdft3db_subth(1, a, scale);
rdft3d_sub(1, a);
} else {
xdft3da_sub2(1, 1, a, scale);
cdft3db_sub(1, a, scale);
rdft3d_sub(1, a);
}
fillSymmetric(a);
} else {
mixedRadixRealInverseFull(a, scale);
}
}
示例12: 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);
}
}
示例13: DoubleDCT_3D
import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
* Creates new instance of DoubleDCT_3D.
*
* @param slices
* number of slices
* @param rows
* number of rows
* @param columns
* number of columns
*/
public DoubleDCT_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];
}
dctSlices = new DoubleDCT_1D(slices);
if (slices == rows) {
dctRows = dctSlices;
} else {
dctRows = new DoubleDCT_1D(rows);
}
if (slices == columns) {
dctColumns = dctSlices;
} else if (rows == columns) {
dctColumns = dctRows;
} else {
dctColumns = new DoubleDCT_1D(columns);
}
}
示例14: forward
import edu.emory.mathcs.utils.ConcurrencyUtils; //导入方法依赖的package包/类
/**
* Computes 1D real, forward DHT leaving the result in <code>a</code>.
*
* @param a
* data to transform
* @param offa
* index of the first element in array <code>a</code>
*/
public void forward(final double[] a, final int offa) {
if (n == 1)
return;
fft.realForward(a, offa);
final double[] b = new double[n];
System.arraycopy(a, offa, b, 0, n);
int nd2 = n / 2;
int nthreads = ConcurrencyUtils.getNumberOfThreads();
if ((nthreads > 1) && (nd2 > ConcurrencyUtils.getThreadsBeginN_1D_FFT_2Threads())) {
nthreads = 2;
final int k1 = nd2 / nthreads;
Future<?>[] futures = new Future[nthreads];
for (int i = 0; i < nthreads; i++) {
final int firstIdx = 1 + i * k1;
final int lastIdx = (i == (nthreads - 1)) ? nd2 : firstIdx + k1;
futures[i] = ConcurrencyUtils.submit(new Runnable() {
@Override
public void run() {
int idx1, idx2;
for (int i = firstIdx; i < lastIdx; i++) {
idx1 = 2 * i;
idx2 = idx1 + 1;
a[offa + i] = b[idx1] - b[idx2];
a[offa + n - i] = b[idx1] + b[idx2];
}
}
});
}
ConcurrencyUtils.waitForCompletion(futures);
} else {
int idx1, idx2;
for (int i = 1; i < nd2; i++) {
idx1 = 2 * i;
idx2 = idx1 + 1;
a[offa + i] = b[idx1] - b[idx2];
a[offa + n - i] = b[idx1] + b[idx2];
}
}
if ((n % 2) == 0) {
a[offa + nd2] = b[1];
} else {
a[offa + nd2] = b[n - 1] - b[1];
a[offa + nd2 + 1] = b[n - 1] + b[1];
}
}
示例15: 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);
}
}