Skip to content

Commit

Permalink
Merge pull request #11 from kalmarek/fix/julia-1.0
Browse files Browse the repository at this point in the history
Fix/julia 1.0
  • Loading branch information
Marek Kaluba authored Sep 1, 2021
2 parents 6dfa0f6 + 78b6666 commit 1dd45b3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.3'
- '1.0'
- '1'
- 'nightly'
os:
Expand Down
9 changes: 4 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
name = "StarAlgebras"
uuid = "0c0c59c1-dc5f-42e9-9a8b-b5dc384a6cd1"
authors = ["Marek Kaluba <[email protected]>"]
version = "0.1.3"
version = "0.1.4"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[compat]
julia = "1"
Groups = "0.6.0"
GroupsCore = "0.3"
julia = "1"

[extras]
Groups = "5d8bd718-bd84-11e8-3b40-ad14f4a32557"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
GroupsCore = "d5909c97-4eac-4ecc-a3dc-fdd0858a4120"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Groups", "GroupsCore", "Random", "Test"]
test = ["Pkg", "GroupsCore", "Random", "Test"]
35 changes: 19 additions & 16 deletions src/types.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
abstract type AbstractStarAlgebra end
abstract type AbstractStarAlgebra{O,T} end

struct StarAlgebra{O,T,M<:MultiplicativeStructure,B<:AbstractBasis{T}} <:
AbstractStarAlgebra
AbstractStarAlgebra{O,T}
object::O
mstructure::M
basis::B
Expand Down Expand Up @@ -96,24 +96,27 @@ function Base.isone(a::AlgebraElement)
isone(a[k]) || return false
return isone(b[k])
end
let SA = @static VERSION < v"1.3.0" ? :StarAlgebra : :AbstractStarAlgebra
@eval begin
function (A::$SA{O,T})(elt::T, S = Int) where {O,T}
if hasbasis(A)
b = basis(A)
i = b[elt]
return AlgebraElement(sparsevec([i], [one(S)], length(b)), A)
else
throw("Algebra without basis: cannot coerce $elt.")
end
end

function (A::AbstractStarAlgebra)(elt, T = Int)
if hasbasis(A)
b = basis(A)
i = b[elt]
return AlgebraElement(sparsevec([i], [one(T)], length(b)), A)
else
throw("Algebra without basis: cannot coerce $elt.")
function (A::$SA)(x::Number)
g = one(object(A))
res = A(g, typeof(x))
res = mul!(res, res, x)
return res
end
end
end

function (A::AbstractStarAlgebra)(x::Number)
g = one(object(A))
res = A(g, typeof(x))
res = mul!(res, res, x)
return res
end

Base.similar(X::AlgebraElement, ::Type{T} = eltype(X)) where {T} =
AlgebraElement(similar(coeffs(X), T), parent(X))

Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ include("test_example_words.jl")
include("constructors.jl")
include("arithmetic.jl")

include("sum_of_squares.jl")
if VERSION >= v"1.3.0"
using Pkg
Pkg.add("Groups")
include("sum_of_squares.jl")
end
end

2 comments on commit 1dd45b3

@kalmarek
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/43941

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.4 -m "<description of version>" 1dd45b3f38bc87958db847bb04d14c90687ba6ac
git push origin v0.1.4

Please sign in to comment.