my_pair
instance into which we write the exponent during each term multiplication. Or am I misremembering?
my_pair
is (3, 6)
(3, 2)
in the set
(3, 8)
in the set, right?
my_pair
(3, 6)
how do I use _bucket
because that element does not exist
my_pair
with the _bucket()
method_find()
passing the my_pair
instance and the output from _bucket()
_find()
is end()
, then use _unique_insert()
_bucket
is my_pair
not my_pair
.first
_bucket()
method takes as input a pair
(3, 6)
bucket value of (3, 2)
won't be returned.
end()
end()
.first
(3, 6)
, will I get close (3, 2)
and hence serve our purpose?
for (auto &a: A) {
for (auto &b: B) {
temp.first = a.first + b.first;
temp.second = a.second * b.second;
size_t bucket = C._bucket(temp);
auto it = C._find(temp, bucket);
if (it == C.end()) {
C._unique_insert(temp, bucket);
} else {
piranha::math::multiply_accumulate(it->second,a.second,b.second);
}
}
}
temp.second = a.second * b.second;
this you should do it inside the if (it == C.end()) {
else
you are doing another multiplication
max_load_factor
give?
_update_size()
method
max_load_factor()
is hard-coded to one currently
evaluate_sparsity
happening
0,11488
1,3605
2,1206
3,85
24ms
number of terms: 6272
expand2d: /usr/local/include/piranha/hash_set.hpp:784: piranha::hash_set<T, Hash, Pred>::~hash_set() [with T = SymEngine::my_pair; Hash = SymEngine::my_hash; Pred = SymEngine::hash_eq]: Assertion `sanity_check()' failed.
Abort caught. Printing stacktrace:
Traceback (most recent call last):
Done.
Aborted (core dumped)
evaluate_sparsity
, my bad, it is in the destructor
_update_size()
was never called
_
are considered low-level and potentially dangerous
bucket
is declared?
bucket = C._bucket(temp);
rehash
ing inside the poly_mul3
routine
rehash(10000)
?
begin
and end
iterators for B
on top
begin
iterator
auto
also uses the iterators
it
iterator
const hash_set::iterator begin = B.begin(), end = B.end();
for (auto &a: A) {
for (hash_set::iterator itB = begin; itB != end; ++itB) {
temp.first = a.first + itB->first;
size_t bucket = C._bucket(temp);
auto it = C._find(temp, bucket);
if (it == C.end()) {
// Check it the load factor of C is too large.
if ((double(C.size()) + 1) / C.bucket_count() > C.max_load_factor()) {
// Increase the size of the table.
C._increase_size();
// Recompute the bucker.
bucket = C._bucket(temp);
}
temp.second = a.second * itB->second;
C._unique_insert(temp, bucket);
C._update_size(C.size() + 1u);
} else {
piranha::math::multiply_accumulate(it->second,a.second,it->second);
}
}
}
piranha::math::multiply_accumulate(it->second,a.second,it->second);
piranha::math::multiply_accumulate(it->second,a.second,itB->second);
```
Type code here
cool!
auto
at the moment yes
term
? Piranha is using its own data structure, so maybe we can try using it. Besides hashing, exponent packing (are we using exactly the same ones as Piranha?), hash table (we now use Piranha's) and integer (we now use piranha::integer
), what else can possibly affect the performance of the mul_poly
function?
my_pair
was made up in no time.
rehash
from 10,000
to 100,000
sudo nice -n -19
expand2d
in same conditions 21-22ms
rehash
to 100,000, 18-19ms
my_pair
is fine?
term
class in Piranha is really thin.. it's a my_pair
with a couple of methods on top
temp.second = a.second * b.second;
with:
temp.second = a;
temp.second *= b.second;
unsigned long long
to long long
cmake -DWITH_PIRANHA=yes -DWITH_MPFR=yes .
make VERBOSE=1
C++ compiler: /usr/bin/c++
Build type: Release
C++ compiler flags: -std=c++0x -Wall -Wextra -fPIC -O3 -march=native -ffast-math -funroll-loops -Wno-unused-parameter
make VERBOSE=1
?
[ 27%] Building CXX object src/CMakeFiles/symengine.dir/pow.cpp.o
cd /home/sumith/github/csympy/src && /usr/bin/c++ -std=c++0x -Wall -Wextra -fPIC -O3 -march=native -ffast-math -funroll-loops -Wno-unused-parameter -I/home/sumith/github/csympy/src -I/home/sumith/github/csympy/src/teuchos -I/usr/local/include -o CMakeFiles/symengine.dir/pow.cpp.o -c /home/sumith/github/csympy/src/pow.cpp
-DNDEBUG
NDEBUG
macro is actually part of the standard:
assert
s will be skipped
NDEBUG
/usr/bin/c++ -std=c++11 -fdiagnostics-color=auto -ftemplate-depth=1024 -fvisibility-inlines-hidden -fvisibility=hidden -pthread -O3 -DNDEBUG
(x + y + z + w)**15
try to raise to 20 or something like this
std::vector
encode
doesn't work in power of two, we need to think about that too
monomial
which allows generic representation of exponents
encode
and decode
will tell you when there is an overflow (an exception will be raised)
monomial<rational>
, monomial<integer>
, etc.
monomial<int>
if you want
monomial<symbol>
does not exist in Piranha currently (a symbol in Piranha is just a label, a string representing a symbolic variable)