cristicbz / scid

Scientific library for the D programming language
Boost Software License 1.0
23 stars 8 forks source link

DiagonalMatrix / Scalar #81

Open dsimcha opened 12 years ago

dsimcha commented 12 years ago
import scid.matvec;

void main() {
    auto m = DiagonalMatrix!double([1.0, 2, 3]);
    eval(m / 3.0);
}

scid\ops\expression.d(403): Error: static assert "Types 'BasicMatrix!(BasicDiagonalMatrixStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),cast(DiagonalMatrixStorageType)0))' and 'double' do not define a promotion. " scid\ops\expression.d(376): instantiated from here: PromotionImpl!(BasicMatrix!(BasicDiagonalMatrixStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),cast(DiagonalMatrixStorageType)0)),double) scid\ops\expression.d(312): instantiated from here: Promotion!(BasicMatrix!(BasicDiagonalMatrixStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),cast(DiagonalMatrixStorageType)0)),double) scid\ops\eval.d(70): instantiated from here: ExpressionResult!(Expression!(op,BasicMatrix!(BasicDiagonalMatrixStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),cast(DiagonalMatrixStorageType)0)),Expression!(op,double,double))) test.d(5): instantiated from here: eval!(Expression!(op,BasicMatrix!(BasicDiagonalMatrixStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),cast(DiagonalMatrixStorageType)0)),Expression!(op,double,double)))

cristicbz commented 12 years ago

Yeah, like I mentioned in a commit message, DiagonalMatrices are in need of quite a bit of attention, they were left behind in a refactoring a while back - should I prioritise it higher? I actually didn't think they would be this useful, but you seem to be using them quite a bit.

dsimcha commented 12 years ago

I've been working on integrating Dstats into SciD (definitely still a work in progress) and I need diagonal matrices for singular value decomposition and weighted least squares regression. That's where all this is coming from. Overall, though, I don't think diagonal matrices are that high a priority. I just seem to have stumbled on the few use cases where they're needed lately. Just to give a complete answer, here are the things I would put ahead of diagonal matrices, in order of priority. Maybe this should be on the wiki, too, with anything you would add:

  1. Lapack wrappers for basic matrix factorizations. I'm already working on this slowly but surely. SVD and Cholesky are there already because those are the two I happened to have an urgent need for. I want to get around to QR factorization, eigenvalue decomposition, and LU decomposition. I understand that inv(m) * v uses LU decomposition under the hood, but I think it should still be exposed in scid.linalg.
  2. Improving the tests. scid.demo seems to have tests, but they're just not run. I know OPTLINK gets in the way here, though.
  3. Misc. bug fixes.
  4. Fixing symmetric and triangular matrix operations. These are basically unusable right now IIRC. (I haven't really tried to use them because the few things I did try were so horribly broken that I figured they were still a work in progress.)
  5. Benchmarking/performance improvements.