Tag Info

New answers tagged

0

SparseArray[{{i_, i_} :> 2, {i_, j_} :> -1 /; Abs[i - j] == 1}, {10, 10}] // MatrixForm or SparseArray[{Band[{1, 1}] -> 2, Band[{2, 1}] -> -1, Band[{1, 2}] -> -1}, {10, 10}] // MatrixForm


3

Here is a slightly compacted reformulation of belisarius's answer: a = Take[mat, 10, 10]; b = Take[mat, 10, -15]; c = Take[mat, -15, 10]; d = Take[mat, -15, -15]; rr = ArrayRules[d - c.SparseArray[LinearSolve[a, b]]]; detr = Det[SparseArray[rr /. (pos_ /; VectorQ[pos, IntegerQ] -> expr_) :> (pos -> C @@ pos), ...


8

You have shown that when the arrays are not sparse, using SparseArray is futile. Let's look at a case when it is sparse: MatSparse = SparseArray[{{1, 1} -> 1, {2000, 2} -> 2, {3, 3} -> 3, {1, 2000} -> 4}]; MatNormal = Normal[MatSparse]; multNormal = Timing[MatNormal.MatNormal]; multSparse = Timing[MatSparse.MatSparse]; Grid[{{"", "Normal", ...


16

Using the properties of Block matrices: $$\det\begin{pmatrix}\mathbf A&\mathbf B\\\mathbf C&\mathbf D\end{pmatrix}=\det(\mathbf A)\det\left(\mathbf D-\mathbf C\mathbf A^{-1}\mathbf B\right)$$ To visualize your matrix: mat1 = mat; {mat1[[;; 10, ;; 10]], mat1[[;; 10, 11 ;;]], mat1[[11 ;;, ;; 10]], mat1[[11 ;;, 11 ;;]]} = Range@4; (* cool :) *) ...



Top 50 recent answers are included