anchor.diff:      /// computes the row specific sample covariance matrix of a data matrix 
       let rowSampleCovarianceMatrixOf (dataMatrix:Matrix<float>) =
           columnCovarianceMatrixOf (dataMatrix.Transpose.NumRows-1) dataMatrix.Transpose
  -
       //----------------------------------------------------------------------------
  -
   end
  -
   [<AutoOpen>]
   module MatrixExtension =
   
  
positive.code: 
      // Accessors
      let get (a:matrix) i j   = MG.get a i j
      let set (a:matrix) i j x = MG.set a i j x
          
      // Creation
      let init  m n f = DS.initDenseMatrixDS  m n f |> MS.dense 
      let ofList    xss   = DS.listDenseMatrixDS    xss |> MS.dense
      let ofSeq     xss   = DS.seqDenseMatrixDS    xss |> MS.dense
      let diag  (v:vector)   = MG.diag v 
      let initDiagonal  (v:vector)   = MG.diag v 
      let constDiag  n x : matrix  = MG.constDiag n x 
      let create  m n x  = DS.constDenseMatrixDS  m n x |> MS.dense
      let ofScalar x     = DS.scalarDenseMatrixDS x |> MS.dense
  
      let ofArray2D arr : matrix = MG.ofArray2D arr
      let toArray2D (m : matrix) = MG.toArray2D m
  
      let getDiagN  (a:matrix) n = MG.getDiagN a n
      let getDiag  (a:matrix) = MG.getDiag a
  
      // Operators
      let add (a:matrix) (b:matrix) = MS.addM   a b
      let sub (a:matrix) (b:matrix) = MS.subM   a b
      let mul (a:matrix) (b:matrix) = MS.mulM   a b
      let mulV (a:matrix) (b:vector) = MS.mulMV   a b
      let mulRV (a:rowvec) (b:matrix) = MS.mulRVM   a b
      let cptMul (a:matrix) (b:matrix) = MS.cptMulM   a b
      let cptMax (a:matrix) (b:matrix) = MS.cptMaxM a b
      let cptMin (a:matrix) (b:matrix) = MS.cptMinM a b
      let scale a (b:matrix) = MS.scaleM   a b
      let neg (a:matrix)  = MS.negM a
      let trace (a:matrix)  = MS.traceM a
      let transpose  (a:matrix) = MG.transpose a
      let forall f (a:matrix) = MG.forall f a
      let exists  f (a:matrix) = MG.exists f a
      let foralli f (a:matrix) = MG.foralli f a
      let existsi  f (a:matrix) = MG.existsi f a
      let map  f (a:matrix) = MG.map f a
      let copy  (a:matrix) = MG.copy a
      let mapi  f (a:matrix) : matrix = MG.mapi f a
      let fold  f z (a:matrix) = MG.fold f z a
      let foldi  f z (a:matrix) = MG.foldi f z a
  
      let toDense (a:matrix) = MG.toDense a 
      let initDense i j a : matrix = MG.initDense i j a 
      let initSparse i j a : matrix = MG.initSparse i j a 
      let nonzero_entries (a:matrix) = MG.nonzero_entries a 
  
      let zero m n  = DS.zeroDenseMatrixDS m n |> MS.dense
      let identity m  : matrix = MG.identity m      
      let ones m n  = create m n 1.0
      ///Returns row of index i of matrix a    
      let getRow (a:matrix) i      = MG.getRow a i
      ///Replaces row of index j of matrix a with values of vector v, if vector length matches rowsize
      let setRow (a:Matrix<_>) j (v:Vector<_>) = MG.setRow a j v
      ///Returns col of index j of matrix a
      let getCol (a:matrix) j      = MG.getCol a j
      ///Replaces column of index i of matrix a with values of vector v, if vector length matches columnsize
      let setCol (a:Matrix<_>) i (v:Vector<_>) = MG.setCol a i v
      let getCols (a:matrix) i1 i2    = MG.getCols a i1 i2
      let getRows (a:matrix) j1 j2    = MG.getRows a j1 j2
      let getRegion (a:matrix) i1 j1 i2 j2    = MG.getRegion a i1 j1 i2 j2
  
      let rowRange (a:Matrix<_>) = (0,a.NumRows - 1)
      let colRange (a:Matrix<_>) = (0,a.NumCols - 1)
      let wholeRegion a = (colRange a, rowRange a)
          
      let foldByRow f (z:Vector<'T>) (a:matrix) = 
          colRange a |> GU.foldR (fun z j -> MS.mapiV (fun i z -> f z (get a i j)) z) z
      let foldByCol f (z:RowVector<'T>) (a:matrix) = 
          rowRange a |> GU.foldR (fun z i -> MS.mapiRV (fun j z -> f z (get a i j)) z) z
  
      let foldRow f (z:'T) (a:matrix) i = 
          colRange a |> GU.foldR (fun (z:'T) j -> f z (get a i j)) z
      let foldCol f (z:'T) (a:matrix) j = 
          rowRange a |> GU.foldR (fun (z:'T) i -> f z (get a i j)) z
  
      let sum (a:matrix)  = MS.sumM a
      let prod (a:matrix)  = MS.prodM a
      let norm  (a:matrix) = MS.normM  a
      let dot (a:matrix) b = MS.dotM a b
  
      let cptPow  a y = map (fun x -> x ** y) a
          
      // Functions that only make sense on this type
      let randomize v = map (fun vij -> MRandom.float vij) v      (* res_ij = random [0,vij] values *)
  
      let ofRowVector x : matrix = MS.rowvecM x
      let ofVector    x : matrix = MS.vectorM x
      let toVector    x : vector = MS.toVectorM x
      let toRowVector x : rowvec = MS.toRowVectorM x
      let toScalar    x : float  = MS.toScalarM x
  
      let inplaceAdd  (a:matrix) b = MS.inplaceAddM a b
      let inplaceSub  (a:matrix) b = MS.inplaceSubM a b
  
      // Mutation
      let inplace_assign  f (a:matrix) = MG.inplace_assign f a
      let inplace_mapi  f (a:matrix) = MG.inplace_mapi f a
      let inplace_cptMul (a:matrix) b = MS.inplaceCptMulM a b
      let inplace_scale  a (b:matrix) = MS.inplaceScaleM a b
  
      let inplace_add  a b = inplaceAdd a b
      let inplace_sub  a b = inplaceSub a b
      let of_rowvec x = ofRowVector x
  
negative.code: 
          // Accessors
          let get (a:Matrix<_>) i j   = a.[i,j]
          let set (a:Matrix<_>) i j x = a.[i,j] <- x              
          // Creation
          let ofList xss = MS.listM  xss
          let ofSeq xss  = MS.seqM  xss
          let init m n f = MS.initM  m n f
          let ofArray2D (arr: 'T[,])  : Matrix<'T> = MS.arrayM arr
          let toArray2D (m:Matrix<_>) = Array2D.init m.NumRows m.NumCols (fun i j -> get m i j)
          let initNumeric m n f = MS.initNumericM m n f
          let zero m n = MS.zeroM m n
          let identity m = MS.identityM m
          let create m n x = MS.constM m n x
          let ofScalar x = MS.scalarM x
          let diag v = MS.diagM v
          let initDiagonal v = MS.diagM v
          let constDiag n x = MS.constDiagM n x
            
          // Operators
          /// Performs a element wise addition of matrices a and b (a+b).
          /// Only usable if both matrices have the same dimensions.
          let add a b = MS.addM a b
          /// Performs a element wise substraction of matrices a and b (a-b).
          /// Only usable if both matrices have the same dimensions.
          let sub a b = MS.subM a b
          /// Performs a left sided matrix multiplication of a and b (a*b).
          /// Only usable if both matrices have the same dimensions.
          let mul a b = MS.mulM a b
          /// Performs a matrix multiplication of the 1*n rowvector a and the m*n matrix b (a*b).
          /// Only usable if column number (n) of the vector equals the row number (m) of the matrix.
          let mulRV a b = MS.mulRVM a b
          /// Performs a matrix multiplication m*n matrix a and the m*1 vector b (a*b).
          /// Only usable if column number (n) of the matrix equals the row number (m) of the vector.
          let mulV a b = MS.mulMV a b
          /// Performs a element wise multiplication of matrices a and b (a*b, Hadamard-Product).
          /// Only usable if both matrices have the same dimensions.
          let cptMul a b = MS.cptMulM a b
          /// Performs a element wise comparison of matrices a and b always preserving the greater value.
          /// Only usable if both matrices have the same dimensions.
          let cptMax a b = MS.cptMaxM a b
          /// Performs a element wise comparison of matrices a and b always preserving the smaller value.
          /// Only usable if both matrices have the same dimensions.
          let cptMin a b = MS.cptMinM a b
          /// Builds a new matrix where the elements are the result of multiplying every element of the given matrix with the given value
          let scale a b = MS.scaleM a b
          /// Performs a dot product of matrices a and b.
          /// Only usable if both matrices have the same dimensions.
          let dot a b = MS.dotM a b
          /// Scales matrix a by element wise mulitplication with minus 1.
          let neg a = MS.negM a        
          /// Computes the trace of matrix a by summing elements of the diagonal.
          /// Only usable if matrices a is a square matrix (m*m).
          let trace a = MS.traceM a
          /// Computes the sum all elements matrix elements.
          let sum a = MS.sumM a
          /// Computes the product of all matrix elements.
          let prod a = MS.prodM a
          ///
          let norm a = MS.normM a
          /// Returns the transpose of matrix a 
          let transpose a = MS.transM a
          /// Performs a element wise addition of matrices a and b (a+b).
          /// Attention: the output overrides matrix a.
          /// Only usable if both matrices have the same dimensions.        
          let inplaceAdd a b = MS.inplaceAddM a b
          /// Performs a element wise substraction of matrices a and b (a-b).
          /// Attention: the output overrides matrix a.
          /// Only usable if both matrices have the same dimensions.
          let inplaceSub a b = MS.inplaceSubM a b
          /// Iterates the given Matrix row wise and applies function f element wise.
          /// The iteration stops and returns true if an element satisfies the condition or false when the end of
          /// the matrix is reached.
          let exists f a = MS.existsM  f a
          /// Iterates the given Matrix row wise and applies function f element wise.
          /// The iteration stops and returns false if an element fails the condition or true when the end of
          /// the matrix is reached.
          let forall f a = MS.forallM  f a
          /// Iterates the given Matrix row wise and applies function f element wise.
          /// The iteration stops and returns true if an element satisfies the condition or false when the end of
          /// the matrix is reached.
          let existsi f a = MS.existsiM  f a
          /// Iterates the given Matrix row wise and applies function f element wise.
          /// The iteration stops and returns false if an element fails the condition or true when the end of
          /// the matrix is reached.
          let foralli f a = MS.foralliM  f a
          ///
          let map f a = MS.mapM f a
          ///
          let copy a = MS.copyM a
          ///
          let mapi f a = MS.mapiM f a
          ///
          let getDiagN a n = MS.getDiagnM a n
          ///
          let getDiag a = MS.getDiagnM a 0
          ///
          let toDense a = MS.toDenseM a 
          ///
          let initDense i j a = MS.initDenseM i j a 
          ///
          let initSparse i j a = MS.initSparseM i j a 
          ///
          let fold f z a = MS.foldM f z a
          ///
          let foldi f z a = MS.foldiM f z a
          ///  
          let compare a b = MS.compareM LanguagePrimitives.GenericComparer a b
          ///
          let hash a = MS.hashM LanguagePrimitives.GenericEqualityComparer a
          ///Returns row of index i of matrix a
          let getRow a i = MS.getRowM a i
          ///Replaces row of index j of matrix a with values of vector v, if vector length matches rowsize
          let setRow (a:Matrix<_>) j (v:Vector<_>) = MS.setRowM a j v
          ///Returns col of index j of matrix a
          let getCol a j = MS.getColM a j  
          ///Replaces column of index i of matrix a with values of vector v, if vector length matches columnsize
          let setCol (a:Matrix<_>) i (v:Vector<_>) = MS.setColM a i v
          ///
          let getCols a i1 i2 = MS.getColsM a (i1,i1+i2-1)
          ///
          let getRows a j1 j2 = MS.getRowsM a (j1,j1+j2-1)
          ///
          let getRegion a i1 j1 i2 j2 = MS.getRegionM a (i1,i1+i2-1) (j1,j1+j2-1)
          ///    
          let ofRowVector x = MS.rowvecM x
          ///
          let ofVector x = MS.vectorM x
          ///
          let toVector x = MS.toVectorM x
          ///
          let toRowVector x = MS.toRowVectorM x
          ///
          let toScalar x = MS.toScalarM x
              
          let inplace_assign f a    = MS.inplaceAssignM  f a
          let inplace_cptMul a b    = MS.inplaceCptMulM a b
          let inplace_scale a b     = MS.inplaceScaleM a b
          let inplace_mapi f a      = MS.inplace_mapiM f a
          let of_rowvec x           = ofRowVector x
          let of_vector x           = ofVector x
          let to_vector x           = toVector x
  