Skip to content

Commit

Permalink
bla
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma committed Oct 31, 2024
1 parent 9df1993 commit 04f5903
Showing 1 changed file with 73 additions and 4 deletions.
77 changes: 73 additions & 4 deletions src/flint/fmpz_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1855,13 +1855,82 @@ addmul!(z::ZZMatrixOrPtr, a::ZZMatrixOrPtr, b::Integer) = addmul!(z, a, flintify
addmul!(z::ZZMatrixOrPtr, a::IntegerUnionOrPtr, b::ZZMatrixOrPtr) = addmul!(z, b, a)

function mul!(z::Vector{ZZRingElem}, a::ZZMatrixOrPtr, b::Vector{ZZRingElem})
ccall((:fmpz_mat_mul_fmpz_vec_ptr, libflint), Nothing,
(Ptr{Ref{ZZRingElem}}, Ref{ZZMatrix}, Ptr{Ref{ZZRingElem}}, Int),
z, a, b, length(b))
return z
bb = Nemo.@new_struct(ZZMatrix)
be = zeros(Int, length(b))
zz = Nemo.@new_struct(ZZMatrix)
ze = zeros(Int, length(z))

GC.@preserve z b bb be zz ze begin
bb.entries = reinterpret(Ptr{ZZRingElem}, pointer(be))
bb.rows = reinterpret(Ptr{Ptr{ZZRingElem}}, pointer([pointer(be) + i for i in 0:length(b) - 1]))
bb.r = length(b)
bb.c = 1
@show b
for i in 1:length(be)
be[i] = b[i].d
end
@show bb

zz.entries = reinterpret(Ptr{ZZRingElem}, pointer(ze))
@show zz.entries
zz.rows = reinterpret(Ptr{Ptr{ZZRingElem}}, pointer([zz.entries + i for i in 0:length(z) - 1]))
zz.r = length(z)
zz.c = 1
@show zz

for i in 1:length(ze)
ze[i] = z[i].d
end
@show zz
mul!(zz, a, bb)
@show zz
for i in 1:length(ze)
z[i].d = ze[i]
end
return z
end
#ccall((:fmpz_mat_mul_fmpz_vec_ptr, libflint), Nothing,
# (Ptr{Ref{ZZRingElem}}, Ref{ZZMatrix}, Ptr{Ref{ZZRingElem}}, Int),
# z, a, b, length(b))
#return z
end

function mul!(z::Vector{ZZRingElem}, a::Vector{ZZRingElem}, b::ZZMatrixOrPtr)
if true false
aa = Nemo.@new_struct(ZZMatrix)
ae = zeros(Int, length(a))
if length(z) != length(a)
zz = Nemo.@new_struct(ZZMatrix)
ze = zeros(Int, length(z))
else
zz = aa
ze = ae
end
GC.@preserve z a aa ae zz ze begin
for i in 1:length(ae)
ae[i] = a[i].d
end
aa.entries = reinterpret(Ptr{ZZRingElem}, pointer(ae))
aa.rows = reinterpret(Ptr{Ptr{ZZRingElem}}, pointer([aa.entries]))
aa.r = 1
aa.c = length(ae)
if length(z) != length(a)
zz.entries = reinterpret(Ptr{ZZRingElem}, pointer(ze))
zz.rows = reinterpret(Ptr{Ptr{ZZRingElem}}, pointer([zz.entries]))
zz.r = 1
zz.c = length(ze)
for i in 1:length(ze)
ze[i] = z[i].d
end
end
mul!(zz, aa, b)
for i in 1:length(ze)
z[i].d = ze[i]
end
end
return z
end

ccall((:fmpz_mat_fmpz_vec_mul_ptr, libflint), Nothing,
(Ptr{Ref{ZZRingElem}}, Ptr{Ref{ZZRingElem}}, Int, Ref{ZZMatrix}),
z, a, length(a), b)
Expand Down

0 comments on commit 04f5903

Please sign in to comment.