Skip to content

Commit

Permalink
🎨 Standarize code ./scripts directory
Browse files Browse the repository at this point in the history
  • Loading branch information
WaKeMaTTa committed Apr 3, 2019
1 parent 85ea86d commit f6c890c
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 91 deletions.
1 change: 0 additions & 1 deletion scripts/switch_lapack_ubuntu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def run(cmd)
system cmd
end


run "update-alternatives --set liblapack.so.3 #{lapack_prefix}/liblapack.so.3"
run "update-alternatives --set liblapack.so #{lapack_prefix}/liblapack.so"
run "update-alternatives --set libblas.so.3 #{blas_prefix}/libblas.so.3"
Expand Down
174 changes: 84 additions & 90 deletions scripts/ttable_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,113 +3,107 @@
# A helper file for generating and maintaining template tables.

DTYPES = [
:uint8_t,
:int8_t,
:int16_t,
:int32_t,
:int64_t,
:float32_t,
:float64_t,
:'nm::Complex64',
:'nm::Complex128',
:'nm::RubyObject'
]
:uint8_t,
:int8_t,
:int16_t,
:int32_t,
:int64_t,
:float32_t,
:float64_t,
:'nm::Complex64',
:'nm::Complex128',
:'nm::RubyObject',
]

def nullify(disabled = []) #:nodoc:
DTYPES.map { |t| if disabled.include?(t) then :NULL else t end }
DTYPES.map { |t| disabled.include?(t) ? :NULL : t }
end

ITYPES = [
:uint8_t,
:uint16_t,
:uint32_t,
:uint64_t
]
:uint8_t,
:uint16_t,
:uint32_t,
:uint64_t,
]

EWOPS = [
:'nm::EW_ADD',
:'nm::EW_SUB',
:'nm::EW_MUL',
:'nm::EW_DIV',
:'nm::EW_POW',
:'nm::EW_MOD',
:'nm::EW_EQEQ',
:'nm::EW_NEQ',
:'nm::EW_LT',
:'nm::EW_GT',
:'nm::EW_LEQ',
:'nm::EW_GEQ'
]
:'nm::EW_ADD',
:'nm::EW_SUB',
:'nm::EW_MUL',
:'nm::EW_DIV',
:'nm::EW_POW',
:'nm::EW_MOD',
:'nm::EW_EQEQ',
:'nm::EW_NEQ',
:'nm::EW_LT',
:'nm::EW_GT',
:'nm::EW_LEQ',
:'nm::EW_GEQ',
]

LR_ALLOWED = {
:uint8_t => DTYPES,
:int8_t => DTYPES,
:int16_t => DTYPES,
:int32_t => DTYPES,
:int64_t => DTYPES,
:float32_t => DTYPES,
:float64_t => DTYPES,
:'nm::Complex64' => DTYPES,
:'nm::Complex128' => DTYPES,
:'nm::RubyObject' => DTYPES
uint8_t: DTYPES,
int8_t: DTYPES,
int16_t: DTYPES,
int32_t: DTYPES,
int64_t: DTYPES,
float32_t: DTYPES,
float64_t: DTYPES,
'nm::Complex64': DTYPES,
'nm::Complex128': DTYPES,
'nm::RubyObject': DTYPES,
}

lines =
case ARGV[0]
when 'OPLR'
'{' +
EWOPS.map do |op|

'{' +
DTYPES.map do |l_dtype|

'{' +
LR_ALLOWED[l_dtype].map do |r_dtype|
if r_dtype == :NULL
'NULL'
else
"fun<#{op}, #{l_dtype}, #{r_dtype}>"
end
end.join(', ') +
'}'

end.join(",\n") +
'}'

end.join(",\n") +
'}'

when 'OPID'
'{' +
EWOPS.map do |op|
'{' +
ITYPES.map do |itype|
'{' +
DTYPES.map do |dtype|

if dtype == :NULL
'NULL'
else
"fun<#{op}, #{itype}, #{dtype}>"
end

end.join(",") +
'}'
end.join(",\\\n") +
'}'
end.join(",\\\n") +
'}'

when 'LR'
'{' + DTYPES.map do |l_dtype|
'{' + LR_ALLOWED[l_dtype].map do |r_dtype|
when "OPLR"
"{" +
EWOPS.map { |op|
"{" +
DTYPES.map { |l_dtype|
"{" +
LR_ALLOWED[l_dtype].map { |r_dtype|
if r_dtype == :NULL
"NULL"
else
"fun<#{op}, #{l_dtype}, #{r_dtype}>"
end
}.join(", ") +
"}"
}.join(",\n") +
"}"
}.join(",\n") +
"}"

when "OPID"
"{" +
EWOPS.map { |op|
"{" +
ITYPES.map { |itype|
"{" +
DTYPES.map { |dtype|
if dtype == :NULL
"NULL"
else
"fun<#{op}, #{itype}, #{dtype}>"
end
}.join(",") +
"}"
}.join(",\\\n") +
"}"
}.join(",\\\n") +
"}"

when "LR"
"{" + DTYPES.map { |l_dtype|
"{" + LR_ALLOWED[l_dtype].map { |r_dtype|
if r_dtype == :NULL
'NULL'
"NULL"
else
"fun<#{l_dtype}, #{r_dtype}>"
end
end.join(', ') + '}'
end.join(",\n") + '}'
}.join(", ") + "}"
}.join(",\n") + "}"
end

puts lines

0 comments on commit f6c890c

Please sign in to comment.