numo-linalg-alt 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/README.md +83 -5
- data/ext/numo/linalg/blas/blas_common.h +30 -0
- data/ext/numo/linalg/blas/blas_util.c +39 -0
- data/ext/numo/linalg/blas/blas_util.h +11 -0
- data/ext/numo/linalg/{converter.h → blas/converter.h} +0 -2
- data/ext/numo/linalg/blas/dot.c +1 -1
- data/ext/numo/linalg/blas/dot.h +1 -6
- data/ext/numo/linalg/blas/dot_sub.c +1 -1
- data/ext/numo/linalg/blas/dot_sub.h +1 -6
- data/ext/numo/linalg/blas/gemm.c +21 -21
- data/ext/numo/linalg/blas/gemm.h +3 -9
- data/ext/numo/linalg/blas/gemv.c +10 -10
- data/ext/numo/linalg/blas/gemv.h +3 -9
- data/ext/numo/linalg/blas/nrm2.c +1 -1
- data/ext/numo/linalg/blas/nrm2.h +1 -6
- data/ext/numo/linalg/extconf.rb +34 -6
- data/ext/numo/linalg/lapack/gebal.h +1 -1
- data/ext/numo/linalg/lapack/gees.c +4 -4
- data/ext/numo/linalg/lapack/gees.h +1 -1
- data/ext/numo/linalg/lapack/geev.c +8 -24
- data/ext/numo/linalg/lapack/geev.h +1 -1
- data/ext/numo/linalg/lapack/gehrd.c +77 -0
- data/ext/numo/linalg/lapack/gehrd.h +15 -0
- data/ext/numo/linalg/lapack/gelsd.h +1 -1
- data/ext/numo/linalg/lapack/geqrf.h +1 -1
- data/ext/numo/linalg/lapack/gerqf.h +1 -1
- data/ext/numo/linalg/lapack/gesdd.h +1 -1
- data/ext/numo/linalg/lapack/gesv.h +1 -1
- data/ext/numo/linalg/lapack/gesvd.h +1 -1
- data/ext/numo/linalg/lapack/getrf.h +1 -1
- data/ext/numo/linalg/lapack/getri.h +1 -1
- data/ext/numo/linalg/lapack/getrs.h +1 -1
- data/ext/numo/linalg/lapack/gges.c +4 -4
- data/ext/numo/linalg/lapack/gges.h +1 -1
- data/ext/numo/linalg/lapack/heev.c +1 -1
- data/ext/numo/linalg/lapack/heev.h +1 -1
- data/ext/numo/linalg/lapack/heevd.c +1 -1
- data/ext/numo/linalg/lapack/heevd.h +1 -1
- data/ext/numo/linalg/lapack/heevr.c +1 -1
- data/ext/numo/linalg/lapack/heevr.h +1 -1
- data/ext/numo/linalg/lapack/hegv.c +1 -1
- data/ext/numo/linalg/lapack/hegv.h +1 -1
- data/ext/numo/linalg/lapack/hegvd.c +1 -1
- data/ext/numo/linalg/lapack/hegvd.h +1 -1
- data/ext/numo/linalg/lapack/hegvx.c +1 -1
- data/ext/numo/linalg/lapack/hegvx.h +1 -1
- data/ext/numo/linalg/lapack/hetrf.h +1 -1
- data/ext/numo/linalg/lapack/lange.c +7 -8
- data/ext/numo/linalg/lapack/lange.h +1 -1
- data/ext/numo/linalg/lapack/lapack_util.c +57 -0
- data/ext/numo/linalg/lapack/lapack_util.h +27 -0
- data/ext/numo/linalg/lapack/orghr.c +82 -0
- data/ext/numo/linalg/lapack/orghr.h +15 -0
- data/ext/numo/linalg/lapack/orgqr.h +1 -1
- data/ext/numo/linalg/lapack/orgrq.h +1 -1
- data/ext/numo/linalg/lapack/potrf.h +1 -1
- data/ext/numo/linalg/lapack/potri.h +1 -1
- data/ext/numo/linalg/lapack/potrs.h +1 -1
- data/ext/numo/linalg/lapack/syev.c +1 -1
- data/ext/numo/linalg/lapack/syev.h +1 -1
- data/ext/numo/linalg/lapack/syevd.c +1 -1
- data/ext/numo/linalg/lapack/syevd.h +1 -1
- data/ext/numo/linalg/lapack/syevr.c +1 -1
- data/ext/numo/linalg/lapack/syevr.h +1 -1
- data/ext/numo/linalg/lapack/sygv.c +1 -1
- data/ext/numo/linalg/lapack/sygv.h +1 -1
- data/ext/numo/linalg/lapack/sygvd.c +1 -1
- data/ext/numo/linalg/lapack/sygvd.h +1 -1
- data/ext/numo/linalg/lapack/sygvx.c +1 -1
- data/ext/numo/linalg/lapack/sygvx.h +1 -1
- data/ext/numo/linalg/lapack/sytrf.h +1 -1
- data/ext/numo/linalg/lapack/trtrs.h +1 -1
- data/ext/numo/linalg/lapack/unghr.c +82 -0
- data/ext/numo/linalg/lapack/unghr.h +15 -0
- data/ext/numo/linalg/lapack/ungqr.h +1 -1
- data/ext/numo/linalg/lapack/ungrq.h +1 -1
- data/ext/numo/linalg/linalg.c +5 -0
- data/ext/numo/linalg/linalg.h +17 -6
- data/lib/numo/linalg/version.rb +1 -1
- data/lib/numo/linalg.rb +160 -20
- metadata +15 -6
- data/ext/numo/linalg/util.c +0 -103
- data/ext/numo/linalg/util.h +0 -18
- /data/ext/numo/linalg/{converter.c → blas/converter.c} +0 -0
data/lib/numo/linalg.rb
CHANGED
|
@@ -340,7 +340,9 @@ module Numo
|
|
|
340
340
|
raise ArgumentError, "invalid array type: #{a.class}" if bchr == 'n'
|
|
341
341
|
|
|
342
342
|
fnc = :"#{bchr}potrs"
|
|
343
|
-
x,
|
|
343
|
+
x, info = Numo::Linalg::Lapack.send(fnc, a, b.dup, uplo: uplo)
|
|
344
|
+
raise "the #{-info}-th argument of potrs had illegal value" if info.negative?
|
|
345
|
+
|
|
344
346
|
x
|
|
345
347
|
end
|
|
346
348
|
|
|
@@ -364,17 +366,13 @@ module Numo
|
|
|
364
366
|
|
|
365
367
|
getrf = :"#{bchr}getrf"
|
|
366
368
|
lu, piv, info = Numo::Linalg::Lapack.send(getrf, a.dup)
|
|
369
|
+
raise "the #{-info}-th argument of getrf had illegal value" if info.negative?
|
|
370
|
+
raise 'the factor U is singular, and the inverse matrix could not be computed.' if info.positive?
|
|
367
371
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
det_l * det_u * det_p
|
|
373
|
-
elsif info.positive?
|
|
374
|
-
raise 'the factor U is singular, and the inverse matrix could not be computed.'
|
|
375
|
-
else
|
|
376
|
-
raise "the #{-info}-th argument of getrf had illegal value"
|
|
377
|
-
end
|
|
372
|
+
det_l = 1
|
|
373
|
+
det_u = lu.diagonal.prod
|
|
374
|
+
det_p = piv.map_with_index { |v, i| v == i + 1 ? 1 : -1 }.prod
|
|
375
|
+
det_l * det_u * det_p
|
|
378
376
|
end
|
|
379
377
|
|
|
380
378
|
# Computes the inverse matrix of a square matrix.
|
|
@@ -407,13 +405,14 @@ module Numo
|
|
|
407
405
|
getri = :"#{bchr}getri"
|
|
408
406
|
|
|
409
407
|
lu, piv, info = Numo::Linalg::Lapack.send(getrf, a.dup)
|
|
410
|
-
if info.
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
408
|
+
raise "the #{-info}-th argument of getrf had illegal value" if info.negative?
|
|
409
|
+
raise 'the factor U is singular, and the inverse matrix could not be computed.' if info.positive?
|
|
410
|
+
|
|
411
|
+
a_inv, info = Numo::Linalg::Lapack.send(getri, lu, piv)
|
|
412
|
+
raise "the #{-info}-th argument of getrf had illegal value" if info.negative?
|
|
413
|
+
raise 'the factor U is singular, and the inverse matrix could not be computed.' if info.positive?
|
|
414
|
+
|
|
415
|
+
a_inv
|
|
417
416
|
end
|
|
418
417
|
|
|
419
418
|
# Computes the (Moore-Penrose) pseudo-inverse of a matrix using singular value decomposition.
|
|
@@ -441,7 +440,7 @@ module Numo
|
|
|
441
440
|
rank = s.gt(rcond * s[0]).count
|
|
442
441
|
|
|
443
442
|
u = u[true, 0...rank] / s[0...rank]
|
|
444
|
-
u.dot(vh[0...rank, true]).conj.transpose
|
|
443
|
+
u.dot(vh[0...rank, true]).conj.transpose.dup
|
|
445
444
|
end
|
|
446
445
|
|
|
447
446
|
# Computes the polar decomposition of a matrix.
|
|
@@ -740,6 +739,63 @@ module Numo
|
|
|
740
739
|
[b, v, sdim]
|
|
741
740
|
end
|
|
742
741
|
|
|
742
|
+
# Computes the Hessenberg decomposition of a square matrix.
|
|
743
|
+
# The Hessenberg decomposition is given by `A = Q * H * Q^H`,
|
|
744
|
+
# where `A` is the input matrix, `Q` is a unitary matrix,
|
|
745
|
+
# and `H` is an upper Hessenberg matrix.
|
|
746
|
+
#
|
|
747
|
+
# @example
|
|
748
|
+
# require 'numo/linalg'
|
|
749
|
+
#
|
|
750
|
+
# a = Numo::DFloat[[1, 2, 3], [4, 5, 6], [7, 8, 9]] * 0.5
|
|
751
|
+
# h, q = Numo::Linalg.hessenberg(a, calc_q: true)
|
|
752
|
+
#
|
|
753
|
+
# pp h
|
|
754
|
+
# # => Numo::DFloat#shape=[3,3]
|
|
755
|
+
# # [[0.5, -1.7985, -0.124035],
|
|
756
|
+
# # [-4.03113, 7.02308, 1.41538],
|
|
757
|
+
# # [0, 0.415385, -0.0230769]]
|
|
758
|
+
# pp q
|
|
759
|
+
# # => Numo::DFloat#shape=[3,3]
|
|
760
|
+
# # [[1, 0, 0],
|
|
761
|
+
# # [0, -0.496139, -0.868243],
|
|
762
|
+
# # [0, -0.868243, 0.496139]]
|
|
763
|
+
# pp (a - q.dot(h).dot(q.transpose)).abs.max
|
|
764
|
+
# # => 1.7763568394002505e-15
|
|
765
|
+
#
|
|
766
|
+
# @param a [Numo::NArray] The n-by-n square matrix.
|
|
767
|
+
# @param calc_q [Boolean] The flag indicating whether to calculate the unitary matrix `Q`.
|
|
768
|
+
# @return [Numo::NArray] if calc_q=false, the Hessenberg form `H`.
|
|
769
|
+
# @return [Array<Numo::NArray, Numo::NArray>] if calc_q=true,
|
|
770
|
+
# the Hessenberg form `H` and the unitary matrix `Q`.
|
|
771
|
+
def hessenberg(a, calc_q: false)
|
|
772
|
+
raise Numo::NArray::ShapeError, 'input array a must be 2-dimensional' if a.ndim != 2
|
|
773
|
+
raise Numo::NArray::ShapeError, 'input array a must be square' if a.shape[0] != a.shape[1]
|
|
774
|
+
|
|
775
|
+
bchr = blas_char(a)
|
|
776
|
+
raise ArgumentError, "invalid array type: #{a.class}" if bchr == 'n'
|
|
777
|
+
|
|
778
|
+
func = :"#{bchr}gebal"
|
|
779
|
+
b, ilo, ihi, _, info = Numo::Linalg::Lapack.send(func, a.dup)
|
|
780
|
+
|
|
781
|
+
raise "the #{-info}-th argument of #{func} had illegal value" if info.negative?
|
|
782
|
+
|
|
783
|
+
func = :"#{bchr}gehrd"
|
|
784
|
+
hq, tau, info = Numo::Linalg::Lapack.send(func, b, ilo: ilo, ihi: ihi)
|
|
785
|
+
|
|
786
|
+
raise "the #{-info}-th argument of #{func} had illegal value" if info.negative?
|
|
787
|
+
|
|
788
|
+
h = hq.triu(-1)
|
|
789
|
+
return h unless calc_q
|
|
790
|
+
|
|
791
|
+
func = %w[d s].include?(bchr) ? :"#{bchr}orghr" : :"#{bchr}unghr"
|
|
792
|
+
q, info = Numo::Linalg::Lapack.send(func, hq, tau, ilo: ilo, ihi: ihi)
|
|
793
|
+
|
|
794
|
+
raise "the #{-info}-th argument of #{func} had illegal value" if info.negative?
|
|
795
|
+
|
|
796
|
+
[h, q]
|
|
797
|
+
end
|
|
798
|
+
|
|
743
799
|
# Solves linear equation `A * x = b` or `A * X = B` for `x` from square matrix `A`.
|
|
744
800
|
#
|
|
745
801
|
# @example
|
|
@@ -773,7 +829,11 @@ module Numo
|
|
|
773
829
|
raise ArgumentError, "invalid array type: #{a.class}, #{b.class}" if bchr == 'n'
|
|
774
830
|
|
|
775
831
|
gesv = :"#{bchr}gesv"
|
|
776
|
-
Numo::Linalg::Lapack.send(gesv, a.dup, b.dup)
|
|
832
|
+
_lu, x, _ipiv, info = Numo::Linalg::Lapack.send(gesv, a.dup, b.dup)
|
|
833
|
+
raise "the #{-info}-th argument of getrf had illegal value" if info.negative?
|
|
834
|
+
raise 'the factor U is singular, and the solution could not be computed.' if info.positive?
|
|
835
|
+
|
|
836
|
+
x
|
|
777
837
|
end
|
|
778
838
|
|
|
779
839
|
# Solves linear equation `A * x = b` or `A * X = B` for `x` assuming `A` is a triangular matrix.
|
|
@@ -1559,6 +1619,22 @@ module Numo
|
|
|
1559
1619
|
a_expm
|
|
1560
1620
|
end
|
|
1561
1621
|
|
|
1622
|
+
# Computes the matrix logarithm using its eigenvalue decomposition.
|
|
1623
|
+
#
|
|
1624
|
+
# @param a [Numo::NArray] The n-by-n square matrix.
|
|
1625
|
+
# @return [Numo::NArray] The matrix logarithm of `a`.
|
|
1626
|
+
def logm(a)
|
|
1627
|
+
raise Numo::NArray::ShapeError, 'input array a must be 2-dimensional' if a.ndim != 2
|
|
1628
|
+
raise Numo::NArray::ShapeError, 'input array a must be square' if a.shape[0] != a.shape[1]
|
|
1629
|
+
|
|
1630
|
+
ev, vl, = eig(a, left: true, right: false)
|
|
1631
|
+
v = vl.transpose.conj
|
|
1632
|
+
inv_v = Numo::Linalg.inv(v)
|
|
1633
|
+
log_ev = Numo::NMath.log(ev)
|
|
1634
|
+
|
|
1635
|
+
inv_v.dot(log_ev.diag).dot(v)
|
|
1636
|
+
end
|
|
1637
|
+
|
|
1562
1638
|
# Computes the matrix sine using the matrix exponential.
|
|
1563
1639
|
#
|
|
1564
1640
|
# @param a [Numo::NArray] The n-by-n square matrix.
|
|
@@ -1613,6 +1689,70 @@ module Numo
|
|
|
1613
1689
|
a_sin.dot(Numo::Linalg.inv(a_cos))
|
|
1614
1690
|
end
|
|
1615
1691
|
|
|
1692
|
+
# Computes the matrix hyperbolic sine using the matrix exponential.
|
|
1693
|
+
#
|
|
1694
|
+
# @param a [Numo::NArray] The n-by-n square matrix.
|
|
1695
|
+
# @return [Numo::NArray] The matrix hyperbolic sine of `a`.
|
|
1696
|
+
def sinhm(a)
|
|
1697
|
+
raise Numo::NArray::ShapeError, 'input array a must be 2-dimensional' if a.ndim != 2
|
|
1698
|
+
raise Numo::NArray::ShapeError, 'input array a must be square' if a.shape[0] != a.shape[1]
|
|
1699
|
+
|
|
1700
|
+
0.5 * (expm(a) - expm(-a))
|
|
1701
|
+
end
|
|
1702
|
+
|
|
1703
|
+
# Computes the matrix hyperbolic cosine using the matrix exponential.
|
|
1704
|
+
#
|
|
1705
|
+
# @param a [Numo::NArray] The n-by-n square matrix.
|
|
1706
|
+
# @return [Numo::NArray] The matrix hyperbolic cosine of `a`.
|
|
1707
|
+
def coshm(a)
|
|
1708
|
+
raise Numo::NArray::ShapeError, 'input array a must be 2-dimensional' if a.ndim != 2
|
|
1709
|
+
raise Numo::NArray::ShapeError, 'input array a must be square' if a.shape[0] != a.shape[1]
|
|
1710
|
+
|
|
1711
|
+
0.5 * (expm(a) + expm(-a))
|
|
1712
|
+
end
|
|
1713
|
+
|
|
1714
|
+
# Computes the matrix hyperbolic tangent.
|
|
1715
|
+
#
|
|
1716
|
+
# @param a [Numo::NArray] The n-by-n square matrix.
|
|
1717
|
+
# @return [Numo::NArray] The matrix hyperbolic tangent of `a`.
|
|
1718
|
+
def tanhm(a)
|
|
1719
|
+
raise Numo::NArray::ShapeError, 'input array a must be 2-dimensional' if a.ndim != 2
|
|
1720
|
+
raise Numo::NArray::ShapeError, 'input array a must be square' if a.shape[0] != a.shape[1]
|
|
1721
|
+
|
|
1722
|
+
a_sinh = sinhm(a)
|
|
1723
|
+
a_cosh = coshm(a)
|
|
1724
|
+
a_sinh.dot(Numo::Linalg.inv(a_cosh))
|
|
1725
|
+
end
|
|
1726
|
+
|
|
1727
|
+
# Computes the square root of a matrix using its eigenvalue decomposition.
|
|
1728
|
+
#
|
|
1729
|
+
# @param a [Numo::NArray] The n-by-n square matrix.
|
|
1730
|
+
# @return [Numo::NArray] The matrix square root of `a`.
|
|
1731
|
+
def sqrtm(a)
|
|
1732
|
+
raise Numo::NArray::ShapeError, 'input array a must be 2-dimensional' if a.ndim != 2
|
|
1733
|
+
raise Numo::NArray::ShapeError, 'input array a must be square' if a.shape[0] != a.shape[1]
|
|
1734
|
+
|
|
1735
|
+
ev, vl, = eig(a, left: true, right: false)
|
|
1736
|
+
v = vl.transpose.conj
|
|
1737
|
+
inv_v = Numo::Linalg.inv(v)
|
|
1738
|
+
sqrt_ev = Numo::NMath.sqrt(ev)
|
|
1739
|
+
|
|
1740
|
+
inv_v.dot(sqrt_ev.diag).dot(v)
|
|
1741
|
+
end
|
|
1742
|
+
|
|
1743
|
+
# Computes the matrix sign function using its inverse and square root matrices.
|
|
1744
|
+
#
|
|
1745
|
+
# @param a [Numo::NArray] The n-by-n square matrix.
|
|
1746
|
+
# @return [Numo::NArray] The matrix sign function of `a`.
|
|
1747
|
+
def signm(a)
|
|
1748
|
+
raise Numo::NArray::ShapeError, 'input array a must be 2-dimensional' if a.ndim != 2
|
|
1749
|
+
raise Numo::NArray::ShapeError, 'input array a must be square' if a.shape[0] != a.shape[1]
|
|
1750
|
+
|
|
1751
|
+
a_sqrt = sqrtm(a.dot(a))
|
|
1752
|
+
a_inv = Numo::Linalg.inv(a)
|
|
1753
|
+
a_inv.dot(a_sqrt)
|
|
1754
|
+
end
|
|
1755
|
+
|
|
1616
1756
|
# Computes the inverse of a matrix using its LU decomposition.
|
|
1617
1757
|
#
|
|
1618
1758
|
# @param lu [Numo::NArray] The LU decomposition of the n-by-n matrix `A`.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: numo-linalg-alt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yoshoku
|
|
@@ -37,6 +37,11 @@ files:
|
|
|
37
37
|
- CODE_OF_CONDUCT.md
|
|
38
38
|
- LICENSE.txt
|
|
39
39
|
- README.md
|
|
40
|
+
- ext/numo/linalg/blas/blas_common.h
|
|
41
|
+
- ext/numo/linalg/blas/blas_util.c
|
|
42
|
+
- ext/numo/linalg/blas/blas_util.h
|
|
43
|
+
- ext/numo/linalg/blas/converter.c
|
|
44
|
+
- ext/numo/linalg/blas/converter.h
|
|
40
45
|
- ext/numo/linalg/blas/dot.c
|
|
41
46
|
- ext/numo/linalg/blas/dot.h
|
|
42
47
|
- ext/numo/linalg/blas/dot_sub.c
|
|
@@ -47,8 +52,6 @@ files:
|
|
|
47
52
|
- ext/numo/linalg/blas/gemv.h
|
|
48
53
|
- ext/numo/linalg/blas/nrm2.c
|
|
49
54
|
- ext/numo/linalg/blas/nrm2.h
|
|
50
|
-
- ext/numo/linalg/converter.c
|
|
51
|
-
- ext/numo/linalg/converter.h
|
|
52
55
|
- ext/numo/linalg/extconf.rb
|
|
53
56
|
- ext/numo/linalg/lapack/gebal.c
|
|
54
57
|
- ext/numo/linalg/lapack/gebal.h
|
|
@@ -56,6 +59,8 @@ files:
|
|
|
56
59
|
- ext/numo/linalg/lapack/gees.h
|
|
57
60
|
- ext/numo/linalg/lapack/geev.c
|
|
58
61
|
- ext/numo/linalg/lapack/geev.h
|
|
62
|
+
- ext/numo/linalg/lapack/gehrd.c
|
|
63
|
+
- ext/numo/linalg/lapack/gehrd.h
|
|
59
64
|
- ext/numo/linalg/lapack/gelsd.c
|
|
60
65
|
- ext/numo/linalg/lapack/gelsd.h
|
|
61
66
|
- ext/numo/linalg/lapack/geqrf.c
|
|
@@ -92,6 +97,10 @@ files:
|
|
|
92
97
|
- ext/numo/linalg/lapack/hetrf.h
|
|
93
98
|
- ext/numo/linalg/lapack/lange.c
|
|
94
99
|
- ext/numo/linalg/lapack/lange.h
|
|
100
|
+
- ext/numo/linalg/lapack/lapack_util.c
|
|
101
|
+
- ext/numo/linalg/lapack/lapack_util.h
|
|
102
|
+
- ext/numo/linalg/lapack/orghr.c
|
|
103
|
+
- ext/numo/linalg/lapack/orghr.h
|
|
95
104
|
- ext/numo/linalg/lapack/orgqr.c
|
|
96
105
|
- ext/numo/linalg/lapack/orgqr.h
|
|
97
106
|
- ext/numo/linalg/lapack/orgrq.c
|
|
@@ -118,14 +127,14 @@ files:
|
|
|
118
127
|
- ext/numo/linalg/lapack/sytrf.h
|
|
119
128
|
- ext/numo/linalg/lapack/trtrs.c
|
|
120
129
|
- ext/numo/linalg/lapack/trtrs.h
|
|
130
|
+
- ext/numo/linalg/lapack/unghr.c
|
|
131
|
+
- ext/numo/linalg/lapack/unghr.h
|
|
121
132
|
- ext/numo/linalg/lapack/ungqr.c
|
|
122
133
|
- ext/numo/linalg/lapack/ungqr.h
|
|
123
134
|
- ext/numo/linalg/lapack/ungrq.c
|
|
124
135
|
- ext/numo/linalg/lapack/ungrq.h
|
|
125
136
|
- ext/numo/linalg/linalg.c
|
|
126
137
|
- ext/numo/linalg/linalg.h
|
|
127
|
-
- ext/numo/linalg/util.c
|
|
128
|
-
- ext/numo/linalg/util.h
|
|
129
138
|
- lib/numo/linalg.rb
|
|
130
139
|
- lib/numo/linalg/version.rb
|
|
131
140
|
- vendor/tmp/.gitkeep
|
|
@@ -136,7 +145,7 @@ metadata:
|
|
|
136
145
|
homepage_uri: https://github.com/yoshoku/numo-linalg-alt
|
|
137
146
|
source_code_uri: https://github.com/yoshoku/numo-linalg-alt
|
|
138
147
|
changelog_uri: https://github.com/yoshoku/numo-linalg-alt/blob/main/CHANGELOG.md
|
|
139
|
-
documentation_uri: https://gemdocs.org/gems/numo-linalg-alt/0.
|
|
148
|
+
documentation_uri: https://gemdocs.org/gems/numo-linalg-alt/0.6.0/
|
|
140
149
|
rubygems_mfa_required: 'true'
|
|
141
150
|
rdoc_options: []
|
|
142
151
|
require_paths:
|
data/ext/numo/linalg/util.c
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
#include "util.h"
|
|
2
|
-
|
|
3
|
-
lapack_int get_itype(VALUE val) {
|
|
4
|
-
const lapack_int itype = NUM2INT(val);
|
|
5
|
-
|
|
6
|
-
if (itype != 1 && itype != 2 && itype != 3) {
|
|
7
|
-
rb_raise(rb_eArgError, "itype must be 1, 2 or 3");
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return itype;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
char get_jobz(VALUE val) {
|
|
14
|
-
const char jobz = NUM2CHR(val);
|
|
15
|
-
|
|
16
|
-
if (jobz != 'N' && jobz != 'V') {
|
|
17
|
-
rb_raise(rb_eArgError, "jobz must be 'N' or 'V'");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return jobz;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
char get_jobvs(VALUE val) {
|
|
24
|
-
const char jobvs = NUM2CHR(val);
|
|
25
|
-
if (jobvs != 'N' && jobvs != 'V') {
|
|
26
|
-
rb_raise(rb_eArgError, "jobvs must be 'N' or 'V'");
|
|
27
|
-
}
|
|
28
|
-
return jobvs;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
char get_range(VALUE val) {
|
|
32
|
-
const char range = NUM2CHR(val);
|
|
33
|
-
|
|
34
|
-
if (range != 'A' && range != 'V' && range != 'I') {
|
|
35
|
-
rb_raise(rb_eArgError, "range must be 'A', 'V' or 'I'");
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return range;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
char get_uplo(VALUE val) {
|
|
42
|
-
const char uplo = NUM2CHR(val);
|
|
43
|
-
|
|
44
|
-
if (uplo != 'U' && uplo != 'L') {
|
|
45
|
-
rb_raise(rb_eArgError, "uplo must be 'U' or 'L'");
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return uplo;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
int get_matrix_layout(VALUE val) {
|
|
52
|
-
const char option = NUM2CHR(val);
|
|
53
|
-
|
|
54
|
-
switch (option) {
|
|
55
|
-
case 'r':
|
|
56
|
-
case 'R':
|
|
57
|
-
break;
|
|
58
|
-
case 'c':
|
|
59
|
-
case 'C':
|
|
60
|
-
rb_warn("Numo::Linalg does not support column major.");
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return LAPACK_ROW_MAJOR;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
enum CBLAS_TRANSPOSE get_cblas_trans(VALUE val) {
|
|
68
|
-
const char option = NUM2CHR(val);
|
|
69
|
-
enum CBLAS_TRANSPOSE res = CblasNoTrans;
|
|
70
|
-
|
|
71
|
-
switch (option) {
|
|
72
|
-
case 'n':
|
|
73
|
-
case 'N':
|
|
74
|
-
res = CblasNoTrans;
|
|
75
|
-
break;
|
|
76
|
-
case 't':
|
|
77
|
-
case 'T':
|
|
78
|
-
res = CblasTrans;
|
|
79
|
-
break;
|
|
80
|
-
case 'c':
|
|
81
|
-
case 'C':
|
|
82
|
-
res = CblasConjTrans;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return res;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
enum CBLAS_ORDER get_cblas_order(VALUE val) {
|
|
90
|
-
const char option = NUM2CHR(val);
|
|
91
|
-
|
|
92
|
-
switch (option) {
|
|
93
|
-
case 'r':
|
|
94
|
-
case 'R':
|
|
95
|
-
break;
|
|
96
|
-
case 'c':
|
|
97
|
-
case 'C':
|
|
98
|
-
rb_warn("Numo::Linalg does not support column major.");
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return CblasRowMajor;
|
|
103
|
-
}
|
data/ext/numo/linalg/util.h
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#ifndef NUMO_LINALG_ALT_UTIL_H
|
|
2
|
-
#define NUMO_LINALG_ALT_UTIL_H 1
|
|
3
|
-
|
|
4
|
-
#include <ruby.h>
|
|
5
|
-
|
|
6
|
-
#include <cblas.h>
|
|
7
|
-
#include <lapacke.h>
|
|
8
|
-
|
|
9
|
-
lapack_int get_itype(VALUE val);
|
|
10
|
-
char get_jobz(VALUE val);
|
|
11
|
-
char get_jobvs(VALUE val);
|
|
12
|
-
char get_range(VALUE val);
|
|
13
|
-
char get_uplo(VALUE val);
|
|
14
|
-
int get_matrix_layout(VALUE val);
|
|
15
|
-
enum CBLAS_TRANSPOSE get_cblas_trans(VALUE val);
|
|
16
|
-
enum CBLAS_ORDER get_cblas_order(VALUE val);
|
|
17
|
-
|
|
18
|
-
#endif // NUMO_LINALG_ALT_UTIL_H
|
|
File without changes
|