我对Mathematica的输出结果有一个问题。两个矩阵A和B必须以特殊形式导出。这两个代码构成了从Maple导出的数据列表。使用写字板打开的导出文件看起来像列(附加文件),这一点很重要。
请,如果你已经检查过它正在工作,请给我回复,谢谢!你可以与下面的文件进行比较来检查你的答案。
代码在这里
矩阵A和B,代码在Maple和导出文件中
http://www.2shared.com/file/49wW8Z0-/EXAMPLE_EXPORT_MAPLE_FINAL.html
我还将在这里向大家介绍它,很容易看到
代码1)
A := Matrix(2, 2, {(1, 1) = (455200000000/6133413)*w(1), (1, 2) = -(1792000000000/116534847)*w(1), (2, 1) = (455200000000/6133413)*w(2), (2, 2) = -(1792000000000/116534847)*w(2)})
precision := double: writeto(`Aexport.for`):
for i from 1 to 2 do:for j from 1 to 2 do:
if A[i,j]<>0 then codegen[fortran]([A00[i,j]=A[i,j]],optimized):
fi:od:od:writeto(terminal):代码2)
B := Matrix(2, 2, {(1, 1) = 6436781.609, (1, 2) = 0, (2, 1) = 0, (2, 2) = 3862068.966})
writeto(Bexport);
for i to 2 do
for j to 2 do
printf("%016.15E\n", B[i, j])
end do:
end do:
writeto(terminal)发布于 2011-12-02 18:19:32
以下只是第(二)部分的译文:
matrix = {{6436781.609, 0}, {0, 3862068.966}}
Export["Bexport", Map[FortranForm, N@Flatten[matrix]], "Table"]请测试一下,让我知道它是否适用于您。
与Maple版本的不同之处在于:E是以小写形式编写的,并且输出的位数不是固定的(但是,正如您所看到的,所有有效位数都被保留)。这些差异会在您的应用程序中造成问题吗?
发布于 2011-12-03 03:29:37
我相信这就是你想要的矩阵B:
b = {{6436781.609, 0}, {0, 3862068.966}}
bformatted =
NumberForm[
Flatten@b,
{16, 15},
NumberFormat -> (Row[{#, "E+", StringTake["00" <> #3, -2]}] &)
];
bstring =
StringReplace[
ToString@bformatted,
{"{"|"}"|" " -> "", "," -> "\n"}
];
WriteString["Bexport.dat", bstring, "\n"]
Close["Bexport.dat"]https://stackoverflow.com/questions/8354503
复制相似问题