I'm not particularly aligned with either decision direction. Though
there are some things to think about.
Comments in-line.
One of the things that needs to be considered is what happens when an
arithmetic method is given blas-based types that do not agree. At the
moment, this case is handled as the slow path (which is also the support
for the general case Matrix). Without this fallthrough, we need to come
up with a way to handle interactions between different blas-based types.
This might involve adding a wrapper type that is not-exported that acts
as a shim between these. We would still however have some fall-through
path.
> This extra support is not that big of a deal for simple functions like
> Add. However, we want to be able to provide good and fast
> implementations of advanced functions like Cholesky decomposition, QR
> factorization, etc. Most matrix implementations (numpy, matlab, etc.)
> call Lapack to compute these routines. Lapack itself builds off of
> BLAS, and we can recreate functions as necessary to support mat64. For
> example, I am close to having a working Cholesky decomposition. The
> problem is that the full Matrix cannot support coding in the Lapack
> style.
I don't think that we need to do this. At the moment, we have a Cholesky
that accepts a SymDense and an SVD that accepts a Dense - we require
that people call DenseCopyOf(m) if they are not providing an appropriate
type. For the more complex functions or functions where there is an
obvious reason to require a blas-based type, I think this approach is
fine.
> Matrices are often overwritten in-place with their types changed (so a
> Symmetric input will be overwritten to be a Triangular output), which
> is not supported via the interface. Additionally, Lapack routines
> typically need to take matrix "views", which is not supported with the
> Matrix interface. These issues prevent us from just implementing a
> "Matrix" version of lapack (that uses At and Set instead of a direct
> access). Instead we'll need to code these by hand (as is currently
> done in QR). I think this will severely hamper our ability to provide
> advanced functions in the package, as we will need to implement both
> the efficient Lapack call and also figure out how to implement it by
> hand without using View.
The way that lapack does this is intrinsically unsafe. If we want to
mimic it, unsafe will do that for us if we accept the comment above as
reasonable.