Spiral matrix, Matrix

Source: Internet
Author: User

Spiral matrix, Matrix

Spiral MatrixIt refers to a spiral matrix with numbers increasing from the first line to the right and increasing downward,
To the left, and to the up, so that the cycle.

 

1 import java. io. *; 2 public class demo1 3 {4 public static void main (String [] args) 5 {6 String strln = ""; 7 System. out. println ("Enter the number of columns in the matrix:"); 8 InputStreamReader input = new InputStreamReader (System. in); 9 BufferedReader buff = new BufferedReader (input); 10 try {11 strln = buff. readLine (); 12} 13 catch (IOException e) {14 System. out. println (e. toString (); 15} 16 int int1 = Integer. parseInt (strln); 17 int n = int 1; 18 System. out. println ("this is a line array with the number of rows and columns" + n + "); 19 int intA = 1; // initialize 20 int [] [] array = new int [n] [n]; 21 int intB; 22 if (n % 2! = 0) {23 intB = n/2 + 1; 24} 25 else26 intB = n/2; 27 for (int I = 0; I <intB; I ++) 28 {// cycle from external to internal 29 // start from left to right horizontal 30 for (int j = I; j <n-I; j ++) {31 array [I] [j] = intA; 32 intA ++; 33} 34 35 // 36 vertical (int k = I + 1; k <n-I; k ++) {37 array [k] [n-i-1] = intA; 38 intA ++; 39} 40 41 // from right to left Horizontal 42 for (int L = n-i-2; L> = I; L --) {43 array [n-i-1] [L] = intA; 44 intA ++; 45} 46 47 // bottom to top longitudinal 48 for (int m = n-i-2; m> I; m --) {49 array [m] [I] = intA; 50 intA ++; 51} 52} 53 for (int I = 0; I <n; I ++) {54 for (int j = 0; j <n; j ++) {55 System. out. print (array [I] [j] + ""); 56} 57 System. out. println (); 58} 59 60} 61}


How can I determine whether a matrix is a tiered matrix?

Check whether the number of columns in the first column not 0 in each row is decreasing. If yes, it is a tiered matrix of rows. Otherwise, it is not.

Quadratic Form of matrix of Higher Algebra

For the quadratic form, matrix A must be A real symmetric matrix.
The real symmetric matrix can be divided into two sides. That is to say, there is a reversible matrix P, so that P ^ {-1} AP is the diagonal matrix. Here P ^ {-1} represents the inverse matrix of P.
As you said, first obtain the feature root of A and the feature vectors, P1, P2, and P3 corresponding to each root respectively. At this time, P = (P1, P2, P ^ {-1} AP is the diagonal matrix.
However, if you want to change P ^ {-1} to PT, you must try to change P to an orthogonal array, because the definition of an orthogonal array is inverse and transpose.
Therefore, we need to convert P1, P2, and P3 orthogonal units to Q1, Q2, and Q3. The obtained matrix (Q1, Q2, and Q3) is orthogonal arrays.
Note: Orthogonal unitization is usually required instead of just unitization. However, if P1, P2, and P3 belong to different feature roots, they are orthogonal, thus eliminating the need for orthogonal process.

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.