]> gitweb.michael.orlitzky.com - spline3.git/blobdiff - src/Values.hs
Write the output file in main.
[spline3.git] / src / Values.hs
index bd7c4d66af25ba443a6afe7f72d7bc6885df7f3b..a33bbba56d3eef9da970d845de285af4c39ac39d 100644 (file)
@@ -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) []