help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GMP and Octave


From: Paul Kienzle
Subject: Re: GMP and Octave
Date: Tue, 1 Mar 2005 19:35:22 -0500

The symbolic toolbox on octave-forge provides access
to gmp via ginac and cln.

symbols() initializes the toolbox.
vpa("n") for integer n creates a bignum.

E.g.,

  octave> symbols()
  octave> vpa("2")^vpa("100")
  ans =

  1267650600228229401496703205376

You can do other things such as rationals:

  octave> vpa("2")/vpa("3")
  ans = 

  2/3

floats:

  octave> digits(40)
  ans = 40
  octave> Pi
  ans =

  3.141592653589793238462643383279502884197169399376


and polynomials:

  octave> x = sym("x")
  octave> y = vpa("3")*x^vpa("3") + vpa("2")*x^vpa("2") - x + vpa("2")
  y =

  2+2*x^2+3*x^3-x

Personally, I would like to see to see automatic promotion of
floating point integers to vpa numbers when used in symbolic
expressions so that you can express polynomials more naturally:

  octave> y = 3*x^3 + 2*x^2 - x + 2
  y =

  2.0+(2.0)*x^(2.0)+(3.0)*x^(3.0)-x

It doesn't fully support matrices, but there has been some work d
one on it.

E.g.,

  octave> x = ex_matrix(2,2,vpa("1"),vpa("2"),vpa("3"),vpa("4"))

With the new cat functions you can do a much better job.


BTW I've heard reports of successful builds of cln for OS X, and
I have one for windows so this could be built for all platforms.

- Paul

On Mar 1, 2005, at 2:47 PM, Todd Neal wrote:


I saw in the archived mailing list where there was a mention of using GMP from within Octave. I started writing a wrapper and began to wonder if anyone had already created one.

octave:2> a=make_gmp("3");
octave:3> a=a*9
a =

27
octave:4> a^a
ans =

443426488243037769948249630619149892803
octave:5> a^a-3
ans =

443426488243037769948249630619149892800


Todd



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]