oscar-system / Oscar.jl

A comprehensive open source computer algebra system for computations in algebra, geometry, and number theory.
https://www.oscar-system.org
Other
310 stars 113 forks source link

Inefficient conversion from OSCAR to Singular #3828

Open fingolfin opened 1 month ago

fingolfin commented 1 month ago

It seems there is quite some inefficient conversion code from OSCAR to Singular (perhaps also the other way around) in e.g. src/Rings/mpoly.jl. One example:

function (SF::Singular.N_AlgExtField)(a::fqPolyRepFieldElem)
  F = parent(a)
  SFa = gen(SF)
  res = SF(coeff(a, 0))
  for i in 1:degree(F)-1
    res += SF(coeff(a, i))*SFa^i # <- very inefficient
  end
  return res
end

At the very least don't compute SFa^i in each iteration, reuse the previous one. But really, we should use the coefficient vector and directly construct the output from that.

Multiple other functions in that file have the exact same problem.

I assume the algebraic geometry / commutative algebra team will want to resolve this.

ederc commented 1 month ago

Dumb question: Shouldn't these conversion functions not be part of Singular.jl?

fingolfin commented 1 month ago

@ederc agreed

fingolfin commented 3 weeks ago

Searching for ^i in this file reveals more instances.

fingolfin commented 3 weeks ago

We also just noticed that there may be a correctness issue here if the field on the OSCAR and Singular sides use different defining polynomials?

It also doesn't even check if the size of the fields coincides

thofma commented 3 weeks ago

Should be addressed together with https://github.com/oscar-system/Oscar.jl/issues/976