Category "matrix"

Spiral matrix with entered rows and columns

As an assignment i have to create a spiral matrix where the user inputs the number of rows and number of columns. This is my code for far (first year in colleg

Cosine similarity calculation between two matrices

I have a code to calculate cosine similarity between two matrices: def cos_cdist_1(matrix, vector): v = vector.reshape(1, -1) return sp.distance.cdist(

Neighboring gray-level dependence matrix (NGLDM) in MATLAB

I would like to calculate a couple of texture features (namely: small/ large number emphasis, number non-uniformity, second moment and entropy). Those can be co

Implementing matrix operation using AVX in C

I'm trying to implement the following operation using AVX: for (i=0; i<N; i++) { for(j=0; j<N; j++) { for (k=0; k<K; k++) { d[i][j] += 2 *

apa_table() increase table width

How do I increase the width of an apa_table in R Markdown. I'm using the papaja package. I would like the width to be long enough to fit the table's title. This

Extracting all matrices out of a nested list with varying sublist lengths in R

I have a nested list of matrices. More specifically, I have a list of matrix lists, each with a variable number of matrices. I would like to extract all the mat

Multithreading matrix multiplication in C#

I have a task - write multithreading matrix multiplication. Each vector product must be calculated in new thread.(If we have matrices n by m and m by k we must

Tensordot for numpy array and scipy sparse matrix

For a current project I have to compute the inner product of a lot of vectors with the same matrix (which is quite sparse). The vectors are associated with a tw

solving Ax =b for a non-square matrix A using python

I'm focusing on the special case where A is a n x d matrix (where k < d) representing an orthogonal basis for a subspace of R^d and b is known to be inside t

Adding a vector to matrix rows in numpy

Is there a fast way in numpy to add a vector to every row or column of a matrix. Lately, I have been tiling the vector to the size of the matrix, which can use

Adding row/column headers to NumPy arrays

I have a NumPy ndarray to which I would like to add row/column headers. The data is actually 7x12x12, but I can represent it like this: A=[[[0, 1, 2, 3, 4, 5]

How can I check if a matrix is an element of a list of matrices? in R

I'm pretty new to programming in R. I have a matrix of numbers mat, as well as a list of matrices matlist. I want to check if the matrix mat matches with (i.e

Average transformation matrix for a list of transformations

I have multiple estimates for a transformation matrix, from mapping two point clouds to each other via ICP (Iterative Closest Point). How can I generate the av

Is there a Python equivalent of MATLAB's conv2 function?

Does Python or any of its modules have an equivalent of MATLAB's conv2 function? More specifically, I'm interested in something that does the same computation a

PHP rotate matrix counter-clockwise

I am solving a larger problem and at one step I need to rotate a 2D array counter-clockwise. So if I have this matrix: 1 2 3 4 1 2 3 4 3 4 5 6 3 4 5 6 After

Calculate a 2D homogeneous perspective transformation matrix from 4 points in MATLAB

I've got coordinates of 4 points in 2D that form a rectangle and their coordinates after a perspective transformation has been applied. The perspective trans