ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 03 May 2020 16:59:26 +0200Decomposition of a matrix in subvectorshttps://ask.sagemath.org/question/51250/decomposition-of-a-matrix-in-subvectors/I have a matrix say
M = matrix([[0,0,5,3],[3,1,5,4],[4,4,6,2],[4,2,7,8],[5,4,6,6],[7,5,8,9]])
do divide the lines in two part 3/3 and construct all the vector composing the two submatrix. I want to know if it is possible to index those vectors ? I know how to do this for one shot
`A=M.delete_columns([1,2,3]).delete_rows([3,4,5])`
If I have understud there is a mecanism to construct block matrix not to deconstruct a matrix in block.
Here are the vectors
M_1=[0, 3, 4] M_5=[4, 5, 7]
M_2=[0, 1, 4] M_6=[2, 4, 5]
M_3=[5, 5, 6] M_7=[7, 6, 8]
M_4=[3, 4, 2] M_8=[8, 6, 9]
of course column vectors.Sun, 03 May 2020 15:29:21 +0200https://ask.sagemath.org/question/51250/decomposition-of-a-matrix-in-subvectors/Comment by tmonteil for <p>I have a matrix say</p>
<pre><code>M = matrix([[0,0,5,3],[3,1,5,4],[4,4,6,2],[4,2,7,8],[5,4,6,6],[7,5,8,9]])
</code></pre>
<p>do divide the lines in two part 3/3 and construct all the vector composing the two submatrix. I want to know if it is possible to index those vectors ? I know how to do this for one shot</p>
<p><code>A=M.delete_columns([1,2,3]).delete_rows([3,4,5])</code></p>
<p>If I have understud there is a mecanism to construct block matrix not to deconstruct a matrix in block.</p>
<p>Here are the vectors</p>
<p>M_1=[0, 3, 4] M_5=[4, 5, 7]</p>
<p>M_2=[0, 1, 4] M_6=[2, 4, 5]</p>
<p>M_3=[5, 5, 6] M_7=[7, 6, 8]</p>
<p>M_4=[3, 4, 2] M_8=[8, 6, 9]</p>
<p>of course column vectors.</p>
https://ask.sagemath.org/question/51250/decomposition-of-a-matrix-in-subvectors/?comment=51251#post-id-51251Could you please provide the list of vectors you want in the above example so that we understand the question ?Sun, 03 May 2020 15:39:11 +0200https://ask.sagemath.org/question/51250/decomposition-of-a-matrix-in-subvectors/?comment=51251#post-id-51251Comment by tmonteil for <p>I have a matrix say</p>
<pre><code>M = matrix([[0,0,5,3],[3,1,5,4],[4,4,6,2],[4,2,7,8],[5,4,6,6],[7,5,8,9]])
</code></pre>
<p>do divide the lines in two part 3/3 and construct all the vector composing the two submatrix. I want to know if it is possible to index those vectors ? I know how to do this for one shot</p>
<p><code>A=M.delete_columns([1,2,3]).delete_rows([3,4,5])</code></p>
<p>If I have understud there is a mecanism to construct block matrix not to deconstruct a matrix in block.</p>
<p>Here are the vectors</p>
<p>M_1=[0, 3, 4] M_5=[4, 5, 7]</p>
<p>M_2=[0, 1, 4] M_6=[2, 4, 5]</p>
<p>M_3=[5, 5, 6] M_7=[7, 6, 8]</p>
<p>M_4=[3, 4, 2] M_8=[8, 6, 9]</p>
<p>of course column vectors.</p>
https://ask.sagemath.org/question/51250/decomposition-of-a-matrix-in-subvectors/?comment=51255#post-id-51255OK thanks for clarifying.Sun, 03 May 2020 16:11:44 +0200https://ask.sagemath.org/question/51250/decomposition-of-a-matrix-in-subvectors/?comment=51255#post-id-51255Answer by tmonteil for <p>I have a matrix say</p>
<pre><code>M = matrix([[0,0,5,3],[3,1,5,4],[4,4,6,2],[4,2,7,8],[5,4,6,6],[7,5,8,9]])
</code></pre>
<p>do divide the lines in two part 3/3 and construct all the vector composing the two submatrix. I want to know if it is possible to index those vectors ? I know how to do this for one shot</p>
<p><code>A=M.delete_columns([1,2,3]).delete_rows([3,4,5])</code></p>
<p>If I have understud there is a mecanism to construct block matrix not to deconstruct a matrix in block.</p>
<p>Here are the vectors</p>
<p>M_1=[0, 3, 4] M_5=[4, 5, 7]</p>
<p>M_2=[0, 1, 4] M_6=[2, 4, 5]</p>
<p>M_3=[5, 5, 6] M_7=[7, 6, 8]</p>
<p>M_4=[3, 4, 2] M_8=[8, 6, 9]</p>
<p>of course column vectors.</p>
https://ask.sagemath.org/question/51250/decomposition-of-a-matrix-in-subvectors/?answer=51252#post-id-51252I am not sure about your exact question, but does the following solve your problem:
A = M[:3].columns() + M[3:].columns() ; A
leads to :
[(0, 3, 4),
(0, 1, 4),
(5, 5, 6),
(3, 4, 2),
(4, 5, 7),
(2, 4, 5),
(7, 6, 8),
(8, 6, 9)]
So that `A[0]` is `(0, 3, 4)`, `A[1]` is `(0, 1, 4)`, and so on.Sun, 03 May 2020 15:49:26 +0200https://ask.sagemath.org/question/51250/decomposition-of-a-matrix-in-subvectors/?answer=51252#post-id-51252Comment by Cyrille for <p>I am not sure about your exact question, but does the following solve your problem:</p>
<pre><code>A = M[:3].columns() + M[3:].columns() ; A
</code></pre>
<p>leads to :</p>
<pre><code>[(0, 3, 4),
(0, 1, 4),
(5, 5, 6),
(3, 4, 2),
(4, 5, 7),
(2, 4, 5),
(7, 6, 8),
(8, 6, 9)]
</code></pre>
<p>So that <code>A[0]</code> is <code>(0, 3, 4)</code>, <code>A[1]</code> is <code>(0, 1, 4)</code>, and so on.</p>
https://ask.sagemath.org/question/51250/decomposition-of-a-matrix-in-subvectors/?comment=51256#post-id-51256No obviously you solve my problem. ThanksSun, 03 May 2020 16:59:26 +0200https://ask.sagemath.org/question/51250/decomposition-of-a-matrix-in-subvectors/?comment=51256#post-id-51256