我试图将这个矩阵打印到一个文件中,但是为了将它执行到gnuplot中我需要创建一个没有逗号和括号的文件,我该怎么做?
*install hmatrix
*install hmatrix-special
*import Numeric.LinearAlgebra
(5><2)
[ 0.12130139101653795, -3.9532277879855915e-2
, -9.943512129289413e-2, -1.8736674261187188e-2
, 0.21650870755682688, -7.774998273846949e-3
, -0.19540767578866855, -4.889335919164774e-2
, -4.296730149180415e-2, 0.11493730960653939 ]
答案 0 :(得分:1)
这将打印出矩阵,每行都有自己的行:
{-# LANGUAGE NoMonomorphismRestriction #-}
import Numeric.LinearAlgebra
m :: Matrix Double
m = (5><2)
[ 0.12130139101653795, -3.9532277879855915e-2
, -9.943512129289413e-2, -1.8736674261187188e-2
, 0.21650870755682688, -7.774998273846949e-3
, -0.19540767578866855, -4.889335919164774e-2
, -4.296730149180415e-2, 0.11493730960653939 ]
printMatrix m = do
putStrLn $ unlines $ map (unwords . map show . toList ) (toRows m)
test = printMatrix m