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
2
votes
2 answers

Build diagonal matrix without using for loop

I am trying to build the following matrix in Python without using a for loop: A [[ 0.1 0.2 0. 0. 0. ] [ 1. 2. 3. 0. 0. ] [ 0. 1. 2. 3. 0. ] [ 0. 0. 1. 2. 3. ] [ 0. 0. 0. 4. 5. ]] I tried the fill_diagonal…
wigging
  • 8,492
  • 12
  • 75
  • 117
2
votes
1 answer

How can I have the diagonal and reverse diagonal crossing a point in a 2D matrix?

I have the following matrix (per se) and I want to find its diagonal and its reverse diagonal given any point in it. I can think of the algorithm but I am not sure what R function will help me to implement it. Like I know how to access all the rows…
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
2
votes
3 answers

Chess, algorithm to find last location moving diagonally

This may be a little hard to explain without a picture but, I am in the process of checking to see if the king is in check. To do so, I am starting at the king's location and going up, left, down, right, then all the diagonal patterns. To simplify…
Matt C
  • 4,470
  • 5
  • 26
  • 44
2
votes
4 answers

Change diagonal of a non square matrix

Suppose I have this kind of matrix: 1 2 3 3 2 3 4 5 6 7 8 9 3 2 3 How do I add a diagonal of ones into this? Is there an easy way? To show what I mean: 1 2 3 3 1 3 4 5 1 1 8 9 3 1 3
Paulinchen2
  • 125
  • 1
  • 6
2
votes
1 answer

set some diagonal elements of a matrix in Matlab

A quick question, I have a sparse matrix A and a index list b = [2, 3, 4 ...], I want to set A(2, 2), A(3, 3), A(4, 4)... = 0. I tried A(b, b) = 0, the result is that A(2, 3), A(2, 4), A(3, 2), A(3, 4), A(4, 2), A(4, 3) and some non-diagonal…
ivory
  • 243
  • 4
  • 16
2
votes
3 answers

How do I diagonalize a matrix quickly in C++?

I don't know which library to choose (for windows): LAPACK++, Armadillo, IT++, Eigen, or maybe something else? All I need to do is to check if a big (about 10,000*10,000) matrix is diagonalizable, and if so, to get the diagonal and the invertible…
Ella Sharakanski
  • 2,683
  • 3
  • 27
  • 47
2
votes
2 answers

Weird CSS behavior - Diagonal border - Why is the border edge not straight?

I want to add a white gap between menu elements but Im encountering a weird problem. See this jfiddle: http://jsfiddle.net/ERYat/1/ Here is the CSS code: /* a styling */ ul#menu-menu-services a { display: block; font-size: 20px; color:…
2
votes
1 answer

Extract and set thick diagonal of numpy array

I have a simple numpy question. How can I extract and consequently set a diagonal having a "thickness" equal to width with a constant value? I know the fill_diagonal function which fills the main diagonal with the given value. Similar to that I want…
mg007
  • 2,888
  • 24
  • 29
2
votes
2 answers

Efficient way to make a multi-diagonal matrix

Is there an efficient way to produce square multi-diagonal matricies such as these: [[1,2,3], [2,1,2], [3,2,1]] [[1,2,3,4,5], [2,1,2,3,4], [3,2,1,2,3], [4,3,2,1,2], [5,4,3,2,1]] My efforts so far have produced the…
Richard
  • 56,349
  • 34
  • 180
  • 251
2
votes
2 answers

CSS3 1px diagonal lines gradient

I want to create a diagonal pattern using CSS3, something like this: So 1px dark diagonal line, 1px light diagonal line and so on... This is what i came up with, i feel like i'm close but something is defenitely not right: background-color:…
passatgt
  • 4,234
  • 4
  • 40
  • 54
2
votes
9 answers

How to put a diagonal line over a textbox in CSS?

Sorry about not having an example, but basically I want to give an effect of having a text box crossed out, like being cancelled, etc. Anyone got any ideas?
Lucas
  • 16,930
  • 31
  • 110
  • 182
2
votes
1 answer

Put labels on the diagonal of a matrix in a Matlab Plot

In Matlab, suppose you imagesc a square matrix. Is there a way to plot the Xticklabels on the diagonal?
LeonaRdo
  • 124
  • 1
  • 9
2
votes
0 answers

UIGestureRecognizer in master/detail for diagonal movement interfering with sub view

I have a master detail template application with a specific view that needs to have gestures disabled (specifically right swipe since that fires up the table view under the UISplitViewController). I have added the following code snippet to my view's…
Brent
  • 21
  • 1
1
vote
2 answers

Dynamic programming approximation

I am trying to calculate a function F(x,y) using dynamic programming. Functionally: F(X,Y) = a1 F(X-1,Y)+ a2 F(X-2,Y) ... + ak F(X-k,Y) + b1 F(X,Y-1)+ b2 F(X,Y-2) ... + bk F(X,Y-k) where k is a small number (k=10). The problem is, X=1,000,000 and…
ElKamina
  • 7,747
  • 28
  • 43
1
vote
2 answers

Multiplication of Vectors with diagonal of a matrices from t to t+1 in Matlab

Still very new to programming... I have 9x1 Vectors at time t, t+1, t+2 etc. [10 10 10 10 10 10 10 10 10]' and matrices. Each matrix is 9x9 and also at time 1, t+1, t+2 etc. = 1 0 0 0 0 0 0 0 0 0 1 0 0 …
Tetra
  • 747
  • 2
  • 9
  • 15