From 4709a0c535da50f93db30aaffc93f016fd3220ed Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sun, 7 Jan 2007 03:28:53 +0000 Subject: [PATCH] Fix conversion of n-th roots to mathematica and octave syntax. * src/mathed/MathExtern.C (pipeThroughOctave): take into account that the output from octave may contain ansi control sequences. * src/mathed/InsetMathRoot.[Ch] (InsetMathRoot::mathematica): new virtual method to output n-th roots in mathematica syntax. * src/mathed/InsetMathRoot.C (InsetMathRoot::octave): octave has not a root() command. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16559 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathRoot.C | 8 +++++++- src/mathed/InsetMathRoot.h | 2 ++ src/mathed/MathExtern.C | 9 +++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/mathed/InsetMathRoot.C b/src/mathed/InsetMathRoot.C index bf0112a2da..c6b60b69da 100644 --- a/src/mathed/InsetMathRoot.C +++ b/src/mathed/InsetMathRoot.C @@ -103,9 +103,15 @@ void InsetMathRoot::maple(MapleStream & os) const } +void InsetMathRoot::mathematica(MathematicaStream & os) const +{ + os << '(' << cell(1) << ")^(1/(" << cell(0) <<"))"; +} + + void InsetMathRoot::octave(OctaveStream & os) const { - os << "root(" << cell(1) << ',' << cell(0) << ')'; + os << '(' << cell(1) << ")^(1/(" << cell(0) <<"))"; } diff --git a/src/mathed/InsetMathRoot.h b/src/mathed/InsetMathRoot.h index 57af6ae83a..0ba0653261 100644 --- a/src/mathed/InsetMathRoot.h +++ b/src/mathed/InsetMathRoot.h @@ -40,6 +40,8 @@ public: /// void maple(MapleStream &) const; /// + void mathematica(MathematicaStream &) const; + /// void octave(OctaveStream &) const; private: virtual std::auto_ptr doClone() const; diff --git a/src/mathed/MathExtern.C b/src/mathed/MathExtern.C index a70106d9ea..30dfaa346e 100644 --- a/src/mathed/MathExtern.C +++ b/src/mathed/MathExtern.C @@ -1283,11 +1283,12 @@ namespace { expr.insert(pos, 1, '*'); } - if (out.size() < 6) + // remove 'ans = ' taking into account that there may be an + // ansi control sequence before, such as '\033[?1034hans = ' + size_t i = out.find("ans = "); + if (i == string::npos) return MathArray(); - - // remove 'ans = ' - out = out.substr(6); + out = out.substr(i + 6); // parse output as matrix or single number MathAtom at(new InsetMathArray(from_ascii("array"), from_utf8(out))); -- 2.39.2