(*******************************************************************
This file was generated automatically by the Mathematica front end.
It contains Initialization cells from a Notebook file, which
typically will have the same name as this file except ending in
".nb" instead of ".m".

This file is intended to be loaded into the Mathematica kernel using
the package loading commands Get or Needs.  Doing so is equivalent
to using the Evaluate Initialization Cells menu command in the front
end.

DO NOT EDIT THIS FILE.  This entire file is regenerated
automatically each time the parent Notebook file is saved in the
Mathematica front end.  Any changes you make to this file will be
overwritten.
***********************************************************************)

BeginPackage["SingularValueDecompositionUnstandard`",{"LinearAlgebra`MatrixManipulation`",
    "System`","Global`"}]

(*Copyright \[Copyright] Frank Hespeler 2008*)



SingularValueDecompositionUnstandard::usage=
  "variant of singular value decomposition acording to Sims (2000). From the original singular value decomposition is only chosen the square diagonal matrix in the middle, containing the nonzero singular values, and the according submatrices of the outer unitary matrices."

Begin["`Private`"]
SingularValueDecompositionUnstandard[matrix_,
    tol_:100*$MachineEpsilon]:=({test1,test2,test3}=
      SingularValueDecomposition[matrix,Tolerance\[Rule]tol];
    counter1=Total[
        Table[If[test2[[i,i]]\[NotEqual]0,1,0],{i,1,
            Min[Dimensions[test2]]}]];{test1,test2,test3}=
      If[counter1\[NotEqual]0,{SubMatrix[
            test1,{1,1},{Length[test1],counter1}],
          SubMatrix[test2,{1,1},{counter1,counter1}],
          SubMatrix[
            ConjugateTranspose[test3],{1,1},{counter1,
              Length[ConjugateTranspose[test3]]}]},
        SingularValueDecomposition[matrix]];{test1,test2,test3})
End[]
EndPackage[]