public void SolveVector5() { int i; float e, me; ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T5); ComplexFloatVector X = cdsl.Solve(Y5); // determine the maximum error me = 0.0f; for (i = 0; i < cdsl.Order; i++) { e = ComplexMath.Absolute((X5[i] - X[i]) / X5[i]); if (e > me) { me = e; } } Assert.IsTrue(me < Tolerance5, "Maximum Error = " + me.ToString()); }
public void NullParameterTestforSolveMatrix() { ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T5); ComplexFloatMatrix X = cdsl.Solve(null as ComplexFloatMatrix); }
public void NullParameterTestforSolveVector() { ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T5); ComplexFloatVector X = cdsl.Solve(null as ComplexFloatVector); }
public void MismatchRowsTestforSolveVector() { ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T4); ComplexFloatVector X = cdsl.Solve(X5); }
public void SingularityPropertyTest() { ComplexFloatVector T = new ComplexFloatVector(10); for (int i = 1; i < 10; i++) { T[i] = new ComplexFloat((float) (i + 1), (float) (i + 1)); } T[0] = new ComplexFloat(2.0f, 2.0f); ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T); Assert.IsTrue(cdsl.IsSingular); }
public void GetDeterminantMethodTest5() { // calculate determinant from diagonal ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T5); // check results match float e = ComplexMath.Absolute((cdsl.GetDeterminant() - Det5) / Det5); Assert.IsTrue(e < Tolerance5); }
public void DecompositionTest5() { int i, j; float e, me; ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T5); ComplexFloatMatrix U = cdsl.U; ComplexFloatMatrix D = cdsl.D; ComplexFloatMatrix L = cdsl.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 < cdsl.Order; i++) { for (j = 0; j <= i ; j++) { e = ComplexMath.Absolute((L5[i, j] - L[i, j]) / L5[i, j]); if (e > me) { me = e; } } } Assert.IsTrue(me < Tolerance5, "Maximum Error = " + me.ToString()); // check the diagonal me = 0.0f; for (i = 0; i < cdsl.Order; i++) { e = ComplexMath.Absolute((D5[i] - D[i, i]) / D5[i]); if (e > me) { me = e; } } Assert.IsTrue(me < Tolerance5, "Maximum Error = " + me.ToString()); }
public void GetInverse5() { int i, j; float e, me; ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T5); // check inverse ComplexFloatMatrix I = cdsl.GetInverse(); me = 0.0f; for (i = 0; i < cdsl.Order; i++) { for (j = 0; j < cdsl.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 GetMatrixMemberTest() { ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T5); ComplexFloatMatrix cdsldm = cdsl.GetMatrix(); for (int row = 0; row < T5.Length; row++) { for (int column = 0; column < T5.Length; column++) { if (column < row) { Assert.IsTrue(cdsldm[row, column] == T5[row - column]); } else { Assert.IsTrue(cdsldm[row, column] == T5[column - row]); } } } }
public void OrderPropertyTest() { ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T5); Assert.IsTrue(cdsl.Order == 5); }
public void GetVectorMemberTest() { ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T5); ComplexFloatVector TT = cdsl.GetVector(); Assert.IsTrue(T5.Equals(TT)); }
public void ZeroLengthVectorTestsforConstructor1() { ComplexFloatVector cdv = new ComplexFloatVector(1, 0.0f); cdv.RemoveAt(0); ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(cdv); }
public void NullParameterTestforConstructor() { ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(null as ComplexFloatVector); }
public void MismatchRowsTestforSolveMatrix() { ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T4); ComplexFloatMatrix X = cdsl.Solve(I5); }
public void SingularityPropertyTest5() { ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T5); Assert.IsFalse(cdsl.IsSingular); }
/// <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 SolveMatrix4() { int i, j; float e, me; ComplexFloatSymmetricLevinson cdsl = new ComplexFloatSymmetricLevinson(T4); // check inverse ComplexFloatMatrix I = cdsl.Solve(ComplexFloatMatrix.CreateIdentity(4)); me = 0.0f; for (i = 0; i < cdsl.Order; i++) { for (j = 0; j < cdsl.Order; j++) { e = ComplexMath.Absolute((I4[i, j] - I[i, j]) / I4[i, j]); if (e > me) { me = e; } } } Assert.IsTrue(me < Tolerance4, "Maximum Error = " + me.ToString()); }