cristicbz / scid

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

ArrayErrorMessages/MatrixErrorMessages #64

Closed dsimcha closed 12 years ago

dsimcha commented 12 years ago

Did this somehow get broken when you refactored error handling? ArrayErrorMessages and MatrixErrorMessages apparently aren't defined anywhere in the source tree. When I grep it, they only appear in diagonalmat.d.

import scid.matvec;

 void main() {
     auto foo = DiagonalMatrix!double(5);
 }

scid\storage\diagonalmat.d(393): Error: mixin scid.storage.diagonalmat.DiagonalMatrixSubVectorStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),transposeVectorType).DiagonalMatrixSubVectorStorage.ArrayErrorMessages!() is not defined scid\storage\diagonalmat.d(273): Error: template instance scid.storage.diagonalmat.DiagonalMatrixSubVectorStorage!(RefCounted!(CowArray!(double),cast (RefCountedAutoInitialize)1),transposeVectorType) error instantiating scid\storage\diagonalmat.d(33): instantiated from here: DiagonalMatrixSubVectorStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),cast(VectorType)1) scid\storage\diagonalmat.d(18): instantiated from here: BasicDiagonalMatrixStorage!(RefCounted!(CowArray!(double),cast(RefCountedAutoInitialize)1),cast(DiagonalMatrixStorageType)0) scid\matrix.d(140): instantiated from here: DiagonalMatrixStorage!(double) test9.d(4): instantiated from here: DiagonalMatrix!(double)

cristicbz commented 12 years ago

Yes, when I refactored the error handling, diagonal matrices got left behind. It's a bit tedious, but I'll try to get around to it this weekend.

dsimcha commented 12 years ago

If you're not going to get around to this soon, can you give me some quick hints about how this works/what needs to be done so I can fix it myself?

cristicbz commented 12 years ago

Sorry about that, I actually already fixed the error messages themselves, but diagonal matrices do not work at all - I haven't really updated them in a long time, and they don't have promotions defined, so no operation works on them. I'll try adding a quick fix, but properly finish them up will have to wait, I'm afraid. I'll send my commit in a few hours. I actually have a question - does this work on your end?

void main() { auto w = SymmetricMatrix!double([[1.,2.,3.,4],[1.,2.,3.,4],[1.,2.,3.,4],[1.,2.,3.,4]]); eval(w*w); }

This crashes at runtime on my computer, but I was sure this worked before - I reinstalled everything from compiler to IDE at some point - and I don't know if it's the compiler or my code any more.

dsimcha commented 12 years ago

Doesn't work on my end either. I tested on both Windows and Linux and on both DMD and GDC. Possibly related to issue 63, which gives a similar error message. Interestingly, though, the GDC error message is completely different than the DMD one. (Please don't be another destructor issue).

GDC error message (GDC doesn't do stack traces yet):

dsimcha@pippin:~/bin$ gdmd test.d -L-lblas -L-llapack -g
dsimcha@pippin:~/bin$ ./test
core.exception.AssertError@/cis/home/dsimcha/apps/gdc/include/d2/4.6.1/std/typecons.d(2487): Assertion failure

The relevant assert is in the destructor of RefCounted and checks that the reference count is >0 before decrementing it. Note, though, that GDC is still on DMD 2.055's front end, so if there were any d'tor bugs fixed between 2.055 and 2.056 (I'm not aware of any off the top of my head) then this could be a red herring.

DMD error message (with monstrous stack trace):

dsimcha@pippin:~/bin$ dmd test.d -L-lblas -L-llapack -g
dsimcha@pippin:~/bin$ ./test
core.exception.AssertError@/cis/home/dsimcha/customd/scid/internal/assertmessages.d(123): Dimension mismatch in matrix assignment: lhsDims = (0, 0), rhsDims = (4, 4)
----------------
./test(_d_assert_msg+0x1f) [0x5d6227]
./test(const(void function(ulong, ulong)) scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix.MatrixChecks!().checkAssignDims_+0xec) [0x5af5a0]
./test(void scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix.resize(ulong, ulong, void*)+0x52) [0x5ae7ca]
./test(void scid.ops.fallback.__T21fallbackMatrixProductVE4scid3ops4eval9Transpose0VE4scid3ops4eval9Transpose0TS4scid6matrix355__T11BasicMatrixTS4scid7storage9packedmat295__T13PackedStorageTS4scid7storage9symmetric225__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z21SymmetricArrayAdapterZ13PackedStorageZ11BasicMatrixTS4scid6matrix355__T11BasicMatrixTS4scid7storage9packedmat295__T13PackedStorageTS4scid7storage9symmetric225__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z21SymmetricArrayAdapterZ13PackedStorageZ11BasicMatrixTdTS4scid6matrix355__T11BasicMatrixTS4scid7storage9packedmat295__T13PackedStorageTS4scid7storage9symmetric225__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z21SymmetricArrayAdapterZ13PackedStorageZ11BasicMatrixZ.fallbackMatrixProduct(double, ref scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix, ref scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix, double, ref scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix)+0x85) [0x5cfe51]
./test(void scid.ops.eval.__T17evalMatrixProductVE4scid3ops4eval9Transpose0VE4scid3ops4eval9Transpose0TdTdTS4scid6matrix355__T11BasicMatrixTS4scid7storage9packedmat295__T13PackedStorageTS4scid7storage9symmetric225__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z21SymmetricArrayAdapterZ13PackedStorageZ11BasicMatrixTS4scid6matrix355__T11BasicMatrixTS4scid7storage9packedmat295__T13PackedStorageTS4scid7storage9symmetric225__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z21SymmetricArrayAdapterZ13PackedStorageZ11BasicMatrixTS4scid6matrix355__T11BasicMatrixTS4scid7storage9packedmat295__T13PackedStorageTS4scid7storage9symmetric225__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z21SymmetricArrayAdapterZ13PackedStorageZ11BasicMatrixZ.evalMatrixProduct(double, ref scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix, ref scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix, double, ref scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix)+0x105) [0x5cfd79]
./test(void scid.ops.eval.__T8evalCopyVE4scid3ops4eval9Transpose0TS4scid3ops10expression795__T10ExpressionVAyaa1_2aTS4scid6matrix355__T11BasicMatrixTS4scid7storage9packedmat295__T13PackedStorageTS4scid7storage9symmetric225__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z21SymmetricArrayAdapterZ13PackedStorageZ11BasicMatrixTS4scid6matrix355__T11BasicMatrixTS4scid7storage9packedmat295__T13PackedStorageTS4scid7storage9symmetric225__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z21SymmetricArrayAdapterZ13PackedStorageZ11BasicMatrixZ10ExpressionTS4scid6matrix355__T11BasicMatrixTS4scid7storage9packedmat295__T13PackedStorageTS4scid7storage9symmetric225__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z21SymmetricArrayAdapterZ13PackedStorageZ11BasicMatrixZ.evalCopy(ref scid.ops.expression.Expression!("*", scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix, scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix).Expression, ref scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix)+0x40) [0x5cfc20]
./test(scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix scid.ops.eval.eval!(scid.ops.expression.Expression!("*", scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix, scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix).Expression).eval(scid.ops.expression.Expression!("*", scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix, scid.matrix.BasicMatrix!(scid.storage.packedmat.PackedStorage!(scid.storage.symmetric.__T21SymmetricArrayAdapterTS3std8typecons108__T10RefCountedTS4scid7storage8cowarray15__T8CowArrayTdZ8CowArrayVE3std8typecons24RefCountedAutoInitialize1Z10RefCountedVE4scid6matrix14MatrixTriangle0VE4scid6matrix12StorageOrder1Z.SymmetricArrayAdapter).PackedStorage).BasicMatrix).Expression)+0x30) [0x5cfba0]
./test(_Dmain+0x1ea) [0x596f26]
./test(extern (C) int rt.dmain2.main(int, char**).void runMain()+0x17) [0x5d6833]
./test(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x2a) [0x5d63da]
./test(extern (C) int rt.dmain2.main(int, char**).void runAll()+0x42) [0x5d6886]
./test(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x2a) [0x5d63da]
./test(main+0xd3) [0x5d636b]
/lib/libc.so.6(__libc_start_main+0xfd) [0x7f2631b06c4d]
----------------
cristicbz commented 12 years ago

Hmmm, at least you get a proper stack trace. On my end, it reports completely wrong lines. I'll file an issue and look at it later. In the meantime, I committed the quick fix I promised. I ran the dMatOpsTest for DiagonalMatrix and it worked - but I'd still be careful when using any matrix type other than general matrices.