]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Core/Methods/Distances.hs
[auth] forgot password async endpoint
[gargantext.git] / src / Gargantext / Core / Methods / Distances.hs
1 {-|
2 Module : Gargantext.Graph.Distances
3 Description : Distance management tools
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 {-# LANGUAGE Strict #-}
13
14 module Gargantext.Core.Methods.Distances
15 where
16
17 import Debug.Trace (trace)
18 import Data.Aeson
19 import Data.Array.Accelerate (Matrix)
20 import Data.Swagger
21 import GHC.Generics (Generic)
22 import Gargantext.Core.Methods.Distances.Accelerate.Conditional (measureConditional)
23 import Gargantext.Core.Methods.Distances.Accelerate.Distributional (logDistributional)
24 import Gargantext.Prelude (Ord, Eq, Int, Double, Show, ($), show)
25 import Prelude (Enum, Bounded, minBound, maxBound)
26 import Test.QuickCheck (elements)
27 import Test.QuickCheck.Arbitrary
28
29 ------------------------------------------------------------------------
30 data Distance = Conditional | Distributional
31 deriving (Show, Eq)
32
33 measure :: Distance -> Matrix Int -> Matrix Double
34 measure Conditional x = measureConditional x
35 measure Distributional x = trace (show y) $ y
36 where
37 y = logDistributional x
38
39 ------------------------------------------------------------------------
40 withMetric :: GraphMetric -> Distance
41 withMetric Order1 = Conditional
42 withMetric Order2 = Distributional
43
44 ------------------------------------------------------------------------
45 data GraphMetric = Order1 | Order2
46 deriving (Generic, Eq, Ord, Enum, Bounded, Show)
47
48 instance FromJSON GraphMetric
49 instance ToJSON GraphMetric
50 instance ToSchema GraphMetric
51 instance Arbitrary GraphMetric where
52 arbitrary = elements [ minBound .. maxBound ]
53
54 ------------------------------------------------------------------------
55