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.



1087
1088
1089
1090
# File 'lib/BOAST/Algorithm.rb', line 1087

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

Instance Method Details

#to_s ⇒ Object



1091
1092
1093
# File 'lib/BOAST/Algorithm.rb', line 1091

def to_s
  self.to_str
end

#to_str ⇒ Object



1094
1095
1096
1097
# File 'lib/BOAST/Algorithm.rb', line 1094

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



1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
# File 'lib/BOAST/Algorithm.rb', line 1110

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

#to_str_fortran ⇒ Object



1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
# File 'lib/BOAST/Algorithm.rb', line 1098

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