Questions tagged [matrices]

For questions about construction and modification of matrices, objects represented by 2-dimensional arrays that are used to define linear operators within linear algebra.

Filter by
Sorted by
Tagged with
0 votes
0 answers
22 views

Modify this GEPP algorithm to work with matrices

I've been stuck with this problem for a day or so, and I really can't figure it out. I need to modify this pseudocode so that it works when b is not just a vector, but a matrix with same number of ...
king michael's user avatar
0 votes
0 answers
32 views

Find submatrix with sum as close to k as possible

What is the efficient algorithm to find a submatrix (must be rectangle) with a sum that is as close as possible to k? Matrix consists only of nonnegative integers. Iterating through all possible ...
qpexxtt's user avatar
1 vote
0 answers
31 views

Maximize sum of matrix after deleting K rows and K columns

You're given a m by n matrix filled with positive integers, as well as some integer k (0 <...
jeffkmeng's user avatar
  • 111
1 vote
1 answer
143 views

Time Complexity of Matrix Fibonacci Algorithm

In my reference, Exercise 0.4(e), Algorithms by Sanjoy Dasgupta, Christos H. Papadimitriou, and Umesh V. Vazirani, it is given that $$ \begin{bmatrix}F_n\\F_{n+1}\end{bmatrix}=\begin{bmatrix}0&1\\...
Sooraj S's user avatar
  • 139
3 votes
0 answers
67 views

What's the fastest known non-galactic algorithm for matrix multiplication of large matrices

"A galactic algorithm is one that outperforms any other algorithm for problems that are sufficiently large, but where "sufficiently large" is so big that the algorithm is never used in ...
blademan9999's user avatar
2 votes
1 answer
72 views

A version of Bareiss algorithm or similar for symmetric matrices

A linear equation $Ax=b$ can be solved by reducing the matrix $A$ to upper triangular form by using Gaussian elimination or LU decomposition. If $A$ is symmetric and positive definite one can use ...
QuantumWiz's user avatar
1 vote
0 answers
36 views

Algorithm for the inversion of a striped matrix with tridiagonal stripes

I'd like to compute the inverse of a matrix of size $S^2N \times S^2N$ over complex numbers that is composed of tri-diagonal $S\times S$ size blocks of tri-diagonal $S\times S$ block matrices. This ...
Ezrael's user avatar
  • 11
0 votes
0 answers
35 views

Matrix Multiplication with a matrix consisting of a single shifted row

I have the following question (prefacing this with the fact that this is a question from an exam, I am currently studying but am stumped so reaching out for help). The answer to the following ...
Alon .G.'s user avatar
2 votes
1 answer
67 views

Selecting a submatrix of a binary matrix NP hard?

I have the following problem and I am wondering if it is NP Hard or not. Let $A$ be a binary matrix whose rows and columns are indexed by the sets $\mathcal{I}=1,...,m$ and $\mathcal{J}=1,...,n$. A ...
D. Sena's user avatar
  • 23
0 votes
0 answers
382 views

How to generalize MATRIX-MULTIPLY-RECURSIVE to multiply n × n matrices?

the question is as follows: "Generalize MATRIX-MULTIPLY-RECURSIVE to multiply n × n matrices for which n is not necessarily an exact power of 2. Give a recurrence describing its running time. ...
Portgas D Ace's user avatar
1 vote
1 answer
155 views

Reorder columns in a 2d matrix to maximize the count of all repeated subarrays across all rows

I have a matrix (input): -- c1 c2 c3 r1 AA BB CC r2 CC RR BB r3 EE DD FF r4 KK DD EE r5 DD GG KK r6 PP QQ KK Let's call each matrix cell a namespace. If two ...
night-crawler's user avatar
1 vote
1 answer
30 views

Writing an Algorithm to Represent a Bit Matrix in Minimal Operations?

I am trying to come up with an algorithm to find the minimal representation of the transformation from a zero matrix to a target matrix. Specifically, I have an empty matrix and can perform operations ...
ImaDoofus's user avatar
1 vote
1 answer
91 views

Given a binary matrix, find the number of sub-matrices with all ones

Given a matrix A, let Aij denote the element of the i'th row and j'th column. $$ A_{i,j}\in \{0, 1\}$$ Find the number of sub-matrices with all ones. 1 <= #rows, #columns <= 150 P.S. This ...
Yuv's user avatar
  • 139
2 votes
0 answers
62 views

Permuting matrix entries to lower rank

Suppose I have a rank-$k$ matrix $A \in \mathbf{R}^{m \times n}$. Now suppose this matrix has its elements shuffled by an adversary to maximize the rank. Is there a way to reverse this permutation and ...
Calvin Elder's user avatar
1 vote
0 answers
41 views

Adding two 2D matrices together: row by row vs column by column

When adding two 2D matrices of the same size (in row major format), in sequential code with no vector operations, is it faster to add them column by column or row by row? At first I thought it would ...
Gabriel's user avatar
  • 11
8 votes
5 answers
3k views

In algorithms for matrix multiplication (eg Strassen), why do we say n is equal to the number of rows and not the number of elements in both matrices?

In Strassen's algorithm, we calculate the time complexity based on n being the number of rows of the square matrix. Why don't we take n to be the total number of entries in the matrices (so if we were ...
thebasqueinterdisciplinarian's user avatar
2 votes
2 answers
192 views

Complexity of unbounded Gaussian convolution

What is the asymptotic complexity of doing a convolution of an unbounded Gaussian on an NxN input matrix $M$? The naive approach is $O(n^4)$ ($R_{ij} = \sum_{k=1}^{n}\sum_{l=1}^{n}M_{kl}*g(\sqrt{(k-i)^...
TLW's user avatar
  • 1,404
1 vote
2 answers
96 views

Convert lower-left matrix triangle 1D index to row, column

How can I convert a 1D index in the lower-left triangle of a grid into a row and column? For example, consider this table of 1D indices, indexed by row and column ...
Andy Thomas's user avatar
1 vote
1 answer
38 views

Expected value of maximum of a matrix of size $n$

I have a square matrix (call it $A$) of size $n$ ($n$ is a positive integer). Each column is a permutation of $[1:n]$. I take the first row of $A$, i.e. $A(1,:)$ and wonder what will be the frequency ...
fox's user avatar
  • 183
0 votes
0 answers
28 views

Fast compute of F*P*FT matrix product

Let $P$ be a symmetric (positive definite, if that helps...) matrix of size $n$. Let $F$ be a matrix of size $n$. Is there an existing efficient algorithm implementation to calculate $FPF^T$ ? Is ...
Parker Lewis's user avatar
0 votes
1 answer
30 views

Split matrix by groups of columns but *capture all combinations of X columns* for some X

Say I have a big matrix, ~50000 rows, ~80000 columns. I want to split it up and solve subproblems on different machines (horizontal scaling). But I need to make sure every column can be combined with ...
Alexander Mills's user avatar
0 votes
0 answers
106 views

Prove that the total number of parenthesizations of n matrices is Ω(4^n/n^3/2)

Is it possible to prove the total number of parenthesizations of n matrices is Ω(4^n/n^3/2) using the Induction Method? Recurrence formula from CLRS book When n = 1, the sequence consists of just one ...
learner_b's user avatar
0 votes
0 answers
240 views

Binary Matrix covered with squares to cover all 1's in min cost

So I recently came across a question in my Algorithms class. Given a binary matrix of N X N. we can do following operation any number of times we can take a square of size M X M (1 <= M <= N) ...
Kira Yoshikage's user avatar
1 vote
1 answer
55 views

Having a 2D matrix with three typed elements, how to efficiently cover one of the types and NOT cover the other one?

I have a matrix with three possible elements: A, B and C. The size of the matrix could be a maximum of 15x16. $$ \begin{bmatrix} A & A & C & A\\ A & C & B & C\\ A & C & ...
Superluminal's user avatar
0 votes
0 answers
49 views

Complexity of calculating Takagi's factorization of $n \times n$ matrix

As described here the Takagi factorization of a square symmetric complex matrix $A=VDV^T$ where D is a real nonnegative diagonal matrix, and V is unitary. I'm wondering what the complexity of ...
atman's user avatar
  • 53
2 votes
1 answer
60 views

Finding a map between two matrices that minimises distance differences of neighbors

Given two binary matrices of the same size with the same element counts, how can we find a map mapping ones to ones such that the sum of differences of distances of all pairs of neighbors is minimised,...
user10364768's user avatar
0 votes
1 answer
40 views

Time reversible Markov chains question

Let Q be a symmetric transition probability matrix on states 1 , . . . , n; that is $q_{i,j} = q_{j,i}$ for all i , j. Consider a markov chain defined as follows. Whenever the chain is in state i, the ...
Win_odd Dhamnekar's user avatar
0 votes
0 answers
39 views

Display XY data on computer

I would like to experiment with displaying the output of an analog to digital converter on computer. Samples of the ADC output would determine the intensity of one pixel. The input to the ADC is an ...
Otto Hunt's user avatar
0 votes
0 answers
66 views

Given a 2D Array (of 0's and 1's), find the minimum number of rows required so that maximum columns have their sum greater than a threshold

I have a 2D array of some rows and columns which are having only 0's and 1's. I would want to know if there is a way to optimize the number of rows so that maximum number of columns have their column ...
Pramod Gopinath's user avatar
0 votes
1 answer
60 views

Whether a number is in a sorted matrix

I have a square n-by-n matrix of integers. The number of columns is equal to the number of rows. Each column and row are sorted from the lowest to highest numbers. For example: Another example: I ...
אורי orihpt's user avatar
1 vote
2 answers
392 views

Counting the number of parenthesization

I'm reading CLRS and there is something I don't understand regarding counting the number of parenthesization, in the Matrix-chain multiplication chapter, the book says: Denote the number of ...
beginwithc's user avatar
1 vote
1 answer
148 views

Complexity of finding $d$ largest eigenvectors of a symmetric matrix

I know that for $n \times n$ matrix, it takes $O(n^2)$ time complexity to compute the largest eigenpair of the matrix using Power method or etc. I'm interested to further extend the case so that now ...
Jon Megan's user avatar
  • 123
0 votes
2 answers
89 views

What kind of algorithm do i need when the place of numbers changing according to n number?

I have a project in Golang. But i don't have any idea about how to solve it. n will be an odd number (Feedback will be given if an odd number is not written) As output, a structure with n*n matrix ...
Yiğit Yılmaz's user avatar
1 vote
0 answers
23 views

Algorithmic ideas to multiply two tall & skinny matrices into one large square matrix?

This problems comes from AI, and it looks something like this: I am supposed to multiply two floating-point matrices A * B. A ...
Azuresonance's user avatar
0 votes
0 answers
19 views

runtime of solving matrix differential equation wrt dimensions of matrix

Suppose a computer solves a coupled differential equations (with given boundary conditions) of which each equation deals with $2^n \times 2^n$ size of matrices as solutions. My question is Does time-...
userflux9674's user avatar
3 votes
0 answers
161 views

Low-rank matrix completion is NP-hard

In looking into the problem of low-rank matrix completion / relaxations of the general problem to derive exact solutions, many papers cite that the original formulation is NP-hard but I cannot find a ...
Doc Stories's user avatar
1 vote
1 answer
39 views

Find indices of equal cells in a matrix

I am trying to find the indices of all the equal elements in a matrix $\left ( n\times m \right )$. For each pair of matching cell, I will perform a specific function on them. For example: $ \begin{...
Peter Fayez's user avatar
4 votes
1 answer
595 views

Maximum sum of values in a square grid (one in each row/ column)

this is my first post here so bare with me :). What i'm looking for is an algorithm that can find the maximum sum of values in a square grid under the restriction, that you can only pick 1 value from ...
Control's user avatar
  • 41
1 vote
0 answers
57 views

Time complexity of computing general imminant

Consider the immanent of $n \times n$ complex matrices \begin{equation} \operatorname{Imm}_f(A) = \sum_{\sigma \in S_n} f_n(\sigma) A_{1 \sigma(1)} \cdots A_{n \sigma(n)}. \end{equation} Here $f_n:\pi ...
En-Jui Kuo's user avatar
0 votes
3 answers
160 views

Data structure to efficiently add zero-rows to a sparse matrix

I would like to create a data structure representing a sparse matrix, where the number of non-zero values is $\mathcal{O}(n)$ (the matrix is $n\times n$). The matrix should support the following ...
Ariel Yael's user avatar
1 vote
0 answers
194 views

Describing the subproblem graph for matrix-chain multiplication

From Introduction to Algorithms by CLRS: 15.2-4 Describe the subproblem graph for matrix-chain multiplication with an input chain of length n. How many vertices does it have? How many edges does it ...
Andrew Schroeder's user avatar
4 votes
0 answers
66 views

minimizing a pairwise sum with respect to a sequence of integers

Let $m$ and $n$ be two integers, where $m \leq n$. Suppose you are given $m^2$ matrices $W^{i,j} \in \mathbb{R}^{n \times n}$ for $i, j \in \{1, \dots, m\}$. The goal is to find a sequence $a$ of $m$ ...
MWB's user avatar
  • 485
9 votes
1 answer
641 views

Optimizing a sum of matrix chains

Edit Jan 31: important special case is when the sums form a nested structure, search for "Hasse diagram is a tree" below Here's a practically relevant variation on matrix chain problem: Find ...
Yaroslav Bulatov's user avatar
4 votes
2 answers
114 views

Best-known complexity for $l \times m$ by $m \times n$ matrix multiplication?

I know that the fastest known algorithm for multiplying two $m \times m$ matrices runs in time $m^{\omega}$, where currently we have $\omega = 2.3728596$ due to Virginia Williams's latest result (see ...
Caleb Stanford's user avatar
8 votes
11 answers
4k views

Real life examples of *zero* weight edges in graphs

The meaning of edges with zero weight in a weighted graph questions me for a long time, and I even asked a related question previously. Yet, when I recently read here a question on real life example ...
Matthieu Latapy's user avatar
2 votes
0 answers
87 views

Is it NP-hard to find different roots of different matrices simultaneously?

Consider the following problem: input: pairwise distinct natural numbers $k_1,\dots,k_m$ that are all $\leq n$, and matrices $A_1,\dots,A_m \in \Bbb Q^{n \times n}$ where $m \leq n$. output: a ...
Haim's user avatar
  • 21
1 vote
1 answer
179 views

A hash function for a 2D hash table with a scattering property?

I have an $n\times n$ matrix, and want to find a bijective function $h:[n^2] \to [n]\times [n]$ that can act as a hash function to map the numbers 1 through $n^2$ to row/column indices in my matrix. ...
RJL's user avatar
  • 11
6 votes
1 answer
163 views

Computing tr(ABCD...)

Suppose we have $k$ $n\times n$ matrices $A,B,C,\ldots$. Is there a way to compute/approximate the trace of their product much faster than computing/approximating the full matrix product? IE, ...
Yaroslav Bulatov's user avatar
2 votes
1 answer
103 views

Cover 2 by n binary matrix with submatrices of minimum total size

This is a homework problem. Let $A$ be an input binary matrix of size $2 \times n$, and $L$ an integer. The objective is to cover all 1s in $A$ with submatrices, such that we minimize the sum of the ...
Rob32409's user avatar
  • 115
3 votes
1 answer
264 views

N points with maximum sum distance

Given a distance matrix for 50,000 points, how do I select $N$ points so that the sum of all distances between the $N$ points is maximized? $N$ could be as high as 100. To calculate the sum of ...
user2349481's user avatar

1
2 3 4 5 6