From: Marios Karaoulis on 7 Jul 2010 13:40 Hi, I need some help to speed up things in a sparse matris. I have a large sparse matrix like this k=sparse(a_index,b_index,val_index,10000,10000); (a_index and b_index have duplicate values). Now another matrix have some info about some additional zeroing elements like this node_ebc=[1 13 155 3455 5645 3432 .....]; num_ebc=length(node_ebc); for i=1:num_ebc m=node_ebc(i); k(m,m)=1; for j=1:10000 if m~=j fem.k(m,j)=0; fem.k(j,m)=0; end end end This loop is very slow. How can i speed up things?
From: Bruno Luong on 7 Jul 2010 15:22 Marios Karaoulis <marios.karaoulis(a)gmail.com> wrote in message <5dae28d8-48b8-42f1-be87-de18abf71b5e(a)q12g2000yqj.googlegroups.com>... > Hi, I need some help to speed up things in a sparse matris. > I have a large sparse matrix like this > > k=sparse(a_index,b_index,val_index,10000,10000); > > (a_index and b_index have duplicate values). > > Now another matrix have some info about some additional zeroing > elements like this > node_ebc=[1 13 155 3455 5645 3432 .....]; > > num_ebc=length(node_ebc); > > for i=1:num_ebc > m=node_ebc(i); > k(m,m)=1; > for j=1:10000 > if m~=j > fem.k(m,j)=0; > fem.k(j,m)=0; > end > end > end > > This loop is very slow. > How can i speed up things? Well, the first obvious improvement you could try is replacing the inner loop by k(m,:)=0; k(:,m)=0; then move the diagonal assignment k(m,m)=1; below it. Bruno
From: Bruno Luong on 7 Jul 2010 15:32 The whole variable locking can be done as following: k(node_ebc,:)=0; k(:,node_ebc)=0; for m=node_ebc k(m,m) = 1; end % Bruno
From: Marios Karaoulis on 7 Jul 2010 15:38 Actually, what I did is the following k(node_ebc,:)=0; k(:,node_ebc)=0; k(node_ebc,node_ebc)=1; but the speed of this calculations are really slow. If i have k matrix as full, then speed is amazing faster. So I was hoping in zeroing only the NECESSARY non zero elements (since there are many zero elements on those columns and rows), usinhg the a_index, b_index, val_index.
From: Bruno Luong on 7 Jul 2010 18:35 Marios Karaoulis <marios.karaoulis(a)gmail.com> wrote in message <6265f1e1-92e6-4481-9003-31570ba53023(a)k39g2000yqb.googlegroups.com>... > Actually, what I did is the following > > k(node_ebc,:)=0; > k(:,node_ebc)=0; > k(node_ebc,node_ebc)=1; The last statement (sub-block assignment) is not equivalent to what you wrote earlier (subdiagonal assignment), or my simplification of it: for m=node_ebc % ... k(m,m) = 1; end You what did you exactly do? Are you ready to settle on something for the community to work on? Bruno
|
Pages: 1 Prev: help me on matlab MEX Next: Scaling graph axis without scaling the graph itself? |