Skip to content

Commit

Permalink
fix clang error (#85)
Browse files Browse the repository at this point in the history
* Update ci.yml

* use vector

* more clang fixes

* fix
  • Loading branch information
ahmed-irfan authored Dec 17, 2024
1 parent a79b13b commit c2c079c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: |
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=${{ matrix.mode }} ..
${{ matrix.env }} cmake -DCMAKE_BUILD_TYPE=${{ matrix.mode }} ..
make
- name: Check
Expand Down
14 changes: 8 additions & 6 deletions src/polyxx/polynomial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,29 +377,31 @@ namespace poly {

std::vector<Polynomial> psc(const Polynomial& p, const Polynomial& q) {
std::size_t size = std::min(degree(p), degree(q)) + 1;
lp_polynomial_t* tmp[size];
std::vector<lp_polynomial_t*> tmp;
for (std::size_t i = 0; i < size; ++i) {
tmp[i] = lp_polynomial_new(detail::context(p, q));
tmp.push_back(lp_polynomial_new(detail::context(p, q)));
}
lp_polynomial_psc(tmp, p.get_internal(), q.get_internal());
lp_polynomial_psc(tmp.data(), p.get_internal(), q.get_internal());
std::vector<Polynomial> res;
for (std::size_t i = 0; i < size; ++i) {
res.emplace_back(tmp[i]);
}
tmp.clear();
return res;
}

std::vector<Polynomial> subres(const Polynomial& p, const Polynomial& q) {
std::size_t size = std::min(degree(p), degree(q)) + 1;
lp_polynomial_t* tmp[size];
std::vector<lp_polynomial_t*> tmp;
for (std::size_t i = 0; i < size; ++i) {
tmp[i] = lp_polynomial_new(detail::context(p, q));
tmp.push_back(lp_polynomial_new(detail::context(p, q)));
}
lp_polynomial_subres(tmp, p.get_internal(), q.get_internal());
lp_polynomial_subres(tmp.data(), p.get_internal(), q.get_internal());
std::vector<Polynomial> res;
for (std::size_t i = 0; i < size; ++i) {
res.emplace_back(tmp[i]);
}
tmp.clear();
return res;
}

Expand Down
9 changes: 6 additions & 3 deletions src/polyxx/upolynomial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,19 @@ namespace poly {
}

std::vector<Integer> coefficients(const UPolynomial& p) {
lp_integer_t coeffs[degree(p) + 1];
std::vector<lp_integer_t> coeffs;
lp_integer_t tmp;
for (std::size_t i = 0; i < degree(p) + 1; ++i) {
lp_integer_construct_from_int(lp_Z, &coeffs[i], 0);
lp_integer_construct_from_int(lp_Z, &tmp, 0);
coeffs.push_back(tmp);
}
lp_upolynomial_unpack(p.get_internal(), coeffs);
lp_upolynomial_unpack(p.get_internal(), coeffs.data());
std::vector<Integer> res;
for (std::size_t i = 0; i < degree(p) + 1; ++i) {
res.emplace_back(&coeffs[i]);
lp_integer_destruct(&coeffs[i]);
}
coeffs.clear();
return res;
}

Expand Down

0 comments on commit c2c079c

Please sign in to comment.