Sha256: 2fe69c316eb9b82164cd7f0cdc0ec97d2bef43f12f0add750ef78b3feef674c0
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
require 'spec_helper' describe 'opr-calc/matrix' do it 'can be required without error' do expect { require subject }.not_to raise_error end end require 'opr-calc/matrix' describe Matrix do context 'when symmetric' do subject :symmetric_matrix do Matrix[[ 4, 12, -16 ], [ 12, 37, -43 ], [ -16, -43, 98 ]] end describe '#symmetric?' do it 'returns true' do expect(symmetric_matrix.symmetric?).to be(true) end end describe '#cholesky_factor' do let :expected_cholesky_factorization do Matrix[[ 2, 0, 0], [ 6, 1, 0], [-8, 5, 3]] end it 'returns a Matrix' do expect(symmetric_matrix.cholesky_factor).to be_a(Matrix) end it 'properly calculates the Cholesky factorization' do expect(symmetric_matrix.cholesky_factor).to eq(expected_cholesky_factorization) end end end context 'when asymmetric' do subject :asymmetric_matrix do Matrix[[3, 5, 3], [2, 4, 2], [5, 2, 1]] end describe '#symmetric?' do it 'returns false' do expect(asymmetric_matrix.symmetric?).to be(false) end end describe '#cholesky_factor' do it 'raises an error' do expect { asymmetric_matrix.cholesky_factor }.to raise_error(ArgumentError, 'must provide a symmetric matrix') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opr-calc-1.0.0 | spec/lib/opr-calc/matrix_spec.rb |