Tag Info

Hot answers tagged

6

You have to be a bit careful here; your last approach does not give the desired matrix F: (LinearSolve[dV, dv] // Transpose).dV === dv False Then what does give the correct output? We can use the fact that for generic matrices $A$ and $B$ we have $A.B = (B^T.A^T)^T$ and write F = Transpose @ LinearSolve[Transpose @ dV, Transpose @ dv] And indeed, ...


6

The order of eigenvalues is the most convenient order for the algorithm, which find these eigenvalues. You can always order them as you want very simply a = # + #\[Transpose] &@RandomReal[1, {10, 10}]; {ε, ψ} = Eigensystem[a]; {ε, ψ} = {ε[[#]], ψ[[#]]} &@ Ordering[ε]; Furthermore, the eigenvalues can be complex for non-Hermitian matrices. There is ...


5

Dense blocks One can split matrices by blocks and use these blocks as a dense matrices blockSize = 100; m1[a_] m2[b_] ^:= a.b; part = Developer`PartitionMap[If[Length@#@"NonzeroValues" > 0, m1@Normal@#, 0] &, a, {blockSize, blockSize}]; a2.u_ ^:= Flatten[Developer`ToPackedArray[ part.Developer`PartitionMap[m2, u, blockSize]], 1] I have ...


2

ClearAll[randomSymMat]; randomSymMat = Module[{mat = RandomVariate[#, {#2, #2}], upper, diag}, upper = UpperTriangularize[mat, 1]; diag = DiagonalMatrix[Diagonal@mat]; diag + upper + Transpose[upper]] &; dist = NormalDistribution[3, 5]; First[AbsoluteTiming[res = randomSymMat[dist, 1000]]] (* 0.065046 *) res == Transpose[res] (* True *)


2

As I mention in the linked answer, you can always translate the spectrum of the matrix by the Hilbert-Schmidt norm to be certain that Mathematica's ordering of the eigenvalues will coincide with the natural order on the real line. For a large matrix, this is more efficient that FindPermutations. Edit Here is an implementation of the shift approach: ...


1

expr = aaa - 3 bbb + ccc + ddd - eee expr /. _?Negative :> 0 (* aaa + ccc + ddd *)



Only top voted, non community-wiki answers of a minimum length are eligible