"Defined as Algorithm 2 in the paper. It's needed since it's called by Algorithm 4"
]
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 18,
"execution_count": null,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"# review the restarted GMRES method (hereafter referred to as GMRES in short), which is a nonsymmetric Krylov subspace solver based on the Arnoldi decomposition procedure\n",
"def Arnoldi(A,v0,m):\n",
"\n",
"# return the matrix V, the matrix Hp, the vector v, the scalar beta and the number of iterations j. Where V is a matrix of dimension n x m, Hp is an upper Hessenberg matrix of dimension (m+1) x m. Return also the m+1 vector of the basis V. Return h as the m+1,m element of Hp and the vector v as the m+1 element of the basis V.\n",
"\n",
"\n",
"def ArnoldiGMRES(A,v0,m):\n",
" v = v0\n",
" v = v0\n",
" beta = norm(v)\n",
" beta = norm(v)\n",
" v = v/beta\n",
" v = v/beta\n",
@ -129,52 +131,26 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"m = 100\n",
"m = 100\n",
"n = 110\n",
"n = 110\n",
"A = sp.sparse.rand(n,n, density=0.1, format='lil')\n",
"A = sp.sparse.rand(n,n, density=0.1, format='lil')\n",