source: trunk/anuga_work/development/carrier_greenspan/swap.py @ 8866

Last change on this file since 8866 was 8594, checked in by mungkasi, 12 years ago

Uploading the 1D Carrier-Greenspan test for 2D model.

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.