Tag Info

Hot answers tagged


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, ...


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 ...


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 ...


This is a bit long for a comment. You can use a tandem of LinearSolve and NullSpace. But for exact problems this will, I'm fairly sure, use dense matrices. That takes you back to what Solve is doing anyway, under the hood. Assuming your inputs are integer or rationals you might avoid dense matrix algebra as follows. Use numerical methods to find a single ...


Ok, I'll go ahead and answer my own question. After some thinking I came up with this: getIntersection[l1_, l2_] := Module[{n, ker, coeffs}, ker = NullSpace[Transpose[Join[l1,l2]]]; n = Length[l1]; coeffs = Map[Function[v, v[[1 ;; n]]], ker]; Return [Map[Function[v, v.l1], coeffs]]; ]; Can this be made any faster?


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 *)


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: ...

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