fsolve

Jaroslav Hajek highegg at gmail.com
Mon May 26 07:14:37 CDT 2008


On Sun, May 25, 2008 at 8:57 PM, yakup murat mert <ymmert at yahoo.com> wrote:
> function result=Uval(Us,Ud,Sbt,Uf,Vg)
> result=(0.0256*Us.+0.0256*Sbt.*(exp(Uf).*(exp(-Us).+Us.-1)+exp(-Uf).*(exp(Us.-Ud).-Us.-exp(-Ud))).^0.5).-Vg;
> ...
>
> ...
>
> Us=fsolve(@(Us) Uval(Us,Ud,Sbt,Uf,Vg) , init);
>
> ....
>
> ...
>
> Code above works on matlab. The equation is parametric. And depends on "Ud"
> "Sbt" "Uf" "Vg"  parameters.  "Us"  is unknown (like x) "Ud" is 1*100 matrix
> and rest are constants.  In matlab  after this code "Us" becomes 1*100
> matrix and has been solved 100 times according to "Ud" .
>
> This code hasnt been accepted by octave. I checked everything but coulndt
> find equivalent...
>
> any suggestion....?
>


Currently, fsolve is implemented to use column vectors exclusively -
you can switch to that as a quick remedy. Matlab is probably more
smart here; it always shapes the
input to user function according to the shape of user's initial guess.
It even allows things like
fsolve (@fcn, ones(3,3,3)) (returns a 3x3x3-array)

The attached two changesets solve this. I noticed that
octave_value::vector_value with force_vector_conversion = true didn't
work on N-d arrays, and generally the XXX_vector_value methods were
sloppy, making unnecessary copies. Hence the first changeset.

The second changeset modifies the fsolve function to behave like
Matlab's. It can be applied without the first one, but then N-d arrays
still won't work.

make check seems to go without problems.

regards,

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ov-xxx-value.diff
Type: text/x-patch
Size: 17342 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080526/3599d9da/attachment-0002.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fsolve_xdims.diff
Type: text/x-patch
Size: 3415 bytes
Desc: not available
Url : https://www.cae.wisc.edu/pipermail/bug-octave/attachments/20080526/3599d9da/attachment-0003.bin 


More information about the Bug-octave mailing list