fsolve
John W. Eaton
jwe at bevo.che.wisc.edu
Fri Jun 20 15:05:51 CDT 2008
On 26-May-2008, Jaroslav Hajek wrote:
| 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.
Sorry for the delay.
I applied this changeset.
Thanks,
jwe
More information about the Bug-octave
mailing list