Skip to content

Commit

Permalink
Merge pull request #31 from RexWzh/rex-dev
Browse files Browse the repository at this point in the history
minor changes to operations
  • Loading branch information
RexWzh authored Oct 16, 2022
2 parents 886582a + 38ac892 commit 3f34546
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QRCoders"
uuid = "f42e9828-16f3-11ed-2883-9126170b272d"
authors = ["Jérémie Gillet <jie.gillet@gmail.com> and contributors"]
version = "1.2.0"
version = "1.2.1"

This comment has been minimized.

Copy link
@RexWzh

RexWzh Oct 16, 2022

Author Member

[deps]
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Expand Down
15 changes: 12 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ Module that can create QR codes as data or images using `qrcode` or `exportqrcod
```@docs
qrcode
exportqrcode
getversion
getmode
```

## styled QR codes

Plot in REPL.

```@docs
unicodeplot
unicodeplotbychar
```

## Encoding modes
There are three several encoding mode currently supported.
There are five several encoding mode currently supported.

```@docs
Mode
Numeric
Alphanumeric
Byte
Kanji
UTF8
```

## Error Correction
Expand Down
19 changes: 8 additions & 11 deletions src/errorcorrection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ end

"""
Values of log₂1, log₂2, ..., log₂255 in GF(256).
It is a table of `Int` instead of `UInt8` to avoid integers overflow.
"""
const antipowtable = let
table = Vector{Int}(undef, 255)
table = Vector{UInt8}(undef, 255)
table[powtable] .= 0:254
table
end
Expand All @@ -59,18 +57,17 @@ gflog2(n::Integer) = antipowtable[n]
"""
gfinv(a::Integer)
"""
gfinv(a::Integer) = gfpow2(-gflog2(a))
gfinv(a::Integer) = gfpow2(0xff-gflog2(a))

"""
Multiplication table of non-zero elements in GF(256).
"""
const multtable = [iszero(i * j) ? 0x0 : gfpow2(gflog2(i) + gflog2(j)) for i in 0:255, j in 0:255]

const multtable = [iszero(i * j) ? 0x0 : gfpow2(Int(gflog2(i)) + gflog2(j)) for i in 0:255, j in 0:255]

"""
Division table of non-zero elements in GF(256).
"""
const divtable = [iszero(i) ? 0x0 : gfpow2(gflog2(i) - gflog2(j)) for i in 0:255, j in 1:255]
const divtable = [iszero(i) ? 0x0 : gfpow2(Int(gflog2(i)) - gflog2(j)) for i in 0:255, j in 1:255]

"""
mult(a::Integer, b::Integer)
Expand Down Expand Up @@ -176,17 +173,17 @@ Increase the degree of `p` by `n`.
<<(p::Poly{T}, n::Int) where T = Poly{T}(vcat(zeros(T, n), p.coeff))

function +(a::Poly{T}, b::Poly{T}) where T
l = max(length(a), length(b))
return Poly{T}([xor(get(a.coeff, i, zero(T)), get(b.coeff, i, zero(T))) for i in 1:l])
l, o = max(length(a), length(b)), zero(T)
return Poly{T}([xor(get(a.coeff, i, o), get(b.coeff, i, o)) for i in 1:l])
end

"""
*(p, q)
Multiply two polynomials or a polynomial with a scalar.
"""
*(a::T, p::Poly{T}) where T = Poly{T}(mult.(a, p.coeff))
*(p::Poly{T}, a::T) where T = Poly{T}(mult.(a, p.coeff))
*(a::Integer, p::Poly{T}) where T = Poly{T}(mult.(a, p.coeff))
*(p::Poly{T}, a::Integer) where T = Poly{T}(mult.(a, p.coeff))
function *(a::Poly{T}, b::Poly{T}) where T
prodpoly = Poly(zeros(T, length(a) + length(b) - 1))
for (i, c1) in enumerate(a.coeff), (j, c2) in enumerate(b.coeff)
Expand Down

1 comment on commit 3f34546

@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/70323

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 v1.2.1 -m "<description of version>" 3f3454665b1302ad51cc563e7ab713729cf0b55d
git push origin v1.2.1

Please sign in to comment.