Skip to content

Commit

Permalink
feat: improve matrix algebra code (#1415)
Browse files Browse the repository at this point in the history
- use more inplace operations
  • Loading branch information
thofma authored Feb 23, 2024
1 parent 320cf85 commit 67a5f48
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/AlgAss/AlgMatElem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ end
Returns $a^b$.
"""
function ^(a::MatAlgebraElem, b::Int)
return parent(a)(matrix(a, copy = false)^b)
return parent(a)(matrix(a, copy = false)^b, check = false)
end

################################################################################
Expand Down Expand Up @@ -260,12 +260,13 @@ function (A::MatAlgebra{T, S})(v::Vector{T}; copy::Bool = true) where { T, S }
@assert length(v) == dim(A)
R = coefficient_ring(A)
M = zero_matrix(R, degree(A), degree(A))
temp = zero_matrix(R, degree(A), degree(A))
B = basis(A)
for i = 1:dim(A)
#M = add!(M, M, matrix(basis(A)[i], copy = false)*v[i])
M += matrix(B[i], copy = false)*R(v[i])
temp = mul!(temp, matrix(B[i], copy = false), R(v[i]))
M = add!(M, M, temp)
end
a = A(M; check = false)
a = A(M; check = false, deepcopy = false)
if copy
a.coeffs = Base.copy(v)
else
Expand Down

0 comments on commit 67a5f48

Please sign in to comment.