}
+bool MathArray::isMatrix() const
+{
+ return size() == 1 && begin()->nucleus() && begin()->nucleus()->isMatrix();
+}
+
+
/// interface to MathML
string mathmlize() const;
+ ///
+ bool isMatrix() const;
+
private:
/// Buffer
buffer_type bf_;
}
+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_ == "|")
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_;
}
+
///
void metrics(MathMetricsInfo const & st) const;
///
+ bool isMatrix() const;
+ ///
string octavize() const;
///
string maplize() 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;
+}
+
///
string octavize() const;
+ ///
+ string maplize() const;
protected:
/// returns proper 'end of line' code for LaTeX
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; }
cell(0).writeNormal(os);
os << "]";
}
+
+
+string MathSqrtInset::maplize() const
+{
+ return "sqrt(" + cell(0).maplize() + ')';
+}
void writeNormal(std::ostream &) const;
///
void metrics(MathMetricsInfo const & st) const;
+ ///
+ string maplize() const;
};
#endif