Skip to content

Commit

Permalink
Added reordering tool to match Sprouts ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
repepo committed Aug 9, 2023
1 parent 82916fe commit ab2d97d
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tools/kore2sprouts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import sys
import scipy.sparse as ss
import scipy.io as sio

sys.path.insert(1,'bin/')
import utils as ut
import parameters as par




def main(Anpz):
'''
reshuffle kore matrices to match sprouts ordering
'''

A = ut.load_csr(str(Anpz))

N = par.N

ll = int(A.shape[0]/(4*N))

gb = np.array([4,2,2,2]) # the basis order for each section

N1 = N-gb # number of rows without bc's for each section

nbc = 2*np.sum(gb) # total number of bc rows

Aout = ss.dok_matrix(A.shape, dtype=complex)


for j in range(4): #loop over the four sections

for k in range(ll):

row0 = gb[j] + k*N + j*ll*N #initial row for kore

row1 = nbc + k*N1[j] + sum(ll*N1[:j]) #initial row for sprouts

Aout[ row1 : row1 + N1[j], : ] = A[ row0 : row0 + N1[j], : ]

sio.mmwrite('out.mtx', Aout)


return 0


if __name__ == '__main__':
import sys
sys.exit(main(sys.argv[1]))

0 comments on commit ab2d97d

Please sign in to comment.