简体   繁体   English

涉及逆运算的矩阵乘法:无穷大

[英]Multiplication of matrices involving inverse operation: getting infinity

In my earlier question asked here : Matlab: How to compute the inverse of a matrix 在我之前的问题中,这里问过: Matlab:如何计算矩阵的逆

I wanted to know how to perform inverse operation 我想知道如何执行逆运算

A = [1/2, (1j/2), 0;
     1/2, (-1j/2), 0;
     0,0,1]

 T = A.*1

 Tinv = inv(T)

The output is Tinv = 输出为Tinv =

   1.0000             1.0000                  0          
        0 - 1.0000i        0 + 1.0000i        0          
        0                  0             1.0000 

which is the same as in the second picture. 与第二张图片相同。 The first picture is the matrix A 第一张图片是矩阵A

Ť

T逆

However for a larger matrix say 5 by 5, if I don't use the identity, I to perform element wise multiplication, I am getting infinity value. 但是,对于更大的矩阵,说5 x 5,如果我不使用恒等式, I将执行元素明智的乘法,那么我将得到无穷大值。 Here is an example 这是一个例子

A = [1/2, (1j/2),  1/2, (1j/2),  0;
     1/2, (-1j/2), 1/2, (-1j/2), 0;
     1/2, (1j/2),  1/2, (1j/2),  0;
     1/2, (-1j/2), 1/2, (-1j/2), 0;
     0,    0 ,     0 ,  0,      1.00
          ];

T = A.*1

Tinv = inv(T)
Tinv =

   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf
   Inf   Inf   Inf   Inf   Inf

So, I tried to multiply T = A.*I where I = eye(5) then took the inverse Eventhough, I don't get infinity value, I am getting element 2 which is not there in the picture for 3 by 3 matrix case. 因此,我尝试将T = A.*I乘以I = eye(5)然后取反偶数,但是我没有得到无穷大的值,我得到的元素2在图片中不存在3 x 3矩阵案件。 Here is the result 这是结果

Tinv =

   2.0000                  0                  0                  0                  0          
        0                  0 + 2.0000i        0                  0                  0          
        0                  0             2.0000                  0                  0          
        0                  0                  0                  0 + 2.0000i        0          
        0                  0                  0                  0             1.0000    

If for 3 by 3 matrix case, I use I = eye(3) , then again I get element 2. 如果对于3 x 3矩阵的情况,我使用I = eye(3) ,那么我又得到元素2。

Tinv =

   2.0000                  0                  0          
        0                  0 + 2.0000i        0          
        0                  0             1.0000 

What is the proper method? 什么是正确的方法?

Question : For general case, for any sized matrix m by m , should I multiply using I = eye(m) ? 问题:对于一般情况,对于m by m任何大小的矩阵,我是否应该使用I = eye(m)相乘? Using I prevents infinity values, but results in new numbers 2 . 使用I可以防止无穷大,但是会产生新的数字2 I am really confused. 我真的很困惑。 Please help 请帮忙

UPDATE: Here is the full image where Theta is a vector of 3 unknowns which are Theta1, Theta1* and Theta2 are 3 scalar valued parameters. 更新:这是完整图像,其中Theta是3个未知数的向量,其中Theta1,Theta1 *和Theta2是3个标量值参数。 Theta1 is a complex valued number, so we are representing it into two parts, Theta1 and Theta1* and Theta2 is a real valued number. Theta1是一个复数值,因此我们将其分为两部分:Theta1和Theta1 *,而Theta2是一个实数值。 g is a complex valued function. g是一个复数值函数。 The expression of the derivative of a complex valued function with respect to Theta evaluates to T^H. 复数值函数相对于Theta的导数的表达式为T ^ H。 Since, there are 3 unknowns, the matrix T should be of size 3 by 3. 由于存在3个未知数,因此矩阵T的大小应为3乘3。

图片新

your problem is slightly different than you think. 您的问题与您认为的略有不同。 The symbols ( I , 0 ) in the matrices in the images are not necessarily scalars (only for n = 1 ), but they are actually square matrices . 图像中矩阵中的符号( I0不一定是标量 (仅对于n = 1 ),但是它们实际上是平方矩阵

I is an identity matrix and 0 is a matrix of zeros. I是一个单位矩阵, 0是一个零矩阵。 if you treat these matrix like that you will get the expected answers: 如果像这样对待这些矩阵,您将得到预期的答案:

n = 2; % size of the sub-matrices
I = eye(n); % identity matrix
Z = zeros(n); % matrix of zeros
% your T matrix
T = [1/2*I, (1j/2)*I, Z;
    1/2*I, (-1j/2)*I, Z;
    Z,Z,I];
% inverse of T
Tinv1 = inv(T);
% expected result
Tinv2 = [I,I,Z;
    -1j*I,1j*I,Z;
    Z,Z,I];
% max difference between computed and expected
maxDist = max(abs(Tinv1(:) - Tinv2(:)))

First you should know , whether you should do 首先你应该知道 ,是否应该做

T = A.*eye(...)

or 要么

I = A.*1 %// which actually does nothing

These are completely different things. 这些是完全不同的东西。 Be sure what you need, then think about the code. 确定您需要什么,然后考虑代码。


The reason why you get all inf is because the determinant det of your matrix is zero . 获得所有inf的原因是因为矩阵的行列式det 为零

det(T) == 0

So from the mathematical point of view your result is correct, as building the inverse requires every element of T to be divided by det(T) . 因此,从数学的角度来看,您的结果是正确的,因为构建逆函数需要将T每个元素除以det(T) Your matrix cannot be inversed. 您的矩阵不能求逆。 If it should be possible, the error is in your input matrix, or again in your understanding of the actual underlying problem to solve. 如果可能,则该错误是在您的输入矩阵中,或者是在您对要解决的实际潜在问题的理解中。

Edit 编辑

After your question update, it feels like you're actually looking for ctranpose instead of inv . 更新问题后,感觉好像您实际上是在寻找ctranpose而不是inv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM