|
From: Ivan <ast...@bk...> - 2025-10-21 12:24:06
|
Hi all, I cannot convert a long enough expression into C code with gentran. Is it bug or I'm missing something? Also, is there any other way to generate C code? The expression that cannot be converted is var:-((sqrt(m_piM^4+W^8*cost^2-W^8+4*P0^2*W^6)+((cost^2-1)*m_nuc^2+W^2*cost^2-W^2)*m_piM^4+sqrt(m_piM^2+P0^2)*(4*W^2*m_nuc*m_piM^2-4*W^2*m_nuc^3+4*W^4*m_nuc)+((2-2*cost^2)*m_nuc^4-4*W^2*cost^2*m_nuc^2-2*W^4*cost^2-2*W^4)*m_piM^2+(cost^2-1)*m_nuc^6+(W^2-W^2*cost^2)*m_nuc^4+(W^4-W^4*cost^2)*m_nuc^2+W^6*cost^2-W^6)/((cost^2-1)*m_piM^4+((2-2*cost^2)*m_nuc^2-2*W^2*cost^2-2*W^2)*m_piM^2+(cost^2-1)*m_nuc^4+(2*W^2-2*W^2*cost^2)*m_nuc^2+W^4*cost^2-W^4)); Here is full example: $ maxima Loading /home/larry/.maxima/maxima-init.mac Maxima 5.48.1 https://maxima.sourceforge.io using Lisp SBCL 2.5.4 Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. The function bug_report() provides bug reporting information. (%i1) load(allgentran); (%o1) /usr/share/maxima/5.48.1/share/contrib/gentran/allgentran.lisp (%i2) gentranlang:c; (%o2) c (%i3) var:-((sqrt(m_piM^4+W^8*cost^2-W^8+4*P0^2*W^6)+((cost^2-1)*m_nuc^2+W^2*cost^2-W^2)*m_piM^4+sqrt(m_piM^2+P0^2)*(4*W^2*m_nuc*m_piM^2-4*W^2*m_nuc^3+4*W^4*m_nuc)+((2-2*cost^2)*m_nuc^4-4*W^2*cost^2*m_nuc^2-2*W^4*cost^2-2*W^4)*m_piM^2+(cost^2-1)*m_nuc^6+(W^2-W^2*cost^2)*m_nuc^4+(W^4-W^4*cost^2)*m_nuc^2+W^6*cost^2-W^6)/((cost^2-1)*m_piM^4+((2-2*cost^2)*m_nuc^2-2*W^2*cost^2-2*W^2)*m_piM^2+(cost^2-1)*m_nuc^4+(2*W^2-2*W^2*cost^2)*m_nuc^2+W^4*cost^2-W^4)); 4 8 2 8 2 6 (%o3) - (sqrt(m_piM + W cost - W + 4 P0 W ) 2 2 2 2 2 4 + ((cost - 1) m_nuc + W cost - W ) m_piM 2 2 2 2 2 3 4 + sqrt(m_piM + P0 ) (4 W m_nuc m_piM - 4 W m_nuc + 4 W m_nuc) 2 4 2 2 2 4 2 4 2 + ((2 - 2 cost ) m_nuc - 4 W cost m_nuc - 2 W cost - 2 W ) m_piM 2 6 2 2 2 4 4 4 2 2 + (cost - 1) m_nuc + (W - W cost ) m_nuc + (W - W cost ) m_nuc 6 2 6 2 4 2 2 2 2 + W cost - W )/((cost - 1) m_piM + ((2 - 2 cost ) m_nuc - 2 W cost 2 2 2 4 2 2 2 2 4 2 - 2 W ) m_piM + (cost - 1) m_nuc + (2 W - 2 W cost ) m_nuc + W cost 4 - W ) (%i4) gentran(eval(var)); Maxima encountered a Lisp error: LEFTOVER-MFORMAT-ARGS?: extra mformat args (NIL T0 undeclared variable NIL) Automatically continuing. To enable the Lisp debugger set *debugger-hook* to nil. |