3

I have 2 questions related to comparing character vectors in Dyalog APL. The following code will compare character vectors one-by-one:

a←'ATCG'
b←'GTCA'
a=b
  • In order to speed up (in case of 2 vectors, as well as in case of comparing many vectors to a single vector), should I convert character vector to a numeric vector or it won't matter in APL (similar to comparing chars in C)?
  • I am comparing DNA sequences (which may consist of letter from the ATCG alphabet only). Is there anything I can do to speed up various operations on such vectors?
4

1 回答 1

1

有趣的是,在我的(旧)版本的 Dyalog APL 上,将字符转换为小整数实际上运行速度快了 25%。这可能在最近的版本中得到了加速。

尝试

a <- []av iota 'ATCG'   // sorry, no apl characters
b <- []av iota 'GTCA'
a = b

确保最大值小于 128。

要检查您是否具有最小可能的整数表示,请使用 []dr 函数。[]dr a 应该为整数 -128 <= x <= 127 返回 82。

Dyalog APL 将自动转换为可能的最低整数宽度。

于 2014-08-07T09:17:26.343 回答