2 * \file InsetMathExFunc.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathExFunc.h"
16 #include "MathStream.h"
17 #include "MathSupport.h"
18 #include "MetricsInfo.h"
20 #include "support/docstream.h"
28 InsetMathExFunc::InsetMathExFunc(docstring const & name)
29 : InsetMathNest(1), name_(name)
33 InsetMathExFunc::InsetMathExFunc(docstring const & name, MathData const & ar)
34 : InsetMathNest(1), name_(name)
40 Inset * InsetMathExFunc::clone() const
42 return new InsetMathExFunc(*this);
46 void InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
48 mathed_string_dim(mi.base.font, name_, dim);
49 // Cache the inset dimension.
54 void InsetMathExFunc::draw(PainterInfo & pi, int x, int y) const
56 drawStrBlack(pi, x, y, name_);
60 docstring InsetMathExFunc::name() const
66 void InsetMathExFunc::maple(MapleStream & os) const
69 os << "linalg[det](" << cell(0) << ')';
71 os << name_ << '(' << cell(0) << ')';
75 void InsetMathExFunc::maxima(MaximaStream & os) const
78 os << "determinant(" << cell(0) << ')';
80 os << name_ << '(' << cell(0) << ')';
84 static string asMathematicaName(string const & name)
86 if (name == "sin") return "Sin";
87 if (name == "sinh") return "Sinh";
88 if (name == "arcsin") return "ArcSin";
89 if (name == "asin") return "ArcSin";
90 if (name == "cos") return "Cos";
91 if (name == "cosh") return "Cosh";
92 if (name == "arccos") return "ArcCos";
93 if (name == "acos") return "ArcCos";
94 if (name == "tan") return "Tan";
95 if (name == "tanh") return "Tanh";
96 if (name == "arctan") return "ArcTan";
97 if (name == "atan") return "ArcTan";
98 if (name == "cot") return "Cot";
99 if (name == "coth") return "Coth";
100 if (name == "csc") return "Csc";
101 if (name == "sec") return "Sec";
102 if (name == "exp") return "Exp";
103 if (name == "log") return "Log";
104 if (name == "ln" ) return "Log";
105 if (name == "arg" ) return "Arg";
106 if (name == "det" ) return "Det";
107 if (name == "gcd" ) return "GCD";
108 if (name == "max" ) return "Max";
109 if (name == "min" ) return "Min";
110 if (name == "erf" ) return "Erf";
111 if (name == "erfc" ) return "Erfc";
116 static docstring asMathematicaName(docstring const & name)
118 return from_utf8(asMathematicaName(to_utf8(name)));
122 void InsetMathExFunc::mathematica(MathematicaStream & os) const
124 os << asMathematicaName(name_) << '[' << cell(0) << ']';
128 void InsetMathExFunc::mathmlize(MathStream & os) const
130 ++os.tab(); os.cr(); os.os() << '<' << name_ << '>';
132 os.cr(); --os.tab(); os.os() << "</" << name_ << '>';
136 void InsetMathExFunc::octave(OctaveStream & os) const
138 os << name_ << '(' << cell(0) << ')';