"Original" open source math.net basic Math class library using C # computing matrix condition number

Source: Internet
Author: User
Tags rowcount

Total contents of this blog article category: http://www.cnblogs.com/asxinyu/p/4288836.html

Open source math.net basic Math Class library use total directory: http://www.cnblogs.com/asxinyu/p/4329737.html

The basic usage of math.net was introduced last month, which includes matrix, vector related operation, analytic data format, numerical integration, data statistic, correlation function, solving linear equation Group and random number generator. This month then dig deep into the various functions of the math.net, and the source code analysis, so that you can use the math.net in the. NET platform to easily develop mathematical calculations related, or can be quickly transplanted into their own system of the source (sometimes do not need all the functions, Only part of the function code is needed, today is the ability to compute the matrix condition number using C # in Math.net.

Matrix condition number of the concept of more difficult to understand, before learning linear algebra, but also more understanding, a long time no contact, also forget, so the theoretical part of the content of the encyclopedia, the need or to see the textbook is better. If it's too complicated, you can skip the call. But in order to maintain the integrity of the support, I still write it out.

This text address: http://www.cnblogs.com/asxinyu/p/4304307.html

1. What is a matrix condition number

The condition number of matrix A is equal to the product of norm of a and the inverse norm of a, namely cond (A) =‖a‖ ‖a^ (-1) ‖, corresponding to 3 kinds of norm of matrix, can define 3 kinds of condition number accordingly. The function cond (a,1), cond (a), or cond (a INF) is a measure of the morbid or not of a matrix, and the larger the condition number the more morbid The matrix. The condition number actually represents the sensitivity of the matrix calculation to the error. For the ax=b of linear equations, if the condition number of a is large, the small change of B can cause the large change of the solution x, and the numerical stability is poor. If the condition number of a is small, B has a slight change, the change of X is very small and the numerical stability is good. It can also indicate that B does not change, and a has a slight change in the condition of X.

The realization of 2.math.net matrix condition number

Math.net in the calculation of the matrix condition number is the same as the determinant and rank, directly used in the matrix decomposition algorithm using conditionnumber to obtain, as above http://www.cnblogs.com/asxinyu/p/ There is a Conditionnumber implementation in the 4304304.html code.

1  Public Override floatConditionnumber2 {3     Get4     {5         varTMP = Math.min (U.rowcount, VT. ColumnCount)-1;6         returnMath.Abs (s[0]) /Math.Abs (s[tmp]);7     }8}

Other processes are simpler and more similar, they are no longer explained. If you need to see the source code, it is important to use the situation.

3.math.net code that calculates the number of matrix conditions

The above process and principle is just easy to understand its implementation process, the following is a simple demonstration of the calculation of the matrix condition number in the math.net process, is directly called calculation.

1 //format Settings2 varFormatProvider =(CultureInfo) CultureInfo.InvariantCulture.Clone ();3FormatProvider.TextInfo.ListSeparator =" ";4 //Create a random matrix5 varMatrix =NewDensematrix (5);6 varRnd =NewRandom (1); 7  for(vari =0; I < Matrix. RowCount; i++)8 {9      for(varj =0; J < Matrix. ColumnCount; J + +)Ten     { OneMatrix[i, J] =Rnd. Nextdouble (); A     } - } -  theConsole.WriteLine (@"Initial Matrix"); -Console.WriteLine (Matrix. ToString ("#0.00\t", formatprovider)); - Console.WriteLine (); -  + //Conditions Condition Number -Console.WriteLine (@"Matrix Condition number"); + Console.WriteLine (Matrix. Conditionnumber ()); AConsole.WriteLine ();

The results are as follows:

1 Initial Matrix2Densematrix 5x5-Double3 0.25      0.11    0.47    0.77    0.664 0.43      0.35    0.94    0.10    0.645 0.03      0.25    0.32    0.99    0.686 0.65      0.28    0.62    0.70    0.707 0.95      0.09    0.16    0.38    0.808 9 Ten Matrix Condition number One 21.581238807809
4. Resources

Including source code and case can go to the official website to download, this series of articles in the directory of the first article: Http://www.cnblogs.com/asxinyu/p/4264638.html, there is an introduction. Because the source code is very big, if cannot find the corresponding case, can carry on the search, can find the corresponding code relatively quickly.

"Original" open source math.net basic Math class library using C # computing matrix condition number

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.