1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Copyright (C) INRIA 3// Copyright (C) 2012 - 2016 - Scilab Enterprises 4// Copyright (C) 2020 - Samuel GOUGEON 5// 6// This file is hereby licensed under the terms of the GNU GPL v2.0, 7// pursuant to article 5.3.4 of the CeCILL v.2.1. 8// This file was originally licensed under the terms of the CeCILL v2.1, 9// and continues to be available under such terms. 10// For more information, see the COPYING file which you should have received 11// along with this program. 12 13function b = %sp_l_sp(a, p) 14 // a sparse, p sparse, b sparse 15 // b = a \ p such that p = a * b 16 17 [ma, na] = size(a) 18 [mp, np] = size(p) 19 if ma <> mp then 20 msg = _("%s: Arguments #%d and #%d: Same numbers of rows expected.\n") 21 error(msprintf(msg, "%sp_l_sp", 1, 2)) 22 end 23 if issquare(a) 24 if det(a) <> 0 then 25 b = inv(a) * p 26 return 27 end 28 else 29 p = a.' * p 30 a = a.' * a 31 end 32 33 [h,rk] = lufact(a) 34 if rk < min(ma,na) then 35 warning(msprintf(_("sparse \ sparse: Deficient rank: rank = %d"),rk)) 36 end 37 b = [] 38 for k = 1:np 39 b = [b, sparse(lusolve(h,full(p(:,k))))] 40 end 41 ludel(h) 42endfunction 43