Invert a matrix from a 4D array : equivalence or difference with indexes

In summary, In the first approach, the user inverts a 100x100 matrix for each element of the covariance matrix. The second approach uses a dot product between each element of the covariance matrix and a matrix of size 100x100.
  • #1
fab13
318
6
TL;DR Summary
I am looking for help about the manipulation in a formula of the inversion of matrixes from a 4D array and the interpretation of a factor which is actually a matrix of 100x100 size in this formula.
I have a 4D array of dimension ##100\text{x}100\text{x}3\text{x}3##. I am working with `Python Numpy. This 4D array is used since I want to manipulate 2D array of dimensions ##100\text{x}100## for the following equation (it allows to compute the ##(i,j)## element ##F_{ij}## of Fisher matrix) :

##F_{ij} = \sum_{XY}\,\int\,\dfrac{V_{0}\,\text{d}^3 k}{(2\pi)^{3}}\,\bigg(\dfrac{\partial P_{\text{obs,X}}}{\partial p_{i}}\bigg)\,(C^{-1})_{XY}\,\bigg(\dfrac{\partial P_{\text{obs,Y}}}{\partial p_{j}}\bigg)\quad(1) ##

##X## and ##Y## vary between ##1,2,3##.
The derivatives ##\bigg(\dfrac{\partial P_{\text{obs,X}}}{\partial p_{i}}\bigg)## and ##\bigg(\dfrac{\partial P_{\text{obs,X}}}{\partial p_{j}}\bigg)## are discrete arrays of dimension ##100\text{x}100##.

First I compute a "Covariance matrix" ##C## of dimension ##100\text{x}100## for each ##X## and ##Y##. So I have a 4D array for ##C##.

1) Now, I have an issue about the interpretation of the term ##(C^{-1})_{XY}##.

For the moment, what I do is to compute a 2D array of matrix ##3\text{x}3## (so a 2D array of ##10000## elements with a matrix ##3\text{x}3## for each element of this 2D array).

Then, after this, I invert the ##10000## matrixes ##3\text{x}3## and I multiply by a direct dot product of ##C^{-1}## with the derivatives in parenthesis.

To compute th final value ##F_{ij}##, I do a summation on ##X## and ##Y## (i.e on ##X,Y=1,2,3##) of the 2D final grid ##100\text{x}100## and integrate it.

2) I don't know if things of this formula are well carried out. Indeed, inverting ##10000## matrixes ##3\text{x}3## is not the same thing than inverting 9 matrixes of size ##100\text{x}100##, is it ?

In all cases, I thing I have to consider the matrix ##(C^{-1})_{XY}## like a matrix of ##100\text{x}100## dimensions.

Indeed, I think ##(C^{-1})## should be a ##100\text{x}100## matrix.

But on the other side, in my code, I perform the inversion of ##10000## ##3\text{x}3## matrixes and once this computation is done, I take the 9 matrixes of ##100\text{x}100## dimension.

Is my method right ?


3) I suppose that the 2 following operations are not commutative :

invert ##10000## matrixes of ##3\text{x}3## and using 9 matrixes of ##100\text{x}100## from this inversion OR invert directly 9 matrixes of ##100\text{x}100##

It seems that I make confusions between inverting matrix and reconstruct or use again this inversion with a 4D array.


If someone could help me to interpret correctly the equation ##(1)##, especially the term ##(C^{-1})_{XY}##, in order to do the right computations.

Regards
 
Technology news on Phys.org
  • #2
No, in general inverting 10,000 3x3 matrices will not give you the same result as inverting 9 100x100 matrices. If you want to convince yourself of that, try it both ways with a 2x2x3x3 array and see if you get the same result.
 
  • #3
Sorry, I add more details since my first post may cause confusions.

I did a little error in the equation ##(1)## on notations of Covariance factor ##C##, the right one is :

##F_{ij} = \sum_{XY}\,\int\,\dfrac{V_{0}\,\text{d}^3 k}{(2\pi)^{3}}\,\bigg(\dfrac{\partial P_{\text{obs,X}}}{\partial p_{i}}\bigg)\,C_{XY}^{-1}\,\bigg(\dfrac{\partial P_{\text{obs,Y}}}{\partial p_{j}}\bigg)\quad(1)##

What I am almost sure is that factor ##C## must have a size of ##100\text{x}100##.

I think I have 2 choices for the factor ##C_{XY}^{-1}## in the equation ##(1)## if I use a 4D dimension array for ##C_{XY}^{-1}[0:100][0:100][0:2][0:2]## , i.e with an element noted by ##C_{XY}^{-1}[\text{i}][\text{j}][\text{k}][\text{l}]## :

1) Invert for each ##(i,j)## element a matrix ##3\text{x}3##, then I take each block of ##100\text{x}100## associated to each element of matrix ##3\text{x}3## , and after multiplying each derivatives block (of size ##100\text{x}100##) by each of the ##(k,l)## elements (which varies from ##0## to ##2##) and which represent a block ##100\text{x}100## . In this case, the formula would mean a dot-to-dot product of each element ##(i,j)## of the matrix ##C_{XY}^{-1}## (of dimensions ##100\text{x}100##), by the corresponding element ##(\text{i},\text{j})## of ##X,Y## derivatives blocks (also of dimensions ##100\text{x}100##)

2) Invert for each ##(k,l)## element a matrix of size ##100\text{x}100## and multiplying with a dot product each of the 9 matrixes ##100\text{x}100## by each of the corresponding derivatives (labeled by index ##X## and ##Y##).

For the moment, a colleague has implemented the first solution 1) but I have not enough elements to confirm if that is the right method.

I have a few difficulties to explain better the 2 approaches because there is a slightly difference but results between both will never be the same, at least I think.

QUESTION 1) : What I assume also checkable is that operation 1) and 2) don't give the same ##100\text{x}100## matrix for the factor of inverted covariance ##C_{XY}^{-1}## : is it right ?

QUESTION 2) : What do you think about these 2 possible interpretations to compute ##C_{XY}^{-1}##, which one to use ?


Any help would be great because I am stuck for a long time on this issue. Regards
 
Last edited:

FAQ: Invert a matrix from a 4D array : equivalence or difference with indexes

1. What is a matrix in a 4D array?

A matrix in a 4D array is a collection of numbers arranged in a rectangular grid with rows and columns. It is a higher-dimensional version of a 2D matrix, with additional dimensions representing further layers of data.

2. What does it mean to invert a matrix?

Inverting a matrix means finding its inverse, which is a new matrix that when multiplied with the original matrix results in the identity matrix. This is similar to finding the reciprocal of a number, but in a higher-dimensional space.

3. How is a matrix inverted from a 4D array?

To invert a matrix from a 4D array, the matrix must first be square (i.e. have the same number of rows and columns). Then, a series of mathematical operations are performed on the matrix to find its inverse, such as using Gaussian elimination or LU decomposition.

4. What is the equivalence or difference between inverting a matrix and using indexes?

Inverting a matrix is a mathematical process that produces a new matrix, while using indexes is a way to access specific elements within a matrix. Indexing can be used to retrieve data from a matrix, while inverting a matrix transforms the entire matrix into a new form.

5. Why is inverting a matrix from a 4D array important in science?

Inverting a matrix from a 4D array is important in science because it allows for the manipulation and analysis of complex data sets. Many scientific fields, such as physics and engineering, use 4D arrays to represent data from multiple variables, and inverting these arrays can provide valuable insights and solutions to problems.

Similar threads

Replies
10
Views
25K
Replies
2
Views
3K
Replies
69
Views
4K
2
Replies
61
Views
7K
Replies
1
Views
2K
Replies
1
Views
973
2
Replies
42
Views
8K
Back
Top