X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FValues.hs;h=0ef8410813e80729e09a0af3ec4a162bd7868814;hb=d1ee387490ef0ada8781f4bf81f82cce7f0006ba;hp=bd7c4d66af25ba443a6afe7f72d7bc6885df7f3b;hpb=883ce9d78072c492000de94478189095032b6615;p=spline3.git diff --git a/src/Values.hs b/src/Values.hs index bd7c4d6..0ef8410 100644 --- a/src/Values.hs +++ b/src/Values.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE TypeSynonymInstances #-} +{-# LANGUAGE FlexibleInstances #-} module Values where @@ -14,9 +14,11 @@ import Data.Array.Repa ( fromList, index, reshape, + size ) -import Data.Array.Repa.IO.Vector (readVectorFromTextFile) +import Data.Array.Repa.IO.Vector (readVectorFromTextFile, + writeVectorToTextFile) import System.FilePath () import Test.QuickCheck (Arbitrary(..), Gen) @@ -54,6 +56,12 @@ read_values_3d sh path = do one_d <- read_values_1d path return $ reshape sh one_d +write_values_1d :: Values3D -> FilePath -> IO () +write_values_1d v3d path = do + let size3d = size $ extent v3d + let shape1d = (Z :. size3d) + let v1d = reshape shape1d v3d + writeVectorToTextFile v1d path empty3d :: Values3D empty3d = Data.Array.Repa.fromList (Z :. 0 :. 0 :. 0) [] @@ -71,4 +79,14 @@ idx v3d i j k = index v3d shape where shape :: DIM3 - shape = (Z :. i :. j :. k) + shape = (Z :. k :. j :. i) + + +zoom_shape :: Int -> DIM3 -> DIM3 +zoom_shape scale_factor sh = + let (Z :. x :. y :. z) = sh + x' = x * scale_factor + y' = y * scale_factor + z' = z * scale_factor + in + (Z :. x' :. y' :. z')