anchor.diff:              p <- p + 1 // Skip the first entry since we already handled it above
       
               while (p < x.entries.Count && q < y.entries.Count) do
  -                if (x.entries.[p].index = y.entries.[q].index) then
  -                    let xNew = c  * x.entries.[p].value - s * y.entries.[q].value
  -                    let yNew = s *  x.entries.[p].value + c * y.entries.[q].value
  +                if (fst x.entries.[p] = fst y.entries.[q]) then
  +                    let xNew = c  * snd x.entries.[p] - s * snd y.entries.[q]
  +                    let yNew = s *  snd x.entries.[p] + c * snd y.entries.[q]
                       if (not (xNew = 0.0)) then
  -                        x.entries.[p].value <- xNew
  +                        x.entries.[p] <- (fst x.entries.[p], xNew)
                           p <- p + 1
                       else
                           x.entries.RemoveAt(p)
                       if ( not (yNew = 0.0)) then
  -                        y.entries.[q].value <- yNew
  +                        y.entries.[q] <- (fst y.entries.[q], yNew)
                           q <- q + 1
                       else
                           y.entries.RemoveAt(q)
  -                else if(x.entries.[p].index < y.entries.[q].index) then
  -                    let k = x.entries.[p].index
  -                    let xNew = c * x.entries.[p].value
  -                    let yNew = s * x.entries.[p].value
  -                    x.entries.[p].value <- xNew
  +                else if(fst x.entries.[p] < fst y.entries.[q]) then
  +                    let k = fst x.entries.[p]
  +                    let xNew = c * snd x.entries.[p]
  +                    let yNew = s * snd x.entries.[p]
  +                    x.entries.[p] <- (fst x.entries.[p] , xNew)
                       p <-p + 1
  -                    y.entries.Insert(q, SparseEntry(k, yNew))
  +                    y.entries.Insert(q,(k, yNew))
                       q <- q + 1
                   else
  -                    let k = y.entries.[q].index
  -                    let xNew= -s * y.entries.[q].value
  -                    let yNew= c * y.entries.[q].value
  -                    x.entries.Insert(p,SparseEntry(k, xNew))
  +                    let k = fst y.entries.[q]
  +                    let xNew= -s * snd y.entries.[q]
  +                    let yNew= c * snd y.entries.[q]
  +                    x.entries.Insert(p,(k, xNew))
                       p <- p + 1
  -                    y.entries.[q].value <- yNew
  +                    y.entries.[q] <- (fst y.entries.[q], yNew)
                       q <- q + 1
               if(p < x.entries.Count) then
                   while(p < x.entries.Count) do
  -                    let k = x.entries.[p].index
  -                    let xNew = c * x.entries.[p].value
  -                    let yNew = s * x.entries.[p].value
  -                    x.entries.[p].value <- xNew
  +                    let k = fst x.entries.[p]
  +                    let xNew = c * snd x.entries.[p]
  +                    let yNew = s * snd x.entries.[p]
  +                    x.entries.[p] <- (fst x.entries.[p], xNew)
                       p <- p + 1
  -                    y.entries.Insert(q,SparseEntry(k, yNew))
  +                    y.entries.Insert(q,(k, yNew))
                       q <- q + 1      
               else if(q < y.entries.Count) then
                   while(q < y.entries.Count) do
  -                    let k = y.entries.[q].index
  -                    let xNew = -s * y.entries.[q].value
  -                    let yNew = c * y.entries.[q].value
  -                    x.entries.Insert(p,SparseEntry(k, xNew))
  +                    let k = fst y.entries.[q]
  +                    let xNew = -s * snd y.entries.[q]
  +                    let yNew = c * snd y.entries.[q]
  +                    x.entries.Insert(p,(k, xNew))
                       p <- p + 1
  -                    y.entries.[q].value <- yNew
  +                    y.entries.[q] <- (fst y.entries.[q], yNew)
                       q <- q + 1
   
               encode(c, s)
  
positive.code:         let RSeq = seq{ for row in R do
                              x <- x+1
                              for entry in row.entries do
                                  yield(x, entry.index, float entry.value)}
  
          let ROut = Matrix.initSparse m n RSeq
  
  
negative.code:             for k=i to m-1 do
                  A.[l,k] <- A.[l,k] - 2.0 * v.[l-i] * v'A.[k-i]
          v                                                              // Return reflection vector.
  
      type SparseVector() = 
          member val entries = new ResizeArray<(int*float)>() with get,set
          member m.Front
              with get() = m.entries.[0]
              and set(value) = m.entries.[0] <- value
          member m.Add (entry:(int*float)) =
              m.entries.Add(entry)
          member m.IsEmpty =
              m.entries.Count <= 0
          member m.Swap (other:SparseVector) =
              let temp = new ResizeArray<(int*float)> (other.entries)
              other.entries <- new ResizeArray<(int*float)>(m.entries)
              m.entries <- new ResizeArray<(int*float)>(temp)
          member m.PopFront =
              let value = m.entries.[0]
              m.entries.RemoveAt(0)
  