Skip to content

Commit

Permalink
Included Multiple differential equations,strings and square roots.
Browse files Browse the repository at this point in the history
  • Loading branch information
adityawagh114 committed Aug 4, 2021
1 parent 0dab109 commit 14ce513
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
38 changes: 35 additions & 3 deletions wxmx2texi/expressions_from_xml.mac
@@ -1,3 +1,4 @@

/* expressions_from_xml.mac -- process Maxima expressions constructed from wxmx output XML
*
* Note that these pattern matching rules work only for
Expand All @@ -12,7 +13,7 @@

load ("expressions_from_xml.lisp");

matchdeclare ([aa, bb, cc, dd], all);
matchdeclare ([aa, bb, cc, dd,ee,ff,ele1,ele2,ele3,ele4,ele5,ele6], all);

defrule (rule_for_numbers, n()(aa), parse_string(aa));
defrule (rule_for_variables, v()(aa), ?makealias(aa));
Expand Down Expand Up @@ -64,8 +65,38 @@ process_lsum (bb, cc, dd) :=
list_values: rest (args (bb), 2)],
append ([apostrophe, 'lsum, paren_left, dd, comma, var, comma], list_values, [paren_right]));

defrule (rule_for_sqrts, q()(aa), ['sqrt, paren_left, aa, paren_right]);
defrule (rule_for_strings, st()(aa), aa);

defrule(r1,e()(r()(v()(aa)), r()(n()(bb))) ,[aa,comma,bb]);
defrule(r2,v()(aa) ,[aa,comma,1]);

defrule (rule_for_diffs1, d()(f("yes")(aa, r()(s()("d"), h()("*"), ele1)), h()("*"), ff), additional_diff_analysis1(ff,ele1));
defrule (rule_for_diffs2, d()(f("yes")(aa, r()(s()("d"), h()("*"), ele1,h()("*"),s()("d"), h()("*"), ele2 )), h()("*"), ff), additional_diff_analysis2(ff,ele1,ele2));
defrule (rule_for_diffs3, d()(f("yes")(aa, r()(s()("d"), h()("*"), ele1,h()("*"),s()("d"), h()("*"), ele2 ,h()("*"),s()("d"), h()("*"), ele3 )), h()("*"), ff), additional_diff_analysis3(ff,ele1,ele2,ele3));
defrule (rule_for_diffs4, d()(f("yes")(aa, r()(s()("d"), h()("*"), ele1,h()("*"),s()("d"), h()("*"), ele2 ,h()("*"),s()("d"), h()("*"), ele3 ,h()("*"),s()("d"), h()("*"), ele4 )), h()("*"), ff), additional_diff_analysis4(ff,ele1,ele2,ele3,ele4));
defrule (rule_for_diffs5, d()(f("yes")(aa, r()(s()("d"), h()("*"), ele1,h()("*"),s()("d"), h()("*"), ele2 ,h()("*"),s()("d"), h()("*"), ele3 ,h()("*"),s()("d"), h()("*"), ele4 ,h()("*"),s()("d"), h()("*"), ele5 )), h()("*"), ff), additional_diff_analysis5(ff,ele1,ele2,ele3,ele4,ele5));
defrule (rule_for_diffs6, d()(f("yes")(aa, r()(s()("d"), h()("*"), ele1,h()("*"),s()("d"), h()("*"), ele2 ,h()("*"),s()("d"), h()("*"), ele3 ,h()("*"),s()("d"), h()("*"), ele4 ,h()("*"),s()("d"), h()("*"), ele5 ,h()("*"),s()("d"), h()("*"), ele6 )), h()("*"), ff), additional_diff_analysis6(ff,ele1,ele2,ele3,ele4,ele5,ele6));


additional_diff_analysis1 (ff,ele1) :=([apostrophe, 'diff, paren_left,ff,comma,apply1(ele1,r1,r2),paren_right]);
additional_diff_analysis2 (ff,ele1,ele2) :=([apostrophe, 'diff, paren_left,ff,comma,apply1(ele1,r1,r2),comma,apply1(ele2,r1,r2),paren_right]);
additional_diff_analysis3 (ff,ele1,ele2,ele3) :=([apostrophe, 'diff, paren_left,ff,comma,apply1(ele1,r1,r2),comma,apply1(ele2,r1,r2),comma,apply1(ele3,r1,r2),paren_right]);
additional_diff_analysis4 (ff,ele1,ele2,ele3,ele4) :=([apostrophe, 'diff, paren_left,ff,comma,apply1(ele1,r1,r2),comma,apply1(ele2,r1,r2),comma,apply1(ele3,r1,r2),comma,apply1(ele4,r1,r2),paren_right]);
additional_diff_analysis5 (ff,ele1,ele2,ele3,ele4,ele5) :=([apostrophe, 'diff, paren_left,ff,comma,apply1(ele1,r1,r2),comma,apply1(ele2,r1,r2),comma,apply1(ele3,r1,r2),comma,apply1(ele4,r1,r2),comma,apply1(ele5,r1,r2),paren_right]);
additional_diff_analysis6 (ff,ele1,ele2,ele3,ele4,ele5,ele6) :=([apostrophe, 'diff, paren_left,ff,comma,apply1(ele1,r1,r2),comma,apply1(ele2,r1,r2),comma,apply1(ele3,r1,r2),comma,apply1(ele4,r1,r2),comma,apply1(ele5,r1,r2),comma,apply1(ele6,r1,r2),paren_right]);


tokens_from (e%) :=
(apply1 (e%, rule_for_subscripts,
(apply1 (e%,
rule_for_diffs1,
rule_for_diffs2,
rule_for_diffs3,
rule_for_diffs4,
rule_for_diffs5,
rule_for_diffs6,
rule_for_strings,
rule_for_subscripts,
rule_for_subsuperscripts,
rule_for_sums,
rule_for_lsums,
Expand All @@ -79,6 +110,7 @@ tokens_from (e%) :=
rule_for_functions,
rule_for_fractions,
rule_for_exponents,
rule_for_sqrts,
rule_for_text,
rule_for_rows,
rule_for_parentheses),
Expand All @@ -88,4 +120,4 @@ split_mth (e%) :=
block ([aa: args (e%), ii],
ii: sublist_indices (aa, lambda ([e1], not atom(e1) and op(e1) = lbl())),
ii: append (ii, [length (aa) + 1]),
makelist (aa[ii[j]] = makelist (aa[i], i, ii[j] + 1, ii[j + 1] - 1), j, 1, length (ii) - 1));
makelist (aa[ii[j]] = makelist (aa[i], i, ii[j] + 1, ii[j + 1] - 1), j, 1, length (ii) - 1));
10 changes: 8 additions & 2 deletions wxmx2texi/wxmx2texi.lisp
Expand Up @@ -263,11 +263,17 @@
(if (string/= (cell-output_string cellobject) "NotDefined" )
(setf final_output (modify_output (cell-output_string cellobject))))

(if (= startindex 1)
(if (and (> (length cell_array) 1 ) (= startindex 1 ))
(with-open-file (texinfo_string texi_location :direction :output :if-exists :append :if-does-not-exist :create)
(format texinfo_string "@node Cell~a,Cell~a,Top,Top~%~%" startindex ( + startindex 1))))

(if (= startindex endindex)
(if (= (length cell_array) 1 )
(with-open-file (texinfo_string texi_location :direction :output :if-exists :append :if-does-not-exist :create)
(format texinfo_string "@node Cell~a,,Top,Top~%~%" startindex ( + startindex 1))))



(if (and (> (length cell_array) 1 ) (= startindex endindex))
(with-open-file (texinfo_string texi_location :direction :output :if-exists :append :if-does-not-exist :create)
(format texinfo_string "@node Cell~a, ,Cell~a,Top~%~%
" startindex ( - startindex 1))))
Expand Down

0 comments on commit 14ce513

Please sign in to comment.