Questions on the manipulation of matrices in Mathematica.

learn more… | top users | synonyms (1)

80
votes
7answers
22k views

Elegant operations on matrix rows and columns

Question The Mathematica tutorial has a section 'Basic Matrix Operations', describing operations like transpose, inverse and determinant. These operations all work on entire matrices. I am missing a ...
0
votes
1answer
37 views

Help needed with assignment [on hold]

Can I get some help with this: Write a module which as an input receives two matrices, the first matrix transforms in to the same matrix, but in the new matrix occur absolute values of the first, ...
1
vote
1answer
66 views

Improve simulation speed using Compile

I have two square matrices, a hermitian matrix h and an unitary matrix v. I am interested in the following function ...
6
votes
2answers
615 views

Sort matrix by columns and rows without changing them

I would like to sort a matrix in descending order first by the total of each column, then by the total of each row, but without changing their content. For example, if I had: ...
0
votes
0answers
50 views

Which method to use for finding maximum without actually computing optimization function explicitly?

I am new to Mathematica and I am currently working on an optimization problem. The optimization function that I have easy to calculate for some assignment of variable but it is very difficult to ...
-1
votes
1answer
51 views

Module whose input is a function of 2 variables [on hold]

I need to make a Module whose input is a function of 2 variables and 2 variables m,n so i can make a Matrix with Array. Basicaly, I need this: ...
-1
votes
0answers
30 views

Estimating fundamental matrix for stereo pair

I want to calculate fundamental matrix for stereo pair. Matlab has this function - estimateFundamentalMatrix. Is there an analog in Mathematica? If no how I can calculate it?
7
votes
1answer
255 views

Is it possible to implement symbolic sub matrices?

The accepted answer in the following link: http://stackoverflow.com/questions/5708208/symbolic-matrices-in-mathematica-with-unknown-dimensions provides a functionality to create symbolic matrices ...
1
vote
2answers
69 views

Matrix with infinity on main diagonal

The question is trivial, however, there might be unexpected solutions. What would be nice way to create a square matrix with $\infty$ on main diagonal, and some arbitrary constant everywhere else? My ...
2
votes
2answers
205 views

How to make Mathematica show matrices and vectors nicely

It shows me like {{0}, {1}, {0}, {-1}} . Is it possible to make it look like a vector, always?
0
votes
1answer
74 views

Finite Field matrix rank calculation

How does one define a matrix over $\mathrm{GF}(p^r)$ in Mathematica in order to compute rank? I am working with $\mathrm{GF}(2)$?
3
votes
2answers
226 views

Binarizing a matrix

I have an image with a few bright pixels with the remaining ones very dark. The difference is in orders of magnitude. I want to binarize this matrix (corresponding to the image) making all values ...
-3
votes
0answers
39 views

Harris corner detection and plots [closed]

Could someone help me recreate these plots using Mathmatica. https://youtu.be/9-F5-gUIAWE?t=20m28s The are applying a hessian matrix to an image, and calculates the eigenvector.. And They then ...
5
votes
3answers
153 views

Constructing a grid from a matrix

I would like to construct a grid from a matrix. For example, one possible matrix is $M1$. $$M1= \begin{pmatrix} c2 & a1 & a1 & a1 & a1 & a1\\ a2 & b1 & c2 & a1 & ...
0
votes
0answers
51 views

Does Mathematica support Laguerre Polynomials of Matrix Argument?

I am wondering whether Mathematica can also compute the Laguerre polynomials of matrix argument as the appear in multivariate statistics? For example, they appear in this paper here: ...
0
votes
1answer
87 views

Extract coefficient matrix $A$ from expression $f(x)$

I have expression: $$f(x)=\sum_{i=0}^{K-1}\sum_{j=0}^{N-1}a_{i,j}e^{ix}x^j.$$ I want to extract coefficient matrix $A$ from expression $f(x)$ where $$A=\left( \begin{array}{ccccc} a_{0,0}& ...
0
votes
1answer
39 views

symbol matrix calulation

I have question about matrix calculation. like $\mathbf{b}^{t}\Sigma \mathbf{b}$, where $\Sigma$ is 7 by 7 matrix, and $\mathbf{b}$ is vector of 7. and each element in the vector b or $\Sigma$ is ...
0
votes
1answer
48 views

Symbolically solve system of equations involving matrix

I need to solve the following system of equations symbolically for a_i, b_i, and c_i: ...
14
votes
3answers
562 views

Why is calling Dot with many arguments so inefficient?

Say I want to multiply a reasonably large list of symbolic matrices. ...
8
votes
3answers
926 views

How to manipulate gauge theory in Mathematica?

I want to know if there is a way of typing into Mathematica an expression like the following, $$\epsilon^{\mu \nu \lambda} f^{abc} A^a_\mu A^b_\nu A^c_\lambda + g\epsilon^{\mu \nu \lambda} A^a_\mu ...
3
votes
1answer
106 views

$\mathbf L\mathbf D\mathbf L^\top$ Cholesky decomposition

Mathematica can do a Cholesky decomposition $\mathbf A = \mathbf L\mathbf L^\top$, but how do I do a LDL decomposition $\mathbf A = \mathbf L\mathbf D\mathbf L^\top$, with $\mathbf L$ being a unit ...
2
votes
0answers
54 views

Factor out a constant from a matrix

I've got a matrix in which every entry is of the form x/4. I cant find out how to factor out the 1/4 so that the actual matrix is clearer. Thanks for your help!
2
votes
1answer
49 views

Efficient Implementation of Resistance Distance for graphs?

Is there an implementation of the resistance distance matrix (or just resistance matrix) for graphs available in Mathematica?
0
votes
0answers
44 views

in the part assignment is not a symbol, create different matrices with a “Do” loop [duplicate]

Im trying to assemble new matrices from some previous matrices I have created, but I can´t. What Im trying to do is the following: 1) I have different matrices: ...
0
votes
1answer
53 views

Returning functions that are partly evaluated

I have some performance issues when calling Table[{h, Slow1[h, n]}, {n, nlist}, {h, 0.1, 10, 0.5}]; for a given list ...
1
vote
1answer
69 views

How to construct a kernel from a function?

I would like to convolve an image with a mathematical function. I understand that I need to have the mathematical function in a matrix form. How can I build it? Thanks
12
votes
1answer
231 views

Why does partitioning increase Dot execution speed?

I have noticed that multiplying a list of matrices can be significantly sped up by partitioning the list, calculating the product of the partitions matrices, and then multiplying the results. ...
3
votes
3answers
221 views

Hypergeometric function with a matrix argument

I am looking for the evaluation of a Hypergeometric function with a matrix argument as for example in Ploev and Edelman or as showcased in this Wikipedia article. From what I understand from ...
0
votes
1answer
76 views

whats wrong when I use for loop for creating a matirx? [closed]

When I use separate value for "i" and "j", I get the correct desirable answer. ...
1
vote
1answer
325 views

Usage of Piecewise/RSolve to solve an equation based on condition

I am trying to compute price of call option on a stock using the finite difference method. I have a VBA code for it, and I am trying to find out how I can use Mathematica memoization functions and ...
0
votes
1answer
57 views

Symbolic matrix inversion

If I try to get an inverse of a matrix: a | b | c b | d | 0 c | 0 | 0 Inverse[{{a, b, c}, {b, d, 0}, {c, 0, 0}}] I get the answer: ...
21
votes
0answers
163 views

Does Mathematica store hidden information for matrix objects?

Bug introduced in 10.0.0 and persisting through 10.1.0 or later I found a case where calling one built-in function (HermitianMatrixQ) for a given matrix changes ...
0
votes
3answers
55 views

Simplifying Terms in a Matrix

Given the following 3 matrices: M1=1/3*{{1,1,1},{1,α,α^2},{1,α^2,α]}} Z1={{Z+Zg,Zg,Zg},{Zg,Z+Zg,Zg},{Zg,Zg,Z+Zg}} M2={{1,1,1},{1,α^2,α},{1,α,α^2}} where alpha ...
0
votes
2answers
25 views
-1
votes
1answer
47 views

Beginner Question: Assigning an indexed Variable to a given list

I am pretty new to the game and have a problem, which i am sitting on for hours. 1) I created a random Matrix 5x5 ...
4
votes
1answer
67 views

Speed up the auxiliary function magicSquare when $n$ is doubly-even

Today, I saw a question about magic square. Please see here When $n$ is doubly-even.Namely, Mod[n,4]==0 ...
1
vote
1answer
61 views

Divide each element of a list of 500 matrices by another matrix

Lets say that I have a Table of dimension (3,3,500) and I'd like to perform element-wise division by a 3x3 matrix along the third dimension (of length 500 in this case). What is the most elegant way ...
8
votes
3answers
645 views

The magic square function

There're some matrices that the sum of columns, sum of rows, and sum of diagonals are the same value. Here is an example: ...
1
vote
1answer
66 views

Assigning some results after a solve procedure to the coefficients of a matrix

I have a matrix M[3,3]. After a solve procedure, I obtained these results. {{M[1, 2] -> Cos[ψ[t]], M[1, 3] -> 0, M[2, 3] -> 0, Cos[θ[t]] -> M[3, 1], M[3, 2] -> 0, M[3, 3] -> 1, M[2, 1] -> ...
0
votes
0answers
32 views

Parametrizing a matrix given its trace and norm

I have a problem where I have to generate random matrices with the following properties: ($a$ is a given fixed number) $\mathrm{Tr}\, A=0$ $\mathrm{Tr}(A^\dagger A)=\|A\|_F^2=a$ I was wondering ...
4
votes
4answers
113 views

Express block matrix in terms of matrix basis

I'm trying to construct a function that returns the multiplication table of a matrix Lie algebra. Assuming a basis of matrices, my definitions: ...
-1
votes
1answer
89 views

Laplace equation

I tried to run this code, but it doesn't work for NDSolve ...
5
votes
4answers
170 views
2
votes
1answer
101 views

Anyone knows the algorithm used by NullSpace function?

NullSpace function gives a list of vectors that forms a basis for the null space of the input matrix. When the rank of the input argument matrix $M_{m\times n}$ is ...
4
votes
2answers
111 views

Gridding in a Nested Matrix

We have a nested matrix as: nested={{he, {{e, f, g, h}, {s, 0, q, i}, {s, 0, q, j}}}, {ho, {{e, f, g, h}, {0, u, t, i}, {u, t, 0, j}}}} and with the line ...
0
votes
0answers
54 views

Recursive computation using Piecewise

I am trying to create an array using a series of equations using Piecewise. I am stuck in one of them. I am just putting a simplified version of code as below. I ...
4
votes
4answers
705 views

Writing a circular matrix

I have two square matrices, $A$ and $B$, of the same size, say, of $m \times m$. What I want is to write a programme/function of three variables, $A$, $B$ and $n$, that outputs the $mn \times mn$ ...
0
votes
1answer
56 views

Elements inside arrays seem to be strings rather than signed numbers

When I have code like b = Array[Subscript[be, #] &, {3, 1}] b = b /. {Subscript[be, k_] :> Subscript[-be, k] /; k > 1} I am noticing that Mathematica ...
0
votes
0answers
36 views

Deciphering output messages using Solve

I'm trying to solve the following system. The error messages I'm getting suggest that there may not be a solution [my desired result], but I'm not sure if there could be something else going on. The ...