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
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
f455b5b4
Commit
f455b5b4
authored
Oct 28, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Distributional (WIP)
parent
e510b73c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
5 deletions
+31
-5
Distributional.hs
...ntext/Core/Methods/Distances/Accelerate/Distributional.hs
+19
-3
Utils.hs
src/Gargantext/Core/Methods/Matrix/Accelerate/Utils.hs
+12
-2
No files found.
src/Gargantext/Core/Methods/Distances/Accelerate/Distributional.hs
View file @
f455b5b4
...
@@ -54,10 +54,11 @@ import qualified Gargantext.Prelude as P
...
@@ -54,10 +54,11 @@ import qualified Gargantext.Prelude as P
-- * Distributional Distance
-- * Distributional Distance
distributional''
::
(
P
.
Num
(
Exp
a
)
distributional''
::
(
P
.
Num
(
Exp
a
)
,
P
.
Fractional
(
Exp
a
)
,
P
.
Fractional
(
Exp
a
)
,
Elt
a
,
P
.
Ord
(
Exp
a
)
,
Ord
a
)
)
=>
Matrix
a
->
Matrix
a
=>
Matrix
a
->
Matrix
a
distributional''
m'
=
run
$
mi_d_mi
distributional''
m'
=
run
mi_d_mi
where
where
m
=
use
m'
m
=
use
m'
n
=
dim
m'
n
=
dim
m'
...
@@ -68,11 +69,26 @@ distributional'' m' = run $ mi_d_mi
...
@@ -68,11 +69,26 @@ distributional'' m' = run $ mi_d_mi
d_m_o
=
(
#*#
)
d_m
(
matrixOne
n
)
d_m_o
=
(
#*#
)
d_m
(
matrixOne
n
)
mi
=
(
.*
)
((
./
)
m
o_d_m
)
((
./
)
m
o_d_m
)
mi
=
(
.*
)
((
./
)
m
o_d_m
)
((
./
)
m
d_m_o
)
d_mi
=
(
.*
)
(
matrixIdentity
n
)
mi
d_mi
=
(
.*
)
(
matrixIdentity
n
)
mi
mi_d_mi
=
(
.-
)
mi
d_mi
mi_d_mi
=
(
.-
)
mi
d_mi
-- WIP (specs describe iteration on vectors, using full matrix version here)
d_mi_d_mi
=
(
.*
)
(
matrixIdentity
n
)
mi_d_mi
min_mi_mj
=
zipWith
min
d_mi_d_mi
d_mj_d_mj
where
-- not sure about transpose here
-- maybe backpermute j to i cells ?
d_mj_d_mj
=
transpose
d_mi_d_mi
sum_min_mi_mj
=
matSumCol
n
min_mi_mj
sum_mi
=
matSumCol
n
d_mi_d_mi
result
=
zipWith
(
/
)
sum_min_mi_mj
sum_mi
...
...
src/Gargantext/Core/Methods/Matrix/Accelerate/Utils.hs
View file @
f455b5b4
...
@@ -64,6 +64,16 @@ import Data.Array.Accelerate.LinearAlgebra hiding (Matrix, transpose, Vector)
...
@@ -64,6 +64,16 @@ import Data.Array.Accelerate.LinearAlgebra hiding (Matrix, transpose, Vector)
->
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
->
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
(
.*
)
=
zipWith
(
*
)
(
.*
)
=
zipWith
(
*
)
(
.**
)
::
(
Shape
ix
,
Slice
ix
,
Elt
a
,
P
.
Num
(
Exp
a
)
)
=>
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
->
Acc
(
Array
((
ix
:.
Int
)
:.
Int
)
a
)
(
.**
)
m
=
(
.*
)
m
m
(
./
)
::
(
Shape
ix
(
./
)
::
(
Shape
ix
,
Slice
ix
,
Slice
ix
,
Elt
a
,
Elt
a
...
@@ -179,10 +189,10 @@ dim m = n
...
@@ -179,10 +189,10 @@ dim m = n
-- [ 12.0, 15.0, 18.0,
-- [ 12.0, 15.0, 18.0,
-- 12.0, 15.0, 18.0,
-- 12.0, 15.0, 18.0,
-- 12.0, 15.0, 18.0]
-- 12.0, 15.0, 18.0]
matSumCol
::
Dim
->
Acc
(
Matrix
Double
)
->
Acc
(
Matrix
Double
)
matSumCol
::
(
Elt
a
,
P
.
Num
(
Exp
a
))
=>
Dim
->
Acc
(
Matrix
a
)
->
Acc
(
Matrix
a
)
matSumCol
r
mat
=
replicate
(
constant
(
Z
:.
(
r
::
Int
)
:.
All
))
$
sum
$
transpose
mat
matSumCol
r
mat
=
replicate
(
constant
(
Z
:.
(
r
::
Int
)
:.
All
))
$
sum
$
transpose
mat
matSumCol'
::
Matrix
Double
->
Matrix
Double
matSumCol'
::
(
Elt
a
,
P
.
Num
(
Exp
a
))
=>
Matrix
a
->
Matrix
a
matSumCol'
m
=
run
$
matSumCol
n
m'
matSumCol'
m
=
run
$
matSumCol
n
m'
where
where
n
=
dim
m
n
=
dim
m
...
...
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