Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [matrix]

Matrix is a rectangular array of elements (e.q. numbers, symbols, or expressions), arranged in columns and rows.

2
votes
0answers
18 views

Randomized Submatrix of a Sparse Matrix

I have a sparse square matrix $A$ with size $n \times n$ and number of nonzero entries $nnz$. The goal is making a sub-matrix $B$ with $s$ nonzeros which are randomly chosen from $A$. Duplicates are ...
1
vote
2answers
36 views

Access optimized data structure for representing integer lattice

Consider the integer lattice in $2d$, namely the set $\mathbb{Z}^2 = \{(x,y): x,y\in \mathbb{Z}\}$, and let $u:\mathbb{Z}^2 \to \mathbb{R} $ be a function defined on some bounded subset of $\mathbb{Z}^...
1
vote
1answer
118 views

Solving linear system with matrix multiplication

When solving a linear system $Ax=b$ where $A=B^TCB$ do I need to form $A$ explicitly by two matrix-matrix multiplications or is there another more simple way? $C$ is a NxN matrix and not always ...
4
votes
1answer
122 views

Do I really need to invert this matrix

I need to calculate a matrix $A$ (at least some elements of it, see below) as defined by the following equation $$ A=B(\mathbb{1}-B)^{-1} $$ where B is a square matrix of dimension $N$ and $\mathbb{...
1
vote
0answers
58 views

finding null space to a complex matrix

I need to solve the following equation: $$ \begin{pmatrix} \frac{\omega^2}{c^2}\varepsilon_x-\mu_z^{-1}k_y^2-\mu_y^{-1}k_z^2 & \mu_z^{-1}k_xk_y & \mu_y^{-1}k_xk_z\\ \mu_z^{-1}k_xk_y &\...
8
votes
3answers
166 views

Rule of thumb for sparse vs dense matrix storage

Suppose I know the expected sparsity of a matrix (i.e. the number of non-zeros / total possible number of non-zeros). Is there a rule of thumb (perhaps approximate) for deciding whether to use sparse ...
3
votes
0answers
96 views

Computing Small Eigenvalues with Sparse Symmetric Indefinite Mass Matrix

I want the eigenvalues of the following generalized eigenvalue problem: $$ Av = \lambda M v $$ where $A\in\mathbb{R}^{n\times n}$ is sparse, symmetric, and positive semi-definite $M\in\mathbb{R}^{n\...
1
vote
1answer
45 views

Thomas Algorithm Kernel OpenCL

I am trying to implement the Thomas algorithm using OpenCL. ...
2
votes
2answers
152 views

Lost on Matrix Inversion

I try to implement some big matrix inversion. My system configuration is Hardware:- Memory: 62.8GiB, Processor: Intel Xeon(R)CPU E5-2670 v3 @2.30GHZ*48 To implement matrix inversion I am using ...
3
votes
0answers
32 views

Reweighted least squares factorization

This is a continuation of the question asked here. I want to solve numerous least squares systems of the form $$ D_i A x \approx D_i b $$ where $D_i$ are $m \times m$ diagonal matrices with positive ...
6
votes
0answers
105 views

An invertible matrix that minimizes the norm of the product with a given matrix

Given a fat matrix $B \in \mathbb{C}^{n \times m}$ (where $m > n$) with full row rank, I would like to find (numerically) a full-rank matrix $A$ that minimizes the Frobenius norm of the product $A ...
2
votes
1answer
57 views

Finding probability vectors from an implicit equation

I have $q$ $n$-dimensional vectors $\vec y_i$ and a matrix $\hat B$ of shape $n\times m$. I'm looking for $q$ $m$-dimensional vectors $\vec x_i$ such that: $\vec y_i=\hat B \vec x_i$ each vector $\...
0
votes
0answers
45 views

Finding attribution of coefficient in a matrix

I have the following $d*n$ matrix in $\{0, 1\}$ \begin{bmatrix} x_{11} & x_{12} & x_{13} & \dots & x_{1n} \\ x_{21} & x_{22} & x_{23} & \dots & x_{2n} \\ ...
4
votes
2answers
125 views

How “sparse” should a sparse matrix be to see benefits?

I have a matrix, whose size scales as $2^N$ (assume even $N$). In each row of the matrix, only about $2^{N/2}$ of the entries are filled ($N$ can be somewhere between 10 and 40, depending on what's ...
3
votes
1answer
65 views

Compute nearly degenerated eigen values and vectors

In a quantum physics calculation, I have to deal with a matrix that has a lot of eigenvalues really close to each other ($10^{-6}$ relative difference for example) and I can't manage to obtain ...
0
votes
0answers
28 views

Converting logit coefficients into probabilities through the inverse multinomial logit

I am trying to come up with the transition intensities of a parameterized Markov model, i.e, the elements of the transition matrix weighted by the covariates through the inverse Logit relation: $$\...
5
votes
1answer
117 views

Generate approximately semi-orthogonal tall matrix approximately satisfying constraints

I have a set of matrices $\{(A_i,D_i)\}$ for $i\in\{1,\ldots,n\}$, where: Each $D_j\in\mathbb{R}^{S\times S}$ is diagonal, and every entry on the main diagonal is non-negative. Each $A_j\in\mathbb{R}^...
5
votes
1answer
44 views

Transform from linear index of a packed triangular matrix to dense indices

Given indices $i,j$ s.t. $0\leq i \leq j <n$, the function $f(i,j)=i+j(j+1)/2$ maps 2d indices to linear indices in column major order. What is the fastest way to invert this function? My first ...
7
votes
2answers
178 views

Is large condition number good measure of nearness to singularity for a matrix?

I am new to numerical linear algebra, so i came to know that condition number in 2-norm case will be ratio of largest to smallest singular value. Another concept "Nearness To Singularity" is measured ...
4
votes
1answer
114 views

How can I apply Euler's Method to predict a point in time rotating around multiple axis'

I am xposting this from my original stackoverflow question where I was presented with a coding challenge that I have been able to narrow down extensively and I think it lies with Euler's Method. Here'...
6
votes
2answers
230 views

Matrix multiplication accuracy Matlab vs Python

I am translating some Matlab code into Python and I having some problems regarding matrix multiplication accuracy. Assuming we have following data: ...
2
votes
2answers
54 views

Discrete-time input matrix when one of the eigenvalues of the system matrix is zero

If we have a continuous time state-equation, $$ \dot{x}(t) = A x(t) + B u(t)$$ where $A \in \mathbb{R}^{n \times n}, x \in \mathbb{R}^{n\times1}, B \in \mathbb{R}^{n \times m}, u \in \mathbb{R}^{m \...
-1
votes
2answers
195 views

Does armadillo library slow down the execution of matrix operations?

I've converted a MATLAB code to C++ to speed it up, using the Armadillo library to handle matrix operations in C++, but surprisingly it is 10 times slower than the MATLAB code! So I test the ...
3
votes
2answers
74 views

Image hash similarity matching possible?

I have the following question: We have two face image files (JPEG), a Matrix of $128\times 128$ with values between 0-255. We would like to hash both image files using a function $f(x, key)$. Where I ...
1
vote
0answers
49 views

Dense decomposition of very non-square matrices

I have inherited code that solves Eigen::Matrix problems using the code shown on this page: ...
0
votes
0answers
32 views

Minimum Residual Richardson Iteration for non positive definite matrix

I am trying to solve a matrix equation using a simple Minimum Residual Richardson method (http://depts.washington.edu/ph506/Boyd.pdf : page 304-306). I am using a finite difference matrix as ...
9
votes
2answers
221 views

Matrix exponential of a Hamiltonian matrix

Let $A, G, Q$ be real, square, dense matrices. $G$ and $Q$ are symmetric. Let $$H = \begin{bmatrix} A & -G \\ -Q &-A^T \end{bmatrix}$$ be a Hamiltonian matrix. I want to compute the matrix ...
3
votes
1answer
98 views

Solve $A^{-1} b$ when one column is replaced

Given square matrix $A_0$, vector $b$, vector $A_0^{-1}b$ and matrices $A_1, A_2, \dots, A_k$, in which each $A_i$ is generated from $A_{i-1}$ by replacing one single column, I would like to find an ...
2
votes
0answers
62 views

Acceleration of matrix geometric series

Suppose we want to find $x$ such that: $$x=b+Ax$$ where $A$ is a large sparse square matrix with eigenvalues in the unit circle. There are two representations of the solution: 1) $$x=(I-A)^{-1}b,$$...
0
votes
0answers
40 views

How to reduce dimension using CUR Decomposition?

I am trying to understand this paper called High Dimensionality Reduction Using CUR Matrix Decomposition and Auto-encoder for Web Image Classification. I have understood the method proposed for ...
0
votes
0answers
84 views

Julia--background code for “jacobi” and “gauss_seidel”

Considering the system below, I can solve it by both Jacobi's method and Gauss-Seidel's method. I know there are pre-made functions for both in Julia, which is what I used, but I'd like to to see ...
8
votes
2answers
81 views

Exploiting patterns in matrix for efficient matrix-vector multiplication

I have the following situation: I have a sequence of vectors $x_1, x_2,.. $ and for each I want to compute the product $Ax_i$ where $A$ is fixed at the outset. Although there is no information about ...
3
votes
1answer
177 views

What is the fastest method to invert millions of matrices?

My project involves large simulation and estimation. For each simulation I need to solve 600,000 systems of nonlinear equations. Currently I am using Newton's method to find the solutions. That ...
3
votes
1answer
94 views

Normalizing a density matrix at each iteration

I need to numerically evolve a density matrix using this formula(Actually I have more terms but right nows I am starting with this and facing problems): $$\dot\rho(t) = -i[H(t), \rho(t)]$$ $H(t)$ is ...
0
votes
1answer
54 views

Matrix factorization empty rows and columns

I would like to do non negative mf and I wanna ask a question about my main matrix. The question is should I include rows and columns that have no non-zero entry in them. I think if there is not a ...
6
votes
0answers
144 views

Speed and accuracy of Strassen vs Winograd matrix multiplication algorithms

I am doing work which requires as fast matrix multiplication as possible and just want to double-check with this community that the Winograd variant of Strassen's MM algorithm is the fastest practical ...
4
votes
2answers
137 views

MATLAB Matrix Multiply Efficiency

I am using MATLAB to prototype a few matrix multiply techniques and compare efficiency. Eventually, I will move the prototype codes to C. It is for a homework assignment where we need to write an ...
3
votes
0answers
65 views

Backward stable algorithm to get orthogonal projection onto the column space of a matrix

I have to find the orthogonal projection of a vector $b$ onto the matrix $A$ of size $m \times n$. In my application, I don't have the luxury of calculating the QR factorization. All I have are ...
0
votes
0answers
51 views

Coding infinite matrices in Python 2.7

Hi does anyone know how I can go about coding the following type of Gaussian position operator in Python 2.7: $$A_{c} = \int_{-\infty}^{\infty}\frac{e^{-(x'-c)^2}/(4V)}{(2 \pi V)^{1/4}}|x' \rangle \...
2
votes
3answers
205 views

Matrix vector multiplication performance

I have been learning about the impact of cache size on code performance. I wrote a small code to see how using a column major loop in MATLAB would be better than using a row major loop, since MATLAB ...
1
vote
1answer
49 views

Optimal algorithm choice for mixed diagonal/dense problem

$$ \text{Let}\\ A, B \in \mathbb{C}^{n \times n} \text{ and } \hat{\alpha}, \hat{\beta} \in \mathbb{C}^{n}, \hat{f} \in \mathbb{C}^{2n} \\ \text{Find }\\ \underline{\mathbf{x}} \in \mathbb{C}^{2n} \...
1
vote
0answers
151 views

Multithreading determinant computation of a Big Matrix

I've been trying to design an algorithm for computing determinant of Big square Matrices (N <= 1000). I am allowed to use multithreading, but still, I can't design the algorithm. The assignment ...
6
votes
1answer
146 views

Fast multiplication of highly structured matrix

I want to compute a fast matrix-vector product using a matrix $T$ which has a peculiar quasi-Hankel structure. For example, \begin{equation} T_2= \left( \begin{array}{c|ccc|cccccc} a & b & c &...
0
votes
1answer
65 views

Which are some good algorithms and heuristics to calculate the similarity between two matrices?

Say I have a matrix like this: \begin{bmatrix} 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 1 \\ 0 & 1 & 1 & 1 \\ \end{bmatrix} And this one: \begin{bmatrix} ...
1
vote
0answers
80 views

Low memory algorithm for matrix diagonalisation

I'm trying to find the largest eigenvalues of very large $N \times N$ matrices ($N = 10^{10}$ and larger). The matrices are not sparse but the multiplication operation is fast. For now, I'm using ...
2
votes
2answers
164 views

Inverting big symmetric and singular matrices

In this post I found a very similar probem to the one I have, but not a satisfactory answer for my purposes. I have a set of matrices $C_\ell$. They are exactly symmetric by construction. ...
7
votes
0answers
164 views

Eigenvalue with largest imaginary part

Iterative eigensolvers such as ARPACK, give the option to find a subset of the eigenvalues which have the largest imaginary part. My question is how do these algorithms work. As I understand it, ...
4
votes
0answers
84 views

Eigenvector with maximum overlap

Given a matrix $M$ and a vector $v$, is there an efficient method to find the normalized eigenvector of $M$ that is closest to $v$, in that it has maximal overlap. More explicitly, a vector $v$ can be ...
3
votes
1answer
158 views

How to compute the Frobenius norm of matrices whose entries are either too large or too small?

While implementing in Matlab the Frobenius norm of a matrix $$\| A\|_{\text F} := \sqrt{ \sum_{i=1}^m \sum_{j=1}^n a_{ij}^2 },$$ a problem arises when numbers are too big or too small: If a number ...
3
votes
1answer
426 views

How can I speed up this code for sparse matrix-vector multiplication?

I've written a C++ function that multiplies a sparse matrix (stored in CSR format) by a dense vector. Here's the code: ...