mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Guard ruby/spec with spec/mspec/tool/wrap_with_guard.rb
This commit is contained in:
parent
350bc29107
commit
835a495608
Notes:
git
2021-05-27 14:42:36 +09:00
164 changed files with 4474 additions and 3982 deletions
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/identity'
|
|
||||||
|
|
||||||
describe "Matrix.I" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/identity'
|
||||||
|
|
||||||
|
describe "Matrix.I" do
|
||||||
it_behaves_like :matrix_identity, :I
|
it_behaves_like :matrix_identity, :I
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
ruby_version_is "2.6" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
ruby_version_is "2.6" do
|
||||||
describe "Matrix#antisymmetric?" do
|
describe "Matrix#antisymmetric?" do
|
||||||
it "returns true for an antisymmetric Matrix" do
|
it "returns true for an antisymmetric Matrix" do
|
||||||
Matrix[[0, -2, Complex(1, 3)], [2, 0, 5], [-Complex(1, 3), -5, 0]].antisymmetric?.should be_true
|
Matrix[[0, -2, Complex(1, 3)], [2, 0, 5], [-Complex(1, 3), -5, 0]].antisymmetric?.should be_true
|
||||||
|
@ -34,4 +36,5 @@ ruby_version_is "2.6" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.build" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.build" do
|
||||||
|
|
||||||
it "returns a Matrix object of the given size" do
|
it "returns a Matrix object of the given size" do
|
||||||
m = Matrix.build(3, 4){1}
|
m = Matrix.build(3, 4){1}
|
||||||
|
@ -64,10 +66,11 @@ describe "Matrix.build" do
|
||||||
m.row_size.should == 3
|
m.row_size.should == 3
|
||||||
m.column_size.should == 3
|
m.column_size.should == 3
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "for a subclass of Matrix" do
|
describe "for a subclass of Matrix" do
|
||||||
it "returns an instance of that subclass" do
|
it "returns an instance of that subclass" do
|
||||||
MatrixSub.build(3){1}.should be_an_instance_of(MatrixSub)
|
MatrixSub.build(3){1}.should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#clone" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#clone" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = Matrix[[1, 2], [3, 4], [5, 6]]
|
@a = Matrix[[1, 2], [3, 4], [5, 6]]
|
||||||
end
|
end
|
||||||
|
@ -22,4 +24,5 @@ describe "Matrix#clone" do
|
||||||
MatrixSub.ins.clone.should be_an_instance_of(MatrixSub)
|
MatrixSub.ins.clone.should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#coerce" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#coerce" do
|
||||||
it "allows the division of integer by a Matrix " do
|
it "allows the division of integer by a Matrix " do
|
||||||
(1/Matrix[[0,1],[-1,0]]).should == Matrix[[0,-1],[1,0]]
|
(1/Matrix[[0,1],[-1,0]]).should == Matrix[[0,-1],[1,0]]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/collect'
|
|
||||||
|
|
||||||
describe "Matrix#collect" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/collect'
|
||||||
|
|
||||||
|
describe "Matrix#collect" do
|
||||||
it_behaves_like :collect, :collect
|
it_behaves_like :collect, :collect
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#column_size" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#column_size" do
|
||||||
it "returns the number of columns" do
|
it "returns the number of columns" do
|
||||||
Matrix[ [1,2], [3,4] ].column_size.should == 2
|
Matrix[ [1,2], [3,4] ].column_size.should == 2
|
||||||
end
|
end
|
||||||
|
@ -10,4 +12,5 @@ describe "Matrix#column_size" do
|
||||||
Matrix[ [], [] ].column_size.should == 0
|
Matrix[ [], [] ].column_size.should == 0
|
||||||
Matrix[ ].column_size.should == 0
|
Matrix[ ].column_size.should == 0
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#column" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#column" do
|
||||||
before :all do
|
before :all do
|
||||||
@m = Matrix[[1,2,3], [2,3,4]]
|
@m = Matrix[[1,2,3], [2,3,4]]
|
||||||
end
|
end
|
||||||
|
@ -32,4 +34,5 @@ describe "Matrix#column" do
|
||||||
-> { @m.column(3){ raise } }.should_not raise_error
|
-> { @m.column(3){ raise } }.should_not raise_error
|
||||||
-> { @m.column(-4){ raise } }.should_not raise_error
|
-> { @m.column(-4){ raise } }.should_not raise_error
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.column_vector" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.column_vector" do
|
||||||
|
|
||||||
it "returns a single column Matrix when called with an Array" do
|
it "returns a single column Matrix when called with an Array" do
|
||||||
m = Matrix.column_vector([4,5,6])
|
m = Matrix.column_vector([4,5,6])
|
||||||
|
@ -22,4 +24,5 @@ describe "Matrix.column_vector" do
|
||||||
MatrixSub.column_vector([4,5,6]).should be_an_instance_of(MatrixSub)
|
MatrixSub.column_vector([4,5,6]).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#column_vectors" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#column_vectors" do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@vectors = Matrix[ [1,2], [3,4] ].column_vectors
|
@vectors = Matrix[ [1,2], [3,4] ].column_vectors
|
||||||
|
@ -23,4 +25,5 @@ describe "Matrix#column_vectors" do
|
||||||
Matrix[ [] ].column_vectors.should == []
|
Matrix[ [] ].column_vectors.should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.columns" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.columns" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = [1, 2]
|
@a = [1, 2]
|
||||||
@b = [3, 4]
|
@b = [3, 4]
|
||||||
|
@ -39,4 +41,5 @@ describe "Matrix.columns" do
|
||||||
MatrixSub.columns([[1]]).should be_an_instance_of(MatrixSub)
|
MatrixSub.columns([[1]]).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/conjugate'
|
|
||||||
|
|
||||||
describe "Matrix#conj" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/conjugate'
|
||||||
|
|
||||||
|
describe "Matrix#conj" do
|
||||||
it_behaves_like :matrix_conjugate, :conj
|
it_behaves_like :matrix_conjugate, :conj
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/conjugate'
|
|
||||||
|
|
||||||
describe "Matrix#conjugate" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/conjugate'
|
||||||
|
|
||||||
|
describe "Matrix#conjugate" do
|
||||||
it_behaves_like :matrix_conjugate, :conjugate
|
it_behaves_like :matrix_conjugate, :conjugate
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.[]" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.[]" do
|
||||||
|
|
||||||
it "requires arrays as parameters" do
|
it "requires arrays as parameters" do
|
||||||
-> { Matrix[5] }.should raise_error(TypeError)
|
-> { Matrix[5] }.should raise_error(TypeError)
|
||||||
|
@ -62,4 +64,5 @@ describe "Matrix.[]" do
|
||||||
MatrixSub[ [20,30], [40.5, 9] ].should be_an_instance_of(MatrixSub)
|
MatrixSub[ [20,30], [40.5, 9] ].should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/determinant'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#det" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/determinant'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#det" do
|
||||||
it_behaves_like :determinant, :det
|
it_behaves_like :determinant, :det
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/determinant'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#determinant" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/determinant'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#determinant" do
|
||||||
it_behaves_like :determinant, :determinant
|
it_behaves_like :determinant, :determinant
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.diagonal" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.diagonal" do
|
||||||
before :each do
|
before :each do
|
||||||
@m = Matrix.diagonal(10, 11, 12, 13, 14)
|
@m = Matrix.diagonal(10, 11, 12, 13, 14)
|
||||||
end
|
end
|
||||||
|
@ -37,9 +39,9 @@ describe "Matrix.diagonal" do
|
||||||
MatrixSub.diagonal(1).should be_an_instance_of(MatrixSub)
|
MatrixSub.diagonal(1).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Matrix.diagonal?" do
|
describe "Matrix.diagonal?" do
|
||||||
it "returns true for a diagonal Matrix" do
|
it "returns true for a diagonal Matrix" do
|
||||||
Matrix.diagonal([1, 2, 3]).diagonal?.should be_true
|
Matrix.diagonal([1, 2, 3]).diagonal?.should be_true
|
||||||
end
|
end
|
||||||
|
@ -69,4 +71,5 @@ describe "Matrix.diagonal?" do
|
||||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'spec_helper'
|
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#/" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'spec_helper'
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#/" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = Matrix[ [1, 2], [3, 4] ]
|
@a = Matrix[ [1, 2], [3, 4] ]
|
||||||
@b = Matrix[ [4, 5], [6, 7] ]
|
@b = Matrix[ [4, 5], [6, 7] ]
|
||||||
|
@ -51,4 +53,5 @@ describe "Matrix#/" do
|
||||||
-> { @a / [ [1, 2] ] }.should raise_error(TypeError)
|
-> { @a / [ [1, 2] ] }.should raise_error(TypeError)
|
||||||
-> { @a / Object.new }.should raise_error(TypeError)
|
-> { @a / Object.new }.should raise_error(TypeError)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#each" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#each" do
|
||||||
before :all do
|
before :all do
|
||||||
@m = Matrix[ [1, 2, 3], [4, 5, 6] ]
|
@m = Matrix[ [1, 2, 3], [4, 5, 6] ]
|
||||||
@result = (1..6).to_a
|
@result = (1..6).to_a
|
||||||
|
@ -22,9 +24,9 @@ describe "Matrix#each" do
|
||||||
@m.each {|x| a << x}
|
@m.each {|x| a << x}
|
||||||
a.should == @result
|
a.should == @result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Matrix#each with an argument" do
|
describe "Matrix#each with an argument" do
|
||||||
before :all do
|
before :all do
|
||||||
@m = Matrix[ [1, 2, 3, 4], [5, 6, 7, 8] ]
|
@m = Matrix[ [1, 2, 3, 4], [5, 6, 7, 8] ]
|
||||||
@t = Matrix[ [1, 2], [3, 4], [5, 6], [7, 8] ]
|
@t = Matrix[ [1, 2], [3, 4], [5, 6], [7, 8] ]
|
||||||
|
@ -71,4 +73,5 @@ describe "Matrix#each with an argument" do
|
||||||
@m.each(:upper).to_a.should == [1, 2, 3, 4, 6, 7, 8]
|
@m.each(:upper).to_a.should == [1, 2, 3, 4, 6, 7, 8]
|
||||||
@t.each(:upper).to_a.should == [1, 2, 4]
|
@t.each(:upper).to_a.should == [1, 2, 4]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#each_with_index" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#each_with_index" do
|
||||||
before :all do
|
before :all do
|
||||||
@m = Matrix[ [1, 2, 3], [4, 5, 6] ]
|
@m = Matrix[ [1, 2, 3], [4, 5, 6] ]
|
||||||
@result = [
|
@result = [
|
||||||
|
@ -29,9 +31,9 @@ describe "Matrix#each_with_index" do
|
||||||
@m.each_with_index {|x, r, c| a << [x, r, c]}
|
@m.each_with_index {|x, r, c| a << [x, r, c]}
|
||||||
a.should == @result
|
a.should == @result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Matrix#each_with_index with an argument" do
|
describe "Matrix#each_with_index with an argument" do
|
||||||
before :all do
|
before :all do
|
||||||
@m = Matrix[ [1, 2, 3, 4], [5, 6, 7, 8] ]
|
@m = Matrix[ [1, 2, 3, 4], [5, 6, 7, 8] ]
|
||||||
@t = Matrix[ [1, 2], [3, 4], [5, 6], [7, 8] ]
|
@t = Matrix[ [1, 2], [3, 4], [5, 6], [7, 8] ]
|
||||||
|
@ -78,4 +80,5 @@ describe "Matrix#each_with_index with an argument" do
|
||||||
@m.each_with_index(:upper).to_a.should == [[1, 0, 0], [2, 0, 1], [3, 0, 2], [4, 0, 3], [6, 1, 1], [7, 1, 2], [8, 1, 3]]
|
@m.each_with_index(:upper).to_a.should == [[1, 0, 0], [2, 0, 1], [3, 0, 2], [4, 0, 3], [6, 1, 1], [7, 1, 2], [8, 1, 3]]
|
||||||
@t.each_with_index(:upper).to_a.should == [[1, 0, 0], [2, 0, 1], [4, 1, 1]]
|
@t.each_with_index(:upper).to_a.should == [[1, 0, 0], [2, 0, 1], [4, 1, 1]]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::EigenvalueDecomposition#eigenvalue_matrix" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::EigenvalueDecomposition#eigenvalue_matrix" do
|
||||||
it "returns a diagonal matrix with the eigenvalues on the diagonal" do
|
it "returns a diagonal matrix with the eigenvalues on the diagonal" do
|
||||||
Matrix[[14, 16], [-6, -6]].eigensystem.eigenvalue_matrix.should == Matrix[[6, 0],[0, 2]]
|
Matrix[[14, 16], [-6, -6]].eigensystem.eigenvalue_matrix.should == Matrix[[6, 0],[0, 2]]
|
||||||
Matrix[[1, 1], [-1, 1]].eigensystem.eigenvalue_matrix.should == Matrix[[Complex(1,1), 0],[0, Complex(1,-1)]]
|
Matrix[[1, 1], [-1, 1]].eigensystem.eigenvalue_matrix.should == Matrix[[Complex(1,1), 0],[0, Complex(1,-1)]]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::EigenvalueDecomposition#eigenvalues" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::EigenvalueDecomposition#eigenvalues" do
|
||||||
it "returns an array of complex eigenvalues for a rotation matrix" do
|
it "returns an array of complex eigenvalues for a rotation matrix" do
|
||||||
Matrix[[ 1, 1],
|
Matrix[[ 1, 1],
|
||||||
[-1, 1]].eigensystem.eigenvalues.sort_by{|v| v.imag}.should ==
|
[-1, 1]].eigensystem.eigenvalues.sort_by{|v| v.imag}.should ==
|
||||||
|
@ -19,4 +21,5 @@ describe "Matrix::EigenvalueDecomposition#eigenvalues" do
|
||||||
[-6, -6]].eigensystem.eigenvalues.sort.map!{|x| x.round(10)}.should ==
|
[-6, -6]].eigensystem.eigenvalues.sort.map!{|x| x.round(10)}.should ==
|
||||||
[ 2, 6 ]
|
[ 2, 6 ]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::EigenvalueDecomposition#eigenvector_matrix" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::EigenvalueDecomposition#eigenvector_matrix" do
|
||||||
it "returns a complex eigenvector matrix given a rotation matrix" do
|
it "returns a complex eigenvector matrix given a rotation matrix" do
|
||||||
# Fix me: should test for linearity, not for equality
|
# Fix me: should test for linearity, not for equality
|
||||||
Matrix[[ 1, 1],
|
Matrix[[ 1, 1],
|
||||||
|
@ -17,4 +19,5 @@ describe "Matrix::EigenvalueDecomposition#eigenvector_matrix" do
|
||||||
Matrix[[0.7071067811865475, 0.7071067811865475],
|
Matrix[[0.7071067811865475, 0.7071067811865475],
|
||||||
[-0.7071067811865475, 0.7071067811865475]]
|
[-0.7071067811865475, 0.7071067811865475]]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::EigenvalueDecomposition#eigenvectors" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::EigenvalueDecomposition#eigenvectors" do
|
||||||
it "returns an array of complex eigenvectors for a rotation matrix" do
|
it "returns an array of complex eigenvectors for a rotation matrix" do
|
||||||
# Fix me: should test for linearity, not for equality
|
# Fix me: should test for linearity, not for equality
|
||||||
Matrix[[ 1, 1],
|
Matrix[[ 1, 1],
|
||||||
|
@ -19,4 +21,5 @@ describe "Matrix::EigenvalueDecomposition#eigenvectors" do
|
||||||
Vector[0.7071067811865475, 0.7071067811865475]
|
Vector[0.7071067811865475, 0.7071067811865475]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::EigenvalueDecomposition#initialize" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::EigenvalueDecomposition#initialize" do
|
||||||
it "raises an error if argument is not a matrix" do
|
it "raises an error if argument is not a matrix" do
|
||||||
-> {
|
-> {
|
||||||
Matrix::EigenvalueDecomposition.new([[]])
|
Matrix::EigenvalueDecomposition.new([[]])
|
||||||
|
@ -21,4 +23,5 @@ describe "Matrix::EigenvalueDecomposition#initialize" do
|
||||||
m = Matrix[ [0,0,0,0,0], [0,0,0,0,1], [0,0,0,1,0], [1,1,0,0,1], [1,0,1,0,1] ]
|
m = Matrix[ [0,0,0,0,0], [0,0,0,0,1], [0,0,0,1,0], [1,1,0,0,1], [1,0,1,0,1] ]
|
||||||
Matrix::EigenvalueDecomposition.new(m).should_not == "infinite loop"
|
Matrix::EigenvalueDecomposition.new(m).should_not == "infinite loop"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::EigenvalueDecomposition#to_a" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::EigenvalueDecomposition#to_a" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = Matrix[[14, 16], [-6, -6]]
|
@a = Matrix[[14, 16], [-6, -6]]
|
||||||
@e = Matrix::EigenvalueDecomposition.new(@a)
|
@e = Matrix::EigenvalueDecomposition.new(@a)
|
||||||
|
@ -15,4 +17,5 @@ describe "Matrix::EigenvalueDecomposition#to_a" do
|
||||||
v, d, v_inv = @e.to_a
|
v, d, v_inv = @e.to_a
|
||||||
(v * d * v_inv).map{|e| e.round(10)}.should == @a
|
(v * d * v_inv).map{|e| e.round(10)}.should == @a
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#[]" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#[]" do
|
||||||
|
|
||||||
before :all do
|
before :all do
|
||||||
@m = Matrix[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]
|
@m = Matrix[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]]
|
||||||
|
@ -20,4 +22,5 @@ describe "Matrix#[]" do
|
||||||
@m[1,8].should be_nil
|
@m[1,8].should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#empty?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#empty?" do
|
||||||
it "returns true when the Matrix is empty" do
|
it "returns true when the Matrix is empty" do
|
||||||
Matrix[ ].empty?.should be_true
|
Matrix[ ].empty?.should be_true
|
||||||
Matrix[ [], [], [] ].empty?.should be_true
|
Matrix[ [], [], [] ].empty?.should be_true
|
||||||
|
@ -19,9 +21,9 @@ describe "Matrix#empty?" do
|
||||||
Matrix[ [1, 2] ].empty?(42)
|
Matrix[ [1, 2] ].empty?(42)
|
||||||
}.should raise_error(ArgumentError)
|
}.should raise_error(ArgumentError)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Matrix.empty" do
|
describe "Matrix.empty" do
|
||||||
it "returns an empty matrix of the requested size" do
|
it "returns an empty matrix of the requested size" do
|
||||||
m = Matrix.empty(3, 0)
|
m = Matrix.empty(3, 0)
|
||||||
m.row_size.should == 3
|
m.row_size.should == 3
|
||||||
|
@ -59,10 +61,11 @@ describe "Matrix.empty" do
|
||||||
}.should raise_error(ArgumentError)
|
}.should raise_error(ArgumentError)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "for a subclass of Matrix" do
|
describe "for a subclass of Matrix" do
|
||||||
it "returns an instance of that subclass" do
|
it "returns an instance of that subclass" do
|
||||||
MatrixSub.empty(0, 1).should be_an_instance_of(MatrixSub)
|
MatrixSub.empty(0, 1).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/equal_value'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#eql?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/equal_value'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#eql?" do
|
||||||
it_behaves_like :equal, :eql?
|
it_behaves_like :equal, :eql?
|
||||||
|
|
||||||
it "returns false if some elements are == but not eql?" do
|
it "returns false if some elements are == but not eql?" do
|
||||||
Matrix[[1, 2],[3, 4]].eql?(Matrix[[1, 2],[3, 4.0]]).should be_false
|
Matrix[[1, 2],[3, 4]].eql?(Matrix[[1, 2],[3, 4.0]]).should be_false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/equal_value'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#==" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/equal_value'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#==" do
|
||||||
it_behaves_like :equal, :==
|
it_behaves_like :equal, :==
|
||||||
|
|
||||||
it "returns true if some elements are == but not eql?" do
|
it "returns true if some elements are == but not eql?" do
|
||||||
Matrix[[1, 2],[3, 4]].should == Matrix[[1, 2],[3, 4.0]]
|
Matrix[[1, 2],[3, 4]].should == Matrix[[1, 2],[3, 4.0]]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#**" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#**" do
|
||||||
|
|
||||||
describe "given an integer _n_" do
|
describe "given an integer _n_" do
|
||||||
it "multiples the Matrix by itself _n_ times" do
|
it "multiples the Matrix by itself _n_ times" do
|
||||||
|
@ -61,4 +63,5 @@ describe "Matrix#**" do
|
||||||
(MatrixSub.ins ** 1).should be_an_instance_of(MatrixSub)
|
(MatrixSub.ins ** 1).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#find_index without any argument" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#find_index without any argument" do
|
||||||
before :all do
|
before :all do
|
||||||
@m = Matrix[ [1, 2, 3, 4], [5, 6, 7, 8] ]
|
@m = Matrix[ [1, 2, 3, 4], [5, 6, 7, 8] ]
|
||||||
end
|
end
|
||||||
|
@ -19,9 +21,9 @@ describe "Matrix#find_index without any argument" do
|
||||||
it "returns the first index for which the block is true" do
|
it "returns the first index for which the block is true" do
|
||||||
@m.find_index{|x| x >= 3}.should == [0, 2]
|
@m.find_index{|x| x >= 3}.should == [0, 2]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Matrix#find_index with a subselection argument" do
|
describe "Matrix#find_index with a subselection argument" do
|
||||||
before :all do
|
before :all do
|
||||||
@tests = [
|
@tests = [
|
||||||
[ Matrix[ [1, 2, 3, 4], [5, 6, 7, 8] ], {
|
[ Matrix[ [1, 2, 3, 4], [5, 6, 7, 8] ], {
|
||||||
|
@ -108,9 +110,9 @@ describe "Matrix#find_index with a subselection argument" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Matrix#find_index with only a generic argument" do
|
describe "Matrix#find_index with only a generic argument" do
|
||||||
before :all do
|
before :all do
|
||||||
@m = Matrix[ [1, 2, 3, 4], [1, 2, 3, 4] ]
|
@m = Matrix[ [1, 2, 3, 4], [1, 2, 3, 4] ]
|
||||||
end
|
end
|
||||||
|
@ -126,9 +128,9 @@ describe "Matrix#find_index with only a generic argument" do
|
||||||
it "ignores a block" do
|
it "ignores a block" do
|
||||||
@m.find_index(4){raise "oups"}.should == [0, 3]
|
@m.find_index(4){raise "oups"}.should == [0, 3]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Matrix#find_index with two arguments" do
|
describe "Matrix#find_index with two arguments" do
|
||||||
it "raises an ArgumentError for an unrecognized last argument" do
|
it "raises an ArgumentError for an unrecognized last argument" do
|
||||||
-> {
|
-> {
|
||||||
@m.find_index(1, "all"){}
|
@m.find_index(1, "all"){}
|
||||||
|
@ -143,4 +145,5 @@ describe "Matrix#find_index with two arguments" do
|
||||||
@m.find_index(:diagonal, 1){}
|
@m.find_index(:diagonal, 1){}
|
||||||
}.should raise_error(ArgumentError)
|
}.should raise_error(ArgumentError)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#hash" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#hash" do
|
||||||
|
|
||||||
it "returns an Integer" do
|
it "returns an Integer" do
|
||||||
Matrix[ [1,2] ].hash.should be_an_instance_of(Integer)
|
Matrix[ [1,2] ].hash.should be_an_instance_of(Integer)
|
||||||
|
@ -12,4 +14,5 @@ describe "Matrix#hash" do
|
||||||
Matrix[ *data ].hash.should == Matrix[ *data ].hash
|
Matrix[ *data ].hash.should == Matrix[ *data ].hash
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.hermitian?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.hermitian?" do
|
||||||
it "returns true for a hermitian Matrix" do
|
it "returns true for a hermitian Matrix" do
|
||||||
Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, -3), 5, 6]].hermitian?.should be_true
|
Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, -3), 5, 6]].hermitian?.should be_true
|
||||||
end
|
end
|
||||||
|
@ -31,4 +33,5 @@ describe "Matrix.hermitian?" do
|
||||||
Matrix[[Complex(1,1)]].hermitian?.should be_false
|
Matrix[[Complex(1,1)]].hermitian?.should be_false
|
||||||
Matrix[[Complex(1,0)]].hermitian?.should be_true
|
Matrix[[Complex(1,0)]].hermitian?.should be_true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/identity'
|
|
||||||
|
|
||||||
describe "Matrix.identity" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/identity'
|
||||||
|
|
||||||
|
describe "Matrix.identity" do
|
||||||
it_behaves_like :matrix_identity, :identity
|
it_behaves_like :matrix_identity, :identity
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/imaginary'
|
|
||||||
|
|
||||||
describe "Matrix#imag" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/imaginary'
|
||||||
|
|
||||||
|
describe "Matrix#imag" do
|
||||||
it_behaves_like :matrix_imaginary, :imag
|
it_behaves_like :matrix_imaginary, :imag
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/imaginary'
|
|
||||||
|
|
||||||
describe "Matrix#imaginary" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/imaginary'
|
||||||
|
|
||||||
|
describe "Matrix#imaginary" do
|
||||||
it_behaves_like :matrix_imaginary, :imaginary
|
it_behaves_like :matrix_imaginary, :imaginary
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#inspect" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#inspect" do
|
||||||
|
|
||||||
it "returns a stringified representation of the Matrix" do
|
it "returns a stringified representation of the Matrix" do
|
||||||
Matrix[ [1,2], [2,1] ].inspect.should == "Matrix[[1, 2], [2, 1]]"
|
Matrix[ [1,2], [2,1] ].inspect.should == "Matrix[[1, 2], [2, 1]]"
|
||||||
|
@ -24,4 +26,5 @@ describe "Matrix#inspect" do
|
||||||
MatrixSub.ins.inspect.should == "MatrixSub[[1, 0], [0, 1]]"
|
MatrixSub.ins.inspect.should == "MatrixSub[[1, 0], [0, 1]]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'spec_helper'
|
|
||||||
require_relative 'shared/inverse'
|
|
||||||
|
|
||||||
describe "Matrix#inv" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'spec_helper'
|
||||||
|
require_relative 'shared/inverse'
|
||||||
|
|
||||||
|
describe "Matrix#inv" do
|
||||||
it_behaves_like :inverse, :inv
|
it_behaves_like :inverse, :inv
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#inverse_from" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#inverse_from" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'spec_helper'
|
|
||||||
require_relative 'shared/inverse'
|
|
||||||
|
|
||||||
describe "Matrix#inverse" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'spec_helper'
|
||||||
|
require_relative 'shared/inverse'
|
||||||
|
|
||||||
|
describe "Matrix#inverse" do
|
||||||
it_behaves_like :inverse, :inverse
|
it_behaves_like :inverse, :inverse
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.lower_triangular?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.lower_triangular?" do
|
||||||
it "returns true for a square lower triangular Matrix" do
|
it "returns true for a square lower triangular Matrix" do
|
||||||
Matrix[[1, 0, 0], [1, 2, 0], [1, 2, 3]].lower_triangular?.should be_true
|
Matrix[[1, 0, 0], [1, 2, 0], [1, 2, 3]].lower_triangular?.should be_true
|
||||||
Matrix.diagonal([1, 2, 3]).lower_triangular?.should be_true
|
Matrix.diagonal([1, 2, 3]).lower_triangular?.should be_true
|
||||||
|
@ -21,4 +23,5 @@ describe "Matrix.lower_triangular?" do
|
||||||
Matrix[[0, 1], [0, 0], [0, 0], [0, 0]].lower_triangular?.should be_false
|
Matrix[[0, 1], [0, 0], [0, 0], [0, 0]].lower_triangular?.should be_false
|
||||||
Matrix[[0, 0, 0, 1], [0, 0, 0, 0]].lower_triangular?.should be_false
|
Matrix[[0, 0, 0, 1], [0, 0, 0, 0]].lower_triangular?.should be_false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::LUPDecomposition#determinant" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::LUPDecomposition#determinant" do
|
||||||
it "returns the determinant when the matrix is square" do
|
it "returns the determinant when the matrix is square" do
|
||||||
a = Matrix[[7, 8, 9], [14, 46, 51], [28, 82, 163]]
|
a = Matrix[[7, 8, 9], [14, 46, 51], [28, 82, 163]]
|
||||||
a.lup.determinant.should == 15120 # == a.determinant
|
a.lup.determinant.should == 15120 # == a.determinant
|
||||||
|
@ -18,4 +20,5 @@ describe "Matrix::LUPDecomposition#determinant" do
|
||||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::LUPDecomposition#initialize" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::LUPDecomposition#initialize" do
|
||||||
it "raises an error if argument is not a matrix" do
|
it "raises an error if argument is not a matrix" do
|
||||||
-> {
|
-> {
|
||||||
Matrix::LUPDecomposition.new([[]])
|
Matrix::LUPDecomposition.new([[]])
|
||||||
|
@ -10,4 +12,5 @@ describe "Matrix::LUPDecomposition#initialize" do
|
||||||
Matrix::LUPDecomposition.new(42)
|
Matrix::LUPDecomposition.new(42)
|
||||||
}.should raise_error(TypeError)
|
}.should raise_error(TypeError)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::LUPDecomposition#l" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::LUPDecomposition#l" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = Matrix[[7, 8, 9], [14, 46, 51], [28, 82, 163]]
|
@a = Matrix[[7, 8, 9], [14, 46, 51], [28, 82, 163]]
|
||||||
@lu = Matrix::LUPDecomposition.new(@a)
|
@lu = Matrix::LUPDecomposition.new(@a)
|
||||||
|
@ -15,4 +17,5 @@ describe "Matrix::LUPDecomposition#l" do
|
||||||
it "returns a lower triangular matrix" do
|
it "returns a lower triangular matrix" do
|
||||||
@l.lower_triangular?.should be_true
|
@l.lower_triangular?.should be_true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::LUPDecomposition#p" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::LUPDecomposition#p" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = Matrix[[7, 8, 9], [14, 46, 51], [28, 82, 163]]
|
@a = Matrix[[7, 8, 9], [14, 46, 51], [28, 82, 163]]
|
||||||
@lu = Matrix::LUPDecomposition.new(@a)
|
@lu = Matrix::LUPDecomposition.new(@a)
|
||||||
|
@ -15,4 +17,5 @@ describe "Matrix::LUPDecomposition#p" do
|
||||||
it "returns a permutation matrix" do
|
it "returns a permutation matrix" do
|
||||||
@p.permutation?.should be_true
|
@p.permutation?.should be_true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::LUPDecomposition#solve" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::LUPDecomposition#solve" do
|
||||||
describe "for rectangular matrices" do
|
describe "for rectangular matrices" do
|
||||||
it "raises an error for singular matrices" do
|
it "raises an error for singular matrices" do
|
||||||
a = Matrix[[1, 2, 3], [1, 3, 5], [2, 5, 8]]
|
a = Matrix[[1, 2, 3], [1, 3, 5], [2, 5, 8]]
|
||||||
|
@ -50,4 +52,5 @@ describe "Matrix::LUPDecomposition#solve" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::LUPDecomposition#to_a" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::LUPDecomposition#to_a" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = Matrix[[7, 8, 9], [14, 46, 51], [28, 82, 163]]
|
@a = Matrix[[7, 8, 9], [14, 46, 51], [28, 82, 163]]
|
||||||
@lu = Matrix::LUPDecomposition.new(@a)
|
@lu = Matrix::LUPDecomposition.new(@a)
|
||||||
|
@ -30,4 +32,5 @@ describe "Matrix::LUPDecomposition#to_a" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "has other properties implied by the specs of #l, #u and #p"
|
it "has other properties implied by the specs of #l, #u and #p"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::LUPDecomposition#u" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::LUPDecomposition#u" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = Matrix[[7, 8, 9], [14, 46, 51], [28, 82, 163]]
|
@a = Matrix[[7, 8, 9], [14, 46, 51], [28, 82, 163]]
|
||||||
@lu = Matrix::LUPDecomposition.new(@a)
|
@lu = Matrix::LUPDecomposition.new(@a)
|
||||||
|
@ -15,4 +17,5 @@ describe "Matrix::LUPDecomposition#u" do
|
||||||
it "returns an upper triangular matrix" do
|
it "returns an upper triangular matrix" do
|
||||||
@u.upper_triangular?.should be_true
|
@u.upper_triangular?.should be_true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/collect'
|
|
||||||
|
|
||||||
describe "Matrix#map" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/collect'
|
||||||
|
|
||||||
|
describe "Matrix#map" do
|
||||||
it_behaves_like :collect, :map
|
it_behaves_like :collect, :map
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#minor" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#minor" do
|
||||||
before :each do
|
before :each do
|
||||||
@matrix = Matrix[ [1,2], [3,4], [5,6] ]
|
@matrix = Matrix[ [1,2], [3,4], [5,6] ]
|
||||||
end
|
end
|
||||||
|
@ -82,4 +84,5 @@ describe "Matrix#minor" do
|
||||||
MatrixSub.ins.minor(0, 1, 0, 1).should be_an_instance_of(MatrixSub)
|
MatrixSub.ins.minor(0, 1, 0, 1).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#-" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#-" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = Matrix[ [1, 2], [3, 4] ]
|
@a = Matrix[ [1, 2], [3, 4] ]
|
||||||
@b = Matrix[ [4, 5], [6, 7] ]
|
@b = Matrix[ [4, 5], [6, 7] ]
|
||||||
|
@ -39,4 +41,5 @@ describe "Matrix#-" do
|
||||||
(m-m).should be_an_instance_of(MatrixSub)
|
(m-m).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#*" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#*" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = Matrix[ [1, 2], [3, 4] ]
|
@a = Matrix[ [1, 2], [3, 4] ]
|
||||||
@b = Matrix[ [4, 5], [6, 7] ]
|
@b = Matrix[ [4, 5], [6, 7] ]
|
||||||
|
@ -65,4 +67,5 @@ describe "Matrix#*" do
|
||||||
(m*1).should be_an_instance_of(MatrixSub)
|
(m*1).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.new" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.new" do
|
||||||
it "is private" do
|
it "is private" do
|
||||||
Matrix.should have_private_method(:new)
|
Matrix.should have_private_method(:new)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.normal?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.normal?" do
|
||||||
# it "returns false for non normal matrices" do
|
# it "returns false for non normal matrices" do
|
||||||
# Matrix[[0, 1], [1, 2]].should_not.normal?
|
# Matrix[[0, 1], [1, 2]].should_not.normal?
|
||||||
# end
|
# end
|
||||||
|
@ -23,4 +25,5 @@ describe "Matrix.normal?" do
|
||||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.orthogonal?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.orthogonal?" do
|
||||||
it "returns false for non orthogonal matrices" do
|
it "returns false for non orthogonal matrices" do
|
||||||
Matrix[[0, 1], [1, 2]].should_not.orthogonal?
|
Matrix[[0, 1], [1, 2]].should_not.orthogonal?
|
||||||
Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].should_not.orthogonal?
|
Matrix[[1, 1, 0], [0, 1, 1], [1, 0, 1]].should_not.orthogonal?
|
||||||
|
@ -23,4 +25,5 @@ describe "Matrix.orthogonal?" do
|
||||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#permutation?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#permutation?" do
|
||||||
it "returns true for a permutation Matrix" do
|
it "returns true for a permutation Matrix" do
|
||||||
Matrix[[0, 1, 0], [0, 0, 1], [1, 0, 0]].permutation?.should be_true
|
Matrix[[0, 1, 0], [0, 0, 1], [1, 0, 0]].permutation?.should be_true
|
||||||
end
|
end
|
||||||
|
@ -29,4 +31,5 @@ describe "Matrix#permutation?" do
|
||||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#+" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#+" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = Matrix[ [1,2], [3,4] ]
|
@a = Matrix[ [1,2], [3,4] ]
|
||||||
@b = Matrix[ [4,5], [6,7] ]
|
@b = Matrix[ [4,5], [6,7] ]
|
||||||
|
@ -39,4 +41,5 @@ describe "Matrix#+" do
|
||||||
(m+m).should be_an_instance_of(MatrixSub)
|
(m+m).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#rank" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#rank" do
|
||||||
it "returns the rank of the Matrix" do
|
it "returns the rank of the Matrix" do
|
||||||
Matrix[ [7,6], [3,9] ].rank.should == 2
|
Matrix[ [7,6], [3,9] ].rank.should == 2
|
||||||
end
|
end
|
||||||
|
@ -16,4 +18,5 @@ describe "Matrix#rank" do
|
||||||
Matrix[[0,0],[0,0],[1,0]].rank.should == 1
|
Matrix[[0,0],[0,0],[1,0]].rank.should == 1
|
||||||
Matrix[[0,1],[0,0],[1,0]].rank.should == 2
|
Matrix[[0,1],[0,0],[1,0]].rank.should == 2
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#real?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#real?" do
|
||||||
it "returns true for matrices with all real entries" do
|
it "returns true for matrices with all real entries" do
|
||||||
Matrix[ [1, 2], [3, 4] ].real?.should be_true
|
Matrix[ [1, 2], [3, 4] ].real?.should be_true
|
||||||
Matrix[ [1.9, 2], [3, 4] ].real?.should be_true
|
Matrix[ [1.9, 2], [3, 4] ].real?.should be_true
|
||||||
|
@ -22,9 +24,9 @@ describe "Matrix#real?" do
|
||||||
Matrix[ [Complex(1,0), 2], [3, 4] ].real?.should be_false
|
Matrix[ [Complex(1,0), 2], [3, 4] ].real?.should be_false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Matrix#real" do
|
describe "Matrix#real" do
|
||||||
it "returns a matrix with the real part of the elements of the receiver" do
|
it "returns a matrix with the real part of the elements of the receiver" do
|
||||||
Matrix[ [1, 2], [3, 4] ].real.should == Matrix[ [1, 2], [3, 4] ]
|
Matrix[ [1, 2], [3, 4] ].real.should == Matrix[ [1, 2], [3, 4] ]
|
||||||
Matrix[ [1.9, Complex(1,1)], [Complex(-0.42, 0), 4] ].real.should == Matrix[ [1.9, 1], [-0.42, 4] ]
|
Matrix[ [1.9, Complex(1,1)], [Complex(-0.42, 0), 4] ].real.should == Matrix[ [1.9, 1], [-0.42, 4] ]
|
||||||
|
@ -40,4 +42,5 @@ describe "Matrix#real" do
|
||||||
MatrixSub.ins.real.should be_an_instance_of(MatrixSub)
|
MatrixSub.ins.real.should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/rectangular'
|
|
||||||
|
|
||||||
describe "Matrix#rect" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/rectangular'
|
||||||
|
|
||||||
|
describe "Matrix#rect" do
|
||||||
it_behaves_like :matrix_rectangular, :rect
|
it_behaves_like :matrix_rectangular, :rect
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/rectangular'
|
|
||||||
|
|
||||||
describe "Matrix#rectangular" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/rectangular'
|
||||||
|
|
||||||
|
describe "Matrix#rectangular" do
|
||||||
it_behaves_like :matrix_rectangular, :rectangular
|
it_behaves_like :matrix_rectangular, :rectangular
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#regular?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#regular?" do
|
||||||
|
|
||||||
it "returns false for singular matrices" do
|
it "returns false for singular matrices" do
|
||||||
m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]
|
m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]
|
||||||
|
@ -28,4 +30,5 @@ describe "Matrix#regular?" do
|
||||||
Matrix.empty(3,0).regular?
|
Matrix.empty(3,0).regular?
|
||||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#round" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#round" do
|
||||||
it "returns a matrix with all entries rounded" do
|
it "returns a matrix with all entries rounded" do
|
||||||
Matrix[ [1, 2.34], [5.67, 8] ].round.should == Matrix[ [1, 2], [6, 8] ]
|
Matrix[ [1, 2.34], [5.67, 8] ].round.should == Matrix[ [1, 2], [6, 8] ]
|
||||||
Matrix[ [1, 2.34], [5.67, 8] ].round(1).should == Matrix[ [1, 2.3], [5.7, 8] ]
|
Matrix[ [1, 2.34], [5.67, 8] ].round(1).should == Matrix[ [1, 2.3], [5.7, 8] ]
|
||||||
|
@ -18,4 +20,5 @@ describe "Matrix#round" do
|
||||||
MatrixSub.ins.round.should be_an_instance_of(MatrixSub)
|
MatrixSub.ins.round.should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#row_size" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#row_size" do
|
||||||
it "returns the number rows" do
|
it "returns the number rows" do
|
||||||
Matrix[ [1,2], [3, 4], [5, 6] ].row_size.should == 3
|
Matrix[ [1,2], [3, 4], [5, 6] ].row_size.should == 3
|
||||||
end
|
end
|
||||||
|
@ -10,4 +12,5 @@ describe "Matrix#row_size" do
|
||||||
Matrix[ [], [], [] ].row_size.should == 3
|
Matrix[ [], [], [] ].row_size.should == 3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#row" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#row" do
|
||||||
before :all do
|
before :all do
|
||||||
@m = Matrix[ [1, 2], [2, 3], [3, 4] ]
|
@m = Matrix[ [1, 2], [2, 3], [3, 4] ]
|
||||||
end
|
end
|
||||||
|
@ -33,4 +35,5 @@ describe "Matrix#row" do
|
||||||
-> { @m.row(3){ raise } }.should_not raise_error
|
-> { @m.row(3){ raise } }.should_not raise_error
|
||||||
-> { @m.row(-4){ raise } }.should_not raise_error
|
-> { @m.row(-4){ raise } }.should_not raise_error
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.row_vector" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.row_vector" do
|
||||||
|
|
||||||
it "returns a Matrix" do
|
it "returns a Matrix" do
|
||||||
Matrix.row_vector([]).should be_an_instance_of(Matrix)
|
Matrix.row_vector([]).should be_an_instance_of(Matrix)
|
||||||
|
@ -21,4 +23,5 @@ describe "Matrix.row_vector" do
|
||||||
MatrixSub.row_vector([1]).should be_an_instance_of(MatrixSub)
|
MatrixSub.row_vector([1]).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#row_vectors" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#row_vectors" do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@vectors = Matrix[ [1,2], [3,4] ].row_vectors
|
@vectors = Matrix[ [1,2], [3,4] ].row_vectors
|
||||||
|
@ -23,4 +25,5 @@ describe "Matrix#row_vectors" do
|
||||||
Matrix[].row_vectors.should == []
|
Matrix[].row_vectors.should == []
|
||||||
Matrix[ [] ].row_vectors.should == [ Vector[] ]
|
Matrix[ [] ].row_vectors.should == [ Vector[] ]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.rows" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.rows" do
|
||||||
before :each do
|
before :each do
|
||||||
@a = [1, 2]
|
@a = [1, 2]
|
||||||
@b = [3, 4]
|
@b = [3, 4]
|
||||||
|
@ -38,4 +40,5 @@ describe "Matrix.rows" do
|
||||||
MatrixSub.rows([[0, 1], [0, 1]]).should be_an_instance_of(MatrixSub)
|
MatrixSub.rows([[0, 1], [0, 1]]).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::Scalar#Fail" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::Scalar#Fail" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::Scalar#Raise" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::Scalar#Raise" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::Scalar#/" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::Scalar#/" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::Scalar#**" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::Scalar#**" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::Scalar.included" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::Scalar.included" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::Scalar#initialize" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::Scalar#initialize" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::Scalar#-" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::Scalar#-" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::Scalar#*" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::Scalar#*" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix::Scalar#+" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix::Scalar#+" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.scalar" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.scalar" do
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@side = 3
|
@side = 3
|
||||||
|
@ -64,4 +66,5 @@ describe "Matrix.scalar" do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#singular?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#singular?" do
|
||||||
it "returns true for singular matrices" do
|
it "returns true for singular matrices" do
|
||||||
m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]
|
m = Matrix[ [1,2,3], [3,4,3], [0,0,0] ]
|
||||||
m.singular?.should be_true
|
m.singular?.should be_true
|
||||||
|
@ -28,4 +30,5 @@ describe "Matrix#singular?" do
|
||||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#square?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#square?" do
|
||||||
|
|
||||||
it "returns true when the Matrix is square" do
|
it "returns true when the Matrix is square" do
|
||||||
Matrix[ [1,2], [2,4] ].square?.should be_true
|
Matrix[ [1,2], [2,4] ].square?.should be_true
|
||||||
|
@ -25,4 +27,5 @@ describe "Matrix#square?" do
|
||||||
Matrix[[]].square?.should be_false
|
Matrix[[]].square?.should be_false
|
||||||
Matrix.columns([[]]).square?.should be_false
|
Matrix.columns([[]]).square?.should be_false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.symmetric?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.symmetric?" do
|
||||||
it "returns true for a symmetric Matrix" do
|
it "returns true for a symmetric Matrix" do
|
||||||
Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, 3), 5, 6]].symmetric?.should be_true
|
Matrix[[1, 2, Complex(0, 3)], [2, 4, 5], [Complex(0, 3), 5, 6]].symmetric?.should be_true
|
||||||
end
|
end
|
||||||
|
@ -26,4 +28,5 @@ describe "Matrix.symmetric?" do
|
||||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/transpose'
|
|
||||||
|
|
||||||
describe "Matrix#transpose" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/transpose'
|
||||||
|
|
||||||
|
describe "Matrix#transpose" do
|
||||||
it_behaves_like :matrix_transpose, :t
|
it_behaves_like :matrix_transpose, :t
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#to_a" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#to_a" do
|
||||||
it "returns the array of arrays that describe the rows of the matrix" do
|
it "returns the array of arrays that describe the rows of the matrix" do
|
||||||
Matrix[].to_a.should == []
|
Matrix[].to_a.should == []
|
||||||
Matrix[[]].to_a.should == [[]]
|
Matrix[[]].to_a.should == [[]]
|
||||||
Matrix[[1]].to_a.should == [[1]]
|
Matrix[[1]].to_a.should == [[1]]
|
||||||
Matrix[[1, 2], [3, 4]].to_a.should == [[1, 2],[3, 4]]
|
Matrix[[1, 2], [3, 4]].to_a.should == [[1, 2],[3, 4]]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#to_s" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#to_s" do
|
||||||
it "needs to be reviewed for spec completeness"
|
it "needs to be reviewed for spec completeness"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/trace'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#tr" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/trace'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#tr" do
|
||||||
it_behaves_like :trace, :tr
|
it_behaves_like :trace, :tr
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/trace'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix#trace" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/trace'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix#trace" do
|
||||||
it_behaves_like :trace, :trace
|
it_behaves_like :trace, :trace
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/transpose'
|
|
||||||
|
|
||||||
describe "Matrix#transpose" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/transpose'
|
||||||
|
|
||||||
|
describe "Matrix#transpose" do
|
||||||
it_behaves_like :matrix_transpose, :transpose
|
it_behaves_like :matrix_transpose, :transpose
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'shared/identity'
|
|
||||||
|
|
||||||
describe "Matrix.unit" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'shared/identity'
|
||||||
|
|
||||||
|
describe "Matrix.unit" do
|
||||||
it_behaves_like :matrix_identity, :unit
|
it_behaves_like :matrix_identity, :unit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.unitary?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.unitary?" do
|
||||||
it "returns false for non unitary matrices" do
|
it "returns false for non unitary matrices" do
|
||||||
Matrix[[0, 1], [1, 2]].should_not.unitary?
|
Matrix[[0, 1], [1, 2]].should_not.unitary?
|
||||||
Matrix[[0, Complex(0, 2)], [Complex(0, 2), 0]].should_not.unitary?
|
Matrix[[0, Complex(0, 2)], [Complex(0, 2), 0]].should_not.unitary?
|
||||||
|
@ -30,4 +32,5 @@ describe "Matrix.unitary?" do
|
||||||
}.should raise_error(Matrix::ErrDimensionMismatch)
|
}.should raise_error(Matrix::ErrDimensionMismatch)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.upper_triangular?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.upper_triangular?" do
|
||||||
it "returns true for an upper triangular Matrix" do
|
it "returns true for an upper triangular Matrix" do
|
||||||
Matrix[[1, 2, 3], [0, 2, 3], [0, 0, 3]].upper_triangular?.should be_true
|
Matrix[[1, 2, 3], [0, 2, 3], [0, 0, 3]].upper_triangular?.should be_true
|
||||||
Matrix.diagonal([1, 2, 3]).upper_triangular?.should be_true
|
Matrix.diagonal([1, 2, 3]).upper_triangular?.should be_true
|
||||||
|
@ -21,4 +23,5 @@ describe "Matrix.upper_triangular?" do
|
||||||
Matrix.empty(0,3).upper_triangular?.should be_true
|
Matrix.empty(0,3).upper_triangular?.should be_true
|
||||||
Matrix.empty(0,0).upper_triangular?.should be_true
|
Matrix.empty(0,0).upper_triangular?.should be_true
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Vector#cross_product" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Vector#cross_product" do
|
||||||
it "returns the cross product of a vector" do
|
it "returns the cross product of a vector" do
|
||||||
Vector[1, 2, 3].cross_product(Vector[0, -4, 5]).should == Vector[22, -5, -4]
|
Vector[1, 2, 3].cross_product(Vector[0, -4, 5]).should == Vector[22, -5, -4]
|
||||||
end
|
end
|
||||||
|
@ -11,4 +13,5 @@ describe "Vector#cross_product" do
|
||||||
Vector[1, 2, 3].cross_product(Vector[0, -4])
|
Vector[1, 2, 3].cross_product(Vector[0, -4])
|
||||||
}.should raise_error(Vector::ErrDimensionMismatch)
|
}.should raise_error(Vector::ErrDimensionMismatch)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Vector.each2" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Vector.each2" do
|
||||||
before :all do
|
before :all do
|
||||||
@v = Vector[1, 2, 3]
|
@v = Vector[1, 2, 3]
|
||||||
@v2 = Vector[4, 5, 6]
|
@v2 = Vector[4, 5, 6]
|
||||||
|
@ -46,4 +48,5 @@ describe "Vector.each2" do
|
||||||
enum.to_a.should == [[1, 4], [2, 5], [3, 6]]
|
enum.to_a.should == [[1, 4], [2, 5], [3, 6]]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Vector#eql?" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Vector#eql?" do
|
||||||
before do
|
before do
|
||||||
@vector = Vector[1, 2, 3, 4, 5]
|
@vector = Vector[1, 2, 3, 4, 5]
|
||||||
end
|
end
|
||||||
|
@ -13,4 +15,5 @@ describe "Vector#eql?" do
|
||||||
it "returns false when there are a pair corresponding elements which are not equal in the sense of Kernel#eql?" do
|
it "returns false when there are a pair corresponding elements which are not equal in the sense of Kernel#eql?" do
|
||||||
@vector.eql?(Vector[1, 2, 3, 4, 5.0]).should be_false
|
@vector.eql?(Vector[1, 2, 3, 4, 5.0]).should be_false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Vector#inner_product" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Vector#inner_product" do
|
||||||
it "returns the inner product of a vector" do
|
it "returns the inner product of a vector" do
|
||||||
Vector[1, 2, 3].inner_product(Vector[0, -4, 5]).should == 7
|
Vector[1, 2, 3].inner_product(Vector[0, -4, 5]).should == 7
|
||||||
end
|
end
|
||||||
|
@ -19,4 +21,5 @@ describe "Vector#inner_product" do
|
||||||
it "uses the conjugate of its argument" do
|
it "uses the conjugate of its argument" do
|
||||||
Vector[Complex(1,2)].inner_product(Vector[Complex(3,4)]).should == Complex(11, 2)
|
Vector[Complex(1,2)].inner_product(Vector[Complex(3,4)]).should == Complex(11, 2)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../../spec_helper'
|
require_relative '../../../spec_helper'
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Vector#normalize" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Vector#normalize" do
|
||||||
it "returns a normalized copy of the vector" do
|
it "returns a normalized copy of the vector" do
|
||||||
x = 0.2672612419124244
|
x = 0.2672612419124244
|
||||||
Vector[1, 2, 3].normalize.should == Vector[x, x * 2, x * 3]
|
Vector[1, 2, 3].normalize.should == Vector[x, x * 2, x * 3]
|
||||||
|
@ -15,4 +17,5 @@ describe "Vector#normalize" do
|
||||||
Vector[0, 0, 0].normalize
|
Vector[0, 0, 0].normalize
|
||||||
}.should raise_error(Vector::ZeroVectorError)
|
}.should raise_error(Vector::ZeroVectorError)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require_relative 'fixtures/classes'
|
|
||||||
require 'matrix'
|
|
||||||
|
|
||||||
describe "Matrix.zero" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require_relative 'fixtures/classes'
|
||||||
|
require 'matrix'
|
||||||
|
|
||||||
|
describe "Matrix.zero" do
|
||||||
it "returns an object of type Matrix" do
|
it "returns an object of type Matrix" do
|
||||||
Matrix.zero(3).should be_kind_of(Matrix)
|
Matrix.zero(3).should be_kind_of(Matrix)
|
||||||
end
|
end
|
||||||
|
@ -33,9 +35,9 @@ describe "Matrix.zero" do
|
||||||
MatrixSub.zero(3).should be_an_instance_of(MatrixSub)
|
MatrixSub.zero(3).should be_an_instance_of(MatrixSub)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Matrix.zero?" do
|
describe "Matrix.zero?" do
|
||||||
it "returns true for empty matrices" do
|
it "returns true for empty matrices" do
|
||||||
Matrix.empty.should.zero?
|
Matrix.empty.should.zero?
|
||||||
Matrix.empty(3,0).should.zero?
|
Matrix.empty(3,0).should.zero?
|
||||||
|
@ -49,4 +51,5 @@ describe "Matrix.zero?" do
|
||||||
it "returns false for matrices with non zero entries" do
|
it "returns false for matrices with non zero entries" do
|
||||||
Matrix[[1]].should_not.zero?
|
Matrix[[1]].should_not.zero?
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'net/ftp'
|
|
||||||
|
|
||||||
describe "Net::FTPError" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'net/ftp'
|
||||||
|
|
||||||
|
describe "Net::FTPError" do
|
||||||
it "is an Exception" do
|
it "is an Exception" do
|
||||||
Net::FTPError.should < Exception
|
Net::FTPError.should < Exception
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'net/ftp'
|
|
||||||
|
|
||||||
describe "Net::FTPPermError" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'net/ftp'
|
||||||
|
|
||||||
|
describe "Net::FTPPermError" do
|
||||||
it "is an Exception" do
|
it "is an Exception" do
|
||||||
Net::FTPPermError.should < Exception
|
Net::FTPPermError.should < Exception
|
||||||
end
|
end
|
||||||
|
@ -9,4 +11,5 @@ describe "Net::FTPPermError" do
|
||||||
it "is a subclass of Net::FTPError" do
|
it "is a subclass of Net::FTPError" do
|
||||||
Net::FTPPermError.should < Net::FTPError
|
Net::FTPPermError.should < Net::FTPError
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
require_relative '../../spec_helper'
|
require_relative '../../spec_helper'
|
||||||
require 'net/ftp'
|
|
||||||
|
|
||||||
describe "Net::FTPProtoError" do
|
ruby_version_is ""..."3.1" do
|
||||||
|
require 'net/ftp'
|
||||||
|
|
||||||
|
describe "Net::FTPProtoError" do
|
||||||
it "is an Exception" do
|
it "is an Exception" do
|
||||||
Net::FTPProtoError.should < Exception
|
Net::FTPProtoError.should < Exception
|
||||||
end
|
end
|
||||||
|
@ -9,4 +11,5 @@ describe "Net::FTPProtoError" do
|
||||||
it "is a subclass of Net::FTPError" do
|
it "is a subclass of Net::FTPError" do
|
||||||
Net::FTPPermError.should < Net::FTPError
|
Net::FTPPermError.should < Net::FTPError
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue