public class NativeArrayKernel extends Object implements ArrayKernel
ArrayKernel
.C_TO_R_ABS, C_TO_R_IM, C_TO_R_RE, CA_PROD, CA_SUM, CE_ADD, CE_DIV, CE_MUL, CE_SUB, CU_ADD, CU_CONJ, CU_COS, CU_EXP, CU_FILL, CU_MUL, CU_RND, CU_SHUFFLE, CU_SIN, I_TO_R, IE_ADD, IE_MAX, IE_MIN, IE_MUL, IE_SUB, IU_ADD, IU_FILL, IU_MUL, IU_SHUFFLE, R_TO_C_IM, R_TO_C_RE, RA_ENT, RA_MAX, RA_MIN, RA_PROD, RA_SUM, RA_VAR, RD_PROD, RD_SUM, RE_ADD, RE_DIV, RE_MAX, RE_MIN, RE_MUL, RE_SUB, RI_GZERO, RI_LZERO, RI_MAX, RI_MIN, RI_SORT, RI_ZERO, RR_MAX, RR_MIN, RR_PROD, RR_SUM, RR_VAR, RU_ABS, RU_ADD, RU_ATAN, RU_COS, RU_EXP, RU_FILL, RU_INV, RU_LOG, RU_MUL, RU_POW, RU_RND, RU_SHUFFLE, RU_SIN, RU_SQR, RU_SQRT
Constructor and Description |
---|
NativeArrayKernel()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
double[] |
caOp(int type,
double[] srcV)
Performs a complex accumulator operation.
|
void |
convert(int type,
Object srcV,
boolean isSrcComplex,
Object dstV,
boolean isDstComplex)
Performs a conversion operation.
|
void |
cuOp(int type,
double aRe,
double aIm,
double[] srcV)
Applies a complex unary operation.
|
void |
derandomize()
Seeds the underlying source of randomness with a constant.
|
void |
diag(double[] srcV,
double[] dstV,
int size,
boolean complex)
Gets the diagonal of a
Matrix . |
void |
eigs(double[] srcV,
double[] vecV,
double[] valV,
int size)
Computes the eigenvectors and eigenvalues of a
Matrix . |
void |
eOp(int type,
Object lhsV,
Object rhsV,
Object dstV,
boolean complex)
Applies a binary operation.
|
int[] |
find(int[] srcV,
int[] srcD,
int[] srcS,
int[] logical)
Extracts the valid indices along a dimension anchored at the given logical index.
|
<V> SparseArrayState<V> |
insertSparse(V oldV,
int[] oldD,
int[] oldS,
int[] oldDo,
int[] oldI,
V newV,
int[] newLi)
Inserts elements into a sparse array.
|
void |
invert(double[] srcV,
double[] dstV,
int size)
Computes the inverse of a
Matrix . |
void |
iuOp(int type,
int a,
int[] srcV)
Applies an integer unary operation.
|
void |
map(int[] bounds,
Object srcV,
int[] srcD,
int[] srcS,
Object dstV,
int[] dstD,
int[] dstS)
Performs a mapping operation.
|
void |
mul(double[] lhsV,
double[] rhsV,
int lr,
int rc,
double[] dstV,
boolean complex)
Multiplies two
Matrix s. |
void |
randomize()
Seeds the underlying source of randomness with the current time.
|
double |
raOp(int type,
double[] srcV)
Performs a real accumulator operation.
|
void |
rdOp(int type,
double[] srcV,
int[] srcD,
int[] srcS,
double[] dstV,
int... opDims)
Performs a real dimension operation.
|
void |
riOp(int type,
double[] srcV,
int[] srcD,
int[] srcS,
int[] dstV,
int dim)
Performs a real index operation.
|
void |
rrOp(int type,
double[] srcV,
int[] srcD,
int[] srcS,
double[] dstV,
int[] dstD,
int[] dstS,
int... opDims)
Performs a real reduce operation.
|
void |
ruOp(int type,
double a,
double[] srcV)
Applies a real unary operation.
|
void |
slice(int[] slices,
Object srcV,
int[] srcD,
int[] srcS,
Object dstV,
int[] dstD,
int[] dstS)
Performs a slicing operation.
|
<V> SparseArrayState<V> |
sliceSparse(int[] slices,
V srcV,
int[] srcD,
int[] srcS,
int[] srcDo,
int[] srcI,
int[] srcIo,
int[] srcIi,
V dstV,
int[] dstD,
int[] dstS,
int[] dstDo,
int[] dstI,
int[] dstIo,
int[] dstIi)
Slices one sparse array into another.
|
void |
svd(double[] srcV,
int srcStrideRow,
int srcStrideCol,
double[] uV,
double[] sV,
double[] vV,
int nRows,
int nCols)
Computes the singular value decomposition of a
Matrix . |
public NativeArrayKernel()
public final void randomize()
ArrayKernel
randomize
in interface ArrayKernel
public final void derandomize()
ArrayKernel
derandomize
in interface ArrayKernel
public final void map(int[] bounds, Object srcV, int[] srcD, int[] srcS, Object dstV, int[] dstD, int[] dstS)
ArrayKernel
map
in interface ArrayKernel
bounds
- the mapping bounds.srcV
- the source values.srcD
- the source dimensions.srcS
- the source strides.dstV
- the destination values.dstD
- the destination dimensions.dstS
- the destination strides.public final void slice(int[] slices, Object srcV, int[] srcD, int[] srcS, Object dstV, int[] dstD, int[] dstS)
ArrayKernel
slice
in interface ArrayKernel
slices
- the slicing specification.srcV
- the source values.srcD
- the source dimensions.srcS
- the source strides.dstV
- the destination values.dstD
- the destination dimensions.dstS
- the destination strides.public final void rrOp(int type, double[] srcV, int[] srcD, int[] srcS, double[] dstV, int[] dstD, int[] dstS, int... opDims)
ArrayKernel
rrOp
in interface ArrayKernel
type
- the operation type.srcV
- the source values.srcD
- the source dimensions.srcS
- the source strides.dstV
- the destination values.dstD
- the destination dimensions.dstS
- the destination strides.opDims
- the dimensions of interest.public final void riOp(int type, double[] srcV, int[] srcD, int[] srcS, int[] dstV, int dim)
ArrayKernel
riOp
in interface ArrayKernel
type
- the operation type.srcV
- the source values.srcD
- the source dimensions.srcS
- the source strides.dstV
- the destination values.dim
- the dimension of interest.public final void rdOp(int type, double[] srcV, int[] srcD, int[] srcS, double[] dstV, int... opDims)
ArrayKernel
rdOp
in interface ArrayKernel
type
- the operation type.srcV
- the source values.srcD
- the source dimensions.srcS
- the source strides.dstV
- the destination values.opDims
- the dimensions of interest.public final double raOp(int type, double[] srcV)
ArrayKernel
raOp
in interface ArrayKernel
type
- the operation type.srcV
- the array.public final double[] caOp(int type, double[] srcV)
ArrayKernel
caOp
in interface ArrayKernel
type
- the operation type.srcV
- the array.public final void ruOp(int type, double a, double[] srcV)
ArrayKernel
ruOp
in interface ArrayKernel
type
- the operation type.a
- the argument, if any.srcV
- the array.public final void cuOp(int type, double aRe, double aIm, double[] srcV)
ArrayKernel
cuOp
in interface ArrayKernel
type
- the operation type.aRe
- the real part of the argument, if any.aIm
- the imaginary part of the argument, if any.srcV
- the array.public final void iuOp(int type, int a, int[] srcV)
ArrayKernel
iuOp
in interface ArrayKernel
type
- the operation type.a
- the argument, if any.srcV
- the array.public final void eOp(int type, Object lhsV, Object rhsV, Object dstV, boolean complex)
ArrayKernel
eOp
in interface ArrayKernel
type
- the operation type.lhsV
- the left hand side values.rhsV
- the right hand side values.dstV
- the destination values.complex
- whether the operation is complex-valued.public final void convert(int type, Object srcV, boolean isSrcComplex, Object dstV, boolean isDstComplex)
ArrayKernel
convert
in interface ArrayKernel
type
- the operation type.srcV
- the source values.isSrcComplex
- whether the source is complex-valued.dstV
- the destination values.isDstComplex
- whether the destination is complex-valued.public final void mul(double[] lhsV, double[] rhsV, int lr, int rc, double[] dstV, boolean complex)
ArrayKernel
Matrix
s. They are assumed to have storage order Array.IndexingOrder.FAR
.mul
in interface ArrayKernel
lhsV
- the left hand side values.rhsV
- the right hand side values.lr
- the row count of the result.rc
- the column count of the result.dstV
- the destination values.complex
- whether the operation is complex-valued.public final void diag(double[] srcV, double[] dstV, int size, boolean complex)
ArrayKernel
Matrix
.diag
in interface ArrayKernel
srcV
- source values.dstV
- destination values.size
- the matrix size.complex
- whether the operation is complex-valued.public final void svd(double[] srcV, int srcStrideRow, int srcStrideCol, double[] uV, double[] sV, double[] vV, int nRows, int nCols)
ArrayKernel
Matrix
.svd
in interface ArrayKernel
srcV
- the source values.srcStrideRow
- the source row stride.srcStrideCol
- the source column stride.uV
- the input vectors.sV
- the gain controls.vV
- the output vectors.nRows
- the number of rows.nCols
- the number of columns.public final void eigs(double[] srcV, double[] vecV, double[] valV, int size)
ArrayKernel
Matrix
.eigs
in interface ArrayKernel
srcV
- the source values.vecV
- the eigenvectors.valV
- the eigenvalues.size
- the matrix size.public final void invert(double[] srcV, double[] dstV, int size)
ArrayKernel
Matrix
.invert
in interface ArrayKernel
srcV
- the source values.dstV
- the destination values.size
- the matrix size.public final int[] find(int[] srcV, int[] srcD, int[] srcS, int[] logical)
ArrayKernel
find
in interface ArrayKernel
srcV
- the source values.srcD
- the source dimensions.srcS
- the source strides.logical
- the logical index.public final <V> SparseArrayState<V> insertSparse(V oldV, int[] oldD, int[] oldS, int[] oldDo, int[] oldI, V newV, int[] newLi)
ArrayKernel
insertSparse
in interface ArrayKernel
V
- the storage array type.oldV
- the old values.oldD
- the old dimensions.oldS
- the old strides.oldDo
- the old dimension offsets.oldI
- the old physical indices. Invariant: Sorted in ascending order, and does not contain duplicates.newV
- the new values.newLi
- the new physical indices, which need not be sorted in ascending order.SparseArrayState
.public final <V> SparseArrayState<V> sliceSparse(int[] slices, V srcV, int[] srcD, int[] srcS, int[] srcDo, int[] srcI, int[] srcIo, int[] srcIi, V dstV, int[] dstD, int[] dstS, int[] dstDo, int[] dstI, int[] dstIo, int[] dstIi)
ArrayKernel
sliceSparse
in interface ArrayKernel
V
- the storage array type.slices
- the slicing specification.srcV
- the source values.srcD
- the source dimensions.srcS
- the source strides.srcDo
- the source dimension offsets.srcI
- the source physical indices. Invariant: Sorted in ascending order, and does not contain duplicates.srcIo
- the source indirection offsets.srcIi
- the source indirections.dstV
- the destination values.dstD
- the destination dimensions.dstS
- the destination strides.dstDo
- the destination dimension offsets.dstI
- the destination physical indices. Invariant: Sorted in ascending order, and does not contain
duplicates.dstIo
- the destination indirection offsets.dstIi
- the destination indirections.SparseArrayState
.