Skip to content

Commit

Permalink
make gen for vector spaces faster (#1403)
Browse files Browse the repository at this point in the history
  • Loading branch information
fieker authored Aug 4, 2023
1 parent bfa185a commit e537fdd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/generic/FreeModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ end
function gen(N::FreeModule{T}, i::Int) where T <: Union{RingElement, NCRingElem}
@boundscheck 1 <= i <= ngens(N) || throw(ArgumentError("generator index out of range"))
R = base_ring(N)
return N([(j == i ? one(R) : zero(R)) for j = 1:ngens(N)])
m = zero_matrix(R, 1, ngens(N))
m[1, i] = one(R)
return N(m)
end

basis(N::FreeModule) = gens(N)
Expand Down

0 comments on commit e537fdd

Please sign in to comment.