Ignore:
Timestamp:
11/05/13 13:44:39 (8 years ago)
Author:
Ivan Raikov
Message:

9ML-toolkit: added SML support libraries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/9ML-toolkit/trunk/sml-lib/nodegraph.sml

    r29994 r29995  
    44signature NODE_GRAPH =
    55sig
    6     type symbol = Symbol.symbol
    7     type nindex = int
    8     type rangemap = (int * int) list
     6    type index = int
     7    type rangemap = {localStart: int, localEnd: int, globalStart: int} list
    98
    10     val nodeGraph : (symbol * SparseMatrix.matrix * rangemap) ->
    11                     (nindex, real, unit) Graph.graph
     9    val nodeGraph : (string * SparseMatrix.matrix * rangemap) ->
     10                    (index, real, unit) Graph.graph
    1211                   
    13     val junctionMatrix : ((nindex, real, unit) Graph.graph) -> SparseMatrix.matrix
     12    val junctionMatrix : ((index, real, unit) Graph.graph) -> SparseMatrix.matrix
    1413
    1514
     
    1918struct
    2019
    21 type symbol   = Symbol.symbol
    2220type index    = int
    2321type rangemap = {localStart: int, localEnd: int, globalStart: int} list
     
    2523exception Index
    2624
    27 fun nodeGraph (S, rangemap) =
     25fun nodeGraph (modelname, S, rangemap) =
    2826    let
    29         val mapIndex m i = case List.find (fn (({localStart,localEnd,globalStart} =>
    30                                                 i >= localStart andalso i < localEnd)) m of
     27        fun mapIndex m i = case List.find (fn {localStart,localEnd,globalStart} =>
     28                                              (i >= localStart andalso i < localEnd)) m of
    3129                               SOME ({localStart,localEnd,globalStart}) => globalStart + (i-localStart)
    3230                             | NONE => raise Index
     
    3533       
    3634        val G as Graph.GRAPH g =
    37             DirectedGraph.graph(Symbol.name modelname,(),N) :
     35            DirectedGraph.graph(modelname,(),N) :
    3836            (index,real,unit) Graph.graph
    3937
     
    4543        val add_edge = #add_edge g
    4644
    47         val _ List.app
    48               (fn (s) =>
    49                   let
    50                       val sl = SparseMatrix.slice (S,1,i)
    51                   in
    52                       SparseMatrix.sliceAppi
    53                           (fn (t,v) => add_edge (mapIndex rangemap s, mapIndex rangemap t,v))
    54                           sl
    55                   end)
    56               idxs
     45        val _ = List.app
     46                    (fn (s) =>
     47                        let
     48                            val sl = SparseMatrix.slice (S,1,s)
     49                        in
     50                            SparseMatrix.sliceAppi
     51                                (fn (t,v) => add_edge (mapIndex rangemap s, mapIndex rangemap t,v))
     52                                sl
     53                        end)
     54                    idxs
    5755
    5856    in
    5957        G
    6058    end
     59
    6160
    6261fun junctionMatrix (Graph.GRAPH g) =
Note: See TracChangeset for help on using the changeset viewer.