shared
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends
Static Public Member Functions | List of all members
SparseOps Class Reference

A class for sparse array operations. More...

#include <SparseOps.hpp>

Static Public Member Functions

static jobject createSparseArrayState (JNIEnv *env, ArrayPinHandler::jarray_type type, MergeResult *res, jarray oldV, jarray newV)
 Creates a sparse array by assigning old and new array values into it. More...
 
static MergeResultmerge (jint *oldIndices, jint *oldIndirections, jint oldLen, jint *newIndices, jint *newIndirections, jint newLen, jint *dims, jint *strides, jint *dimOffsets, jint nDims)
 Merges old and new array metadata. More...
 
static jint normalize (jint *values, jint start, jint end)
 Normalizes a range of sorted values such that duplicates are removed. More...
 
static void getSlicedIndirections (jint *sliceOffsets, jint *sliceCounts, jint *slices, jint *dimOffsets, jint *indirectionOffsets, jint *indirections, jint nIndirections, jint *dims, jint nDims, jint *result, jint &len)
 Gets the sliced indirections. More...
 
static void merge (jint *indices, jint *indirections, jint len, jint *resIndices, jint *resIndirections, jint &resLen)
 Merges sliced indirections by physical index. More...
 
static jobject slice (JNIEnv *env, jobject thisObj, jintArray slices, jobject srcV, jintArray srcD, jintArray srcS, jintArray srcDo, jintArray srcI, jintArray srcIo, jintArray srcIi, jobject dstV, jintArray dstD, jintArray dstS, jintArray dstDo, jintArray dstI, jintArray dstIo, jintArray dstIi)
 Slices one sparse array into another. More...
 
static jobject insert (JNIEnv *env, jobject thisObj, jobject oldV, jintArray oldD, jintArray oldS, jintArray oldDo, jintArray oldI, jobject newV, jintArray newI)
 Inserts elements into a sparse array. More...
 

Detailed Description

A class for sparse array operations.

Member Function Documentation

jobject SparseOps::createSparseArrayState ( JNIEnv *  env,
ArrayPinHandler::jarray_type  type,
MergeResult res,
jarray  oldV,
jarray  newV 
)
static

Creates a sparse array by assigning old and new array values into it.

Parameters
envthe JNI environment.
typethe common array type.
resthe MergeResult.
oldVthe old array.
newVthe new array.
Returns
the sparse array.
void SparseOps::getSlicedIndirections ( jint *  sliceOffsets,
jint *  sliceCounts,
jint *  slices,
jint *  dimOffsets,
jint *  indirectionOffsets,
jint *  indirections,
jint  nIndirections,
jint *  dims,
jint  nDims,
jint *  result,
jint &  len 
)
static

Gets the sliced indirections.

Parameters
sliceOffsetsthe slice offsets.
sliceCountsthe slice counts.
slicesthe slices.
dimOffsetsthe dimension offsets.
indirectionOffsetsthe indirection offsets.
indirectionsthe indirections.
nIndirectionsthe number of indirections.
dimsthe dimensions.
nDimsthe number of dimensions.
resultthe result array.
lenthe result length.
jobject SparseOps::insert ( JNIEnv *  env,
jobject  thisObj,
jobject  oldV,
jintArray  oldD,
jintArray  oldS,
jintArray  oldDo,
jintArray  oldI,
jobject  newV,
jintArray  newI 
)
static

Inserts elements into a sparse array.

Parameters
envthe JNI environment.
thisObjthis object.
oldVthe old values.
oldDthe old dimensions.
oldSthe old strides.
oldDothe old dimension offsets.
oldIthe old physical indices. Invariant: Sorted in ascending order, and does not contain duplicates.
newVthe new values.
newIthe new physical indices, which need not be sorted in ascending order.
Returns
the sparse array.
MergeResult * SparseOps::merge ( jint *  oldIndices,
jint *  oldIndirections,
jint  oldLen,
jint *  newIndices,
jint *  newIndirections,
jint  newLen,
jint *  dims,
jint *  strides,
jint *  dimOffsets,
jint  nDims 
)
static

Merges old and new array metadata.

Parameters
oldIndicesthe old physical indices. Invariant: Sorted in ascending order, and does not contain duplicates.
oldIndirectionsthe indirections on old values.
oldLenthe old array length.
newIndicesthe new physical indices. Invariant: Sorted in ascending order, and does not contain duplicates.
newIndirectionsthe indirections on new values.
newLenthe new array length.
dimsthe dimensions.
stridesthe strides.
dimOffsetsthe dimension offsets.
nDimsthe number of dimensions.
Returns
the MergeResult.
void SparseOps::merge ( jint *  indices,
jint *  indirections,
jint  len,
jint *  resIndices,
jint *  resIndirections,
jint &  resLen 
)
static

Merges sliced indirections by physical index.

Parameters
indicesthe physical indices.
indirectionsthe sliced indirections.
lenthe number of elements.
resIndicesthe resulting physical indices.
resIndirectionsthe resulting sliced indirections.
resLenthe resulting number of elements.
jint SparseOps::normalize ( jint *  values,
jint  start,
jint  end 
)
static

Normalizes a range of sorted values such that duplicates are removed.

Parameters
valuesthe array of values.
startthe start index.
endthe end index.
Returns
the number of resulting unique values.
jobject SparseOps::slice ( JNIEnv *  env,
jobject  thisObj,
jintArray  slices,
jobject  srcV,
jintArray  srcD,
jintArray  srcS,
jintArray  srcDo,
jintArray  srcI,
jintArray  srcIo,
jintArray  srcIi,
jobject  dstV,
jintArray  dstD,
jintArray  dstS,
jintArray  dstDo,
jintArray  dstI,
jintArray  dstIo,
jintArray  dstIi 
)
static

Slices one sparse array into another.

Parameters
envthe JNI environment.
thisObjthis object.
slicesthe slicing specification.
srcVthe source values.
srcDthe source dimensions.
srcSthe source strides.
srcDothe source dimension offsets.
srcIthe source physical indices. Invariant: Sorted in ascending order, and does not contain duplicates.
srcIothe source indirection offsets.
srcIithe source indirections.
dstVthe destination values.
dstDthe destination dimensions.
dstSthe destination strides.
dstDothe destination dimension offsets.
dstIthe destination physical indices. Invariant: Sorted in ascending order, and does not contain duplicates.
dstIothe destination indirection offsets.
dstIithe destination indirections.
Returns
the sparse array.