# Determinant calculation (C #)

Source: Internet
Author: User

In recent days to learn advanced algebra teacher said to write a program to calculate the determinant of the results, idle to do nothing to simply write a bit.

Not much to say, on the code

`1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 6 namespaceNROW_CULMN7 {8     class Program9     {Ten          Public Static DoubleJlength =0; One         Static voidMain (string[] args) A         { -             //double[,] row_culmn = {{3, 1,-1, 1}, {1,-1, 1, 2}, {2, 1, 2,-1}, {1, 0, 2, 1,}}; -             //determinant two-dimensional array the             Double[,] row_culmn = {{1,4,9, -}, {4,9, -, -}, {9, -, -, \$}, { -, -, \$, the} }; -              -              -              +              for(inti =0; I <4; i++) -             { +                  for(intj =0; J <4; J + +) A                 { atConsole.Write (Row_culmn[i, J]. ToString () +"  "); -                 } - Console.WriteLine (); -             } - Console.WriteLine (); - Console.WriteLine (); in Console.WriteLine (); -             introw =0;//Line to  +             intRowup =1;//offset column to the right (relative row) -Jlength =math.sqrt (ROW_CULMN. Length); the  *              for(row =0; Row < Jlength-1; row++) \$             {Panax Notoginseng                 //The recursive algorithm calculates the determinant as the lower triangle is all 0. -VALUEROW_CULMN (refROW_CULMN,refrow, rowup); therowup++; +             } A             //the value of the calculated determinant double value cannot be equal to 0 by default otherwise all values are zero the             DoubleA =1; +              for(inti =0; i < jlength; i++) -             { \$ Console.WriteLine (Row_culmn[i, I]); \$A *=row_culmn[i, I]; -             } -             //formatted output theConsole.WriteLine (string. Format ("{0:f}", a)); - console.readline ();Wuyi  the         } -  Wu          Public Static voidVALUEROW_CULMN (ref Double[,] RC,ref intRowintrowup) -         { About             //Double jlength = math.sqrt (RC. Length); \$             DoubleK//coefficients multiplied by columns -             if(Rowup <jlength) -             { -K =-rc[rowup, row]/rc[row, row]; A                  for(intj =0; J < Jlength; J + +) +                 { theRc[rowup, j] + = Rc[row, j] *K; -                 } \$  the Console.WriteLine (); the Console.WriteLine (); the                  for(intm =0; M <4; m++) the                 { -                      for(intj =0; J <4; J + +) in                     { theConsole.Write (Rc[m, J]. ToString () +"  "); the                     } About Console.WriteLine (); the                 } the  the Console.WriteLine (); +rowup++; -VALUEROW_CULMN (refRcrefrow, rowup); the             }Bayi             Else the{return; } the         } -  -  the  the     } the}`

Determinant calculation (C #)

Related Keywords:

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.