Questions on the manipulation of matrices in Mathematica.

learn more… | top users | synonyms (1)

6
votes
3answers
267 views

How can I create a random symmetric matrix in this way?

The most straight forward way for me to think about is like this: ...
0
votes
1answer
34 views

Picking some elements of a matrix and generating another matrix [duplicate]

If we have a nested matrix as: start={ {{1, 2, 2, 3}, {1, 1, -2, 1}, {3, 2, 2, -I}, {1, 2, 0, -I}}, {{3, 4, 4, 0}, {1, 1, 4, 1}, {3, 3, 4, -1}, {1, 1, 2, I}} } ...
2
votes
1answer
37 views

wrong result of an iteration related to replacement and comparing

We have two nested matrix and a code for replacement following an equality as: ...
1
vote
3answers
120 views

Conditionally binarizing matrices

I want to (fastly) convert matrices with values that are <= a threshold to binary matrices. I used a call to Binarize, but I don't like the Image and ImageData conversions as they obfuscate the ...
4
votes
2answers
94 views

replacement in a nested matrix

We have a nested matrix m1 = {{{1, 2, 2, I}, {1, 1, -2, 1}, {3, 2, 2, -I}}, {{3, 4, 4, I}, {1, 1, 4, 1}, {3, 3, 4, -1}}}; we must replace the first number of ...
6
votes
0answers
129 views

Why has Version 10.3 precision reduced?

In version 7.0.1.0 and versions 10.0 and 10.1 the following is produced: ...
2
votes
1answer
63 views

Why the curly bracket? [closed]

Why are there the curly braces in the output of DY = {{Cos[ay], 0, Sin[ay]}, {0, 1, 0}, {-Sin[ay], 0, Cos[ay], 0}}; DY // MatrixForm It looks inconsistent ...
3
votes
1answer
145 views

Hasse Diagrams from Adjacency Matrix

Let's say I have a rather large adjacency matrix for a partial order relation. Say an 80x80 matrix. What is the best way to display Hasse diagram? I have tried AdjacencyGraph and it does a not so bad ...
1
vote
1answer
45 views

How to find selected elements of inverse of a banded matrix without inverting it?

Is it possible to find some selected elements of the inverse of a large sparse matrix without inverting it? For example consider this Hermitian matrix (as a general case). ...
1
vote
2answers
89 views

Partial comparison between lists contained in larger matrices [closed]

Please presume we have two nested matrices m1 and m2: ...
0
votes
1answer
52 views

generation a nested matrix with a partly comparison of two other nested matrices [closed]

(this problem is maybe challenging because of its partly comparison) there are two nested matrices: mainmatrix1: ...
4
votes
3answers
214 views

Creating a nested matrix from two lists

I have a matrix and two lists: ...
1
vote
1answer
182 views

Derivative of a symbolic matrix

I need to write an elasticity equations as: {{a*∂/∂x,b*∂/∂y},{c*∂/∂x,d*∂/∂y},{e*∂/∂y,f*∂/∂x}}.{{u},{v}} where a,b,...,f are ...
0
votes
1answer
43 views

Lift and projection method in Least Squares Inverse Eigenvalue Problems [closed]

I need to implement the lift and projection method proposed by XUZHOU CHEN AND MOODY T. CHU in http://www4.ncsu.edu/~mtchu/Research/Papers/lsiep.pdf on page 7 in ...
3
votes
1answer
144 views

How to speed up filling a matrix as much as possible in a loop?

In order to find the solution of an $n\times n$ system of nonlinear equations by the method $x_{k+1}=x_k-D_k^{-1}f(x_k)$ where $D_k$ is an approximation of the Jacobian and defined by ...
0
votes
1answer
57 views

LinearSolve on non-square matrices?

I just came across a strange behaviour for LinearSolve (on Mathematica 8.0.0.0). Consider the following definitions: ...
2
votes
1answer
98 views

Product of $N\ 2 \times 2$ matrices and subsequently solving an equation dependent on the product

I have $N\ 2 \times 2$ matrices, each one containing one variable energy which may be complex. I want to muliply them all together to a single matrix ...
2
votes
1answer
118 views

Easier way to calculate Taylor remainder in 2nd order series

At the moment I have implemented the code for a Taylor 2nd order series for the function in three variables: $x_3^3+\frac{x_1-x_2}{x_1+x_2}$ The code builds on following expression: ...
2
votes
7answers
329 views

How to repeat a matrix on it's side?

I have the following matrix in Mathematica: mat = {{0,0,1,1}, {0,1,0,1}} I want to repeat this matrix N number of times on the side. For example if N = 3 then ...
3
votes
1answer
67 views

sorting eigenvectors of a final combined matrix

I have two matrices m1 and m2 as below: ...
1
vote
1answer
80 views

What's is the restrictions for the function MatrixExp?

When I use the MatrixExp on a general $2\times2$ matrix, Mathematica gives me this result: MatrixExp[{{a,b},{c,d}}] // TraditionalForm ...
5
votes
1answer
83 views

Would like to draw something similar to confusionMatrix created by ClassifierMeasurements

How do I show the values in each box? I know how to add the labels. Thank You
3
votes
3answers
133 views

Chopping matrix elements, real or imaginary

An undesired shape of a matrix has the following form: which is created by ...
2
votes
1answer
76 views

Mathematica's Solve[] and LinearSolve[] doesn't work to solve a system of equations IF parameters are not replaced

(I'm working on Mathematica 10.3) I have a system of 81 algebraic linear equations with 81 variables (variables are a1 to a81). ...
9
votes
1answer
224 views

Speed up construction of a dense matrix

I wish to find the numerical eigenvalues of a relatively small (100 dimensional) Hermitian matrix. While the eigenvalue calculation itself is fast, the construction of the matrix is taking longer than ...
7
votes
1answer
170 views

What kind of Arnoldi method is used in Mathematica?

Can someone give me a bit more information about what mathematical method Mathematica is using, (preconditioner, filtering-restarting, deflation) in the Lanczos implementation when I input something ...
5
votes
4answers
154 views

Add to matrix missing elements (for list of time series)

This question is an extension of the 43122. I’ve looked through many interesting post (like this) but (as always) missed the direct matching. So the setting is simple: ...
3
votes
2answers
115 views

How to form binary matrix with constants and given probability?

I want to create a binary matrix of 6x3 in which six elements (m13,m23, m33, m42, m52, m61) are constant and assigned '0' value; whereas for other twelve elements (m11, m12, m21, m22, m31,m32, m41, ...
4
votes
1answer
116 views

How to increase the evaluation speed of this somewhat complicated table / matrix operation?

I'd like to calculate the following one-dimensional array: OneDimArray = Table[(Norm[Sum[ MatrixA[[i,j]]VectorB[[j]],{j,N}]])^2,{i,N}] However this takes a very ...
3
votes
0answers
78 views

Real Canonical Form of Arbitrary Size Matrices

I have been searching the site and the Mathematica documentation, but have not found anything regarding this. If we find the Jordan Form of the following matrix, we get complex values, but I would ...
1
vote
2answers
65 views

How to replace the selected value in matrix with a specific digit?

I want to replace the selected values through "RandomChoice" by 1 and all other values in matrix with 0. I want output in binary form matirx. ...
3
votes
2answers
133 views

Factor multiplied matrix with vector

Say I have a matrix multiplication of the form $$B=A\cdot X$$ or $$\left( \begin{array}{c} \text{a11} \text{x1}+\text{a12} \text{x2}+\text{a13} \text{x3} \\ \text{a21} \text{x1}+\text{a22} ...
2
votes
1answer
136 views

different situations with Compilation of ConstantArray

First, we load some tools related to Compile for analysis. ...
2
votes
1answer
84 views

Eigenvectors choose intuitive ordering/sorting

Starting from some symmetric $L\times L$ matrices $M$(see below), I want to compute the eigenvectors in Mathematica, in order to construct an ...
1
vote
1answer
55 views

Fast arithmetic on matrix elements

I have a square matrix $U$ of dimension $L\times L$, I am interested in the following quantity $U_{1,j}U_{2,k}U_{3,l}U_{4,m}\cdots U_{L,q}$ summed over all permutations of the letter indices, ...
0
votes
2answers
103 views

How to map the second highest value in each row of a matrix

I have a matrix with three or more columns called mat. I would like to map the second highest value in each row of mat into its ...
1
vote
2answers
124 views

How to parallelize this code?

Initialize a matrix a with value of $\alpha$ in central cell as "ice", and $\beta$ in every other cell. ...
13
votes
2answers
536 views

more numerically accurate inverse matrix

I encountered the following matrix mat = {{2, 2.161209223472559` + 1.682941969615793` I}, {2.161209223472559` - 1.682941969615793` I, 2}} and ...
3
votes
1answer
60 views

How to fill a tensor with matrices one by one?

I have this tensor: nn = 4; tableToFill = Table[x, {p, 1, nn}, {q, 1, nn}, {i, 1, nn}, {j, 1, nn}]; that I want to fill with a matrix one by one with a matrix ...
3
votes
0answers
52 views

FindInstance of Matrices

I'm trying to use FindInstance to find examples of matrices that complete an expression. However, it seems like I need to specify atomics as my variables to the function. So, here's a really simple ...
0
votes
0answers
56 views

Can't operate on vector within a list of rules

I'm trying to set up a list of rules which includes the following: ...
0
votes
0answers
47 views

LatticeReduce question

Does LatticeReduce work with arbitrary precision arithmetic? That is, if I give it a linearly independent integer basis, but the integers are 40 decimal digits long ...
6
votes
2answers
152 views
3
votes
1answer
126 views

FindMaximum “is not a real number at” nrnum problem

I'm experiencing a problem using FindMaximum that I don't understand (due to my newbie knowledge of Mathematica's syntax). That is, FindMaximum sometimes returns a (correct) answer, but sometimes ...
0
votes
1answer
106 views

Generate random Hermitian matrices [duplicate]

I want to generate random Hermitian matrices. For now, random Hermitian matrices with size 2 are obvious to construct. But elegant methods for higher dimension would be nice! Are there methods besides ...
0
votes
0answers
34 views

Handling a matrix with components greater than machine precision

I have four quantities stemming from a 4th order differential equation. I can represent these as a vector which is a product of a 4X4 matrix $$ M=\left\{v,\frac{\partial v}{\partial x},\frac{\partial ...
6
votes
2answers
72 views

A problem about matrix/vector extension via $\tt ArrayPad$

Given that I have a vector and matrix as follow: vec = Array[Subscript["P", #] &, 6, 0]; mat = Array[Subscript["P", #1, #2] &, {5, 4}, {0, 0}]; And I ...
2
votes
1answer
59 views

Eigenvalues are not the same in the special case

I have this matrix: h = { {e1, 2, x}, {2, 2, x}, {x, x, 2} }; I want to calculate the eigenvalues and then set x equal to zero: ...
6
votes
1answer
69 views

Matrix Multiplication after “Flatten”

Say we originally had two matrices, $A$ and $B$, both $n \times n$, whose product $$ C= A.B $$ Now I flatten $A$. I can obtain a flatten $C$, from the following multiplication $$ ...
6
votes
1answer
121 views

List consisting of positions of the matrix elements and the elements themselves

Given a 2D matrix I would like to make a list with elements consisting of positions of the matrix elements and the elements themselves. Let the matrix be ...