Aelve Codesearch

grep over package repositories
Please provide a string to search for.
3+ characters are required.
Index updated about a month ago

total matches: more than 1000

BCMtools-0.1.1
8 matches
src/BCM/Binary.hs
    size :: a -> Int

instance BinaryData Int64 where
    hGetData hdl = fmap fromIntegral . (hGetData hdl :: Bool -> IO Word64)
    hPutData hdl = (hPutData hdl :: Word64 -> IO ()). fromIntegral
    size _ = 8
    {-# INLINE hGetData #-}
    {-# INLINE hPutData #-}


            
src/BCM/Binary.hs
        hPutData hdl d_matrix_magic
        hPutData hdl (fromIntegral r :: Int64)
        hPutData hdl (fromIntegral c :: Int64)
        G.mapM_ (hPutData hdl) vec

    hGetData hdl _ = do
        magic <- hGetData hdl False
        let byteSwapped | magic == d_matrix_magic = False
                        | byteSwap32 magic == d_matrix_magic = True

            
src/BCM/Binary.hs
        c <- fromIntegral <$> (hGetData hdl byteSwapped :: IO Int64)
        vec <- hGetDoubleVector hdl (r*c)
        if byteSwapped
           then return $ DM.Matrix r c c 0 $ G.map byteSwap $ G.convert vec
           else return $ DM.Matrix r c c 0 $ G.convert vec
    size = undefined
    {-# INLINE hGetData #-}
    {-# INLINE hPutData #-}


            
src/BCM/Binary.hs
    hPutData hdl (DS.SymMatrix n vec) = do
        hPutData hdl ds_matrix_magic
        hPutData hdl (fromIntegral n :: Int64)
        G.mapM_ (hPutData hdl) vec

    hGetData hdl _ = do
        magic <- hGetData hdl False
        let byteSwapped | magic == ds_matrix_magic = False
                        | byteSwap32 magic == ds_matrix_magic = True

            
src/BCM/Binary.hs
        let len = ((n+1)*n) `shiftR` 1
        vec <- hGetDoubleVector hdl len
        if byteSwapped
           then return $ DS.SymMatrix n $ G.map byteSwap $ G.convert vec
           else return $ DS.SymMatrix n $ G.convert vec
    size = undefined
    {-# INLINE hGetData #-}
    {-# INLINE hPutData #-}


            
src/BCM/Binary.hs
        hPutData hdl (fromIntegral r :: Int64)
        hPutData hdl (fromIntegral c :: Int64)
        hPutData hdl (fromIntegral n :: Int64)
        G.mapM_ (hPutData hdl) vec
        G.mapM_ (hPutData hdl . (fromIntegral :: Int -> Int64)) ci
        G.mapM_ (hPutData hdl . (fromIntegral :: Int -> Int64)) rp
      where
        n = G.length vec

    hGetData hdl _ = do
        magic <- hGetData hdl False

            
src/BCM/Binary.hs
        ci <- G.convert <$> hGetIntVector hdl n
        rp <- G.convert <$> hGetIntVector hdl c
        if byteSwapped
           then return $ SM.CSR r c (G.map byteSwap vec)
                                    (G.map (fromIntegral . (byteSwap :: Int64 -> Int64) . fromIntegral) ci)
                                    (G.map (fromIntegral . (byteSwap :: Int64 -> Int64) . fromIntegral) rp)
           else return $ SM.CSR r c vec ci rp
    {-# INLINE hGetData #-}
    {-# INLINE hPutData #-}

    size (SM.CSR _ _ vec ci rp) = 28 + 8 * (G.length vec + G.length ci + G.length rp)

            
src/BCM/Visualize/Internal.hs
{-# INLINE coloursToPalette #-}

toPngData :: Conduit [Word8] IO B.ByteString
toPngData = CL.map (B.pack . (0:)) $= Z.compress 5 Z.defaultWindowBits
{-# INLINE toPngData #-}

            
BiobaseXNA-0.10.0.0
1 matches
Biobase/Primary/Pretty.hs
newtype Pretty f a = Pretty { getPretty :: f a }

instance (LetterChar x) => ToJSON (Pretty VU.Vector (Letter x)) where
  toJSON = String . T.pack . map letterChar . VU.toList . getPretty

instance (LetterChar x) => ToJSON (Pretty V.Vector (Letter x)) where
  toJSON = String . T.pack . map letterChar . V.toList . getPretty

instance (LetterChar x, VS.Storable (Letter x)) => ToJSON (Pretty VS.Vector (Letter x)) where
  toJSON = String . T.pack . map letterChar . VS.toList . getPretty

instance (LetterChar x) => ToJSON (Pretty [] (Letter x)) where
  toJSON = String . T.pack . map letterChar . getPretty


            
CoreFoundation-0.1
2 matches
CoreFoundation/Types/Array/Internal.hs

withVector :: CF a => V.Vector a -> (Ptr (Ptr (Repr a)) -> Int -> IO b) -> IO b
withVector v f =
  (S.unsafeWith (V.convert (V.map extractPtr v)) $ \buf -> f buf (V.length v))
  `finally` touch v

buildVector :: CF a => Int -> (Ptr (Ptr (Repr a)) -> IO b) -> IO (V.Vector a, b)
buildVector len f = do
  mvec <- SM.new (fromIntegral len)

            
CoreFoundation/Types/Array/Internal.hs
  mvec <- SM.new (fromIntegral len)
  res <- SM.unsafeWith mvec $ \ptr -> f ptr
  vec <- S.unsafeFreeze mvec
  vec' <- V.mapM (get . return) $ S.convert vec
  return (vec', res)


touch :: a -> IO ()
touch a = IO (\s -> (# touch# a s, () #))

            
DistanceTransform-0.1.2
5 matches
src/DistanceTransform/Euclidean.hs
phase1 :: (Integral a, Vector v a, Vector v Int)
       => LoopRunner -> Zipper Int -> v a -> v Int
phase1 runLoop dim p = 
  V.map (\x -> x*x) $ V.create $
   do v <- VM.new (product $ fromZipper dim)
      let pullRight !i = if p ! i == 0
                         then VM.unsafeWrite v i 0
                         else VM.unsafeRead v (i-step) >>= 
                                (VM.unsafeWrite v i $!) . (1+)

            
src/DistanceTransform/Euclidean.hs
                                (VM.unsafeWrite v i $! prev+1)
          innerLoop !offset _ = 
            do VM.unsafeWrite v offset $! toInfty offset
               mapM_ (pullRight . (offset+)) [step,2*step..n' - 1]
               mapM_ (pushLeft . (offset+)) [n'-2*step,n'-3*step..0]
      runLoop dim innerLoop
      return v
  where toInfty !i = let !dimsum = zipSum dim
                     in if p ! i == 0 then 0 else dimsum
        {-# INLINE toInfty #-}

            
src/DistanceTransform/Euclidean.hs
                            aux !q = 
                              if q < 0 
                              then VM.unsafeWrite s 0 u >> return 0
                              else do !w <- (sep u $!) `fmap` VM.unsafeRead s q
                                      if w < m
                                      then let !q' = q+1
                                           in do VM.unsafeWrite s q' u
                                                 VM.unsafeWrite t q' w
                                                 return q'

            
src/DistanceTransform/Euclidean.hs
-- @[columns,rows]@.
edt :: (Integral a, Floating b, Vector v a, Vector v b, Vector v Int)
    => [Int] -> v a -> v b
edt dims v = V.map aux $ sedt dims v
  where aux = sqrt . fromIntegral
{-# SPECIALIZE edt :: [Int] -> U.Vector Int -> U.Vector Float #-}
{-# SPECIALIZE edt :: [Int] -> U.Vector Int -> U.Vector Double #-}
{-# SPECIALIZE edt :: [Int] -> U.Vector Word8 -> U.Vector Float #-}
{-# SPECIALIZE edt :: [Int] -> U.Vector Word8 -> U.Vector Double #-}

            
src/DistanceTransform/Euclidean.hs
-- format, we would give @[width,height]@ or @[columns,rows]@.
edtPar :: (Integral a, Floating b, Vector v a, Vector v b, Vector v Int)
       => [Int] -> v a -> v b
edtPar dims v = V.map aux $ sedtPar dims v
  where aux = sqrt . fromIntegral
{-# SPECIALIZE edtPar :: [Int] -> U.Vector Int -> U.Vector Float #-}
{-# SPECIALIZE edtPar :: [Int] -> U.Vector Int -> U.Vector Double #-}
{-# SPECIALIZE edtPar :: [Int] -> U.Vector Word8 -> U.Vector Float #-}
{-# SPECIALIZE edtPar :: [Int] -> U.Vector Word8 -> U.Vector Double #-}

            
GLUtil-0.9.3
2 matches
src/Graphics/GLUtil/Textures.hs
-- | Bind each of the given textures to successive texture units at
-- the given 'TextureTarget' starting with texture unit 0.
withTextures :: BindableTextureTarget t => t -> [TextureObject] -> IO a -> IO a
withTextures tt ts m = do mapM_ aux (zip ts [0..])
                          r <- m
                          cleanup 0 ts
                          activeTexture $= TextureUnit 0
                          return r
  where aux (t,i) = do activeTexture $= TextureUnit i

            
src/Graphics/GLUtil/Textures.hs
-- are used, consider using 'withTextures' or 'withTextures2D'.
withTexturesAt :: BindableTextureTarget t
               => t -> [(TextureObject,GLuint)] -> IO a -> IO a
withTexturesAt tt ts m = do mapM_ aux ts
                            r <- m
                            mapM_ (cleanup . snd) ts
                            return r
  where aux (t,i) = do activeTexture $= TextureUnit i
                       textureBinding tt $= Just t
        cleanup i = do activeTexture $= TextureUnit i
                       textureBinding tt $= Nothing

            
Hate-0.1.4.3
4 matches
src/Hate/Graphics/Backend/Util.hs
    return $ VertexStream { vao = _vao, vbo = _vbo, texVbo = _texVbo, vertNum = _vertNum }

calculateTexCoords :: [Vec2] -> [Vec2]
calculateTexCoords verts = map (flipY . pointwise scaleFactor) verts
    where
        maxX = _1 $ maximumBy (comparing _1) verts
        maxY = _2 $ maximumBy (comparing _2) verts
        scaleFactor = Vec2 (1 / maxX) (1 / maxY)
        flipY (Vec2 x y) = Vec2 x y

            
src/Hate/Graphics/Backend/Util.hs

makeGlobalPipelineDescs :: [Input] -> [Uniform] -> [Varying] -> [Uniform] -> String -> String -> (ShaderDesc, ShaderDesc)
makeGlobalPipelineDescs vertexInputs vertexUniforms varyings fragmentUniforms vss fss =
    ( globalVertexShader vertexInputs (map toOutput varyings) vertexUniforms vss
    , globalFragmentShader (map toInput varyings) fragmentUniforms fss
    )

solidColorPipelineDescs :: (ShaderDesc, ShaderDesc)
solidColorPipelineDescs = makeGlobalPipelineDescs [] [] []
    [Uniform Vec4Tag Nothing "in_color"]

            
src/Hate/Graphics/Sprite.hs

loadImageDataIntoTexture :: JP.Image JP.PixelRGBA8 -> IO ()
loadImageDataIntoTexture (JP.Image width height dat) = do
    unsafeWith dat $ GL.build2DMipmaps GL.Texture2D GL.RGBA8 (fromIntegral width) (fromIntegral height)
      . GL.PixelData GL.RGBA GL.UnsignedByte

loadImageDataIntoTexture _ = error "Not yet supported"

getImageSize :: JP.Image JP.PixelRGBA8 -> (Int, Int)

            
src/Hate/Graphics/Sprite.hs
-- |Loads a file from disk and constructs a drawable sprite.
loadSprite :: FilePath -> IO Sprite
loadSprite path = do
    image <- (fmap . fmap) JPU.fromDynamicImage $ JP.readImage path
    case image of
        (Left err) -> do print err
                         exitWith (ExitFailure 1)
        (Right imgData) -> do 
            texId <- GL.genObjectName :: IO GL.TextureObject

            
JuicyPixels-blp-0.1.1.0
8 matches
src/Codec/Picture/Blp/Internal/Encoder.hs
      + 4 -- Height
      + 4 -- Picture type
      + 4 -- Picture subtype
      + 16 * 4 -- Mipmaps offsets
      + 16 * 4 -- Mipmaps sizes
    mipmaps = let
      mkOffsetSize :: BS.ByteString -> (Int, [(Word32, Word32)]) ->  (Int, [(Word32, Word32)])
      mkOffsetSize bs (!offset, !acc) = (offset + BS.length bs, (fromIntegral offset, fromIntegral $ BS.length bs) : acc)
      uncomprStartOffset = headerSize + 4 * 256
      in reverse . snd $ case blpExt of
        BlpJpeg{..} -> let

            
src/Codec/Picture/Blp/Internal/Encoder.hs
      then xs ++ replicate (n - length xs) (last xs)
      else take n xs
    ensureLengthV n a xs = if V.length xs < n then xs <> V.replicate (n - V.length xs) a else V.take n xs
    putMipMapOffsets = traverse_ putWord32le . ensureLength 16 . take numMips . fmap fst $ mipmaps
    putMipMapSizes = traverse_ putWord32le . ensureLength 16 . take numMips . fmap snd $ mipmaps
    putRgba8 (PixelRGBA8 r g b a) = putWord8 r >> putWord8 g >> putWord8 b >> putWord8 a
    putBlpExt = case blpExt of -- TODO: check sync of compression flag and BlpExt
       BlpJpeg{..} -> do
         putWord32le $ fromIntegral $ BS.length blpJpegHeader
         putByteString blpJpegHeader

            
src/Codec/Picture/Blp/Internal/Encoder.hs
  , blpWidth = fromIntegral $ dynamicMap imageWidth img
  , blpHeight = fromIntegral $ dynamicMap imageHeight img
  , blpPictureType = pictype
  , blpPictureSubType = 5 -- world edit use this for war3mapMap.blp
  , blpExt = toBlpExt compression pictype quality numMips img'
  }
  where
    pictype = if hasAlpha img
      then UncompressedWithAlpha

            
src/Codec/Picture/Blp/Internal/Encoder.hs
      else UncompressedWithoutAlpha
    img' = convertRGBA8 img

-- | Take only first N mipmaps in list, fill rest with last non-fake mipmap
fakeMipMaps :: Int -- ^ How much true values to preserve (if <= 0, the function does nothing)
  -> [a] -- ^ List of mimpaps
  -> [a] -- ^ Result with fakes
fakeMipMaps = go Nothing
  where

            
src/Codec/Picture/Blp/Internal/Encoder.hs
        [] -> []
        x : xs' -> x : go (Just x) (n-1) xs'

-- | Scale image to form the sequence of mipmaps. The first element is always the original picture.
--
-- The scale procedure assumes that original image has power of 2 sides, that allows to simply pick
-- average of 4 pixels.
createMipMaps :: Image PixelRGBA8 -> [Image PixelRGBA8]
createMipMaps img = img : go img

            
src/Codec/Picture/Blp/Internal/Encoder.hs
    go i | imageWidth i <= 1 && imageHeight i <= 1 = []
         | otherwise = let i' = power2Scale i in i' : go i'

-- | Scale image to form the sequence of mipmaps. The first element is always the original picture.
--
-- The scale procedure assumes that original image has power of 2 sides, that allows to simply pick
-- 1 of 4 pixels.
createMipMapsIndexed :: Pixel a => Image a -> [Image a]
createMipMapsIndexed img = img : go img

            
src/Codec/Picture/Blp/Internal/Encoder.hs
      UncompressedWithAlpha -> True
      _ -> False

-- | Convert picture to BLP JPEG and create mipmaps
toBlpJpg :: Word8 -> Int -> Bool -> Image PixelRGBA8 -> BlpExt
toBlpJpg quality numMips hasAlpha img = BlpJpeg {
    blpJpegHeader = header
  , blpJpegData = mipmapsRawWithoutHeader
  }
  where
    processAlpha :: Image PixelRGBA8 -> Image PixelRGBA8
    processAlpha = pixelMap $ \p@(PixelRGBA8 r g b a) -> if hasAlpha then p else PixelRGBA8 r g b 255


            
src/Codec/Picture/Blp/Internal/Encoder.hs
    processAlpha :: Image PixelRGBA8 -> Image PixelRGBA8
    processAlpha = pixelMap $ \p@(PixelRGBA8 r g b a) -> if hasAlpha then p else PixelRGBA8 r g b 255

    mipmaps :: [Image PixelCMYK8]
    mipmaps = toBlpCMYK8 <$> (fakeMipMaps numMips . createMipMaps . processAlpha $ img)

    metadata :: CM.Metadatas
    metadata = CM.insert (CM.Unknown "JPEG Quality") (CM.Int $ fromIntegral quality) mempty

    mipmapsRaw :: [BS.ByteString]