A Simple and Practical Linear Algebra Library Interface with Static Size Checking

被引:6
作者
Abe, Akinori [1 ]
Sumii, Eijiro [1 ]
机构
[1] Tohoku Univ, Grad Sch Informat Sci, Sendai, Miyagi 980, Japan
关键词
D O I
10.4204/EPTCS.198.1
中图分类号
TP301 [理论、方法];
学科分类号
081202 ;
摘要
Linear algebra is a major field of numerical computation and is widely applied. Most linear algebra libraries (in most programming languages) do not statically guarantee consistency of the dimensions of vectors and matrices, causing runtime errors. While advanced type systems-specifically, dependent types on natural numbers-can ensure consistency among the sizes of collections such as lists and arrays [3, 4, 22], such type systems generally require non-trivial changes to existing languages and application programs, or tricky type-level programming. We have developed a linear algebra library interface that verifies the consistency (with respect to dimensions) of matrix operations by means of generative phantom types, implemented via fairly standard ML types and module system. To evaluate its usability, we ported to it a practical machine learning library from a traditional linear algebra library. We found that most of the changes required for the porting could be made mechanically, and changes that needed human thought are minor.
引用
收藏
页码:1 / 21
页数:21
相关论文
共 18 条
[1]  
[Anonymous], LAPACK LIN ALG PACKA
[2]  
Blume M., 2001, Electronic Notes in Theoretical Computer Science, V59, DOI 10.1016/S1571-0661(05)80452-9
[3]  
Braibant T, 2010, LECT NOTES COMPUT SC, V6172, P163, DOI 10.1007/978-3-642-14052-5_13
[4]  
Cui S, 2005, LECT NOTES COMPUT SC, V3717, P310
[5]  
Danvy O., 1998, Journal of Functional Programming, V8, P621, DOI 10.1017/S0956796898003104
[6]  
Eaton Frederik, 2006, P 2006 ACM SIGPLAN W, P120, DOI [10.1145/1159842.1159859, DOI 10.1145/1159842.1159859]
[7]   Phantom types and subtyping [J].
Fluet, Matthew ;
Pucella, Riccardo .
JOURNAL OF FUNCTIONAL PROGRAMMING, 2006, 16 :751-791
[8]  
Galassi Mark, GNU SCI LIB GSL
[9]  
Hinze R., 2003, FUN PROGRAMMING, P245
[10]   Lightweight Static Capabilities [J].
Kiselyov, Oleg ;
Shan, Chung-chieh .
ELECTRONIC NOTES IN THEORETICAL COMPUTER SCIENCE, 2007, 174 (07) :79-104