mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2025-01-01 03:40:29 +01:00
isdefined(::GroupRing, :basis) safety checks
This commit is contained in:
parent
b73aebe33a
commit
3176172f23
@ -100,15 +100,17 @@ function (RG::GroupRing)(T::Type=Int)
|
|||||||
return GroupRingElem(spzeros(T,length(RG.basis)), RG)
|
return GroupRingElem(spzeros(T,length(RG.basis)), RG)
|
||||||
end
|
end
|
||||||
|
|
||||||
function (A::GroupRing)(X::GroupRingElem)
|
function (RG::GroupRing)(X::GroupRingElem)
|
||||||
length(X) == length(A.basis) || throw("Can not coerce to $A: lengths differ")
|
isdefined(RG, :basis) || throw("Complete the definition of GroupRing first")
|
||||||
X.parent = A
|
length(X) == length(RG.basis) || throw("Can not coerce to $RG: lengths differ")
|
||||||
|
X.parent = RG
|
||||||
return X
|
return X
|
||||||
end
|
end
|
||||||
|
|
||||||
function (A::GroupRing)(x::AbstractVector)
|
function (RG::GroupRing)(x::AbstractVector)
|
||||||
length(x) == length(A.basis) || throw("Can not coerce to $A: lengths differ")
|
isdefined(RG, :basis) || throw("Complete the definition of GroupRing first")
|
||||||
return GroupRingElem(x, A)
|
length(x) == length(RG.basis) || throw("Can not coerce to $RG: lengths differ")
|
||||||
|
return GroupRingElem(x, RG)
|
||||||
end
|
end
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -262,8 +264,10 @@ end
|
|||||||
function groupring_mult{T<:Number}(X::GroupRingElem{T}, Y::GroupRingElem{T})
|
function groupring_mult{T<:Number}(X::GroupRingElem{T}, Y::GroupRingElem{T})
|
||||||
parent(X) == parent(Y) || throw(ArgumentError(
|
parent(X) == parent(Y) || throw(ArgumentError(
|
||||||
"Elements don't seem to belong to the same Group Ring!"))
|
"Elements don't seem to belong to the same Group Ring!"))
|
||||||
result = groupring_mult(X.coeffs, Y.coeffs, parent(X).pm)
|
RG = parent(X)
|
||||||
return GroupRingElem(result, parent(X))
|
isdefined(RG, :pm) || complete(RG)
|
||||||
|
result = groupring_mult(X.coeffs, Y.coeffs, RG.pm)
|
||||||
|
return GroupRingElem(result, RG)
|
||||||
end
|
end
|
||||||
|
|
||||||
function groupring_mult{T<:Number, S<:Number}(X::GroupRingElem{T},
|
function groupring_mult{T<:Number, S<:Number}(X::GroupRingElem{T},
|
||||||
@ -271,8 +275,10 @@ function groupring_mult{T<:Number, S<:Number}(X::GroupRingElem{T},
|
|||||||
parent(X) == parent(Y) || throw("Elements don't seem to belong to the same
|
parent(X) == parent(Y) || throw("Elements don't seem to belong to the same
|
||||||
Group Ring!")
|
Group Ring!")
|
||||||
warn("Multiplying elements with different base rings!")
|
warn("Multiplying elements with different base rings!")
|
||||||
result = groupring_mult(X.coeffs, Y.coeffs, parent(X).pm)
|
RG = parent(X)
|
||||||
return GroupRingElem(result, parent(X))
|
isdefined(RG, :pm) || complete(RG)
|
||||||
|
result = groupring_mult(X.coeffs, Y.coeffs, RG.pm)
|
||||||
|
return GroupRingElem(result, RG)
|
||||||
end
|
end
|
||||||
|
|
||||||
(*)(X::GroupRingElem, Y::GroupRingElem) = groupring_mult(X,Y)
|
(*)(X::GroupRingElem, Y::GroupRingElem) = groupring_mult(X,Y)
|
||||||
@ -286,6 +292,7 @@ end
|
|||||||
function star(X::GroupRingElem)
|
function star(X::GroupRingElem)
|
||||||
isdefined(X, :parent) || throw("Define parent object for $X first")
|
isdefined(X, :parent) || throw("Define parent object for $X first")
|
||||||
RG = parent(X)
|
RG = parent(X)
|
||||||
|
isdefined(RG, :basis) || complete(RG)
|
||||||
result = RG()
|
result = RG()
|
||||||
for (i,c) in enumerate(X.coeffs)
|
for (i,c) in enumerate(X.coeffs)
|
||||||
if c != zero(eltype(X.coeffs))
|
if c != zero(eltype(X.coeffs))
|
||||||
|
Loading…
Reference in New Issue
Block a user