Sha256: 59b8e6ae2d26929fd0d7b8854fb323816cda83f261a94910aa173e7e326cd1e7

Contents?: true

Size: 472 Bytes

Versions: 12

Compression:

Stored size: 472 Bytes

Contents

module Qlang
  module Api
    module MatrixApi
      def execute(rows)
        row_count = rows.count
        column_count = rows.first.count
        case $type
        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}]"
        end
      end
      module_function :execute
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
qlang-0.0.27180000 lib/qlang/api/matrix_api.rb
qlang-0.0.27100000 lib/qlang/api/matrix_api.rb
qlang-0.0.27000000 lib/qlang/api/matrix_api.rb
qlang-0.0.27 lib/qlang/api/matrix_api.rb
qlang-0.0.14142135 lib/qlang/api/matrix_api.rb
qlang-0.0.1414213 lib/qlang/api/matrix_api.rb
qlang-0.0.141421 lib/qlang/api/matrix_api.rb
qlang-0.0.14142 lib/qlang/api/matrix_api.rb
qlang-0.0.1414 lib/qlang/api/matrix_api.rb
qlang-0.0.141 lib/qlang/api/matrix_api.rb
qlang-0.0.14 lib/qlang/api/matrix_api.rb
qlang-0.0.1 lib/qlang/api/matrix_api.rb