If a matrix A is triangular, then its diagonal entries are its eigenvalues. If I can reduce a nontriangular matrix B to A, does it mean that the eigenvalues of B are the same of A?

The book I have says that If a matrix A is triangular, then its diagonal entries are its eigenvalues. By my tests it doesn't seem to be the case that, if I reduce a matrix B to A, that the eigenvalues of B will be the same as of A, but maybe I'm doing something wrong. I've seen so many different equivalencies between matrix that are row reducible to another that I thought that could be the case for eigenvalues too.

πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/oldespondent
πŸ“…︎ Dec 25 2021
🚨︎ report
How to exponentiate a nearly sub-diagonal matrix consisting of integers in nalgebra

I'm trying to solve day 6 pt 1 of advent of code, and I have the following matrix intended to represent each day's evolution:

SMatrix::<u64, 9, 9>::from([
        [0, 0, 0, 0, 0, 0, 0, 0, 1],
        [1, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 1, 0, 0, 0, 0, 0, 0, 1],
        [0, 0, 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, 0, 0],
        [0, 0, 0, 0, 0, 0, 1, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 1, 0],
    ]);

I want to compute the nth power of this matrix, where n is the number of days since the beginning. What's the best way to do this in Rust?

I was thinking I would diagonalize the matrix and do scalar exponentiation, but I can't seem to find a tool in nalgebra to do so. I found the pow function, which uses squaring exponentiation which doesn't seem bad, but it also expects the fields to be floats, which I suspect will produce inaccuracies in my answers due to drift.

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Dec 06 2021
🚨︎ report
If I reduce a matrix A to a triangular form, will its diagonals be the eigenvalues of A?

My book does not say anything about it being true or false. I couldn't find anywhere saying one thing or the other. My tests so far shows that this is not the case, but can't hurt to ask.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/oldespondent
πŸ“…︎ Jan 02 2022
🚨︎ report
Is the only diagonizable form of a matrix that with its eigenvalues along the diagonal?

If A is nxn with geometric multiplicity n (for simplicity let's just say it has n distinct eigenvalues), then it can be diagonalized into the form with its eigenvalues along the diagonal of the matrix. Is there any other way it can he diagonalized? Or is the only way to diagonalise it to find the eigenvalues and put them along the diagonal?

πŸ‘︎ 10
πŸ’¬︎
πŸ“…︎ Nov 04 2021
🚨︎ report
Is there a name for a diagonal matrix that goes upwards rather than downwards?

For example, a 2x2 identity matrix where the 0s and 1s are switched.

πŸ‘︎ 12
πŸ’¬︎
πŸ‘€︎ u/LoganJFisher
πŸ“…︎ Oct 23 2021
🚨︎ report
How do I get all the diagonals from a matrix?

Hello everyone. I want to get all the diagonals from a matrix.

Let's say I have a matrix =

[[1, 2, 3],

[1, 2, 3],

[1, 2, 3]]

My code only gets the diagonals [[1], [1, 2], [1, 2, 3], [2, 3], [3]]

How can I get diagonals [[3], [2, 3], [1, 2, 3], [1, 2], [1]]?

This is the code I have that completes only the first half of the diagonals.

    new = []
    n = 0
    while n <= length - 1:
        i = n
        j = 0
        temp = []
        while i >= 0:
            try:
                temp.append(otherGrid[i][j])
                i -= 1
                j += 1
            except IndexError:
                break
        new.append(temp)
        n += 1
    k = 1
    while k <= length - 1:
        k += 1
        i = length - 1
        j = k
        temp = []
        while j <= length - 1:
            try:
                temp.append(otherGrid[i][j])
                i -= 1
                j += 1
            except IndexError:
                break
        new.append(temp)

How can I modify this code to get the diagonals going the other direction? That is, diagonal down starting from the first row, last column?

Thanks. I appreciate any help.

πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/LaFineMouche
πŸ“…︎ Sep 02 2021
🚨︎ report
Function that returns the reverse diagonal of an n x n matrix? I tried this, but it doesn't work.
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Put-CallParity
πŸ“…︎ Jul 14 2021
🚨︎ report
Proof of multiplying a diagonal matrix with itself.... (ignore flair)

Hi all. I'm trying to prove by induction that if you raise a diagonal matrix A by power n, the entries of A^n are the respective entries of A raised by power n. Anyone have guidance or resources I could look at? Thanks in advance! I can't really find what I want on YouTube, and would appreciate your inputs :)

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/starboundseeker
πŸ“…︎ Jul 15 2021
🚨︎ report
Permanent of a block-diagonal matrix

I know that the determinant has the property that a block diagonal matrix A with blocks A_1 ... A_n has the determinant det(A) = prod(det(A_i)). I think the same should hold for the matrix permanent, and some quick numerical tests seem to suggest that's true, but I have been unable to find a statement of this anywhere, let alone a proof. If anyone can confirm it / point me in the right direction I would much appreciate it. The reason for asking is that I'm doing some simulations where I need to take the permanent of block diagonal matrices and being able to fractorize it would be a big help.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/fulis
πŸ“…︎ Aug 12 2021
🚨︎ report
How to take diagonal from matrix…

I’m wondering how I can extract a diagonal that is NOT the main diagonal of a matrix (i need the diag above). How can I do this? I’ve tried the diag function then realized its only for the main diagonal of a matrix.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/wreatme
πŸ“…︎ Jun 30 2021
🚨︎ report
An elegant way of creating Tri-diagonal matrix in MATLAB?

I am trying to to numerically solve a convection-diffusion system for which I need to create a Tri-diagonal matrix. I made a simplification of my code to obtain following Tri-diagonal matrix:

https://imgur.com/a/2mfgPEr

In the following code, there is "my way" of creating such matrix - it works... but I have a strong feeling that there are more elegant solutions.

https://github.com/JKhay/MATLAB/blob/main/Test

Is this "OK" or would you recommend something better?

πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/iBo0m
πŸ“…︎ Mar 23 2021
🚨︎ report
I need to switch the Major Diagonal and Minor Diagonal of a Matrix to display a different character than the rest of the Matrix and I am lost on how to do so.

Here is the code I have so far

#include <iostream>
using namespace std;
const int SIZE = 4;
const char DEFAULT = '?';
//---------------------
void displayMatrix (const char theMatrix [ ] [SIZE])
{
int curRow;
int curCol;
for (curRow = 0; curRow < SIZE; curRow++)
{
for (curCol = 0; curCol < SIZE; curCol++)
{
cout << theMatrix [curRow] [curCol] << " ";
}
cout << endl;
}
}
//--------------------------
void majorDiag (char theMatrix [ ] [SIZE])
{
}
//------------------------
void minorDiag (char theMatrix [ ] [SIZE])
{
}
//---------------------------
int main ()
{
char myNumber [SIZE] [SIZE] = { {'?','?','?','?'}, {'?','?','?','?'}, {'?','?','?','?'}, {'?','?','?','?'}};
displayMatrix (myNumber);
return 0;
}

I need to finish the majorDiag and minorDiag functions and if anyone has any tips or advice I would greatly appreciate it.

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/GunnaGTSu1
πŸ“…︎ Jun 06 2021
🚨︎ report
What are specific geometric interpretations of the following matrices - Diagonal , Upper and Lower Triangular , Transposed Matrix and Inverted Matrix ?

I'm aware that multiplying a vector by a matrix leads to a changing ( scaling , rotating , etc ) of space. But I'm interested in knowing the effect on the space by matrices that do specific things to it.

πŸ‘︎ 56
πŸ’¬︎
πŸ‘€︎ u/acidic_orbit
πŸ“…︎ Jan 22 2021
🚨︎ report
How is the mirror image of a matrix across the diagonal called?
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/AICoffeeBreak
πŸ“…︎ Jun 17 2021
🚨︎ report
How to go from Diagonal Matrix of Energies to Total Energy

This feels like a really dumb question but If i have:

E_11 0 0 0

0 E_22 0 0

0 0 E_33 0

0 0 0 E_44

and I have gotten these by pinching the Hamiltonian matrix elements with the relevant wave-functions , is the total energy just the Trace of this Matrix (sum of the diagonals)?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/100NatziScalps
πŸ“…︎ Apr 06 2021
🚨︎ report
reduce the matrix into a triangular matrix so you can multiply the main diagonal retard
πŸ‘︎ 502
πŸ’¬︎
πŸ‘€︎ u/grillMaster_
πŸ“…︎ Oct 30 2020
🚨︎ report
Infomax Notes Diagonal Matrix

On page 2 of the Infomax notes, it says WM = diag(d1, d2) but then says d1 and d2 are on the off-diagonals. Shouldn't they be on the diagonal itself?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/PuzzledPenguin0
πŸ“…︎ Jan 26 2021
🚨︎ report
Trying to check if a matrix is a magic square.. having issues assigning the pointer, p, for the diagonal? Code below

https://imgur.com/a/XRRuFzd

Above is the link for the code I have written so far. I understand how I would need to traverse the column and rows and have assigned p correctly to my knowledge. How do I assign p for the two diagonals and have it pick up the correct number. A magic square is a matrix that has the same sum for all rows; same sum for all columns and he same sum for both diagonals. I am doing this for an assignment. Can anyone explain to me the pointer and how it can be assigned. Thanks!

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/swat199
πŸ“…︎ Jan 29 2021
🚨︎ report
[Java][Matrix] How can you tell that a cell in a matrix is diagonal to another cell?

I wanted to ask this question, as well as present what I think is a correct assumption.

So from my understanding I would think that a cell (i, j) is diagonal to a cell (m, r) if these two cells are equal to eachother when added or equal to each other when substracted.

Meaning : if i - j == m - r or i + j == m + r then its diagonal

I think this is correct, but I'm second guessing myself after seeing this :

https://www.geeksforgeeks.org/check-if-two-elements-of-a-matrix-are-on-the-same-diagonal-or-not/

Which states a cell is diagonal if : abs(P – Q) == abs(X – Y) or P + Q == X + Y

But, I don't think the above is correct because when using it in a test scenario I came across an incorrect edge case :

For an 5 x 5 matrx, the points (1,0) and (3,4) satisfy the above condition, but these cells are not diagonal.

So is my thought process correct? Or am I missing something? The definition of diagonal without the absolute value works for me, but I don't know if I'm possibly missing some edge case.

Can someone explain if I'm wrong, and if so what am I missing?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/entrancehere
πŸ“…︎ Dec 17 2020
🚨︎ report
Diagonal matrix - Infomax

Hello,

I was revising Infomax and in page 2 in the notes, it explains that we need to have to find an unmixing matrix W such that we finally obtain a diagonal matrix from the mixing matrix M.

I am quite confused as why this condition is stated as:

MW = diagonal

and not

WM = diagonal

since as far as I see, first we mix the sources and then we unmix them. Also, before stating the conditions it says: " (...) precisely, since x = WMs we want WM to be a diagonal matrix multiplied by a permutation matrix (...) "

Thank you in advance!

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Jan 15 2021
🚨︎ report
igraph: Why does inverse log weighted similarity for a directed graph produce similarity along the diagonal that is lower than it's similarity to other nodes? Self-similarity should be constant (akin to 1's on a correlational matrix) but here it's not. However, for undirected graph, diagonals are 0s
g_Undirected&lt;-sample_gnp(10, .6, directed = FALSE, loops = FALSE)
g_Directed&lt;-sample_gnp(10, .6, directed = TRUE, loops = FALSE)

similarity(g_Undirected, method = "invlogweighted")

https://preview.redd.it/r256gpdd22m51.png?width=749&format=png&auto=webp&s=2f718a23e5c438458448dbd3d7299ace31b4967d

similarity(g_Directed, method = "invlogweighted")

https://preview.redd.it/zv9ye85vv4m51.png?width=708&format=png&auto=webp&s=f6a835cba70732b2e0ca741b4acc01216e003584

Does anyone know why this is the case?

(1) Why are numbers along the diagonal for the similarity matrix for the directed graph not a constant? Furthermore, some self-similarity cells are less than similarity to other nodes, which does not make any conceptual sense.

(2) Why do directed and undirected graphs confer different similarity matrices? They should be identical, right? I understand similarity to be agnostic to direction and simply concerned with common neighbors.

πŸ‘︎ 11
πŸ’¬︎
πŸ‘€︎ u/Stauce52
πŸ“…︎ Sep 09 2020
🚨︎ report
[Linear Algebra] Determinant of matrix which has all zero entries except for ones just above and below the main diagonal

https://imgur.com/8qaQuQ8

I found the general pattern, but need help quantifying in terms of n. For example, detA2 is -1, detA3 is 0, detA4 is 1, detA5 is 0, etc...

How exactly do I say what detAn is for any n? I know that it is 0 for odd n, but I am struggling with making the summation. The pattern continuing forever is pretty self-explanatory once the rule is found, right?

Thank you in advance for any help you can provide!

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Darthjacobous
πŸ“…︎ Oct 26 2020
🚨︎ report
[Matrix Multiplication] Diagonal and Antidiagonal matrix multiplication

Hi all,

For a homework question, I had to multiply two arbitrary diagonal matrices together and two arbitrary antidiagonal matrices together. I got that two diagonal matrices multiplied together is commutative, where AB=BA no matter what. However, on the two antidiagonal matrices, I am a little unsure if my reasoning is correct. I got that two antidiagonal matrices multiplied together is a diagonal matrix, but I am unsure about the contents of the matrix.

Is what I have correct? Please see my work. Thank you very much for your help!

https://imgur.com/gallery/kuze2kc

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Darthjacobous
πŸ“…︎ Oct 03 2020
🚨︎ report
JBD will launch worlds smallest 640x480 Active Matrix microLED display in 2020 | 0.13" diagonal
πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ May 29 2020
🚨︎ report
igraph: Why does inverse log weighted similarity for a directed graph produce similarity along the diagonal that is lower than it's similarity to other nodes? Self-similarity should be constant (akin to 1's on a correlational matrix) but here it's not. However, for undirected graph, diagonals are 0s /r/rstats/comments/ip9xfs…
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Stauce52
πŸ“…︎ Sep 09 2020
🚨︎ report
igraph: Why does inverse log weighted similarity for a directed graph produce similarity along the diagonal that is lower than it's similarity to other nodes? Self-similarity should be constant (akin to 1's on a correlational matrix) but here it's not. However, for undirected graph, diagonals are 0s /r/rstats/comments/ip9xfs…
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Stauce52
πŸ“…︎ Sep 09 2020
🚨︎ report
Is there a way to change the order of diagonal matrix multiplication?

If I have a matrix multiplication T*D*T*D*T, where D is some diagonal matrix and T is some general matrix. Is there a way to change the order of the multiplication such that I can have something multiplied to T^3 ?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/shenlongdaren
πŸ“…︎ Jul 01 2020
🚨︎ report
Is there a way to enter the same formula over the diagonal elements of a matrix all at once?

My brother is working on his thesis and needs to edit a formula over all the diagonal elements of his 292x292 matrix. Is it possible to select the cells and insert the formula all at once?

We have done some searching online and found a macro for selecting diagonal elements, but it doesn't allow to copy a formula over the complete selection, as it would when selecting a column or row.

Any idea how this could be done?

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/jaspeirdenbeir
πŸ“…︎ Apr 23 2020
🚨︎ report
How would you concisely represent the diagonal and off diagonal elements of a matrix?

I've recently come across some notation I've never seen before used to represent the diagonal and off diagonal elements of a matrix.

I've attached a link to the excerpt in question as I'm not 100% how to write matrices and whatnot in reddit.

https://imgur.com/a/AK60G5t

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/ConcernedOperator
πŸ“…︎ Jan 05 2020
🚨︎ report
Finding the coordinates of a diagonal word in a matrix (python).

I have been stuck for several days now on how to find the coordinates of the first letter of a word given in a matrix, assuming that the word is diagonally found in the matrix. I already have the code to find the diagonal words in a matrix but, I can't seem to find a way to get the coordinates(index) of the first letter. The code that finds the diagonal words is :

for x in range(column_length+row_length-1):
        tempList2=[]
        for y in range(min(x, column_length-1), max(0, x-row_length+1)-1, -1):
            tempList2.append(rows[column_length-1-y][x-y])
        negative_slopes2.append(tempList2)
        for number,word in enumerate(negative_slopes2):
            candidate=''.join(word)
        for word in words:
            if word in candidate:  
                solution.update({word:('down-right',column_length-1-y,x-y)})
print(solution)

I tried using the `column_length-1-y, x-y` but it does not really work it gives the coordinates of a wrong letter. The code above essentially creates an 'artificial' row that finds all the possible diagonals in a matrix (including non-words) then it filters the diagonals that contain the word I am looking for. With this I cannot use the index of that "artificial row" since it would have a different indexing from the original Matrix. What are the possible solutions to my problem?

I have been running around for circles on how I am going to be solving this. This is literally the last wall that blocks me from finishing my project. Any help would be gladly appreciated!

πŸ‘︎ 10
πŸ’¬︎
πŸ‘€︎ u/Monsi_Boy
πŸ“…︎ Sep 28 2019
🚨︎ report
Iris dataset as scatter plot matrix with histograms on diagonal. [OC]
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/hageldave
πŸ“…︎ Jun 08 2019
🚨︎ report
Finding all elements of a matrix on a diagonal 'line'

Hi,

I have a large matrix (~1000Β²) that contains grayscale values of an image. I now want to write a function that takes two positions (element indeces, eg (45,298) and (450,356)) and returns a vector (or any other container) with all values that were 'touched' by the line between the elements. 'Touched' means that the line crossed over the space between the index and the next indeces (if you imagine a piece of grid paper, you would draw a line between two points, which would 'touch' each filed it gets into). I hope I could convay what I am looking for. Is there any maths that could help me? I tried bruteforcing it (calculate the 'line''s x-coordinate on every y and vice versa and check for the elements), but it never really worked.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/AnonAustria13
πŸ“…︎ Aug 06 2019
🚨︎ report
[Algorithm help] Most computationally efficient algorithm to create square matrices of 1's along the diagonal of a large matrix

Given a list of numbers, for example [2, 4, 1, 3], create a square matrix of dimension sum(list) x sum(list) , where along the diagonals , there are square matrices of the sizes specified by the list. In the case of [2, 4, 1, 3] , that would result in

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

The method should generalize to any (positive) values in the list, and any length of list.

Assume that we have access to all the numpy operations https://docs.scipy.org/doc/numpy/reference/routines.html

What I came up so far:

Brute force method: Create each sub matrix individually, and then concatenate them

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Oct 23 2019
🚨︎ report
Finding the coordinates of a diagonal word in a matrix (python).

I have been stuck for several days now on how to find the coordinates of the first letter of a word given in a matrix, assuming that the word is diagonally found in the matrix. I already have the code to find the diagonal words in a matrix but, I can't seem to find a way to get the coordinates(index) of the first letter. The code that finds the diagonal words is :

for x in range(column_length+row_length-1):
        tempList2=[]
        for y in range(min(x, column_length-1), max(0, x-row_length+1)-1, -1):
            tempList2.append(rows[column_length-1-y][x-y])
        negative_slopes2.append(tempList2)
        for number,word in enumerate(negative_slopes2):
            candidate=''.join(word)
        for word in words:
            if word in candidate:  
                solution.update({word:('down-right',column_length-1-y,x-y)})
print(solution)

I tried using the `column_length-1-y, x-y` but it does not really work it gives the coordinates of a wrong letter. The code above essentially creates an 'artificial' row that finds all the possible diagonals in a matrix (including non-words) then it filters the diagonals that contain the word I am looking for. With this I cannot use the index of that "artificial row" since it would have a different indexing from the original Matrix. What are the possible solutions to my problem?

I have been running around for circles on how I am going to be solving this. This is literally the last wall that blocks me from finishing my project. Any help would be gladly appreciated!

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Monsi_Boy
πŸ“…︎ Sep 28 2019
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.