]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathMatrix.cpp
d368f217b7b1493485c0ebbc652f5bd487824ae4
[lyx.git] / src / mathed / InsetMathMatrix.cpp
1 /**
2  * \file InsetMathMatrix.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathMatrix.h"
14 #include "MathData.h"
15 #include "MathStream.h"
16
17
18 namespace lyx {
19
20 InsetMathMatrix::InsetMathMatrix(InsetMathGrid const & p, 
21                         docstring const & left, docstring const & right)
22         : InsetMathGrid(p), left_(left), right_(right)
23 {}
24
25
26 Inset * InsetMathMatrix::clone() const
27 {
28         return new InsetMathMatrix(*this);
29 }
30
31
32 void InsetMathMatrix::write(WriteStream & os) const
33 {
34         InsetMathGrid::write(os);
35 }
36
37
38 void InsetMathMatrix::normalize(NormalStream & os) const
39 {
40         InsetMathGrid::normalize(os);
41 }
42
43
44 void InsetMathMatrix::maple(MapleStream & os) const
45 {
46         os << "matrix(" << int(nrows()) << ',' << int(ncols()) << ",[";
47         for (idx_type idx = 0; idx < nargs(); ++idx) {
48                 if (idx)
49                         os << ',';
50                 os << cell(idx);
51         }
52         os << "])";
53 }
54
55
56 void InsetMathMatrix::maxima(MaximaStream & os) const
57 {
58         os << "matrix(";
59         for (row_type row = 0; row < nrows(); ++row) {
60                 if (row)
61                         os << ',';
62                 os << '[';
63                 for (col_type col = 0; col < ncols(); ++col) {
64                         if (col)
65                                 os << ',';
66                         os << cell(index(row, col));
67                 }
68                 os << ']';
69         }
70         os << ')';
71 }
72
73
74 void InsetMathMatrix::mathematica(MathematicaStream & os) const
75 {
76         os << '{';
77         for (row_type row = 0; row < nrows(); ++row) {
78                 if (row)
79                         os << ',';
80                 os << '{';
81                 for (col_type col = 0; col < ncols(); ++col) {
82                         if (col)
83                                 os << ',';
84                         os << cell(index(row, col));
85                 }
86                 os << '}';
87         }
88         os << '}';
89 }
90
91
92 void InsetMathMatrix::mathmlize(MathStream & os) const
93 {
94         os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
95            << left_ << "</mo>";
96         os << MTag("mtable");
97         for (row_type row = 0; row < nrows(); ++row) {
98                 os << MTag("mtr");
99                 for (col_type col = 0; col < ncols(); ++col)
100                         os << MTag("mtd") << cell(index(row, col)) << ETag("mtd");
101                 os << ETag("mtr");
102         }
103         os << ETag("mtable");
104         os << "<mo form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>"
105            << right_ << "</mo>";
106 }
107
108
109 void InsetMathMatrix::octave(OctaveStream & os) const
110 {
111         os << '[';
112         for (row_type row = 0; row < nrows(); ++row) {
113                 if (row)
114                         os << ';';
115                 os << '[';
116                 for (col_type col = 0; col < ncols(); ++col)
117                         os << cell(index(row, col)) << ' ';
118                 os << ']';
119         }
120         os << ']';
121 }
122
123
124 } // namespace lyx