Làm cách nào để kiểm tra xem ma trận có phải là danh tính trong python không?

Đối tượng tham chiếu để cho phép tạo các mảng không phải là mảng NumPy. Nếu một mảng giống như được chuyển vào dưới dạng like hỗ trợ giao thức __array_function__, thì kết quả sẽ được xác định bởi nó. Trong trường hợp này, nó đảm bảo việc tạo ra một đối tượng mảng tương thích với đối tượng được truyền qua đối số này

Trong bài viết này, chúng tôi sẽ thảo luận về các bước và trực giác để tạo ma trận nhận dạng và hiển thị các ví dụ bằng Python

Mục lục

  • Giới thiệu
  • Giải thích ma trận nhận dạng
  • Thuộc tính ma trận nhận dạng
  • Ma trận nhận dạng trong Python
  • Phần kết luận

Giới thiệu

Ma trận đơn vị [I] thường thấy trong rất nhiều biểu thức ma trận trong đại số tuyến tính

Tại thời điểm này, bạn nên làm quen với việc hiểu ý nghĩa đằng sau ma trận đồng nhất sẽ rất hữu ích.

Để tiếp tục làm theo hướng dẫn này, chúng ta sẽ cần thư viện Python sau. cục mịch

Nếu bạn chưa cài đặt chúng, vui lòng mở “Command Prompt” [trên Windows] và cài đặt chúng bằng mã sau

pip install numpy

Giải thích ma trận nhận dạng

Chúng ta đã biết, nhưng ma trận nhận dạng chính xác là gì và nó được sử dụng như thế nào?

Ma trận đơn vị I_n là một ma trận vuông cấp n chứa đầy các số 1 trên đường chéo chính và các số 0 ở mọi nơi khác

Đây là vài ví dụ

Hình ảnh của tác giả

và như vậy cho kích thước lớn hơn

Về mặt đồ thị, ma trận I_2 chỉ biểu diễn các vectơ cơ sở

Hình ảnh của tác giả

Hình ảnh của tác giả

Thuộc tính ma trận nhận dạng

Dưới đây là một số thuộc tính hữu ích của ma trận đồng nhất

  • Ma trận đơn vị luôn là ma trận vuông [cùng số hàng và cột], chẳng hạn như. 2×2, 3×3, v.v.
  • Kết quả của phép nhân bất kỳ ma trận nào với ma trận đơn vị là chính ma trận đó [nếu phép nhân được xác định]

Hình ảnh của tác giả
  • Kết quả của phép nhân một ma trận với ma trận nghịch đảo của nó là ma trận đơn vị

Hình ảnh của tác giả

Ma trận nhận dạng trong Python

Để tạo ma trận nhận dạng trong Python, chúng ta sẽ sử dụng thư viện numpy. Và bước đầu tiên sẽ là nhập nó

Numpy có rất nhiều hàm hữu ích và đối với thao tác này, chúng ta sẽ sử dụng hàm nhận dạng [] để tạo một mảng hình vuông chứa đầy các số 1 trong đường chéo chính và các số 0 ở mọi nơi khác

Bây giờ, hãy tạo một ma trận nhận dạng 2×2

Và bạn sẽ nhận được

[[1. 0.]
[0. 1.]]

Bây giờ bạn đã biết cách tạo ma trận đồng nhất và có thể khám phá thêm các phép toán của ma trận bằng cách tính nghịch đảo ma trận và nhân ma trận trong Python

Phần kết luận

Trong bài viết này, chúng tôi đã thảo luận về các bước và trực giác để tạo ma trận nhận dạng, cũng như hiển thị một ví dụ hoàn chỉnh bằng Python

Vui lòng để lại nhận xét bên dưới nếu bạn có bất kỳ câu hỏi nào hoặc có đề xuất cho một số chỉnh sửa và xem thêm các bài viết về Đại số tuyến tính của tôi

Trong đại số tuyến tính, điều này đôi khi được gọi là Ma trận đơn vị, của một ma trận vuông [kích thước = n x n] với các số 1 trên đường chéo chính và các số 0 ở những nơi khác. Ma trận đồng nhất được ký hiệu là “I”. Đôi khi U hoặc E cũng được sử dụng để biểu thị Ma trận nhận dạng.  

Một thuộc tính của ma trận đồng nhất là nó không thay đổi ma trận nếu nó được nhân với Ma trận đồng nhất

ví dụ.   

Input  : 2
Output : 1 0
         0 1

Input :  4
Output : 1 0 0 0
         0 1 0 0
         0 0 1 0
         0 0 0 1
The explanation is simple. We need to make all
the elements of principal or main diagonal as 
1 and everything else as 0.

Chương trình in ma trận nhận dạng. logic rất đơn giản. Bạn cần in 1 ở những vị trí có hàng bằng cột của ma trận và đặt tất cả các vị trí khác bằng 0.  

Thực hiện

C++




// C++ program to print Identity Matrix

#include

using namespace std;

 

int Identity[int

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
1

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______580_______
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______8
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
9

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______3_______8
Yes 
4

Yes 
2______3_______2

Yes 
7_______13_______8

Yes 
7_______575_______0 // C++ program to print Identity Matrix1

// C++ program to print Identity Matrix2_______575_______3// C++ program to print Identity Matrix4// C++ program to print Identity Matrix5

Yes 
7_______575_______7

// C++ program to print Identity Matrix2_______575_______9// C++ program to print Identity Matrix4// C++ program to print Identity Matrix5

Yes 
2____576_______3

Yes 
2____576_______5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 using0

#include3

 

using2

int using4

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______580_______ using8

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______578_______0

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 using0

#include3

 

namespace5

C




namespace6

namespace7

 

int Identity[int

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
1

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______580_______
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______8
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
9

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______3_______8
Yes 
4

Yes 
2______3_______2

Yes 
7_______13_______8

Yes 
7_______575_______0 // C++ program to print Identity Matrix1

// C++ program to print Identity Matrix2_______581_______3____581_______4Identity[5Identity[6

Yes 
7_______575_______7

// C++ program to print Identity Matrix2_______581_______3Identity[4Identity[5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
03

Yes 
2____576_______3

Yes 
2_______581_______3_______581_______4
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
09
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 using0

#include3

 

using2

int using4

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______580_______ using8

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______25

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 using0

#include3

Java




1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
30

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
31
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
32

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
33
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
34

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______37 int
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
39_______580_______
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
1

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______580_______
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
47

Yes 
2_______3_______8
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
50
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51_______3_______52

Yes 
2______3_______2

Yes 
7_______3_______8
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
57
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
59

Yes 
7_______3_______2

// C++ program to print Identity Matrix2______13_______8

// C++ program to print Identity Matrix2_______575_______0 // C++ program to print Identity Matrix1

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
68
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
69
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
70// C++ program to print Identity Matrix4
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

// C++ program to print Identity Matrix2______575_______7

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
68
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
70// C++ program to print Identity Matrix4
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

Yes 
7_______576_______3

Yes 
7_______3_______84

Yes 
2____576_______3

Yes 
2_______576_______9
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51// C++ program to print Identity Matrix5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
93

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______577_______2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______97
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
37
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
99
Yes 
00

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______580_______
Yes 
05
Yes 
06// C++ program to print Identity Matrix5

Yes 
2______3_______25

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

#include3

 

Yes 
13

Python3




Yes 
14

 

Yes 
15

Yes 
16
Yes 
17

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______8
Yes 
20
Yes 
21
Yes 
22Identity[4
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51
Yes 
25

Yes 
2_______3_______8
Yes 
28
Yes 
21
Yes 
22Identity[4
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51
Yes 
25

 

Yes 
7_______13_______35

Yes 
7_______575_______0
Yes 
38
Yes 
39
Yes 
39
Yes 
41

// C++ program to print Identity Matrix2_______13_______43____581_______4

Yes 
45
Yes 
46
Yes 
39// C++ program to print Identity Matrix4
Yes 
49

Yes 
7_______575_______7
Yes 
52

// C++ program to print Identity Matrix2_______13_______43____581_______4

Yes 
56
Yes 
46
Yes 
39// C++ program to print Identity Matrix4
Yes 
49

Yes 
2_______13_______43
Yes 
63

 

Yes 
64

Yes 
65
Yes 
39
Yes 
06

Yes 
68

C#




Yes 
69

using

Yes 
71

 

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
33
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
34

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______37 int
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
39_______580_______
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
1

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______580_______
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
5

Yes 
2

Yes 
2_______3_______8
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
9

Yes 
2______3_______2

Yes 
7_______3_______8
Yes 
4

Yes 
7_______3_______2

// C++ program to print Identity Matrix2______13_______8

// C++ program to print Identity Matrix2_______575_______0 // C++ program to print Identity Matrix1

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67_______575_______03// C++ program to print Identity Matrix4
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

// C++ program to print Identity Matrix2______575_______7

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67_______575_______09// C++ program to print Identity Matrix4
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

Yes 
7_______576_______3

Yes 
7_______575_______15

Yes 
2____576_______3

Yes 
2_______576_______9 using0

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______577_______2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______97
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
37
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
99 // C++ program to print Identity Matrix30

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______580_______ using8

Yes 
2______3_______25

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

#include3

 

// C++ program to print Identity Matrix41

PHP




// C++ program to print Identity Matrix42

// C++ program to print Identity Matrix43

// C++ program to print Identity Matrix44

 

// C++ program to print Identity Matrix45 Identity[// C++ program to print Identity Matrix47

Yes 
49

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______575_______51// C++ program to print Identity Matrix5// C++ program to print Identity Matrix53// C++ program to print Identity Matrix5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______8 Identity[4_______575_______51 // C++ program to print Identity Matrix60// C++ program to print Identity Matrix51 // C++ program to print Identity Matrix62// C++ program to print Identity Matrix47// C++ program to print Identity Matrix5// C++ program to print Identity Matrix51// C++ program to print Identity Matrix66

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______3_______8 Identity[4// C++ program to print Identity Matrix53 // C++ program to print Identity Matrix60// C++ program to print Identity Matrix53 // C++ program to print Identity Matrix62// C++ program to print Identity Matrix47// C++ program to print Identity Matrix5// C++ program to print Identity Matrix53// C++ program to print Identity Matrix66

Yes 
2______3_______2

Yes 
7

Yes 
7_______575_______84

Yes 
7_______575_______86

Yes 
7_______575_______0 Identity[4_______575_______51 // C++ program to print Identity Matrix91// C++ program to print Identity Matrix53
Yes 
49

Yes 
7_______575_______95 // C++ program to print Identity Matrix96// C++ program to print Identity Matrix4// C++ program to print Identity Matrix5

Yes 
7_______575_______7

Yes 
7_______575_______95 #include03// C++ program to print Identity Matrix4// C++ program to print Identity Matrix5

Yes 
2____576_______3

Yes 
2_______575_______95____3_______09// C++ program to print Identity Matrix5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 using0

#include3

 

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______577_______2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______21 #include22

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______39#include21
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

 

#include27

#include28

Javascript




#include29

 

#include30

#include31____575_______45 #include33

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______36 #include37

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______36 #include40

#include41

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______8
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
9

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______3_______8
Yes 
4

Yes 
2______3_______2

Yes 
7_______13_______8

Yes 
7_______575_______0 // C++ program to print Identity Matrix1

// C++ program to print Identity Matrix2_______576_______58// C++ program to print Identity Matrix4

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

Yes 
7_______575_______7

// C++ program to print Identity Matrix2_______576_______64____575_______4

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

Yes 
2____576_______3

Yes 
2_______576_______70#include71
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
70#include73
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 using0

#include3

#include81

using2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
93_______577_______8

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______578_______0

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______89

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

#include91

Đầu ra

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 

Thời gian phức tạp. O[hàng x cột]
Không gian phụ trợ. O[1], vì không sử dụng thêm dung lượng
 
Chương trình kiểm tra xem một ma trận vuông đã cho có phải là Ma trận đồng nhất không.  

C++




#include92

#include93

using namespace std;

 

#include97 int #include99

 

using00 using01int using03int using05

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______8 Identity[4int using11

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______3_______8 Identity[4int using18

Yes 
2______3_______2

Yes 
7_______575_______0 using23

// C++ program to print Identity Matrix2_______576_______9 using26// C++ program to print Identity Matrix5

Yes 
7_______575_______7 // C++ program to print Identity Matrix0 using31

// C++ program to print Identity Matrix2_______576_______9 using26// C++ program to print Identity Matrix5

Yes 
2____576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 using42// C++ program to print Identity Matrix5

#include3

 

using2

int using4

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______580_______ using51

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______580_______ using54

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67using56

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67using58

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67using60

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______575_______0 using63

using64____577_______65using66_______575_______5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______575_______7

using64____577_______65using72// C++ program to print Identity Matrix5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 using0

#include3

C




using78

using79

 

using80

int using82____580_______ using84int using05

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______8 Identity[4int using92

Yes 
2_______3_______8 Identity[4int using97

Yes 
7_______575_______0 namespace00

// C++ program to print Identity Matrix2_______576_______9 using0

Yes 
7_______575_______7 // C++ program to print Identity Matrix0 namespace07

// C++ program to print Identity Matrix2_______576_______9 using0

Yes 
2____576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 namespace17

#include3

int using4

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

 

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______578_______23

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______580_______ using51

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______580_______ namespace29

namespace30____578_______31

namespace30____578_______33

namespace30namespace35

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______575_______0 namespace38

Yes 
2_______581_______3_______581_______4namespace42
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______575_______7

Yes 
2_______581_______3_______581_______4namespace49
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 using0

#include3

 

namespace55

Java




namespace56

namespace57

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
31
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
32

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
33
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
34

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______580_______ namespace65_______578_______66// C++ program to print Identity Matrix5

namespace68

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______37 namespace71 using01int namespace74int using05

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______3_______8 Identity[4int namespace83
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51namespace85

Yes 
2______3_______2

Yes 
7_______3_______8 Identity[4int namespace92
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51namespace94

Yes 
7_______3_______2

// C++ program to print Identity Matrix2_______575_______0 namespace99

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
69
Yes 
49

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67_______576_______9 using26// C++ program to print Identity Matrix5

// C++ program to print Identity Matrix2_______575_______7 // C++ program to print Identity Matrix0 std;09

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51
Yes 
49

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67_______576_______9 using26// C++ program to print Identity Matrix5

Yes 
7_______576_______3

Yes 
2____576_______3

Yes 
2_______576_______9 using42// C++ program to print Identity Matrix5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
93

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______577_______2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______97
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
37
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
99
Yes 
00

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______580_______ std;38std;39// C++ program to print Identity Matrix5

Yes 
2_______580_______ std;43_______3_______69std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;51

std;52_______3_______2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
69std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;51

std;52_______3_______2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
69std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;51

std;52_______3_______2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51_______579_______45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
69std;81

Yes 
2

Yes 
2_______575_______0 using63

std;86_______579_______87using66

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

Yes 
2____575_______7

std;86_______579_______87using72____3_______10

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

#include3

 

 

std;99

Python3




int00

int01

int02

Yes 
39 namespace66// C++ program to print Identity Matrix5

Yes 
16 int07

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______8
Yes 
20
Yes 
21
Yes 
22int13

Yes 
2_______3_______8
Yes 
28
Yes 
21
Yes 
22int13

Yes 
7_______575_______0
Yes 
38
Yes 
39
Yes 
39
Yes 
28int26

// C++ program to print Identity Matrix2_______580_______28

Yes 
39
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
69int31

// C++ program to print Identity Matrix2_______576_______9 int34// C++ program to print Identity Matrix5

Yes 
7_______580_______37 int38
Yes 
39
Yes 
28int26

int42____580_______28

Yes 
39
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51int31

// C++ program to print Identity Matrix2_______576_______9 int34// C++ program to print Identity Matrix5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 int53// C++ program to print Identity Matrix5

 

int55

int56_______13_______39 std;39// C++ program to print Identity Matrix5

int60_______13_______39 int62_______3_______69std;45

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51int70

using64int72_______3_______51std;45

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
69std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51int70

using64int72_______3_______51std;45

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
69std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51int70

using64int72_______3_______51_______579_______45

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
51std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
69Identity[00

// C++ program to print Identity Matrix0 Identity[02

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______13_______43____581_______4using66
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

// C++ program to print Identity Matrix7____13_______52

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______13_______43____581_______4using72
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

 

Identity[15

Identity[16

C#




Identity[17

namespace57

using

Yes 
71

 

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
33
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
34

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______581_______25

 

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______37 using00 using01intIdentity[31int using05

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______3_______8 Identity[4int using11

Yes 
2______3_______2

Yes 
7_______3_______8 Identity[4int using18

Yes 
7_______3_______2

// C++ program to print Identity Matrix2_______575_______0 Identity[52

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67_______576_______9 using26// C++ program to print Identity Matrix5

// C++ program to print Identity Matrix2_______575_______7 // C++ program to print Identity Matrix0 Identity[60

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
67_______576_______9 using26// C++ program to print Identity Matrix5

Yes 
7_______576_______3

Yes 
2____576_______3

Yes 
2_______576_______9 using42// C++ program to print Identity Matrix5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______577_______2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______97
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
37
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
99 // C++ program to print Identity Matrix30

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______580_______ using51

Yes 
2_______580_______ Identity[90

Identity[91____577_______56

Identity[91____577_______58

Identity[91____577_______60

Yes 
2

Yes 
2_______575_______0 using63

Yes 
2_______3_______002____577_______66
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

Yes 
2____575_______7

Yes 
2_______3_______002____577_______72
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

#include3

 

 

// C++ program to print Identity Matrix41

PHP




// C++ program to print Identity Matrix42

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
016

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
017

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
018

 

// C++ program to print Identity Matrix45 using01

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
021_______579_______45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
023
Yes 
49

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______8 Identity[4_______575_______51 // C++ program to print Identity Matrix60// C++ program to print Identity Matrix51 // C++ program to print Identity Matrix62
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
023// C++ program to print Identity Matrix5// C++ program to print Identity Matrix51// C++ program to print Identity Matrix66

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______3_______8 Identity[4// C++ program to print Identity Matrix53 // C++ program to print Identity Matrix60// C++ program to print Identity Matrix53 // C++ program to print Identity Matrix62
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
023// C++ program to print Identity Matrix5// C++ program to print Identity Matrix53// C++ program to print Identity Matrix66

Yes 
2______3_______2

Yes 
7_______575_______0 Identity[4_______575_______51 // C++ program to print Identity Matrix91// C++ program to print Identity Matrix53 int26

// C++ program to print Identity Matrix2_______3_______021int72// C++ program to print Identity Matrix51

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
063// C++ program to print Identity Matrix53
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
065

// C++ program to print Identity Matrix2_______576_______9

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
068

Yes 
7_______575_______7 // C++ program to print Identity Matrix0 Identity[4// C++ program to print Identity Matrix51
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
074// C++ program to print Identity Matrix53
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
076

namespace30

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
021_______580_______72// C++ program to print Identity Matrix51
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
063// C++ program to print Identity Matrix53
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
083

// C++ program to print Identity Matrix2_______576_______9

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
068

Yes 
2____576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
093

#include3

 

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______577_______2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______023
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
099

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______021
Yes 
39
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
103Identity[4
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
103_______3_______106

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
107_______3_______103
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
109

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
107______3_______103
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
112

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
107______3_______103
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
115

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______575_______0
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
118_______3_______021std;45
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
023_______3_______122

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______575_______95 using66// C++ program to print Identity Matrix5

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______575_______7

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______575_______95 using72// C++ program to print Identity Matrix5

 

#include27

#include28

Javascript




#include29

 

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
136

namespace57

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
138

 

// C++ program to print Identity Matrix45

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
140

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______8
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
144

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______3_______2

Yes 
2_______3_______8
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
149

Yes 
2______3_______2

Yes 
7_______575_______0 using23

// C++ program to print Identity Matrix2_______576_______9 using26// C++ program to print Identity Matrix5

Yes 
7_______575_______7 // C++ program to print Identity Matrix0 using31

// C++ program to print Identity Matrix2_______576_______9 using26// C++ program to print Identity Matrix5

Yes 
2____576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______9 using42// C++ program to print Identity Matrix5

#include3

 

using2

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
177

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
178

Yes 
7_______3_______180

Yes 
7_______3_______182

Yes 
7______3_______184

namespace68

// C++ program to print Identity Matrix0 using63

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______70using66
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

// C++ program to print Identity Matrix7

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3_______576_______70using72
1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
10

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
3

1 0 0 0 0 
0 1 0 0 0 
0 0 1 0 0 
0 0 0 1 0 
0 0 0 0 1 
198

 

#include91

Đầu ra

Yes 

Thời gian phức tạp. O[hàng x cột]
Không gian phụ trợ. O[1], vì không sử dụng thêm dung lượng

Bài viết này được đóng góp bởi Aarti_Rathi. Vui lòng viết bình luận nếu bạn thấy bất cứ điều gì không chính xác hoặc bạn muốn chia sẻ thêm thông tin về chủ đề thảo luận ở trên.  

Ma trận nhận dạng trong Python là gì?

Giới thiệu về ma trận danh tính. Định nghĩa từ điển của Ma trận đồng nhất là ma trận vuông trong đó tất cả các phần tử của đường chéo chính hoặc đường chéo chính là 1 và tất cả các phần tử khác là 0 .

Ma trận nào là ma trận đồng nhất?

Ma trận đơn vị là ma trận vuông có các số 1 trên đường chéo chính và các số 0 ở mọi nơi khác . Ví dụ: ma trận nhận dạng 2×2 và 3×3 được hiển thị bên dưới. Chúng được gọi là ma trận đồng nhất vì khi bạn nhân chúng với một ma trận tương thích, bạn sẽ nhận được cùng một ma trận.

Ma trận nhận dạng được định nghĩa như thế nào?

Ma trận đơn vị là một ma trận vuông đã cho có thứ tự bất kỳ chứa các phần tử trên đường chéo chính của nó có giá trị bằng 1, trong khi các phần tử còn lại của ma trận bằng 0

Bạn sẽ tạo ma trận nhận dạng bằng Python như thế nào?

Để tạo ma trận nhận dạng trong Python, chúng tôi sẽ sử dụng thư viện numpy . Và bước đầu tiên sẽ là nhập nó. Numpy có rất nhiều hàm hữu ích và đối với thao tác này, chúng ta sẽ sử dụng hàm nhận dạng [] để tạo một mảng hình vuông chứa đầy các số 1 trong đường chéo chính và các số 0 ở mọi nơi khác.

Chủ Đề