mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
some support for det and abs for math-extern
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2970 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6e3fcdf812
commit
0f23028f4b
@ -335,3 +335,9 @@ MathArray::iterator MathArray::end()
|
||||
}
|
||||
|
||||
|
||||
bool MathArray::isMatrix() const
|
||||
{
|
||||
return size() == 1 && begin()->nucleus() && begin()->nucleus()->isMatrix();
|
||||
}
|
||||
|
||||
|
||||
|
@ -128,6 +128,9 @@ public:
|
||||
/// interface to MathML
|
||||
string mathmlize() const;
|
||||
|
||||
///
|
||||
bool isMatrix() const;
|
||||
|
||||
private:
|
||||
/// Buffer
|
||||
buffer_type bf_;
|
||||
|
@ -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_;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@ public:
|
||||
///
|
||||
void metrics(MathMetricsInfo const & st) const;
|
||||
///
|
||||
bool isMatrix() const;
|
||||
///
|
||||
string octavize() const;
|
||||
///
|
||||
string maplize() const;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -151,6 +151,8 @@ public:
|
||||
|
||||
///
|
||||
string octavize() const;
|
||||
///
|
||||
string maplize() const;
|
||||
|
||||
protected:
|
||||
/// returns proper 'end of line' code for LaTeX
|
||||
|
@ -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; }
|
||||
|
@ -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() + ')';
|
||||
}
|
||||
|
@ -25,5 +25,7 @@ public:
|
||||
void writeNormal(std::ostream &) const;
|
||||
///
|
||||
void metrics(MathMetricsInfo const & st) const;
|
||||
///
|
||||
string maplize() const;
|
||||
};
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user