Sha256: 1d571b825db79c231e81c24de1018ec4a9d09022e83332a4257314b3958a0397

Contents?: true

Size: 622 Bytes

Versions: 5

Compression:

Stored size: 622 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Numo::Linalg do
  describe 'lu_inv' do
    let(:m) { 5 }
    let(:mat_a) { rand_square_real_mat(m) }
    let(:mat_b) { rand_square_complex_mat(m) }

    it 'calculates the inverse of a square real matrix' do
      inv_mat_a = described_class.inv(mat_a)
      expect((inv_mat_a.dot(mat_a) - Numo::DFloat.eye(m)).abs.max).to be < ERR_TOL
    end

    it 'calculates the inverse of a square complex matrix' do
      inv_mat_b = described_class.inv(mat_b)
      expect((inv_mat_b.dot(mat_b) - Numo::DFloat.eye(m)).abs.max).to be < ERR_TOL
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
numo-linalg-0.1.7 spec/linalg/function/lu_inv_spec.rb
numo-linalg-0.1.6 spec/linalg/function/lu_inv_spec.rb
numo-linalg-0.1.5 spec/linalg/function/lu_inv_spec.rb
numo-linalg-0.1.4 spec/linalg/function/lu_inv_spec.rb
numo-linalg-0.1.3 spec/linalg/function/lu_inv_spec.rb