Developer Reference

Sorting an Observation Matrix

You can use Summary Statistics routines to sort observation matrices by components of a random vector in the ascending order. The routines sort either rows or columns of the observation matrix depending on its storage, row- or column-major format. Sorting results are packed by the routines in accordance with your settings of the storage format for the output matrix. For supported storage formats see the table
Storage format of matrix of observations, order statistics and matrix of sorted observations
in the Summary Statistics section of [MKLMan].
You should allocate enough memory to hold the results of the calculations. The size of the array should provide storage for
elements, where:
  • p
    is the dimension of the task
  • n
    is the number of observations
Register the memory and storage format of the sorting result using the
editor before sorting the matrix of the observations. If you want the library to store sorting results into the input matrix, use the storage type for matrix of the sorted observations identical to the one of the input dataset. In this case you cannot choose individual components of the random vector for sorting.
The library offers the radix sort method to sort the data. The sorting follows the pattern of the example below:
#define DIM 3 /* dimension of the task */ #define N 10 /* number of observations */ int main() { VSLSSTaskPtr task; MKL_INT p, n; MKL_INT x_storage, sorted_x_storage; MKL_INT indices[DIM]={1,1,0}; /* the first two vector components are processed */ double x[DIM][N]; /* matrix of observations */ double y[DIM][N]; /* sorted matrix of observations */ int status; /* Parameters of the task and initialization */ n = N; p = DIM; x_storage = VSL_SS_MATRIX_STORAGE_ROWS; sorted_x_storage = VSL_SS_MATRIX_STORAGE_ROWS; /* Create a task */ status = vsldSSNewTask(&task, &p, &n, &x_storage, (double *)x, 0, indices); /* Initialize the task parameters*/ status = vsldSSEditTask(task, VSL_SS_ED_SORTED_OBSERV, y); status = vsliSSEditTask(task, VSL_SS_ED_SORTED_OBSERV_STORAGE, &sorted_x_storage); /* Sort the observation matrix using the radix method **/ status = vsldSSCompute(task, VSL_SS_SORTED_OBSERV, VSL_SS_METHOD_RADIX); /* Deallocate the task resources */ status = vslSSDeleteTask(&task); return 0; }

Product and Performance Information


Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804