/usr/lib/python2.7/dist-packages/pysparse/poisson.py is in python-sparse 1.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | import spmatrix
import numpy
def poisson1d(n):
L = spmatrix.ll_mat(n, n, 3*n-2)
for i in range(n):
L[i,i] = 2
if i > 0:
L[i,i-1] = -1
if i < n-1:
L[i,i+1] = -1
return L
def poisson1d_sym(n):
L = spmatrix.ll_mat_sym(n, 2*n-1)
for i in range(n):
L[i,i] = 2
if i > 0:
L[i,i-1] = -1
return L
def poisson2d(n):
n2 = n*n
L = spmatrix.ll_mat(n2, n2, 5*n2-4*n)
for i in range(n):
for j in range(n):
k = i + n*j
L[k,k] = 4
if i > 0:
L[k,k-1] = -1
if i < n-1:
L[k,k+1] = -1
if j > 0:
L[k,k-n] = -1
if j < n-1:
L[k,k+n] = -1
return L
def poisson2d_sym(n):
n2 = n*n
L = spmatrix.ll_mat_sym(n2, 3*n2-2*n)
for i in range(n):
for j in range(n):
k = i + n*j
L[k,k] = 4
if i > 0:
L[k,k-1] = -1
if j > 0:
L[k,k-n] = -1
return L
def poisson2d_sym_blk(n):
n2 = n*n
L = spmatrix.ll_mat_sym(n2, 3*n2-2*n)
I = spmatrix.ll_mat_sym(n, n)
for i in range(n):
I[i,i] = -1
P = spmatrix.ll_mat_sym(n, 2*n-1)
for i in range(n):
P[i,i] = 4
if i > 0:
P[i,i-1] = -1
for i in range(0, n*n, n):
L[i:i+n,i:i+n] = P
if i > 0: L[i:i+n,i-n:i] = I
return L
|