kml_sparse_?gthrz
Gather the elements specified in full-storage sparse vector y into a vector that is in compressed form
(the operation is defined as x[i]=y[indx[i]], i=0,1,…nz-1) and zero out these elements in y.
Interface Definition
C interface:
kml_sparse_status_t kml_sparse_sgthrz(const KML_INT nz, float *y, float *x, const KML_INT *indx);
kml_sparse_status_t kml_sparse_dgthrz(const KML_INT nz, double *y, double *x, const KML_INT *indx);
kml_sparse_status_t kml_sparse_cgthrz(const KML_INT nz, KML_Complex8 *y, KML_Complex8 *x, const KML_INT *indx);
kml_sparse_status_t kml_sparse_zgthrz(const KML_INT nz, KML_Complex16 *y, KML_Complex16 *x, const KML_INT *indx);
Fortran interface:
RES = KML_SPARSE_SGTHRZ(NZ, Y, X, INDX);
RES = KML_SPARSE_DGTHRZ(NZ, Y, X, INDX);
RES = KML_SPARSE_CGTHRZ(NZ, Y, X, INDX);
RES = KML_SPARSE_ZGTHRZ(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/Output |
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 i-th 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_sgthrz(nz, y, x, indx);
/*
* Output x:
* 5.000000 -2.000000
* Output y:
* -1.000000 0.000000 0.000000 3.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_SGTHRZ(NZ,Y,X,INDX);
!
! OUTPUT X:
! 5.000000 -2.000000
! OUTPUT Y:
! -1.000000 0.000000 0.000000 3.000000
!