kml_sparse_?gthr
Gather the elements specified in full-storage sparse vector y to a vector that is in compressed form.
x[i]=y[indx[i]], i=0,1, ..., nz-1
Interface Definition
C interface:
kml_sparse_status_t kml_sparse_sgthr(const KML_INT nz, const float *y, float *x, const KML_INT *indx);
kml_sparse_status_t kml_sparse_dgthr(const KML_INT nz, const double *y, double *x,const KML_INT *indx);
kml_sparse_status_t kml_sparse_cgthr(const KML_INT nz, const KML_Complex8 *y, KML_Complex16 *x, const KML_INT *indx);
kml_sparse_status_t kml_sparse_zgthr(const KML_INT nz, const KML_Complex16 *y, KML_Complex16 *x, const KML_INT *indx);
Fortran interface:
RES = KML_SPARSE_SGTHR(NZ, Y, X, INDX);
RES = KML_SPARSE_DGTHR(NZ, Y, X, INDX);
RES = KML_SPARSE_CGTHR(NZ, Y, X, INDX);
RES = KML_SPARSE_ZGTHR(NZ, Y, X, INDX);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
nz |
Integer |
Number of elements in the x and indx arrays |
Input |
y |
|
Array y. The size is at least max(indx[i]). |
Input |
x |
|
Array x for storing non-zero elements. The size is at least nz. |
Input/Output |
indx |
Integer array |
indx[i] indicates the serial number of the ith element in the x array in the dense vector. The array size is at least nz. |
Input |
Return Value
Function execution status. The enumeration type is kml_sparse_status_t.
Dependencies
C: "kspblas.h"
Fortran: "kspblas.f03"
Examples
C interface:
KML_INT nz = 2;
KML_INT indx[2] = {1,2};
float x[2] = {0,0};
float y[4] = {-1, 5, -2 ,3};
kml_sparse_status_t status = kml_sparse_sgthr(nz,y,x,indx);
/*
* Output x:
* 5.000000 -2.000000
*/
Fortran interface:
INTEGER(C_INT) :: NZ = 2
INTEGER(C_INT) :: INDX(2)
INTEGER(C_INT) :: STATUS
REAL(C_FLOAT) :: X(2), Y(4)
DATA INDX/1,2/
DATA X/0,0/
DATA Y/-1, 5, -2 ,3/
STATUS = KML_SPARSE_SGTHR(NZ,Y,X,INDX);
!
! OUTPUT X:
! 5.000000 -2.000000
!