Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
8d237e3c
Unverified
Commit
8d237e3c
authored
May 30, 2018
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mat2cooc
parent
4a4ade7d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
Index.hs
src/Gargantext/Viz/Graph/Index.hs
+10
-10
No files found.
src/Gargantext/Viz/Graph/Index.hs
View file @
8d237e3c
...
...
@@ -27,7 +27,8 @@ module Gargantext.Viz.Graph.Index
where
import
qualified
Data.Array.Accelerate
as
A
import
qualified
Data.Array.Accelerate.IO.Data.Vector.Unboxed
as
AU
import
qualified
Data.Array.Accelerate.Interpreter
as
A
import
Data.Array.Accelerate
(
Matrix
,
Elt
,
Shape
,
(
:.
)(
..
),
Z
(
..
))
import
qualified
Data.Vector.Unboxed
as
DVU
import
Data.List
(
concat
)
...
...
@@ -69,21 +70,20 @@ map'' m = cooc2mat toI m
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
cooc2mat
::
Ord
t
=>
Map
t
Index
->
Map
(
t
,
t
)
Int
->
A
.
Matrix
Int
cooc2mat
ti
m
=
A
.
fromFunction
shape
(
\
(
A
.
Z
A
.:.
x
A
.
:.
y
)
->
lookup'
x
y
)
cooc2mat
::
Ord
t
=>
Map
t
Index
->
Map
(
t
,
t
)
Int
->
Matrix
Int
cooc2mat
ti
m
=
A
.
fromFunction
shape
(
\
(
Z
:.
x
:.
y
)
->
lookup'
x
y
)
where
shape
=
(
A
.
Z
A
.:.
n
A
.:.
n
)
n
=
M
.
size
ti
lookup'
x
y
=
maybe
0
identity
(
M
.
lookup
(
x
,
y
)
(
toIndex
ti
m
))
mat2cooc
::
A
.
Matrix
Double
->
Map
(
Index
,
Index
)
Double
mat2cooc
m
=
M
.
fromList
$
concat
-- [((Int,Int), Double)]
$
map
(
\
(
x
,
xs
)
->
map
(
\
(
y
,
ys
)
->
((
x
,
y
),
ys
))
xs
)
-- [[((Int,Int), Double)]]
$
zip
([
1
..
]
::
[
Int
])
-- [(Int, [(Int, Double)]]
$
map
(
zip
([
1
..
]
::
[
Int
]))
-- [[(Int, Double)]]
$
splitEvery
n
(
A
.
toList
m
)
-- [[Double]]
-- TODO rename mat2map
mat2cooc
::
(
Elt
a
,
Shape
(
Z
:.
Index
))
=>
A
.
Array
(
Z
:.
Index
:.
Index
)
a
->
Map
(
Index
,
Index
)
a
mat2cooc
m
=
M
.
fromList
.
map
f
.
A
.
toList
.
A
.
run
.
A
.
indexed
$
A
.
use
m
where
A
.
Z
A
.:.
_
A
.:.
n
=
A
.
arrayShape
m
Z
:.
_
:.
n
=
A
.
arrayShape
m
f
((
Z
:.
i
:.
j
),
x
)
=
((
i
,
j
),
x
)
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment