# Questions tagged [matrix]

In mathematics, a matrix (plural matrices) is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns. The individual items in a matrix are called its elements or entries.

**-1**

votes

**0**answers

15 views

### How rotate source vector to target (to nearest vector) by using only 2 Euler angles

I need to rotate source 3D vector to target vector by rotation around only two axes YZ.
I have mechanism with 2 motors rotating around Y and then around Z. I have random source vector attached to ...

**1**

vote

**1**answer

17 views

### Why is the following line producing a 1-dimensional array instead of a 2-dimensional one?

I'm attempting to read a CSV file in Julia 1.1, producing a matrix of strings with the same layout as the original data in the csv file. In other words, if my CSV-file was
a,s,d,f,g,h
q,w,e,r,t,y
my ...

**0**

votes

**1**answer

18 views

### convert eigen matrix into std::vector<std::array<>> form

How can I convert an Eigen matrix into std::vector<std::array<>> form? Suppose I have an Eigen matrix Eigen::MatrixXd A(4,3). Is it possible to convert matrix A in std::vector<std::...

**1**

vote

**0**answers

25 views

### 3-D numpy matrix multiplication in numpy to get 1 D array

I've 2 3-D matrix of this form:
a = np.random.randint(0, 100, size=(3, 4, 3))
b = np.random.normal(0, 1, size=(3,3, 4))
I want to multiply these 2 matrices, in such a way that I get a matrix of ...

**0**

votes

**1**answer

25 views

### Matrix class: “No instance of overloaded function push_back matches the argument list”

So, I'm creating a class that represents an arbitrarily-sized matrix, and I want to write a function that "exports" the internal Vector to a 2-dimensional array.
I've found some code that seems to ...

**0**

votes

**2**answers

39 views

### Julia or R: create symmetric matrix by minimum of off-diagonal elements

Here is a complex problem. I have an arbitrary square matrix in R (can be in Julia as well), for example
> set.seed(420)
> A <- matrix(runif(16),nrow = 4,byrow = T)
> A
[,1] ...

**-9**

votes

**0**answers

30 views

### How to calculate this sum [on hold]

i'm trying to calculate the value of sum of any random matrix sum on picture i tried using apply,lapply but didn't work, any suggestion
![sum{sum{(Nij-((Ni*Nj)/n)^2)/)(Ni*Nj)/n))}}]
where Ni sum of ...

**0**

votes

**0**answers

12 views

### load apply output into matrix [duplicate]

I wish to load the output from an apply statement into a matrix. The problem is that the number of elements varies among rows in the apply output list.
I can achieve what I want with a for-loop, but ...

**0**

votes

**0**answers

8 views

### Maxima: define columns of matrix as a vector

In Maxima I want to define vectors using the columns of randomly generated matrix where not only the entries but also the number of rows and columns is random. My code so far:
n:2+random(5);
m:2+...

**0**

votes

**0**answers

18 views

### Objective-C Nested For Loop To Create Matrix Duplicate Entries

I am working on an iOS app in objective-c (calculating inbreeding coefficient). I have a for loop nested in a for loop to create a matrix. I am getting strange output when looking for a value in the ...

**0**

votes

**1**answer

16 views

### Convert string entered into input() back to two dimensional matrix

In a python program I am writing in CodeSkupltor3, data is stored as a single number in a list of lists (a 2d matrix). Because CodeSkulptor can't save files, I added an option for the user to export ...

**0**

votes

**0**answers

21 views

### Don't understand Sin equation of plasma effect to 2d array for LED strip matrix in Python

I successfully got the code below, from Github, working on a raspberry pi and a 8 x 16 LED matrix using PWM on pin 18. Since it uses sin and cos functions to create the graphics, I wanted to try to ...

**-1**

votes

**0**answers

41 views

### C stop printf float promotion [on hold]

Hello and thank you in advance,
So I am working on a program for class that requires matrix multiplication. Due to both extreme memory constraints (lowest memory use in class gets bonus points) and ...

**0**

votes

**0**answers

11 views

### Passing 2d Matrix and a Vector - A Robust Matrix*Vector calculating function

I am trying to build a robust matrix*vector calculating function (MatVec) that requires me to pass a 2d square matrix A and a 1d array V with n as number of rows or columns. Two things here:
I don't ...

**0**

votes

**1**answer

52 views

### matrix in visual basic

so i have a task to create a square matrix then from that return the average of the rows and columns, having some problem though
Dim m, n, i, j As Integer
Dim A(2, 2) As Integer
...

**2**

votes

**2**answers

42 views

### Convert a dictionary which values are different-length lists into a dataframe

I have a dictionary which the keys are years while the values are corresponding models. Below is a piece of data I printed out from the dictionary.
1975: ['MODEL9808533471'],
1985: ['MODEL0912768548'...

**0**

votes

**5**answers

46 views

### Change elements in one matrix based on positions given by another matrix in R

Let's say I have a symmetric matrix A, for example
> A <- matrix(runif(16),nrow = 4,byrow = T)
> ind <- lower.tri(A)
> A[ind] <- t(A)[ind]
> A
[,1] [,2] [,3] ...

**0**

votes

**0**answers

26 views

### Efficient Matrix Multiplication and Ranking for Collaborative Filtering

I am working on a recommender system side project and came across this C++ package which implemented collaborative filtering for BPR with parallel SGD (https://github.com/cjlin1/libmf). The model ...

**0**

votes

**0**answers

23 views

### What's the old version of matmul() in Numpy for matrix multiplication?

I need to use an older version of NumPy which doesn't have matmul() in it. What's the original way to multiply matrices in NumPy? I know * is elementwise multiplication and that .dot() is different in ...

**0**

votes

**0**answers

11 views

### Android Camera2 frame horizontal inversion

I want to horizontally invert frames coming to Surface object made from TextureView. What I can do is to set transformation matrix to this TextureView instance, whereas I postScale by -1 for x and 1 ...

**0**

votes

**1**answer

16 views

### Matrix for predict disease to symptom using panda DataFrame [duplicate]

first i'm beginner in python I have the same problem, to craete matrix my data csv file into pandas dataFrame like the following format
disease symptom frequence
0 d1 s1 Very ...

**1**

vote

**1**answer

20 views

### R - Sum list of matrix with different columns

I have a large list of matrix with different columns and I would like to sum these matrix counting 0 if column X does not exist in one matrix.
If you have used the function rbind.fill from plyr I ...

**1**

vote

**1**answer

20 views

### R : break rows into combinations of pairs

Let's say I have the below lines and I want to break them into pairs:
fname_c1 fname_c2 lname_c1 lname_c2 by bm bd group
<fct> <fct> <fct> <fct> <...

**0**

votes

**0**answers

7 views

### How to efficiently delete blocks in a sparse matrix in R

I have large sparse matrix (roughly 10 million rows, 10000 columns, around 20 non zero entries per row) and I want to delete certain blocks of it efficiently, where a block consists of a list of rows (...

**2**

votes

**1**answer

66 views

### Problems with empty cell in a large matrix: MATLAB

I have a large matrix of 102730 rows in the form of text file (sample text file is attached) with some header files in it. The first column show year, the next the month, followed by the day, and ...

**0**

votes

**0**answers

7 views

### Jacobi Method with many zero terms FLOPs

I am given a 100x100 matrix in a system and in a general case, it takes bigO(n^2) flops to do each sweep of the Jacobi method so if you have to do 100 sweeps, it becomes as inefficient as running ...

**0**

votes

**1**answer

25 views

### Find conserved columns in matrix

I'd like some help.
I have a matrix with 21 rows and a
previously undefined number of columns (depend of the input).
Each cell has a number representing how many times the element of the row
appears ...

**0**

votes

**0**answers

31 views

### Computing and using Jacobian for solve_ivp method

I'm trying to compute the Jacobian of a large system of first-order ODE's. I need the Jacobian for use in my solve_ivp code.
Heres how I attempt to compute the jacobian.
C1 = sp.symbols('C[0], C[1], ...

**1**

vote

**1**answer

40 views

### Python - Efficient extracting data from list of tuples to another list

Multiprocessing called function generates raw_data list containing tuples (index_i, index_j, some_result). It is normally quite a large list, but here is some short example:
raw_data = [(0, 0, 1.0),
(...

**-1**

votes

**1**answer

24 views

### Creating a matrix from panda df to display prediction between Disease_Symptom

hello all i'm begginer in python datafram ::
i have my dataframe in pandas like the following format
header[Disease, Symptom]
Disease Symptom
0 di1 sy1
1 di1 sy4
2 ...

**0**

votes

**0**answers

21 views

### Split a huge matrix into submatrices to compute correlation

I want to compute the correlations on my matrix which has thousands of rows. It is for the moment impossible to compute the correlations on the entire matrix because it is too big.
My idea is to ...

**0**

votes

**1**answer

23 views

### R - Perform Function on Matrix Values using Value Location

I'm building a software that takes advantage of R's matrix calculations to build a heat map. Assuming I've got the following as my starting matrix:
-1.8784 -1.8783 -1.8782
53.5919 0 ...

**-1**

votes

**0**answers

7 views

### How do you do PCA with correlation matrix, without any package?

I need a PCA with correlation matrix but without any R package

**-1**

votes

**0**answers

22 views

### How do I add a new row to an EXISTING numpy matrix? [duplicate]

If I have a numpy matrix mymatrix=[[0,2,4,6]] and I also have an element newrow=[1,2,3,4].
How do I add newrow to the bottom of mymatrix so that it becomes,
[[0,2,4,6],
[1,2,3,4]]

**1**

vote

**1**answer

31 views

### Sum outer product of vector plus its transpose plus a matrix

Please suggest efficient and robust method (memory size, numerical accuracy, computation speed) for the following matrix procedure:
A + [ b * transpose(b) ] + transpose( [b * transpose(b) ] )
...

**0**

votes

**1**answer

26 views

### Read graph from file and convert into array Java

I need to read graph matrix from txt file. For example
4
0 1 1 0
1 0 1 0
1 1 0 1
0 0 1 0
This is input file. First number is number of vertices. I tried something like this:
Scanner sc = new ...

**1**

vote

**2**answers

41 views

### Matrix size in Python

a is a 2x2 matrix
b is a 2x1 matrix
c is a 1x2 matrix
But ... what kind of matrices d is?
import numpy as np
a= np.array([[1,2],[3,4]])
b= np.array([[1],[2]])
c= np.array([[1,2]])
d= np.array([1,2]...

**0**

votes

**1**answer

24 views

### R - Adding Data Frame to Matrix [duplicate]

I am trying to transform a data frame (treating as a vector) with locational data and a value onto a matrix that uses locational data as it's row and column names.
(Run snippets to see layout ...

**0**

votes

**0**answers

36 views

### Program to read and print a triangular matrix from a file doesn't work [on hold]

I want to read a file with a lower triangular matrix and print it on screen using fortran90. However, the code is not working. It doesn't have any syntax errors. I want to know where is it that I'm ...

**3**

votes

**3**answers

93 views

### Can “sort” function inside of <algorithm> be used to sort 2-dimensional char arrays?

char s[251],c[13][21],*p;
int n;
f.get(s,251);
p=strtok(s," ");
n=0;
while(p)
{
strcpy(c[n],p);
++n;
p=strtok(NULL," ");
}
Code takes multiple words separated by spaces then the n word is ...

**1**

vote

**1**answer

18 views

### extract clusters / sets of nodes from an undirected graph

Description
I would like to identify and obtain n-sized clusters in form of groups of nodes from an undirected graph dataset (optimally in Python). Currently I am stuck in a sphere way outside of my ...

**1**

vote

**1**answer

21 views

### Create 2d/3d matrix “object” from data columns and plot it further as contour plot

i got actually stuck in this case already on creating the matrix. Lets start with the data first:
Length Diameter Defect Start Defect End Defect Location Defect Angle
1 9850 100 ...

**0**

votes

**0**answers

23 views

### Rearrange dataframe to matrix matching multiple conditions

I have a list of 1000 items, each item has its own category and colour and a score (the higher the better), I want
-select 16 items out of all to form a 4x4 matrix (prefer to select higher scored ...

**0**

votes

**0**answers

12 views

### FSL error inv(): matrix appears to be singular

I am conducting analysis of imaging data, performing fiber tracking using FSL probtrackx2. However, I encounter the following error message:
error: inv(): matrix appears to be singular
libc++abi....

**1**

vote

**2**answers

25 views

### Storing upper/lower half of correlation matrix

What is the most { (1) memory efficient (2) time efficient (3) easy-to-access* } way to store the upper/lower half of the correlation matrix to a file in python ?
(By "easy-to-access" I mean- to be ...

**-3**

votes

**0**answers

20 views

### Save messages in store in MatrixSDK ios [on hold]

I do messenger in iOS, using MatrixSDK.
I need to save messages in local store. As I known Matrix has own Realm.
But I cannot save messages in this store.
Any help will be appreciated.

**0**

votes

**1**answer

60 views

### Getting camera calibration (fx, fy, cx, cy) from projection matrix

I understand from this presentation: http://www.terathon.com/gdc07_lengyel.pdf
The focal length (fx) is the first value (e) in all OpenGL projection 4x4 matrices.
How would we get the values of ...

**0**

votes

**1**answer

26 views

### Create sql table for matrix and insert csv file into table

A little new to using sql, but am running into this problem.
I'm trying to create an sql table using sqlite3 for a matrix of months, then insert a csv file into my sql table.
My csv file looks like ...

**0**

votes

**1**answer

27 views

### Boxplot only showing flat lines

I have the following matrix:
test <- matrix(c(2006,100,
2007,105,
2008,98,
2009,102,
2010,107),ncol=2,byrow=TRUE)
And I want to ...

**0**

votes

**1**answer

50 views

### OpenGL Projection Matrix showing Orthographic

I got an orthographic camera working however I wanted to try and implement a perspective camera so I can do some parallax effects later down the line. I am having some issues when trying to implement ...