magma_int_t magma_dindexsort( magma_index_t *x, magma_int_t first, magma_int_t last, magma_queue_t queue ) { magma_int_t info = 0; magma_index_t pivot,j,temp,i; if(first<last){ pivot=first; i=first; j=last; while(i<j){ while( x[i]<=x[pivot] && i<last ) i++; while( x[j]>x[pivot] ) j--; if( i<j ){ temp = x[i]; x[i] = x[j]; x[j] = temp; } } temp=x[pivot]; x[pivot]=x[j]; x[j]=temp; CHECK( magma_dindexsort( x, first, j-1, queue )); CHECK( magma_dindexsort( x, j+1, last, queue )); } cleanup: return info; }
magma_int_t magma_dindexcopy( magma_int_t num_copy, magma_int_t offset, magma_index_t *tmp_x, magma_index_t *x, magma_queue_t queue ) { magma_int_t info = 0; CHECK( magma_dindexsort( tmp_x, 0, num_copy-1, queue )); for( magma_int_t j=0; j<num_copy; j++ ){ x[ j+offset ] = tmp_x[ j ]; tmp_x[ j ] = -1; } cleanup: return info; }