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"
15 #include "MathStream.h"
16 #include "MathStream.h"
17 #include "MathSupport.h"
27 InsetMathExFunc::InsetMathExFunc(docstring const & name)
28 : InsetMathNest(1), name_(name)
32 InsetMathExFunc::InsetMathExFunc(docstring const & name, MathData const & ar)
33 : InsetMathNest(1), name_(name)
39 auto_ptr<Inset> InsetMathExFunc::doClone() const
41 return auto_ptr<Inset>(new InsetMathExFunc(*this));
45 bool InsetMathExFunc::metrics(MetricsInfo & mi, Dimension & dim) const
47 mathed_string_dim(mi.base.font, name_, dim);
55 void InsetMathExFunc::draw(PainterInfo & pi, int x, int y) const
57 drawStrBlack(pi, x, y, name_);
61 docstring InsetMathExFunc::name() const
67 void InsetMathExFunc::maple(MapleStream & os) const
70 os << "linalg[det](" << cell(0) << ')';
72 os << name_ << '(' << cell(0) << ')';
76 void InsetMathExFunc::maxima(MaximaStream & os) const
79 os << "determinant(" << cell(0) << ')';
81 os << name_ << '(' << cell(0) << ')';
85 static string asMathematicaName(string const & name)
87 if (name == "sin") return "Sin";
88 if (name == "sinh") return "Sinh";
89 if (name == "arcsin") return "ArcSin";
90 if (name == "asin") return "ArcSin";
91 if (name == "cos") return "Cos";
92 if (name == "cosh") return "Cosh";
93 if (name == "arccos") return "ArcCos";
94 if (name == "acos") return "ArcCos";
95 if (name == "tan") return "Tan";
96 if (name == "tanh") return "Tanh";
97 if (name == "arctan") return "ArcTan";
98 if (name == "atan") return "ArcTan";
99 if (name == "cot") return "Cot";
100 if (name == "coth") return "Coth";
101 if (name == "csc") return "Csc";
102 if (name == "sec") return "Sec";
103 if (name == "exp") return "Exp";
104 if (name == "log") return "Log";
105 if (name == "ln" ) return "Log";
106 if (name == "arg" ) return "Arg";
107 if (name == "det" ) return "Det";
108 if (name == "gcd" ) return "GCD";
109 if (name == "max" ) return "Max";
110 if (name == "min" ) return "Min";
111 if (name == "erf" ) return "Erf";
112 if (name == "erfc" ) return "Erfc";
117 static docstring asMathematicaName(docstring const & name)
119 return from_utf8(asMathematicaName(to_utf8(name)));
123 void InsetMathExFunc::mathematica(MathematicaStream & os) const
125 os << asMathematicaName(name_) << '[' << cell(0) << ']';
129 void InsetMathExFunc::mathmlize(MathStream & os) const
131 os << MTag(name_.c_str()) << cell(0) << ETag(name_.c_str());
135 void InsetMathExFunc::octave(OctaveStream & os) const
137 os << name_ << '(' << cell(0) << ')';