Information Octave

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Information Octave

Pietro Maggio

Good morning,

I'm a student who is using Octave and I need some information.

I would need to parse the default Sqrt() function to understand which algorithm is implemented; where can I find the implementation?

Thanks so much.


Greetings.

Pietro Maggio




_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Information Octave

siko1056
Pietro Maggio wrote

> Good morning,
>
> I'm a student who is using Octave and I need some information.
>
> I would need to parse the default Sqrt() function to understand which
> algorithm is implemented; where can I find the implementation?
>
> Thanks so much.
>
>
> Greetings.
>
> Pietro Maggio

Hello Pietro Maggio,

I do not fully understand what you mean by "parse the default Sqrt()"
especially "parsing"?  But I'll try to answer:  The sqrt-function itself is
defined in [1].  That is the function called from the interpreter when you
type "sqrt(2)" for example.  In [1] you see, that the work just gets
forwarded to the underlying datatype of the first argument `args(0)`, in my
example "2" (real double scalar).  So the actual "sqrt algorithm" invoked
depends on your datatype (a real/complex double/float/int matrix/scalar,
...).  To my knowledge from searching within the sources, most likely it
will be forwarded to an element-wise "std::sqrt" or "octave::math::rc_sqrt"
[2], the latter one is "std::sqrt" with handling of special complex number
cases.

HTH,
Kai

[1]:
http://hg.savannah.gnu.org/hgweb/octave/file/558de6a42ff7/libinterp/corefcn/mappers.cc#l1969
[2]:
http://hg.savannah.gnu.org/hgweb/octave/file/558de6a42ff7/liboctave/numeric/lo-mappers.cc#l321




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Information Octave

Thomas D. Dean-2
> Pietro Maggio wrote
>> Good morning,
>>
>> I'm a student who is using Octave and I need some information.
>>
>> I would need to parse the default Sqrt() function to understand which
>> algorithm is implemented; where can I find the implementation?
>>
>> Thanks so much.

In octave:

octave > help sqrt

'sqrt' is a built-in function from the file libinterp/corefcn/mappers.cc

  -- sqrt (X)
      Compute the square root of each element of X.

      If X is negative, a complex result is returned.

      To compute the matrix square root, see *note Linear Algebra::.

      See also: realsqrt, nthroot.

Tom Dean

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave