Sha256: 0d32c747b25fa21162ea636c784a0891ac05fc821cfde37d6406af09b13cfefe

Contents?: true

Size: 578 Bytes

Versions: 1

Compression:

Stored size: 578 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 #{LANGS_HASH[$meta_info.lang.to_s]}"
        end
      end
      module_function :execute
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qlang-0.0.27182000 lib/qlang/api/matrix_api.rb