class BOAST::Real

@!parse module VarFunctors; var_functorize Real; end

Attributes

getters[R]
setters[R]
signed[R]
size[R]
total_size[R]
vector_length[R]

Public Class Methods

new(hash={}) click to toggle source

Creates a new instance of Real. @param [Hash] hash contains named properties for the type @option hash [Integer] :size size of the Real type in byte. By default {BOAST.get_default_real_size}. @option hash [Integer] :vector_length length of the vector of Real. By default 1.

# File lib/BOAST/Language/DataTypes.rb, line 88
def initialize(hash={})
  if hash[:size] then
    @size = hash[:size]
  else
    @size = get_default_real_size
  end
  if hash[:vector_length] and hash[:vector_length] > 1 then
    @vector_length = hash[:vector_length]
  else
    @vector_length = 1
  end
  @total_size = @size*@vector_length
  @signed = true
end

Public Instance Methods

==(t) click to toggle source
# File lib/BOAST/Language/DataTypes.rb, line 79
def ==(t)
  return true if t.class == self.class and t.size == size and t.vector_length == vector_length
  return false
end
copy(options={}) click to toggle source
# File lib/BOAST/Language/DataTypes.rb, line 111
def copy(options={})
  hash = to_hash
  options.each { |k,v|
    hash[k] = v
  }
  return Real::new(hash)
end
decl() click to toggle source
# File lib/BOAST/Language/DataTypes.rb, line 119
def decl
  return "real(kind=#{@size})" if lang == FORTRAN
  if [C, CL, CUDA].include?( lang ) and @vector_length == 1 then
    return "float" if @size == 4
    return "double" if @size == 8
  elsif lang == C and @vector_length > 1 then
    return get_vector_decl(self)
  elsif [CL, CUDA].include?( lang ) and @vector_length > 1 then
    return "float#{@vector_length}" if @size == 4
    return "double#{@vector_length}" if @size == 8
  end
end
decl_ffi() click to toggle source
# File lib/BOAST/Language/DataTypes.rb, line 132
def decl_ffi
  return :float if @size == 4
  return :double if @size == 8
end
signed?() click to toggle source
# File lib/BOAST/Language/DataTypes.rb, line 103
def signed?
  return signed
end
suffix() click to toggle source
# File lib/BOAST/Language/DataTypes.rb, line 137
def suffix
  s = ""
  if [C, CL, CUDA].include?( lang ) then
    s << "f" if @size == 4
  elsif lang == FORTRAN then
    s << "_wp" if @size == 8
  end
  return s
end
to_hash() click to toggle source
# File lib/BOAST/Language/DataTypes.rb, line 107
def to_hash
  return { :size => @size, :vector_length => @vector_length }
end