/// <summary>Performs the QR factorization.</summary>
    protected override void InternalCompute() 
    {
      int m = matrix.Rows;
      int n = matrix.Columns;
      
#if MANAGED
      int minmn = m < n ? m : n;
      r_ = new ComplexFloatMatrix(matrix); // create a copy
      ComplexFloatVector[] u = new ComplexFloatVector[minmn];
      for (int i = 0; i < minmn; i++) 
      {
        u[i] = Householder.GenerateColumn(r_, i, m - 1, i);
        Householder.UA(u[i], r_, i, m - 1, i + 1, n - 1);
      }
      q_ = ComplexFloatMatrix.CreateIdentity(m);
      for (int i = minmn - 1; i >= 0; i--) 
      {
        Householder.UA(u[i], q_, i, m - 1, i, m - 1);
      }
#else
      qr = ComplexFloatMatrix.ToLinearComplexArray(matrix);
      jpvt = new int[n];
      jpvt[0] = 1;
      Lapack.Geqp3.Compute(m, n, qr, m, jpvt, out tau);
      r_ = new ComplexFloatMatrix(m, n);
      // Populate R

      for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
          if (i <= j) {
            r_.data[j * m + i] = qr[(jpvt[j]-1) * m + i];
          }
          else {
            r_.data[j * m + i] = ComplexFloat.Zero;
          }
        }
      }

      q_ = new ComplexFloatMatrix(m, m);
      for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
          if (j < n)
            q_.data[j * m + i] = qr[j * m + i];
          else
            q_.data[j * m + i] = ComplexFloat.Zero;
        }
      }
      if( m < n ){
        Lapack.Ungqr.Compute(m, m, m, q_.data, m, tau);
      } else{
        Lapack.Ungqr.Compute(m, m, n, q_.data, m, tau);
      }
#endif
      for (int i = 0; i < m; i++) 
      {
        if (q_[i, i] == 0)
          isFullRank = false;
      }
    }
Exemplo n.º 2
0
		public void CtorInitialValues()
		{
			ComplexFloatVector test = new ComplexFloatVector(2, (ComplexFloat)1);

			Assert.AreEqual(test.Length, 2);
			Assert.AreEqual(test[0], (ComplexFloat)1);
			Assert.AreEqual(test[1], (ComplexFloat)1);
		}
Exemplo n.º 3
0
		public void CtorDimensions()
		{
			ComplexFloatVector test = new ComplexFloatVector(2);

			Assert.AreEqual(test.Length, 2);
			Assert.AreEqual(test[0], (ComplexFloat)0);
			Assert.AreEqual(test[1], (ComplexFloat)0);
		}
 public void CurrentException2() 
 {
   ComplexFloatVector test = new ComplexFloatVector(new ComplexFloat[2]{1f,2f});
   IEnumerator enumerator = test.GetEnumerator();
   enumerator.MoveNext();
   enumerator.MoveNext();
   enumerator.MoveNext();
   object value=enumerator.Current;
 }
Exemplo n.º 5
0
		public void CtorArray()
		{
			float[] testvector = new float[2] { 0, 1 };

			ComplexFloatVector test = new ComplexFloatVector(testvector);
			Assert.AreEqual(test.Length, testvector.Length);
			Assert.AreEqual(test[0], (ComplexFloat)testvector[0]);
			Assert.AreEqual(test[1], (ComplexFloat)testvector[1]);
		}
 public void Current()
 {
   ComplexFloatVector test = new ComplexFloatVector(new ComplexFloat[2]{1f,2f});
   IEnumerator enumerator = test.GetEnumerator();
   bool movenextresult;
   
   movenextresult=enumerator.MoveNext();
   Assert.IsTrue(movenextresult);
   Assert.AreEqual(enumerator.Current,test[0]);
   
   movenextresult=enumerator.MoveNext();
   Assert.IsTrue(movenextresult);
   Assert.AreEqual(enumerator.Current,test[1]);
   
   movenextresult=enumerator.MoveNext();
   Assert.IsFalse(movenextresult);
 }
Exemplo n.º 7
0
        private static void drotg(ref float da, ref float db, ref float c, ref float s)
        {
            //     construct givens plane rotation.
            //     jack dongarra, linpack, 3/11/78.
            float roe, scale, r, z, Absda, Absdb, sda, sdb;

            roe   = db;
            Absda = System.Math.Abs(da);
            Absdb = System.Math.Abs(db);
            if (Absda > Absdb)
            {
                roe = da;
            }
            scale = Absda + Absdb;
            if (scale == 0.0)
            {
                c = 1.0f;
                s = 0.0f;
                r = 0.0f;
                z = 0.0f;
            }
            else
            {
                sda = da / scale;
                sdb = db / scale;
                r   = scale * (float)System.Math.Sqrt(sda * sda + sdb * sdb);
                if (roe < 0.0)
                {
                    r = -r;
                }
                c = da / r;
                s = db / r;
                z = 1.0f;
                if (Absda > Absdb)
                {
                    z = s;
                }
                if (Absdb >= Absda && c != 0.0)
                {
                    z = 1.0f / c;
                }
            }
            da = r;
            db = z;
            return;
        }
Exemplo n.º 8
0
        ///<summary>Solves a system on linear equations, AX=B, where A is the factored matrixed.</summary>
        ///<param name="B">RHS side of the system.</param>
        ///<returns>the solution vector, X.</returns>
        ///<exception cref="ArgumentNullException">B is null.</exception>
        ///<exception cref="SingularMatrixException">A is singular.</exception>
        ///<exception cref="ArgumentException">The number of rows of A and the length of B must be the same.</exception>
        public ComplexFloatVector Solve(IROComplexFloatVector B)
        {
            if (B == null)
            {
                throw new System.ArgumentNullException("B cannot be null.");
            }
            Compute();
            if (singular)
            {
                throw new SingularMatrixException();
            }
            else
            {
                if (B.Length != order)
                {
                    throw new System.ArgumentException("The length of B must be the same as the order of the matrix.");
                }
#if MANAGED
                // Copy right hand side with pivoting
                ComplexFloatVector X = Pivot(B);

                // Solve L*Y = B(piv,:)
                for (int k = 0; k < order; k++)
                {
                    for (int i = k + 1; i < order; i++)
                    {
                        X[i] -= X[k] * factor[i][k];
                    }
                }
                // Solve U*X = Y;
                for (int k = order - 1; k >= 0; k--)
                {
                    X[k] /= factor[k][k];
                    for (int i = 0; i < k; i++)
                    {
                        X[i] -= X[k] * factor[i][k];
                    }
                }
                return(X);
#else
                ComplexFloat[] rhs = ComplexFloatMatrix.ToLinearComplexArray(B);
                Lapack.Getrs.Compute(Lapack.Transpose.NoTrans, order, 1, factor, order, pivots, rhs, rhs.Length);
                return(new ComplexFloatVector(rhs));
#endif
            }
        }
Exemplo n.º 9
0
        ///<summary>Compute the P Norm of this <c>ComplexFloatVector</c></summary>
        ///<returns><c>float</c> results from norm.</returns>
        ///<remarks>p &gt; 0, if p &lt; 0, ABS(p) is used. If p = 0, the infinity norm is returned.</remarks>
        public float GetNorm(double p)
        {
            if (p == 0)
            {
                return(GetInfinityNorm());
            }
            if (p < 0)
            {
                p = -p;
            }
            double ret = 0;

            for (int i = 0; i < data.Length; i++)
            {
                ret += System.Math.Pow(ComplexMath.Absolute(data[i]), p);
            }
            return((float)System.Math.Pow(ret, 1 / p));
        }
Exemplo n.º 10
0
        ///<summary>Check if <c>ComplexFloatVector</c> variable is the same as another object</summary>
        ///<param name="obj"><c>obj</c> to compare present <c>ComplexFloatVector</c> to.</param>
        ///<returns>Returns true if the variable is the same as the <c>ComplexFloatVector</c> variable</returns>
        ///<remarks>The <c>obj</c> parameter is converted into a <c>ComplexFloatVector</c> variable before comparing with the current <c>ComplexFloatVector</c>.</remarks>
        public override bool Equals(Object obj)
        {
            ComplexFloatVector vector = obj as ComplexFloatVector;

            if (vector == null)
            {
                return(false);
            }

            if (this.data.Length != vector.data.Length)
            {
                return(false);
            }

            for (int i = 0; i < this.data.Length; ++i)
            {
                if (this.data[i] != vector.data[i])
                {
                    return(false);
                }
            }
            return(true);
        }
 public void SingularTestforStaticSolveMatrix()
 {
   ComplexFloatVector cfv = new ComplexFloatVector(3, 1.0f);
   ComplexFloatMatrix X = ComplexFloatLevinson.Solve(cfv, cfv, ComplexFloatMatrix.CreateIdentity(3));
 }
Exemplo n.º 12
0
        /// <overloads>
        /// Solve a symmetric square Toeplitz system.
        /// </overloads>
        /// <summary>
        /// Solve a symmetric square Toeplitz system with a right-side vector.
        /// </summary>
        /// <param name="T">The left-most column of the Toeplitz matrix.</param>
        /// <param name="Y">The right-side vector of the system.</param>
        /// <returns>The solution vector.</returns>
        /// <exception cref="ArgumentNullException">
        /// <B>T</B> and/or <B>Y</B> are null references
        /// </exception>
        /// <exception cref="RankException">
        /// The length of <B>T</B> does not match the length of <B>Y</B>.
        /// </exception>
        /// <exception cref="SingularMatrixException">
        /// The Toeplitz matrix or one of the the leading sub-matrices is singular.
        /// </exception>
        /// <remarks>
        /// This method solves the linear system <B>AX</B> = <B>Y</B>. Where
        /// <B>T</B> is a symmetric square Toeplitz matrix, <B>X</B> is an unknown
        /// vector and <B>Y</B> is a known vector.
        /// <para>
        /// This static member combines the <b>UDL</b> decomposition and the calculation of the solution into a
        /// single algorithm. When compared to the non-static member it requires minimal data storage
        /// and suffers from no speed penalty.
        /// </para>
        /// </remarks>
        public static ComplexFloatVector Solve(IROComplexFloatVector T, IROComplexFloatVector Y)
        {
            ComplexFloatVector X;

            // check parameters
            if (T == null)
            {
                throw new System.ArgumentNullException("T");
            }
            else if (Y == null)
            {
                throw new System.ArgumentNullException("Y");
            }
            else if (T.Length != Y.Length)
            {
                throw new RankException("The length of T and Y are not equal.");
            }
            else
            {
                // allocate memory
                int N = T.Length;
                X = new ComplexFloatVector(N);            // solution vector
                ComplexFloat e;                           // prediction error

                // setup zero order solution
                e = T[0];
                if (e == ComplexFloat.Zero)
                {
                    throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
                }
                X[0] = Y[0] / T[0];

                if (N > 1)
                {
                    ComplexFloatVector a = new ComplexFloatVector(N - 1); // prediction coefficients
                    ComplexFloatVector Z = new ComplexFloatVector(N - 1); // temporary storage vector
                    ComplexFloat       g;                                 // reflection coefficient
                    ComplexFloat       inner;                             // inner product
                    ComplexFloat       k;
                    int i, j, l;

                    // calculate solution for successive orders
                    for (i = 1; i < N; i++)
                    {
                        // calculate first inner product
                        inner = T[i];
                        for (j = 0, l = i - 1; j < i - 1; j++, l--)
                        {
                            inner += a[j] * T[l];
                        }

                        // update predictor coefficients
                        g = -(inner / e);
                        for (j = 0, l = i - 2; j < i - 1; j++, l--)
                        {
                            Z[j] = a[j] + g * a[l];
                        }

                        // copy vector
                        for (j = 0; j < i - 1; j++)
                        {
                            a[j] = Z[j];
                        }

                        a[i - 1] = g;

                        e *= (ComplexFloat.One - g * g);
                        if (e == ComplexFloat.Zero)
                        {
                            throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
                        }

                        // calculate second inner product
                        inner = Y[i];
                        for (j = 0, l = i; j < i; j++, l--)
                        {
                            inner -= X[j] * T[l];
                        }

                        // update solution vector
                        k = inner / e;
                        for (j = 0, l = i - 1; j < i; j++, l--)
                        {
                            X[j] = X[j] + k * a[l];
                        }
                        X[j] = k;
                    }
                }
            }

            return(X);
        }
Exemplo n.º 13
0
 ///<summary>Subtract a <c>ComplexFloatVector</c> from another <c>ComplexFloatVector</c></summary>
 ///<param name="lhs"><c>ComplexFloatVector</c> to subtract from.</param>
 ///<param name="rhs"><c>ComplexFloatVector</c> to subtract.</param>
 ///<returns><c>ComplexFloatVector</c> with results.</returns>
 public static ComplexFloatVector Subtract(ComplexFloatVector lhs, ComplexFloatVector rhs)
 {
     return(lhs - rhs);
 }
 public void ZeroVectorLengthTestforStaticSolveMatrix()
 {
   ComplexFloatVector LC = new ComplexFloatVector(1);
   LC.RemoveAt(0);
   ComplexFloatMatrix X = ComplexFloatLevinson.Solve(LC, TR10, ComplexFloatMatrix.CreateIdentity(10));
 }
    /// <overloads>
    /// There are two permuations of the constructor, both require a parameter corresponding
    /// to the left-most column of a Toeplitz matrix.
    /// </overloads>
    /// <summary>
    /// Constructor with <c>ComplexFloatVector</c> parameter.
    /// </summary>
    /// <param name="T">The left-most column of the Toeplitz matrix.</param>
    /// <exception cref="ArgumentNullException">
    /// <B>T</B> is a null reference.
    /// </exception>
    /// <exception cref="RankException">
    /// The length of <B>T</B> is zero.
    /// </exception>
    public ComplexFloatSymmetricLevinson(IROComplexFloatVector T)
    {
      // check parameter
      if (T == null)
      {
        throw new System.ArgumentNullException("T");
      }
      else if (T.Length == 0)
      {
        throw new RankException("The length of T is zero.");
      }

      // save the vector
      m_LeftColumn = new ComplexFloatVector(T);
      m_Order = m_LeftColumn.Length;

      // allocate memory for lower triangular matrix
      m_LowerTriangle = new ComplexFloat[m_Order][];
      for (int i = 0; i < m_Order; i++)
      {
        m_LowerTriangle[i] = new ComplexFloat[i+1];
      }

      // allocate memory for diagonal
      m_Diagonal = new ComplexFloat[m_Order];

    }
    /// <overloads>
    /// Solve a symmetric square Toeplitz system.
    /// </overloads>
    /// <summary>
    /// Solve a symmetric square Toeplitz system with a right-side vector.
    /// </summary>
    /// <param name="T">The left-most column of the Toeplitz matrix.</param>
    /// <param name="Y">The right-side vector of the system.</param>
    /// <returns>The solution vector.</returns>
    /// <exception cref="ArgumentNullException">
    /// <B>T</B> and/or <B>Y</B> are null references
    /// </exception>
    /// <exception cref="RankException">
    /// The length of <B>T</B> does not match the length of <B>Y</B>.
    /// </exception>
    /// <exception cref="SingularMatrixException">
    /// The Toeplitz matrix or one of the the leading sub-matrices is singular.
    /// </exception>
    /// <remarks>
    /// This method solves the linear system <B>AX</B> = <B>Y</B>. Where
    /// <B>T</B> is a symmetric square Toeplitz matrix, <B>X</B> is an unknown
    /// vector and <B>Y</B> is a known vector.
    /// <para>
    /// This static member combines the <b>UDL</b> decomposition and the calculation of the solution into a
    /// single algorithm. When compared to the non-static member it requires minimal data storage
    /// and suffers from no speed penalty.
    /// </para>
    /// </remarks>
    public static ComplexFloatVector Solve(IROComplexFloatVector T, IROComplexFloatVector Y)
    {

      ComplexFloatVector X;

      // check parameters
      if (T == null)
      {
        throw new System.ArgumentNullException("T");
      }
      else if (Y == null)
      {
        throw new System.ArgumentNullException("Y");
      }
      else if (T.Length != Y.Length)
      {
        throw new RankException("The length of T and Y are not equal.");
      }
      else
      {

        // allocate memory
        int N = T.Length;
        X = new ComplexFloatVector(N);                    // solution vector
        ComplexFloat e;                                   // prediction error

        // setup zero order solution
        e = T[0];
        if (e == ComplexFloat.Zero)
        {
          throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
        }
        X[0] = Y[0] / T[0];

        if (N > 1)
        {
          ComplexFloatVector a = new ComplexFloatVector(N - 1);   // prediction coefficients
          ComplexFloatVector Z = new ComplexFloatVector(N - 1);   // temporary storage vector
          ComplexFloat g;                                   // reflection coefficient
          ComplexFloat inner;                               // inner product
          ComplexFloat k;
          int i, j, l;

          // calculate solution for successive orders
          for (i = 1; i < N; i++)
          {

            // calculate first inner product
            inner = T[i];
            for (j = 0, l = i - 1; j < i - 1; j++, l--)
            {
              inner += a[j] * T[l];
            }

            // update predictor coefficients
            g = -(inner / e);
            for (j = 0, l = i - 2; j < i - 1; j++, l--)
            {
              Z[j] = a[j] + g * a[l];
            }

            // copy vector
            for (j = 0; j < i - 1; j++)
            {
              a[j] = Z[j];
            }

            a[i - 1] = g;

            e *= (ComplexFloat.One - g * g);
            if (e == ComplexFloat.Zero)
            {
              throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
            }

            // calculate second inner product
            inner = Y[i];
            for (j = 0, l = i; j < i; j++, l--)
            {
              inner -= X[j] * T[l];
            }

            // update solution vector
            k = inner / e;
            for (j = 0, l = i - 1; j < i; j++, l--)
            {
              X[j] = X[j] + k * a[l];
            }
            X[j] = k;

          }

        }

      }

      return X;

    }
 public void MemberMultiplyVector()
 {
   ComplexFloatMatrix a = new ComplexFloatMatrix(2);
   a[0,0] = new ComplexFloat(1);
   a[0,1] = new ComplexFloat(2);
   a[1,0] = new ComplexFloat(3);
   a[1,1] = new ComplexFloat(4);
   ComplexFloatVector b = new ComplexFloatVector(2, 2.0f);
   a.Multiply(b);
   Assert.AreEqual(a[0,0],new ComplexFloat(6));
   Assert.AreEqual(a[1,0],new ComplexFloat(14));
   Assert.AreEqual(a.ColumnLength, 1);
   Assert.AreEqual(a.RowLength, 2);
 }
    /// <summary>
    /// Solve a symmetric square Toeplitz system with a right-side matrix.
    /// </summary>
    /// <param name="T">The left-most column of the Toeplitz matrix.</param>
    /// <param name="Y">The right-side matrix of the system.</param>
    /// <returns>The solution matrix.</returns>
    /// <exception cref="ArgumentNullException">
    /// <B>T</B> and/or <B>Y</B> are null references
    /// </exception>
    /// <exception cref="RankException">
    /// The length of <B>T</B> does not match the number of rows in <B>Y</B>.
    /// </exception>
    /// <exception cref="SingularMatrixException">
    /// The Toeplitz matrix or one of the the leading sub-matrices is singular.
    /// </exception>
    /// <remarks>
    /// This method solves the linear system <B>AX</B> = <B>Y</B>. Where
    /// <B>T</B> is a symmetric square Toeplitz matrix, <B>X</B> is an unknown
    /// matrix and <B>Y</B> is a known matrix.
    /// <para>
    /// This static member combines the <b>UDL</b> decomposition and the calculation of the solution into a
    /// single algorithm. When compared to the non-static member it requires minimal data storage
    /// and suffers from no speed penalty.
    /// </para>
    /// </remarks>
    public static ComplexFloatMatrix Solve(IROComplexFloatVector T, IROComplexFloatMatrix Y)
    {

      ComplexFloatMatrix X;

      // check parameters
      if (T == null)
      {
        throw new System.ArgumentNullException("T");
      }
      else if (Y == null)
      {
        throw new System.ArgumentNullException("Y");
      }
      else if (T.Length != Y.Columns)
      {
        throw new RankException("The length of T and Y are not equal.");
      }
      else
      {

        // allocate memory
        int N = T.Length;
        int M = Y.Rows;
        X = new ComplexFloatMatrix(N, M);                 // solution matrix
        ComplexFloatVector Z = new ComplexFloatVector(N);       // temporary storage vector
        ComplexFloat e;                                   // prediction error
        int i, j, l, m;

        // setup zero order solution
        e = T[0];
        if (e == ComplexFloat.Zero)
        {
          throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
        }
        for (m = 0; m < M; m++)
        {
          X[0, m] = Y[0,m] / T[0];
        }

        if (N > 1)
        {

          ComplexFloatVector a = new ComplexFloatVector(N - 1);   // prediction coefficients
          ComplexFloat p;                                   // reflection coefficient
          ComplexFloat inner;                               // inner product
          ComplexFloat k;

          // calculate solution for successive orders
          for (i = 1; i < N; i++)
          {

            // calculate first inner product
            inner = T[i];
            for (j = 0, l = i - 1; j < i - 1; j++, l--)
            {
              inner += a[j] * T[l];
            }

            // update predictor coefficients
            p = -(inner / e);
            for (j = 0, l = i - 2; j < i - 1; j++, l--)
            {
              Z[j] = a[j] + p * a[l];
            }

            // copy vector
            for (j = 0; j < i - 1; j++)
            {
              a[j] = Z[j];
            }

            a[i - 1] = p;
            e *= (ComplexFloat.One - p * p);

            if (e == ComplexFloat.Zero)
            {
              throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
            }

            // update the solution matrix
            for (m = 0; m < M; m++)
            {

              // retrieve a copy of solution column
              for (j = 0; j < i; j++)
              {
                Z[j] = X[j, m];
              }

              // calculate second inner product
              inner = Y[i, m];
              for (j = 0, l = i; j < i; j++, l--)
              {
                inner -= Z[j] * T[l];
              }

              // update solution vector
              k = inner / e;
              for (j = 0, l = i - 1; j < i; j++, l--)
              {
                Z[j] = Z[j] + k * a[l];
              }
              Z[j] = k;

              // store solution column in matrix
              for (j = 0; j <= i; j++)
              {
                X[j, m] = Z[j];
              }

            }

          }

        }

      }

      return X;
    }
 public void StaticMultiplyMatrixNonConformVector()
 {
   ComplexFloatMatrix a = new ComplexFloatMatrix(2);
   ComplexFloatVector b = new ComplexFloatVector(3, 2.0f);
   ComplexFloatVector c = a * b;
 }
Exemplo n.º 20
0
 ///<summary>Add a <c>ComplexFloatVector</c> to another <c>ComplexFloatVector</c></summary>
 ///<param name="lhs"><c>ComplexFloatVector</c> to add to.</param>
 ///<param name="rhs"><c>ComplexFloatVector</c> to add.</param>
 ///<returns><c>ComplexFloatVector</c> with results.</returns>
 public static ComplexFloatVector Add(ComplexFloatVector lhs, ComplexFloatVector rhs)
 {
     return(lhs + rhs);
 }
Exemplo n.º 21
0
        ///<summary>Computes the algorithm.</summary>
        protected override void InternalCompute()
        {
            rows = matrix.RowLength;
            cols = matrix.ColumnLength;
            int mm = System.Math.Min(rows + 1, cols);

            s = new ComplexFloatVector(mm); // singular values
#if MANAGED
            // Derived from LINPACK code.
            // Initialize.
            u = new ComplexFloatMatrix(rows, rows); // left vectors
            v = new ComplexFloatMatrix(cols, cols); // right vectors
            ComplexFloatVector e    = new ComplexFloatVector(cols);
            ComplexFloatVector work = new ComplexFloatVector(rows);

            int   i, iter, j, k, kase, l, lp1, ls = 0, lu, m, nct, nctp1, ncu, nrt, nrtp1;
            float b, c, cs = 0.0f, el, emm1, f, g, scale, shift, sl,
                  sm, sn = 0.0f, smm1, t1, test, ztest, xnorm, enorm;
            ComplexFloat t, r;

            ncu = rows;

            //   reduce matrix to bidiagonal form, storing the diagonal elements
            //   in s and the super-diagonal elements in e.
            int info = 0;
            nct = System.Math.Min(rows - 1, cols);
            nrt = System.Math.Max(0, System.Math.Min(cols - 2, rows));
            lu  = System.Math.Max(nct, nrt);

            for (l = 0; l < lu; l++)
            {
                lp1 = l + 1;
                if (l < nct)
                {
                    // compute the transformation for the l-th column and
                    // place the l-th diagonal in s[l].
                    xnorm = dznrm2Column(matrix, l, l);
                    s[l]  = new ComplexFloat(xnorm, 0.0f);
                    if (dcabs1(s[l]) != 0.0f)
                    {
                        if (dcabs1(matrix[l, l]) != 0.0f)
                        {
                            s[l] = csign(s[l], matrix[l, l]);
                        }
                        zscalColumn(matrix, l, l, 1.0f / s[l]);
                        matrix[l, l] = ComplexFloat.One + matrix[l, l];
                    }

                    s[l] = -s[l];
                }

                for (j = lp1; j < cols; j++)
                {
                    if (l < nct)
                    {
                        if (dcabs1(s[l]) != 0.0f)
                        {
                            // apply the transformation.
                            t = -zdotc(matrix, l, j, l) / matrix[l, l];
                            for (int ii = l; ii < matrix.RowLength; ii++)
                            {
                                matrix[ii, j] += t * matrix[ii, l];
                            }
                        }
                    }

                    //place the l-th row of matrix into  e for the
                    //subsequent calculation of the row transformation.
                    e[j] = ComplexMath.Conjugate(matrix[l, j]);
                }

                if (computeVectors && l < nct)
                {
                    // place the transformation in u for subsequent back multiplication.
                    for (i = l; i < rows; i++)
                    {
                        u[i, l] = matrix[i, l];
                    }
                }

                if (l < nrt)
                {
                    // compute the l-th row transformation and place the l-th super-diagonal in e(l).
                    enorm = dznrm2Vector(e, lp1);
                    e[l]  = new ComplexFloat(enorm, 0.0f);
                    if (dcabs1(e[l]) != 0.0f)
                    {
                        if (dcabs1(e[lp1]) != 0.0f)
                        {
                            e[l] = csign(e[l], e[lp1]);
                        }
                        zscalVector(e, lp1, 1.0f / e[l]);
                        e[lp1] = ComplexFloat.One + e[lp1];
                    }
                    e[l] = ComplexMath.Conjugate(-e[l]);

                    if (lp1 < rows && dcabs1(e[l]) != 0.0f)
                    {
                        // apply the transformation.
                        for (i = lp1; i < rows; i++)
                        {
                            work[i] = ComplexFloat.Zero;
                        }

                        for (j = lp1; j < cols; j++)
                        {
                            for (int ii = lp1; ii < matrix.RowLength; ii++)
                            {
                                work[ii] += e[j] * matrix[ii, j];
                            }
                        }

                        for (j = lp1; j < cols; j++)
                        {
                            ComplexFloat ww = ComplexMath.Conjugate(-e[j] / e[lp1]);
                            for (int ii = lp1; ii < matrix.RowLength; ii++)
                            {
                                matrix[ii, j] += ww * work[ii];
                            }
                        }
                    }

                    if (computeVectors)
                    {
                        // place the transformation in v for subsequent back multiplication.
                        for (i = lp1; i < cols; i++)
                        {
                            v[i, l] = e[i];
                        }
                    }
                }
            }

            //   set up the final bidiagonal matrix or order m.
            m     = System.Math.Min(cols, rows + 1);
            nctp1 = nct + 1;
            nrtp1 = nrt + 1;
            if (nct < cols)
            {
                s[nctp1 - 1] = matrix[nctp1 - 1, nctp1 - 1];
            }
            if (rows < m)
            {
                s[m - 1] = ComplexFloat.Zero;
            }
            if (nrtp1 < m)
            {
                e[nrtp1 - 1] = matrix[nrtp1 - 1, m - 1];
            }
            e[m - 1] = ComplexFloat.Zero;

            //   if required, generate u.
            if (computeVectors)
            {
                for (j = nctp1 - 1; j < ncu; j++)
                {
                    for (i = 0; i < rows; i++)
                    {
                        u[i, j] = ComplexFloat.Zero;
                    }
                    u[j, j] = ComplexFloat.One;
                }

                for (l = nct - 1; l >= 0; l--)
                {
                    if (dcabs1(s[l]) != 0.0)
                    {
                        for (j = l + 1; j < ncu; j++)
                        {
                            t = -zdotc(u, l, j, l) / u[l, l];
                            for (int ii = l; ii < u.RowLength; ii++)
                            {
                                u[ii, j] += t * u[ii, l];
                            }
                        }
                        zscalColumn(u, l, l, -ComplexFloat.One);
                        u[l, l] = ComplexFloat.One + u[l, l];
                        for (i = 0; i < l; i++)
                        {
                            u[i, l] = ComplexFloat.Zero;
                        }
                    }
                    else
                    {
                        for (i = 0; i < rows; i++)
                        {
                            u[i, l] = ComplexFloat.Zero;
                        }
                        u[l, l] = ComplexFloat.One;
                    }
                }
            }

            //   if it is required, generate v.
            if (computeVectors)
            {
                for (l = cols - 1; l >= 0; l--)
                {
                    lp1 = l + 1;
                    if (l < nrt)
                    {
                        if (dcabs1(e[l]) != 0.0)
                        {
                            for (j = lp1; j < cols; j++)
                            {
                                t = -zdotc(v, l, j, lp1) / v[lp1, l];
                                for (int ii = l; ii < v.RowLength; ii++)
                                {
                                    v[ii, j] += t * v[ii, l];
                                }
                            }
                        }
                    }
                    for (i = 0; i < cols; i++)
                    {
                        v[i, l] = ComplexFloat.Zero;
                    }
                    v[l, l] = ComplexFloat.One;
                }
            }

            //   transform s and e so that they are  float .
            for (i = 0; i < m; i++)
            {
                if (dcabs1(s[i]) != 0.0)
                {
                    t    = new ComplexFloat(ComplexMath.Absolute(s[i]), 0.0f);
                    r    = s[i] / t;
                    s[i] = t;
                    if (i < m - 1)
                    {
                        e[i] = e[i] / r;
                    }
                    if (computeVectors)
                    {
                        zscalColumn(u, i, 0, r);
                    }
                }
                //   ...exit
                if (i == m - 1)
                {
                    break;
                }
                if (dcabs1(e[i]) != 0.0)
                {
                    t        = new ComplexFloat(ComplexMath.Absolute(e[i]), 0.0f);
                    r        = t / e[i];
                    e[i]     = t;
                    s[i + 1] = s[i + 1] * r;
                    if (computeVectors)
                    {
                        zscalColumn(v, i + 1, 0, r);
                    }
                }
            }

            //   main iteration loop for the singular values.
            mm   = m;
            iter = 0;

            while (m > 0)
            { // quit if all the singular values have been found.
              // if too many iterations have been performed, set
              //      flag and return.
                if (iter >= MAXITER)
                {
                    info = m;
                    //   ......exit
                    break;
                }

                //      this section of the program inspects for
                //      negligible elements in the s and e arrays.  on
                //      completion the variables kase and l are set as follows.

                //         kase = 1     if s[m] and e[l-1] are negligible and l < m
                //         kase = 2     if s[l] is negligible and l < m
                //         kase = 3     if e[l-1] is negligible, l < m, and
                //                      s[l, ..., s[m] are not negligible (qr step).
                //         kase = 4     if e[m-1] is negligible (convergence).

                for (l = m - 2; l >= 0; l--)
                {
                    test  = ComplexMath.Absolute(s[l]) + ComplexMath.Absolute(s[l + 1]);
                    ztest = test + ComplexMath.Absolute(e[l]);
                    if (ztest == test)
                    {
                        e[l] = ComplexFloat.Zero;
                        break;
                    }
                }

                if (l == m - 2)
                {
                    kase = 4;
                }
                else
                {
                    for (ls = m - 1; ls > l; ls--)
                    {
                        test = 0.0f;
                        if (ls != m - 1)
                        {
                            test = test + ComplexMath.Absolute(e[ls]);
                        }
                        if (ls != l + 1)
                        {
                            test = test + ComplexMath.Absolute(e[ls - 1]);
                        }
                        ztest = test + ComplexMath.Absolute(s[ls]);
                        if (ztest == test)
                        {
                            s[ls] = ComplexFloat.Zero;
                            break;
                        }
                    }

                    if (ls == l)
                    {
                        kase = 3;
                    }
                    else if (ls == m - 1)
                    {
                        kase = 1;
                    }
                    else
                    {
                        kase = 2;
                        l    = ls;
                    }
                }

                l = l + 1;

                //      perform the task indicated by kase.
                switch (kase)
                {
                // deflate negligible s[m].
                case 1:
                    f        = e[m - 2].Real;
                    e[m - 2] = ComplexFloat.Zero;
                    for (k = m - 2; k >= 0; k--)
                    {
                        t1 = s[k].Real;
                        drotg(ref t1, ref f, ref cs, ref sn);
                        s[k] = new ComplexFloat(t1, 0.0f);
                        if (k != l)
                        {
                            f        = -sn * e[k - 1].Real;
                            e[k - 1] = cs * e[k - 1];
                        }
                        if (computeVectors)
                        {
                            zdrot(v, k, m - 1, cs, sn);
                        }
                    }
                    break;

                // split at negligible s[l].
                case 2:
                    f        = e[l - 1].Real;
                    e[l - 1] = ComplexFloat.Zero;
                    for (k = l; k < m; k++)
                    {
                        t1 = s[k].Real;
                        drotg(ref t1, ref f, ref cs, ref sn);
                        s[k] = new ComplexFloat(t1, 0.0f);
                        f    = -sn * e[k].Real;
                        e[k] = cs * e[k];
                        if (computeVectors)
                        {
                            zdrot(u, k, l - 1, cs, sn);
                        }
                    }
                    break;

                // perform one qr step.
                case 3:
                    // calculate the shift.
                    scale = 0.0f;
                    scale = System.Math.Max(scale, ComplexMath.Absolute(s[m - 1]));
                    scale = System.Math.Max(scale, ComplexMath.Absolute(s[m - 2]));
                    scale = System.Math.Max(scale, ComplexMath.Absolute(e[m - 2]));
                    scale = System.Math.Max(scale, ComplexMath.Absolute(s[l]));
                    scale = System.Math.Max(scale, ComplexMath.Absolute(e[l]));
                    sm    = s[m - 1].Real / scale;
                    smm1  = s[m - 2].Real / scale;
                    emm1  = e[m - 2].Real / scale;
                    sl    = s[l].Real / scale;
                    el    = e[l].Real / scale;
                    b     = ((smm1 + sm) * (smm1 - sm) + emm1 * emm1) / 2.0f;
                    c     = (sm * emm1) * (sm * emm1);
                    shift = 0.0f;
                    if (b != 0.0f || c != 0.0f)
                    {
                        shift = (float)System.Math.Sqrt(b * b + c);
                        if (b < 0.0f)
                        {
                            shift = -shift;
                        }
                        shift = c / (b + shift);
                    }
                    f = (sl + sm) * (sl - sm) + shift;
                    g = sl * el;

                    // chase zeros.
                    for (k = l; k < m - 1; k++)
                    {
                        drotg(ref f, ref g, ref cs, ref sn);
                        if (k != l)
                        {
                            e[k - 1] = new ComplexFloat(f, 0.0f);
                        }
                        f        = cs * s[k].Real + sn * e[k].Real;
                        e[k]     = cs * e[k] - sn * s[k];
                        g        = sn * s[k + 1].Real;
                        s[k + 1] = cs * s[k + 1];
                        if (computeVectors)
                        {
                            zdrot(v, k, k + 1, cs, sn);
                        }
                        drotg(ref f, ref g, ref cs, ref sn);
                        s[k]     = new ComplexFloat(f, 0.0f);
                        f        = cs * e[k].Real + sn * s[k + 1].Real;
                        s[k + 1] = -sn * e[k] + cs * s[k + 1];
                        g        = sn * e[k + 1].Real;
                        e[k + 1] = cs * e[k + 1];
                        if (computeVectors && k < rows)
                        {
                            zdrot(u, k, k + 1, cs, sn);
                        }
                    }
                    e[m - 2] = new  ComplexFloat(f, 0.0f);
                    iter     = iter + 1;
                    break;

                // convergence.
                case 4:
                    // make the singular value  positive
                    if (s[l].Real < 0.0)
                    {
                        s[l] = -s[l];
                        if (computeVectors)
                        {
                            zscalColumn(v, l, 0, -ComplexFloat.One);
                        }
                    }

                    // order the singular value.
                    while (l != mm - 1)
                    {
                        if (s[l].Real >= s[l + 1].Real)
                        {
                            break;
                        }
                        t        = s[l];
                        s[l]     = s[l + 1];
                        s[l + 1] = t;
                        if (computeVectors && l < cols)
                        {
                            zswap(v, l, l + 1);
                        }
                        if (computeVectors && l < rows)
                        {
                            zswap(u, l, l + 1);
                        }
                        l = l + 1;
                    }
                    iter = 0;
                    m    = m - 1;
                    break;
                }
            }

            // make matrix w from vector s
            // there is no constructor, creating diagonal matrix from vector
            // doing it ourselves
            mm = System.Math.Min(matrix.RowLength, matrix.ColumnLength);
#else
            float[] d = new float[mm];
            u = new ComplexFloatMatrix(rows);
            v = new ComplexFloatMatrix(cols);
            ComplexFloat[] a = new ComplexFloat[matrix.data.Length];
            Array.Copy(matrix.data, a, matrix.data.Length);
            Lapack.Gesvd.Compute(rows, cols, a, d, u.data, v.data);
            v.ConjugateTranspose();
            for (int i = 0; i < d.Length; i++)
            {
                s[i] = d[i];
            }
#endif
            w = new FloatMatrix(matrix.RowLength, matrix.ColumnLength);
            for (int ii = 0; ii < matrix.RowLength; ii++)
            {
                for (int jj = 0; jj < matrix.ColumnLength; jj++)
                {
                    if (ii == jj)
                    {
                        w[ii, ii] = s[ii];
                    }
                }
            }

            float eps = (float)System.Math.Pow(2.0, -52.0);
            float tol = System.Math.Max(matrix.RowLength, matrix.ColumnLength) * s[0].Real * eps;
            rank = 0;

            for (int h = 0; h < mm; h++)
            {
                if (s[h].Real > tol)
                {
                    rank++;
                }
            }

            if (!computeVectors)
            {
                u = null;
                v = null;
            }
            matrix = null;
        }
Exemplo n.º 22
0
 ///<summary>Divide a <c>ComplexFloatVector</c> x with a <c>ComplexFloat</c> y as x/y</summary>
 ///<param name="lhs"><c>ComplexFloatVector</c> as left hand operand.</param>
 ///<param name="rhs"><c>ComplexFloat</c> as right hand operand.</param>
 ///<returns><c>ComplexFloatVector</c> with results.</returns>
 public static ComplexFloatVector Divide(ComplexFloatVector lhs, ComplexFloat rhs)
 {
     return(lhs / rhs);
 }
Exemplo n.º 23
0
 ///<summary>Multiply a <c>ComplexFloatVector</c> x with a <c>ComplexFloat</c> y as x*y</summary>
 ///<param name="lhs"><c>ComplexFloatVector</c> as left hand operand.</param>
 ///<param name="rhs"><c>ComplexFloat</c> as right hand operand.</param>
 ///<returns><c>ComplexFloatVector</c> with results.</returns>
 public static ComplexFloatVector Multiply(ComplexFloatVector lhs, ComplexFloat rhs)
 {
     return(lhs * rhs);
 }
 public void StaticMultiplyNullMatrixVector()
 {
   ComplexFloatMatrix a = null;
   ComplexFloatVector b = new ComplexFloatVector(2, 2.0f);
   ComplexFloatVector c = ComplexFloatMatrix.Multiply(a,b);
 }
 ///<summary> Constructor </summary>
 public ComplexFloatVectorEnumerator(ComplexFloatVector vector)
 {
     v      = vector;
     index  = -1;
     length = v.Length;
 }
 public void MemberMultiplyMatrixNonConformVector()
 {
   ComplexFloatMatrix a = new ComplexFloatMatrix(2);
   ComplexFloatVector b = new ComplexFloatVector(3, 2.0f);
   a.Multiply(b);
 }
Exemplo n.º 27
0
        /// <summary>
        /// Solve the Yule-Walker equations for a symmetric square Toeplitz system
        /// </summary>
        /// <param name="R">The left-most column of the Toeplitz matrix.</param>
        /// <returns>The solution vector.</returns>
        /// <exception cref="ArgumentNullException">
        /// <B>R</B> is a null reference.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        /// The length of <B>R</B> must be greater than one.
        /// </exception>
        /// <exception cref="SingularMatrixException">
        /// The Toeplitz matrix or one of the the leading sub-matrices is singular.
        /// </exception>
        /// <remarks>
        /// This member is used to solve the Yule-Walker system <B>AX</B> = -<B>a</B>,
        /// where <B>A</B> is a symmetric square Toeplitz matrix, constructed
        /// from the elements <B>R[0]</B>, ..., <B>R[N-2]</B> and
        /// the vector <B>a</B> is constructed from the elements
        /// <B>R[1]</B>, ..., <B>R[N-1]</B>.
        /// <para>
        /// Durbin's algorithm is used to solve the linear system. It requires
        /// approximately the <b>N</b> squared FLOPS to calculate the
        /// solution (<b>N</b> is the matrix order).
        /// </para>
        /// </remarks>
        public static ComplexFloatVector YuleWalker(IROComplexFloatVector R)
        {
            ComplexFloatVector a;

            // check parameters
            if (R == null)
            {
                throw new System.ArgumentNullException("R");
            }
            else if (R.Length < 2)
            {
                throw new System.ArgumentOutOfRangeException("R", "The length of R must be greater than 1.");
            }
            else
            {
                int N = R.Length - 1;
                a = new ComplexFloatVector(N);                    // prediction coefficients
                ComplexFloatVector Z = new ComplexFloatVector(N); // temporary storage vector
                ComplexFloat       e;                             // predictor error
                ComplexFloat       inner;                         // inner product
                ComplexFloat       g;                             // reflection coefficient
                int i, j, l;

                // setup first order solution
                e = R[0];
                if (e == ComplexFloat.Zero)
                {
                    throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
                }
                g    = -R[1] / R[0];
                a[0] = g;

                // calculate solution for successive orders
                for (i = 1; i < N; i++)
                {
                    e *= (ComplexFloat.One - g * g);
                    if (e == ComplexFloat.Zero)
                    {
                        throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
                    }

                    // calculate inner product
                    inner = R[i + 1];
                    for (j = 0, l = i; j < i; j++, l--)
                    {
                        inner += a[j] * R[l];
                    }

                    // update prediction coefficients
                    g = -(inner / e);
                    for (j = 0, l = i - 1; j < i; j++, l--)
                    {
                        Z[j] = a[j] + g * a[l];
                    }

                    // copy vector
                    for (j = 0; j < i; j++)
                    {
                        a[j] = Z[j];
                    }

                    a[i] = g;
                }
            }

            return(a);
        }
    /// <summary>
    /// Solve the Yule-Walker equations for a symmetric square Toeplitz system
    /// </summary>
    /// <param name="R">The left-most column of the Toeplitz matrix.</param>
    /// <returns>The solution vector.</returns>
    /// <exception cref="ArgumentNullException">
    /// <B>R</B> is a null reference.
    /// </exception>
    /// <exception cref="ArgumentOutOfRangeException">
    /// The length of <B>R</B> must be greater than one.
    /// </exception>
    /// <exception cref="SingularMatrixException">
    /// The Toeplitz matrix or one of the the leading sub-matrices is singular.
    /// </exception>
    /// <remarks>
    /// This member is used to solve the Yule-Walker system <B>AX</B> = -<B>a</B>,
    /// where <B>A</B> is a symmetric square Toeplitz matrix, constructed
    /// from the elements <B>R[0]</B>, ..., <B>R[N-2]</B> and
    /// the vector <B>a</B> is constructed from the elements
    /// <B>R[1]</B>, ..., <B>R[N-1]</B>.
    /// <para>
    /// Durbin's algorithm is used to solve the linear system. It requires
    /// approximately the <b>N</b> squared FLOPS to calculate the
    /// solution (<b>N</b> is the matrix order).
    /// </para>
    /// </remarks>
    public static ComplexFloatVector YuleWalker(IROComplexFloatVector R)
    {

      ComplexFloatVector a;

      // check parameters
      if (R == null)
      {
        throw new System.ArgumentNullException("R");
      }
      else if (R.Length < 2)
      {
        throw new System.ArgumentOutOfRangeException("R", "The length of R must be greater than 1.");
      }
      else
      {

        int N = R.Length - 1;
        a = new ComplexFloatVector(N);              // prediction coefficients
        ComplexFloatVector Z = new ComplexFloatVector(N);   // temporary storage vector
        ComplexFloat e;                   // predictor error
        ComplexFloat inner;                 // inner product
        ComplexFloat g;                   // reflection coefficient
        int i, j, l;

        // setup first order solution
        e = R[0];
        if (e == ComplexFloat.Zero)
        {
          throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
        }
        g = -R[1] / R[0];
        a[0] = g;

        // calculate solution for successive orders
        for (i = 1; i < N; i++)
        {

          e *= (ComplexFloat.One - g * g);
          if (e == ComplexFloat.Zero)
          {
            throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
          }

          // calculate inner product
          inner = R[i + 1];
          for (j = 0, l = i; j < i; j++, l--)
          {
            inner += a[j] * R[l];
          }

          // update prediction coefficients
          g = -(inner / e);
          for (j = 0, l = i - 1; j < i; j++, l--)
          {
            Z[j] = a[j] + g * a[l];
          }

          // copy vector
          for (j = 0; j < i; j++)
          {
            a[j] = Z[j];
          }

          a[i] = g;

        }
      }

      return a;
    }
Exemplo n.º 29
0
        /// <summary>
        /// Solve a symmetric square Toeplitz system with a right-side matrix.
        /// </summary>
        /// <param name="T">The left-most column of the Toeplitz matrix.</param>
        /// <param name="Y">The right-side matrix of the system.</param>
        /// <returns>The solution matrix.</returns>
        /// <exception cref="ArgumentNullException">
        /// <B>T</B> and/or <B>Y</B> are null references
        /// </exception>
        /// <exception cref="RankException">
        /// The length of <B>T</B> does not match the number of rows in <B>Y</B>.
        /// </exception>
        /// <exception cref="SingularMatrixException">
        /// The Toeplitz matrix or one of the the leading sub-matrices is singular.
        /// </exception>
        /// <remarks>
        /// This method solves the linear system <B>AX</B> = <B>Y</B>. Where
        /// <B>T</B> is a symmetric square Toeplitz matrix, <B>X</B> is an unknown
        /// matrix and <B>Y</B> is a known matrix.
        /// <para>
        /// This static member combines the <b>UDL</b> decomposition and the calculation of the solution into a
        /// single algorithm. When compared to the non-static member it requires minimal data storage
        /// and suffers from no speed penalty.
        /// </para>
        /// </remarks>
        public static ComplexFloatMatrix Solve(IROComplexFloatVector T, IROComplexFloatMatrix Y)
        {
            ComplexFloatMatrix X;

            // check parameters
            if (T == null)
            {
                throw new System.ArgumentNullException("T");
            }
            else if (Y == null)
            {
                throw new System.ArgumentNullException("Y");
            }
            else if (T.Length != Y.Columns)
            {
                throw new RankException("The length of T and Y are not equal.");
            }
            else
            {
                // allocate memory
                int N = T.Length;
                int M = Y.Rows;
                X = new ComplexFloatMatrix(N, M);                 // solution matrix
                ComplexFloatVector Z = new ComplexFloatVector(N); // temporary storage vector
                ComplexFloat       e;                             // prediction error
                int i, j, l, m;

                // setup zero order solution
                e = T[0];
                if (e == ComplexFloat.Zero)
                {
                    throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
                }
                for (m = 0; m < M; m++)
                {
                    X[0, m] = Y[0, m] / T[0];
                }

                if (N > 1)
                {
                    ComplexFloatVector a = new ComplexFloatVector(N - 1); // prediction coefficients
                    ComplexFloat       p;                                 // reflection coefficient
                    ComplexFloat       inner;                             // inner product
                    ComplexFloat       k;

                    // calculate solution for successive orders
                    for (i = 1; i < N; i++)
                    {
                        // calculate first inner product
                        inner = T[i];
                        for (j = 0, l = i - 1; j < i - 1; j++, l--)
                        {
                            inner += a[j] * T[l];
                        }

                        // update predictor coefficients
                        p = -(inner / e);
                        for (j = 0, l = i - 2; j < i - 1; j++, l--)
                        {
                            Z[j] = a[j] + p * a[l];
                        }

                        // copy vector
                        for (j = 0; j < i - 1; j++)
                        {
                            a[j] = Z[j];
                        }

                        a[i - 1] = p;
                        e       *= (ComplexFloat.One - p * p);

                        if (e == ComplexFloat.Zero)
                        {
                            throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
                        }

                        // update the solution matrix
                        for (m = 0; m < M; m++)
                        {
                            // retrieve a copy of solution column
                            for (j = 0; j < i; j++)
                            {
                                Z[j] = X[j, m];
                            }

                            // calculate second inner product
                            inner = Y[i, m];
                            for (j = 0, l = i; j < i; j++, l--)
                            {
                                inner -= Z[j] * T[l];
                            }

                            // update solution vector
                            k = inner / e;
                            for (j = 0, l = i - 1; j < i; j++, l--)
                            {
                                Z[j] = Z[j] + k * a[l];
                            }
                            Z[j] = k;

                            // store solution column in matrix
                            for (j = 0; j <= i; j++)
                            {
                                X[j, m] = Z[j];
                            }
                        }
                    }
                }
            }

            return(X);
        }
    /// <overloads>
    /// Solve a symmetric square Toeplitz system.
    /// </overloads>
    /// <summary>
    /// Solve a symmetric square Toeplitz system with a right-side vector.
    /// </summary>
    /// <param name="Y">The right-hand side of the system.</param>
    /// <returns>The solution vector.</returns>
    /// <exception cref="ArgumentNullException">
    /// Parameter <B>Y</B> is a null reference.
    /// </exception>
    /// <exception cref="RankException">
    /// The length of <B>Y</B> is not equal to the number of rows in the Toeplitz matrix.
    /// </exception>
    /// <exception cref="SingularMatrixException">
    /// The Toeplitz matrix or one of the the leading sub-matrices is singular.
    /// </exception>
    /// <remarks>
    /// This member solves the linear system <B>TX</B> = <B>Y</B>, where <B>T</B> is
    /// the symmetric square Toeplitz matrix, <B>X</B> is the unknown solution vector
    /// and <B>Y</B> is a known vector.
    /// <para>
    /// The class implicitly decomposes the inverse Toeplitz matrix into a <b>UDL</b> factorisation
    /// using the Levinson algorithm, and then calculates the solution vector.
    /// </para>
    /// </remarks>
    public ComplexFloatVector Solve(IROComplexFloatVector Y)
    {
      ComplexFloatVector X;

      // check parameters
      if (Y == null)
      {
        throw new System.ArgumentNullException("Y");
      }
      else if (m_Order != Y.Length)
      {
        throw new RankException("The length of Y is not equal to the number of rows in the Toeplitz matrix.");
      }

      Compute();

      if (m_IsSingular == true)
      {
        throw new SingularMatrixException("The Toeplitz matrix or one of the the leading sub-matrices is singular.");
      }

      int i, j, l;      // index/loop variables
      ComplexFloat Inner;     // inner product
      ComplexFloat G;       // scaling constant
      ComplexFloat[] A;       // reference to current order coefficients

      // allocate memory for solution
      X = new ComplexFloatVector(m_Order);

      // setup zero order solution
      X[0] = Y[0] / m_LeftColumn[0];

      // solve systems of increasing order
      for (i = 1; i < m_Order; i++)
      {
        // calculate inner product
        Inner = Y[i];
        for (j = 0, l = i; j < i; j++, l--)
        {
          Inner -= X[j] * m_LeftColumn[l];
        }
        // get the current predictor coefficients row
        A = m_LowerTriangle[i];

        // update the solution vector
        G = Inner * m_Diagonal[i];
        for (j = 0; j <= i; j++)
        {
          X[j] += G * A[j];
        }

      }

      return X;
    }
    public void SetupTestCases()
    {
      // unit testing values - order 1

      LC1 = new ComplexFloatVector(1);
      LC1[0] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);

      TR1 = new ComplexFloatVector(1);
      TR1[0] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);

      L1 = new ComplexFloatMatrix(1);
      L1[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      D1 = new ComplexFloatVector(1);
      D1[0] = new ComplexFloat(+5.0000000E-001f, -5.0000000E-001f);

      U1 = new ComplexFloatMatrix(1);
      U1[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      Det1 = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);

      I1 = new ComplexFloatMatrix(1);
      I1[0, 0] = new ComplexFloat(+5.0000000E-001f, -5.0000000E-001f);

      X1 = new ComplexFloatVector(1);
      X1[0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      Y1 = new ComplexFloatVector(1);
      Y1[0] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);

      // unit testing values - order 2

      LC2 = new ComplexFloatVector(2);
      LC2[0] = new ComplexFloat(+3.0000000E+000f, +3.0000000E+000f);
      LC2[1] = new ComplexFloat(+2.0000000E+000f, +0.0000000E+000f);

      TR2 = new ComplexFloatVector(2);
      TR2[0] = new ComplexFloat(+3.0000000E+000f, +3.0000000E+000f);
      TR2[1] = new ComplexFloat(+2.0000000E+000f, +0.0000000E+000f);

      L2 = new ComplexFloatMatrix(2);
      L2[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L2[1, 0] = new ComplexFloat(-3.3333333E-001f, +3.3333333E-001f);
      L2[1, 1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      D2 = new ComplexFloatVector(2);
      D2[0] = new ComplexFloat(+1.6666667E-001f, -1.6666667E-001f);
      D2[1] = new ComplexFloat(+1.2352941E-001f, -1.9411765E-001f);

      U2 = new ComplexFloatMatrix(2);
      U2[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U2[0, 1] = new ComplexFloat(-3.3333333E-001f, +3.3333333E-001f);
      U2[1, 1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      Det2 = new ComplexFloat(-4.0000000E+000f, +1.8000000E+001f);

      I2 = new ComplexFloatMatrix(2);
      I2[0, 0] = new ComplexFloat(+1.2352941E-001f, -1.9411765E-001f);
      I2[0, 1] = new ComplexFloat(+2.3529412E-002f, +1.0588235E-001f);
      I2[1, 0] = new ComplexFloat(+2.3529412E-002f, +1.0588235E-001f);
      I2[1, 1] = new ComplexFloat(+1.2352941E-001f, -1.9411765E-001f);

      X2 = new ComplexFloatVector(2);
      X2[0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      X2[1] = new ComplexFloat(+2.0000000E+000f, +0.0000000E+000f);

      Y2 = new ComplexFloatVector(2);
      Y2[0] = new ComplexFloat(+7.0000000E+000f, +3.0000000E+000f);
      Y2[1] = new ComplexFloat(+8.0000000E+000f, +6.0000000E+000f);

      // unit testing values - order 3

      LC3 = new ComplexFloatVector(3);
      LC3[0] = new ComplexFloat(+3.0000000E+000f, +3.0000000E+000f);
      LC3[1] = new ComplexFloat(+2.0000000E+000f, +0.0000000E+000f);
      LC3[2] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      TR3 = new ComplexFloatVector(3);
      TR3[0] = new ComplexFloat(+3.0000000E+000f, +3.0000000E+000f);
      TR3[1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      TR3[2] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      L3 = new ComplexFloatMatrix(3);
      L3[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L3[1, 0] = new ComplexFloat(-3.3333333E-001f, +3.3333333E-001f);
      L3[1, 1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L3[2, 0] = new ComplexFloat(-1.7073171E-001f, -3.6585366E-002f);
      L3[2, 1] = new ComplexFloat(-2.9878049E-001f, +3.1097561E-001f);
      L3[2, 2] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      D3 = new ComplexFloatVector(3);
      D3[0] = new ComplexFloat(+1.6666667E-001f, -1.6666667E-001f);
      D3[1] = new ComplexFloat(+1.4634146E-001f, -1.8292683E-001f);
      D3[2] = new ComplexFloat(+1.4776571E-001f, -1.9120527E-001f);

      U3 = new ComplexFloatMatrix(3);
      U3[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U3[0, 1] = new ComplexFloat(-1.6666667E-001f, +1.6666667E-001f);
      U3[1, 1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U3[0, 2] = new ComplexFloat(-1.5243902E-001f, +1.2804878E-001f);
      U3[1, 2] = new ComplexFloat(-1.5853659E-001f, +7.3170732E-002f);
      U3[2, 2] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      Det3 = new ComplexFloat(-6.4000000E+001f, +3.9000000E+001f);

      I3 = new ComplexFloatMatrix(3);
      I3[0, 0] = new ComplexFloat(+1.4776571E-001f, -1.9120527E-001f);
      I3[0, 1] = new ComplexFloat(-9.4356418E-003f, +4.1125156E-002f);
      I3[0, 2] = new ComplexFloat(+1.9583408E-003f, +4.8068364E-002f);
      I3[1, 0] = new ComplexFloat(+1.5310664E-002f, +1.0307994E-001f);
      I3[1, 1] = new ComplexFloat(+1.3637173E-001f, -1.9814848E-001f);
      I3[1, 2] = new ComplexFloat(-9.4356418E-003f, +4.1125156E-002f);
      I3[2, 0] = new ComplexFloat(-3.2223607E-002f, +2.7238740E-002f);
      I3[2, 1] = new ComplexFloat(+1.5310664E-002f, +1.0307994E-001f);
      I3[2, 2] = new ComplexFloat(+1.4776571E-001f, -1.9120527E-001f);

      X3 = new ComplexFloatVector(3);
      X3[0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      X3[1] = new ComplexFloat(+2.0000000E+000f, +0.0000000E+000f);
      X3[2] = new ComplexFloat(+3.0000000E+000f, +0.0000000E+000f);

      Y3 = new ComplexFloatVector(3);
      Y3[0] = new ComplexFloat(+8.0000000E+000f, +3.0000000E+000f);
      Y3[1] = new ComplexFloat(+1.1000000E+001f, +6.0000000E+000f);
      Y3[2] = new ComplexFloat(+1.4000000E+001f, +9.0000000E+000f);

      // unit testing values - order 4

      LC4 = new ComplexFloatVector(4);
      LC4[0] = new ComplexFloat(+4.0000000E+000f, +4.0000000E+000f);
      LC4[1] = new ComplexFloat(+3.0000000E+000f, +3.0000000E+000f);
      LC4[2] = new ComplexFloat(+2.0000000E+000f, +2.0000000E+000f);
      LC4[3] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);

      TR4 = new ComplexFloatVector(4);
      TR4[0] = new ComplexFloat(+4.0000000E+000f, +4.0000000E+000f);
      TR4[1] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);
      TR4[2] = new ComplexFloat(+2.0000000E+000f, +2.0000000E+000f);
      TR4[3] = new ComplexFloat(+3.0000000E+000f, +3.0000000E+000f);

      L4 = new ComplexFloatMatrix(4);
      L4[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L4[1, 0] = new ComplexFloat(-7.5000000E-001f, +0.0000000E+000f);
      L4[1, 1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L4[2, 0] = new ComplexFloat(+7.6923077E-002f, +0.0000000E+000f);
      L4[2, 1] = new ComplexFloat(-7.6923077E-001f, +0.0000000E+000f);
      L4[2, 2] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L4[3, 0] = new ComplexFloat(+9.0909091E-002f, +0.0000000E+000f);
      L4[3, 1] = new ComplexFloat(+9.0909091E-002f, +0.0000000E+000f);
      L4[3, 2] = new ComplexFloat(-8.1818182E-001f, +0.0000000E+000f);
      L4[3, 3] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      D4 = new ComplexFloatVector(4);
      D4[0] = new ComplexFloat(+1.2500000E-001f, -1.2500000E-001f);
      D4[1] = new ComplexFloat(+1.5384615E-001f, -1.5384615E-001f);
      D4[2] = new ComplexFloat(+1.4772727E-001f, -1.4772727E-001f);
      D4[3] = new ComplexFloat(+1.3750000E-001f, -1.3750000E-001f);

      U4 = new ComplexFloatMatrix(4);
      U4[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U4[0, 1] = new ComplexFloat(-2.5000000E-001f, +0.0000000E+000f);
      U4[1, 1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U4[0, 2] = new ComplexFloat(-5.3846154E-001f, +0.0000000E+000f);
      U4[1, 2] = new ComplexFloat(+1.5384615E-001f, +0.0000000E+000f);
      U4[2, 2] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U4[0, 3] = new ComplexFloat(-8.1818182E-001f, +0.0000000E+000f);
      U4[1, 3] = new ComplexFloat(+9.0909091E-002f, +0.0000000E+000f);
      U4[2, 3] = new ComplexFloat(+9.0909091E-002f, +0.0000000E+000f);
      U4[3, 3] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      Det4 = new ComplexFloat(-6.4000000E+002f, +0.0000000E+000f);

      I4 = new ComplexFloatMatrix(4);
      I4[0, 0] = new ComplexFloat(+1.3750000E-001f, -1.3750000E-001f);
      I4[0, 1] = new ComplexFloat(+1.2500000E-002f, -1.2500000E-002f);
      I4[0, 2] = new ComplexFloat(+1.2500000E-002f, -1.2500000E-002f);
      I4[0, 3] = new ComplexFloat(-1.1250000E-001f, +1.1250000E-001f);
      I4[1, 0] = new ComplexFloat(-1.1250000E-001f, +1.1250000E-001f);
      I4[1, 1] = new ComplexFloat(+1.3750000E-001f, -1.3750000E-001f);
      I4[1, 2] = new ComplexFloat(+1.2500000E-002f, -1.2500000E-002f);
      I4[1, 3] = new ComplexFloat(+1.2500000E-002f, -1.2500000E-002f);
      I4[2, 0] = new ComplexFloat(+1.2500000E-002f, -1.2500000E-002f);
      I4[2, 1] = new ComplexFloat(-1.1250000E-001f, +1.1250000E-001f);
      I4[2, 2] = new ComplexFloat(+1.3750000E-001f, -1.3750000E-001f);
      I4[2, 3] = new ComplexFloat(+1.2500000E-002f, -1.2500000E-002f);
      I4[3, 0] = new ComplexFloat(+1.2500000E-002f, -1.2500000E-002f);
      I4[3, 1] = new ComplexFloat(+1.2500000E-002f, -1.2500000E-002f);
      I4[3, 2] = new ComplexFloat(-1.1250000E-001f, +1.1250000E-001f);
      I4[3, 3] = new ComplexFloat(+1.3750000E-001f, -1.3750000E-001f);

      X4 = new ComplexFloatVector(4);
      X4[0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      X4[1] = new ComplexFloat(+2.0000000E+000f, +0.0000000E+000f);
      X4[2] = new ComplexFloat(+3.0000000E+000f, +0.0000000E+000f);
      X4[3] = new ComplexFloat(+4.0000000E+000f, +0.0000000E+000f);

      Y4 = new ComplexFloatVector(4);
      Y4[0] = new ComplexFloat(+2.4000000E+001f, +2.4000000E+001f);
      Y4[1] = new ComplexFloat(+2.2000000E+001f, +2.2000000E+001f);
      Y4[2] = new ComplexFloat(+2.4000000E+001f, +2.4000000E+001f);
      Y4[3] = new ComplexFloat(+3.0000000E+001f, +3.0000000E+001f);

      // unit testing values - order 5

      LC5 = new ComplexFloatVector(5);
      LC5[0] = new ComplexFloat(+5.0000000E+000f, +1.0000000E+000f);
      LC5[1] = new ComplexFloat(+4.0000000E+000f, +1.0000000E+000f);
      LC5[2] = new ComplexFloat(+3.0000000E+000f, +1.0000000E+000f);
      LC5[3] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);
      LC5[4] = new ComplexFloat(+0.0000000E+000f, +0.0000000E+000f);

      TR5 = new ComplexFloatVector(5);
      TR5[0] = new ComplexFloat(+5.0000000E+000f, +1.0000000E+000f);
      TR5[1] = new ComplexFloat(+1.0000000E+000f, +4.0000000E+000f);
      TR5[2] = new ComplexFloat(+1.0000000E+000f, +3.0000000E+000f);
      TR5[3] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);
      TR5[4] = new ComplexFloat(+0.0000000E+000f, +0.0000000E+000f);

      L5 = new ComplexFloatMatrix(5);
      L5[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L5[1, 0] = new ComplexFloat(-8.0769231E-001f, -3.8461538E-002f);
      L5[1, 1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L5[2, 0] = new ComplexFloat(+3.8400000E-002f, +1.1200000E-002f);
      L5[2, 1] = new ComplexFloat(-8.1280000E-001f, -7.0400000E-002f);
      L5[2, 2] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L5[3, 0] = new ComplexFloat(+2.2603093E-001f, +9.7680412E-002f);
      L5[3, 1] = new ComplexFloat(+8.8659794E-002f, -4.9484536E-002f);
      L5[3, 2] = new ComplexFloat(-8.9149485E-001f, -2.3788660E-001f);
      L5[3, 3] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L5[4, 0] = new ComplexFloat(-1.1100961E-001f, +5.9189712E-002f);
      L5[4, 1] = new ComplexFloat(+2.3807881E-001f, +1.3619525E-001f);
      L5[4, 2] = new ComplexFloat(+1.0797070E-001f, +5.4774906E-003f);
      L5[4, 3] = new ComplexFloat(-8.0625940E-001f, -2.8594254E-001f);
      L5[4, 4] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      D5 = new ComplexFloatVector(5);
      D5[0] = new ComplexFloat(+1.9230769E-001f, -3.8461538E-002f);
      D5[1] = new ComplexFloat(+1.8080000E-001f, +9.4400000E-002f);
      D5[2] = new ComplexFloat(+1.8015464E-001f, +8.8402062E-002f);
      D5[3] = new ComplexFloat(+1.5698660E-001f, +6.5498707E-002f);
      D5[4] = new ComplexFloat(+1.6335863E-001f, +5.3379923E-002f);

      U5 = new ComplexFloatMatrix(5);
      U5[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U5[0, 1] = new ComplexFloat(-3.4615385E-001f, -7.3076923E-001f);
      U5[1, 1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U5[0, 2] = new ComplexFloat(-5.6320000E-001f, -4.9760000E-001f);
      U5[1, 2] = new ComplexFloat(+8.9600000E-002f, -3.0720000E-001f);
      U5[2, 2] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U5[0, 3] = new ComplexFloat(-7.7757732E-001f, +1.8298969E-002f);
      U5[1, 3] = new ComplexFloat(+7.0103093E-002f, -4.5773196E-001f);
      U5[2, 3] = new ComplexFloat(+5.9536082E-002f, -3.1520619E-001f);
      U5[3, 3] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U5[0, 4] = new ComplexFloat(-3.8732272E-001f, +5.0102819E-001f);
      U5[1, 4] = new ComplexFloat(-3.1309322E-001f, -3.3622620E-001f);
      U5[2, 4] = new ComplexFloat(+6.0556288E-002f, -3.9414442E-001f);
      U5[3, 4] = new ComplexFloat(-7.6951473E-002f, -2.3979216E-001f);
      U5[4, 4] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      Det5 = new ComplexFloat(+5.0900000E+002f, -4.2310000E+003f);

      I5 = new ComplexFloatMatrix(5);
      I5[0, 0] = new ComplexFloat(+1.6335863E-001f, +5.3379923E-002f);
      I5[0, 1] = new ComplexFloat(+2.2939970E-004f, -4.3279784E-002f);
      I5[0, 2] = new ComplexFloat(+3.0931791E-002f, -6.1154404E-002f);
      I5[0, 3] = new ComplexFloat(-3.3198751E-002f, -7.1638344E-002f);
      I5[0, 4] = new ComplexFloat(-9.0017358E-002f, +6.1172024E-002f);
      I5[1, 0] = new ComplexFloat(-1.1644584E-001f, -8.9749247E-002f);
      I5[1, 1] = new ComplexFloat(+1.4442611E-001f, +1.0032784E-001f);
      I5[1, 2] = new ComplexFloat(-1.2433728E-002f, -5.1220119E-003f);
      I5[1, 3] = new ComplexFloat(+4.7268453E-002f, -1.4096573E-005f);
      I5[1, 4] = new ComplexFloat(-3.3198751E-002f, -7.1638344E-002f);
      I5[2, 0] = new ComplexFloat(+1.7345558E-002f, +6.6582631E-003f);
      I5[2, 1] = new ComplexFloat(-1.2410964E-001f, -1.0040846E-001f);
      I5[2, 2] = new ComplexFloat(+1.4624793E-001f, +1.1547147E-001f);
      I5[2, 3] = new ComplexFloat(-1.2433728E-002f, -5.1220119E-003f);
      I5[2, 4] = new ComplexFloat(+3.0931791E-002f, -6.1154404E-002f);
      I5[3, 0] = new ComplexFloat(+3.1622138E-002f, +3.4957299E-002f);
      I5[3, 1] = new ComplexFloat(+2.3108689E-002f, -1.2234063E-002f);
      I5[3, 2] = new ComplexFloat(-1.2410964E-001f, -1.0040846E-001f);
      I5[3, 3] = new ComplexFloat(+1.4442611E-001f, +1.0032784E-001f);
      I5[3, 4] = new ComplexFloat(+2.2939970E-004f, -4.3279784E-002f);
      I5[4, 0] = new ComplexFloat(-2.1293920E-002f, +3.7434662E-003f);
      I5[4, 1] = new ComplexFloat(+3.1622138E-002f, +3.4957299E-002f);
      I5[4, 2] = new ComplexFloat(+1.7345558E-002f, +6.6582631E-003f);
      I5[4, 3] = new ComplexFloat(-1.1644584E-001f, -8.9749247E-002f);
      I5[4, 4] = new ComplexFloat(+1.6335863E-001f, +5.3379923E-002f);

      X5 = new ComplexFloatVector(5);
      X5[0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      X5[1] = new ComplexFloat(+2.0000000E+000f, +0.0000000E+000f);
      X5[2] = new ComplexFloat(+3.0000000E+000f, +0.0000000E+000f);
      X5[3] = new ComplexFloat(+4.0000000E+000f, +0.0000000E+000f);
      X5[4] = new ComplexFloat(+5.0000000E+000f, +0.0000000E+000f);

      Y5 = new ComplexFloatVector(5);
      Y5[0] = new ComplexFloat(+1.4000000E+001f, +2.2000000E+001f);
      Y5[1] = new ComplexFloat(+2.6000000E+001f, +3.2000000E+001f);
      Y5[2] = new ComplexFloat(+3.5000000E+001f, +3.7000000E+001f);
      Y5[3] = new ComplexFloat(+4.4000000E+001f, +3.0000000E+001f);
      Y5[4] = new ComplexFloat(+5.2000000E+001f, +1.4000000E+001f);

      // unit testing values - order 10

      LC10 = new ComplexFloatVector(10);
      LC10[0] = new ComplexFloat(+1.0000000E+001f, +1.0000000E+000f);
      LC10[1] = new ComplexFloat(+9.0000000E+000f, +1.0000000E+000f);
      LC10[2] = new ComplexFloat(+8.0000000E+000f, +1.0000000E+000f);
      LC10[3] = new ComplexFloat(+7.0000000E+000f, +1.0000000E+000f);
      LC10[4] = new ComplexFloat(+6.0000000E+000f, +1.0000000E+000f);
      LC10[5] = new ComplexFloat(+5.0000000E+000f, +1.0000000E+000f);
      LC10[6] = new ComplexFloat(+4.0000000E+000f, +1.0000000E+000f);
      LC10[7] = new ComplexFloat(+3.0000000E+000f, +1.0000000E+000f);
      LC10[8] = new ComplexFloat(+2.0000000E+000f, +1.0000000E+000f);
      LC10[9] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);

      TR10 = new ComplexFloatVector(10);
      TR10[0] = new ComplexFloat(+1.0000000E+001f, +1.0000000E+000f);
      TR10[1] = new ComplexFloat(+1.0000000E+000f, +9.0000000E+000f);
      TR10[2] = new ComplexFloat(+1.0000000E+000f, +8.0000000E+000f);
      TR10[3] = new ComplexFloat(+1.0000000E+000f, +2.0000000E+000f);
      TR10[4] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);
      TR10[5] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);
      TR10[6] = new ComplexFloat(+1.0000000E+000f, +4.0000000E+000f);
      TR10[7] = new ComplexFloat(+1.0000000E+000f, +3.0000000E+000f);
      TR10[8] = new ComplexFloat(+1.0000000E+000f, +2.0000000E+000f);
      TR10[9] = new ComplexFloat(+1.0000000E+000f, +1.0000000E+000f);

      L10 = new ComplexFloatMatrix(10);
      L10[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L10[1, 0] = new ComplexFloat(-9.0099010E-001f, -9.9009901E-003f);
      L10[1, 1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L10[2, 0] = new ComplexFloat(+7.2554049E-003f, +4.5437889E-003f);
      L10[2, 1] = new ComplexFloat(-8.9835104E-001f, -1.7149139E-002f);
      L10[2, 2] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L10[3, 0] = new ComplexFloat(+8.1190931E-003f, +4.8283630E-003f);
      L10[3, 1] = new ComplexFloat(+8.5500220E-003f, +3.8783605E-003f);
      L10[3, 2] = new ComplexFloat(-8.9685128E-001f, -2.5375839E-002f);
      L10[3, 3] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L10[4, 0] = new ComplexFloat(+9.0797285E-003f, +5.0413564E-003f);
      L10[4, 1] = new ComplexFloat(+9.5223197E-003f, +3.9833209E-003f);
      L10[4, 2] = new ComplexFloat(+1.3594954E-002f, +1.3510004E-003f);
      L10[4, 3] = new ComplexFloat(-9.0106887E-001f, -3.2599942E-002f);
      L10[4, 4] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L10[5, 0] = new ComplexFloat(+1.0110174E-002f, +5.1587582E-003f);
      L10[5, 1] = new ComplexFloat(+1.0553084E-002f, +3.9861933E-003f);
      L10[5, 2] = new ComplexFloat(+1.4900585E-002f, +9.5517949E-004f);
      L10[5, 3] = new ComplexFloat(+1.4574245E-002f, -1.1129242E-003f);
      L10[5, 4] = new ComplexFloat(-9.0776628E-001f, -3.8281015E-002f);
      L10[5, 5] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L10[6, 0] = new ComplexFloat(+1.1163789E-002f, +5.1884795E-003f);
      L10[6, 1] = new ComplexFloat(+1.1597112E-002f, +3.8999115E-003f);
      L10[6, 2] = new ComplexFloat(+1.6188452E-002f, +4.4138654E-004f);
      L10[6, 3] = new ComplexFloat(+1.5752309E-002f, -1.7871732E-003f);
      L10[6, 4] = new ComplexFloat(+1.4568519E-002f, -5.3100094E-003f);
      L10[6, 5] = new ComplexFloat(-9.1612446E-001f, -3.9858108E-002f);
      L10[6, 6] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L10[7, 0] = new ComplexFloat(+1.2250407E-002f, +5.1493111E-003f);
      L10[7, 1] = new ComplexFloat(+1.2666180E-002f, +3.7419578E-003f);
      L10[7, 2] = new ComplexFloat(+1.7480233E-002f, -1.7281679E-004f);
      L10[7, 3] = new ComplexFloat(+1.6920428E-002f, -2.5592884E-003f);
      L10[7, 4] = new ComplexFloat(+1.5502251E-002f, -6.3119298E-003f);
      L10[7, 5] = new ComplexFloat(+1.0175586E-002f, -6.2706520E-003f);
      L10[7, 6] = new ComplexFloat(-9.2129653E-001f, -4.0086723E-002f);
      L10[7, 7] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L10[8, 0] = new ComplexFloat(+1.3361099E-002f, +5.0636594E-003f);
      L10[8, 1] = new ComplexFloat(+1.3753926E-002f, +3.5354454E-003f);
      L10[8, 2] = new ComplexFloat(+1.8776835E-002f, -8.5571402E-004f);
      L10[8, 3] = new ComplexFloat(+1.8083822E-002f, -3.3986502E-003f);
      L10[8, 4] = new ComplexFloat(+1.6416076E-002f, -7.3767089E-003f);
      L10[8, 5] = new ComplexFloat(+1.0693868E-002f, -7.1281839E-003f);
      L10[8, 6] = new ComplexFloat(+8.4803223E-003f, -7.7622936E-003f);
      L10[8, 7] = new ComplexFloat(-9.2544568E-001f, -3.8329752E-002f);
      L10[8, 8] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      L10[9, 0] = new ComplexFloat(+1.4514517E-002f, +4.9086455E-003f);
      L10[9, 1] = new ComplexFloat(+1.4876264E-002f, +3.2557272E-003f);
      L10[9, 2] = new ComplexFloat(+2.0088847E-002f, -1.6446645E-003f);
      L10[9, 3] = new ComplexFloat(+1.9247642E-002f, -4.3429207E-003f);
      L10[9, 4] = new ComplexFloat(+1.7306259E-002f, -8.5413384E-003f);
      L10[9, 5] = new ComplexFloat(+1.1183742E-002f, -8.0532599E-003f);
      L10[9, 6] = new ComplexFloat(+8.7870452E-003f, -8.6470170E-003f);
      L10[9, 7] = new ComplexFloat(+6.7700213E-003f, -5.2124680E-003f);
      L10[9, 8] = new ComplexFloat(-9.2836000E-001f, -3.8752385E-002f);
      L10[9, 9] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      D10 = new ComplexFloatVector(10);
      D10[0] = new ComplexFloat(+9.9009901E-002f, -9.9009901E-003f);
      D10[1] = new ComplexFloat(+6.8010260E-002f, +5.2693294E-002f);
      D10[2] = new ComplexFloat(+6.8503012E-002f, +5.2264825E-002f);
      D10[3] = new ComplexFloat(+6.8598237E-002f, +5.1618595E-002f);
      D10[4] = new ComplexFloat(+6.8466983E-002f, +5.0945485E-002f);
      D10[5] = new ComplexFloat(+6.8034270E-002f, +5.0441605E-002f);
      D10[6] = new ComplexFloat(+6.7730052E-002f, +5.0175369E-002f);
      D10[7] = new ComplexFloat(+6.7391349E-002f, +5.0080104E-002f);
      D10[8] = new ComplexFloat(+6.7234262E-002f, +4.9912171E-002f);
      D10[9] = new ComplexFloat(+6.7024327E-002f, +4.9751098E-002f);

      U10 = new ComplexFloatMatrix(10);
      U10[0, 0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U10[0, 1] = new ComplexFloat(-1.8811881E-001f, -8.8118812E-001f);
      U10[1, 1] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U10[0, 2] = new ComplexFloat(-3.0868450E-001f, -8.2968120E-001f);
      U10[1, 2] = new ComplexFloat(+8.1788201E-002f, -1.3059729E-001f);
      U10[2, 2] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U10[0, 3] = new ComplexFloat(-6.9271338E-001f, -4.1101317E-001f);
      U10[1, 3] = new ComplexFloat(+3.0656677E-001f, -4.4856765E-001f);
      U10[2, 3] = new ComplexFloat(+7.8629842E-002f, -1.3672690E-001f);
      U10[3, 3] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U10[0, 4] = new ComplexFloat(-7.5308973E-001f, -1.7764936E-001f);
      U10[1, 4] = new ComplexFloat(-2.1811893E-002f, -2.3257783E-001f);
      U10[2, 4] = new ComplexFloat(+3.0081682E-001f, -4.5300731E-001f);
      U10[3, 4] = new ComplexFloat(+7.3373192E-002f, -1.4180544E-001f);
      U10[4, 4] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U10[0, 5] = new ComplexFloat(-6.6968846E-001f, +1.6997563E-001f);
      U10[1, 5] = new ComplexFloat(-1.4411312E-001f, -3.0897730E-001f);
      U10[2, 5] = new ComplexFloat(-3.1145914E-002f, -2.3117177E-001f);
      U10[3, 5] = new ComplexFloat(+2.9376277E-001f, -4.5405633E-001f);
      U10[4, 5] = new ComplexFloat(+6.6435695E-002f, -1.4363825E-001f);
      U10[5, 5] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U10[0, 6] = new ComplexFloat(-3.6546783E-001f, +1.3495818E-001f);
      U10[1, 6] = new ComplexFloat(-3.3276275E-001f, +6.1455619E-002f);
      U10[2, 6] = new ComplexFloat(-1.4928934E-001f, -3.0660365E-001f);
      U10[3, 6] = new ComplexFloat(-3.6720508E-002f, -2.2950990E-001f);
      U10[4, 6] = new ComplexFloat(+2.8936799E-001f, -4.5408893E-001f);
      U10[5, 6] = new ComplexFloat(+6.2044535E-002f, -1.4415916E-001f);
      U10[6, 6] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U10[0, 7] = new ComplexFloat(-2.2796156E-001f, +2.1789305E-001f);
      U10[1, 7] = new ComplexFloat(-1.4794186E-001f, -5.5572852E-002f);
      U10[2, 7] = new ComplexFloat(-3.3492680E-001f, +6.5840476E-002f);
      U10[3, 7] = new ComplexFloat(-1.5249085E-001f, -3.0276392E-001f);
      U10[4, 7] = new ComplexFloat(-4.0507028E-002f, -2.2608317E-001f);
      U10[5, 7] = new ComplexFloat(+2.8587453E-001f, -4.5245103E-001f);
      U10[6, 7] = new ComplexFloat(+5.8369087E-002f, -1.4290942E-001f);
      U10[7, 7] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U10[0, 8] = new ComplexFloat(-1.8901586E-001f, +3.4805079E-002f);
      U10[1, 8] = new ComplexFloat(-5.2426683E-002f, +1.9340427E-001f);
      U10[2, 8] = new ComplexFloat(-1.4964696E-001f, -5.4033437E-002f);
      U10[3, 8] = new ComplexFloat(-3.3763728E-001f, +6.7573088E-002f);
      U10[4, 8] = new ComplexFloat(-1.5560000E-001f, -3.0169126E-001f);
      U10[5, 8] = new ComplexFloat(-4.3805054E-002f, -2.2544210E-001f);
      U10[6, 8] = new ComplexFloat(+2.8335018E-001f, -4.5271747E-001f);
      U10[7, 8] = new ComplexFloat(+5.5874343E-002f, -1.4345634E-001f);
      U10[8, 8] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      U10[0, 9] = new ComplexFloat(-1.9701952E-001f, +6.3155749E-002f);
      U10[1, 9] = new ComplexFloat(-4.2642564E-003f, -1.6090427E-002f);
      U10[2, 9] = new ComplexFloat(-5.3607239E-002f, +1.9546918E-001f);
      U10[3, 9] = new ComplexFloat(-1.5130367E-001f, -5.1953666E-002f);
      U10[4, 9] = new ComplexFloat(-3.4040569E-001f, +7.0063213E-002f);
      U10[5, 9] = new ComplexFloat(-1.5894822E-001f, -2.9987956E-001f);
      U10[6, 9] = new ComplexFloat(-4.7450414E-002f, -2.2408765E-001f);
      U10[7, 9] = new ComplexFloat(+2.8041710E-001f, -4.5254539E-001f);
      U10[8, 9] = new ComplexFloat(+5.2922147E-002f, -1.4361015E-001f);
      U10[9, 9] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);

      Det10 = new ComplexFloat(+3.6568548E+010f, +2.4768517E+010f);

      I10 = new ComplexFloatMatrix(10);
      I10[0, 0] = new ComplexFloat(+6.7024327E-002f, +4.9751098E-002f);
      I10[0, 1] = new ComplexFloat(+1.0691834E-002f, -6.9924390E-003f);
      I10[0, 2] = new ComplexFloat(+4.1309398E-002f, -1.6380491E-002f);
      I10[0, 3] = new ComplexFloat(+7.9682744E-003f, -1.7380034E-002f);
      I10[0, 4] = new ComplexFloat(+4.2659401E-003f, -2.8007075E-002f);
      I10[0, 5] = new ComplexFloat(-2.6301184E-002f, -1.2239617E-002f);
      I10[0, 6] = new ComplexFloat(-7.5562748E-003f, -1.1009683E-002f);
      I10[0, 7] = new ComplexFloat(-1.3317795E-002f, +1.0434171E-002f);
      I10[0, 8] = new ComplexFloat(+5.1470750E-004f, -1.2906015E-003f);
      I10[0, 9] = new ComplexFloat(-1.6347168E-002f, -5.5689657E-003f);
      I10[1, 0] = new ComplexFloat(-6.0294731E-002f, -4.8784282E-002f);
      I10[1, 1] = new ComplexFloat(+5.7037418E-002f, +5.5989338E-002f);
      I10[1, 2] = new ComplexFloat(-2.8067888E-002f, +6.7497836E-003f);
      I10[1, 3] = new ComplexFloat(+3.3576008E-002f, -4.6936404E-004f);
      I10[1, 4] = new ComplexFloat(+3.2614353E-003f, +8.4914935E-003f);
      I10[1, 5] = new ComplexFloat(+2.8539068E-002f, -1.5668319E-002f);
      I10[1, 6] = new ComplexFloat(-1.9485222E-002f, -1.7952100E-003f);
      I10[1, 7] = new ComplexFloat(+5.4035811E-003f, -2.0272674E-002f);
      I10[1, 8] = new ComplexFloat(-1.3705944E-002f, +1.1564861E-002f);
      I10[1, 9] = new ComplexFloat(+5.1470750E-004f, -1.2906015E-003f);
      I10[2, 0] = new ComplexFloat(+7.1308213E-004f, -1.2546164E-005f);
      I10[2, 1] = new ComplexFloat(-6.0272601E-002f, -4.8871146E-002f);
      I10[2, 2] = new ComplexFloat(+5.7219842E-002f, +5.5680641E-002f);
      I10[2, 3] = new ComplexFloat(-2.8112753E-002f, +6.6173592E-003f);
      I10[2, 4] = new ComplexFloat(+3.3454600E-002f, -6.5413224E-004f);
      I10[2, 5] = new ComplexFloat(+3.0216929E-003f, +8.5724569E-003f);
      I10[2, 6] = new ComplexFloat(+2.8435161E-002f, -1.5684889E-002f);
      I10[2, 7] = new ComplexFloat(-1.9514358E-002f, -1.6393606E-003f);
      I10[2, 8] = new ComplexFloat(+5.4035811E-003f, -2.0272674E-002f);
      I10[2, 9] = new ComplexFloat(-1.3317795E-002f, +1.0434171E-002f);
      I10[3, 0] = new ComplexFloat(+1.0191444E-003f, -1.4239535E-004f);
      I10[3, 1] = new ComplexFloat(+9.9108704E-004f, -2.5251613E-004f);
      I10[3, 2] = new ComplexFloat(-5.9819166E-002f, -4.9484148E-002f);
      I10[3, 3] = new ComplexFloat(+5.7389952E-002f, +5.5227507E-002f);
      I10[3, 4] = new ComplexFloat(-2.8106424E-002f, +6.0757008E-003f);
      I10[3, 5] = new ComplexFloat(+3.3259014E-002f, -8.2858379E-004f);
      I10[3, 6] = new ComplexFloat(+2.9250084E-003f, +8.3171088E-003f);
      I10[3, 7] = new ComplexFloat(+2.8435161E-002f, -1.5684889E-002f);
      I10[3, 8] = new ComplexFloat(-1.9485222E-002f, -1.7952100E-003f);
      I10[3, 9] = new ComplexFloat(-7.5562748E-003f, -1.1009683E-002f);
      I10[4, 0] = new ComplexFloat(+1.1502413E-003f, +1.6639121E-005f);
      I10[4, 1] = new ComplexFloat(+1.1380402E-003f, -1.0980979E-004f);
      I10[4, 2] = new ComplexFloat(+1.3977289E-003f, -5.8000250E-004f);
      I10[4, 3] = new ComplexFloat(-5.9700112E-002f, -4.9533948E-002f);
      I10[4, 4] = new ComplexFloat(+5.7405368E-002f, +5.5059022E-002f);
      I10[4, 5] = new ComplexFloat(-2.8274330E-002f, +6.2766221E-003f);
      I10[4, 6] = new ComplexFloat(+3.3259014E-002f, -8.2858379E-004f);
      I10[4, 7] = new ComplexFloat(+3.0216929E-003f, +8.5724569E-003f);
      I10[4, 8] = new ComplexFloat(+2.8539068E-002f, -1.5668319E-002f);
      I10[4, 9] = new ComplexFloat(-2.6301184E-002f, -1.2239617E-002f);
      I10[5, 0] = new ComplexFloat(+1.5848813E-003f, +2.8852793E-004f);
      I10[5, 1] = new ComplexFloat(+1.5972212E-003f, +1.1105891E-004f);
      I10[5, 2] = new ComplexFloat(+2.0644546E-003f, -4.7842310E-004f);
      I10[5, 3] = new ComplexFloat(+1.9356717E-003f, -7.4622243E-004f);
      I10[5, 4] = new ComplexFloat(-5.9306111E-002f, -4.9933722E-002f);
      I10[5, 5] = new ComplexFloat(+5.7405368E-002f, +5.5059022E-002f);
      I10[5, 6] = new ComplexFloat(-2.8106424E-002f, +6.0757008E-003f);
      I10[5, 7] = new ComplexFloat(+3.3454600E-002f, -6.5413224E-004f);
      I10[5, 8] = new ComplexFloat(+3.2614353E-003f, +8.4914935E-003f);
      I10[5, 9] = new ComplexFloat(+4.2659401E-003f, -2.8007075E-002f);
      I10[6, 0] = new ComplexFloat(+1.5061253E-003f, +6.6650996E-004f);
      I10[6, 1] = new ComplexFloat(+1.5609115E-003f, +4.9307536E-004f);
      I10[6, 2] = new ComplexFloat(+2.1665459E-003f, +1.9121555E-005f);
      I10[6, 3] = new ComplexFloat(+2.1027094E-003f, -2.7790747E-004f);
      I10[6, 4] = new ComplexFloat(+1.9356717E-003f, -7.4622243E-004f);
      I10[6, 5] = new ComplexFloat(-5.9700112E-002f, -4.9533948E-002f);
      I10[6, 6] = new ComplexFloat(+5.7389952E-002f, +5.5227507E-002f);
      I10[6, 7] = new ComplexFloat(-2.8112753E-002f, +6.6173592E-003f);
      I10[6, 8] = new ComplexFloat(+3.3576008E-002f, -4.6936404E-004f);
      I10[6, 9] = new ComplexFloat(+7.9682744E-003f, -1.7380034E-002f);
      I10[7, 0] = new ComplexFloat(+1.4282653E-003f, +8.8920966E-004f);
      I10[7, 1] = new ComplexFloat(+1.5084436E-003f, +7.2160481E-004f);
      I10[7, 2] = new ComplexFloat(+2.1887064E-003f, +3.2867753E-004f);
      I10[7, 3] = new ComplexFloat(+2.1665459E-003f, +1.9121555E-005f);
      I10[7, 4] = new ComplexFloat(+2.0644546E-003f, -4.7842310E-004f);
      I10[7, 5] = new ComplexFloat(+1.3977289E-003f, -5.8000250E-004f);
      I10[7, 6] = new ComplexFloat(-5.9819166E-002f, -4.9484148E-002f);
      I10[7, 7] = new ComplexFloat(+5.7219842E-002f, +5.5680641E-002f);
      I10[7, 8] = new ComplexFloat(-2.8067888E-002f, +6.7497836E-003f);
      I10[7, 9] = new ComplexFloat(+4.1309398E-002f, -1.6380491E-002f);
      I10[8, 0] = new ComplexFloat(+8.3509562E-004f, +9.5832342E-004f);
      I10[8, 1] = new ComplexFloat(+9.3009336E-004f, +8.5497971E-004f);
      I10[8, 2] = new ComplexFloat(+1.5084436E-003f, +7.2160481E-004f);
      I10[8, 3] = new ComplexFloat(+1.5609115E-003f, +4.9307536E-004f);
      I10[8, 4] = new ComplexFloat(+1.5972212E-003f, +1.1105891E-004f);
      I10[8, 5] = new ComplexFloat(+1.1380402E-003f, -1.0980979E-004f);
      I10[8, 6] = new ComplexFloat(+9.9108704E-004f, -2.5251613E-004f);
      I10[8, 7] = new ComplexFloat(-6.0272601E-002f, -4.8871146E-002f);
      I10[8, 8] = new ComplexFloat(+5.7037418E-002f, +5.5989338E-002f);
      I10[8, 9] = new ComplexFloat(+1.0691834E-002f, -6.9924390E-003f);
      I10[9, 0] = new ComplexFloat(+7.2861524E-004f, +1.0511118E-003f);
      I10[9, 1] = new ComplexFloat(+8.3509562E-004f, +9.5832342E-004f);
      I10[9, 2] = new ComplexFloat(+1.4282653E-003f, +8.8920966E-004f);
      I10[9, 3] = new ComplexFloat(+1.5061253E-003f, +6.6650996E-004f);
      I10[9, 4] = new ComplexFloat(+1.5848813E-003f, +2.8852793E-004f);
      I10[9, 5] = new ComplexFloat(+1.1502413E-003f, +1.6639121E-005f);
      I10[9, 6] = new ComplexFloat(+1.0191444E-003f, -1.4239535E-004f);
      I10[9, 7] = new ComplexFloat(+7.1308213E-004f, -1.2546164E-005f);
      I10[9, 8] = new ComplexFloat(-6.0294731E-002f, -4.8784282E-002f);
      I10[9, 9] = new ComplexFloat(+6.7024327E-002f, +4.9751098E-002f);

      X10 = new ComplexFloatVector(10);
      X10[0] = new ComplexFloat(+1.0000000E+000f, +0.0000000E+000f);
      X10[1] = new ComplexFloat(+2.0000000E+000f, +0.0000000E+000f);
      X10[2] = new ComplexFloat(+3.0000000E+000f, +0.0000000E+000f);
      X10[3] = new ComplexFloat(+4.0000000E+000f, +0.0000000E+000f);
      X10[4] = new ComplexFloat(+5.0000000E+000f, +0.0000000E+000f);
      X10[5] = new ComplexFloat(+6.0000000E+000f, +0.0000000E+000f);
      X10[6] = new ComplexFloat(+7.0000000E+000f, +0.0000000E+000f);
      X10[7] = new ComplexFloat(+8.0000000E+000f, +0.0000000E+000f);
      X10[8] = new ComplexFloat(+9.0000000E+000f, +0.0000000E+000f);
      X10[9] = new ComplexFloat(+1.0000000E+001f, +0.0000000E+000f);

      Y10 = new ComplexFloatVector(10);
      Y10[0] = new ComplexFloat(+6.4000000E+001f, +1.4200000E+002f);
      Y10[1] = new ComplexFloat(+8.1000000E+001f, +1.6400000E+002f);
      Y10[2] = new ComplexFloat(+1.0500000E+002f, +1.7500000E+002f);
      Y10[3] = new ComplexFloat(+1.3500000E+002f, +1.7400000E+002f);
      Y10[4] = new ComplexFloat(+1.7000000E+002f, +1.6000000E+002f);
      Y10[5] = new ComplexFloat(+2.0900000E+002f, +1.7600000E+002f);
      Y10[6] = new ComplexFloat(+2.5100000E+002f, +1.9200000E+002f);
      Y10[7] = new ComplexFloat(+2.9500000E+002f, +1.9700000E+002f);
      Y10[8] = new ComplexFloat(+3.4000000E+002f, +1.3500000E+002f);
      Y10[9] = new ComplexFloat(+3.8500000E+002f, +5.5000000E+001f);

      // Tolerances
      Tolerance1 = 1.000E-06f;
      Tolerance2 = 2.000E-06f;
      Tolerance3 = 1.000E-06f;
      Tolerance4 = 1.000E-05f;
      Tolerance5 = 1.000E-05f;
      Tolerance10 = 5.000E-05f;
    }
    public void SingularityPropertyTest2()
    {
      ComplexFloatVector LC = new ComplexFloatVector(4);
      LC[0] = new ComplexFloat(4.0f);
      LC[1] = new ComplexFloat(2.0f);
      LC[2] = new ComplexFloat(1.0f);
      LC[3] = new ComplexFloat(0.0f);

      ComplexFloatVector TR = new ComplexFloatVector(4);
      TR[0] = new ComplexFloat(4.0f);
      TR[1] = new ComplexFloat(8.0f);
      TR[2] = new ComplexFloat(2.0f);
      TR[3] = new ComplexFloat(1.0f);

      ComplexFloatLevinson cfl = new ComplexFloatLevinson(LC,TR);
      Assert.IsTrue(cfl.IsSingular);
    }
 public void FirstElementTestforStaticSolveVector()
 {
   ComplexFloatVector cfv = new ComplexFloatVector(3, 1.0f);
   ComplexFloatVector X = ComplexFloatLevinson.Solve(cfv, TR3, Y3);
 }
 public void ZeroVectorLengthTestforStaticSolveVector()
 {
   ComplexFloatVector LC = new ComplexFloatVector(1);
   LC.RemoveAt(0);
   ComplexFloatVector X = ComplexFloatLevinson.Solve(LC, TR10, Y10);
 }
 public void FirstElementTestforStaticInverse()
 {
   ComplexFloatVector cfv = new ComplexFloatVector(3, 1.0f);
   ComplexFloatMatrix X = ComplexFloatLevinson.Inverse(cfv, TR3);
 }
 public void SingularTestforStaticSolveVector()
 {
   ComplexFloatVector cfv = new ComplexFloatVector(3, 1.0f);
   ComplexFloatVector X = ComplexFloatLevinson.Solve(cfv, cfv, Y3);
 }
 public void ZeroLengthVectorTestsforConstructor1()
 {
   ComplexFloatVector cfv = new ComplexFloatVector(1);
   cfv.RemoveAt(0);
   ComplexFloatLevinson cfl = new ComplexFloatLevinson(cfv, cfv);
 }
 public void FirstElementTestforStaticSolveMatrix()
 {
   ComplexFloatVector cfv = new ComplexFloatVector(3, 1.0f);
   ComplexFloatMatrix X = ComplexFloatLevinson.Solve(cfv, TR3, ComplexFloatMatrix.CreateIdentity(3));
 }
Exemplo n.º 39
0
        /// <summary>Performs the QR factorization.</summary>
        protected override void InternalCompute()
        {
            int m = matrix.Rows;
            int n = matrix.Columns;

#if MANAGED
            int minmn = m < n ? m : n;
            r_ = new ComplexFloatMatrix(matrix); // create a copy
            var u = new ComplexFloatVector[minmn];
            for (int i = 0; i < minmn; i++)
            {
                u[i] = Householder.GenerateColumn(r_, i, m - 1, i);
                Householder.UA(u[i], r_, i, m - 1, i + 1, n - 1);
            }
            q_ = ComplexFloatMatrix.CreateIdentity(m);
            for (int i = minmn - 1; i >= 0; i--)
            {
                Householder.UA(u[i], q_, i, m - 1, i, m - 1);
            }
#else
            qr      = ComplexFloatMatrix.ToLinearComplexArray(matrix);
            jpvt    = new int[n];
            jpvt[0] = 1;
            Lapack.Geqp3.Compute(m, n, qr, m, jpvt, out tau);
            r_ = new ComplexFloatMatrix(m, n);
            // Populate R

            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (i <= j)
                    {
                        r_.data[j * m + i] = qr[(jpvt[j] - 1) * m + i];
                    }
                    else
                    {
                        r_.data[j * m + i] = ComplexFloat.Zero;
                    }
                }
            }

            q_ = new ComplexFloatMatrix(m, m);
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    if (j < n)
                    {
                        q_.data[j * m + i] = qr[j * m + i];
                    }
                    else
                    {
                        q_.data[j * m + i] = ComplexFloat.Zero;
                    }
                }
            }
            if (m < n)
            {
                Lapack.Ungqr.Compute(m, m, m, q_.data, m, tau);
            }
            else
            {
                Lapack.Ungqr.Compute(m, m, n, q_.data, m, tau);
            }
#endif
            for (int i = 0; i < m; i++)
            {
                if (q_[i, i] == 0)
                {
                    isFullRank = false;
                }
            }
        }
 public void ZeroVectorLengthTestforStaticInverse()
 {
   ComplexFloatVector LC = new ComplexFloatVector(1);
   LC.RemoveAt(0);
   ComplexFloatMatrix X = ComplexFloatLevinson.Inverse(LC, LC);
 }
Exemplo n.º 41
0
        /// <summary>
        /// Invert a symmetric square Toeplitz matrix.
        /// </summary>
        /// <param name="T">The left-most column of the symmetric Toeplitz matrix.</param>
        /// <returns>The inverse matrix.</returns>
        /// <exception cref="ArgumentNullException">
        /// <B>T</B> is a null reference.
        /// </exception>
        /// <exception cref="RankException">
        /// The length of <B>T</B> must be greater than zero.
        /// </exception>
        /// <exception cref="SingularMatrixException">
        /// The Toeplitz matrix or one of the the leading sub-matrices is singular.
        /// </exception>
        /// <remarks>
        /// This static member combines the <b>UDL</b> decomposition and Trench's algorithm into a
        /// single algorithm. When compared to the non-static member it requires minimal data storage
        /// and suffers from no speed penalty.
        /// <para>
        /// Trench's algorithm requires <b>N</b> squared FLOPS, compared to <b>N</b> cubed FLOPS
        /// if we simply solved a linear Toeplitz system with a right-side identity matrix (<b>N</b> is the matrix order).
        /// </para>
        /// </remarks>
        public static ComplexFloatMatrix Inverse(IROComplexFloatVector T)
        {
            ComplexFloatMatrix X;

            // check parameters
            if (T == null)
            {
                throw new System.ArgumentNullException("T");
            }
            else if (T.Length < 1)
            {
                throw new System.RankException("The length of T must be greater than zero.");
            }
            else if (T.Length == 1)
            {
                X       = new ComplexFloatMatrix(1);
                X[0, 0] = ComplexFloat.One / T[0];
            }
            else
            {
                int          N = T.Length;
                ComplexFloat f, g;
                int          i, j, l, k, m, n;
                X = new ComplexFloatMatrix(N);

                // calculate the predictor coefficients
                ComplexFloatVector Y = ComplexFloatSymmetricLevinson.YuleWalker(T);

                // calculate gamma
                f = T[0];
                for (i = 1, j = 0; i < N; i++, j++)
                {
                    f += T[i] * Y[j];
                }
                g = ComplexFloat.One / f;

                // calculate first row of inverse
                X[0, 0] = g;
                for (i = 1, j = 0; i < N; i++, j++)
                {
                    X[0, i] = g * Y[j];
                }

                // calculate successive rows of upper wedge
                for (i = 0, j = 1, k = N - 2; i < N / 2; i++, j++, k--)
                {
                    for (l = j, m = i, n = N - 1 - j; l < N - j; l++, m++, n--)
                    {
                        X[j, l] = X[i, m] + g * (Y[i] * Y[m] - Y[k] * Y[n]);
                    }
                }

                // this is symmetric matrix ...
                for (i = 0; i <= N / 2; i++)
                {
                    for (j = i + 1; j < N - i; j++)
                    {
                        X[j, i] = X[i, j];
                    }
                }

                // and a persymmetric matrix.
                for (i = 0, j = N - 1; i < N; i++, j--)
                {
                    for (k = 0, l = N - 1; k < j; k++, l--)
                    {
                        X[l, j] = X[i, k];
                    }
                }
            }

            return(X);
        }
 public void SingularTestforStaticInverse()
 {
   ComplexFloatVector cfv = new ComplexFloatVector(3, 1.0f);
   ComplexFloatMatrix X = ComplexFloatLevinson.Inverse(cfv, cfv);
 }
 public void OperatorMultiplyNullMatrixVector()
 {
   ComplexFloatMatrix a = null;
   ComplexFloatVector b = new ComplexFloatVector(2, 2.0f);
   ComplexFloatVector c = a * b;
 }
 public void FirstElementTestforConstructor1()
 {
   ComplexFloatVector cfv = new ComplexFloatVector(3, ComplexFloat.One);
   ComplexFloatLevinson cfl = new ComplexFloatLevinson(LC3, cfv);
 }
 public void StaticMultiplyMatrixVector()
 {
   ComplexFloatMatrix a = new ComplexFloatMatrix(2);
   a[0,0] = new ComplexFloat(1);
   a[0,1] = new ComplexFloat(2);
   a[1,0] = new ComplexFloat(3);
   a[1,1] = new ComplexFloat(4);
   ComplexFloatVector b = new ComplexFloatVector(2, 2.0f);
   ComplexFloatVector c = ComplexFloatMatrix.Multiply(a,b);
   Assert.AreEqual(c[0],new ComplexFloat(6));
   Assert.AreEqual(c[1],new ComplexFloat(14));
 }