]> git.lyx.org Git - features.git/commitdiff
some support for det and abs for math-extern
authorAndré Pönitz <poenitz@gmx.net>
Wed, 7 Nov 2001 10:21:51 +0000 (10:21 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Wed, 7 Nov 2001 10:21:51 +0000 (10:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2970 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/array.C
src/mathed/array.h
src/mathed/math_deliminset.C
src/mathed/math_deliminset.h
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_inset.h
src/mathed/math_sqrtinset.C
src/mathed/math_sqrtinset.h

index 507aa2cc2f7a37ebcd55e69a58705afbd52f3c00..5331bf258857e67337f3e715ab476156f2427242 100644 (file)
@@ -335,3 +335,9 @@ MathArray::iterator MathArray::end()
 }
 
 
+bool MathArray::isMatrix() const
+{
+       return size() == 1 && begin()->nucleus() && begin()->nucleus()->isMatrix();
+}
+
+
index 52dc1528f81a2916b953ca70259ff546c58b8f67..24c9e4fd0b257d727a6bc3aec052470c9ed1c590 100644 (file)
@@ -128,6 +128,9 @@ public:
        /// interface to MathML
        string mathmlize() const;
 
+       ///
+       bool isMatrix() const;
+
 private:
        /// Buffer
        buffer_type bf_;
index 7c5c736b900d2d0e5acbcbb4a5d1a55c58b13073..767a60f7ec8a5bf58b50261e5d34ea197e179c16 100644 (file)
@@ -93,6 +93,13 @@ void MathDelimInset::draw(Painter & pain, int x, int y) const
 }
 
 
+bool MathDelimInset::isMatrix() const
+{
+       return left_ == "(" && right_ == ")" && cell(0).size() == 1 && 
+               cell(0).begin()->nucleus() && cell(0).begin()->nucleus()->asArrayInset();
+}
+
+
 string MathDelimInset::octavize() const
 {
        if (left_ == "|" && right_ == "|")
@@ -103,7 +110,12 @@ string MathDelimInset::octavize() const
 
 string MathDelimInset::maplize() const
 {
-       if (left_ == "|" && right_ == "|")
-               return "abs(" + cell(0).octavize() + ")";
-       return left_ + cell(0).octavize() + right_;
+       if (left_ == "|" && right_ == "|") {
+               if (cell(0).isMatrix()) 
+                       return "linalg[det](" + cell(0).maplize() + ")";
+               else
+                       return "abs(" + cell(0).maplize() + ")";
+       }
+       return left_ + cell(0).maplize() + right_;
 }
+
index 24a3ab22550de0f0438fea98324264a8081390b1..0ffe24d3c7cd0ddd5d118d2d3493ec86abfed768 100644 (file)
@@ -28,6 +28,8 @@ public:
        ///
        void metrics(MathMetricsInfo const & st) const;
        ///
+       bool isMatrix() const;
+       ///
        string octavize() const;
        ///
        string maplize() const;
index 5b31df9cbdb6e57469e3df915935fc4d8f96eec6..17823c7973685c5c139d4eace5ba656ed47ddf8e 100644 (file)
@@ -605,3 +605,22 @@ string MathGridInset::octavize() const
        return res;
 }
 
+
+string MathGridInset::maplize() const
+{
+       string res = "array([";
+       for (row_type row = 0; row < nrows(); ++row) {
+               if (row)
+                       res += ',';
+               res += '[';
+               for (col_type col = 0; col < ncols(); ++col) {
+                       if (col)
+                               res += ',';
+                       res += cell(index(row, col)).maplize();
+               }
+               res += ']';
+       }
+       res += "])";
+       return res;
+}
+
index 60027ec5685a00fd13804f330e69055e39dd901a..af3f69e68db6d8081411b9b2e86cbff86a8579c5 100644 (file)
@@ -151,6 +151,8 @@ public:
 
        ///
        string octavize() const;
+       ///
+       string maplize() const;
 
 protected:
        /// returns proper 'end of line' code for LaTeX
index 59335a33315ad3bf7320d8af5a42eba1124cf25c..5c81b6cc635fd37e94d718607ecf295ec9d45875 100644 (file)
@@ -234,6 +234,8 @@ public:
        virtual bool isRelOp() const { return false; }
        ///
        virtual bool isMacro() const { return false; }
+       /// is this a matrix or matrix expression?
+       virtual bool isMatrix() const { return false; }
 
        ///
        virtual char getChar() const { return 0; }
index 9c6b4b3ed34455f55dc94a54c2883d6ffcca26bf..0b3e2c72dbf1edadbee32c85f924c56c58cea74e 100644 (file)
@@ -55,3 +55,9 @@ void MathSqrtInset::writeNormal(std::ostream & os) const
        cell(0).writeNormal(os); 
        os << "]";
 }
+
+
+string MathSqrtInset::maplize() const
+{
+       return "sqrt(" + cell(0).maplize() + ')';
+}
index 78e3ecedcebdf3a5be204011f16cd16da68ffdb2..8f21fe99d8e05a4ea08c8bb499849095bcd3cb6b 100644 (file)
@@ -25,5 +25,7 @@ public:
        void writeNormal(std::ostream &) const;
        ///
        void metrics(MathMetricsInfo const & st) const;
+       ///
+       string maplize() const;
 };
 #endif