Sha256: bfd5fd3bb5b5deabd3433a35a0aa5eaa9f39e1d20a4805836a15eba1028aec55

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "../spec_helper.rb"))

describe MPFR::Matrix, "when setting number to particular element" do
  before(:all) do
    MPFR.set_default_prec(128)
    @row = 4
    @column = 7
    @matrix = MPFR::Matrix.new(@row, @column)
    @source = GenerateNumber.float_matrix_arguments(1, @row, @column)[0]
  end

  it "should have elements which equals to source number." do
    (0...(@matrix.row_size)).each do |i|
      (0...(@matrix.column_size)).each do |j|
        fr = MPFR.new(@source[i][j].to_s)
        @matrix.set_element(i, j, fr)
        @matrix[i, j].should eql fr
      end
    end
  end

end

describe MPFR::Matrix, "when calculating row and column" do
  before(:all) do
    MPFR.set_default_prec(128)
    @row = 6
    @column = 4
    @sources = GenerateNumber.float_matrix_arguments(100, @row, @column)
    @matrixies = @sources.map { |a| MPFR::Matrix.new(a) }
  end

  it "should have row vector." do
    @matrixies.each do |m|
      (0...(m.column_size)).each do |i|
        col = m.column(i)
        (0...(m.row_size)).each do |j|
          col[j].should eql m[j, i]
        end
      end
    end
  end

  it "should have column vector." do
    @matrixies.each do |m|
      (0...(m.row_size)).each do |i|
        row = m.row(i)
        (0...(m.column_size)).each do |j|
          row[j].should eql m[i, j]
        end
      end
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby-mpfr-0.0.17 spec/mpfr_matrix/mpfr_matrix_set_element_spec.rb
ruby-mpfr-0.0.16 spec/mpfr_matrix/mpfr_matrix_set_element_spec.rb
ruby-mpfr-0.0.15 spec/mpfr_matrix/mpfr_matrix_set_element_spec.rb