[ruby/matrix] Make frozen matrices Ractor shareable
This commit is contained in:
parent
6b264e833f
commit
a7dccd08e7
Notes:
git
2020-12-09 16:16:06 +09:00
@ -532,7 +532,8 @@ class Matrix
|
||||
alias map! collect!
|
||||
|
||||
def freeze
|
||||
@rows.freeze
|
||||
@rows.each(&:freeze).freeze
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
@ -2141,6 +2142,9 @@ class Vector
|
||||
all?(&:zero?)
|
||||
end
|
||||
|
||||
#
|
||||
# Makes the matrix frozen and Ractor-shareable
|
||||
#
|
||||
def freeze
|
||||
@elements.freeze
|
||||
super
|
||||
|
@ -818,4 +818,13 @@ class TestMatrix < Test::Unit::TestCase
|
||||
assert_equal(Matrix[[(1-2i), 1], [(0-1i), 2], [0, 3]], @c1.adjoint)
|
||||
assert_equal(Matrix.empty(0,2), @e1.adjoint)
|
||||
end
|
||||
|
||||
def test_ractor
|
||||
obj1 = @m1.freeze
|
||||
|
||||
obj2 = Ractor.new obj1 do |obj|
|
||||
obj
|
||||
end.take
|
||||
assert_same obj1, obj2
|
||||
end if defined?(Ractor)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user