Tagged Questions

Questions on the manipulation of matrices in Mathematica.

learn more… | top users | synonyms (1)

0
votes
3answers
180 views

Determinant of a random matrix consisting of integers

I am trying to implement a function that finds the determinant of a random matrix consisting of integers. This is the code I have written so far, but I am stuck. Suggestions ? I want to find a ...
0
votes
0answers
80 views

I need to draw a direction field and x1 vs t graph for the ode

I have written the following codes and i am able to get to the trajectory but not able to draw the direction field and x1 or x2 vs time plots. ...
0
votes
0answers
200 views

Solving for equilibrium distribution (symbolic) by matrix multiplication

I have a huge transition matrix (81x81). The matrix is too huge to paste here, so I store it in this notebook. (There are constraints on the symbols: $0<p_b<1$ and $0<p_g<1$. If further ...
1
vote
1answer
70 views

Multilpe matrix (mxm) and vector (n), wich are unequal, so get a (three dimensional matrix) mxmxn matrix

For example I have this matrix: mk = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} and I'd like it to multiple with this: ...
0
votes
1answer
203 views

How to speed up the computation of a specific array

I am doing some calculations on superconductivity and I REALLY need to speed up the way I calculate one of my arrays. I will put the input to the matrix (of course a tiny toy model of what I am ...
4
votes
3answers
256 views

Approximate minimum degree permutation algorithm in Mathematica

In MATLAB there is a nice implementation of the so called AMD (approximate minimum degree permutation) algorithm named amd (see Online MATLAB Documentation). There is an alternative algorithm called ...
1
vote
2answers
121 views

Add a column to a matrix as a function of the other columns

I was wondering if its possible to add a column to a matrix by a formula that uses all other columns, like this: ...
0
votes
3answers
592 views

Find the number of nonzero elements

How do you find the number of elements in a matrix that are non-zero. For instance, the following matrix has 5 nonzero elements. ...
0
votes
1answer
197 views

Performing matrix multiplications with a list

I have a question in regards to PseudoInverse. I have $A$, an $n\times 2$ matrix, and when I want to compute $(A^T A)^{-1}A$, by using ...
0
votes
2answers
139 views

How to calculate expected return, row by row in matrix? [closed]

Please help me, I'm writing my project and dont know how to solve this big matrix: I have to compute return row by row: 1st row: (18.32-17.14)/17.14 ; (19.17-18.32)/18.32 .... ...
1
vote
1answer
97 views

Transpose a ragged triangular matrix and display as columns rather than rows

I have a triangular list of lists as follows: ...
10
votes
4answers
463 views

Can (compiled) matrix permanent evaluation be further sped-up?

Update II  Sample code for simulating boson-sampling experiments has been added (as an answer). This code exploits new Mathematica capabilities relating to both empirical and smooth ...
0
votes
0answers
134 views

RowReduce : Record of all the row operations for RREF

I read "for what right-hand sides $b=(a,b,c)$ does $Ax=b$ have a solution", but that question pertains to solving for the unknown vector. I'd like a record of all of the row operations required to put ...
1
vote
1answer
617 views

Is there a built-in function to find the adjoint of a matrix?

I've been looking for a function that helps me get the adjoint matrix o a given one, I found that you can get the cofactors of a matrix but only by using the "Combinatorica" package, which I couldn't ...
1
vote
0answers
146 views

matrix with IF/THEN condition

How to generate all posible matrices with some conditions on the elements? I need to make for given $n$ all $n\times n$ matrices $A=(a_{ij})$ with three conditions: I. $a_{ij}=+1$ or $0$ or $-1$. ...
0
votes
0answers
101 views

Need Help with Output/Code Optimization Conparative Statics with System of Equations and Matrices

I have a system of equations (equilibrium conditions) and would like to evaluate how changes of exogenous variables affect the endogenous values. In step 1, I state the equilibrium equations and some ...
13
votes
1answer
461 views

Block Matrix Algebra with Mathematica

I have come up with some BlockMatrix Algebra for Mathematica to make notations easier. I have the following: ...
3
votes
2answers
339 views

How can we multiply nested matrices?

If we have nested matrices, such as: $$ \begin{bmatrix} \begin{bmatrix} a_{1,1} & a_{1,2}\\ a_{2,1} & a_{2,2}\\ \end{bmatrix} \begin{bmatrix} ...
0
votes
2answers
153 views

How to insert trigonometric functions into matrices' vector components? [closed]

Is it possible to insert a trigonometric function into a matrix which will be able to be used dynamically, as an element of one of the vectors of the matrix? I'm trying to perform an operation like ...
5
votes
4answers
252 views

Reduce a huge low-rank matrix

I have a huge square matrix, with a lot of zero columns and zero rows: $m=\left( \begin{array}{ccccccccc} 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & ...
6
votes
4answers
647 views

Check if a matrix is Positive Semidefinite

I have a question concerning the check whether a given matrix is positive semidefinite or not. In mathematica the function PositiveDefiniteMatrixQ[m] tells me ...
2
votes
2answers
254 views

Covariance of a P x M x N matrix

I have a stack of tiff files. When imported to Mathematica, they form a $P \times M \times N$ matrix, where $P$ is the number of single images in the stack, $M$ is the number of horizontal pixels and ...
1
vote
1answer
228 views

General form of a linear transformation

Let $v_1 = \begin{bmatrix} 2 \\ -1 \end{bmatrix}$ and $v_2=\begin{bmatrix} 1 \\ -1 \end{bmatrix}$ and let $A= \begin{bmatrix} 3 & 2 \\ -2 & 1 \end{bmatrix}$ be a matrix for $T\colon \Bbb ...
4
votes
1answer
151 views

Calculate the covariance of a large matrix

I have to compute the covariance of 50 very large integer matrices (2500x2000 elements). However, according to my estimation this will take around 10 days. Do you have any ideas how to speed things ...
0
votes
1answer
637 views

Best way to compute row eigenvectors

Without qualification, the term eigenvectors (of a matrix) refers to the column eigenvectors (of a matrix) and can be directly computed with Eigenvectors[]. To get ...
6
votes
1answer
227 views

Is matrix multiplication automatically done in parallel in Mathematica 9?

In good old Mathematica versions (5.2, 6.0), matrix multiplication was automatically done in parallel. For example, on an 8-core machine, define two square real matrices: ...
15
votes
1answer
291 views

Unpacked eigenvectors of complex matrices

Edit: This bug is fixed in Mathematica 10.0.0 I want to calculate eigenvectors of a Hermitian matrix. For example ...
7
votes
1answer
227 views

Limit for Matrix expression

Let's assume that $Q_0$ is $3\times 3$ matrix with $\det Q_0\neq0 $ and $$ Q_{i+1} = \frac{1}{2}\left[ Q_i+(Q_i^{-1})^T \right] $$ I need to find next limit: $\lim _{i \to +\infty}$$Q_i$. In other ...
0
votes
1answer
63 views

Issues FindRootPlot command

I've had some fun playing around with FindRootPlot for a simple system of equations: ...
2
votes
1answer
170 views

How to create a SparseArray satisfying multiple conditions on Parts and Elements of a Matrix?

I have a matrix m1 of size $3 \times 19$. Rows $1$, $2$ and $3$ represent $3$ different groups, and columns represent $4$ different blocks: block1 - columns $1$, ...
4
votes
2answers
148 views

Permutations: selecting reviewers without conflicts of interest

I would like to automate the process of selecting a number of proposal reviewers that fit a conflict of interest criterion. Let's say I have 5 reviewers and 5 applicants from 5 departments. The ...
5
votes
5answers
299 views

What is the fastest way to replace all zeros in a matrix?

In the following matrix m every 0 should be replaced with a 1: m = {{0,1,2},{5,0,3},{8,0,0}} Desired result: ...
5
votes
2answers
230 views

Random Matrix with integer coefficients and inverse also having integer coefficients

I'm trying to build a function that gives me matrices such that each: Has integer coefficients. Is non singular. Has inverse which also has integer coefficients. I have some code that one of my ...
0
votes
0answers
103 views

Getting increased accuracy for roots of determinant

I have a matrix $a(\kappa)$ from which I am trying to determine $\kappa$ by using the equation $det(a(\kappa)) = 0$. The matrices I deal with are on the order of 100 X 100 to 500 X 500. Originally I ...
1
vote
2answers
252 views

Finding maximal sublist of linearly independent vectors

Given a list of vectors v = {v1, ..., vn}, which is the fastest way to find a maximal sublist of linearly independent vectors? I could add the vectors one by one to ...
3
votes
2answers
139 views

Write list of polynomials as a matrix of coefficients times a list of monomials

I have the following problem: given a list of polynomials P = {p1, ..., pn} on the variables x[1], ..., x[n], find a list of ...
0
votes
2answers
138 views

Deleting duplicates from matrix

I have a 4x4 symmetric matrix that is obtained by solving some equations. I tried deleting duplicates with DeleteDuplicates, but that's not working with nested ...
3
votes
2answers
191 views

Mixed product identity between tensors in Mathematica 9

How can we simplify tensor expressions in Mathematica 9 using the mixed-product identity $(A\otimes B)(C \otimes D) \equiv AC \otimes BD$ ? Is it possible to implement this kind of evaluations using ...
2
votes
1answer
639 views

How to simplify symbolic matrix multiplication results?

I've defined three symbolic abstract matrices X, M and S as shown below. ...
4
votes
3answers
799 views

Minimum spanning Tree from a weighted adjacency graph

Note: Cross-posted at http://community.wolfram.com/groups/-/m/t/137658?p_p_auth=8QnKtT9I I have a really big graph, 40x40. Here is my code ...
0
votes
2answers
478 views

Classification of a linear system of equations with a parameter

I need to get every possible value of k that returns infinite number of solutions or no solution to this system: ...
2
votes
2answers
106 views

Keep order of mulciplication in Matrix production

{{λ E, B}, {λ A1, λ E}}.{{E, 0}, {-A1, E}} \begin{align*}\left(\begin{array}{cc} E^2 \lambda -A1 B & B E \\ 0 & E^2 \lambda ...
1
vote
1answer
286 views

Row-Reduced-Echelon-Form with Equation Parameters for Consistent Systems

I often do row-reduced-echelon-form (RREF) calculations that involve parameters using the RowReduce command. Most times, I want to know which parameters make the system consistent. For example: ...
6
votes
1answer
633 views

Fastest way to do vector / matrix multiplication with constant matrix

Suppose we have a fixed n x n matrix, call it $B$. What is fastest way to evaluate $v^t B\;v$ over many different vectors $v$? Since $B$ is a constant matrix, does this allow the number of operations ...
3
votes
1answer
77 views

quadratic constraint feasibility

Suppose that $A$ is an $n \times n$ matrix, and I have observed some entries of $A$, say, $A_S$ ($A$ restricted on $S$) for some subset $S$ in $\{1,...,n\} \times \{1,...,n\}$. I want to know if it's ...
2
votes
3answers
132 views

Any way to reverse span and join two span in Mathematica?

I port a matlab code to mathematica. In the original matlab code, I use ":" to pick up the desired elements in a matrix. In mathematica, I find in the documentation that the span operator is ";;" ...
7
votes
1answer
408 views

Extract matrix from a system of linear equations [duplicate]

I have a big system of linear equations $f_i(x_1,...x_n)$ with $n$ variables and $n$ equations. I want to extract the matrix $M$ where $\vec{f}(\vec{x})=M\vec{x}$. For example if I have $$ f_1(x) = x ...
1
vote
1answer
531 views

Direct sum of matrices [duplicate]

Is there a simple way (perhaps even a built-in function) that allows one to compute the direct sum of two square matrices?
0
votes
0answers
44 views

Eigenvalues of a matrix, rhombus/hash sign [duplicate]

I wanted calculate the eigenvalues of A = {{0, 1, 0, 0}, {a, b, c, 0}, {0, 0, 0, 1}, {d, 0, e, f}} Then assigned the parameters a value ...
0
votes
0answers
50 views

Construct matrix B from columns of matrix A? [duplicate]

Starting with Mathematica and working with matrices, I am looking for a way to construct a new matrix B from columns of matrix A. For example, matrix a has 8 columns and 4 rows, I want matrix B to be ...