Suppose I had the following matrix: matrix(c(1,1,2,1,2,3,2,1,3,2,2,1),ncol=3) Result: [,1] [,2] [,3] [1,] 1 2 3 [2,] 1 3 2 [3,] 2 2 2 [4,] 1 1 1 How can I filter/subset this matrix by whether or not each row has duplicate values? For example, in this case, I would only...

I do appreciate your helps! Thanks in advance! I have a huge text file in the following format: ********************************* timestep 455 No_Specs 3 H2 49 H2O2 1 O2 49 ********************************* timestep 460 No_Specs 3 H2O 49 H2O2 1 O2 49 ********************************* timestep 465 No_Specs 2 H2 50 O2 50 *********************************...

I there any way to avoid copy-on-modify for in-place modifications of matrices in R? I am trying to copy a smaller matrix to a slice of larger matrix as follows. library(data.table) y <- matrix(c(11,21,31,12,22,32),nrow=3,ncol=2) address(y) [1] "08429190" y[2:3,] <- matrix(c(1,1,8,12),nrow=2) address(y) [1] "0E033D28" ...

Let's say in my directory I have five files. Files: 1,2,3,4, & 5 I have a script that will do a mathematical process to compare two files and I want to use this script on every file in the directory, example below. compare file 1 to 2,3,4, & 5 compare...

I have a following problem where I have a dataframe (df): df <- data.frame(inp = c("inp1", "inp2", "inp3"), A = c(1,2,3), B = c(1,2,3)) I need to construct a inp*inp square matrix from this dataframe that complies to certain formulas for diagonal and off-diagonal elements. The diagonal elements are calculated...

I'm building a reasonably huge matrix with this constructor: var M = Matrix<double>.Build.Dense(N, N, (i, j) => SomeRoutine(i, j)); N is big and SomeRoutine is slow, so I'm trying to optimize things here and there. I noticed that for any i, j holds SomeRoutine(i, j) == SomeRoutine(j, i), i.e. M...

I'm trying to remove the rows which has duplicates in sequence. I have only 2 possible values which are 0 and 1. I have nXm which n shows possible number of bits and m is not important for my question. My goal is to find an matrix which is nX(m-a)....

I have a 4D matrix with dimensions 7x4x24x10 (Lets call it main_mat). I want to get a matrix of size 7x4x24 (rand_mat) so that each element of this (rand_mat) matrix is actually a uniformly random draw from the main matrix (main_mat). I am sorry if I have not put the...

I have a [32678 x 10] matrix (w2c) and I want to copy 24700 rows of it to another matrix(out). I have the index of the rows to be copied in a vector(index). For doing this in matlab I do: out = w2c(index_im,:); It takes approximately 0.002622 seconds. In OpenCV:...

I have a question regarding the extraction of the (raw) model matrix of random effects from models fitted with lmer (lme4) in R. More specifically, I want to obtain a data frame or a matrix that contains all variables that are involved in random effects terms. The matter is further...

Implementing the answer from this thread I have this code that translates the deltayaw, deltaroll and deltapitch angles into one angle and rotates a node around it. The angles that are taken as the parameters are momentary changes of angles since giving the whole angles would ignore the changes in...

Why does the top line of code create a zeroed out matrix but the bottom four lines of code give an error ("list assignment index out of range")? matrix = [ [ 0 for i in range (6)] for j in range(6)] matrix = [[]] for i in range (6):...

I have a matrix looks like: 0 0 0 0 0 1 0 0 0 0 0 2 0 0 0 0 0 2 0 0 0 0 0 1 0 1 0 0 0 1 0 4 0 0 0 0 0 3 0 0 6 0 0 4...

I'm trying to reshape a multidimensional array into the original image. I have split an image of 512x512 pixels in sub-matrices of 8x8 pixels using the great solution that I found in this question: sub_images = permute(reshape(permute(reshape(i_image, size(i_image, 1), n, []), [2 1 3]), n, m, []), [2 1 3]);...

So I have two matrices A= [3;0;0;0;0;0;0]; and B is 7x7 matrix, so I got it to print all the values of this system equation. Now, what I need help with is how can I get it to take the first answer and then divide it by the first value...

Problem description: I am trying to develop some 2D game with terrain collision in C# using XNA framework. I have already completed simple terrain generating and object, for example car, can move on this terrain. But now, I get a problem with camera fix to that car. I tried to...

I have a matrix in this format: year month Freq 1 2014 April 466 2 2015 April 59535 3 2014 August 10982 4 2015 August 0 5 2014 December 35881 6 2015 December 0 7 2014 February 17 8 2015 February 24258 9 2014 January 0 10 2015 January 22785...

I have a symmetric matrix (dimension: 12,000 X 12,000) named A and I want to create another one based on a formula, which depends on the elements position. To explain: I want to create the D matrix (based on the values from A) using the formula: Dij = 1 -...

I created this toy problem that reflects my much bigger problem: import numpy as np ind = np.ones((3,2,4)) # shape=(3L, 2L, 4L) dist = np.array([[0.1,0.3],[1,2],[0,1]]) # shape=(3L, 2L) ans = np.array([np.dot(dist[i],ind[i]) for i in xrange(dist.shape[0])]) # shape=(3L, 4L) print ans """ prints: [[ 0.4 0.4 0.4 0.4] [ 3. 3....

This question already has an answer here: MATLAB one liner for batch assignment in 2D matrix? 1 answer So I'm a beginner in MATLAB so this question might be trivial. Suppose x=[1 2 3 4 5] and y=[3 4 2 5 1] and img = zeros(5,5). I want to...

Say I have the following array/matrix in python (any language will do, to be honest). A = [0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1...

Well, I hope I explain it simple: I have a matrix: matrix(c("a","b","c",1,2,3), nrow=3, ncol=2) with output: [,1] [,2] [1,] "a" "1" [2,] "b" "2" [3,] "c" "3" I have a vector, for example: vector1 <- c("b", "a", "b", "c") I want that another vector to pick the values associated of...

I am trying to merge two matrices that share same values in multiple columns. The following matrices should exemplify my problem and provide a MWE. However, my data is very long size(500000, 4), therefore I am searching an efficient way to merge them. The data consists of option data where...

Long story short, I have this dataGridView and I want the cell [0,0] to be the cell on the lower-left corner of the grid, not on the top-left of the grid like it does by default. For example, visually, if i do something like: dataGridView1[0, 0].Value = "a"; I get...

fname = file.choose() two = read.csv(fname.header=T) rec = two$Receipt del = two$Delivery date = two$Date net = rec-del yrec = matrix(rec,nrow=365,ncol=4,byrow=F) ydel = matrix(del,nrow=365,ncol=4,byrow=F) ynet = matrix(net,nrow=365,ncol=4,byrow=F) yrecsum = 0 yrecavg = 0 for(i in 1:4) { for(j in 1:365) { yrecsum[i] = yrecsum[i]+yrec[j,i] } yrecavg[i] = yrecsum[i]/365 } So...

I'm having problems multiplying specific values within my multidimensional matrix by a scalar. My matrix has the following dimension: size(comDatabe) = 5 10 3 397 10 The third dimension is an x-y-z coordinate frame. Something went wrong and now my y-axis is defined upside down for one subject (#8 out...

I have a vector say a = c(1,2,3,4,5,6) I would like to organize them into the elements into an upper triangle matrix (without considering diagonal elements, they are all zero) by row. My goal is to get the following matrix: [,1] [,2] [,3] [,4] [1,] 0 1 2 3 [2,]...

I'm trying to create a simple way to change the Total column to either -1, 1, or 0. When x=1, y=1, z=1, then Total=1. When x=-1, y=1, z=1, then Total=-1. In all other cases, Total=0. So, rows 2013-07-03 and 2013-07-05 should have Total=1. Row 2013-07-09 should have Total=-1. All other...

I'd like to know how to calculate the factorial of a matrix elementwise. For example, import numpy as np mat = np.array([[1,2,3],[2,3,4]]) np.the_function_i_want(mat) would give a matrix mat2 such that mat2[i,j] = mat[i,j]!. I've tried something like np.fromfunction(lambda i,j: np.math.factorial(mat[i,j])) but it passes the entire matrix as argument for np.math.factorial....

In each iteration I want to add 1 randomly to binary vector, Let say iteration = 1, k = [0 0 0 0 0 0 0 0 0 0] iteration = 2, k = [0 0 0 0 1 0 0 0 0 0] iteration = 3, k = [0...

I am trying to compute pairwise correlations over rolling windows for n= 40 variables where all rolled pairwise correlations for 2 given variables are saved in a new variable. My dataset has the following structure: Date V1 V2 V3 . . . 01/01/2009 0.3 0.6 0.5 02/01/2009 0.1 0.5 0.2...

>>> A = np.matrix(np.zeros(2, 3))) >>> A.shape (2, 3) >>> A matrix([[ 0., 0., 0.], [ 0., 0., 0.]]) Does the matrix A have two rows with three zeros or two columns with three zeros?...

I have a large, sparse binary matrix (roughly 39,000 x 14,000; most rows have only a single "1" entry). I'd like to cluster similar rows together, but my initial plan takes too long to complete: d <- dist(inputMatrix, method="binary") hc <- hclust(d, method="complete") The first step doesn't finish, so I'm...

I'm trying to come up with a solution that takes in a matrix like this: [[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]] and returns an array traversing the array as a spiral, so in this example: [1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10] I'm having trouble getting this recursive solution to work, in which the result array takes the...

I'm learning three.js and am trying to multiply two translation matrices together to get a single matrix that describes both translations: | 1 0 0 -2 | | 1 0 0 3 | | 0 1 0 7 | * | 0 1 0 4 | | 0 0 1...

There's probably a name for the algorithm I want, but I'm not sure how to find it. I have lots of 96-well plates like this: 1 2 3 4 5 6 7 8 9 10 11 12 ------------------------------------ A | X O O O O O O O O O...

I need to transform the output of an aggregate (mean) into a matrix outer-like style. data(mtcars) aggregate(disp ~ cyl + gear, data = mtcars, FUN = mean ) cyl gear disp 4 3 120.1000 6 3 241.5000 8 3 357.6167 4 4 102.6250 6 4 163.8000 4 5 107.7000 6...

I have a matrix m=[10 15.675; 13.5 34.987; 20 55.5]; I want to write this matrin on o txt file. I want to use different precisions for each columns. For example 1 for 1st column and 2 for 2nd column. Desired output: 10.0 15.68 13.5 34.99 20.0 55.50 I am...

I was trying to implement a FFT-based multiplication algorithm in M2(R). Basically an algorithm that gets as an input two polynoms with elements given as matrices, and builds the product polynom. However, even though the algorithm should work, as it looks exactly identical to a version I wrote earlier on...

I've been coding for my university where we are working with matrices and I can't find the error in the code that is changing the value of the variable where I save the columns of the matrix. I've tried debugging it and can´t find it, it simply ends the function...

I'm making a game in C# and XNA 4.0. It's pretty much finished, but now I want to add settings so that players can change the window size if they want to. The current setup goes like this: void Initialize() { //The window size is initally 800x480 graphics.PreferredBackBufferWidth = 800;...

I have some legacy R code that does: b = t(a) c = t(b) What does this code do? Looks like a noop to me. a is a vector constructed by c(1:20). Edit: bonus points on how to do this better....

I have mat<-matrix(1:12,3) vect<-c(2,2,2) How can I multiply each column by the vector in order to obtain: 2, 8, 14, 20 4, 10, 16, 22 6, 12, 18, 24 ...

I have a 1*3000 double matrix. I am doing some calculation and I need to calculate sum of n-1 columns in each step. For example, if I have this matrix: A = [1 2 3 4 5 6] The summation I'm looking for should be like this: B = [0...

Does anyone know how to handle this error? It occurs both on my PC ("Windows" "7 x64" "build 7601, Service Pack 1" "x86-64") and Mac ("Darwin" "Darwin" "12.5.0" "Darwin Kernel Version 12.5.0: Sun Sep 29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64") library(MODISTools) data(SubsetExample) MODISSubsets(LoadDat = SubsetExample, Products = "MOD13Q1", Bands = c("250m_16_days_EVI",...

I've read a dozen articles online about the correct order of rotation, translation and scale matrix multiplication in OpenGL. However, now that I started implementing it myself, I came to the point where I'm really confused. Let's assume that in my code I'm calculating the transformation matrix, and I'm passing...

I have a function that defines a very long polynomial useful in operations with matrices. The formula multiplies binomials of the form (1+xi*yj) , where i and j are subscripted and correspond to the rows and columns of the matrix in question, respectively. The polynomial that results is the product...

How can I solve , where and and in the least squares sense in matlab? So I'd like to have the minimizing as output....

Can I receive a specified value (0 for example) when trying to get a value outside of a NumPy matrix? For example: #getItem - some method which do what i want a = numpy.array([[1, 2], [3, 4]]) getItem(a, 1, 1) # == 4 getItem(a, -1, 1) # == 0 Of...

This issue is quite tricky to explain but I am sure some of you already faced it. So I have two matrix. Matrix 1 (mat 1) and Matrix 2 (mat 2) What I want to do is to record in a third matrix (mat3) the value of mat2, after checking...

a = 1 2 3 b = 1 2 3 a.*b ans = 1 2 3 2 4 6 3 6 9 I used the .* operator to multiply a row vector and a column vector in Octave to see the results. I dont understand how the answer is obtained....

I'm starting to learn how to implement divide and conquer algorithms, but I'm having some trouble with this exercise. I have written an algorithm but unfortunately it returns a 0 value. I need to count how many times a number finds in the matrix using D&C. My idea is to...

I am trying to fill a vector with a matrix of values in c++. I'm not very self confident with this procedure (I don't know well about pointers and I don't know if I need it here) however I am trying this int auxMat[gray.rows][gray.cols]; vector<int> collectionSum; collectionSum.push_back(auxMat); When I try...

Please help me any help will be appreciated. I wrote a code in C to solve equations, but I don't know why some equations that I input into this calculator, give me wrong values, the algorithm is correct because I execute it in C and give me the correct answers...

We were given an assignment to find the numerical first and second derivative using given steps: 1) Define two arrays, x and y=f (x) (Use any function) 2) Define the differential operator as a matrix (e.g. for f' , define the matrix D= (1/2h)(U-L) where U is an Uppershift Matrix,...

I am doing a project involving scientific computing. The following are three variables and their values I got after some experiments. There is also an equation with three unknowns, a, b and c: x=(a+0.98)/y+(b+0.7)/z+c How do I get values of a,b,c using the above? Is this possible in MATLAB?...

[UPDATE] the code and a few sentences were changed to reflect a realization explained in my second comment. The code should compile with the line below, however, I have an older gfortran and may not be seeing some errors that you might. gfortran BLU_implementation_copy.f90 -o BLU_implementation_copy.x I'm getting an incredibly...

I had a square matrix typed dynamically, correctly allocated double **matrix; I want to delete a "x" row and "x" column from that matrix, in a way like that: SOURCE MATRIX: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 I want to...

Here is the question - Write a program to find the maximum element in a matrix using functions. Function specification: int findMax(int **a, int m, int n) The first argument corresponds to the pointer to the matrix. The second argument corresponds to the number of rows in the matrix. The...

I have two matrices with the same columns and rows names: > metilacion[1:5,1:5] A2BP1 A2M A2ML1 A4GALT AAAS paciente1 0.2804884 0.5816559 1.1814702 -0.6234276 -0.3997400 paciente2 0.5122471 1.2944264 0.5673766 0.4490407 -0.6045510 paciente3 -0.3116356 1.6085049 0.9970350 0.3379215 -0.4787046 paciente4 -0.7220941 0.8771948 2.1445474 -0.5837802 -0.4848246 paciente5 -0.3369999 1.5885716 0.8185654 0.2374583 -0.5698858 > expresion[1:5,1:5]...

I would like to change matrix A to a size that match with matrix size B so that later on I can perform minus function on A - B. from numpy import matrix A = matrix([[7, 5]]) B = matrix([[2, 0],[0, 0]]) The value 7 is used to deduct [2,0]...

I've created a lower triangular distance matrix (because of size issues) as jagged array Note: Distances between objects are symmetric var dm = new double[size][] for (var i = 0; i < size; i++) { dm[i] = new double[i+1]; for (var j = 0; j < i+1; j++) { dm[i][j]...

So I have written this: HSRXdistpR = squeeze(comDatape_m1(2,7,1,:,isubj)); HSRXdistpL = squeeze(comDatape_m1(2,4,1,:,isubj)); TocomXdistp = squeeze(comDatape_m1(2,10,1,:,isubj)); for i = 1:2; HSRXp = NaN(8,3*i); HSRXp(:,i*3) = [HSRXdistpR(:,i) HSRXdistpL(:,i) TocomXdistp(:,i)]; end In the first part I am just selecting data from a 5-D matrix, nothing special. All that's important here is that it creates...

Is there any function that can calculate cumulative maximum for a double matrix? I have a 1*3000 matrix and I need to calculate the cumulative maximum. For example if the matrix is: A = [8 3 6 7 9 10 6 2 2 3] The cumulative maximum array will be:...

I have an array for which I would like to obtain a measure of the similarity between values in each column. By which I mean I wish to compare the rows between pairwise columns of the array and increment a measure when their values match. The resulting measure would then...

I have got a matrix Nx3 dimension in matlab. I want to calculate the norm of every n-th row of the matrix. However I want to perform the norm calculation without using for loop. Is there a way to do so? My for loop code: for i=1:length(accelerometer) magnitude(i,:) = sqrt(accelerometer(i,1)^2...

i have a matrix of objects: var data = [[ {"value": "1"}, {"value": "2"}, {"value": "2"}, {"value": "4"} ], [ {"value": "1"}, {"value": "2"}, {"value": "2"}, {"value": "4"} ], [ {"value": "1"}, {"value": "3"}, {"value": "3"}, {"value": "5"} ]]; and I would like to render the matirx out as a...

I want to get dot product of N vector pairs (a_vec[i, :], b_vec[i, :]). a_vec has shape [N, 3], bvec has the same shape (N 3D vectors). I know that it can be easily done in cycle via numpy.dot function. But cannot it be done somehow simpler and faster?...

I have matrix A and matrix B. Matrix A is 100*3. Matrix B is 10*3. I need to insert one row from matrix B each time in a sequence into matrix A after every 10th row. The result would be Matrix A with 110*3. How can I do this in...

I'm having a numpy ndarray where I would like to check if each row vector is monotonically increasing. Example: a = np.asarray([[1,2,3],[1,5,7],[4,3,6]]) monotonically_increasing(a) Expected return: [True, True, False] I'm not entirely sure how to efficiently do this, since the matrices are expected to be quite large (~1000x1000), and was hoping...

I'm trying to figure out how to reverse RotateAxisAngle to get back rotations around these arbitrary axes (or equivalent rotations that yield same net rotation, doesn't have to be identical). Does anyone know how to do it? I'm using MathGeoLib, but I don't see an opposite way, to return back...

I have decided to learn Python. I have a background in c++ so there are some challenges I have wrapping my brain around Python. My question is: I have the following syntax in C++ and I am looking for an equivalent in Python. This is just a snippet of code....

So I have a C++ code that finds the inverse of a square matrix. The inverse is full and it would be bad to keep it all in memory because I am working with hundreds of thousands of columns. My code generates the columns one by one. After finding the...

I'm trying to remove "singletons" from a binary matrix. Here, singletons refers to elements that are the only "1" value in the row AND the column in which they appear. For example, given the following matrix: > matrix(c(0,1,0,1,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,1,1), nrow=6) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] 0 1 0...

Being new to algorithms and having searched all over the web, including some answers on stackoverflow, I still find myself asking how I find the distance between those nodes in a simple matrix. First of all, the simple matrix: public class MatrixRoutes { int[][] position; // matrix int size; MatrixRoutes(int...

I'm making a game in C# and XNA 4.0. In some levels I need a camera matrix to make the level appear to scroll left/right. Additionally, I also need a scaling matrix to scale the graphics when the settings are used to change the window size. Both of my matrices...

I am using large matrices of doubles in C++. I need to get rows or columns from these matrices and pass them to a function. What is the fastest way I can do this? One way is to write a function that returns a copy of the desired row or...

Using example from Andrew Ng's class (finding parameters for Linear Regression using normal equation): With Python: X = np.array([[1, 2104, 5, 1, 45], [1, 1416, 3, 2, 40], [1, 1534, 3, 2, 30], [1, 852, 2, 1, 36]]) y = np.array([[460], [232], [315], [178]]) θ = ((np.linalg.inv(X.T.dot(X))).dot(X.T)).dot(y) print(θ) Result: [[...

I want to create a matrix which has distinct rows selected from another matrix. For Example, I have a 10x3 matrix A A = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26...

I have a question about subsetting in R. Say I have the following Matrices: Ch1.Amplitude Ch2.Amplitude [1,] 6968.577 9637.309 [2,] 11903.564 11385.656 [3,] 13503.292 9928.314 Ch1.Amplitude Ch2.Amplitude [1,] 11903.564 11385.656 [2,] 2519.582 8042.450 [3,] 9878.749 5899.139 I would like to match row 2 of the first Matrix A with row...

I'm working on setting some boundary conditions for a water table model, and I am able to set the entire first row to a constant value, but not the entire first column. I am using np.zeros((11,1001)) to make an empty matrix. Does anyone know why I am successful at defining...

Consider the following N × N matrices A and B that contain only positive integers: B is created from A by summing the odd numbers that neighbour each element, at position [i,j] in A. Each computed sum is then stored in the corresponding position [i,j] in B. For example: At...

I would like to make a matrix whose lines are different permutations of the following vector= [1,2,3,4,5,10,10,10,10,10] I tried to use the random.shuffle function, but it seems that everytime I use that, It redefines all objects to which it is assigned. For example, I have tried the following: vec=[1,2,3,4,5] for...

I have a matrix of 0-1. What I would like to do is to loop into this matrix and search for the 1. Each time a 1 has been found, to simply jump or pass that row, in order to only record 1 value per row. What I am trying...

I am looking for a function in any package that can print matrix[1:5, 1:5]. head() is good for those that have few columns but not for a large matrix. I know I can create my own function for it but I am wondering if there is a function for it...

I have two matrices A and B as given below: A = [1 2 3 4 5] B = [10 11 12 13 15 16 17 18 17 12 15 13 20 21 22 17 40 41 32 33] and I would like to output it to a text file...

I want to write a function that is modify every elements inside a matrix. But I have some problem when compiling. Warning 10: this expression should have type unit. I think because all function in ocaml need to return to a value or unit, so if I implement two tasks...

I convert a list of integers to a two dimensinal array like this: data = numpy.array( l ) shape = ( 10, 30 ) data = data.reshape( shape ) I try to get the indices x,y of the matrix of the values that are bigger than some threshold and lower...

I have a data set (D) of (nxd) where n=number of rows and d= number of dimensions, I create a similarity matrix (S)(nxn) by comparing each row of the data set (D) and then convert it into a sparse matrix (tx3) where t is the number of non-zero elements of...

I am trying to print the right hemisphere of a matrix. If we draw the main and the secondary diagonals in a matrix we see that we got 4 equal parts, the right part is called (in my algorithms textbook) the right hemisphere of a square matrix. For example, in...

The input is a N x N matrix which has to be shifted cyclically (either Clockwise or Counter-Clockwise) by one element. Example Input (Size 3) : 1 2 3 4 5 6 7 8 9 Output : 2 3 6 1 5 9 4 7 8 Example Input (Size 4)...

I have been trying to solve the following problem. Suppose I have the following vector: aux1<-c(0,0,0,4,5,0,7,0,0,10,11,12) where the numbers represent the number of the row. I want to calculate the distance between the differents elements of this vector fixing the first component, then the second and so on. If the...

The question is more focused on performance of calculation. I have 2 matrix with the same number of columns and different number of rows. One matrix is the 'pattern' whose rows have to be compared separately with the other matrix rows (all rows), then to be able to extract statistical...

I would like to add each coefficient of a vector to each different column of a matrix. For example, if I have a vector and a matrix: x <- c(1,2,3) M <- matrix(c(5,6,7), nrow = 3, ncol = 3) I would like to in my new matrix M1 1+5 in...

I've got a list of 8 coordinates stored as list of lists: coordinates = [[47.2486, -1.54806], [43.5656, 1.47417], [48.3592, -4.57], [48.1439, 17.1097], [39.6275, 140.198], [30.0458, 31.2625], [38.9371, -77.0869], [33.9, 35.4823]] With the following script, I seek to output a matrix of coordinates: import numpy from scipy.spatial.distance import pdist coordinates_array =...

I am trying to image coordinates to 3D coordinates. Using the solvePnP function (in C++)has given me 3X1 rotation matrix and 3X1 translation matrix. But isn't the [R|t] matrix supposed to be 3X4? Any help will be greatly appreciated!...

I realize this problem and solutions are all over StackOverflow like here however I'm still unable to make this work. Most of the examples say that I just need to multiply the row by the width and add the column meaning the location (4, 3) in a 4x4 square grid...

I have this vector ID var2 ID var2 var1 ID var2 ID var3 "1000" "1" "1001" "1" "1" "1002" "7" "1003" "3" that can be obtained from x=c("1000","1","1001","1","1","1002","7","1003","3") names(x)=c("ID","var2","ID","var2","var1","ID","var2","ID","var3") and I would convert it into this matrix of dimension 4x4: ID var1 var2 var3 "1000" NA "1" NA "1001" "1"...

I have a symmetric matrix S(n*n) where approximately 70% of the data are 0. Symmetric matrix I want to convert the symmetric matrix into a sparse matrix with t rows. What would be the time complexity of generating a sparse matrix from the original symmetric matrix? Is it O(n^2), because...

I have a problem in c++ the teacher asking us to display a field of structures that contains n=100 students. Is this the right way to do it ? #include <iostream> #include <math.h> using namespace std; struct Students{ string name; int id; int mark1; int mark2; int mark3; }; int...