Hello,

I'm having some trouble with some matrix calculations in SAGE. I'd
like to find the kernel of some matrices, but I think I'm doing
something wrong, because it's very slow.

For example:
sage: M = matrix(RDF, 200,400, lambda i,j: i+j)
sage: %time M.right_kernel()
CPU times: user 379.39 s, sys: 0.55 s, total: 379.94 s
Wall time: 380.66 s
Vector space of degree 400 and dimension 398 over Real Double Field
Basis matrix:
398 x 400 dense matrix over Real Double Field

whereas, say, this small C++ program using the Eigen2 libraries:
#include <Eigen/Eigen>
using namespace Eigen;
int main()
{
    MatrixXd m(200,400);
    for(int i = 0; i < 200; ++i)
        for(int j = 0; j < 400; ++j)
            m(i,j) = i+j;
    LU<MatrixXd> lu(m);
    MatrixXd ker(m.rows(), lu.dimensionOfKernel());
    lu.computeKernel(&ker);
    return 0;
}

does the following:
time ./matrix

real    0m0.014s
user    0m0.000s
sys     0m0.010s

Is there something I'm missing about how to use the SAGE matrix
classes? Five orders of magnitude faster in C++ seems a bit surprising
to me; perhaps SAGE isn't reaching ATLAS or numpy or whatever it's
supposed to use internally?

Henry de Valence

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to