IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 游戏开发 -> delte -> 正文阅读

[游戏开发]delte

Chaper 03 Linear Algebra Review



3.1 Matrices and Vectors矩阵和向量

Matrices are 2-dimensional arrays:
A vector is a matrix with one column and many rows:

矩阵Matrix:Rectangular array of numbers:

Dimension of matrix: number of rows x number of columns
在这里插入图片描述
矩阵元素 Matrix Elements(entries of matrix)
在这里插入图片描述
向量 Vector: An n X 1 matrix
在这里插入图片描述
Notation and terms:

  • Aij refers to the element in the ith row and jth column of
    matrix A.

  • A vector with ‘n’ rows is referred to as an ‘n’-dimensional vector.

  • vi refers to the element in the ith row of the vector.

  • In general, all our vectors and matrices will be 1-indexed. Note that for some programming languages, the arrays are 0-indexed.

  • Matrices are usually denoted by uppercase names while vectors are lowercase.

  • “Scalar” means that an object is a single value, not a vector or matrix.

  • R refers to the set of scalar real numbers.

  • Rn refers to the set of n-dimensional vectors of real numbers.

Run the cell below to get familiar with the commands in Octave/Matlab. Feel free to create matrices and vectors and try out different things.

% The ; denotes we are going back to a new row.
A = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]

% Initialize a vector 
v = [1;2;3] 

% Get the dimension of the matrix A where m = rows and n = columns
[m,n] = size(A)

% You could also store it this way
dim_A = size(A)

% Get the dimension of the vector v 
dim_v = size(v)

% Now let's index into the 2nd row 3rd column of matrix A
A_23 = A(2,3)

在这里插入图片描述

3.2 Addition and scalar multiplication 加法和标量乘法

Matrix Addition
在这里插入图片描述
Scalar Multiplication
在这里插入图片描述
Combination of Operands
在这里插入图片描述
Experiment below with the Octave/Matlab commands for matrix addition and scalar multiplication. Feel free to try out different commands. Try to write out your answers for each command before running the cell below.

% Initialize matrix A and B 
A = [1, 2, 4; 5, 3, 2]
B = [1, 3, 4; 1, 1, 1]

% Initialize constant s 
s = 2

% See how element-wise addition works
add_AB = A + B 

% See how element-wise subtraction works
sub_AB = A - B

% See how scalar multiplication works
mult_As = A * s

% Divide A by s
div_As = A / s

% What happens if we have a Matrix + scalar?
add_As = A + s

在这里插入图片描述

3.3 Matrix-vector multiplication 矩阵向量乘法

Example
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

prediction = datamatrix * parameters

An m x n matrix multiplied by an n x 1 vector results in an m x 1 vector.

Below is an example of a matrix-vector multiplication. Make sure you understand how the multiplication works. Feel free to try different matrix-vector multiplications.

% Initialize matrix A 
A = [1, 2, 3; 4, 5, 6;7, 8, 9] 

% Initialize vector v 
v = [1; 1; 1] 

% Multiply A * v
Av = A * v

在这里插入图片描述

3.3 Matrix-matrix multiplication 矩阵乘法

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
An m x n matrix multiplied by an n x o matrix results in an m x o matrix. In the above example, a 3 x 2 matrix times a 2 x 2 matrix resulted in a 3 x 2 matrix.

To multiply two matrices, the number of columns of the first matrix must equal the number of rows of the second matrix.

For example:

% Initialize a 3 by 2 matrix 
A = [1, 2; 3, 4;5, 6]

% Initialize a 2 by 1 matrix 
B = [1; 2] 

% We expect a resulting matrix of (3 by 2)*(2 by 1) = (3 by 1) 
mult_AB = A*B

% Make sure you understand why we got that result

在这里插入图片描述

3.5 Matrix multiplication properties 矩阵乘法特征

不满足交换律
在这里插入图片描述
满足结合律
在这里插入图片描述

Identity Matrix 单位矩阵
在这里插入图片描述
Matrices are not commutative: A?B != B?A
Matrices are associative: (A?B)?C = A?(B?C)

The identity matrix, when multiplied by any matrix of the same dimensions, results in the original matrix.

It’s just like multiplying numbers by 1. The identity matrix simply has 1’s on the diagonal (upper left to lower right diagonal) and 0’s elsewhere.

When multiplying the identity matrix after some matrix (A?I), the square identity matrix’s dimension should match the other matrix’s columns.

When multiplying the identity matrix before some other matrix (I?A), the square identity matrix’s dimension should match the other matrix’s rows.

% Initialize random matrices A and B 
A = [1,2;4,5]
B = [1,1;0,2]

% Initialize a 2 by 2 identity matrix
I = eye(2)

% The above notation is the same as I = [1,0;0,1]

% What happens when we multiply I*A ? 
IA = I*A 

% How about A*I ? 
AI = A*I 

% Compute A*B 
AB = A*B 

% Is it equal to B*A? 
BA = B*A 

% Note that IA = AI but AB != BA

在这里插入图片描述

3.5 Inverse and transpose 逆和转置

逆矩阵

A必须是方阵,不能全为0
在这里插入图片描述
在这里插入图片描述

求逆矩阵
Octave软件
在这里插入图片描述

A = [ 3 4 ; 2 16 ]   // 定义矩阵A
inverseOfA = pinv(A) // 求A的逆矩阵
A * inverseOfA  // A与A的逆矩阵相乘,结果是单位矩阵I
inverseOfA * A  // A的逆矩阵相乘与A,结果是单位矩阵I

在这里插入图片描述

The inverse of a matrix A is denoted A?1.
Multiplying by the inverse results in the identity matrix.

A non square matrix does not have an inverse matrix. We can compute inverses of matrices in octave with the pinv(A) function and in Matlab with the inv(A) function. Matrices that don’t have an inverse are singular or degenerate.

The transposition of a matrix is like rotating the matrix 90° in clockwise direction and then reversing it.
We can compute transposition of matrices in matlab with the transpose(A) function or A’:

In other words:

A~ij~ = A~ij~^T^

% Initialize matrix A 
A = [1,2,0;0,5,6;7,0,9]

% Transpose A 
A_trans = A' 

% Take the inverse of A 
A_inv = inv(A)

% What is A^(-1)*A? 
A_invA = inv(A)*A

在这里插入图片描述

  游戏开发 最新文章
6、英飞凌-AURIX-TC3XX: PWM实验之使用 GT
泛型自动装箱
CubeMax添加Rtthread操作系统 组件STM32F10
python多线程编程:如何优雅地关闭线程
数据类型隐式转换导致的阻塞
WebAPi实现多文件上传,并附带参数
from origin ‘null‘ has been blocked by
UE4 蓝图调用C++函数(附带项目工程)
Unity学习笔记(一)结构体的简单理解与应用
【Memory As a Programming Concept in C a
上一篇文章      下一篇文章      查看所有文章
加:2021-09-12 13:27:58  更:2021-09-12 13:29:51 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/17 13:52:47-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码