Sparse matrix bug?

Joseph Turian <[email protected]> Tue, 10 Jan 2006 01:07:17 -0500
Newsgroups gmane.comp.lib.mtl.devel
Message-ID <[email protected]>
Dear MTL developers,

I recently downloaded mtl-2.1.2-22, which I'm using with gcc 4.0.1.

I've noticed some strange behavior with sparse matrices.
Please observe the output from the following code.
I expect that both multiplications should yield [-0.6,0], however that is
NOT the result given by the first operation, before the zeroes in the matrix
have been specified. Instead, the first operation gives [-0.6,-0.6]

Perhaps I misunderstand how to achieve the desired sparse matrix
multiplication?

Thank you for your help

   Joseph


===

#include <iostream>

using namespace std;

#include <mtl/matrix.h>
#include <mtl/mtl.h>
#include <mtl/utils.h>
#include <mtl/linalg_vec.h>

using namespace mtl;

int main() {
        typedef matrix<double, rectangle<>, compressed<>, row_major>::type
XMat;

        unsigned N = 2;

        XMat x(N, N);
        dense1D<double> y(N), g(N);

        x(0,0) = 1;
        x(1,1) = 1;

        y[0] = 1;
        y[1] = 1;

        mtl::set(g, 0);
        mtl::add(g, mtl::scaled(x[0], -0.6), g);
        print_vector(g);

        x(0, 1) = 0;
        x(1, 0) = 0;

        mtl::set(g, 0);
        mtl::add(g, mtl::scaled(x[0], -0.6), g);
        print_vector(g);

        return 1;
}

===



--
http://www.cs.nyu.edu/~turian/

_______________________________________________
This list is archived at http://www.osl.iu.edu/MailArchives/mtl-devel/