[Pkg-octave-commit] [SCM] octave-symbolic branch, master, updated. a718b53403d9f164f8c2a3df521385a01d28a11b
pkienzle
pkienzle at 416fae20-06d0-4450-9b69-c6c34d4b5f03
Mon Jan 3 03:40:20 UTC 2011
The following commit has been merged in the master branch:
commit 7fe6670fb2db06d663fe9c0b6123b39024f78cbe
Author: pkienzle <pkienzle at 416fae20-06d0-4450-9b69-c6c34d4b5f03>
Date: Thu Mar 14 21:58:18 2002 +0000
Access CLN's probably_prime function (error rate 1 in 2^100 IIRC)
git-svn-id: https://octave.svn.sourceforge.net/svnroot/octave/trunk/octave-forge/main/symbolic@167 416fae20-06d0-4450-9b69-c6c34d4b5f03
diff --git a/Makefile b/Makefile
index 98b9881..a38821f 100644
--- a/Makefile
+++ b/Makefile
@@ -2,39 +2,40 @@
sinclude ../../Makeconf
ifndef MKOCTFILE
-# assumptions to make if not using ./configure script
-MKOCTFILE=mkoctfile
-HAVE_GINAC=1
+ # assumptions to make if not using ./configure script
+ MKOCTFILE=mkoctfile
+ HAVE_GINAC=1
endif
-SRC=symbols.cc ov-ex.cc ov-sym.cc ov-vpa.cc ov-ex-mat.cc
+SRC=symbols.cc ov-ex.cc ov-sym.cc ov-vpa.cc ov-ex-mat.cc probably_prime.cc
OBJ=$(SRC:.cc=.o)
%.o: %.cc ; $(MKOCTFILE) -v $(GINAC_CPP_FLAGS) -c $<
-ifdef HAVE_GINAC
-
-GINAC_CPP_FLAGS=$(shell ginac-config --cppflags)
-GINAC_LD_FLAGS=$(shell ginac-config --libs)
-
FUNCTIONS=vpa sym is_vpa is_sym is_ex to_double digits\
Cos Sin Tan aCos aSin aTan Cosh Sinh Tanh aCosh\
aSinh aTanh Exp Log subs differentiate expand\
collect coeff lcoeff tcoeff degree ldegree quotient\
remainder premainder Pi ex_matrix
-OBJLINKS=$(addsuffix .oct,$(FUNCTIONS))
+SYMBOLS_LINKS=$(addsuffix .oct,$(FUNCTIONS))
-all: symbols.oct
+ifdef HAVE_GINAC
+ PROGS=symbols.oct $(SYMBOLS_LINKS)
+ GINAC_CPP_FLAGS=$(shell ginac-config --cppflags)
+ GINAC_LD_FLAGS=$(shell ginac-config --libs)
+else
+ PROGS=
+endif
-symbols.oct: $(OBJ)
- $(MKOCTFILE) -v -o $@ $(OBJ) $(GINAC_LD_FLAGS) ; \
- for i in $(OBJLINKS); do ln -sf symbols.oct $$i ; done
-else
+all: $(PROGS)
-all:
+symbols.oct: Makefile $(OBJ)
+ $(MKOCTFILE) -v -o $@ $(OBJ) $(GINAC_LD_FLAGS) ; \
-endif
+$(SYMBOLS_LINKS): Makefile
+ -$(RM) $@
+ $(LN_S) symbols.oct $@
clean:
$(RM) *.o *.oct core octave-core *~
diff --git a/probably_prime.cc b/probably_prime.cc
new file mode 100644
index 0000000..fb92816
--- /dev/null
+++ b/probably_prime.cc
@@ -0,0 +1,40 @@
+
+#include <octave/oct.h>
+#include <ginac/ginac.h>
+#include "symbols.h"
+
+
+DEFUN_DLD(probably_prime, args, ,
+"-*- texinfo -*-\n\
+ at deftypefn Loadable Function {r =} is_prime(@var{x})\n\
+Return true if the variable precision number is probably prime,\n\
+with error 1 in 2^100.\n\
+ at end deftypefn\n\
+")
+{
+ int nargin = args.length ();
+ octave_value_list retval;
+ GiNaC::numeric value;
+
+ if (nargin != 1)
+ {
+ print_usage("probably_prime");
+ return retval;
+ }
+
+ try
+ {
+ if(!get_numeric(args(0), value))
+ {
+ print_usage("probably_prime");
+ return retval;
+ }
+ retval(0) = GiNaC::is_prime(value);
+ }
+ catch (exception e)
+ {
+ e.what ();
+ return retval;
+ }
+ return retval;
+}
--
octave-symbolic
More information about the Pkg-octave-commit
mailing list