Question about Lusol_obj.repcol
zhehu opened this issue · comments
I met a problem in testing lusol_obj.repcol().
I replace one column of matrix A with itself, then recalculate sum of elements in the matrix. Result1 and result2 are always same. But sometimes result2 becomes NaN. When scale of A is bigger as 1000, result will never be correct.
Here is my code in Matlab:
n = 20;
A = sprand(n,n,0.2)/10+speye(n);
lu_options = lusol_obj.luset('nzinit',200000,'pivot','TCP');
one_vector = ones(n,1);
mylu = lusol_obj(A,lu_options);
result1 = one_vector'*mylu.mulA(one_vector)
mylu.repcol(A(:,10),10); %replace col 10 with himself
result2 = one_vector'*mylu.mulA(one_vector)
result:
test2
result1 =
54.5849
result2 =
54.5849
test2
result1 =
53.1647
result2 =
8.4224e+252
Version of MATLAB, and make matlab_test:
< M A T L A B (R) >
Copyright 1984-2012 The MathWorks, Inc.
R2012b (8.0.0.783) 64-bit (maci64)
August 22, 2012
test_addcol_lhr02: passed
test_addrow_lhr02: passed
test_delcol_lhr02: passed
test_delrow_lhr02: passed
test_factorize_lhr02: passed
test_mulA_lhr02: passed
test_mulAt_lhr02: passed
test_r1mod_lhr02: passed
test_repcol_lhr02: passed
test_reprow_lhr02: passed
test_solveA_lhr02: passed
test_solveAt_lhr02: passed
and I also tested it in ubuntu 13.04, matlab R2012b. Same problem exist.
$ gfortran --version
GNU Fortran (GCC) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.
Thanks for reporting this. It turned out to be a problem passing a sparse vector into the repcol
method. I've updated lusol_obj.m
to densify all input vectors. Please give it a try. If things seem to work for you, I will post another release.
It works! thank you!