Skip to content

Commit

Permalink
delete memory (#78)
Browse files Browse the repository at this point in the history
* delete memory

* delete commented code

* update version to 1.0.6
  • Loading branch information
kotarotanahashi authored Oct 19, 2020
1 parent fdebf82 commit 9607026
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 37 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set(CMAKE_CXX_FLAGS "-std=c++11 -O4")

include(external/pybind11.cmake)
include_directories(cpp_dimod)
#add_subdirectory(include)
add_subdirectory(src)


Expand Down
5 changes: 0 additions & 5 deletions include/coeff.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class CoeffPlaceholder: public Coeff{
PlPolyPtr expand() override {
auto prod = CoeffProd(label, 1);
auto poly = new PHMono(prod, 1.0);
//cout << "CoeffPlaceholder::expand " << poly->to_string() << "\n";
return poly;
}

Expand Down Expand Up @@ -131,9 +130,7 @@ class CoeffMul: public Coeff{
PlPolyPtr expand() override {
auto poly_right = right->expand();
auto poly_left = left->expand();
//auto new_poly = poly_right->mul(poly_left);
auto new_poly = PlPolyOperation::mul(poly_right, poly_left);
//cout << "mul::expand " << new_poly->to_string() << "\n";
return new_poly;
}
};
Expand Down Expand Up @@ -167,9 +164,7 @@ class CoeffAdd: public Coeff{
PlPolyPtr expand() override {
auto poly_right = right->expand();
auto poly_left = left->expand();
//auto new_poly = poly_right->add(poly_left);
auto new_poly = PlPolyOperation::add(poly_right, poly_left);
//cout << "add::expand " << new_poly->to_string() << "\n";
return new_poly;
}
};
11 changes: 0 additions & 11 deletions include/express.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,23 @@ class Add : public Base{
Add(shared_ptr<Add> add_left, shared_ptr<Add> add_right):
node(create_node(add_left, add_right)){}

//Add(double add_left, shared_ptr<Add> add_right):
// node(create_node(make_shared<Num>(add_left), add_right)){}

Add(shared_ptr<Base> child){
this->node = new AddList(child);
}

Add(shared_ptr<Base> left, shared_ptr<Base> right){
//cout << "Add::add\n";
this->node = new AddList(left);
this->node->next = new AddList(right);
}

Add(shared_ptr<Base> left, double right_num){
BasePtr right = static_pointer_cast<Base>(make_shared<Num>(right_num));
Add(left, right);
//this->node = new AddList(left);
//this->node->next = new AddList(right);
}

Add(double left_num, shared_ptr<Base> right){
BasePtr left = static_pointer_cast<Base>(make_shared<Num>(left_num));
Add(left, right);
//this->node = new AddList(left);
//this->node->next = new AddList(right);
}

~Add(){}
Expand Down Expand Up @@ -501,8 +493,6 @@ class SubH: public Base{

~SubH(){}

//virtual BasePtr express() = 0;
//virtual BasePtr penalty() = 0;
virtual ExpressType get_type() const override {
return ExpressType::SUBH;
}
Expand Down Expand Up @@ -553,7 +543,6 @@ class Constraint: public Base{
}

std::string to_string(bool with_symbol) override {
//check_instance_variable();
return string("Constraint(label=") + label + "," + this->hamiltonian->to_string(with_symbol) + ")";
}

Expand Down
6 changes: 3 additions & 3 deletions include/prod.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ class Prod {
}

Prod merge(Prod& other){
int i = 0; // index for this->sorted_indices
int j = 0; // index for other.sorted_indices
int k = 0; // index for new_sorted_indices
int i = 0;
int j = 0;
int k = 0;
size_t max_size = std::max(this->length, other.length);
uint32_t* new_sorted_indices = new uint32_t[max_size+1];

Expand Down
8 changes: 0 additions & 8 deletions include/pybase.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ class PyBase : public Base {
);
}

/*Poly* expand() override {
PYBIND11_OVERLOAD_PURE(
Poly*,
Base,
expand
);
};*/

Expanded* expand(Encoder& encoder) override {return NULL;}

bool equal_to(BasePtr other) override {
Expand Down
2 changes: 1 addition & 1 deletion pyqubo/package_info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# (major, minor, patch, prerelease)

VERSION = (1, 0, 5, "")
VERSION = (1, 0, 6, "")
__shortversion__ = '.'.join(map(str, VERSION[:3]))
__version__ = '.'.join(map(str, VERSION[:3])) + "".join(VERSION[3:])

Expand Down
10 changes: 2 additions & 8 deletions src/express.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

using namespace::std;

/*---------- Base ------------*/
BasePtr Base::add(BasePtr other){
BasePtr this_ptr = shared_from_this();
AddPtr new_base(new Add(this_ptr, other));
Expand Down Expand Up @@ -113,12 +112,11 @@ Model Base::compile(CoeffPtr strength){

auto model = Model(*compiled_qubo, encoder, expanded);

//expanded->delete_linked_list();
//delete expanded;
expanded->delete_linked_list();
delete expanded;
return model;
}

/*---------- Add ------------*/
BasePtr Add::add(BasePtr other){
BasePtr this_ptr = shared_from_this();
AddPtr new_base(new Add(static_pointer_cast<Add>(this_ptr), other));
Expand All @@ -139,15 +137,13 @@ Expanded* Add::expand(Encoder& encoder){
return new_expanded;
};

/*---------Mul------------*/
Expanded* Mul::expand(Encoder& encoder){
Expanded* left_expanded = this->left->expand(encoder);
Expanded* right_expanded = this->right->expand(encoder);
Expanded* new_expanded = expanded::mul(left_expanded, right_expanded);
return new_expanded;
};

/*---------Binary------------*/
Expanded* Binary::expand(Encoder& encoder){
BasePtr this_ptr = shared_from_this();
Mono* poly = new Mono(static_pointer_cast<Binary>(this_ptr), encoder);
Expand All @@ -162,14 +158,12 @@ Expanded* Spin::expand(Encoder& encoder){
return new_expanded;
};

/*---------Num------------*/
Expanded* Num::expand(Encoder& encoder){
BasePtr this_ptr = shared_from_this();
Mono* poly = new Mono(static_pointer_cast<Num>(this_ptr));
return new Expanded(poly);
};

/*---------Placeholder------------*/
Expanded* Placeholder::expand(Encoder& encoder){
BasePtr this_ptr = shared_from_this();
Mono* poly = new Mono(static_pointer_cast<Placeholder>(this_ptr));
Expand Down

0 comments on commit 9607026

Please sign in to comment.