Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to learn Julia Matrix Operation

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to learn Julia matrix operation, the editor feels very practical, so share with you to learn, I hope you can get something after reading this article, say no more, follow the editor to have a look.

1.1 Generation of Matrix

Generate a matrix of 4 rows and 4 columns, using 1-16 numbers. Note that when you generate a matrix here, you need to define an empty array first, and then fill it.

Mat = Array (Int32,4,4)

4 × 4 Array {Int32,2}:

125804192 256236432 79364176 79364176

0 0 0

79234864 79266064 125805712 248775184

0 0 0

Mat [:] = 1:16

Mat

4 × 4 Array {Int32,2}:

1 5 9 13

2 6 10 14

3 7 11 15

4 8 12 16

You can also use reshape to build a matrix reshape (1)

3 × 5 Base.ReshapedArray {Int64,2,UnitRange {Int64}, Tuple {}}:

1 4 7 10 13

2 5 8 11 14

3 6 9 12 15

1.2 extract main diagonal diag (mat)

4-element Array {Int64,1}:

one

six

eleven

sixteen

1.3 generate a diagonal matrix eye (4) with a diagonal of 1

4 × 4 Array {Float64,2}:

1.0 0.0 0.0 0.0

0.0 1.0 0.0 0.0

0.0 0.0 1.0 0.0

0.0 0.0 0.0 1.0

1.4 extract the lower triangular tril (mat) of the matrix

4 × 4 Array {Int64,2}:

1 0 0 0

2 6 0 0

3 7 11 0

4 8 12 16

1.5 extract the upper triangle triu (mat) of the matrix

4 × 4 Array {Int64,2}:

1 5 9 13

0 6 10 14

0 0 11 15

0 0 0 16

1.6 Matrix transpose mat'

4 × 4 Array {Int64,2}:

1 2 3 4

5 6 7 8

9 10 11 12

13 14 15 16

1.7 Matrix multiplication a = [[1] [1] [2]

2 × 2 Array {Int64,2}:

1 2

3 4

B = [[2pr 4] [3pm 5]]

2 × 2 Array {Int64,2}:

2 3

4 5

Multiply the corresponding values

A. Roomb

2 × 2 Array {Int64,2}:

2 6

12 20

Matrix multiplication

Axib

2 × 2 Array {Int64,2}:

10 13

22 29

1.8 Matrix inverse inv (a)

2 × 2 Array {Float64,2}:

-2.0 1.0

1.5-0.5

Inv (a) * a

2 × 2 Array {Float64,2}:

1.0 0.0

2.22045e-16 1.0

The above is how to learn Julia matrix operation, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report