小编Dav*_*ton的帖子

无法将预期类型`Maybe(String,Int,String)'与实际类型`([Char],t0,[Char])'匹配

我正在测试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)

haskell ghci

4
推荐指数
2
解决办法
7698
查看次数

CUDA浮点给出不同的结果

我正在使用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)

cuda image grayscale

2
推荐指数
1
解决办法
984
查看次数

标签 统计

cuda ×1

ghci ×1

grayscale ×1

haskell ×1

image ×1