Linked Questions

2 votes
3 answers
1k views

How to remove extra levels in list [duplicate]

My question is how to turn a 4-level matrix (notice one extra level) A = {{{{1, 2, 3}, {4, 5, 6}}}, {{{7, 8, 9}, {10, 11, 12}}}}; into the following: ...
Kaa1el's user avatar
  • 561
0 votes
1 answer
206 views

How to understand the extensional usage of Flatten? [duplicate]

Recently, I have been reading Mathematica program that written by many advanced Mathematica user, like Mr.Wizard, J.M., Kuba,etc to improve my programming capacity In the On generalizing Partition[] (...
xyz's user avatar
  • 625
0 votes
0 answers
108 views

Don't understand the number of levels of "Flatten" [duplicate]

I have a data data={{{-(1/2), -(3/2)}, {1/2, -(1/2)}, {3/2, 1/ 2}}, {{-(3/2), -(5/2)}, {-(1/2), -(3/2)}, {1/2, -(1/2)}, {3/2, 1/ 2}, {5/2, 3/2}}} I want to ...
我心永恒's user avatar
  • 1,572
21 votes
14 answers
811 views

How to neatly get the sum of symmetric elements in a list?

The task is to compute symmSum[{a, b, c, d, e, f}] (*==> {a+f, b+e, c+d} *) symmSum[{a, b, c, d, e}] (*==> {a+e, b+d, c} *) My clumsy solution is ...
faleichik's user avatar
  • 12.7k
27 votes
7 answers
3k views

Equating matrices (or higher order tensors) element-wise

Say I have two matrices (or, as in my case, higher order tensors) $A,B$, and I want to solve the equation $A=B$. To do so , I need a list of equations that equate entry-wise the elements of $A$ and $B$...
yohbs's user avatar
  • 7,046
13 votes
9 answers
1k views

Prepend 0 to sublists

My question is similar to this one, but my goal is to prepend a single 0 the each sublist, not incrementally many 0's. The file I'm working is a CSV containing around 50K sublists of length 35. I've ...
CHM's user avatar
  • 3,415
18 votes
5 answers
5k views

Ways to compute inner products of tensors

One way to evaluate the following sums is combining Table and Sum: $u_{abcd} = \sum_{e=1}^3 v_{aeb}w_{ced}$ $q_{ab} = \sum_{d,e=1}^3 v_{d e a}w_{deb}$ It will look like ...
sjdh's user avatar
  • 7,777
32 votes
6 answers
11k views

Best way to create symmetric matrices

From time to time I need to generate symmetric matrices with relatively expensive cost of element evaluation. Most frequently these are Gram matrices where elements are $L_2$ dot products. Here are ...
faleichik's user avatar
  • 12.7k
36 votes
2 answers
3k views

Transpose uneven lists

Is there a quick method to transpose uneven lists without conditionals? With: Drop[Table[q, {10}], #] & /@ Range[10] Thus the first list would have the ...
Mr. Demetrius Michael's user avatar
8 votes
7 answers
794 views

How to create a matrix of paired values from two matrices?

I have two matrices. They are, m1={{a,b},{c,d}}; m2={{w,x},{y,z}}; I want to create a matrix of paired values that looks like this, ...
desla.slade's user avatar
7 votes
6 answers
992 views

How can I apply a function only to even-index elements of a list?

A = {1, 2, 3, 4, 5} and, Dd[P_] := P + 1 How can I map "Dd" into "A" such that the outcome is: {1, 3, 3, 5, ...
Ito's user avatar
  • 71
10 votes
7 answers
569 views

How can I "mix" the elements of two lists?

Is there a function in Mathematica that allows me to combine two different lists if the elements in the same position are equal? For example, imagine I have these lists: ...
Ardust's user avatar
  • 103
5 votes
9 answers
422 views

Joining two lists with Transpose and with an offset

I have two lists of the same length n. For the case of n=5, these would be: ...
Karl Easterly's user avatar
13 votes
2 answers
6k views

How to get MATLAB data imported with the same dimensions?

I have some MATLAB image data with the following dimensions (output is from MATLAB): >> size(im) ans = 86 86 3 45 The data imports just fine ...
shanusmagnus's user avatar
  • 1,159
12 votes
3 answers
675 views

Most efficient way to build block / banded SparseArray

I have a matrix that I generate with a procedure that looks like this: ...
b3m2a1's user avatar
  • 46.9k

15 30 50 per page