[Scilab-users] sparse() to build a block-diagonal matrix?

Samuel Gougeon sgougeon at free.fr
Tue Nov 26 13:51:43 CET 2019


Le 26/11/2019 à 03:43, Chin Luh Tan a écrit :
> Hi,
>
> from the first glance on the documentation you show:
>
> "Beside this function, you can also use sparse() primitive to build a 
> block diagonal sparse matrix."
>
> it sound to me that this statement said the sparse could be used to 
> create block diagonal matrix with the similar inputs to sysdiag.
>
>
> But after a trying to stare at it again... I think it might mean:
>
> " to convert the *block diagonal matrix* to *block diagonal /sparse 
> /matrix "*
>
> which likely is the one shown in the example:
> S=sysdiag([1  2;  3  4],  [5  6;  7  8],  [9  10;  11  12],  [13  14;  15  16])
> S=sparse  <sparse.html>(S)
> which simply to say that we could use sparse to convert the full 
> matrix created by sysdiag to sparse?
>

Chin Luh,

You are right.

Yesterday evening i posted awish to improve sysdiag 
<http://bugzilla.scilab.org/show_bug.cgi?id=16257>(), and also to rename 
it /blockdiag/() (but both aspects are distinct). I have rewritten 
sysdiag() as indicated in the wish, and made an additional improvement, 
that is: When at least one input is sparse, the result is built as a 
sparse/from the beginning/, instead of only when the first sparse input 
is met and included in the result. Hence, the probability of a memory 
issue is decreased.

Best regards
Samuel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20191126/e63f5ab9/attachment.htm>


More information about the users mailing list