row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a...

27
1 1 -1 2 3 5 -7 0 2 -3 1 5 a row col k akk i aik j 3 4 0 - - - - def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Upload: dangcong

Post on 20-Apr-2019

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

3 5 -7 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 - - - -

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 2: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

3 5 -7 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 - - -

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 3: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

3 5 -7 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 3 - -

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 4: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

3 5 -7 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 0 - -

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 5: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

3 5 -7 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 0 - -

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 6: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

3 5 -7 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 1 - -

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 7: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

3 5 -7 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 1 3 -

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 8: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

3 5 -7 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 1 3 0

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 9: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 5 -7 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 1 3 0

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 10: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 2 -7 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 1 3 1

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 11: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 2 -4 0

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 1 3 2

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 12: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 2 -4 -6

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 1 3 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 13: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 2 -4 -6

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 2 3 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 14: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 2 -4 -6

2 -3 1 5

a

row col k akk i aik j

3 4 0 1 2 2 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 15: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 2 -4 -6

0 -5 3 1

a

row col k akk i aik j

3 4 0 1 2 2 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 16: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 2 -4 -6

0 -5 3 1

a

row col k akk i aik j

3 4 1 1 2 2 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 17: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 2 -4 -6

0 -5 3 1

a

row col k akk i aik j

3 4 1 2 2 2 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 18: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 1 -2 -3

0 -5 3 1

a

row col k akk i aik j

3 4 1 2 3 2 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 19: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 1 -2 -3

0 -5 3 1

a

row col k akk i aik j

3 4 1 2 0 2 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 20: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 1 -1 2

0 1 -2 -3

0 -5 3 1

a

row col k akk i aik j

3 4 1 2 0 1 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 21: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 0 1 5

0 1 -2 -3

0 -5 3 1

a

row col k akk i aik j

3 4 1 2 0 1 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 22: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 0 1 5

0 1 -2 -3

0 -5 3 1

a

row col k akk i aik j

3 4 1 2 1 1 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 23: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 0 1 5

0 1 -2 -3

0 -5 3 1

a

row col k akk i aik j

3 4 1 2 2 -5 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 24: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 0 1 5

0 1 -2 -3

0 0 -7 -14

a

row col k akk i aik j

3 4 1 2 2 -5 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 25: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 0 1 5

0 1 -2 -3

0 0 -7 -14

a

row col k akk i aik j

3 4 2 -7 2 -5 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 26: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 0 1 5

0 1 -2 -3

0 0 1 2

a

row col k akk i aik j

3 4 2 -7 3 -5 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end

Page 27: row col k akk i aik j 4 0 - lecture.ecc.u-tokyo.ac.jpshagiya/gj.pdf · row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row

1 0 0 3

0 1 0 1

0 0 1 2

a

row col k akk i aik j

3 4 2 -7 2 -5 3

def gj(a) row = a.length() col = a [0].length() for k in 0..(col-2) akk = a[k][k] for i in 0..(col-1) # normalize row k a[k][i]=a[k][i ]*1.0/akk end for i in 0..(row-1) # eliminate column k if i != k # of all rows but k aik = a[i][k] for j in k..(col-1) a[i][j] = a[i][j] - aik * a[k][j] end end end end a end