3
$\begingroup$

i have a matrix like this:

F := Table[Subscript[f, i, j], {i, 3}, {j, 3}]
c=F.F

my question is that how to convert the components of c to this form Subscript[f, i, j]->f(i,j) when i am using FortranForm?

$\endgroup$

1 Answer 1

3
$\begingroup$

I don't know what do you expect from Lists but here is a quick solution:

FortranForm[c /. Subscript -> (#[##2] &)]

enter image description here

Edit:

dear Kuba i am looking for something like this : c(1,1)=f(1,1)^2+f(1,2)*f(2,1)+f(1,3)*f(3,1) and so on. –

Column @ Flatten @ MapIndexed[
  StringTemplate["c(``,``) = ``", InsertionFunction -> ToString
  ][
    Sequence @@ #2, FortranForm[# /. Subscript -> (#[##2] &)]
  ] &
, c
, {2}
]

enter image description here

$\endgroup$
2
  • $\begingroup$ dear Kuba i am looking for something like this : c(1,1)=f(1,1)^2+f(1,2)*f(2,1)+f(1,3)*f(3,1) and so on. $\endgroup$
    – user49047
    Commented Dec 20, 2017 at 14:16
  • $\begingroup$ @user49047 please see the edit. $\endgroup$
    – Kuba
    Commented Dec 20, 2017 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.