Questions tagged [diagonal]

Diagonal means either a diagonal matrix (usually a square matrix) in which the entries outside the main diagonal are all zero. The diagonal entries themselves may or may not be zero. Or, the values of the diagonal matrix.

Since a lot of things in programming is based on matrices doing thing horizontal or vertical is often easier then doing it diagonal. Questions dealing with these difficulties should be tagged diagonal.

Diagonal matrices occur in many areas of linear algebra. Because of the simple description of the matrix operation and eigenvalues/eigenvectors, it is always desirable to represent a given matrix or linear map by a diagonal matrix.

You probably want to add more specific tags about the technology you are using. Areas where the tag ´diagonal´ becomes relevant often drawing and animation.

584 questions
-1
votes
2 answers

Elements north, south, east, west of the diagonal intersection within a matrix

I want to know the conditions for the 4 main areas of a matrix besides the diagonals. For example in the following matrix A=[1,2,3,4,5; 6,7,8,9,10; 11,12,13,14,15; 16,17,18,19,20; 21,22,23,24,25;] The elements from the north side would…
user7228367
-1
votes
1 answer

How to have diagonal labels in R Corrgram?

Corrgram docs have been misleading, since 2012, as discussed in the email thread how to change variable names in corrgram diagonal about putting labels on the diagonal. Many users think wrongly that diag.panel=... is the solution but it is not as…
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
-1
votes
1 answer

How to fill a 2D array diagonally

I have a 2D char array that I need to fill with color codes to create synthetic images that have patterns. The array is filled with zeros, which end up returning a black image if run through a separate program. I need to fill the array diagonally…
Collecto
  • 89
  • 9
-1
votes
1 answer

Matrix diagonal elements of a matrix

I want to create a matrix where The matrix is diagonal elements of the matrix elements other? without loop in Matlab A=[1 2;3 4] B=[1 0 0 0;0 2 0 0;0 0 3 0;0 0 0 4]
abbas
  • 57
  • 6
-1
votes
2 answers

How do you find the diagonal (left to right) opposite of a coordinate in a 10x10 grid blocks

I need to create a function that finds the diagonal opposite of a coordinate in a 10x10 grid…
bbnn
  • 3,505
  • 10
  • 50
  • 68
-1
votes
2 answers

Diagonal Shapes with CSS

What is the best way to create a diagonal shape like this with pure CSS maybe only using :after and :before pseudo elements on the content div? Thanks.
Lukas Hillebrand
  • 390
  • 5
  • 20
-1
votes
3 answers

Diag function om multiple dimensions in R

I would like to use the diag() function on a list of vectors, so as to get a list of matrices where the diagonals are the vectors of my list. To be more specific, suppose I have a list called list of 100 vectors with 14 values each. >dim(list) 100…
Chris
  • 13
  • 2
-1
votes
1 answer

Replace one element of a column in another

Let A and B be column vectors: A = (1:6).'; %'// [1;2;3;4;5;6] B = (7:12).'; %'// [7;8;9;10;11;12] How do I construct a matrix such that one element of A is replaced each time by an element from B to get C as: C = [... 7 1 1 1 1 1 2…
Jessi
  • 33
  • 7
-1
votes
3 answers

How to create a diagonal within a nested for loop?

Ok, so I have to create something that looks like this: Enter dimension of board: 8 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 My problem is that my code will only…
adamscott34
  • 11
  • 1
  • 7
-1
votes
2 answers

How do I get calculate the sum of the diagonal of a specified element in a matrix?

for eg if i have a matrix 4 5 9 8 3 8 3 2 4 10 1 3 1 9 9 6 7 7 2 1 7 4 6 7 2 6 3 5 4 2 7 2 2 9 3 4 How do I calculate the…
TYL
  • 1,577
  • 20
  • 33
-1
votes
1 answer

Drawing a responsive diagonal line

This is what I want: a page split in two vertical parts: a red one with contents (200px in the fiddle) + the right part is a diagonal that goes top-left (200, 0) to bottom-right of the browser window. I'd like this line to be responsive to any page…
jcptzr
  • 1
  • 2
-1
votes
2 answers

Convert a matrix in R into a upper/lower triangular matrix divided by secondary diagonal

I know that with upper.tri() and lower.tri() I can get upper and lower triangular matrix divided by primary diagonal. But what is the fastest way to get triangular matrix divided by the secondary diagonal?
Vadym B.
  • 681
  • 7
  • 21
-1
votes
1 answer

How to make a sprite move diagonally?

I have a sprite that needs to follow the command of an arrow sprite that rotates, right now I can only make my sprite move up,down and left,right. How about diagonally? I have no Idea how to do that, the sprite also needs to move always towards…
Kevin Bryan
  • 1,846
  • 2
  • 22
  • 45
-1
votes
1 answer

ruby diagonal of a rectangle

I am trying to create a method that returns the length of a rectangle/square diagonal as a float. However, my method diagonal doesn't seem to work as intended. I guess I have hit a road block and would like to see if any of you had an idea on how I…
Nappstir
  • 995
  • 2
  • 20
  • 38
-1
votes
2 answers

print 2d array diagonally from bottom to top

I have a two dimensional array in my java prgm [ 1 2 3 4 5 6 7 8 9 ] How to arrange this matrix diagonally in clockwise direction..such as [ 9 8 6 7 5 3 4 2 1 ] this should be applicable for all square matrix of order N. can…
lpd
  • 51
  • 2
  • 11