diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2009-04-27 11:24:44 -0500 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2009-04-27 21:49:42 +0200 |
commit | ef0e1e9a215cd69f1d95e8bd3c6207d19112916f (patch) | |
tree | 5bc980657233a28eaf9c8f4e3f39660a8e5d99c8 /Tools | |
parent | f29fad1ac38b99c37416dd96fd8e1449d1c0b77f (diff) |
Correct errors in handling FD and PD Jacobians: Save and restore the current Jacobians in the corresponding global variables.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/CodeGen/TensorTools.m | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/Tools/CodeGen/TensorTools.m b/Tools/CodeGen/TensorTools.m index 1bf7c64..73a45ee 100644 --- a/Tools/CodeGen/TensorTools.m +++ b/Tools/CodeGen/TensorTools.m @@ -577,7 +577,7 @@ componentNameRule := (* Convert references to ordinary derivative components into single-symbol - names; i.e. PD[x, 1, 2, 3] -> D123[x]. *) + names; i.e., PD[x, 1, 2, 3] -> D123[x]. *) (* This is disabled now (by introducing a dummy pattern), because we would like all differencing to be performed by our custom @@ -1063,9 +1063,25 @@ PDtoFDForJacobian[x_, jacobian_] := fd = jacobian[[2]]; j = jacobian[[3]]; dj = jacobian[[4]]; - y = x /. {pd :> PD, fd :> FD, j :> J, dj :> dJ}; + (* The above rules use the global function names PD, FD, J, and + dJ. We therefore have to swap these names in and out. *) + y = x /. If[pd=!=PD, {PD -> quotedPD}, {}] + /. If[pd=!=PD, {pd -> PD }, {}] + /. If[fd=!=FD, {FD -> quotedFD}, {}] + /. If[fd=!=FD, {fd -> FD }, {}] + /. If[j =!=J , {J -> quotedJ }, {}] + /. If[j =!=J , {j -> J }, {}] + /. If[dj=!=dJ, {dJ -> quoteddJ}, {}] + /. If[dj=!=dJ, {dj -> dJ }, {}]; result = PDtoFDDefaultJacobian[y]; - result /. {J :> j, dJ :> dj}]; + result /. If[dj=!=dJ, {dJ -> dj}, {}] + /. If[dj=!=dJ, {quoteddJ -> dJ}, {}] + /. If[j =!=J , {J -> j }, {}] + /. If[j =!=J , {quotedJ -> J }, {}] + /. If[fd=!=FD, {FD -> fd}, {}] + /. If[fd=!=FD, {quotedFD -> FD}, {}] + /. If[pd=!=PD, {PD -> pd}, {}] + /. If[pd=!=PD, {quotedPD -> PD}, {}]]; PDtoFDForJacobians[x_, js_] := If[js == {}, |