matrix

How do I generate an adjacency matrix of a graph from a dictionary in python?

不打扰是莪最后的温柔 提交于 2021-02-06 09:32:04
问题 I have the following dictionary: g = { 'A': ['A', 'B', 'C'], 'B': ['A', 'C', 'E'], 'C': ['A', 'B', 'D'], 'D': ['C','E'], 'E': ['B','D'] } It implements a graph, each list contains the neighbors of the graph vertices (dictionary keys are the vertices itself). I'm in trouble, I can not think of a way to get a graph adjacency matrix from their lists of neighbors, might be easy but I am new to python, I hope someone can help me! I am using Python 3.5 I need to generate the following matrix: 回答1:

R vectorized array data manipulation

半城伤御伤魂 提交于 2021-02-06 02:40:59
问题 I think there will be much more people interested into this subject. I have some specific task to do in the most efficient way. My base data are: - time indices of buy and sell signals - on the diag of time indicies I have ROC (rate of change) between closest buy-sell pairs: r <- array(data = NA, dim = c(5, 5), dimnames = list(buy_idx = c(1,5,9,12,16), sell_idx = c(3,7,10,14,19))) diag(r) <- c(1.04,0.97,1.07,1.21,1.1) The task is to generate moving compound ROC on every possible window (buy

R vectorized array data manipulation

为君一笑 提交于 2021-02-06 02:27:23
问题 I think there will be much more people interested into this subject. I have some specific task to do in the most efficient way. My base data are: - time indices of buy and sell signals - on the diag of time indicies I have ROC (rate of change) between closest buy-sell pairs: r <- array(data = NA, dim = c(5, 5), dimnames = list(buy_idx = c(1,5,9,12,16), sell_idx = c(3,7,10,14,19))) diag(r) <- c(1.04,0.97,1.07,1.21,1.1) The task is to generate moving compound ROC on every possible window (buy

PDF 1.7 - How exactly does the CTM (Current Transformation Matrix) work?

眉间皱痕 提交于 2021-02-05 20:27:40
问题 After reading the Adobe PDF 1.7 (ISO 32000-1:2008) specification, I'm still having trouble understanding how to properly create my transformation matrix. The specification in section 4.2/4.3 state the following: • Translations are specified as [ 1 0 0 1 tx ty ], where tx and ty are the distances to translate the origin of the coordinate system in the horizontal and vertical dimensions, respectively. • Scaling is obtained by [ sx 0 0 sy 0 0 ]. This scales the coordinates so that 1 unit in the

PDF 1.7 - How exactly does the CTM (Current Transformation Matrix) work?

五迷三道 提交于 2021-02-05 20:27:27
问题 After reading the Adobe PDF 1.7 (ISO 32000-1:2008) specification, I'm still having trouble understanding how to properly create my transformation matrix. The specification in section 4.2/4.3 state the following: • Translations are specified as [ 1 0 0 1 tx ty ], where tx and ty are the distances to translate the origin of the coordinate system in the horizontal and vertical dimensions, respectively. • Scaling is obtained by [ sx 0 0 sy 0 0 ]. This scales the coordinates so that 1 unit in the

Importing an array from matlab into R

送分小仙女□ 提交于 2021-02-05 20:11:05
问题 I'm sure this is a simple problem, but I haven't been able to find an obvious solution. I have a series of model output array files (dim 180, 360, 12) generated in matlab that I need to open in R. I have attempted to use the R.matlab package, simply using the readMat command, and this results in a list object. Attempting to write this list into a matrix results in a memory allocation error. I have tried unlisting, but that did not help either. How can I open these matlab matrix files and

Importing an array from matlab into R

五迷三道 提交于 2021-02-05 20:06:41
问题 I'm sure this is a simple problem, but I haven't been able to find an obvious solution. I have a series of model output array files (dim 180, 360, 12) generated in matlab that I need to open in R. I have attempted to use the R.matlab package, simply using the readMat command, and this results in a list object. Attempting to write this list into a matrix results in a memory allocation error. I have tried unlisting, but that did not help either. How can I open these matlab matrix files and

convert Matrix of type CV_32FC1 to CV_64FC1

三世轮回 提交于 2021-02-05 14:36:53
问题 How do I convert a cv::Mat of type CV_32FC1 to the type CV_64FC1 (equivalent to a change from float to double)? I am opening a Matrix that was saved as XML ( cvSave ) but as a float. This means that the field <dt> has the value f in the file. I need to change it to d to open it. But I'd rather not do this, instead I'd like to open it directly as a Matrix with elements of type double, or convert it later from float to double. Below is my code for opening the file. /** Load cv::Mat from XML

How do I change a certain value in a matrix in Haskell?

烂漫一生 提交于 2021-02-05 08:48:47
问题 I'm very new to Haskell and haven't fully understood how it works yet. In the following method I would like to change a certain value in a matrix or as it is realized in Haskell, a list of lists. setEntry :: [[Int]] -> Int -> Int -> Int -> [[Int]] setEntry x i j aij = This is my method so far. I know it's not much but I really don't know how to continue. The plan is to give it a matrix and then change the value that can be found in the ith line and the jth column to aij. I'd be very grateful

Insert vector into matrix at specific columns

别等时光非礼了梦想. 提交于 2021-02-05 08:31:25
问题 How would I insert a vector b into a matrix at column col? I cannot find any syntax for and insert or append function in Fortran. So far all I have done is reassigned the values in the column, but I only want to insert the vector. real :: M(n,n) integer :: n, col real :: b(n) M(n:col) = b(:) 回答1: If I understood of your problem, you want to: increase the number n of columns of the matrix m by 1; insert the content of a vector b in m as a new column, at index col ; right-shift the remaining