From: Michael Orlitzky Date: Tue, 23 Aug 2011 20:23:58 +0000 (-0400) Subject: Write the output file in main. X-Git-Tag: 0.0.1~229 X-Git-Url: http://gitweb.michael.orlitzky.com/?p=spline3.git;a=commitdiff_plain;h=2a90a63d5fbc8fb57a97e97054e139f5284bf7b0 Write the output file in main. --- diff --git a/src/Main.hs b/src/Main.hs index 7b50de9..b8edf9e 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -18,4 +18,4 @@ main = do mridata <- read_values_3d mri_shape "./data/mridata.txt" let g = make_grid 1 mridata let output = zoom g 1 - print output + write_values_1d output "output.txt" diff --git a/src/Values.hs b/src/Values.hs index bd7c4d6..a33bbba 100644 --- a/src/Values.hs +++ b/src/Values.hs @@ -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) []