Class: BOAST::ConstArray

Inherits:
Array
  • Object
show all
Defined in:
lib/BOAST/Algorithm.rb

Instance Method Summary collapse

Constructor Details

#initialize(array, type = nil) ⇒ ConstArray

Returns a new instance of ConstArray.



1143
1144
1145
1146
# File 'lib/BOAST/Algorithm.rb', line 1143

def initialize(array,type = nil)
  super(array)
  @type = type::new if type
end

Instance Method Details

#to_s ⇒ Object



1147
1148
1149
# File 'lib/BOAST/Algorithm.rb', line 1147

def to_s
  self.to_str
end

#to_str ⇒ Object



1150
1151
1152
1153
# File 'lib/BOAST/Algorithm.rb', line 1150

def to_str
  return self.to_str_fortran if BOAST::get_lang == FORTRAN
  return self.to_str_c if [C, CL, CUDA].include?( BOAST::get_lang )
end

#to_str_c ⇒ Object



1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
# File 'lib/BOAST/Algorithm.rb', line 1166

def to_str_c
  s = ""
  return s if self.first.nil?
  s += "{\n"
  s += self.first 
  self[1..-1].each { |v|
    s += ",\n"+v
  }
  s += "}"
end

#to_str_fortran ⇒ Object



1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
# File 'lib/BOAST/Algorithm.rb', line 1154

def to_str_fortran
  s = ""
  return s if self.first.nil?
  s += "(/ &\n"
  s += self.first
  s += "_wp" if @type and @type.size == 8
  self[1..-1].each { |v|
    s += ", &\n"+v
    s += "_wp" if @type and @type.size == 8
  }
  s += " /)"
end