예제 #1
0
void fcrystal_tuple_sort(const sint *const handle, const sint *const n,
                         sint   Ai[], const sint *const mi,
                         slong  Al[], const sint *const ml,
                         double Ad[], const sint *const md,
                         const sint keys[], const sint *const nkey)
{
  const size_t size_i = (*mi)*sizeof(sint),
               size_l = (*ml)*sizeof(slong),
               size_d = (*md)*sizeof(double);
  int init=0;
  sint nk = *nkey;
  buffer *buf;
  CHECK_HANDLE("crystal_tuple_sort");
  buf = &handle_array[*handle]->data;
  if(nk<=0) return;
  while(--nk>=0) {
    sint k = keys[nk]-1;
    if(k<0 || k>=*mi+*ml)
      fail(1,__FILE__,__LINE__,"crystal_tuple_sort: invalid key");
    else if(k<*mi) sortp     (buf,init, (uint *)&Ai[k],    *n,size_i);
    else           sortp_long(buf,init, (ulong*)&Al[k-*mi],*n,size_l);
    init=1;
  }
  if(*mi) sarray_permute_buf_(ALIGNOF(sint  ),size_i,Ai,*n, buf);
  if(*ml) sarray_permute_buf_(ALIGNOF(slong ),size_l,Al,*n, buf);
  if(*md) sarray_permute_buf_(ALIGNOF(double),size_d,Ad,*n, buf);
}
예제 #2
0
void fcrystal_ituple_sort(const sint *handle,
                          sint A[], const sint *m, const sint *n,
                          const sint keys[], const sint *nkey)
{
  const size_t size = (*m)*sizeof(sint);
  sint nk = *nkey;
  buffer *buf;
  CHECK_HANDLE("crystal_ituple_sort");
  buf = &handle_array[*handle]->data;
  if(--nk>=0) {
    sortp(buf,0, (uint*)&A[keys[nk]-1],*n,size);
    while(--nk>=0)
      sortp(buf,1, (uint*)&A[keys[nk]-1],*n,size);
    sarray_permute_buf_(ALIGNOF(sint),size,A,*n, buf);
  }
}
예제 #3
0
inline void sortp(Iter first, Iter last, IterP p)
{
  typedef typename std::iterator_traits<Iter>::value_type T;  
  typedef typename std::iterator_traits<IterP>::value_type P;  
  sortp(first, last, p, std::less<T>(), std::allocator<P>());
}
예제 #4
0
inline void sortp(Iter first, Iter last, IterP p, Cmp cmp)
{
  typedef typename std::iterator_traits<IterP>::value_type P;  
  sortp(first, last, p, cmp, std::allocator<P>());
}