# [Scilab-users] row-sum of a hyper-matrix without loop

 Classic List Threaded
4 messages
Reply | Threaded
Open this post in threaded view
|

## [Scilab-users] row-sum of a hyper-matrix without loop

 Is it posible to get a 2-dimension matrix y(j,k) =Σ_i x(i,j,k) from 3 dimension hyper- matrix x(i,j,k) without using  k-loop? If there is such a way, please teach me. Best regards, Masahiro Fujimoto -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html_______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

## Re: row-sum of a hyper-matrix without loop

 Le 24/11/2019 à 19:53, fujimoto2005 a écrit : ```Is it posible to get a 2-dimension matrix y(j,k) =Σ_i x(i,j,k) from 3 dimension hyper- matrix x(i,j,k) without using k-loop? If there is such a way, please teach me.``` --> h = grand(4,3,2,"uin",0,3)  h  = (:,:,1)    0.   0.   2.    2.   3.   3.    2.   1.   3.    1.   1.   1. (:,:,2)    0.   3.   1.    2.   0.   1.    3.   1.   3.    0.   2.   3. --> matrix(sum(h,1),-1,size(h,2))  ans  =    5.   9.   6.    5.   5.   8. Regards _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

## Re: row-sum of a hyper-matrix without loop

 Le 24/11/2019 à 20:01, Samuel Gougeon a écrit : Le 24/11/2019 à 19:53, fujimoto2005 a écrit : ```Is it posible to get a 2-dimension matrix y(j,k) =Σ_i x(i,j,k) from 3 dimension hyper- matrix x(i,j,k) without using k-loop? If there is such a way, please teach me.``` --> h = grand(4,3,2,"uin",0,3)  h  = (:,:,1)    0.   0.   2.    2.   3.   3.    2.   1.   3.    1.   1.   1. (:,:,2)    0.   3.   1.    2.   0.   1.    3.   1.   3.    0.   2.   3. --> matrix(sum(h,1),-1,size(h,2))  ans  =    5.   9.   6.    5.   5.   8. Sorry, the correct algorithm is --> h = grand(4,3,2,"uin",0,3)  h  = (:,:,1)    2.   0.   1.    2.   3.   2.    0.   0.   2.    1.   1.   3. (:,:,2)    1.   0.   1.    1.   2.   0.    3.   3.   1.    0.   0.   2. --> matrix(sum(h,1),size(h,2), -1)  ans  =    5.   5.    4.   5.    8.   4. Samuel _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

## Re: row-sum of a hyper-matrix without loop

 Dear Samuel Thanks for your answer. Best　regards, Masahiro Fujimoto -- Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html_______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users