Module: CAMath
- Includes:
- GSL::CONST::MKSA, GSL::CONST::NUM
- Defined in:
- lib/carray-gsl/core.rb
Class Method Summary collapse
- .cholesky_solve(c, b) ⇒ Object
- .coupling_9j(*argv) ⇒ Object
- .graph(*args) ⇒ Object
- .lu_solve(lu, b) ⇒ Object
- .qr_solve(qr, b) ⇒ Object
- .stats_correlation(v1, v2) ⇒ Object
- .stats_covariance(v1, v2) ⇒ Object
- .stats_covariance_m(v1, v2, mean1, mean2) ⇒ Object
- .sv_solve(u, v, s, b) ⇒ Object
Class Method Details
.cholesky_solve(c, b) ⇒ Object
610 611 612 613 614 615 |
# File 'lib/carray-gsl/core.rb', line 610 def cholesky_solve (c, b) CArray.attach(c, b) { cholesky = c["@cholesky"] return GSL::Linalg::Cholesky.solve(cholesky, b.gv).ca.v } end |
.coupling_9j(*argv) ⇒ Object
585 586 587 |
# File 'lib/carray-gsl/core.rb', line 585 def coupling_9j (*argv) return GSL.Sf.coupling_9j(*argv) end |
.graph(*args) ⇒ Object
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 |
# File 'lib/carray-gsl/core.rb', line 635 def graph (*args) if args.last.is_a?(String) = args.pop else = nil end args.map! do |arg| case arg when CArray arg.to_gv when Array arg.map{|a| a.is_a?(CArray) ? a.to_gv : a } else arg end end return GSL.graph(*args) end |
.lu_solve(lu, b) ⇒ Object
589 590 591 592 593 594 |
# File 'lib/carray-gsl/core.rb', line 589 def lu_solve (lu, b) CArray.attach(lu, b) { perm = lu["@perm"] return GSL::Linalg::LU.solve(lu.gm, perm, b.gv).ca.v } end |
.qr_solve(qr, b) ⇒ Object
596 597 598 599 600 601 602 |
# File 'lib/carray-gsl/core.rb', line 596 def qr_solve (qr, b) CArray.attach(qr, b) { qrm = qr["@qr"] tau = qr["@tau"] return GSL::Linalg::QR.solve(qrm, tau, b.gv).ca.v } end |
.stats_correlation(v1, v2) ⇒ Object
629 630 631 632 633 |
# File 'lib/carray-gsl/core.rb', line 629 def stats_correlation (v1, v2) CArray.attach(v1, v2) { return GSL::Stats.correlation(v1.gv, v2.gv) } end |
.stats_covariance(v1, v2) ⇒ Object
617 618 619 620 621 |
# File 'lib/carray-gsl/core.rb', line 617 def stats_covariance (v1, v2) CArray.attach(v1, v2) { return GSL::Stats.covariance(v1.gv, v2.gv) } end |
.stats_covariance_m(v1, v2, mean1, mean2) ⇒ Object
623 624 625 626 627 |
# File 'lib/carray-gsl/core.rb', line 623 def stats_covariance_m (v1, v2, mean1, mean2) CArray.attach(v1, v2) { return GSL::Stats.covariance_m(v1.gv, v2.gv, mean1, mean2) } end |
.sv_solve(u, v, s, b) ⇒ Object
604 605 606 607 608 |
# File 'lib/carray-gsl/core.rb', line 604 def sv_solve (u, v, s, b) CArray.attach(u, v, s, b) { return GSL::Linalg::SV.solve(u.gm, v.gm, s.gv, b.gv).ca.v } end |