| 5 |
lars |
1 |
<!doctype html>
|
|
|
2 |
<title>CodeMirror: Mathematica mode</title>
|
|
|
3 |
<meta charset="utf-8" />
|
|
|
4 |
<link rel=stylesheet href="../../doc/docs.css">
|
|
|
5 |
<link rel=stylesheet href=../../lib/codemirror.css>
|
|
|
6 |
<script src=../../lib/codemirror.js></script>
|
|
|
7 |
<script src=../../addon/edit/matchbrackets.js></script>
|
|
|
8 |
<script src=mathematica.js></script>
|
|
|
9 |
<style type=text/css>
|
|
|
10 |
.CodeMirror {
|
|
|
11 |
border-top: 1px solid black;
|
|
|
12 |
border-bottom: 1px solid black;
|
|
|
13 |
}
|
|
|
14 |
</style>
|
|
|
15 |
<div id=nav>
|
|
|
16 |
<a href="http://codemirror.net">
|
|
|
17 |
<h1>CodeMirror</h1>
|
|
|
18 |
<img id=logo src="../../doc/logo.png">
|
|
|
19 |
</a>
|
|
|
20 |
<ul>
|
|
|
21 |
<li>
|
|
|
22 |
<a href="../../index.html">Home</a>
|
|
|
23 |
<li>
|
|
|
24 |
<a href="../../doc/manual.html">Manual</a>
|
|
|
25 |
<li>
|
|
|
26 |
<a href="https://github.com/codemirror/codemirror">Code</a>
|
|
|
27 |
</ul>
|
|
|
28 |
<ul>
|
|
|
29 |
<li>
|
|
|
30 |
<a href="../index.html">Language modes</a>
|
|
|
31 |
<li>
|
|
|
32 |
<a class=active href="#">Mathematica</a>
|
|
|
33 |
</ul>
|
|
|
34 |
</div>
|
|
|
35 |
<article>
|
|
|
36 |
<h2>Mathematica mode</h2>
|
|
|
37 |
<textarea id="mathematicaCode"> (* example Mathematica code *) (* Dualisiert wird anhand einer Polarität an einer Quadrik $x^t Q x = 0$ mit regulärer Matrix $Q$ (also mit $det(Q) \neq 0$), z.B. die Identitätsmatrix. $p$ ist eine Liste von Polynomen - ein Ideal. *) dualize::"singular"
|
|
|
38 |
= "Q must be regular: found Det[Q]==0."; dualize[ Q_, p_ ] := Block[ { m, n, xv, lv, uv, vars, polys, dual }, If[Det[Q] == 0, Message[dualize::"singular"], m = Length[p]; n = Length[Q] - 1; xv = Table[Subscript[x, i], {i, 0, n}]; lv = Table[Subscript[l,
|
|
|
39 |
i], {i, 1, m}]; uv = Table[Subscript[u, i], {i, 0, n}]; (* Konstruiere Ideal polys. *) If[m == 0, polys = Q.uv, polys = Join[p, Q.uv - Transpose[Outer[D, p, xv]].lv] ]; (* Eliminiere die ersten n + 1 + m Variablen xv und lv aus dem Ideal polys.
|
|
|
40 |
*) vars = Join[xv, lv]; dual = GroebnerBasis[polys, uv, vars]; (* Ersetze u mit x im Ergebnis. *) ReplaceAll[dual, Rule[u, x]] ] ] </textarea>
|
|
|
41 |
<script>
|
|
|
42 |
var mathematicaEditor = CodeMirror.fromTextArea(document.getElementById('mathematicaCode'),
|
|
|
43 |
{
|
|
|
44 |
mode: 'text/x-mathematica',
|
|
|
45 |
lineNumbers: true,
|
|
|
46 |
matchBrackets: true
|
|
|
47 |
});
|
|
|
48 |
</script>
|
|
|
49 |
<p>
|
|
|
50 |
<strong>MIME types defined:</strong> <code>text/x-mathematica</code> (Mathematica).</p>
|
|
|
51 |
</article>
|