Sha256: 4cbce669cd95152008544297e6b34232794459c1e979d5d39a30afa0d9ba0c22

Contents?: true

Size: 567 Bytes

Versions: 9

Compression:

Stored size: 567 Bytes

Contents

module Hilbert
  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

9 entries across 9 versions & 1 rubygems

Version Path
hilbert-0.0.2700420 lib/hilbert/api/matrix_api.rb
hilbert-0.0.2700410 lib/hilbert/api/matrix_api.rb
hilbert-0.0.2700400 lib/hilbert/api/matrix_api.rb
hilbert-0.0.2700320 lib/hilbert/api/matrix_api.rb
hilbert-0.0.2700300 lib/hilbert/api/matrix_api.rb
hilbert-0.0.2700210 lib/hilbert/api/matrix_api.rb
hilbert-0.0.2700110 lib/hilbert/api/matrix_api.rb
hilbert-0.0.2700100 lib/hilbert/api/matrix_api.rb
hilbert-0.0.2700001 lib/hilbert/api/matrix_api.rb