Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to solve this?

Status
Not open for further replies.

mikibelavista

Technical User
Jan 18, 2012
32
I have problem like this:
do k = 1, n_data
do i = 1, c
work_s = vv(i,:) - x(k,:)
w(k,i,:)=work_s
di=1/work_s
di2=di**2
di3=di**3
d(k,i,:)=di2
tri(k,i,:)=di3

select case (k)
case(1)
b1=d(1,:,:)
t1=tri(1,1,:)
q1=tri(1,2,:)
res1=sum(b1,dim=1)
i1=1/res1
ik1=(i1)**2
sum1=ik1*t1
qum1=ik1*q1
case(2)
b2=d(2,:,:)
t2=tri(2,1,:)
q2=tri(2,2,:)
res2=sum(b2,dim=1)
i2=1/res2
ik2=(i2)**2
sum2=ik2*t2
qum2=ik2*q2
case(3)
b3=d(3,:,:)
t3=tri(3,1,:)
q3=tri(3,2,:)
res3=sum(b3,dim=1)
i3=1/res3
ik3=(i3)**2
sum3=ik3*t3
qum3=ik3*q3

So I repeat case for every point.But it is senseless tocpy 2000 times,for example.Ideas?
 
well, it is up to you...do you desire to keep your sum1, sum2, sum3 variables just like that, individual scalars? Or can you turn those into an array the_sum() ?

As it is, your Cases can be automated by placing 'k' instead of your first indeces 1, 2, 3...

Other than that, I presume this is just part of the code...I don't see where your do-loops end...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top