public class ArrayUtilsGPU
extends java.lang.Object
field[i * 2 * N + 2 * j] = Re[i][j],
field[i * 2 * N + 2 * j + 1] = Im[i][j]; 0 <= i < M, 0 <= j < N
Modifier and Type | Method and Description |
---|---|
double[] |
complexAmplitude(int M,
int N,
double[] phase,
double amp)
Creates a complex array pointwise.
|
double[] |
complexAmplitude(int M,
int N,
double[] phase,
double[] amp)
Creates a complex array pointwise.
|
double[] |
complexAmplitude(int M,
int N,
double phase,
double[] amp)
Creates a complex array pointwise.
|
float[] |
complexAmplitude(int M,
int N,
float[] phase,
float amp)
Creates a complex array element by element.
|
float[] |
complexAmplitude(int M,
int N,
float[] phase,
float[] amp)
Creates a complex array pointwise.
|
float[] |
complexAmplitude(int M,
int N,
float phase,
float[] amp)
Creates a complex array pointwise.
|
double[] |
complexAmplitude2(int M,
int N,
double[] real,
double[] imaginary)
Takes the real and imaginary parts and returns a complex array.
|
float[] |
complexAmplitude2(int M,
int N,
float[] real,
float[] imaginary)
Takes the real and imaginary parts and returns a complex array.
|
double[] |
complexMultiplication(int M,
int N,
double[] a,
double[] b)
Computes the pointwise complex multiplication of 2 arrays.
|
float[] |
complexMultiplication(int M,
int N,
float[] a,
float[] b)
Computes the pointwise complex multiplication of 2 arrays.
|
void |
complexMultiplication2(int M,
int N,
double[] a,
double[] b)
Computes the pointwise complex multiplication of 2 arrays leaving the
result in
a . |
void |
complexMultiplication2(int M,
int N,
float[] a,
float[] b)
Computes the pointwise complex multiplication of 2 arrays leaving the
result in
a . |
void |
complexShift(int M,
int N,
double[] a)
Performs the circular shifting of a complex array, leaving the result in
a . |
void |
complexShift(int M,
int N,
float[] a)
Performs the circular shifting of a complex array, leaving the result in
a . |
void |
complexShiftGPU(int M,
int N,
jcuda.driver.CUdeviceptr devA,
boolean isFloat)
Performs the circular shifting of a complex array, leaving the result in
a . |
void |
divide(double[] a,
double num)
Computes the pointwise division of an array by
num , leaving the
result in a . |
void |
divide(float[] a,
float num)
Computes the pointwise division of an array by
num , leaving the
result in a . |
static ArrayUtilsGPU |
getInstance()
Returns the current instance of ArrayUtilsGPU.
|
double[] |
imaginary(int M,
int N,
double[] a)
Extracts the imaginary part of a complex array.
|
float[] |
imaginary(int M,
int N,
float[] a)
Extracts the imaginary part of a complex array.
|
static java.lang.String |
jDiffractionVersion()
Returns the library version as a String.
|
double[] |
log10(double[] a)
Computes log10 of a real array.
|
float[] |
log10(float[] a)
Computes log10 of a real array.
|
static void |
matrixToVectorArray(int M,
int N,
double[][] a,
double[] b)
Converts a 2D array into a 1D array leaving the result in
b . |
static void |
matrixToVectorArray(int M,
int N,
float[][] a,
float[] b)
Converts a 2D array into a 1D array leaving the result in
b . |
double |
max(double[] a)
Gets the max value of a real array.
|
float |
max(float[] a)
Gets the max value of a real array.
|
double |
min(double[] a)
Gets the min value of a real array.
|
float |
min(float[] a)
Gets the min value of a real array.
|
double[] |
modulus(int M,
int N,
double[] a)
Computes the modulus of a complex array.
|
float[] |
modulus(int M,
int N,
float[] a)
Computes the modulus of a complex array.
|
double[] |
modulusSq(int M,
int N,
double[] a)
Computes the squared modulus of a complex array.
|
float[] |
modulusSq(int M,
int N,
float[] a)
Computes the squared modulus of a complex array.
|
void |
multiply(double[] a,
double num)
Computes the pointwise multiplication of an array by
num , leaving
the result in a . |
void |
multiply(float[] a,
float num)
Computes the pointwise multiplication of an array by
num , leaving
the result in a . |
double[] |
phase(int M,
int N,
double[] a)
Computes the phase (angle) of a complex array.
|
float[] |
phase(int M,
int N,
float[] a)
Computes the phase (angle) of a complex array.
|
static double[] |
real(int M,
int N,
double[] a)
Extracts the real part of a complex array.
|
float[] |
real(int M,
int N,
float[] a)
Extracts the real part of a complex array.
|
void |
realShift(int M,
int N,
double[] a)
Performs the circular shifting of a real array, leaving the result in
a . |
void |
realShift(int M,
int N,
float[] a)
Performs the circular shifting of a real array, leaving the result in
a . |
double[] |
scale(double[] a,
double maxScale)
Scales a real array to
[0 - maxScale] . |
double[] |
scale(double[] a,
double max,
double min,
double maxScale)
Scales a real array to
[0 - maxScale] . |
float[] |
scale(float[] a,
float maxScale)
Scales a real array to
[0 - maxScale] . |
float[] |
scale(float[] a,
float max,
float min,
float maxScale)
Scales a real array to
[0 - maxScale] . |
void |
scale2(double[] a,
double maxScale)
Scales a real array to
[0 - maxScale] leaving the result in
a . |
void |
scale2(double[] a,
double max,
double min,
double maxScale)
Scales a real array to
[0 - maxScale] leaving the result in
a . |
void |
scale2(float[] a,
float maxScale)
Scales a real array to
[0 - maxScale] leaving the result in
a . |
void |
scale2(float[] a,
float max,
float min,
float maxScale)
Scales a real array to
[0 - maxScale] leaving the result in
a . |
static void |
vectorToMatrixArray(int M,
int N,
double[] a,
double[][] b)
Converts a 1D array into a 2D array leaving the result in
b . |
static void |
vectorToMatrixArray(int M,
int N,
float[] a,
float[][] b)
Converts a 1D array into a 2D array leaving the result in
b . |
public static ArrayUtilsGPU getInstance() throws java.io.IOException
null
, a new instance is created.java.io.IOException
public static java.lang.String jDiffractionVersion()
public float[] phase(int M, int N, float[] a)
phase[i * N + j] = atan(Im[i][j] / Re[i][j])
M
- number of rowsN
- number of columnsa
- complex arraypublic double[] phase(int M, int N, double[] a)
phase[i * N + j] = atan(Im[i][j] / Re[i][j])
M
- number of rowsN
- number of columnsa
- complex arraypublic float[] modulus(int M, int N, float[] a)
modulus[i * N + j] = sqrt(Re[i][j]^2 + Im[i][j]^2)
M
- number of rowsN
- number of columnsa
- complex arraypublic double[] modulus(int M, int N, double[] a)
modulus[i][j] = sqrt(Re[i][j]^2 + Im[i][j]^2)
M
- number of rowsN
- number of columnsa
- complex arraypublic float[] modulusSq(int M, int N, float[] a)
modulusSq[i * N + j] = Re[i][j]^2 + Im[i][j]^2
M
- number of rowsN
- number of columnsa
- complex arraypublic double[] modulusSq(int M, int N, double[] a)
modulusSq[i * N + j] = Re[i][j]^2 + Im[i][j]^2
M
- number of rowsN
- number of columnsa
- complex arraypublic float[] complexMultiplication(int M, int N, float[] a, float[] b)
M
- number of rowsN
- number of columnsa
- complex arrayb
- complex arraypublic double[] complexMultiplication(int M, int N, double[] a, double[] b)
M
- number of rowsN
- number of columnsa
- complex arrayb
- complex arraypublic void complexMultiplication2(int M, int N, float[] a, float[] b)
a
.M
- number of rowsN
- number of columnsa
- complex arrayb
- complex arraypublic void complexMultiplication2(int M, int N, double[] a, double[] b)
a
.M
- number of rowsN
- number of columnsa
- complex arrayb
- complex arraypublic float[] complexAmplitude(int M, int N, float[] phase, float[] amp)
amp * exp(i * phase)
.M
- number of rowsN
- number of columnsphase
- phase arrayamp
- amplitude arraypublic double[] complexAmplitude(int M, int N, double[] phase, double[] amp)
amp * exp(i * phase)
.M
- number of rowsN
- number of columnsphase
- phase arrayamp
- amplitude arraypublic float[] complexAmplitude(int M, int N, float[] phase, float amp)
amp * exp(i * phase)
M
- number of rowsN
- number of columnsphase
- phase arrayamp
- amplitudepublic double[] complexAmplitude(int M, int N, double[] phase, double amp)
amp * exp(i * phase)
.M
- number of rowsN
- number of columnsphase
- phase arrayamp
- amplitudepublic float[] complexAmplitude(int M, int N, float phase, float[] amp)
amp * exp(i * phase)
.M
- number of rowsN
- number of columnsphase
- phaseamp
- amplitude arraypublic double[] complexAmplitude(int M, int N, double phase, double[] amp)
amp * exp(i * phase)
.M
- number of rowsN
- number of columnsphase
- phaseamp
- amplitude arraypublic float[] complexAmplitude2(int M, int N, float[] real, float[] imaginary)
M
- number of rowsN
- number of columnsreal
- real part arrayimaginary
- imaginary part arraypublic double[] complexAmplitude2(int M, int N, double[] real, double[] imaginary)
M
- number of rowsN
- number of columnsreal
- real part arrayimaginary
- imaginary part arraypublic float[] real(int M, int N, float[] a)
M
- number of rowsN
- number of columnsa
- complex arraypublic static double[] real(int M, int N, double[] a)
M
- number of rowsN
- number of columnsa
- complex arraypublic float[] imaginary(int M, int N, float[] a)
M
- number of rowsN
- number of columnsa
- complex arraypublic double[] imaginary(int M, int N, double[] a)
M
- number of rowsN
- number of columnsa
- complex arraypublic void complexShift(int M, int N, float[] a)
a
.
a b -> d c
c d b a
M
- number of rowsN
- number of columnsa
- complex arraypublic void complexShift(int M, int N, double[] a)
a
.
a b -> d c
c d b a
M
- number of rowsN
- number of columnsa
- complex arraypublic void complexShiftGPU(int M, int N, jcuda.driver.CUdeviceptr devA, boolean isFloat)
a
.
a b -> d c
c d b a
M
- number of rowsN
- number of columnsdevA
- complex arrayisFloat
- public void realShift(int M, int N, float[] a)
a
.
a b -> d c
c d b a
M
- number of rowsN
- number of columnsa
- real arraypublic void realShift(int M, int N, double[] a)
a
.
a b -> d c
c d b a
M
- number of rowsN
- number of columnsa
- real arraypublic void multiply(float[] a, float num)
num
, leaving
the result in a
.a
- arraynum
- numberpublic void multiply(double[] a, double num)
num
, leaving
the result in a
.a
- arraynum
- numberpublic void divide(float[] a, float num)
num
, leaving the
result in a
.a
- arraynum
- numberpublic void divide(double[] a, double num)
num
, leaving the
result in a
.a
- arraynum
- numberpublic float[] log10(float[] a)
a
- arraypublic double[] log10(double[] a)
a
- arraypublic float max(float[] a)
a
- arraypublic double max(double[] a)
a
- arraypublic float min(float[] a)
a
- arraypublic double min(double[] a)
a
- arraypublic float[] scale(float[] a, float max, float min, float maxScale)
[0 - maxScale]
.a
- arraymax
- array's max valuemin
- array's min valuemaxScale
- max value of the output arraypublic double[] scale(double[] a, double max, double min, double maxScale)
[0 - maxScale]
.a
- arraymax
- array's max valuemin
- array's min valuemaxScale
- max value of the output arraypublic float[] scale(float[] a, float maxScale)
[0 - maxScale]
. Array's max and min values
are found using max(float[])
and min(float[])
.a
- arraymaxScale
- max value of the output arraypublic double[] scale(double[] a, double maxScale)
[0 - maxScale]
. Array's max and min values
are found using max(double[])
and min(double[])
.a
- arraymaxScale
- max value of the output arraypublic void scale2(float[] a, float max, float min, float maxScale)
[0 - maxScale]
leaving the result in
a
.a
- arraymax
- array's max valuemin
- array's min valuemaxScale
- max value of the output arraypublic void scale2(double[] a, double max, double min, double maxScale)
[0 - maxScale]
leaving the result in
a
.a
- arraymax
- array's max valuemin
- array's min valuemaxScale
- max value of the output arraypublic void scale2(float[] a, float maxScale)
[0 - maxScale]
leaving the result in
a
. Array's max and min values are found using
max(float[])
and min(float[])
.a
- arraymaxScale
- max value of the output arraypublic void scale2(double[] a, double maxScale)
[0 - maxScale]
leaving the result in
a
. Array's max and min values are found using
max(double[])
and min(double[])
.a
- arraymaxScale
- max value of the output arraypublic static void vectorToMatrixArray(int M, int N, float[] a, float[][] b)
b
. It
is assumed that the information on the 1D array is distributed as the
rows of the 2D array in sequence.M
- number of data points in x directionN
- number of data points in y directiona
- 1D arrayb
- 2D arraypublic static void vectorToMatrixArray(int M, int N, double[] a, double[][] b)
b
. It
is assumed that the information on the 1D array is distributed as the
rows of the 2D array in sequence.M
- number of data points in x directionN
- number of data points in y directiona
- 1D arrayb
- 2D arraypublic static void matrixToVectorArray(int M, int N, float[][] a, float[] b)
b
. The
information on the 1D array is distributed as the rows of the 2D array in
sequence.M
- number of data points in x directionN
- number of data points in y directiona
- 2D arrayb
- 1D arraypublic static void matrixToVectorArray(int M, int N, double[][] a, double[] b)
b
. The
information on the 1D array is distributed as the rows of the 2D array in
sequence.M
- number of data points in x directionN
- number of data points in y directiona
- 2D arrayb
- 1D array