Skip to content

Commit 07c6bf6

Browse files
committed
Web style improvements.
1 parent 88b0b93 commit 07c6bf6

File tree

5 files changed

+44
-16
lines changed

5 files changed

+44
-16
lines changed

core/Algorithm.cc

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -777,17 +777,12 @@ Algorithm::range_vector_t::iterator Algorithm::find_arg_superset(range_vector_t&
777777

778778
bool Algorithm::is_termlike(iterator it)
779779
{
780-
if(tr.is_head(it)) {
781-
if(*it->name!="\\sum" && *it->name!="\\equals") return true;
782-
return false;
783-
}
784-
else {
785-
if(*tr.parent(it)->name=="\\sum" )
786-
return true;
787-
else if(*tr.parent(it)->name=="\\equals")
788-
return true;
789-
return false;
790-
}
780+
if(!is_factorlike(it))
781+
if(*it->name!="\\sum")
782+
if(it->fl.parent_rel==str_node::p_none)
783+
return true;
784+
785+
return false;
791786
}
792787

793788
bool Algorithm::is_factorlike(iterator it)

core/Algorithm.hh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,14 @@ class Algorithm : public IndexClassifier {
167167
static bool compare_(const str_node&, const str_node&);
168168

169169

170-
/// Determine structure (version-2)
170+
/// Determines whether the indicated node is 'like a term in a
171+
/// sum'. This requires that the node is not a `\sum` node, not
172+
/// a child of a `\prod` node, and that its parent rel is of
173+
/// argument-type (p_none).
171174
bool is_termlike(iterator);
175+
176+
/// Determines whether the indicated node is 'like a factor in a product'.
177+
/// This requires that the parent is a `\prod' node.
172178
bool is_factorlike(iterator);
173179

174180
/// Take a single non-product node in a sum and wrap it in a

core/algorithms/explicit_indices.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "algorithms/substitute.hh"
55
#include "properties/ImplicitIndex.hh"
66
#include "properties/PartialDerivative.hh"
7+
#include "properties/Trace.hh"
78

89
using namespace cadabra;
910

@@ -21,6 +22,8 @@ bool explicit_indices::can_apply(iterator st)
2122
// same index names.
2223

2324
if(*st->name=="\\equals") return false; // switch
25+
auto trace = kernel.properties.get<Trace>(st);
26+
if(trace) return false;
2427
if(*st->name=="\\sum") return true;
2528
if(is_termlike(st)) {
2629
if(tr.is_head(st)) return true;
@@ -35,6 +38,8 @@ Algorithm::result_t explicit_indices::apply(iterator& it)
3538
{
3639
result_t res=result_t::l_no_action;
3740

41+
std::cerr << "apply at " << it << std::endl;
42+
3843
// Ensure that we are always working on a sum, even
3944
// if there is only one term.
4045
if(is_termlike(it))
@@ -48,6 +53,9 @@ Algorithm::result_t explicit_indices::apply(iterator& it)
4853

4954
sibling_iterator term=tr.begin(it);
5055
while(term!=tr.end(it)) {
56+
iterator nxt=term;
57+
++nxt;
58+
5159
iterator tmp=term;
5260
prod_wrap_single_term(tmp);
5361
term=tmp;
@@ -77,8 +85,10 @@ Algorithm::result_t explicit_indices::apply(iterator& it)
7785
}
7886

7987
tmp=term;
88+
std::cerr << term << std::endl;
8089
prod_unwrap_single_term(tmp);
81-
++term;
90+
91+
term=nxt;
8292
}
8393

8494
return res;

tests/explicit_implicit.cdb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,22 @@ def test03():
5050
print("Test 03 passed")
5151

5252
test03()
53-
53+
54+
# def test04():
55+
# __cdbkernel__=create_scope()
56+
# {m,n,p}::Indices(spacetime, position=fixed);
57+
# {a,b,c,d,e,f,g,h}::Indices(spinor, position=fixed);
58+
# \sigma^{p}::ImplicitIndex(\sigma^{p}_{a b});
59+
# \tau^{p}::ImplicitIndex(\tau^{p a b});
60+
# Tr{#}::Trace(indices=spinor);
61+
# ex:= Tr( \sigma^{m} \tau^{n} );
62+
# explicit_indices(_);
63+
# tst:= \sigma^{m}_{a b} \tau^{n b a} - @(ex);
64+
# assert(tst==0)
65+
# print("Test 04 passed")
66+
#
67+
# test04()
68+
5469
#ex:= \chi \psi \sigma^{n} \chi;
5570
#explicit_indices(_);
5671

web2/cadabra2/source/static/styles/cadabra-web.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ div.latex_view {
294294
}
295295
div.MathJax_Display {
296296
text-align: left !important;
297-
margin-bottom: 0px !important;
297+
margin-bottom: 5px !important;
298+
margin-top: 5px !important;
299+
margin-left: 30px;
298300
padding-bottom: 0px !important;
299301
}
300302
.mjx-chtml {
@@ -317,7 +319,7 @@ div.python > div.source {
317319
margin-bottom: 10px;
318320
padding-bottom: 0px;
319321
margin-top: 10px;
320-
white-space: pre;
322+
white-space: pre-wrap;
321323
line-height: 20px;
322324
color: blue;
323325
margin-left: 0px;

0 commit comments

Comments
 (0)