public void GetVectorMemberTest()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T5);
   DoubleVector TT = dsl.GetVector();
   Assert.IsTrue(T5.Equals(TT));
 }
 public void ZeroLengthVectorTestsforConstructor1()
 {
   DoubleVector dv = new DoubleVector(1, 0.0);
   dv.RemoveAt(0);
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(dv);
 }
 public void ZeroLengthVectorTestsforConstructor2()
 {
   double[] dv = new double[0];
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(dv);
 }
 public void NullParameterTestforConstructor1()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(null as DoubleVector);
 }
 public void NullParameterTestforConstructor2()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(null as double[]);
 }
    public void DecompositionTest10()
    {
      int i, j;
      double e, me;
      DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T10);
      DoubleMatrix U = dsl.U;
      DoubleMatrix D = dsl.D;
      DoubleMatrix L = dsl.L;
      
      // check U is the transpose of L
      Assert.IsTrue(U.Equals(L.GetTranspose()));

      // check the lower triangle
      me = 0.0;
      for (i = 0; i < dsl.Order; i++)
      {
        for (j = 0; j <= i ; j++)
        {
          e = System.Math.Abs((A10[i, j] - L[i, j]) / A10[i, j]);
          if (e > me)
          {
            me = e;
          }
        }
      }
      Assert.IsTrue(me < Tolerance10, "Maximum Error = " + me.ToString());

      // check the diagonal
      me = 0.0;
      for (i = 0; i < dsl.Order; i++)
      {
        e = System.Math.Abs((D10[i] - D[i, i]) / D10[i]);
        if (e > me)
        {
          me = e;
        }
      }
      Assert.IsTrue(me < Tolerance10, "Maximum Error = " + me.ToString());
    }
 public void SingularityPropertyTest10()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T10);
   Assert.IsFalse(dsl.IsSingular);
 }
 public void NullParameterTestforSolveMatrix()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T10);
   DoubleMatrix X = dsl.Solve(null as DoubleMatrix);
 }
 public void MismatchRowsTestforSolveMatrix()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T10);
   DoubleMatrix X = dsl.Solve(I5);
 }
 public void MismatchRowsTestforSolveVector()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T10);
   DoubleVector X = dsl.Solve(X5);
 }
 public void SolveVector10()
 {
   int i;
   double e, me;
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T10);
   DoubleVector X = dsl.Solve(Y10);
   
   // determine the maximum error
   me = 0.0;
   for (i = 0; i < dsl.Order; i++)
   {
     e = System.Math.Abs((X10[i] - X[i]) / X10[i]);
     if (e > me)
     {
       me = e;
     }
   }
   Assert.IsTrue(me < Tolerance10, "Maximum Error = " + me.ToString());
 }
 public void NullParameterTestforSolveVector()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T10);
   DoubleVector X = dsl.Solve(null as DoubleVector);
 }
    public void GetDeterminantMethodTest10()
    {
      // calculate determinant from diagonal
      DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T10);

      // check results match
      Double e = System.Math.Abs( (dsl.GetDeterminant() - Det10)/Det10 );
      Assert.IsTrue(e < Tolerance10);
    }
    public void SingularityPropertyTest()
    {
      DoubleVector T = new DoubleVector(10);
      for (int i = 1; i < 10; i++)
      {
        T[i] = (double) (i + 1);
      }
      T[0] = -2.0;

      DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T);
      Assert.IsTrue(dsl.IsSingular);
    }
 public void GetMatrixMemberTest()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T5);
   DoubleMatrix dsldm = dsl.GetMatrix();
   for (int row = 0; row < T5.Length; row++)
   {
     for (int column = 0; column < T5.Length; column++)
     {
       if (column < row)
       {
         Assert.IsTrue(dsldm[row, column] == T5[row - column]);
       }
       else
       {
         Assert.IsTrue(dsldm[row, column] == T5[column - row]);
       }
     }
   }
 }
    public void SolveMatrix5()
    {
      int i, j;
      double e, me;
      DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T5);

      // check inverse
      DoubleMatrix I = dsl.Solve(DoubleMatrix.CreateIdentity(5));
      me = 0.0;
      for (i = 0; i < dsl.Order; i++)
      {
        for (j = 0; j < dsl.Order; j++)
        {
          e = System.Math.Abs((I5[i, j] - I[i, j]) / I5[i, j]);
          if (e > me)
          {
            me = e;
          }
        }
      }
      Assert.IsTrue(me < Tolerance5, "Maximum Error = " + me.ToString());
    }
 public void OrderPropertyTest()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T5);
   Assert.IsTrue(dsl.Order == 5);
 }
    public void GetInverse10()
    {
      int i, j;
      double e, me;
      DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T10);

      // check inverse
      DoubleMatrix I = dsl.GetInverse();
      me = 0.0;
      for (i = 0; i < dsl.Order; i++)
      {
        for (j = 0; j < dsl.Order; j++)
        {
          e = System.Math.Abs((I10[i, j] - I[i, j]) / I10[i, j]);
          if (e > me)
          {
            me = e;
          }
        }
      }
      Assert.IsTrue(me < Tolerance10, "Maximum Error = " + me.ToString());
    }
 public void PositveDefinitePropertyTest5()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(T5);
   Assert.IsTrue(dsl.IsPositiveDefinite);
 }
 public void PositveDefinitePropertyTest()
 {
   DoubleSymmetricLevinson dsl = new DoubleSymmetricLevinson(1.0, 2.0, 3.0, 4.0, 5.0);
   Assert.IsFalse(dsl.IsPositiveDefinite);
 }