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

Problems writing code to draw a rhombus

So i have assignment to type a code which will ask me for a "w". After i type in a number it will create a rhombus with a diagonal which is 2w. The rhombus must be made of intervals and * . The problem that i face now is that when i type w=5 the…
Juginator
  • 9
  • 1
  • 5
-1
votes
1 answer

Diagonal Lines in HTML in 8 different directions

Through a JAVA program, I am generating a Word Search Puzzle in HTML (using table / tr / td options). I am trying to generate another table showing the solution to that puzzle. For example, as shown…
SRKJ
  • 29
  • 5
-2
votes
1 answer

how I can modify the diagonal of a request matrix to be zeros where i = j

I'm doing a matrix with python exporting at excel (library openpyxl) with a request by keyboard cell by cell. My question is how in that request I don't request the diagonal of the matrix and instead refill it with zeros. Here is my…
toborrm
  • 35
  • 6
-2
votes
1 answer

Diagonalizing Matrix A without using any libraries

How can I create Matrix P consisting of three eigenvector columns by using a double nested loop. from sympy.matrices import Matrix, zeros from sympy import pprint A = Matrix([[6,2,6], [2,6,6], [6,6,2]]) ew_A = A.eigenvals() ev_A =…
chaos
  • 5
  • 5
-2
votes
1 answer

Getting sum of each diagonal of a 2D matrix in Python

Imagine I have an n x n matrix. I want to get the sum of each diagonal and print it to the user. For n=3 I can have matrix = [[1,2,3], [1,2,3], [1,2,3]] I would get this printed: sum1 = 3 sum2 = 5 sum3 = 6 sum4 = 3 sum5 = 1 I want to implement it…
-2
votes
1 answer

Sum of diagonals in matrice nxn matlab

How do you calculate the sum of the elements of both diagonals in a matrix nxn but making sure that the middle element, if there is one, is not counted twice in the sum. Thank you!
-2
votes
2 answers

Do not know how to change "under the diagonal" numbers to negative in a matrix

My task is to let user enter number n and then the matrix forms with dimensions n*n. Program then, makes diagonal have zeros, number above diagonal have to be positive numbers (1,2,...,n), and numbers below diagonal have to be negative numbers…
casual
  • 39
  • 6
-2
votes
1 answer

How to print all the diagonal elements of a 2d vector

I'm looking for a C++ way using vector to get all the diagonals of a (square) matrix, represented as a 2d vector. matrix = [ [1,2,3,4], [5,1,2,3], [9,5,1,2]] But I have trouble coming up with a way to generate all the diagonals. The output I'm…
R0bert
  • 507
  • 6
  • 30
-2
votes
1 answer

Side navbar to slide out into diagonal div

I'm very new to diagonal divs and need to replicate the attached home page and menu but I have absolutely no idea how. Please can someone point me in the right direction? I've googled it all day long but I can't find out what I'm really asking so I…
Jo Tidman
  • 37
  • 5
-2
votes
2 answers

How can I find the sum of a diagonal in a 2D Matrix?

I'm new to java. How can I find the sum of diagonals (that looks like /) in a 2D Matrix? Let's say the matrix looks something like this: 4 6 7 2 4 7 5 2 7 The sum of the diagonal(that looks like \) is 15 (4+4+7). Here's my code for that…
-2
votes
1 answer

we need to find the aboslute difference between sum of 2 diagonals. Please can u tell me where i am going wrong

Print the absolute difference between the sums of the matrix's two diagonals as a single integer. diagonalDifference(arr): sum1=0 sum2=0 for i in range(len(arr)): for j in range(len(arr)): if (i==j): …
-2
votes
1 answer

How to assign a matrix to the diagonals of another matrix in matlab

I have a matrix D = zeros (30, 432); i want to assign d = [ 1 1 0 0; 0 0 1 1; 0 0 0 0]; to the diagonals of matrix D. i have the code below but it doesn't allow me to assign d for every diagonal values in…
lighting
  • 400
  • 2
  • 13
-2
votes
1 answer

How to get all diagnoal elements in a matrix?

I'd like to write a function that determines all the diagonal elements in a matrix are same. For instance: ?-diagonal([[1,2,3,4], [2,1,5,6], [6,2,1,9], [8,7,5,1]]). true. Any help is appreciated.
Clark16
  • 73
  • 4
-2
votes
1 answer

Diagonal border on one side of a div

Click for the problem's illustration How should I implement this, given the fact that the background is not solid? I was trying different solutions, but none of them fully fit
Oscar
  • 805
  • 2
  • 10
  • 24
-3
votes
1 answer

Matrix diagonal

I would like to let you know that I'm new to this platform, I'm trying to solve this question, could anyone help me? statement The user must be prompted for the size of the matrix to be created. After user input, a square matrix is ​​created with…
1 2 3
38
39