Commit 4b8b45aa authored by Alexandre Delanoë's avatar Alexandre Delanoë

[OPTIM] worse with list

parent f00fcfaa
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -152,9 +152,9 @@ adjacent (FiniteGraph g) isReflexive =
transition :: KnownNat n
=> AdjacencyMatrix n
-> TransitionMatrix n
transition m = SMatrix.imap (\i j v -> v * (VS.!) s i) m
transition m = SMatrix.imap (\i j v -> v * (List.!!) s i) m
where
s = sumWith Colonne (\s -> 1 / s) m
s = sumWith' Colonne (\s -> 1 / s) m
proxemie :: KnownNat n
......@@ -175,13 +175,13 @@ matconf :: forall n. KnownNat n
matconf False a p = symmetry confmat
where
-- vcount = natToInt @n
degs = sumWith Colonne identity a
sumdeg = VS.sum degs
degs = sumWith' Colonne identity a
sumdeg = List.sum degs
confmat = DMatrix.imap (\ x y v ->
if x < y
then let
prox_y_x_length = v
prox_y_x_infini = ((VS.!) degs x) / sumdeg
prox_y_x_infini = ((List.!!) degs x) / sumdeg
in
(prox_y_x_length - prox_y_x_infini)
/ (prox_y_x_length + prox_y_x_infini)
......@@ -219,15 +219,15 @@ edges_confluence l am tm = -- traceShow ("degs", degs) $
SMatrix.toList matconf'
where
vcount = natToInt @n
degs = sumWith Colonne identity am
sumdeg = VS.sum degs
degs = sumWith' Colonne identity am
sumdeg = List.sum degs
matconf' = SMatrix.imap
(\x y _ ->
if x < y
then
let
deg_x = (VS.!) degs x - 1
deg_y = (VS.!) degs y - 1
deg_x = (List.!!) degs x - 1
deg_y = (List.!!) degs y - 1
tm' = SMatrix.imap (\i j v -> if (i == x && j == y) || ( i == y && j == x)
then 0
......@@ -440,5 +440,17 @@ sumWith dir f m = VS.fromList
where
somme m' = map (sum . SMatrix.toMatrix) m'
sumWith' :: ( Elem a
, Elem t
, KnownNat n
) => Direction -> (t -> a) -> SparseMatrix n n t -> [a]
sumWith' dir f m = map (\v -> f v)
$ case dir of
Colonne -> somme $ SMatrix.getCols m
Ligne -> somme $ SMatrix.getRows m
where
somme m' = map (sum . SMatrix.toMatrix) m'
--------------------------------------------
......@@ -9,6 +9,8 @@ import Data.Text (Text)
import qualified Eigen.Matrix as Matrix
import Graph.BAC.ProxemyOptim
import Graph.FGL
import Graph.Types
import Graph.Tools.Random
import Prelude (String)
import Protolude
import Graph.BAC.ProxemyOptim
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment