diagonal

How can I index the diagonals of a 3-D matrix in MATLAB?

你。 提交于 2019-12-13 00:55:38
问题 I have an M-by-M-by-N matrix, which is a concatenation of N M-by-M matrices. I want to reduce this matrix to an M-by-N matrix by taking the diagonals of each M-by-M submatrix and concatenating them together. How can I do this in a simple vectorized way? 回答1: You can do it by getting the linear indices of the diagonals and using it to form a new matrix [M,~,N]=size(A);%# A is your matrix indx=cumsum([1:(M+1):M^2; M^2.*ones(N-1,M)]);%#diagonal indices B=A(indx');%'# transpose to get MxN In the

CSS diagonal lines - how to fit into its parent element?

时光毁灭记忆、已成空白 提交于 2019-12-12 09:51:46
问题 How can I make a diagonal line fill in and fit into a box (just pure css - without any use of background image)? div.diagonal-container { border: 1px solid #000; width:400px; height:400px; margin: 0 auto; } .to-right, .to-left { border-top:1px solid #ff00ff; width:100%; -moz-transform: rotate(45deg); -o-transform: rotate(45deg); -webkit-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); } .to-right { -moz-transform: rotate(-45deg); -o-transform: rotate(-45deg);

Removing diagonal elements from matrix in R

情到浓时终转凉″ 提交于 2019-12-12 07:57:51
问题 How can I remove the diagonal elements (diagL) from my matrix L using R? I tried using the following: subset(L, select=-diag(L)) or subset(L, select=-c(diag(L))) but I get 0 numbers... 回答1: The R programming language? I like C better, it is easier to spell. One way is to create a matrix with the numbers the way I like them to look: a<-t(matrix(1:16,nrow=4,ncol=4)) which looks like: [,1] [,2] [,3] [,4] [1,] 1 2 3 4 [2,] 5 6 7 8 [3,] 9 10 11 12 [4,] 13 14 15 16 Delete the values on the diagonal

How to have diagonal labels in R Corrgram?

非 Y 不嫁゛ 提交于 2019-12-12 06:53:12
问题 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 seen in the following, but I cannot use labels because it is still not yet documented yes, the argument "labels" it's working fine! It would be great if the docs will be be updated also with this already implemented feature Code library("corrgram")

How to Specify a diagonal matrix using tf.get_variable

隐身守侯 提交于 2019-12-11 17:43:33
问题 I am trying to create a diagonal matrix using tf.get_variable But I do not know how! Like I can make a variable which is a diagonal matrix like: dia_size = tf.zeros((num_filters, img_size)) b = tf.Variable(tf.matrix_diag(dia_size), name=name) b = tf.reshape(b, [-1, img_size, img_size, num_filters]) but I can not do it with tf.get_variable. Thanks for your help in advance! 回答1: If you set the initializer parameter of tf.get_variable to a tensor, the variable will be initialized to the tensor's

numpy functions that can/cannot be used on a compressed sparse row (CSR) matrix

假如想象 提交于 2019-12-11 17:21:55
问题 I am a newbie in Python and I have a (probably very naive) question. I have a CSR (compressed sparse row) matrix to work on (let's name it M ), and looks like some functions that are designed for a 2d numpy array manipulation work for my matrix while some others do not. For example, numpy.sum(M, axis=0) works fine while numpy.diagonal(M) gives an error saying {ValueError}diag requires an array of at least two dimensions . So is there a rationale behind why one matrix function works on M while

adding a small value to only the diagonal elements of a matrix

雨燕双飞 提交于 2019-12-11 14:14:33
问题 I am a newbie to matlab and I am trying to find out the inverse of matrix with very small values. When i try to find the inverse I get an error saying that the matrix is singular. One of the solutions suggested is to try and add some elements to the diagonal elements. I know i have to use eye and diag methods but I am not able come up the correct soltion. Any comments will be helpful. 回答1: If you just want to add the identity matrix or a multiple of it to your square matrix, you can do A_new

Adding Diagonals of a matrix using R

狂风中的少年 提交于 2019-12-11 04:12:42
问题 I would like to add up the upper part diagonals of a matrix starting from the middle, with increment in column until (1,n), n being the last column and save each sum of every diagonal. My code only add the middle diagonal, how can I loop through the matrix to get the sum of the diagonals A <- matrix(c(2, 4, 3, 1, 5, 7, 1, 2, 3, 2, 3, 4, 1, 5, 6, 0), # the data elements nrow = 4, # number of rows ncol = 4, # number of columns byrow = TRUE) # fill matrix by rows sum <- 0 print(A) for (a in 1){

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

笑着哭i 提交于 2019-12-11 04:09:34
问题 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 matrix such that D=(P^(-1))*A*P. This has to be done as fast as possible. I have no idea which library to use. Also, I'll be happy to know in general what are the pros and cons of each of these libraries. 回答1: This may be a rather vague answer, since

CSS3 1px diagonal lines gradient

白昼怎懂夜的黑 提交于 2019-12-11 03:03:36
问题 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: #454545; background-image: repeating-linear-gradient(-45deg, rgba(0,0,0,0.2), rgba(0,0,0,0.2) 1px, transparent 1px, transparent 4px); Demo: http://tinkerbin.com/6mTBtADt 回答1: just use background-size with your exisiting code try to add this background-size