Tag Info

New answers tagged

0

Improving a bit on @Sjoerd C. de Vries comment, you use SlotSequence (##) to do the following: c = {x1, x2}; T = Array[t[##] @@ c &, {2, 2}] { {t[1, 1][x1, x2], t[1, 2][x1, x2]}, {t[2, 1][x1, x2], t[2, 2][x1, x2]} } Taking partial derivatives w.r.t. to one of the coordinates (just to name an example) then works as expected: D[T, x1]


4

Good question; the notion of a tensorial (covariant) derivative is something that is missing in Mathematica AFAIK. I can think of two ways to proceed: Option 1 One way is to overload the TensorRank, TensorDimensions, and TensorSymmetry functions for patterns that have head CD: CD /: TensorRank[CD[tensor_]] := TensorRank[tensor] + 1 CD /: ...


1

As @Artes mentions in his comment, this can be done with xAct, in particular with its xPert package. After installing it, we may load it with << xAct`xPert` We first need to set up some variables: (* Define a 4-dimensional manifold. *) DefManifold[M, 4, IndexRange[a, l]] (* Define a (Lorentzian) metric and its associated curvature tensors. *) ...


2

As far as I know there is no package that can do spinor computations in arbitrary dimensions. There is Gamma but that 'only' does gamma matrix computations. As for exterior forms, Mathematica 9 can do a bit of that: see e.g. TensorWedge and HodgeDual. You might also want to look at the xTerior package for xAct. Speaking of xAct, its author maintains a ...


2

An alternative approach is to use KroneckerProduct which does not require flattening. From the docs on TensorProduct: The KroneckerProduct of matrices is equivalent to the flattening of their TensorProduct to another matrix. That is, for any two matrices m1 and m2 KroneckerProduct[m1, m2] == ArrayFlatten[TensorProduct[m1, m2]] (* True *) So, m1 = ...


8

Depends on what dimension your final matrix is supposed to have. When I should make a guess, I would say you want this TensorProduct[IdentityMatrix[2], IdentityMatrix[2]] // ArrayFlatten


1

I think the following solution is easier to follow: Join @@ Table[ u[[j,k]] , {j, NLevel}, {k, j + 1, NLevel}] The Table part should be self-explanatory: it iterates through $a_{jk}$ for pairs $j < k$. However, it does not return a list of matrices. It returns a list of lists of matrices. These need to be joined together into a single list, which is ...


2

You can also use Part: NLevel = 3; P = Table[SparseArray[{{j, k} -> 1}, {NLevel, NLevel}], {j, NLevel}, {k, NLevel}]; P[[##]] & @@@ Subsets[Range@Length@P, {2}] // Normal (* {{{0, 1, 0}, {0, 0, 0}, {0, 0, 0}}, {{0, 0, 1}, {0, 0, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 0, 1}, {0, 0, 0}}} *) Instead of Subsets[Range@Length@P, {2}] we can also use ...


1

I believe this does what you want (using your u example without the MatrixForm formatting): Normal@Extract[#, Sort@Join[Array[{#, #} &, Length@#], Subsets[Range@Length@#, {2}]]] &[u] (* {{{2, 0, 0}, {0, 0, 0}, {0, 0, 0}}, {{0, 1, 0}, {1, 0, 0}, {0, 0, 0}}, {{0, 0, 1}, {0, 0, 0}, {1, 0, 0}}, {{0, 0, 0}, {0, 2, 0}, {0, 0, 0}}, {{0, 0, 0}, {0, 0, ...



Top 50 recent answers are included