Skip to content

Commit 40bc526

Browse files
committed
Update with accordance to arxiv paper
1 parent 752ad2e commit 40bc526

4 files changed

+1031
-547
lines changed

SimpleTensor.m

+10-7
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
StyleBox[\"dim\",\nFontSlant->\"Italic\"]\)] defines a space of dimension \!\(\*
2828
StyleBox[\"dim\",\nFontSlant->\"Italic\"]\)\!\(\*
2929
StyleBox[\" \",\nFontSlant->\"Italic\"]\)with a string \!\(\*
30-
StyleBox[\"name\",\nFontSlant->\"Italic\"]\) on which tensor calculations will be performed. The optional variables are:
30+
StyleBox[\"name\",\nFontSlant->\"Italic\"]\) on which tensors live. The optional variables are:
3131
\!\(\*
32-
StyleBox[\"index\",\nFontSlant->\"Italic\"]\) - a list of indices on this space or a string prefix to generate names automatically, if missing \!\(\*
32+
StyleBox[\"index\",\nFontSlant->\"Italic\"]\) - a list of indices on this space or a string prefix to generate names automatically; if missing, \!\(\*
3333
StyleBox[\"name\",\nFontSlant->\"Italic\"]\)\!\(\*
34-
StyleBox[\" \",\nFontSlant->\"Italic\"]\)is used as a prefix;
34+
StyleBox[\" \",\nFontSlant->\"Italic\"]\)is used as a prefix.
3535
\!\(\*
36-
StyleBox[\"coord\",\nFontSlant->\"Italic\"]\) - a list of coordinates on this space or a string prefix to generate names automatically, if missing \!\(\*
36+
StyleBox[\"coord\",\nFontSlant->\"Italic\"]\) - a list of coordinates on this space or a string prefix to generate names automatically; if missing, \!\(\*
3737
StyleBox[\"name\",\nFontSlant->\"Italic\"]\)\!\(\*
3838
StyleBox[\" \",\nFontSlant->\"Italic\"]\)is used as a prefix."
3939

@@ -52,9 +52,11 @@
5252

5353
GetArray::usage=
5454
"GetArray[\!\(\*
55-
StyleBox[\"expr\",\nFontSlant->\"Italic\"]\)] substitutes arrays into tensor variables and performs contractions and math operations. The optional variables are:
55+
StyleBox[\"expr\",\nFontSlant->\"Italic\"]\)] substitutes tensor variables with arrays and performs contractions and math operations. The optional variables are:
5656
\!\(\*
57-
StyleBox[\"indices\",\nFontSlant->\"Italic\"]\) - a list of indices in which order the tensor should be transposed. If omitted indices are taken to be in standard order, i.e., the one returned by the standard Sort[] function."
57+
StyleBox[\"indices\",\nFontSlant->\"Italic\"]\) - a list of indices in which order the tensor should be transposed. If omitted \!\(\*
58+
StyleBox[\"indices\",\nFontSlant->\"Italic\"]\) are taken to be the free indices in \!\(\*
59+
StyleBox[\"expr\",\nFontSlant->\"Italic\"]\) in standard order, i.e., the one returned by the standard Sort[] function."
5860

5961
metric::usage=
6062
"metric[-\!\(\*
@@ -213,7 +215,8 @@
213215
SetTensor[head_Symbol[ind__?IndexQ],array_List]:=
214216
Module[{},
215217
If[$Verbose,Print["Setting tensor: ",head[ind]," to have the following array: ", array]];
216-
If[head===basis||head===\[Eth],Print["Cannot modify the built-in tensor: ", head[ind]];Abort[]];
218+
If[head===basis,Print["Cannot set the built-in tensor: ", head[ind]];Abort[]];
219+
If[StringStartsQ[SymbolName[head],"\[Eth]"],Print["Cannot set tensor starting with \[Eth]: ", head[ind]];Abort[]];
217220
If[IndexDim/@{ind}!=Take[Dimensions[array],Length[{ind}]],
218221
Print["Invalid dimension of array ",head[ind],": ",Dimensions[array]," given vs ", IndexDim[#]&/@{ind}, " required."];Abort[]
219222
];

SimpleTensor.nb

+46-36
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
NotebookFileLineBreakTest
1111
NotebookFileLineBreakTest
1212
NotebookDataPosition[ 158, 7]
13-
NotebookDataLength[ 180217, 3491]
14-
NotebookOptionsPosition[ 179866, 3476]
15-
NotebookOutlinePosition[ 180231, 3492]
16-
CellTagsIndexPosition[ 180188, 3489]
13+
NotebookDataLength[ 180898, 3501]
14+
NotebookOptionsPosition[ 180548, 3486]
15+
NotebookOutlinePosition[ 180912, 3502]
16+
CellTagsIndexPosition[ 180869, 3499]
1717
WindowFrame->Normal*)
1818

1919
(* Beginning of Notebook Content *)
@@ -28,15 +28,14 @@ Cell[BoxData[{
2828
\!\(\*StyleBox[\"dim\",FontSlant->\"Italic\"]\)] defines a space of dimension \
2929
\!\(\*StyleBox[\"dim\",FontSlant->\"Italic\"]\)\!\(\*StyleBox[\" \
3030
\",FontSlant->\"Italic\"]\)with a string \
31-
\!\(\*StyleBox[\"name\",FontSlant->\"Italic\"]\) on which tensor calculations \
32-
will be performed. The optional variables are:\n\t\
33-
\!\(\*StyleBox[\"index\",FontSlant->\"Italic\"]\) - a list of indices on this \
34-
space or a string prefix to generate names automatically, if missing \
35-
\!\(\*StyleBox[\"name\",FontSlant->\"Italic\"]\)\!\(\*StyleBox[\" \
36-
\",FontSlant->\"Italic\"]\)is used as a prefix;\n\t\
31+
\!\(\*StyleBox[\"name\",FontSlant->\"Italic\"]\) on which tensors live. The \
32+
optional variables are:\n\t\!\(\*StyleBox[\"index\",FontSlant->\"Italic\"]\) \
33+
- a list of indices on this space or a string prefix to generate names \
34+
automatically; if missing, \!\(\*StyleBox[\"name\",FontSlant->\"Italic\"]\)\!\
35+
\(\*StyleBox[\" \",FontSlant->\"Italic\"]\)is used as a prefix.\n\t\
3736
\!\(\*StyleBox[\"coord\",FontSlant->\"Italic\"]\) - a list of coordinates on \
38-
this space or a string prefix to generate names automatically, if missing \
39-
\!\(\*StyleBox[\"name\",FontSlant->\"Italic\"]\)\!\(\*StyleBox[\" \
37+
this space or a string prefix to generate names automatically; if missing, \!\
38+
\(\*StyleBox[\"name\",FontSlant->\"Italic\"]\)\!\(\*StyleBox[\" \
4039
\",FontSlant->\"Italic\"]\)is used as a prefix.\>\""}],
4140
"\n"}], "\[IndentingNewLine]",
4241
RowBox[{
@@ -57,12 +56,14 @@ corresponding lines in the package file.\>\""}],
5756
RowBox[{
5857
RowBox[{"GetArray", "::", "usage"}], "=", "\[IndentingNewLine]",
5958
"\"\<GetArray[\!\(\*StyleBox[\"expr\",FontSlant->\"Italic\"]\)] \
60-
substitutes arrays into tensor variables and performs contractions and math \
59+
substitutes tensor variables with arrays and performs contractions and math \
6160
operations. The optional variables are:\n\t\
6261
\!\(\*StyleBox[\"indices\",FontSlant->\"Italic\"]\) - a list of indices in \
63-
which order the tensor should be transposed. If omitted indices are taken to \
64-
be in standard order, i.e., the one returned by the standard Sort[] function.\
65-
\>\""}], "\[IndentingNewLine]"}], "\[IndentingNewLine]",
62+
which order the tensor should be transposed. If omitted \
63+
\!\(\*StyleBox[\"indices\",FontSlant->\"Italic\"]\) are taken to be the free \
64+
indices in \!\(\*StyleBox[\"expr\",FontSlant->\"Italic\"]\) in standard \
65+
order, i.e., the one returned by the standard Sort[] function.\>\""}],
66+
"\[IndentingNewLine]"}], "\[IndentingNewLine]",
6667
RowBox[{
6768
RowBox[{
6869
RowBox[{"metric", "::", "usage"}], "=", "\[IndentingNewLine]",
@@ -666,12 +667,23 @@ basises are multiplied successively starting from the first position.\>\""}],
666667
"]"}]}], "]"}], ";", "\[IndentingNewLine]",
667668
RowBox[{"If", "[",
668669
RowBox[{
670+
RowBox[{"head", "===", "basis"}], ",",
669671
RowBox[{
670-
RowBox[{"head", "===", "basis"}], "||",
671-
RowBox[{"head", "===", "\[Eth]"}]}], ",",
672+
RowBox[{"Print", "[",
673+
RowBox[{"\"\<Cannot set the built-in tensor: \>\"", ",", " ",
674+
RowBox[{"head", "[", "ind", "]"}]}], "]"}], ";",
675+
RowBox[{"Abort", "[", "]"}]}]}], "]"}], ";", "\[IndentingNewLine]",
676+
677+
RowBox[{"If", "[",
678+
RowBox[{
679+
RowBox[{"StringStartsQ", "[",
680+
RowBox[{
681+
RowBox[{"SymbolName", "[", "head", "]"}], ",", "\"\<\[Eth]\>\""}],
682+
"]"}], ",",
672683
RowBox[{
673684
RowBox[{"Print", "[",
674-
RowBox[{"\"\<Cannot modify the built-in tensor: \>\"", ",", " ",
685+
RowBox[{
686+
"\"\<Cannot set tensor starting with \[Eth]: \>\"", ",", " ",
675687
RowBox[{"head", "[", "ind", "]"}]}], "]"}], ";",
676688
RowBox[{"Abort", "[", "]"}]}]}], "]"}], ";", "\[IndentingNewLine]",
677689

@@ -1462,19 +1474,11 @@ basises are multiplied successively starting from the first position.\>\""}],
14621474
RowBox[{"Tensor", "[",
14631475
StyleBox[
14641476
RowBox[{"ind", ",", " ", "arr"}],
1465-
FontSlant->"Italic"], "]"}], " ", "into", " ",
1466-
RowBox[{
1467-
StyleBox[
1468-
RowBox[{"`",
1469-
StyleBox["arr",
1470-
FontSlant->"Italic"]}]],
1471-
StyleBox["[",
1472-
FontSlant->"Italic"],
1473-
StyleBox[
1474-
RowBox[{"[", "ind", "]"}],
1475-
FontSlant->"Italic"],
1476-
StyleBox["]",
1477-
FontSlant->"Italic"]}], "`"}], "*)"}], "\[IndentingNewLine]",
1477+
FontSlant->"Italic"], "]"}], " ", "into", " ", "`",
1478+
StyleBox[
1479+
RowBox[{"arr", "[",
1480+
RowBox[{"[", "ind", "]"}], "]"}],
1481+
FontSlant->"Italic"], "`"}], "*)"}], "\[IndentingNewLine]",
14781482
RowBox[{"tmp", "=",
14791483
RowBox[{"tmp", "/.",
14801484
RowBox[{
@@ -3471,12 +3475,18 @@ basises are multiplied successively starting from the first position.\>\""}],
34713475
3.8363794360518293`*^9, 3.8363794367303057`*^9}, 3.8363795024890423`*^9,
34723476
3.836379756144307*^9, {3.836379903117917*^9, 3.836379903236765*^9},
34733477
3.836379940323319*^9, 3.836380406753385*^9, {3.836380479975772*^9,
3474-
3.8363804869433613`*^9}},ExpressionUUID->"3b233b55-4636-484f-9c9c-\
3478+
3.8363804869433613`*^9}, {3.844226669190896*^9, 3.84422668497473*^9}, {
3479+
3.8442395695989943`*^9, 3.844239582438631*^9}, {3.8442396513208437`*^9,
3480+
3.844239665449916*^9}, {3.844239760725512*^9, 3.844239795833708*^9}, {
3481+
3.8442399443698587`*^9, 3.8442399614902077`*^9}, {3.845262828770987*^9,
3482+
3.8452628401852837`*^9}, {3.845262910253687*^9, 3.8452629113786917`*^9}, {
3483+
3.8452631509130898`*^9,
3484+
3.845263154556967*^9}},ExpressionUUID->"3b233b55-4636-484f-9c9c-\
34753485
5fbf90bee5dc"]
34763486
},
34773487
AutoGeneratedPackage->Automatic,
3478-
WindowSize->{1920, 1062},
3479-
WindowMargins->{{0, Automatic}, {-2, Automatic}},
3488+
WindowSize->{955, 1062},
3489+
WindowMargins->{{Automatic, 0}, {-2, Automatic}},
34803490
FrontEndVersion->"12.0 for Linux x86 (64-bit) (April 8, 2019)",
34813491
StyleDefinitions->"Dark.nb"
34823492
]
@@ -3491,7 +3501,7 @@ CellTagsIndex->{}
34913501
*)
34923502
(*NotebookFileOutline
34933503
Notebook[{
3494-
Cell[558, 20, 179304, 3454, 10220, "Input",ExpressionUUID->"3b233b55-4636-484f-9c9c-5fbf90bee5dc",
3504+
Cell[558, 20, 179986, 3464, 10266, "Input",ExpressionUUID->"3b233b55-4636-484f-9c9c-5fbf90bee5dc",
34953505
InitializationCell->True]
34963506
}
34973507
]

0 commit comments

Comments
 (0)