# Tag Info

3

I think for this kind of matrix it is better to use some of the dedicated matrix formats, like, "MTX" (of Matrix Market) or "HarwellBoeing". Below are two examples using "MTX": one with a dense 6000x6000 matrix and one with a sparse matrix. Dense matrix Mathematica mat = RandomReal[{0, 1}, {6000, 6000}]; Export["/path/RandomMat.mtx", mat, "MTX"] Python ...

3

SetDirectory[NotebookDirectory[]] (mat = RandomReal[1, {5, 5}]) // MatrixForm Export["mat.txt", mat, "CSV"] Open python and type >python Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 >>> f = open ( 'mat.txt' , 'r') >>> mat = [ map(float,line.split(',')) for line in f ] >>> print(mat) [[0....

3

Specify Eigensystem[h, 2, Method -> "Direct"] for both cases. That sparse array may go to a different solver (iterative) than the dense method. You can find more options in the documentation of Eigensystem under the options section.

3

Here is a way to do it: dim = 5; s = SparseArray[{{i_, i_} -> -2., {i_, j_} /; Abs[i - j] == 1 -> 1.}, {dim, dim}, 0.]; s[[1, All]] = s[[-1, All]] = 0.; s[[1, 1]] = s[[-1, -1]] = 1.; f = ConstantArray[0., {dim}]; f[[1]] = 0.; f[[-1]] = 1.; LinearSolve[s, f] {0., 0.25, 0.5, 0.75, 1.} Now, we can use: res = SparseArraySparseMatrixILU[s] ...

2

l = {{a, b}, {c, d}, {e, f}}; Flatten[MapIndexed[{#1, #2[[1]]} -> 1 &, l, {2}], 1] (*{{a, 1} -> 1, {b, 1} -> 1, {c, 2} -> 1, {d, 2} -> 1, {e, 3} -> 1, {f, 3} -> 1}*)

Top 50 recent answers are included