我正在测试C程序员的Haskell教程中的示例(第2部分),并且在这个问题上遇到了一些麻烦....
showPet :: Maybe (String, Int, String) -> String
showPet Nothing = "none"
showPet (Just (name, age, species)) = "a " ++ species ++ " named " ++ name ++ ", aged " ++ (show age)
Run Code Online (Sandbox Code Playgroud)
在编译时,使用它进行调用
showPet ("cat",5,"felix")
Run Code Online (Sandbox Code Playgroud)
结果是
<interactive>:131:9:
Couldn't match expected type `Maybe (String, Int, String)'
with actual type `([Char], t0, [Char])'
In the first argument of `showPet', namely `("cat", 5, "felix")'
In the expression: showPet ("cat", 5, "felix")
In an …
Run Code Online (Sandbox Code Playgroud) 我正在使用CUDA 5/VC 2008将图像从彩色转换为灰度.
CUDA内核是:
__global__ static void rgba_to_grayscale( const uchar4* const rgbaImage, unsigned char * const greyImage,
int numRows, int numCols)
{
int pos = blockIdx.x * blockDim.x + threadIdx.x;
if (pos < numRows * numCols) {
uchar4 zz = rgbaImage[pos];
float out = 0.299f * zz.x + 0.587f * zz.y + 0.114f * zz.z;
greyImage[pos] = (unsigned char) out;
}
}
Run Code Online (Sandbox Code Playgroud)
C++函数是:
inline unsigned char rgba_to_grayscale( uchar4 rgbaImage)
{
return (unsigned char) 0.299f * rgbaImage.x + 0.587f * rgbaImage.y …
Run Code Online (Sandbox Code Playgroud)