Sha256: 949ca37266b3649f0ccab032f4c0c4642a23b41d823385c560fdcb7d9b028ccf

Contents?: true

Size: 1.15 KB

Versions: 16

Compression:

Stored size: 1.15 KB

Contents

#!/usr/bin/env ruby
require("gsl")
include GSL
include Linalg

m = Matrix::alloc([0.18, 0.60, 0.57, 0.96], [0.41, 0.24, 0.99, 0.58],
		    [0.14, 0.30, 0.97, 0.66], [0.51, 0.13, 0.19, 0.85])
m.print

lu, perm = m.LU_decomp
m.print
lu.print

b = Vector[1, 2, 3, 4]
x = LU.solve(lu, perm, b)
x = LU.solve(lu, perm, b)
p x
p m

p m.LU_solve(b)
p m.LU_solve(perm, b)
p m.LU_solve(perm, b, x)
p lu.LU_solve(perm, b, x)

p x
LU.refine(m, lu, perm, b, x)
p x

#p b
#m.LU_svx(b)
#p b
#LU.svx(lu, perm, b)
#p b
#p m.LU_solve(perm, b)
#p m.LU_solve(perm, b, x)
#p lu.LU_solve(perm, b, x)

#exit

LU.svx(lu, perm, b)
p b

p m*x.col

b = [1, 2, 3, 4].to_gv
p LU.solve(m, b)

puts("")

m2 = Matrix.alloc([1, 2, 3, 6, 5, 4, 7, 8, 1], 3, 3)
m2.print
lu2, p2, sign = m2.LU_decomp

m3 = Matrix.alloc([1, 2, 3, 4, 5, 6, 7, 8, 0], 3, 3)
m3.print
lu, perm = m3.LU_decomp
LU.invert(lu, perm).print
p m3.class
p lu.class
m4 = m3.invert
LU.invert(m3).print
p m4.invert
p m3.invert.invert.invert

p m2.det
p lu2.det(p2, sign)
p m2.det(p2)

p LU.det(m2)

p LU.lndet(m2)
p LU.lndet(lu2)
p m2.lndet
p lu2.lndet

p LU.sgndet(m2)
p LU.sgndet(lu2, sign)
p m2.sgndet
p lu2.sgndet(sign)

p m
p m/b.col

__END__

Version data entries

16 entries across 16 versions & 4 rubygems

Version Path
rb-gsl-1.16.0.4 examples/linalg/LU.rb
rb-gsl-1.16.0.3 examples/linalg/LU.rb
rb-gsl-1.16.0.3.rc1 examples/linalg/LU.rb
gsl-nmatrix-1.15.3.2 examples/linalg/LU.rb
gsl-nmatrix-1.15.3.1 examples/linalg/LU.rb
rb-gsl-1.16.0.2 examples/linalg/LU.rb
rb-gsl-1.16.0.1 examples/linalg/LU.rb
rb-gsl-1.16.0 examples/linalg/LU.rb
rb-gsl-1.15.3.2 examples/linalg/LU.rb
rb-gsl-1.15.3.1 examples/linalg/LU.rb
blackwinter-gsl-1.15.3.2 examples/linalg/LU.rb
gsl-nmatrix-1.15.3.0 examples/linalg/LU.rb
gsl-1.15.3 examples/linalg/LU.rb
gsl-1.14.7 examples/linalg/LU.rb
gsl-1.14.6 examples/linalg/LU.rb
gsl-1.14.5 examples/linalg/LU.rb