public void GetVectorMemberTest()
 {
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(T5);
   FloatVector TT = fsl.GetVector();
   Assert.IsTrue(T5.Equals(TT));
 }
 public void ZeroLengthVectorTestsforConstructor1()
 {
   FloatVector dv = new FloatVector(1, 0.0f);
   dv.RemoveAt(0);
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(dv);
 }
 public void ZeroLengthVectorTestsforConstructor2()
 {
   float[] dv = new float[0];
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(dv);
 }
 public void NullParameterTestforConstructor1()
 {
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(null as FloatVector);
 }
 public void NullParameterTestforConstructor2()
 {
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(null as float[]);
 }
    public void DecompositionTest10()
    {
      int i, j;
      float e, me;
      FloatSymmetricLevinson fsl = new FloatSymmetricLevinson(T10);
      FloatMatrix U = fsl.U;
      FloatMatrix D = fsl.D;
      FloatMatrix L = fsl.L;

      // check U is the transpose of L
      Assert.IsTrue(U.Equals(L.GetTranspose()));

      // check the lower triangle
      me = 0.0f;
      for (i = 0; i < fsl.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.0f;
      for (i = 0; i < fsl.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()
 {
   FloatSymmetricLevinson fsl = new FloatSymmetricLevinson(T10);
   Assert.IsFalse(fsl.IsSingular);
 }
 public void NullParameterTestforSolveMatrix()
 {
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(T10);
   FloatMatrix X = fsl.Solve(null as FloatMatrix);
 }
 public void MismatchRowsTestforSolveMatrix()
 {
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(T10);
   FloatMatrix X = fsl.Solve(I5);
 }
 public void MismatchRowsTestforSolveVector()
 {
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(T10);
   FloatVector X = fsl.Solve(X5);
 }
 public void SolveVector10()
 {
   int i;
   float e, me;
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(T10);
   FloatVector X = fsl.Solve(Y10);
   
   // determine the maximum error
   me = 0.0f;
   for (i = 0; i < fsl.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()
 {
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(T10);
   FloatVector X = fsl.Solve(null as FloatVector);
 }
    public void GetDeterminantMethodTest10()
    {
      // calculate determinant from diagonal
      FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(T10);

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

      FloatSymmetricLevinson fsl = new FloatSymmetricLevinson(T);
      Assert.IsTrue(fsl.IsSingular);
    }
 public void GetMatrixMemberTest()
 {
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(T5);
   FloatMatrix fsldm = fsl.GetMatrix();
   for (int row = 0; row < T5.Length; row++)
   {
     for (int column = 0; column < T5.Length; column++)
     {
       if (column < row)
       {
         Assert.IsTrue(fsldm[row, column] == T5[row - column]);
       }
       else
       {
         Assert.IsTrue(fsldm[row, column] == T5[column - row]);
       }
     }
   }
 }
    public void SolveMatrix5()
    {
      int i, j;
      float e, me;
      FloatSymmetricLevinson fsl = new FloatSymmetricLevinson(T5);

      // check inverse
      FloatMatrix I = fsl.Solve(FloatMatrix.CreateIdentity(5));
      me = 0.0f;
      for (i = 0; i < fsl.Order; i++)
      {
        for (j = 0; j < fsl.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()
 {
   FloatSymmetricLevinson  fsl = new FloatSymmetricLevinson(T5);
   Assert.IsTrue(fsl.Order == 5);
 }
    public void GetInverse10()
    {
      int i, j;
      float e, me;
      FloatSymmetricLevinson fsl = new FloatSymmetricLevinson(T10);

      // check inverse
      FloatMatrix I = fsl.GetInverse();
      me = 0.0f;
      for (i = 0; i < fsl.Order; i++)
      {
        for (j = 0; j < fsl.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()
 {
   FloatSymmetricLevinson fsl = new FloatSymmetricLevinson(T5);
   Assert.IsTrue(fsl.IsPositiveDefinite);
 }
 public void PositveDefinitePropertyTest()
 {
   FloatSymmetricLevinson fsl = new FloatSymmetricLevinson(1.0f, 2.0f, 3.0f, 4.0f, 5.0f);
   Assert.IsFalse(fsl.IsPositiveDefinite);
 }