Question: How to format columns with one complex number?

Dear All,

Further to my previous question on this forum "How to write data from a matrix while choosing the format?", I would like to update it by adding a complex number. What is the easiest way to deal with that?

Here is the file (that does not compile):

> driver := proc () local A, B, x, f, g, i, j, format, fd:

A := Matrix(3, 3):
f := 1-2*I:
g := evalf(sin((1/5)*Pi)):
i := 0:

for x to 3 do i := i+1:
A[i, 1] := x: A[i, 2] := f: A[i, 3] := g:
end do:

B := convert(A, listlist):
format := "%+03.1f %+04.2f %+04.2f%+07.4f\n":
fd := fopen("file.dat", WRITE):
for j to nops(B) do fprintf(fd, format, op(B[j])) end do:

end proc:

> driver():


Thank you.


Please Wait...