]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathMatrix.cpp
0460a9443ffd2dc14e992f596ef5f1b10002dfe5
[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         : InsetMathGrid(p)
22 {}
23
24
25 Inset * InsetMathMatrix::clone() const
26 {
27         return new InsetMathMatrix(*this);
28 }
29
30
31 void InsetMathMatrix::write(WriteStream & os) const
32 {
33         InsetMathGrid::write(os);
34 }
35
36
37 void InsetMathMatrix::normalize(NormalStream & os) const
38 {
39         InsetMathGrid::normalize(os);
40 }
41
42
43 void InsetMathMatrix::maple(MapleStream & os) const
44 {
45         os << "matrix(" << int(nrows()) << ',' << int(ncols()) << ",[";
46         for (idx_type idx = 0; idx < nargs(); ++idx) {
47                 if (idx)
48                         os << ',';
49                 os << cell(idx);
50         }
51         os << "])";
52 }
53
54
55 void InsetMathMatrix::maxima(MaximaStream & os) const
56 {
57         os << "matrix(";
58         for (row_type row = 0; row < nrows(); ++row) {
59                 if (row)
60                         os << ',';
61                 os << '[';
62                 for (col_type col = 0; col < ncols(); ++col) {
63                         if (col)
64                                 os << ',';
65                         os << cell(index(row, col));
66                 }
67                 os << ']';
68         }
69         os << ')';
70 }
71
72
73 void InsetMathMatrix::mathematica(MathematicaStream & os) const
74 {
75         os << '{';
76         for (row_type row = 0; row < nrows(); ++row) {
77                 if (row)
78                         os << ',';
79                 os << '{';
80                 for (col_type col = 0; col < ncols(); ++col) {
81                         if (col)
82                                 os << ',';
83                         os << cell(index(row, col));
84                 }
85                 os << '}';
86         }
87         os << '}';
88 }
89
90
91 // FIXME XHTML
92 // We need more information here, so we can output the correct
93 // delimiters, which will not always be "[". To do this, we need
94 // to make some changes to InsetMathMatrix, adding a member to 
95 // record the type of delimiter, and then make the extractMatrices 
96 // routine in MathExtern give us this information.
97 void InsetMathMatrix::mathmlize(MathStream & os) const
98 {
99         os << "<mo form='prefix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>[</mo>";
100         os << MTag("mtable");
101         for (row_type row = 0; row < nrows(); ++row) {
102                 os << MTag("mtr");
103                 for (col_type col = 0; col < ncols(); ++col)
104                         os << MTag("mtd") << cell(index(row, col)) << ETag("mtd");
105                 os << ETag("mtr");
106         }
107         os << ETag("mtable");
108         os << "<mo form='postfix' fence='true' stretchy='true' symmetric='true' lspace='thinmathspace'>]</mo>";
109 }
110
111
112 void InsetMathMatrix::octave(OctaveStream & os) const
113 {
114         os << '[';
115         for (row_type row = 0; row < nrows(); ++row) {
116                 if (row)
117                         os << ';';
118                 os << '[';
119                 for (col_type col = 0; col < ncols(); ++col)
120                         os << cell(index(row, col)) << ' ';
121                 os << ']';
122         }
123         os << ']';
124 }
125
126
127 } // namespace lyx