File: plot_result

package info (click to toggle)
amgcl 1.4.4-1
  • links: PTS, VCS
  • area: contrib
  • in suites: sid
  • size: 5,676 kB
  • sloc: cpp: 34,043; python: 747; pascal: 258; f90: 196; makefile: 20
file content (41 lines) | stat: -rwxr-xr-x 805 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/python

import sys
import argparse
import numpy as np
from scipy.io import mmread
from pylab import *

parser = argparse.ArgumentParser(sys.argv[0])
parser.add_argument('-x,--solution', dest='x', default='x.mtx',         help='Solution vector')
parser.add_argument('-p,--part',     dest='p', default='partition.mtx', help='Partition vector')
args = parser.parse_args(sys.argv[1:])

x = mmread(args.x)
p = mmread(args.p)

n = x.shape[0]
x.shape = (n,)
p.shape = (n,)

i = np.arange(n)
j = np.array(sorted(i, key=lambda k: p[k]))

y = np.zeros(x.shape)
y[j] = x

m = int(np.sqrt(n));
y.shape = (m,m)

figure(num=1, figsize=(10,7))
subplot(1,2,1)
imshow(y, origin='lower')
colorbar()
title('solution')

subplot(1,2,2)
imshow(p.reshape((m,m)), origin='lower')
colorbar()
title('partition')

show()