Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > IDL > Trouble with sy...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 173 of 228
Post > Topic >>

Trouble with syntax of minF_conj_grad

by "Siddharth" <malu.spam@[EMAIL PROTECTED] > Mar 13, 2007 at 02:06 PM

I am having trouble implementing the minF_conj_grad routine that is
meant to minimize the expression (Ax-b) where x,b are vectors and A is
a matrix. The program I wrote is as below.

I would really appreciate it if someone can help me with this.

Regards

Siddharth

PRO s

; THIS FINDS THE SOLUTION TO Ax=b WHERE THE MATRIX "A" AND VECTOR "b"
; ARE GIVEN

x_min = replicate(1.,2)
px = x_min

a = fltarr(2,2)
a[0,0] = 2.
a[0,1] = 1.
a[1,0] = 5.
a[1,1] = 7.



b = fltarr(2,1)
b[0,0] = 9.
b[1,0] = 45.
thematrix = a#px - b
print, 'a##x-b= ', thematrix
gradient = reform(transpose(thematrix)#a,2,1)
print, 'gradient outside: ', gradient

f = funky(px,gradient)
print, 'x = ', px
print, 'the function = ', f
minF_conj_grad, x_min, f_min, conv_factor, FUNC_NAME='funky',/
INITIALIZE
while (conv_factor GT 0) do begin
    print, 'running more than once...'
    minF_conj_grad, px, f_min, conv_factor, FUNC_NAME='funky'
    PRINT, 'CURRENT ITERATION OF SOLUTION: ', px
endwhile

;PRINT, 'SOLUTION IS: ', x

END

function funky, px,gradient
c = fltarr(2,2)
c[0,0] = 2.
c[0,1] = 1.
c[1,0] = 5.
c[1,1] = 7.

d = fltarr(2,1)
d[0,0] = 9.
d[1,0] = 45.

thematrixwa = c#px - d
print, 'x inside funky:'
print, px
print, 'the matrixwa inside funky: ', thematrixwa
gradient= reform((transpose(thematrixwa))#c,2,1)
print, 'gradient inside funky:', gradient
print, 'the function inside funky: ',
(transpose(thematrixwa))#(thematrixwa)
f_min=(transpose(thematrixwa))#(thematrixwa)
return, f_min
end
 




 1 Posts in Topic:
Trouble with syntax of minF_conj_grad
"Siddharth" <  2007-03-13 14:06:05 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 8:24:36 CDT 2008.