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.



1156
1157
1158
1159
# File 'lib/BOAST/Algorithm.rb', line 1156

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

Instance Method Details

#to_sObject



1160
1161
1162
# File 'lib/BOAST/Algorithm.rb', line 1160

def to_s
  self.to_str
end

#to_strObject



1163
1164
1165
1166
# File 'lib/BOAST/Algorithm.rb', line 1163

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_cObject



1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
# File 'lib/BOAST/Algorithm.rb', line 1179

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_fortranObject



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

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