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
12 {-# LANGUAGE Strict #-}
14 module Gargantext.Core.Methods.Distances
18 import Data.Array.Accelerate (Matrix)
20 import GHC.Generics (Generic)
21 import Gargantext.Core.Methods.Distances.Accelerate.Conditional (measureConditional)
22 import Gargantext.Core.Methods.Distances.Accelerate.Distributional (logDistributional)
23 import Gargantext.Prelude (Ord, Eq, Int, Double, Show)
24 import Prelude (Enum, Bounded, minBound, maxBound)
25 import Test.QuickCheck (elements)
26 import Test.QuickCheck.Arbitrary
28 ------------------------------------------------------------------------
29 data Distance = Conditional | Distributional
32 measure :: Distance -> Matrix Int -> Matrix Double
33 measure Conditional x = measureConditional x
34 measure Distributional x = y
36 y = logDistributional x
38 ------------------------------------------------------------------------
39 withMetric :: GraphMetric -> Distance
40 withMetric Order1 = Conditional
41 withMetric Order2 = Distributional
43 ------------------------------------------------------------------------
44 data GraphMetric = Order1 | Order2
45 deriving (Generic, Eq, Ord, Enum, Bounded, Show)
47 instance FromJSON GraphMetric
48 instance ToJSON GraphMetric
49 instance ToSchema GraphMetric
50 instance Arbitrary GraphMetric where
51 arbitrary = elements [ minBound .. maxBound ]
53 ------------------------------------------------------------------------