Lazy linear algebra

Lazy Linear Algebra

I wonder if any of the LtU readers would be able to advise me about
lazy languages/libraries for LinearAlgebra.html">linear algebra (vector-matrix numerics). It
strikes me that this is an problem domain in which the lazy approach
might be able to offer significant advantages. For example, it is
often the case that one wants to obtain certain elements of a matrix
resulting from some expression (e.g. one or more rows or columns, or
some elements from some row(s) or column(s)). Linear algebra can be
computationally expensive, especially if you don't want all the
values that would be computed by a naive implementation of some
expression. The lazy approach might be particularly useful if you
don't know a priori which elements you are going to need (e.g.
if the answer you seek depends upon the properties of the matrices in
question, which you may not know until you start in on the
calculations). It is certainly true that one could hand-code this
kind of laziness, but that way lies bugs and hard work on the part of
the programmer. Further, certain matrix operations yield matrices
with properties that could be lazily exploited (e.g. symmetric
matrices may be specified by only the upper or lower triangle),
yielding potential time and space savings. I realise that libraries
such as LAPACK contain
functions that exploit the properties of the matrices, but I
understand that it is the programmer who decides which functions
should be called rather than the machine. As someone with no formal
PL education, can anyone tell me what if any research has been done
on lazy linear algebra and how I might start playing around in such
an area?

(posted for Chris Rose)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Lazy matrices and streams

The LinAlg C++ library used lazy matrices extensively. Indeed it is possible to write
  Matrix haar = haar_matrix(5);
  Matrix unitm = unit(haar);
  Matrix haar_t = transposed(haar);
  Matrix hht = haar * haar_t;           // NB! And it's efficient!

without paying any penalty for copying matrices to and fro, and without reference counting and writing one's own garbage collector. In the example above, in all the cases the matrices are computer right in place. The library does not use templates (because it was developed at the time when GCC did not support templates well, or at all). Some of the library users considered that a feature. The LinAlg library also defined a variety of matrix streams (over (parts of) rows, columns, the diagonal, a matrix block).


Thanks Oleg---that was useful.