Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TensorFSTs.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAST
FST
TensorFSTs.jl
Commits
55bb9b35
Unverified
Commit
55bb9b35
authored
2 years ago
by
Lucas Ondel Yang
Browse files
Options
Downloads
Patches
Plain Diff
change cumsum -> sum
parent
975fbbf5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ops.jl
+3
-3
3 additions, 3 deletions
src/ops.jl
test/runtests.jl
+12
-12
12 additions, 12 deletions
test/runtests.jl
with
15 additions
and
15 deletions
src/ops.jl
+
3
−
3
View file @
55bb9b35
# SPDX-License-Identifier: CECILL-2.1
# SPDX-License-Identifier: CECILL-2.1
"""
"""
Base.cumsum(A[; n = nstates(A)])
Base.cumsum(A[;
init = initstates(A),
n = nstates(A)])
Accumulate the weight of all the paths of length less or equal to
Accumulate the weight of all the paths of length less or equal to
`n`.
`n`.
"""
"""
function
Base.
cum
sum
(
A
::
AbstractFSA
;
v₀
=
α
(
A
),
n
=
nstates
(
A
))
function
Base.sum
(
A
::
AbstractFSA
;
init
=
α
(
A
),
n
=
nstates
(
A
))
v
=
v₀
v
=
init
σ
=
dot
(
v
,
ω
(
A
))
+
ρ
(
A
)
σ
=
dot
(
v
,
ω
(
A
))
+
ρ
(
A
)
for
i
in
1
:
n
for
i
in
1
:
n
v
=
T
(
A
)
'
*
v
v
=
T
(
A
)
'
*
v
...
...
This diff is collapsed.
Click to expand it.
test/runtests.jl
+
12
−
12
View file @
55bb9b35
...
@@ -60,15 +60,15 @@ end
...
@@ -60,15 +60,15 @@ end
# union
# union
B12
=
convert
((
w
,
l
)
->
f
(
L
,
w
,
l
),
union
(
A1
,
A2
))
B12
=
convert
((
w
,
l
)
->
f
(
L
,
w
,
l
),
union
(
A1
,
A2
))
cs_B12
=
cum
sum
(
B12
)
cs_B12
=
sum
(
B12
)
cs_B1_B2
=
cum
sum
(
B1
)
+
cum
sum
(
B2
)
cs_B1_B2
=
sum
(
B1
)
+
sum
(
B2
)
@test
cs_B12
.
tval
[
1
]
≈
cs_B1_B2
.
tval
[
1
]
@test
cs_B12
.
tval
[
1
]
≈
cs_B1_B2
.
tval
[
1
]
@test
cs_B12
.
tval
[
2
]
==
cs_B1_B2
.
tval
[
2
]
@test
cs_B12
.
tval
[
2
]
==
cs_B1_B2
.
tval
[
2
]
# concatenation
# concatenation
B12
=
convert
((
w
,
l
)
->
f
(
L
,
w
,
l
),
cat
(
A1
,
A2
))
B12
=
convert
((
w
,
l
)
->
f
(
L
,
w
,
l
),
cat
(
A1
,
A2
))
cs_B12
=
cum
sum
(
B12
)
cs_B12
=
sum
(
B12
)
cs_B1_B2
=
cum
sum
(
B2
)
*
cum
sum
(
B1
)
cs_B1_B2
=
sum
(
B2
)
*
sum
(
B1
)
@test
cs_B12
.
tval
[
1
]
≈
cs_B1_B2
.
tval
[
1
]
@test
cs_B12
.
tval
[
1
]
≈
cs_B1_B2
.
tval
[
1
]
@test
cs_B12
.
tval
[
2
]
==
cs_B1_B2
.
tval
[
2
]
@test
cs_B12
.
tval
[
2
]
==
cs_B1_B2
.
tval
[
2
]
...
@@ -82,10 +82,10 @@ end
...
@@ -82,10 +82,10 @@ end
B2_n3
=
B2
∪
cat
(
B2
,
B2
)
∪
cat
(
B2
,
B2
,
B2
)
∪
Bϵ
B2_n3
=
B2
∪
cat
(
B2
,
B2
)
∪
cat
(
B2
,
B2
,
B2
)
∪
Bϵ
cB2p
=
closure
(
B2
;
plus
=
true
)
cB2p
=
closure
(
B2
;
plus
=
true
)
cB2
=
closure
(
B2
;
plus
=
false
)
cB2
=
closure
(
B2
;
plus
=
false
)
cs_B2p_n3
=
cum
sum
(
B2p_n3
;
n
=
n
)
cs_B2p_n3
=
sum
(
B2p_n3
;
n
=
n
)
cs_B2_n3
=
cum
sum
(
B2_n3
;
n
=
n
)
cs_B2_n3
=
sum
(
B2_n3
;
n
=
n
)
cs_cB2p
=
cum
sum
(
cB2p
;
n
=
n
)
cs_cB2p
=
sum
(
cB2p
;
n
=
n
)
cs_cB2
=
cum
sum
(
cB2
;
n
=
n
)
cs_cB2
=
sum
(
cB2
;
n
=
n
)
@test
cs_cB2p
.
tval
[
1
]
≈
cs_B2p_n3
.
tval
[
1
]
@test
cs_cB2p
.
tval
[
1
]
≈
cs_B2p_n3
.
tval
[
1
]
@test
cs_cB2p
.
tval
[
2
]
==
cs_B2p_n3
.
tval
[
2
]
@test
cs_cB2p
.
tval
[
2
]
==
cs_B2p_n3
.
tval
[
2
]
@test
cs_cB2
.
tval
[
1
]
≈
cs_B2_n3
.
tval
[
1
]
@test
cs_cB2
.
tval
[
1
]
≈
cs_B2_n3
.
tval
[
1
]
...
@@ -93,13 +93,13 @@ end
...
@@ -93,13 +93,13 @@ end
# reverse
# reverse
rB2
=
convert
((
w
,
l
)
->
f
(
L
,
w
,
l
),
A2
|>
reverse
)
rB2
=
convert
((
w
,
l
)
->
f
(
L
,
w
,
l
),
A2
|>
reverse
)
s1
=
val
(
cum
sum
(
B2
)
.
tval
[
2
])
s1
=
val
(
sum
(
B2
)
.
tval
[
2
])
s2
=
Set
((
StringMonoid
∘
reverse
∘
val
)
.
((
val
∘
cum
sum
)(
rB2
)[
2
]))
s2
=
Set
((
StringMonoid
∘
reverse
∘
val
)
.
((
val
∘
sum
)(
rB2
)[
2
]))
@test
s1
==
s2
@test
s1
==
s2
# renorm
# renorm
@test
Base
.
isapprox
(
val
(
cum
sum
(
A1
|>
renorm
;
n
=
100
)),
val
(
one
(
K
)),
atol
=
1e-6
)
@test
Base
.
isapprox
(
val
(
sum
(
A1
|>
renorm
;
n
=
100
)),
val
(
one
(
K
)),
atol
=
1e-6
)
@test
Base
.
isapprox
(
val
(
cum
sum
(
A2
|>
renorm
;
n
=
100
)),
val
(
one
(
K
)),
atol
=
1e-6
)
@test
Base
.
isapprox
(
val
(
sum
(
A2
|>
renorm
;
n
=
100
)),
val
(
one
(
K
)),
atol
=
1e-6
)
end
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment