Questions on the manipulation of matrices in Mathematica.

learn more… | top users | synonyms (1)

4
votes
3answers
382 views

Efficient matrix / array generation

What is the most efficient way of generating the following matrix? $\left( \begin{array}{ccccc} 1 & 0 & 1 & 0 & 1 & 0 & 1 & \dots\\ \frac{1}{2} & \frac{1}{2} & 0 ...
1
vote
1answer
111 views

Matrix/tensor addition behaving funny under replacement?

I have two matrices I want to add, and one of the matrices is a tensor product of two vectors. I've used a SetDelayed to define the summed matrix, because I want to evaluate it for different values of ...
0
votes
1answer
47 views

Importing a Matrix whit different column numbers depending on the row

I have a bunch of coordinates given in a file. The file contains Startpoints and Endpoints of arrows in columns(Example): ...
3
votes
6answers
332 views

How can I construct a distance table?

I have a list of city names (of arbitrary length), f.e. c = {"BAL", "NYC", "LAS", "AUS"}; and the distances between them : ...
6
votes
7answers
1k views

How to select all elements above the main diagonal of matrix?

How to select all elements above the main diagonal of matrix? I need to create a list of them.
1
vote
3answers
142 views

Working with nested matrices

I have a matrix: A = {{a, b}, {c, d}} But each its element, itself, is another matrix too. ...
42
votes
6answers
3k views

Does Mathematica have advanced indexing?

I have two $M \times K$ arrays $L, T$ where I would like to set all the elements in $L$ to zero whenever the corresponding element of $T$ is greater than 15. The ...
1
vote
1answer
133 views

Matrix and random, weighted assignment of rows

I asked a question in this category previously but my problem has changed. On one hand, I have a large number of data files as .dat format, and on the other hand, I have a matrix ...
0
votes
1answer
72 views

Swapping rows and columns in matrix [closed]

If I have an array like the following $\left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array} \right)$ How can I swap the rows and columns, so it is ...
1
vote
1answer
120 views

Calculate the algebraic multiplicity of known eigenvalues of a large, sparse matrix

I have a large (and sparse) matrix with size 1000x1000 -- 10000x10000. I believe i know all eigenvalues for the matrices. All entries are integers and so are the eigenvalues. I want to check this by ...
0
votes
1answer
220 views

How to create a 2D array (matrix) [closed]

I am pretty new to Mathematica. I need to create 2d array dynamicly. I got some code in C++(Qt) and it looks like this: ...
1
vote
1answer
48 views

Correctly substituting a matrix into a scalar equation [duplicate]

I am having trouble correctly substituting a matrix into an (originally) scalar equation. For example: A = {{3, 1}, {1, 2}} cp = CharacteristicPolynomial[A, x] ...
0
votes
1answer
115 views

Select positive value from a vector

I am wondering how to pick out the positive Omega value from soln, and make these positive values into a row vector. I know how ...
1
vote
1answer
38 views

Evaluation of m.v is blocked by applying MatrixForm. Why? [duplicate]

I'm trying to understand what is happening in the notebook session below. I have a 2x2 matrix m = {{-1,-1}, {-1,-1}}. And a vector ...
4
votes
2answers
121 views

Checking powers of a matrix for zeros

I'm currently working on a project that deals with numerical semigroups and their connection to matrices. I'm pretty new to Mathematica, so I wouldn't be surprised if my question has a simple ...
1
vote
1answer
92 views

Matrix and string variable

There are $100$ .dat data files which contain numerical parameters. ...
1
vote
2answers
110 views

How to drop the identical rows and columns of a matrix?

I'm currently trying to find a way to eliminate from a square matrix of generic dimension the duplicate (up to sign) rows and columns, obtaining a smaller dimensional matrix. I searched around here ...
2
votes
2answers
149 views

Building adjacency matrix from set data

I have two sets: games and players. Players pick their games. As such I will have data say g1={p1,p3,p5},g2={p2,p4},g3={p2,p3,p5}. My interest though is to build the connections among players because ...
2
votes
1answer
63 views

Sorting a matrix except its last row

Given M = {{"Utah", 2}, {"Iowa", 1}, {"Maine", 3}, {"Total", 6}} I want to obtain the reverse-sorted result like this: ...
2
votes
1answer
152 views

Loop in solving multiple matrix calculation

I am wondering is there a way to use loop, like Do, For, to rewrite the last line in the code. I tried to use ...
1
vote
0answers
72 views

vector/list containing matrices as elements dot product [closed]

mA = {{a11, a12}, {a21, a22}}; mB = {{b11, b12}, {b21, b22}}; mC = {{c11, c12}, {c21, c22}}; mD = {{d11, d12}, {d21, d22}}; v={{mA},{mB}}; w={{mC},{mD}}; What I ...
0
votes
1answer
146 views

Factor vector out of a matrix

I am wondering how to factor a[1],a[2],...,a[4] out of sim so that I can write sim as the ...
0
votes
1answer
117 views

Mapping a function over n levels

I want to map a function over a matrix of rank n, for example: ...
2
votes
2answers
175 views

Matrix exponential via Cayley-Hamilton Theorem

I'm attempting to calculate the exponential of a matrix via Cayley-Hamilton theorem. (Following the "concrete example" from http://en.wikipedia.org/wiki/Cayley%E2%80%93Hamilton_theorem) I am having ...
2
votes
0answers
99 views

A math function similar to “LatticeReduce” for finding linear independent basis

We would like to ask a math function similar to "LatticeReduce" for finding linear independent basis. The input is a list of vectors $M=\{v_1,v_2,v_3,\dots\}$, with the following property: There is a ...
1
vote
3answers
95 views

Finding if a matrix is square

I have a matrix which is constructed element by element through some iterations, and thus can be non-square. If it's not square, then I want to make it square filling with ...
0
votes
0answers
52 views

Extracting Coefficient Matrices from partial differential equations

I have a system of differential equations which are in the form Dt[a01,t] + u*Dt[a01,x] + v*Dt[a01,y] + w*Dt[a01,z] I have ten of these equations and my ...
2
votes
1answer
104 views

How to define a matrix with all elements 0? [closed]

A matrix can be defined as M = Array[m, {3, 3}] which gives ...
3
votes
2answers
297 views

Package for representation of groups (group theory)

I wanted to know if there is a package which allows to compute representations of a group like the definition representation, adjoint and so on (for example the Pauli matrix for $SU(2)$ if I specify ...
2
votes
1answer
143 views

Find positions where two matrices differ

I have two matrices A and B of identical dimensions. What's the simplest (shortest) way to find the indices of differing ...
1
vote
1answer
73 views

Importing adjacency matrix from file of 0/1 arrays

Is it possible to import adjacency matrix for graph representation, from simple text file with NxN (rows x columns) of 0s/1s: 0 1 0 0 1 0 1 1 0 1 0 0 0 1 0 0
3
votes
1answer
172 views

Are there any more time-efficient ways to solve a matrix equation than with SparseArray and LinearSolve?

I am trying to solve a matrix equation, with the matrix being tridiagonal. The problem I am having is that a message keeps appearing that I don't have enough memory. Here is the code: ...
6
votes
2answers
418 views

Combining three R, G, B matrices into a single matrix of 3-tuples?

Working with Mathematica 8 on OSX here. I have three $1024 \times 1024$ matrices representing the counts from consecutive exposures onto a CCD with $R$, $G$, and $B$ filters on it, and am looking to ...
0
votes
1answer
64 views

Show List of HighlightGraph Objects in Matrix

I'm new to Mathematica and can't get my problem solved. I want to display a list of HighlightGraph objects in MatrixForm like ...
2
votes
1answer
145 views

Multiple swapping of rows and columns

m={{a, b, c, p}, {d, e, f, x}, {g, h, k, z}, {u, v, w, y}}; I want to swap 1st and 2nd rows by 4th and 3rd rows respectively. And then, swap 1st and 2nd columns ...
3
votes
1answer
182 views

Plotting with ColorFunction -> GrayLevel - no black

This is probably a fairly trivial question, yet I have been unable to find an answer - help would be much appreciated! :) I am trying to plot a 28 x 28 matrix (tabulated data given here), containing ...
4
votes
3answers
315 views

Finding parameters making real part of eigenvalues vanish

I have the following $\;3\times3$ matrix: $\left( \begin{array}{ccc} 0.04 -0.4 b & 0 & 0.04 -0.4 b \\ 0 & -0.08-1.2 b & -0.06-0.9 b \\ 1.04 -0.4 b & 2.08 -0.8 b & 0 ...
0
votes
1answer
332 views

How Simplify and Assume can be combined on matrix products?

What I am trying to do is to simplify some expressions involving matrices! The problem is that Simplify[] considers the simplifications based on alphabetical order and everything is Commutative. For ...
0
votes
0answers
49 views

TableDirection in TableForm

I got confused about what does "the outermost dimension" and "the first dimension" mean in the document I snipped. Does it mean row or column?
3
votes
2answers
110 views

How do we make a negative integer out of a string of a negative number and vice-versa?

Negative numbers are not taken into consideration by mathematica's built-in functions. FromDigits["-2"] Gives me this message: ...
0
votes
0answers
57 views

Find the values of parameters so that the matrix is symmetric positive definite

Good evening , I have a matrix 20x20 in symbolic form. The matrix depends on 5 parameters (a,b,c,d,e). I would like to get the interval of each parameters that ensures that the matrix S is symmetric ...
1
vote
2answers
127 views

How to sort the adjecency matrix of bipartite graph so to have two off-diagonal blocks

In a bipartite graphs there are two class of nodes, say A and B. Each node of class A may interact only with nodes of the class B, and viceversa. The corresponding adjecency matrix is thus composed by ...
0
votes
0answers
43 views

How to get integer/rational and real eigenvectors to be the same? [duplicate]

forgive me if I missed this already being answered or too easy. Given a matrix: q = {{1, 3, 5}, {7, 11, 13}, {1/3, 1/7, 1/13}}; Eigenvectors are different here: ...
0
votes
1answer
197 views

How to get more accurate orthonormal eigenvectors?

I have a matrix M with real entries in MachinePrecision. I compute its eigenvectors and construct matrix ...
0
votes
0answers
59 views

How to compute variances from a matrix/table

I have created a matrix/table with an imported dataset. I want to know what the variance is for 3 values at a time but across 68 columns. I would like to do this in an automated way rather than 1 set ...
0
votes
1answer
205 views

Symbolic Jacobian computation

I have an equation for which I would like to compute the Jacobian symbolically. $$f(x)=Ax-diag(x)(Ax+b)$$, where $x\in \mathbb{R}^n$, $A\in \mathbb{R}^{n\times n}$ and $b\in \mathbb{R}^n$. I am new ...
68
votes
7answers
16k 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
0answers
68 views

Computing residues of matrix valued functions symbolically

I have a somewhat specific application in mind, but I've run into this kind of problem a few times and never found an elegant solution. Is there an efficient way to get Mathematica to recognize that ...
0
votes
0answers
34 views

Mathematica program for PLUR decomposition of a symbolic matrix using full pivoting

I wanted to ask if there is a Mathematica program for PLUR decomposition of a symbolic matrix M, such that M = P*L*U*R, using FULL (row and column) pivoting, and where R = reduced row echelon form of ...
1
vote
1answer
50 views

Formatting All Appropriate Output as Desired Automatically

I want to output in MatrixForm whenever I have a list/vector/matrix, but I do not want to have to type out the command each time. How can I write one command at ...