anchor.diff:                              if ((_startInput = _endInput && _startGrammar = _endGrammar)
                                  || input.[_startInput,_endInput].Overlaps grammar.grammar.[_startGrammar, _endGrammar])
                               then 
  -                                 //intersectionResult.[backStateRemap.[(_startInput,_startGrammar)] ,backStateRemap.[(_endInput,_endGrammar)]] <- 1.0
                                    toUpdate.Add(backStateRemap.[(_startInput,_startGrammar)], backStateRemap.[(_endInput,_endGrammar)], 1.0)
  -            
  -//        for _startInput in 0..inputSize-1 do
  -//            for _endInput in 0..inputSize-1 do
  -//                if input.[_startInput, _endInput].Count <> 0 || _startInput = _endInput
  -//                then 
  -//                    for _startGrammar in 0..grammarSize-1 do
  -//                        for _endGrammar in 0..grammarSize-1 do
  -//                            if (_startInput = _endInput && _startGrammar = _endGrammar)
  -//                               || input.[_startInput, _endInput].Overlaps grammar.grammar.[_startGrammar, _endGrammar]
  -//                            then 
  -//                                 intersectionResult.[backStateRemap.[(_startInput,_startGrammar)] ,backStateRemap.[(_endInput,_endGrammar)]] <- 1.0
  -                                 //toUpdate.Add(backStateRemap.[(_startInput,_startGrammar)] ,backStateRemap.[(_endInput,_endGrammar)])
  -        //) |> ignore
  -        //printfn "f1"        
  -        //xxx.Clear()
  -        //printfn "SSS = %A" toUpdate.Count
  -        //for (i,j) in toUpdate do intersectionResult.[i,j] <- 1.0
  -        //intersectionResult <- intersectionResult.PointwiseAbsoluteMaximum xxx :?>_
  -        //printfn "f11"
  -        let cls = closure toUpdate intersectionResult gpuSparseMatrix gpuSparseMatrix1
  +
  +        let upCsr = Storage.SparseCompressedRowMatrixStorage.OfIndexedEnumerable(intersectionResult.RowCount,intersectionResult.RowCount,toUpdate) 
  +        gpuSparseMatrix1.Update (toUpdate.Count, upCsr.Values, upCsr.RowPointers, upCsr.ColumnIndices)    
  +        closure ()
           toUpdate.Clear()
  -       // printfn "s2"
           _go <- false
  -        cls
  +        intersectionResult
           |> Matrix.iteriSkipZeros (fun i j n ->
               let _startInput,_startGrammar = stateRemap.[i] 
               let _endInput,_endGrammar = stateRemap.[j]
  
positive.code:     val startFinal: array<int*HashSet<int>*HashSet<int>>
      new (grm, strtFnl) = {grammar = grm; startFinal = strtFnl}
  
  let closure (toUpdate:ResizeArray<_*_*_>) (atm:Double.SparseMatrix) (gpuSparseMatrix:MySparseMatrix) (gpuSparseMatrix1:MySparseMatrix) =    
      //printfn "closure start"
      let upCsr = Storage.SparseCompressedRowMatrixStorage.OfIndexedEnumerable(atm.RowCount,atm.RowCount,toUpdate) 
      let csr = (atm.Storage :?> Storage.SparseCompressedRowMatrixStorage<_>)    
      //let gpuSparseMatrix = new MySparseMatrix(atm.RowCount, atm.NonZerosCount, csr.Values, csr.RowPointers, csr.ColumnIndices)
      //let gpuSparseMatrix1 = new MySparseMatrix(atm.RowCount, toUpdate.Count, upCsr.Values, upCsr.RowPointers, upCsr.ColumnIndices)
      gpuSparseMatrix1.Update (toUpdate.Count, upCsr.Values, upCsr.RowPointers, upCsr.ColumnIndices)
      //gpuSparseMatrix.Update (atm.NonZerosCount, csr.Values, csr.RowPointers, csr.ColumnIndices)
      let mutable zeros = atm.NonZerosCount
      let mutable res = sparseCudaGeam gpuSparseMatrix gpuSparseMatrix1 atm.RowCount
      let _go = ref true
      while !_go do
          res <- sparseCudaGeam res (sparseCudaGemm res res atm.RowCount) atm.RowCount
          let newZeros = res.Nnz
          _go := not (zeros = newZeros )
          zeros <- newZeros
  
      csr.ColumnIndices <- res.CsrColInd
      res.CsrRow.CopyTo(csr.RowPointers,0)  //csr.col  <- res.CsrRow
      csr.Values <- res.CsrVal
      //printfn "closure end"
      atm
  //    printfn "closure start"
  //    let mutable zeros = atm.NonZerosCount
  //    let mutable res = atm
  //    let _go = ref true
  //    while !_go do
  //        res <- (res.Add (res.Multiply res) :?> Single.SparseMatrix)
  //        let newZeros = res.NonZerosCount
  //        _go := not (zeros = newZeros )
  //        zeros <- newZeros
  //    printfn "closure end"
  //    res
  
  let main (input:HashSet<int> [,]) (grammar:Grammar) =
      let inputSize = Array2D.length1 input
      let grammarSize = Array2D.length1 grammar.grammar    
      //let xxx = Double.SparseMatrix.Create((inputSize * grammarSize), (inputSize * grammarSize), 0.0)
      let mutable intersectionResult = Double.SparseMatrix.Create((inputSize * grammarSize), (inputSize * grammarSize), 0.0)
      let csr = (intersectionResult.Storage :?> Storage.SparseCompressedRowMatrixStorage<_>)    
      let gpuSparseMatrix = new MySparseMatrix(intersectionResult.RowCount, intersectionResult.NonZerosCount, csr.Values, csr.RowPointers, csr.ColumnIndices)
      let gpuSparseMatrix1 = new MySparseMatrix(intersectionResult.RowCount, intersectionResult.NonZerosCount, csr.Values, csr.RowPointers, csr.ColumnIndices)
      let stateRemap,backStateRemap =
          let m = new Dictionary<_,_>()
          let n = new ResizeArray<_>()
  
negative.code:             | Some (n,s,f) when f.Contains _endGrammar -> _go <- input.[_startInput,_endInput].Add n || _go
              | _ -> ()
              )
  
      input
  
  