Sha256: d5182c567dcd93c71db136f33c8ef9f4d100bcd220afff6730edbc69a746de0d

Contents?: true

Size: 565 Bytes

Versions: 8

Compression:

Stored size: 565 Bytes

Contents

module Qlang
  module Api
    module MatrixApi
      def execute(rows)
        row_count = rows.count
        column_count = rows.first.count
        case $meta_info.lang
        when :r
          "matrix(#{VectorApi.execute(rows.flatten)}, #{row_count}, #{column_count}, byrow = TRUE)"
        when :ruby
          arys_str = rows.map { |row| "[#{row.join(', ')}]" }.join(', ')
          "Matrix[#{arys_str}]"
        else
          fail "Matrix is not implemented for #{$meta_info.lang_str}"
        end
      end
      module_function :execute
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
hilbert-0.0.2700000 lib/qlang/api/matrix_api.rb
qlang-0.0.27182124 lib/qlang/api/matrix_api.rb
qlang-0.0.27182123 lib/qlang/api/matrix_api.rb
qlang-0.0.27182122 lib/qlang/api/matrix_api.rb
qlang-0.0.27182121 lib/qlang/api/matrix_api.rb
qlang-0.0.27182120 lib/qlang/api/matrix_api.rb
qlang-0.0.27182110 lib/qlang/api/matrix_api.rb
qlang-0.0.27182100 lib/qlang/api/matrix_api.rb