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
1 answer

Efficiency of diag() - MATLAB

Motivation: In writing out a matrix operation that was to be performed over tens of thousands of vectors I kept coming across the warning: Requested 200000x200000 (298.0GB) array exceeds maximum array size preference. Creation of arrays greater…
marcman
  • 3,233
  • 4
  • 36
  • 71
2
votes
1 answer

TypeError: 'dia_matrix' object has no attribute '__getitem__' - Python

I'm currently trying to dot product a row from a diagonal matrix formed by scipy.sparse.diags function in "Poisson Stiffness" below, but i am having trouble selecting the row and am getting the following error: TypeError: 'dia_matrix' object has no…
James
  • 395
  • 2
  • 8
  • 16
2
votes
2 answers

How to make an array of diagonal matrices in R?

I know how I can make an array of N numbers of p*p matrices: m=array(x, c(p,p,N)) which x could be a vector or a scalar. I want to make an array of diagonal matrices. Each matrix should be diagonal. I tried several ways but they don't work. Does…
Le1887
  • 19
  • 5
2
votes
1 answer

Extend a diagonal line by a value

I have a line lets say X1="184.357" Y1="-39.3242" X2="244.261" Y2="-30.96551" And I wish to extend the endpoint by 5. How to achieve the extend of line by the value specified? I have created a methods which calculates but I am not sure if it is…
Pankaj Nikam
  • 665
  • 7
  • 22
2
votes
3 answers

Shell script, use awk for diagonal word search

Im looking for a way to get al the diagonal combinations from this block of letters: a b c d e f h i j k l m o p q r s t v w x y z a c d e f g h j k l m n o i have this: awk '{++f; print $(f + 0)}' file.txt but that only gets me ( if i can…
Brutalized
  • 85
  • 2
  • 9
2
votes
1 answer

Sparse matrix vector multiplication using MKL DIA routine

I am using the MKL library to perform the sparse matrix vector multiplication using diagonal format, When I use the MKL mkl_sdiagemv function I get a "MKL ERROR: Parameter 4 was incorrect on entry to MKL_SDIAGEMV. " error.
The Hiary
  • 109
  • 1
  • 13
2
votes
3 answers

Dividing a list into diagonals?

If I have this list of lists: l = [ ['a','r','v','s','s','t','n','g'], ['e','x','a','m','p','l','e','t'], ['g','z','n','p','u','t','x','m'], ['v','a','h','g','i','k','t','f'] ] How can I easily divide it into a list of list according to…
user3814630
  • 167
  • 1
  • 2
  • 4
2
votes
1 answer

Row sums of matrix over/under diagonal

I want to calculate row/col sums for upper/lower triangle matrix (with diagonal). Example: m <- matrix(1:9, nrow=3) #result: upperRowSums(m) ## [1] 12 13 9 lowerRowSums(m) ## [1] 1 7 18 I know that this could be done with simple for loop, but I…
bartektartanus
  • 15,284
  • 6
  • 74
  • 102
2
votes
1 answer

Create slope full width css3

I'm trying to create a slope/diagonal with SVG (first time, other alternatives accepted) and im having a lot of issues with it. My goal is: Create a full width slope (ready for responsive) I want to have the slope on top of a div section and other…
uniqezor
  • 179
  • 1
  • 6
  • 17
2
votes
2 answers

How to distribute 5-digit numbers in 5x5 matrices

I have 98000 5-digit numbers, from 00001 to 98000. I need to distribute these 98000 numbers in 14000 5x5 matrices. A matrix cell must contain only a digit from 0 to 9. Each matrix must receive 7 numbers from the 98000: one number in each line and…
wind39
  • 441
  • 4
  • 14
2
votes
3 answers

How do you style triangular mask in CSS?

I have been looking at how to do this "inverse triangular" background using css. I am referring to the white diagonal parts on the bottom, on top of the background (fixed) image. The most I've gotten is to shapes, which aren't apparently a good…
antonio1475
  • 49
  • 1
  • 7
2
votes
1 answer

Pandas Dataframe: Reduce Diagonal Sub-Frame to Single Row or How to Fill a Dataframe Piece by Piece

In a client/server application, data is requested from the server and the incoming replies mapped using a request id: --> Request data for item i using request_id 1 --> Request data for item j using request_id 2 : <-- Data element i.p for…
user3650713
  • 47
  • 1
  • 4
2
votes
1 answer

Get Diagonals in a Matrix

Using Racket, and avoiding any stateful functions (ones that end with an exclamation mark), I am trying to get all "diagonal strips" in a list of lists, or a vector if that is easier. This is a part of solving the "N-Queens" Chess problem, but I'd…
BlackVegetable
  • 12,594
  • 8
  • 50
  • 82
2
votes
1 answer

How to fill in a matrix given diagonal and off-diagonal elements in r?

I have the elements for a matrix as follows: diag= rep(1,5) offdiag = c(rep(1:4), rep(1:3), rep(1:2), 1) The final matrix I want should should be a symmetric matrix that looks like this: 1 1 2 3 4 1 1 1 2 3 2 1 1 1 2 3 2 1 1 1 4 3 2 1 1 where the…
wen
  • 1,875
  • 4
  • 26
  • 43
2
votes
2 answers

Calculate rectangle's points from diagonal in 3D

I know 3 points in a 3D plane. Two points are the ends of a diagonal and an other one which is random point on the plane. How can I calculate the two other points of a rectangle from the known diagonal line? (Later I will use the points to calculate…