此为 Mathematica 8 文档,内容基于更早版本的 Wolfram 语言
查看最新文档(版本11.1)

CUDASort

CUDASort[vec]
sorts the input vector.
CUDASort[mem]
sorts CUDAMemory in place.

sorts input with respect to the ordering function op.
  • The CUDALink application must be loaded using Needs.
  • works on general vector types such as , , ....
  • does not work on symbolic input.
  • is equivalent to Sort.
First, load the CUDALink application:
This sorts an input list:
This sorts using the Greater ordering function:
If input is CUDAMemory, then memory is returned as output:
This sorts the input CUDAMemory:
Note that the input and output memories are the same—that is, CUDASort sorts memory in place. Memory is retrieved using CUDAMemoryGet:
works on vector types by sorting the data lexicographically. This generates random integer tuples:
This loads the memory as :
This sorts the memory in place:
This gets the memory into Mathematica:
The result agrees with Mathematica:
First, load the CUDALink application:
In[1]:=
Click for copyable input
This sorts an input list:
In[2]:=
Click for copyable input
Out[2]=
 
This sorts using the Greater ordering function:
In[1]:=
Click for copyable input
Out[1]=
 
If input is CUDAMemory, then memory is returned as output:
In[1]:=
Click for copyable input
Out[1]=
This sorts the input CUDAMemory:
In[2]:=
Click for copyable input
Out[2]=
Note that the input and output memories are the same—that is, CUDASort sorts memory in place. Memory is retrieved using CUDAMemoryGet:
In[3]:=
Click for copyable input
Out[3]=
 
works on vector types by sorting the data lexicographically. This generates random integer tuples:
In[1]:=
Click for copyable input
Out[1]=
This loads the memory as :
In[2]:=
Click for copyable input
Out[2]=
This sorts the memory in place:
In[3]:=
Click for copyable input
Out[3]=
This gets the memory into Mathematica:
In[4]:=
Click for copyable input
Out[4]=
The result agrees with Mathematica:
In[5]:=
Click for copyable input
Out[5]=
only works on vectors: