Skip to content

Commit 35eb5bd

Browse files
committed
Merge remote-tracking branch 'dept/domdev'
2 parents 37cdbdd + 0e7d12f commit 35eb5bd

File tree

6 files changed

+506
-599
lines changed

6 files changed

+506
-599
lines changed

cmake/modules/FindGTKMM3.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ if(WIN32)
22
# windows_find_library(GTKMM3 "gtkmm.dll" "glib;sigc++;pango")
33
windows_find_library(GTKMM3_LIBRARIES
44
gtk gdk gdk_pixbuf pangocairo pango atk gio gobject
5-
gmodule glib cairo-gobject cairo libintl atkmm cairomm
5+
gmodule glib cairo-gobject cairo intl atkmm cairomm
66
gdkmm giomm glibmm gtkmm pangomm
77
)
88
if (GTKMM3_LIBRARIES)
@@ -18,4 +18,4 @@ endif()
1818

1919
if (GTKMM3_FOUND)
2020
message(STATUS "Found gtkmm")
21-
endif()
21+
endif()

core/Adjform.cc

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -359,34 +359,38 @@ namespace cadabra {
359359
return -(Adjform::value_type)data->begin().number_of_children();
360360
}
361361

362-
AdjformEx::rational_type AdjformEx::zero = 0;
362+
AdjformEx::integer_type AdjformEx::zero = 0;
363363

364364
AdjformEx::AdjformEx()
365365
{
366366

367367
}
368368

369-
AdjformEx::AdjformEx(const Adjform& adjform, const AdjformEx::rational_type& value, const Ex& prefactor)
369+
AdjformEx::AdjformEx(const Adjform& adjform, const AdjformEx::integer_type& value, const Ex& prefactor)
370370
: prefactor(prefactor)
371371
{
372+
sizeof(mpq_class);
373+
sizeof(int64_t);
372374
set(adjform, value);
373375
}
374376

375-
AdjformEx::AdjformEx(const Adjform& adjform, const rational_type& value, Ex::iterator prefactor)
377+
AdjformEx::AdjformEx(const Adjform& adjform, const integer_type& value, Ex::iterator prefactor)
376378
: prefactor(prefactor)
377379
{
378380
set(adjform, value);
379381
}
380382

381-
AdjformEx::AdjformEx(Ex::iterator it, IndexMap& index_map, const Kernel& kernel)
383+
AdjformEx::AdjformEx(Ex& tr, Ex::iterator it, IndexMap& index_map, const Kernel& kernel)
382384
: prefactor(str_node("\\prod"))
383385
, tensor(str_node("\\prod"))
384386
{
385387
set(Adjform(it, index_map, kernel));
386388

387389
if (*it->name == "\\prod") {
390+
Ex_comparator comp(kernel.properties);
391+
388392
for (Ex::sibling_iterator beg = it.begin(), end = it.end(); beg != end; ++beg) {
389-
if (has_indices(kernel, beg))
393+
if (has_indices(kernel, beg) || !comp.can_move_to_front(tr, it, beg))
390394
tensor.append_child(tensor.begin(), (Ex::iterator)beg);
391395
else
392396
prefactor.append_child(prefactor.begin(), (Ex::iterator)beg);
@@ -410,7 +414,7 @@ namespace cadabra {
410414
one(tensor_begin->multiplier);
411415
}
412416

413-
AdjformEx::rational_type AdjformEx::compare(const AdjformEx& other) const
417+
AdjformEx::integer_type AdjformEx::compare(const AdjformEx& other) const
414418
{
415419
// Early failure checks
416420
if (data.empty() || data.size() != other.data.size())
@@ -419,7 +423,7 @@ namespace cadabra {
419423
// Find the numeric factor between the first two terms, then loop over all
420424
// other terms checking that the factor is the same. If not, return 0
421425
auto a_it = data.begin(), b_it = other.data.begin(), a_end = data.end();
422-
rational_type factor = a_it->second / b_it->second;
426+
integer_type factor = a_it->second / b_it->second;
423427
while (a_it != a_end) {
424428
if (a_it->first != b_it->first)
425429
return 0;
@@ -436,13 +440,13 @@ namespace cadabra {
436440
add(kv.first, kv.second);
437441
}
438442

439-
void AdjformEx::combine(const AdjformEx& other, AdjformEx::rational_type factor)
443+
void AdjformEx::combine(const AdjformEx& other, AdjformEx::integer_type factor)
440444
{
441445
for (const auto& kv : other.data)
442446
add(kv.first, kv.second * factor);
443447
}
444448

445-
void AdjformEx::multiply(const AdjformEx::rational_type& k)
449+
void AdjformEx::multiply(const AdjformEx::integer_type& k)
446450
{
447451
for (auto& kv : data)
448452
kv.second *= k;
@@ -517,33 +521,33 @@ namespace cadabra {
517521
return tensor;
518522
}
519523

520-
const AdjformEx::rational_type& AdjformEx::get(const Adjform& adjform) const
524+
const AdjformEx::integer_type& AdjformEx::get(const Adjform& adjform) const
521525
{
522526
auto pos = data.find(adjform);
523527
return (pos == data.end()) ? zero : pos->second;
524528
}
525529

526-
void AdjformEx::set(const Adjform& term, const AdjformEx::rational_type& value)
530+
void AdjformEx::set(const Adjform& term, const AdjformEx::integer_type& value)
527531
{
528532
if (!term.empty())
529533
set_(term, value);
530534
}
531535

532-
void AdjformEx::set_(const Adjform& term, const AdjformEx::rational_type& value)
536+
void AdjformEx::set_(const Adjform& term, const AdjformEx::integer_type& value)
533537
{
534538
if (value != 0)
535539
data[term] = value;
536540
else
537541
data.erase(term);
538542
}
539543

540-
void AdjformEx::add(const Adjform& term, const AdjformEx::rational_type& value)
544+
void AdjformEx::add(const Adjform& term, const AdjformEx::integer_type& value)
541545
{
542546
if (!term.empty())
543547
add_(term, value);
544548
}
545549

546-
void AdjformEx::add_(const Adjform& term, const AdjformEx::rational_type& value)
550+
void AdjformEx::add_(const Adjform& term, const AdjformEx::integer_type& value)
547551
{
548552
auto elem = data.find(term);
549553
if (elem == data.end() && value != 0) {

core/Adjform.hh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,23 @@ namespace cadabra {
8484
class AdjformEx
8585
{
8686
public:
87-
using rational_type = mpq_class;
88-
using map_t = std::map<Adjform, rational_type>;
87+
using integer_type = int32_t;
88+
using map_t = std::map<Adjform, integer_type>;
8989
using iterator = map_t::iterator;
9090
using const_iterator = map_t::const_iterator;
9191

9292
AdjformEx();
93-
AdjformEx(const Adjform& adjform, const rational_type& value = 1, const Ex& prefactor = Ex());
94-
AdjformEx(const Adjform& adjform, const rational_type& value, Ex::iterator prefactor);
95-
AdjformEx(Ex::iterator it, IndexMap& index_map, const Kernel& kernel);
93+
AdjformEx(const Adjform& adjform, const integer_type& value = 1, const Ex& prefactor = Ex());
94+
AdjformEx(const Adjform& adjform, const integer_type& value, Ex::iterator prefactor);
95+
AdjformEx(Ex& tr, Ex::iterator it, IndexMap& index_map, const Kernel& kernel);
9696

9797
// Check if 'other' is a linear multiple of 'this' and return
9898
// the numeric factor if so, otherwise returns 0
99-
rational_type compare(const AdjformEx& other) const;
99+
integer_type compare(const AdjformEx& other) const;
100100

101101
void combine(const AdjformEx& other); // Add all contributions from 'other' into 'this'
102-
void combine(const AdjformEx& other, rational_type factor);
103-
void multiply(const rational_type& k); // Multiply all terms by a constant factor
102+
void combine(const AdjformEx& other, integer_type factor);
103+
void multiply(const integer_type& k); // Multiply all terms by a constant factor
104104

105105
iterator begin();
106106
const_iterator begin() const;
@@ -119,11 +119,11 @@ namespace cadabra {
119119
Ex& get_tensor_ex();
120120

121121
// Get the value of the term, or zero if it doesn't exist
122-
const rational_type& get(const Adjform& adjform) const;
122+
const integer_type& get(const Adjform& adjform) const;
123123
// Sets the given term to value, creating/removing the term if required
124-
void set(const Adjform& adjform, const rational_type& value = 1);
124+
void set(const Adjform& adjform, const integer_type& value = 1);
125125
// Adds value to the given term, creating/removing the term if required
126-
void add(const Adjform& adjform, const rational_type& value = 1);
126+
void add(const Adjform& adjform, const integer_type& value = 1);
127127

128128
// Symmetrize in the given indices
129129
// e.g. if the only term is abcd then
@@ -143,12 +143,12 @@ namespace cadabra {
143143

144144
private:
145145
// Unsafe (but faster) versions of the public functions
146-
void set_(const Adjform& adjform, const rational_type& value = 1);
147-
void add_(const Adjform& adjform, const rational_type& value = 1);
146+
void set_(const Adjform& adjform, const integer_type& value = 1);
147+
void add_(const Adjform& adjform, const integer_type& value = 1);
148148
map_t data;
149149
Ex prefactor;
150150
Ex tensor;
151-
static rational_type zero;
151+
static integer_type zero;
152152
};
153153
}
154154

core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ add_executable(cadabra2-cli
304304
)
305305
target_compile_definitions(cadabra2-cli PRIVATE CDBPYTHON_NO_NOTEBOOK)
306306
target_include_directories(cadabra2-cli PRIVATE ${PYTHON_INCLUDE_DIRS})
307-
target_link_libraries(cadabra2-cli PRIVATE ${PYTHON_LIBRARIES} ${GLIBMM_LIBRARIES})
307+
target_link_libraries(cadabra2-cli PRIVATE ${PYTHON_LIBRARIES} ${GLIBMM3_LIBRARIES})
308308

309309
# Test preprocessor executable
310310
add_executable(test_preprocessor

0 commit comments

Comments
 (0)