source: trunk/anuga_work/development/2010-projects/anuga_1d/sww-sudi/swap.py @ 8427

Last change on this file since 8427 was 8427, checked in by davies, 13 years ago

Adding the trapezoidal channel validation test, and editing the ANUGA manual

File size: 575 bytes
Line 
1## module swap
2''' swapRows(v,i,j).
3    Swaps rows i and j of vector or matrix [v].
4
5    swapCols(v,i,j).
6    Swaps columns i and j of matrix [v].
7
8def swapRows(v,i,j):
9    if len(v.getshape()) == 1: v[i],v[j] = v[j],v[i]
10    else:
11        temp = v[i].copy()
12        v[i] = v[j]
13        v[j] = temp
14'''
15
16def swapRows(v,i,j):
17    if len(v.flat) == 2:
18        v[i],v[j] = v[j],v[i]
19    else:
20        temp = v[i].copy()
21        v[i] = v[j]
22        v[j] = temp     
23
24def swapCols(v,i,j):
25    temp = v[:,j].copy()
26    v[:,j] = v[:,i]
27    v[:,i] = temp
Note: See TracBrowser for help on using the repository browser.