public void GetLeftColumnTest()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC5, TR5);
   ComplexDoubleVector LC = cdl.GetLeftColumn();
   Assert.IsTrue(LC5.Equals(LC));
 }
 public void MismatchVectorLengthTestsforConstructor1()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC2, TR3);
 }
 public void FirstElementTestforConstructor1()
 {
   ComplexDoubleVector cdv = new ComplexDoubleVector(3, Complex.One);
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC3, cdv);
 }
 public void NullParameterTestforConstructor2()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC5, null as ComplexDoubleVector);
 }
 public void ZeroLengthVectorTestsforConstructor1()
 {
   ComplexDoubleVector cdv = new ComplexDoubleVector(1);
   cdv.RemoveAt(0);
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(cdv, cdv);
 }
 public void OrderPropertyTest()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC5, TR5);
   Assert.IsTrue(cdl.Order == 5);
 }
    public void SingularityPropertyTest2()
    {
      ComplexDoubleVector LC = new ComplexDoubleVector(4);
      LC[0] = new Complex(4.0);
      LC[1] = new Complex(2.0);
      LC[2] = new Complex(1.0);
      LC[3] = new Complex(0.0);

      ComplexDoubleVector TR = new ComplexDoubleVector(4);
      TR[0] = new Complex(4.0);
      TR[1] = new Complex(8.0);
      TR[2] = new Complex(2.0);
      TR[3] = new Complex(1.0);

      ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC,TR);
      Assert.IsTrue(cdl.IsSingular);
    }
 public void MismatchRowsTestforSolveMatrix()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC10, TR10);
   ComplexDoubleMatrix X = cdl.Solve(I5);
 }
    public void SolveMatrix5()
    {
      int i, j;
      double e, me;
      ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC5, TR5);

      // check inverse
      ComplexDoubleMatrix I = cdl.Solve(ComplexDoubleMatrix.CreateIdentity(5));
      me = 0.0;
      for (i = 0; i < cdl.Order; i++)
      {
        for (j = 0; j < cdl.Order; j++)
        {
          e = ComplexMath.Absolute((I5[i, j] - I[i, j]) / I5[i, j]);
          if (e > me)
          {
            me = e;
          }
        }
      }
      Assert.IsTrue(me < Tolerance5, "Maximum Error = " + me.ToString());
    }
 public void SolveVector10()
 {
   int i;
   double e, me;
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC10, TR10);
   ComplexDoubleVector X = cdl.Solve(Y10);
   
   // determine the maximum error
   me = 0.0;
   for (i = 0; i < cdl.Order; i++)
   {
     e = ComplexMath.Absolute((X10[i] - X[i]) / X10[i]);
     if (e > me)
     {
       me = e;
     }
   }
   Assert.IsTrue(me < Tolerance10, "Maximum Error = " + me.ToString());
 }
 public void NullParameterTestforSolveMatrix()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC10, TR10);
   ComplexDoubleMatrix X = cdl.Solve(null as ComplexDoubleMatrix);
 }
 public void MismatchRowsTestforSolveVector()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC10, TR10);
   ComplexDoubleVector X = cdl.Solve(X5);
 }
 public void NullParameterTestforSolveVector()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC10, TR10);
   ComplexDoubleVector X = cdl.Solve(null as ComplexDoubleVector);
 }
    public void GetDeterminantMethodTest10()
    {
      // calculate determinant from diagonal
      ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC10, TR10);

      // check results match
      Double e = ComplexMath.Absolute((cdl.GetDeterminant() - Det10)/Det10);
      Assert.IsTrue(e < Tolerance10);
    }
 public void GetTopRowTest()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC5, TR5);
   ComplexDoubleVector TR = cdl.GetTopRow();
   Assert.IsTrue(TR5.Equals(TR));
 }
    public void GetInverse10()
    {
      int i, j;
      double e, me;
      ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC10, TR10);

      // check inverse
      ComplexDoubleMatrix I = cdl.GetInverse();
      me = 0.0;
      for (i = 0; i < cdl.Order; i++)
      {
        for (j = 0; j < cdl.Order; j++)
        {
          e = ComplexMath.Absolute((I10[i, j] - I[i, j]) / I10[i, j]);
          if (e > me)
          {
            me = e;
          }
        }
      }
      Assert.IsTrue(me < Tolerance10, "Maximum Error = " + me.ToString());
    }
 public void GetMatrixMemberTest()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC5, TR5);
   ComplexDoubleMatrix cdldm = cdl.GetMatrix();
   for (int row = 0; row < TR5.Length; row++)
   {
     for (int column = 0; column < TR5.Length; column++)
     {
       if (column < row)
       {
         Assert.IsTrue(cdldm[row, column] == LC5[row - column]);
       }
       else
       {
         Assert.IsTrue(cdldm[row, column] == TR5[column - row]);
       }
     }
   }
 }
 public void NullParameterTestforConstructor1()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(null as ComplexDoubleVector, TR5);
 }
    public void DecompositionTest3()
    {
      int i, j;
      double e, me;
      ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC3, TR3);
      ComplexDoubleMatrix U = cdl.U;
      ComplexDoubleMatrix D = cdl.D;
      ComplexDoubleMatrix L = cdl.L;
      
      // check the upper triangle
      me = 0.0;
      for (i = 0; i < cdl.Order; i++)
      {
        for (j = 0; j < cdl.Order; j++)
        {
          if (U3[i, j] != U[i, j])
          {
            e = ComplexMath.Absolute((U3[i, j] - U[i, j]) / U3[i, j]);
            if (e > me)
            {
              me = e;
            }
          }
        }
      }
      Assert.IsTrue(me < Tolerance3, "Maximum Error = " + me.ToString());

      // check the lower triangle
      me = 0.0;
      for (i = 0; i < cdl.Order; i++)
      {
        for (j = 0; j < cdl.Order; j++)
        {
          if (L3[i, j] != L[i, j])
          {
            e = ComplexMath.Absolute((L3[i, j] - L[i, j]) / L3[i, j]);
            if (e > me)
            {
              me = e;
            }
          }
        }
      }
      Assert.IsTrue(me < Tolerance3, "Maximum Error = " + me.ToString());

      // check the diagonal
      me = 0.0;
      for (i = 0; i < cdl.Order; i++)
      {
        e = ComplexMath.Absolute((D3[i] - D[i, i]) / D3[i]);
        if (e > me)
        {
          me = e;
        }
      }

      Assert.IsTrue(me < Tolerance3, "Maximum Error = " + me.ToString());
    }
 public void SingularityPropertyTest1()
 {
   ComplexDoubleLevinson cdl = new ComplexDoubleLevinson(LC4,TR4);
   Assert.IsFalse(cdl.IsSingular);
 }