Abstract
Motivated by the need to formalize generation of fast running code for linear algebra applications, we show how an index-free, calculational approach to matrix algebra can be developed by regarding matrices as morphisms of a category with biproducts. This shifts the traditional view of matrices as indexed structures to a type-level perspective analogous to that of the pointfree algebra of programming. The derivation of fusion, cancellation and abide laws from the biproduct equations makes it easy to calculate algorithms implementing matrix multiplication, the kernel operation of matrix algebra, ranging from its divide-and-conquer version to the conventional, iterative one.
From errant attempts to learn how particular products and coproducts emerge from biproducts, we not only rediscovered block-wise matrix combinators but also found a way of addressing other operations calculationally such as e.g. Gaussian elimination. A strategy for addressing vectorization along the same lines is also given.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Franchetti, F., de Mesmay, F., McFarlin, D., Püschel, M.: Operator language: A program generation framework for fast kernels. In: Taha, W.M. (ed.) Domain-Specific Languages. LNCS, vol. 5658, pp. 385–409. Springer, Heidelberg (2009)
Püschel, M., Moura, J.M.F., Johnson, J., Padua, D., Veloso, M., Singer, B.W., Xiong, J., Franchetti, F., Gačić, A., Voronenko, Y., Chen, K., Johnson, R.W., Rizzolo, N.: SPIRAL: Code generation for DSP transforms. Proceedings of the IEEE, special issue on Program Generation, Optimization, and Adaptation 93(2), 232–275 (2005)
de Geijn, R.A.V., Quintana-Ortí, E.S.: The Science of Programming Matrix Computations (2008), http://www.lulu.com
Jones, S.P., Hughes, J., Augustsson, L., Barton, D., Boutel, B., Burton, W., Fasel, J., Hammond, K., Hinze, R., Hudak, P., Johnsson, T., Jones, M., Launchbury, J., Meijer, E., Peterson, J., Reid, A., Runciman, C., Wadler, P.: Report on the programming language Haskell 98 — a non-strict, purely functional language. Technical report (February 1999)
Bird, R., de Moor, O.: Algebra of Programming. In: Hoare, C.A.R. (series ed.). Series in Computer Science. Prentice-Hall International, Englewood Cliffs (1997)
MacLane, S.: Categories for the Working Mathematician (Graduate Texts in Mathematics). Springer, Heidelberg (September 1998)
Macedo, H., Oliveira, J.: Matrices as arrows: a typed approach to linear algebra, Extended abstract. In: CALCO-JNR Workshop, September 6-10, Udine, Italy (2009)
Bloom, S., Sabadini, N., Walters, R.: Matrices, machines and behaviors. Applied Categorical Structures 4(4), 343–360 (1996)
Allenby, R.B.J.T.: Linear Algebra. Elsevier, Amsterdam (1995)
Tarski, A., Givant, S.: A Formalization of Set Theory without Variables. In: AMS, Providence, Rhode Island, vol. 41. AMS Col. Pub, Washington (1987)
Frias, M.: Fork algebras in algebra, logic and computer science, Logic and Computer Science. World Scientific Publishing Co., Singapore (2002)
Wolfram, S., et al.: Mathematica: a system for doing mathematics by computer. Addison-Wesley, New York (1988)
Bird, R.: Lecture notes on constructive functional programming. In: Broy, M. (ed.) CMCS Int. Summer School directed by Bauer, F.L., et al. NATO Adv. Science Institute, Series F: Comp. and System Sciences, vol. 55, Springer, Heidelberg (1989)
Goto, K., Geijn, R.A.v.d.: Anatomy of high-performance matrix multiplication. ACM Trans. Math. Softw. 34(3), 1–25 (2008)
D’Alberto, P., Nicolau, A.: Adaptive Strassen’s matrix multiplication. In: ICS ’07: Proc. of the 21st annual int. conf. on Supercomputing. ACM, NY (2007)
MacLane, S., Birkhoff, G.: Algebra. AMS Chelsea (1999)
Altenkirch, T., Chapman, J., Uustalu, T.: Monads need not be endofunctors. In: Foundations of Software Science and Computational Structures, pp. 297–311 (2010)
Jeuring, J.: The derivation of hierarchies of algorithms on matrices. In: Moller, B. (ed.) Constructing Programs from Specifications, pp. 9–32. North-Holland, Amsterdam (1991)
Backhouse, R.: Mathematics of Program Construction, Univ. of Nottingham, Draft of book in preparation, 608 pages (2004)
Voronenko, Y.: Library Generation for Linear Transforms. PhD thesis, Electrical and Computer Engineering, Carnegie Mellon University (2008)
Oliveira, J.N.: Transforming data by calculation. In: Lämmel, R., Visser, J., Saraiva, J. (eds.) Generative and Transformational Techniques in Software Engineering II. LNCS, vol. 5235, pp. 134–195. Springer, Heidelberg (2008)
Magnus, J., Neudecker, H.: The commutation matrix: Some properties and applications. The Annals of Statistics 7(2), 381–394 (1979)
Dos̆en, K., Petrić, Z.: Self-adjunctions and matrices. Journal of Pure and Applied Algebra 184, 7–39 (2003)
Macedo, H.D., Oliveira, J.N.: Exploring self-adjunctions in vectorization (2010) (in preparation)
Sernadas, A., Ramos, J., Mateus, P.: Linear algebra techniques for deciding the correctness of probabilistic programs with bounded resources. Technical report, SQIG-IT and TU Lisbon, 1049-001 Lisboa, Portugal, — Short paper presented at LPAR 2008, Doha, Qatar. November 22-27 (2008)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2010 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Macedo, H.D., Oliveira, J.N. (2010). Matrices as Arrows!. In: Bolduc, C., Desharnais, J., Ktari, B. (eds) Mathematics of Program Construction. MPC 2010. Lecture Notes in Computer Science, vol 6120. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-13321-3_16
Download citation
DOI: https://doi.org/10.1007/978-3-642-13321-3_16
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-13320-6
Online ISBN: 978-3-642-13321-3
eBook Packages: Computer ScienceComputer Science (R0)