Skip to main content

Matrices as Arrows!

A Biproduct Approach to Typed Linear Algebra

  • Conference paper
Mathematics of Program Construction (MPC 2010)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 6120))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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)

    Chapter  Google Scholar 

  2. 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)

    Google Scholar 

  3. de Geijn, R.A.V., Quintana-Ortí, E.S.: The Science of Programming Matrix Computations (2008), http://www.lulu.com

  4. 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)

    Google Scholar 

  5. 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)

    Google Scholar 

  6. MacLane, S.: Categories for the Working Mathematician (Graduate Texts in Mathematics). Springer, Heidelberg (September 1998)

    Google Scholar 

  7. 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)

    Google Scholar 

  8. Bloom, S., Sabadini, N., Walters, R.: Matrices, machines and behaviors. Applied Categorical Structures 4(4), 343–360 (1996)

    Article  MATH  MathSciNet  Google Scholar 

  9. Allenby, R.B.J.T.: Linear Algebra. Elsevier, Amsterdam (1995)

    Google Scholar 

  10. Tarski, A., Givant, S.: A Formalization of Set Theory without Variables. In: AMS, Providence, Rhode Island, vol. 41. AMS Col. Pub, Washington (1987)

    Google Scholar 

  11. Frias, M.: Fork algebras in algebra, logic and computer science, Logic and Computer Science. World Scientific Publishing Co., Singapore (2002)

    Book  Google Scholar 

  12. Wolfram, S., et al.: Mathematica: a system for doing mathematics by computer. Addison-Wesley, New York (1988)

    MATH  Google Scholar 

  13. 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)

    Google Scholar 

  14. Goto, K., Geijn, R.A.v.d.: Anatomy of high-performance matrix multiplication. ACM Trans. Math. Softw. 34(3), 1–25 (2008)

    Article  Google Scholar 

  15. 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)

    Google Scholar 

  16. MacLane, S., Birkhoff, G.: Algebra. AMS Chelsea (1999)

    Google Scholar 

  17. Altenkirch, T., Chapman, J., Uustalu, T.: Monads need not be endofunctors. In: Foundations of Software Science and Computational Structures, pp. 297–311 (2010)

    Google Scholar 

  18. 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)

    Google Scholar 

  19. Backhouse, R.: Mathematics of Program Construction, Univ. of Nottingham, Draft of book in preparation, 608 pages (2004)

    Google Scholar 

  20. Voronenko, Y.: Library Generation for Linear Transforms. PhD thesis, Electrical and Computer Engineering, Carnegie Mellon University (2008)

    Google Scholar 

  21. 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)

    Chapter  Google Scholar 

  22. Magnus, J., Neudecker, H.: The commutation matrix: Some properties and applications. The Annals of Statistics 7(2), 381–394 (1979)

    Article  MATH  MathSciNet  Google Scholar 

  23. Dos̆en, K., Petrić, Z.: Self-adjunctions and matrices. Journal of Pure and Applied Algebra 184, 7–39 (2003)

    Article  MATH  MathSciNet  Google Scholar 

  24. Macedo, H.D., Oliveira, J.N.: Exploring self-adjunctions in vectorization (2010) (in preparation)

    Google Scholar 

  25. 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)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics