(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



Laplacian1D[n_]:= SparseArray[{Band[{1,1}]:>-2.0, Band[{1,2}]->1.0, Band[{2,1}]->1.0},{n,n}]


SparseDDominant[n_,nzr_]:= Module[
{A},
(*nzr is the number of non-zeroes per row.*)
A=SparseArray[Band[{1,1}]:> RandomChoice[{-1,1}]RandomReal[{1.1nzr,5 nzr}],{n,n}];
Do[
Do[
While[
j=RandomInteger[{1,n}];
A[[i,j]]!=0.0];
A[[i,j]]=RandomReal[{-1,1}],
{j,nzr}
],
{i,1,n}];
A
]



