Index: ctory/libfac/00README
===================================================================
--- factory/libfac/00README	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,199 +1,0 @@
-This is the file 00README.libfac for version 0.3.2 of Singular-libfac.
-
-######### What is Singular-libfac?
-Singular-libfac is an extension to Singular-factory
-(see the Singular-factory documentation for details about Singular-factory
-and what it does; look at REQUIREMENTS how to get Singular-factory), 
-which implements factorization of polynomials over finite fields and algorithms
-for manipulation of polynomial ideals via the characteristic set methods 
-(e.g., calculating the characteristic set and the irreducible characteristic 
-series).
-
-Note: Singular-libfac is just beta-code (as long version is < 1.0.0).
-There are bugs, I think. Please help to test this code!
-Submit a bug-report if you found a bug!
-
-######### Copyright #####################
-the Copyright is given in the file COPYING
-
-######### REQUIREMENTS ###################
-* You need the library Singular-factory, which is part of Singular, to compile
-this code. Get it from 
-  ftp://www.mathematik.uni-kl.de/pub/Math/Singular/Factory  or
-  http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/Factory
-  
-* gcc 2.7.2 ( earlier versions of gcc *may* work as well as any other ANSI C++
-  compiler; it is reported that gcc 2.6.3 works also, but beware of gcc 2.7.0;
-  it has some serious C++ bugs )
-
-* GNU Make version 3.74 or above ( earlier versions of GNU make *may* work )
-
-######### INSTALLATION ###################
-Using configure
-For the library type:
-  configure [--with-debug] [--with-Singular] [--includedir=path-to-factory.h]
-  make
-this will produce libfac.a or libsingfac.a (depending on --with-Singular).
-The only difference between libfac.a and libsingfac.a is: we don't instantiate
-any templates for libsingfac.a.
-
-If you want to produce a test file, type:
-  configure [--with-debug] [--libdir=path-to-libcf.a] [--includedir=path-to-factory.h]
-  make tests
-this will produce libfac.a and a binary called test. "test" is then used to 
-test some examples for factorization.
-
- If you have found a bug in an unmodified version (beside the KNOWN BUGS, see 
-KNOWN BUGS section later), *please* email me: mmessollen@web.de
-Please include the characteristic and the ideal(s)/polynomial(s) you tried as
-well as the factoryversion you used (Best to include all your input!).
-
-As I am no longer at the university, please allow some days for an answer.
-
-Have fun!
- Michael Messollen ( mmessollen@web.de )
-
-##### 
-I would like to thank Dongming Wang <Dongming.Wang@imag.fr> who showed me the 
-power of the Characteristic Set methods and from whom I learned a lot about 
-this topic.
-If you want to learn about characteristic sets, the next is a good point
-to start with:
-    Dongming Wang:
-    An Implementation of the Characteristic Set Method in Maple.
-    In: Automated Practical Reasoning: Algebraic Approaches 
-    (J. Pfalzgraf and D. Wang, eds.), Springer-Verlag, 
-    Wien-New York, 1995, pp. 187-201.
-
-
-########### KNOWN BUGS ############################
-o The  irreducible characteristic series stuff doesn't work for some problems.
-  You will get a warning:
-         "Factorization over algebraic function field required!"
-  if this program needs factorization over an algebraic function field, which
-  is not yet implemented (but I'm working on it).
-  Don't trust the result you'll get in such a case!!!!!!
-Since version 0.3.0 this problem is gone. (or should be :-) )
-
-o The performance of the irreducible characteristic series stuff heavily
-  depends on the ordering of the variables in some cases. No (nearly) optimal
-  ordering of the variables is chosen automatically, right now. 
-  E.g.: if your ideal is (t^10-x, t^31-t^6-t-y, t^8-z) and you choose the
-  variable ordering with t > z > y > x, the calculation of the irreducible 
-  characteristic series will take hours; if you choose t as the variable with 
-  the lowest level, you will get the answer immediately (the ideal is an 
-  irreducible characteristic series with the ordering z > y > x > t ).
-  I am thinking about the problem how to choose the ordering automatically. 
-Since version 0.2 of the library:
-(There is now a function: Varlist neworder(const CFList & PolyList ),
- which returns a list of heuristically optimal reordered variables;
- if you use the library for programming purpose, look at factor.h how to
- use this function in your code)
-For users of Macaulay2 and/or Singular: look at the documentation of the
-respective program, if and how this is incorporated.
-
-o Factorization is slow for large polynomials. There are mainly two reasons
-  for this:
-   a) the factorization algorithm is shipped with no "tricks" yet. (I'm working
-      on that, but it heavily depends on b) )
-   b) factory has an extremely slow GCD-algorithm for the case of 
-      characteristic  p>0 ( people are working on it )
-  There will be a quite different, faster factorization algorithm in the 
-  future.
-
-Problems will be fixed in a later version of libfac .
-
-######### Changes:
-Version coding scheme: major.minor.bugfixnumber
-          e.g.: 0.1 major=0 minor=1 no bugfixnumber (no bugfix incorporated)
-
-V0.1	o Initial version for alpha-testers
-
-V0.2	o Added neworder(..) and reorder(..) for IrrCharSeries
-	o Added external strings (in factor/version.cc):
-	    libfac_name     - the name of the game
-	    libfac_version  - the version number
-	    libfac_date     - the date libfac_version was released
-	    libfac_author   - who wants to know?
-	o added support for factorization of homogeneous polynomials (in 
-          factor/homogfactor.cc), 
-          reorganized code in factor/Factor.cc and factor/Factor.h
-	o added files factor/debug.cc, factor/debug.h, factor/timing.h; 
-	  mainly for internal use
-
-V0.2.1  o changed lc == 1 to lc == unit in choose_mainvar (factor/Factor.cc)
-        o changed cerr and cout messages for use with Singular (all .cc files)
-          (why the hell don't they use libiostream?)
-        o added configure -- basics only; (old)Makefile changed to 
-          Makefile.dist (if nothing works...) 
-          Makefile produced with configure uses GNU coding standards
-	o released Apr 25 1997
-
-V0.2.2	o Added ranlib in Makefile.in after installing - Sun's seem to need it
-	o Put -I. before CPPFLAGS in Makefile.in
-	o hardcoded ./install-sh and ./mkinstalldirs in Makefile.in for 
-	  INSTALL; some machines have a broken install (e.g. HP )
-	  commented out the search for AC_PROG_INSTALL in configure.in
-	o Internal note: Singular now contains definitions from class.cc and
-	  tmpl_inst.h in claptmpl.cc
-	o released May 15 1997
-
-V0.2.3	o Added factor/interrupt.cc and interrupt.h to support interrupting
-	  calculations: We define a global variable "libfac_interruptflag"
-          in factor/version.cc which, if not zero, interrupts the ongoing
-	  calculation. Factorize() will then return an empty list (CFFList), 
-	  IrrCharSeries will return an empty list of lists (ListCFList).
-	  Modified: factor/Factor.cc and charset/charset.cc for this purpose.
-	o version for Macaulay2-Testers
-	o released May 28 1997
-
-V0.2.4	o Changed factor/SqrFree.cc (SqrFreed): Have to interchange variables 
-          if one derivative is zero but not all (e.g. no p'th power)
-	  example: (y^12+x^10)^2 mod 5
-	  Internal note: have to look at SqrFreeTest!!
-	o Changed factor/Factor.cc (Factorize): multiplied exponent of factors
-	  into Output (should be one if Sqrfree doesn't fail); this is for
-	  security only (and should be removed later..)
-	o Changed factor/helpstuff (myappend): added support for lists with
-	  multiple copies of one element (this doesn't happen for this 
-	  algorithms... but you never know)
-	o Changed factor/interrupt.{cc|h}: Removed interrupt.cc; added (inline)
-	  code to interrupt.h; factor.h will now define the external variable
-	  "libfac_interruptflag"
-	  Doesn't any longer issue any message about user-interrupt - the 
-	  CA-System, which has control, should warn user that calculation is 
-	  aborted. Removed libfac_messageflag from factor/version.cc
-	o Summary: removed: factor/interrupt.cc
-		   changed: factor/SqrFree.cc factor/Factor.cc 
-			    factor/helpstuff.cc Makefile.in configure.in 
-			    factor/interrupt.h factor.h factor/version.cc 
-	o Internal note: something changed in unvivariate factorization over
-	  extension fields from factory-1.2b to 1.2c: same polynomial now uses
-	  4 to 12 times longer to factor! Perhaps it's this new random 
-          generator?
-	o released May 30 1997
-
-V0.3.0a	o changed configure.in: will not override CFLAGS or CXXFLAGS if set in
-	  the environment
-	o added new functionality in charset/algfacor.{cc/h} :
-          now we should be able to factorize over any field needed for the
-	  charset-algorithm. (Internal note: perhaps there are still problems
-	  for the char=0 case because of the factory implementation vs. gmp)
-	o for this,  changed charset/csutil.{cc/h} and charset/charset.{cc/h}
-	o include #include <file.h> in file.cc for some CC's
-	o Internal note: need more interrupt handles enabled;
-			 set up test examples for char=0 and char>0;
-	o released Jun 25 1997
-
-V0.3.0b o implemented Tragers algorithm; this is now the default used in 
-          charsets (file: charsets/alg_factor.cc)
-        o for char=0 case there are some problems with factory;
-          for char=p there seems to be an internal factory memory-problem in
-          some cases
-        o released Sep 11 1997
-
-V0.3.1  o now ready for cygwin32
-	o released Jan 15 1998
-
-V0.3.2	o New Copyright
-	o released Jan 31 2001
Index: ctory/libfac/CMakeLists.txt
===================================================================
--- factory/libfac/CMakeLists.txt	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,124 +1,0 @@
-# -*- mode: cmake; -*-
-cmake_minimum_required(VERSION 2.6)
-cmake_policy(VERSION 2.6)
-if(POLICY CMP0011)
-  cmake_policy(SET CMP0011 NEW)
-endif(POLICY CMP0011)
-
-project(libfac)
-string(TOUPPER ${PROJECT_NAME} UPPER_PROJECT_NAME)
-
-# have the full monty in makefiles
-set(CMAKE_VERBOSE_MAKEFILE true)
-
-set(LIBFAC_V_MAJOR 3)
-set(LIBFAC_V_MINOR 1)
-set(LIBFAC_V_PATCH 0)
-set(LIBFAC_NAME   "Factorization and characteristic sets library")
-set(LIBFAC_DATE   "Aug 2008")
-set(LIBFAC_AUTHOR "M. Messollen")
-
-#OPTION(WITH_SINGULAR "build for use with Singular" Off)
-#OPTION(WITH_SINGULARERROR "use error reporting from Singular" Off)
-OPTION(WITH_NOSTREAMIO    "do not require iostream include nor library" Off)
-set(ADD_DEFS "NOSTREAMIO;${_OSDEF};HAVE_CONFIG_H;SINGULAR")
-
-
-###################################################################################################
-# No user settings below
-###################################################################################################
-include(LibfacMacros)
-
-###################################################################################################
-if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
-  message(STATUS "Have compiler: '${CMAKE_CXX_COMPILER_ID}'")
-  if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
-
-    #set(CMAKE_CXX_FLAGS "-W -Wall -Wextra -Wno-non-virtual-dtor")
-    set(CMAKE_CXX_FLAGS "-w --no-rtti -pipe ")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-implicit-templates")
-    #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-
-    set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fomit-frame-pointer -DNDEBUG")
-
-    set(CMAKE_CXX_FLAGS_DEBUG "-Werror -O0 -g -ggdb -Wreturn-type -fno-omit-frame-pointer")
-    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wunused-variable -Wunused-parameter")
-    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wunused-function -Wunused")
-    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Woverloaded-virtual -Wno-system-headers")
-
-    # gprof and gcov support
-    set(CMAKE_CXX_FLAGS_PROFILE "-O0 -g -ggdb -Wreturn-type -Woverloaded-virtual")
-    set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_PROFILE} -Wno-system-headers -pg")
-    set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_PROFILE} -fprofile-arcs -ftest-coverage")
-  endif (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
-endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
-
-###########################################################
-# Where are the additional libraries installed? Note: provide includes
-# path here, subsequent checks will resolve everything else
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/charset)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/factor)
-include_directories(${CMAKE_BINARY_DIR})
-include_directories(${CMAKE_SOURCE_DIR})
-include_directories(${CMAKE_BINARY_DIR}/factory)
-include_directories(${CMAKE_SOURCE_DIR}/factory)
-
-libfac_mk_version(LIBFAC_VERSION_H)
-
-
-##
-## src and objects
-##
-
-set(FACTORSRC1  factor/SqrFree.cc factor/Factor.cc 
-		factor/MVMultiHensel.cc factor/Truefactor.cc 
-		factor/helpstuff.cc  factor/version.cc 
-		factor/homogfactor.cc )
-set(FACTORSRC2 	factor/tmpl_inst.cc)
-set(FACTORSRC  	${FACTORSRC2} ${FACTORSRC1})
-
-
-set(FACTORINCL 	${LIBFAC_VERSION_H} 
-  factor/Factor.h factor/MVMultiHensel.h
-  factor/Truefactor.h factor/tmpl_inst.h factor/SqrFree.h
-  factor/helpstuff.h factor/debug.h factor/timing.h 
-  factor/homogfactor.h     factor/interrupt.h)
-set(CHARSETINCL charset/csutil.h charset/charset.h charset/reorder.h
-  charset/alg_factor.h charset/algfactor.h)
-
-set(charset_srcs  charset/csutil.cc charset/charset.cc
-  charset/reorder.cc charset/alg_factor.cc charset/algfactor.cc
-)
-
-# define libraries
-add_library(fac ${LIBFAC_VERSION_H} ${FACTORSRC} ${CHARSETSRC})
-set_source_files_properties(${FACTORSRC} PROPERTIES OBJECT_DEPENDS 
-  ${FACTORYCONF_H})
-#add_dependencies(fac ${FACTORY_TARGET})
-
-# debug library
-#add_library(fac_g ${LIBFAC_VERSION_H} ${FACTORSRC} ${CHARSETSRC})
-#set_target_properties(fac_g PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
-
-# profile library
-#add_library(fac_p ${LIBFAC_VERSION_H} ${FACTORSRC} ${CHARSETSRC})
-#set_target_properties(fac_p PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_PROFILE})
-
-#
-# libraries for Singular
-if( WITH_SINGULAR )
-  message(STATUS "Compiling libfac for Singular: creating libsingfac.a")
-  add_library(singfac ${LIBFAC_VERSION_H} ${FACTORSRC1} ${charset_srcs})
-  set_target_properties(singfac PROPERTIES 
-    COMPILE_DEFINITION "${ADD_DEFS};SINGULAR")
-
-#  # debug library
-#  add_library(singfac_g ${LIBFAC_VERSION_H} ${FACTORSRC1} ${charset_srcs})
-#  set_target_properties(singfac_g PROPERTIES COMPILE_FLAGS "-DSINGULAR ${CMAKE_CXX_FLAGS_DEBUG}")
-
-#  # profile library
-#  add_library(singfac_p ${LIBFAC_VERSION_H} ${FACTORSRC1} ${charset_srcs})
-#  set_target_properties(singfac_p PROPERTIES COMPILE_FLAGS "-DSINGULAR ${CMAKE_CXX_FLAG_PROFILE}")
-endif( WITH_SINGULAR )
Index: ctory/libfac/COPYING
===================================================================
--- factory/libfac/COPYING	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,45 +1,0 @@
-                        SINGULAR version 3-1
-			   Singular-Libfac
-
-                     University of Kaiserslautern
-
-      Department of Mathematics and  Centre for Computer Algebra
-
-              Author: Michael Messollen <mmessollen@web.de>
-
-                        Copyright (C) 1996-2010
-
-
-                               *NOTICE*
-
-This program is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation ( version 2 or version 3 of the License );
-with the following additional remarks:
-
-This package is part of the software SINGULAR. The GPL is valid for
-this package, other packages may have other copyrights.
-
-Their copyrights and licences can be found in the accompanying files
-which are distributed along with these packages.
-
-For details see the author's notice in the file 00README.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License along
-with this program; if not, write to the Free Software Foundation, Inc.,
-59 Temple Place, Suite 330, Boston, MA  02111-1307  USA (see GPL)
-
-Please send any comments or bug reports to
-<singular@mathematik.uni-kl.de>.
-
-Availability
-============
-
-The latest information about SINGULAR is always available from
-`http://www.singular.uni-kl.de'.
-
Index: ctory/libfac/ChangeLog
===================================================================
--- factory/libfac/ChangeLog	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,88 +1,0 @@
-Fri Feb 14 16:53:42 CET 2003 * hannes: bugfix
-       could not factorize x2+xy+y2 in Fp(a)[x,y], a2+a+1=0
-       added wrapper factorize2 with sanity checks/typ conversions
-
-Thu Nov  7 11:29:33 MET 2002 Hans Schoenemann <hannes@mathematik.uni-kl.de>
-       * interface to NTL
-       * many fixes
-
-Wed Aug 22 16:35:00 CEST 2001 Hans Schoenemann <hannes@mathematik.uni-kl.de>
-       * HAVE_SINGULAR_ERROR/NOSTREAMIO handling in configure
-       * search for main var in Factorize
-       * code clean up
-
-Thu Jun 28 18:27:55 CEST 2001 Hans Schoenemann <hannes@mathematik.uni-kl.de>
-
-       * fixes to resultant, newfactoras, IrrCharSeries, Factorize
-
-Tue Apr 10 15:34:04 CEST 2001 Hans Schoenemann <hannes@mathematik.uni-kl.de>
-
-       * changed copyright notice to GPL
-
-Wed Jun 03 14:42:51 1998    <pohl@FUECHSE>
-
-        * Makefile.in (CPPFLAGS): include paths fixed so that Windows
-        NT will find Factor.h before factor.h
-
-1998-05-25  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
-
-        * charset/alg_factor.cc: replaced identifiers 'random' by
-        'myrandom' to avoid name conflicts with the built-in (stdlib)
-        library function 'random' which might be a macro -- and, actually
-        is  under gcc v 2.6.3
-
-
-Wed Apr 22 16:12:16 1998  Jens Schmidt  <schmidt@mathematik.uni-kl.de>
-
-        * header.tpl, factor.h, factor/version.cc (libfac_name,
-          libgac_version, libfac_date, libfac_athur): defined/declared
-           const
-
-Thu Mar 12 14:32:06 1998  Jens Schmidt  <schmidt@mathematik.uni-kl.de>
-
-        * charset/csutil.cc, charset/alg_factor.cc: all references to
-          `common_den()' replaced by `bCommonDen()'
-
-Fri Feb 27 11:32:02 1998  Jens Schmidt  <schmidt@mathematik.uni-kl.de>
-
-        * factor/tmpl_inst.cc: template names adapted (`*.cc' ->
-          `ftmpl_*.cc')
-
-Tue May 13 11:32:11 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
-
-        * Makefile.in (uninstall): took out template installation
-        (all): added OPTOBJ target so that the dir is created, if necessary
-
-Sun May 25 14:06:12 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
-
-        * configure.in: Fixed handling of CXXFLAGS -- it is not touched if
-          set as env var
-
-Fri May 23 11:10:18 1997  Olaf Bachmann  <obachman@schlupp.mathematik.uni-kl.de (Olaf Bachmann)>
-
-        * configure.in (CXXFLAGS): Check whether they are set before value
-          is assigned
-
-Tue May 13 20:09:03 1997  Olaf Bachmann  <obachman@schlupp.mathematik.uni-kl.de (Olaf Bachmann)>
-
-        * configure.in: Exit with error if factory.h was not found and
-          --enable-factory option was not explicitely given
-
-Tue May 13 11:32:11 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
-
-        * Makefile.in (uninstall): took out template installation
-
-Tue May  6 09:30:51 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
-
-        * Added ranlib after installing libs -- Suns seem to need it
-
-        * configure.in: Manuallu put INSTALL into Makefile.in
-
-Mon May  5 15:43:58 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
-
-        * added installation of templates
-
-Sat May  3 19:58:53 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
-
-        * Makefile.in (CPPFLAGS): Put -I. before other CPPFLAGS
-
Index: ctory/libfac/Makefile.am
===================================================================
--- factory/libfac/Makefile.am	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,54 +1,0 @@
-noinst_LTLIBRARIES=libfac.la libfac_g.la
-
-CXXTEMPLFLAGS =  ## -fno-implicit-templates
-
-libfac_la_CFLAGS   = -O3 -fomit-frame-pointer ${PIPE}
-libfac_g_la_CFLAGS = ${PIPE}
-
-libfac_la_CXXFLAGS   = -O3 -fomit-frame-pointer ${PIPE} ${CXXTEMPLFLAGS}
-libfac_g_la_CXXFLAGS = -g -Wextra -Wall -pedantic -Wno-long-long ${PIPE} ${CXXTEMPLFLAGS}
-# -fdiagnostics-show-option 
-
-AM_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/.. -I${top_builddir} -I${top_builddir}/.. -I${srcdir} -I${builddir} -I${srcdir}/.. -I${builddir}/.. -I${srcdir}/../include  -I${builddir}/../include -I${srcdir}/factor  -I${builddir}/factor -I${srcdir}/charset -I${builddir}/charset ${GMP_CFLAGS} ${NTL_CFLAGS}
-
-libfac_la_CPPFLAGS   = ${AM_CPPFLAGS} -DNDEBUG -DOM_NDEBUG -DHAVE_CONFIG_H
-libfac_g_la_CPPFLAGS = ${AM_CPPFLAGS} -DHAVE_CONFIG_H
-
-FACTORSRC1 =	factor/SqrFree.cc factor/Factor.cc \
-		factor/MVMultiHensel.cc factor/Truefactor.cc \
-		factor/helpstuff.cc factor/homogfactor.cc factor/version.cc
-
-FACTORSRC2 =	factor/tmpl_inst.cc  
-
-FACTORSRC = 	$(FACTORSRC1) $(FACTORSRC2) 
-
-
-CHARSETSRC1 =	charset/csutil.cc charset/charset.cc charset/reorder.cc charset/alg_factor.cc charset/algfactor.cc
-
-CHARSETSRC = 	$(CHARSETSRC1)
-
-
-SOURCES  = $(FACTORSRC) $(CHARSETSRC)
-
-noinst_HEADERS = factor/SqrFree.h factor/Factor.h \
-    factor/MVMultiHensel.h factor/Truefactor.h \
-    factor/helpstuff.h factor/homogfactor.h \
-    factor/class.h factor/debug.h factor/interrupt.h factor/timing.h \
-    factor/tmpl_inst.h \
-    charset/csutil.h charset/charset.h charset/reorder.h charset/alg_factor.h charset/algfactor.h 
-
-libfac_la_SOURCES   = $(SOURCES)
-libfac_g_la_SOURCES = $(SOURCES)
-
-
-libfac_includedir=$(includedir)/factory/libfac
-
-libfac_include_HEADERS   = libfac.h 
-
-EXTRA_DIST = factor/class.cc \
-      factor/test.cc test.cc testcs.cc header.tpl \
-      tests charset/tests bin \
-      ChangeLog 00README 
-
-
-
Index: ctory/libfac/Makefile.dist
===================================================================
--- factory/libfac/Makefile.dist	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,156 +1,0 @@
-#################################################
-factoryversion = 1.2b
-factorypath = ../factory/$(factoryversion)
-RM = /bin/rm -f
-MV = /bin/mv
-AR = ar cr
-RANLIB = ranlib
-LIBPREFX = libfac
-OPTMARK =
-LIBFAC = $(LIBPREFIX)$(OPTMARK).a
-LIBFAC-G = $(LIBPREFIX)-g$(OPTMARK).a 
-SINGLIBFAC = libsingfac$(OPTMARK).a
-SINGLIBFAC-G = libsingfac-g$(OPTMARK).a  
-
-STRIP = strip
-# define the debugging flags here
-#
-FACDEFINES = 
-CHARDEFINES =
-DEFINES = $(FACDEFINES) $(CHARDEFINES)
-WARN = -Wall
-ALLFLAGS = -fno-implicit-templates 
-DEBFLAGS= -g $(DEFINES) $(ALLFLAGS)
-DEBFLAGSTMPL= -g $(DEFINES) 
-OPTFLAGS = -O3 $(DEFINES) $(ALLFLAGS) 
-OPTFLAGSTMPL= -O3 $(DEFINES) 
-
-IFLAGS =  -I/usr/local/include -I$(factorypath)  -I./factor
-CXX = gcc 
-OPTCXX = gcc
-CXXFLAGS = $(WARN) 
-
-# some machines don't like `gcc` as the linker for C++ code...
-# e.g. the SUN Sparc, so we use `g++` as the linker
-LD = g++ $(ALLFLAGS)
-OPTLD = g++ -s $(ALLFLAGS) 
-LDFLAGS=
-LIBPATH = -L/usr/local/lib -L$(factorypath) -L.
-
-.SUFFIXES:      .cc .h .o
-
-DEBOBJ/%.o: %.cc ; $(CXX) -c $< $(CXXFLAGS) $(IFLAGS) $(DEBFLAGS) -o $@
-
-OPTOBJ/%.o: %.cc ; $(OPTCXX) -c $< $(CXXFLAGS) $(IFLAGS) $(OPTFLAGS) -o $@
-
-DEBOBJ/%.o: charset/%.cc ; $(CXX) -c $< $(CXXFLAGS) $(IFLAGS) $(DEBFLAGS) -o $@
-
-OPTOBJ/%.o: charset/%.cc ; $(OPTCXX) -c $< $(CXXFLAGS) $(IFLAGS) $(OPTFLAGS) -o $@
-
-DEBOBJ/%.o: factor/%.cc ; $(CXX) -c $< $(CFLAGS) $(IFLAGS) $(DEBFLAGS) -o $@
-
-OPTOBJ/%.o: factor/%.cc ; $(OPTCXX) -c $< $(CFLAGS) $(IFLAGS) $(OPTFLAGS) -o $@
-
-
-FACTORSRC1 =	factor/SqrFree.cc factor/Factor.cc \
-		factor/MVMultiHensel.cc factor/Truefactor.cc \
-		factor/helpstuff.cc  factor/debug.cc factor/version.cc \
-		factor/homogfactor.cc
-FACTORSRC1 =	factor/tmpl_inst.cc
-FACTORSRC = 	$(FACTORSRC2) $(FACTORSRC1)
-CHARSETSRC1 =	charset/csutil.cc charset/charset.cc charset/reorder.cc
-CHARSETSRC = 	$(CHARSETSRC1)
-FACTORINCL =	factor/Factor.h factor/MVMultiHensel.h factor/Truefactor.h \
-		factor/tmpl_inst.h factor/SqrFree.h factor/helpstuff.h \
-		factor/debug.h factor/timing.h factor/homogfactor.h
-CHARSETINCL =	charset/csutil.h charset/charset.h charset/reorder.h
-
-OPTFACTOROBJ1 =	OPTOBJ/SqrFree.o OPTOBJ/Factor.o OPTOBJ/MVMultiHensel.o \
-		OPTOBJ/Truefactor.o OPTOBJ/helpstuff.o OPTOBJ/version.o \
-		OPTOBJ/homogfactor.o
-OPTFACTOROBJ2 =	OPTOBJ/tmpl_inst.o
-OPTFACTOROBJ =	$(OPTFACTOROBJ2) $(OPTFACTOROBJ1)
-
-DEBFACTOROBJ1 =	DEBOBJ/SqrFree.o DEBOBJ/Factor.o DEBOBJ/MVMultiHensel.o \
-		DEBOBJ/Truefactor.o DEBOBJ/helpstuff.o DEBOBJ/version.o \
-		DEBOBJ/homogfactor.o
-DEBFACTOROBJ2 =	DEBOBJ/tmpl_inst.o
-DEBFACTOROBJ =	$(DEBFACTOROBJ2) $(DEBFACTOROBJ1)
-
-CHARSETOPTOBJ =	OPTOBJ/csutil.o OPTOBJ/charset.o OPTOBJ/reorder.o
-
-CHARSETDEBOBJ =	DEBOBJ/csutil.o DEBOBJ/charset.o DEBOBJ/reorder.o
-
-LIBS = -lfac -lcf -lmem -lgmp -lm #-lPW
-OPTLIBS = -lfac -lcf-optimize -lmem-optimize -lgmp -lm
-DEBLIBS = -lfac-g -lcf-debug -lmem-debug -lgmp -lm
-
-debtest:	libfac-g DEBOBJ/test.o
-		$(LD) -o test $(LIBPATH) DEBOBJ/test.o $(DEBLIBS)
-
-opttest:	libfac OPTOBJ/test.o
-		$(OPTLD) -o test $(LIBPATH) OPTOBJ/test.o $(OPTLIBS)
-
-libfac.a:	$(OPTFACTOROBJ) $(CHARSETOPTOBJ)
-		$(AR) $(LIBFAC) $(OPTFACTOROBJ) $(CHARSETOPTOBJ)
-		$(RANLIB) $(LIBFAC)
-libfac:		libfac.a
-
-libfac-g.a:	$(DEBFACTOROBJ) $(CHARSETDEBOBJ)
-		$(AR) $(LIBFAC-G) $(DEBFACTOROBJ) $(CHARSETDEBOBJ)
-		$(RANLIB) $(LIBFAC-G)
-libfac-g:	libfac-g.a
-
-singlibfac.a:	$(OPTFACTOROBJ1) $(CHARSETOPTOBJ)
-		$(AR) $(SINGLIBFAC) $(OPTFACTOROBJ1) $(CHARSETOPTOBJ)
-		$(RANLIB) $(SINGLIBFAC)
-singlibfac:	singlibfac.a
-
-singlibfac-g.a:	$(DEBFACTOROBJ1) $(CHARSETDEBOBJ)
-		$(AR) $(SINGLIBFAC-G) $(DEBFACTOROBJ1) $(CHARSETDEBOBJ)
-		$(RANLIB) $(SINGLIBFAC-G)
-singlibfac-g:	singlibfac-g.a
-
-debtests:	debtest
-		(cd tests ; factortest )
-
-opttests:	opttest
-		(cd tests ; factortest )
-
-tests:		opttests
-
-newdepend: $(FACTORINCL) $(CHARSETINCL)
-	./bin/makedep -P OPTOBJ $(IFLAGS) $(FACTORSRC1) \
-				> OPTOBJ/optdepend
-	./bin/makedep -P DEBOBJ $(DEFINES) $(IFLAGS) $(FACTORSRC1) \
-				> DEBOBJ/debdepend
-depend:	newdepend
-
-clean:
-	$(RM)   test $(LIBFAC) $(LIBFAC-G) $(SINGLIBFAC) $(SINGLIBFAC-g)
-
-cleanall:	clean
-	( cd charset; make cleanall )
-	$(RM)   OPTOBJ/optdepend DEBOBJ/debdepend  \
-		DEBOBJ/*.o OPTOBJ/*.o \
-
-archive:	cleanall
-		(cd charset ; make cleanall )
-	rm -f ../libfac.tgz
-
-	gtar -zcvf ../libfac.tgz  . 
-
-disk:		archive
-	mcopy ../libfac.tgz a:\libfac.tgz
-	mcopy ../libfac.tgz a:\libfac1.tgz
-
-unpack:
-	mcopy a:\libfac.tgz ../libfac.tgz
-	gtar zxvf ../libfac.tgz
-	( cd charset ; make dirs )
-
-
-DEBOBJ/tmpl_inst.o: factor/tmpl_inst.cc ; $(CXX) -c $< $(CFLAGS) $(DEBFLAGSTMPL) $(IFLAGS) -o $@
-
-OPTOBJ/tmpl_inst.o: factor/tmpl_inst.cc ; $(OPTCXX) -c $< $(CFLAGS) $(OPTFLAGSTMPL) $(IFLAGS) -o $@
-
Index: ctory/libfac/Makefile.in.SAVE_LIBFAC
===================================================================
--- factory/libfac/Makefile.in.SAVE_LIBFAC	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,200 +1,0 @@
-#################################################
-SHELL		= /bin/sh
-RM		= -rm -f
-#################################################
-TARGETNAME		= @targetname@
-LIBFACNAME		= @libfac_name@
-LIBFACVERSION		= @libfac_version@
-LIBFACDATE		= @libfac_date@
-LIBFACAUTHOR		= @libfac_author@
-LIBFACNAME		= @libfac@
-SINGLIBFACNAME		= @libsingfac@
-LIBFACINCLUDE		= @factorH@
-#################################################
-## 
-## various paths
-##
-srcdir		= @srcdir@
-prefix 		= @prefix@
-exec_prefix	= @exec_prefix@
-libdir 		= @libdir@
-includedir	= @includedir@
-
-## 
-## various programs
-##
-AR		= @AR@ cr
-RANLIB		= @RANLIB@
-CXX		= @CXX@
-INSTALL		= ./install-sh -c
-INSTALL_DATA	= ${INSTALL} -m 644
-INSTALL_PROGRAM = ${INSTALL}
-MKINSTALLDIRS	= ./mkinstalldirs
-
-##
-## compiler and linker options
-##
-CXXFLAGS	= @CXXFLAGS@
-CXXTEMPLFLAGS	= @CXXTEMPLFLAGS@
-CPPFLAGS	= -I${srcdir}/factor -I${srcdir}/charset -I${srcdir} -I.. -I${prefix} @CPPFLAGS@ 
-DEFS		= @DEFS@ 
-LDFLAGS		= @LDFLAGS@
-LIBS		= -lfac -lcf -lcfmem -lgmp @LIBS@
-
-##
-## src and objects
-##
-
-FACTORSRC1 =	factor/SqrFree.cc factor/Factor.cc \
-		factor/MVMultiHensel.cc factor/Truefactor.cc \
-		factor/helpstuff.cc  factor/version.cc \
-		factor/homogfactor.cc 
-FACTORSRC2 =	factor/tmpl_inst.cc
-FACTORSRC = 	$(FACTORSRC2) $(FACTORSRC1)
-
-CHARSETSRC1 =	charset/csutil.cc charset/charset.cc charset/reorder.cc
-CHARSETSRC = 	$(CHARSETSRC1)
-
-FACTORINCL =	factor/Factor.h factor/MVMultiHensel.h factor/Truefactor.h \
-		factor/tmpl_inst.h factor/SqrFree.h factor/helpstuff.h \
-		factor/debug.h factor/timing.h factor/homogfactor.h \
-                factor/interrupt.h
-CHARSETINCL =	charset/csutil.h charset/charset.h charset/reorder.h \
-		charset/alg_factor.h charset/algfactor.h
-
-OPTFACTOROBJ1 =	OPTOBJ/SqrFree.o OPTOBJ/Factor.o OPTOBJ/MVMultiHensel.o \
-		OPTOBJ/Truefactor.o OPTOBJ/helpstuff.o OPTOBJ/version.o \
-		OPTOBJ/homogfactor.o
-OPTFACTOROBJ2 =	OPTOBJ/tmpl_inst.o
-OPTFACTOROBJ =	$(OPTFACTOROBJ2) $(OPTFACTOROBJ1)
-
-OPTCHARSETOBJ =	OPTOBJ/csutil.o OPTOBJ/charset.o OPTOBJ/reorder.o \
-		OPTOBJ/alg_factor.o OPTOBJ/algfactor.o
-
-DEBOBJ = $(OPTFACTOROBJ1:%.o=%.og) $(OPTCHARSETOBJ:%.o=%.og)
-PROFOBJ = $(OPTFACTOROBJ1:%.o=%.op) $(OPTCHARSETOBJ:%.o=%.op)
-
-##
-## Primary targets
-##
-
-.SUFFIXES:      .cc .h .o .op .og
-
-all: OPTOBJ ${TARGETNAME} libsingfac_g.a
-
-OPTOBJ:
-	${MKINSTALLDIRS} OPTOBJ
-
-OPTOBJ/%.o: %.cc OPTOBJ
-	$(CXX) $(CXXFLAGS) $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/%.o: charset/%.cc OPTOBJ
-	$(CXX) $(CXXFLAGS) $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/%.o: factor/%.cc OPTOBJ
-	$(CXX) $(CXXFLAGS) $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/tmpl_inst.o: factor/tmpl_inst.cc  OPTOBJ
-	$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/%.op: %.cc  OPTOBJ
-	$(CXX) -O -pg $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/%.op: charset/%.cc  OPTOBJ
-	$(CXX) -O -pg $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/%.op: factor/%.cc OPTOBJ
-	$(CXX) -O -pg $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/tmpl_inst.op: factor/tmpl_inst.cc  OPTOBJ
-	$(CXX) -O -pg $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/%.og: %.cc  OPTOBJ
-	$(CXX) -g $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/%.og: charset/%.cc  OPTOBJ
-	$(CXX) -g $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/%.og: factor/%.cc OPTOBJ
-	$(CXX) -g $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-OPTOBJ/tmpl_inst.og: factor/tmpl_inst.cc  OPTOBJ
-	$(CXX) -g $(CPPFLAGS) $(DEFS) -c $< -o $@
-
-libfac:		OPTOBJ libfac.a
-
-libsingfac:	OPTOBJ libsingfac.a
-
-libsingfac_g:	OPTOBJ libsingfac_g.a
-
-libfac.a:	$(OPTFACTOROBJ) $(OPTCHARSETOBJ)
-		$(AR) ${LIBFACNAME}.a $(OPTFACTOROBJ) $(OPTCHARSETOBJ)
-		$(RANLIB) ${LIBFACNAME}.a
-
-libsingfac.a:	$(OPTFACTOROBJ1) $(OPTCHARSETOBJ)
-		$(AR) ${SINGLIBFACNAME}.a $(OPTFACTOROBJ1) $(OPTCHARSETOBJ)
-		$(RANLIB) ${SINGLIBFACNAME}.a
-
-libsingfac_g.a:	$(DEBOBJ)
-		$(AR) $@ $^
-		$(RANLIB) $@
-
-libsingfac_p.a:	$(PROFOBJ)
-		$(AR) $@ $^
-		$(RANLIB) $@
-
-install-nolns: install
-
-install install-libsingular:	all
-	${MKINSTALLDIRS} ${includedir}
-	${MKINSTALLDIRS} ${libdir}
-	${INSTALL_DATA} ${LIBFACINCLUDE} ${includedir}
-	${INSTALL_DATA} ${TARGETNAME}.a ${libdir}
-	-${INSTALL_DATA} libsingfac_g.a ${libdir}
-	$(RANLIB) ${libdir}/${TARGETNAME}.a
-	-$(RANLIB) ${libdir}/libsingfac_g.a
-
-install_all: install libsingfac_p.a
-	-${INSTALL_DATA} libsingfac_p.a ${libdir}
-	-$(RANLIB) ${libdir}/libsingfac_p.a
-
-uninstall: 
-	$(RM) ${includedir}/${LIBFACINCLUDE}
-	$(RM) ${libdir}/${LIBFACNAME}.a
-	$(RM) ${libdir}/${SINGLIBFACNAME}.a
-
-mostlyclean:
-	$(RM)	test testcs ${LIBFACNAME}.a ${SINGLIBFACNAME}.a \
-		libsingfac_g.a libsingfac_p.a 
-
-clean:	mostlyclean
-	$(RM) OPTOBJ/optdepend OPTOBJ/debdepend  \
-	      OPTOBJ/*.op OPTOBJ/*.og OPTOBJ/*.o
-
-distclean:	clean
-	$(RM) config.cache config.log config.status Makefile
-
-dist:	distclean
-	$(RM) ../libfac-${LIBFACVERSION}.tgz
-	(cd .. ; gtar -zcvf libfac-${LIBFACVERSION}.tgz libfac-${LIBFACVERSION})
-
-depend:
-	@echo "No make depend available!"
-
-########## From here on: Only for internal use!
-#################################################
-
-factest:	libfac OPTOBJ/test.o   
-		$(CXX) -o test $(LDFLAGS) OPTOBJ/test.o $(LIBS)
-
-factests:	factest
-		(cd tests ; factortest )
-
-charsettest:	libfac	OPTOBJ/testcs.o
-		$(CXX) -o testcs $(LDFLAGS) OPTOBJ/testcs.o $(LIBS)
-
-#charsettests:	charsettest
-#		(cd tests ; charsettest )
-
-tests:		factests
-
Index: ctory/libfac/bin/makedep
===================================================================
--- factory/libfac/bin/makedep	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,70 +1,0 @@
-#!/usr/local/bin/perl
-
-# Usage: makedep [options] [files]
-
-# Configuration parameters.
-
-$CPP = "gcc -E";
-# $CPP = "cc -P";
-# $CPP = "/lib/cpp";
-
-# Process switches.
-
-$noglobincludes = 1;
-$prefix = "";
-
-while ($ARGV[0] =~ /^-/) {
-    $_ = shift;
-    if (/^-D(.*)/) {
-	$defines .= " -D" . ($1 ? $1 : shift);
-    }
-    elsif (/^-I(.*)/) {
-	$includes .= " -I" . ($1 ? $1 : shift);
-    }
-    elsif (/^-d(.*)/) {
-	$dir = ($1 ? $1 : shift);
-    }
-    elsif (/^-G/) {
-	$noglobincludes = 0;
-    }
-    elsif (/^-P/) {
-	$prefix .= ($1 ? $1 : shift) . "/";
-    }
-    else {
-	die "Unrecognized switch: $_\n";
-    }
-}
-
-# Do each file on command line.
-
-foreach $file (@ARGV) {
-    open(CPP,"$CPP $defines $includes $file|")
-	|| die "Can't run cpp: $!\n";
-
-    # Scan output for line directives.
-
-    %seen = ();
-    while (<CPP>) {
-	next unless /^#/;
-	next unless ($filename) = /^# \d.*"(.*)"/;
-	$seen{$filename}++;
-    }
-    close CPP;
-
-    # Figure out the corresponding object file name.
-
-    ($ofile = $file) =~ s/\.c$/.o/;
-    ($ofile = $ofile) =~ s/\.C$/.o/;
-    ($ofile = $ofile) =~ s/\.cpp$/.o/;
-    ($ofile = $ofile) =~ s/\.cxx$/.o/;
-    ($ofile = $ofile) =~ s/\.cc$/.o/;
-    $ofile =~ s#.*/##;
-    $ofile = "$dir/$ofile" if $dir;
-
-    # Print out the dependencies.
-
-    foreach (sort keys(%seen)) {
-        print "$prefix$ofile: $_\n" unless ( /^\// && $noglobincludes );
-    }
-    print "\n";
-}
Index: ctory/libfac/bin/makeheader
===================================================================
--- factory/libfac/bin/makeheader	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,51 +1,0 @@
-#!/usr/local/bin/perl
-
-###
-### makeheader - generate a header file out of several header file (ver 1.1)
-###
-
-if ( ( $#ARGV == 0 ) && ( $ARGV[0] eq '-help' ) ) {
-    die "\nThis is makeheader, a header file generation tool.\n\n" .
-	"   with makeheader it is possible to generate a single header\n" .
-	"   file out of several other header files\n" .
-	"   the parts to be included in the generated header file have\n" .
-	"   to be marked with /*BEGINPUBLIC*/ and /*ENDPUBLIC*/\n" .
-        "   to include a header file into the generated header file use\n" .
-	"   the command .INCLUDE name.h on a single line\n\n" .
-        "usage: makeheader <template> <outfile>\n\n";
-}
-
-if ( $#ARGV < 1 ) {
-    die "usage: makeheader <template> <outfile>\n\n";
-}
-
-$infile = shift( @ARGV );
-$outfile = shift( @ARGV );
-
-open( INFILE, $infile ) || 
-    die "makeheader: can not open template file $infile for reading!\n";
-open( OUTFILE, ">$outfile" ) ||
-    die "makeheader: can not open header file $outfile for writing!\n";
-
-while( $currentline = <INFILE> ) {
-    if ( index( $currentline, ".INCLUDE" ) == 0 ) {
-	$currentline =~ s/.INCLUDE //;
-	open( INCLFILE, $currentline ) ||
-	    die "can not open included file '$currentline' for reading!\n";
-	while ( $inclline = <INCLFILE> ) {
-	    if ( index( $inclline, "/*BEGINPUBLIC*/" ) >= 0 ) {
-		while (( $inclline = <INCLFILE> ) &&
-		       ( index( $inclline, "/*ENDPUBLIC*/" ) < 0 )) {
-		    print OUTFILE $inclline;
-		}
-	    }
-	}
-    }
-    else {
-	print OUTFILE $currentline;
-    }
-}
-
-close OUTFILE;
-close INFILE;
-
Index: ctory/libfac/charset/alg_factor.cc
===================================================================
--- factory/libfac/charset/alg_factor.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,768 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////
-// FACTORY - Includes
-#include <factory.h>
-// Factor - Includes
-#include <tmpl_inst.h>
-#include <Factor.h>
-#include <SqrFree.h>
-#include <helpstuff.h>
-// Charset - Includes
-#include "csutil.h"
-#include "charset.h"
-#include "reorder.h"
-#include "algfactor.h"
-// some CC's need this:
-#include "alg_factor.h"
-
-void out_cf(char *s1,const CanonicalForm &f,char *s2);
-
-#ifdef ALGFACTORDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-
-#include <libfac/factor/debug.h>
-
-static Varlist
-Var_is_in_AS(const Varlist & uord, const CFList & Astar);
-
-int getAlgVar(const CanonicalForm &f, Variable &X)
-{
-  if (f.inBaseDomain()) return 0;
-  if (f.inCoeffDomain())
-  {
-    if (f.level()!=0)
-    {
-      X= f.mvar();
-      return 1;
-    }
-    return getAlgVar(f.LC(),X);
-  }
-  if (f.inPolyDomain())
-  {
-    if (getAlgVar(f.LC(),X)) return 1;
-    for( CFIterator i=f; i.hasTerms(); i++)
-    {
-      if (getAlgVar(i.coeff(),X)) return 1;
-    }
-  }
-  return 0;
-}
-
-////////////////////////////////////////////////////////////////////////
-// This implements the algorithm of Trager for factorization of
-// (multivariate) polynomials over algebraic extensions and so called
-// function field extensions.
-////////////////////////////////////////////////////////////////////////
-
-// // missing class: IntGenerator:
-bool IntGenerator::hasItems() const
-{
-    return 1;
-}
-
-CanonicalForm IntGenerator::item() const
-//int IntGenerator::item() const
-{
-  //return current; //CanonicalForm( current );
-  return mapinto(CanonicalForm( current ));
-}
-
-void IntGenerator::next()
-{
-    current++;
-}
-
-// replacement for factory's broken psr
-static CanonicalForm
-mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x ){
-  CanonicalForm r=rr, v=vv, l, test, lu, lv, t, retvalue;
-  int dr, dv, d,n=0;
-
-
-  dr = degree( r, x );
-  dv = degree( v, x );
-  if (dv <= dr) {l=LC(v,x); v = v -l*power(x,dv);}
-  else { l = 1; }
-  d= dr-dv+1;
-  while ( ( dv <= dr  ) && ( r != r.genZero()) ){
-    test = power(x,dr-dv)*v*LC(r,x);
-    if ( dr == 0 ) { r= CanonicalForm(0); }
-    else { r= r - LC(r,x)*power(x,dr); }
-    r= l*r -test;
-    dr= degree(r,x);
-    n+=1;
-  }
-  r= power(l, d-n)*r;
-  return r;
-}
-
-// replacement for factory's broken resultant
-static CanonicalForm
-resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v ){
-  bool on_rational = isOn(SW_RATIONAL);
-  On(SW_RATIONAL);
-  CanonicalForm cd = bCommonDen( f );
-  CanonicalForm fz = f * cd;
-  cd = bCommonDen( g );
-  CanonicalForm gz = g * cd;
-  if (!on_rational)  Off(SW_RATIONAL);
-
-return resultant(fz,gz,v);
-}
-
-// sqr-free routine for algebraic extensions
-// we need it! Ex.: f=c^2+2*a*c-1; as=[a^2+1]; f=(c+a)^2
-//static CFFList alg_sqrfree( const CanonicalForm & f )
-//{
-//  CFFList L;
-//
-//  L.append(CFFactor(f,1));
-//  return L;
-//}
-
-// Calculates a square free norm
-// Input: f(x, alpha) a square free polynomial over K(alpha),
-// alpha is defined by the minimal polynomial Palpha
-// K has more than S elements (S is defined in thesis; look getextension)
-static void
-sqrf_norm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
-           CFGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
-           CanonicalForm & R){
-  Variable y=PPalpha.mvar(),vf=f.mvar();
-  CanonicalForm temp, Palpha=PPalpha, t;
-  int sqfreetest=0;
-  CFFList testlist;
-  CFFListIterator i;
-
-  DEBOUTLN(CERR, "sqrf_norm_sub:      f= ", f);
-  DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
-  myrandom.reset();   s=f.mvar()-myrandom.item()*Palpha.mvar();   g=f;
-  R= CanonicalForm(0);
-  DEBOUTLN(CERR, "sqrf_norm_sub: myrandom s= ", s);
-
-  // Norm, resultante taken with respect to y
-  while ( !sqfreetest ){
-    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
-    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
-    DEBOUTLN(CERR, "sqrf_norm_sub: R= ", R);
-    // sqfree check ; R is a polynomial in K[x]
-    if ( getCharacteristic() == 0 )
-    {
-      temp= gcd(R, R.deriv(vf));
-      DEBOUTLN(CERR, "sqrf_norm_sub: temp= ", temp);
-      if (degree(temp,vf) != 0 || temp == temp.genZero() ){ sqfreetest= 0; }
-      else { sqfreetest= 1; }
-      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
-    }
-    else{
-      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
-      // Look at SqrFreeTest!
-      // (z+a^5+w)^4 with z<w<a should not give sqfreetest=1 !
-      // for now we use this workaround with Factorize...
-      // ...but it should go away soon!!!!
-      Variable X;
-      if (getAlgVar(R,X))
-      {
-        if (R.isUnivariate())
-          testlist=factorize( R, X );
-        else
-          testlist= Factorize(R, X, 0);
-      }
-      else
-        testlist= Factorize(R);
-      DEBOUTLN(CERR, "testlist= ", testlist);
-      testlist.removeFirst();
-      sqfreetest=1;
-      for ( i=testlist; i.hasItem(); i++)
-        if ( i.getItem().exp() > 1 && degree(i.getItem().factor(), R.mvar()) > 0) { sqfreetest=0; break; }
-      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
-    }
-    if ( ! sqfreetest ){
-      myrandom.next();
-      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
-      if ( getCharacteristic() == 0 ) t= CanonicalForm(mapinto(myrandom.item()));
-      else t= CanonicalForm(myrandom.item());
-      s= f.mvar()+t*Palpha.mvar(); // s defines backsubstitution
-      DEBOUTLN(CERR, "sqrf_norm_sub: testing s= ", s);
-      g= f(f.mvar()-t*Palpha.mvar(), f.mvar());
-      DEBOUTLN(CERR, "             gives g= ", g);
-    }
-  }
-}
-static void
-sqrf_agnorm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
-           AlgExtGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
-           CanonicalForm & R){
-  Variable y=PPalpha.mvar(),vf=f.mvar();
-  CanonicalForm temp, Palpha=PPalpha, t;
-  int sqfreetest=0;
-  CFFList testlist;
-  CFFListIterator i;
-
-  DEBOUTLN(CERR, "sqrf_norm_sub:      f= ", f);
-  DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
-  myrandom.reset();   s=f.mvar()-myrandom.item()*Palpha.mvar();   g=f;
-  R= CanonicalForm(0);
-  DEBOUTLN(CERR, "sqrf_norm_sub: myrandom s= ", s);
-
-  // Norm, resultante taken with respect to y
-  while ( !sqfreetest ){
-    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
-    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
-    DEBOUTLN(CERR, "sqrf_norm_sub: R= ", R);
-    // sqfree check ; R is a polynomial in K[x]
-    if ( getCharacteristic() == 0 )
-    {
-      temp= gcd(R, R.deriv(vf));
-      DEBOUTLN(CERR, "sqrf_norm_sub: temp= ", temp);
-      if (degree(temp,vf) != 0 || temp == temp.genZero() ){ sqfreetest= 0; }
-      else { sqfreetest= 1; }
-      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
-    }
-    else{
-      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
-      // Look at SqrFreeTest!
-      // (z+a^5+w)^4 with z<w<a should not give sqfreetest=1 !
-      // for now we use this workaround with Factorize...
-      // ...but it should go away soon!!!!
-      Variable X;
-      if (getAlgVar(R,X))
-      {
-        if (R.isUnivariate())
-          testlist=factorize( R, X );
-        else
-          testlist= Factorize(R, X, 0);
-      }
-      else
-        testlist= Factorize(R);
-      DEBOUTLN(CERR, "testlist= ", testlist);
-      testlist.removeFirst();
-      sqfreetest=1;
-      for ( i=testlist; i.hasItem(); i++)
-        if ( i.getItem().exp() > 1 && degree(i.getItem().factor(), R.mvar()) > 0) { sqfreetest=0; break; }
-      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
-    }
-    if ( ! sqfreetest ){
-      myrandom.next();
-      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
-      if ( getCharacteristic() == 0 ) t= CanonicalForm(mapinto(myrandom.item()));
-      else t= CanonicalForm(myrandom.item());
-      s= f.mvar()+t*Palpha.mvar(); // s defines backsubstitution
-      DEBOUTLN(CERR, "sqrf_norm_sub: testing s= ", s);
-      g= f(f.mvar()-t*Palpha.mvar(), f.mvar());
-      DEBOUTLN(CERR, "             gives g= ", g);
-    }
-  }
-}
-
-static void
-sqrf_norm( const CanonicalForm & f, const CanonicalForm & PPalpha,
-           const Variable & Extension, CanonicalForm & s,  CanonicalForm & g,
-           CanonicalForm & R){
-
-  DEBOUTLN(CERR, "sqrf_norm:      f= ", f);
-  DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha);
-  if ( getCharacteristic() == 0 ) {
-    IntGenerator myrandom;
-    DEBOUTMSG(CERR, "sqrf_norm: no extension, char=0");
-    sqrf_norm_sub(f,PPalpha, myrandom, s,g,R);
-    DEBOUTLN(CERR, "sqrf_norm:      f= ", f);
-    DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha);
-    DEBOUTLN(CERR, "sqrf_norm:      s= ", s);
-    DEBOUTLN(CERR, "sqrf_norm:      g= ", g);
-    DEBOUTLN(CERR, "sqrf_norm:      R= ", R);
-  }
-  else if ( degree(Extension) > 0 ){ // working over Extensions
-    DEBOUTLN(CERR, "sqrf_norm: degree of extension is ", degree(Extension));
-    AlgExtGenerator myrandom(Extension);
-    sqrf_agnorm_sub(f,PPalpha, myrandom, s,g,R);
-  }
-  else{
-    FFGenerator myrandom;
-    DEBOUTMSG(CERR, "sqrf_norm: degree of extension is 0");
-    sqrf_norm_sub(f,PPalpha, myrandom, s,g,R);
-  }
-}
-
-static Varlist
-Var_is_in_AS(const Varlist & uord, const CFList & Astar){
-  Varlist output;
-  CanonicalForm elem;
-  Variable x;
-
-  for ( VarlistIterator i=uord; i.hasItem(); i++){
-    x=i.getItem();
-    for ( CFListIterator j=Astar; j.hasItem(); j++ ){
-      elem= j.getItem();
-      if ( degree(elem,x) > 0 ){ // x actually occures in Astar
-        output.append(x);
-        break;
-      }
-    }
-  }
-  return output;
-}
-
-// Look if Minimalpolynomials in Astar define seperable Extensions
-// Must be a power of p: i.e. y^{p^e}-x
-static int
-inseperable(const CFList & Astar){
-  CanonicalForm elem;
-  int Counter= 1;
-
-  if ( Astar.length() == 0 ) return 0;
-  for ( CFListIterator i=Astar; i.hasItem(); i++){
-    elem= i.getItem();
-    if ( elem.deriv() == elem.genZero() ) return Counter;
-    else Counter += 1;
-  }
-  return 0;
-}
-
-// calculate gcd of f and g in char=0
-static CanonicalForm
-gcd0( CanonicalForm f, CanonicalForm g ){
-  int charac= getCharacteristic();
-  int save=isOn(SW_RATIONAL);
-  setCharacteristic(0); Off(SW_RATIONAL);
-  CanonicalForm ff= mapinto(f), gg= mapinto(g);
-  CanonicalForm result= gcd(ff,gg);
-  setCharacteristic(charac); 
-  if (save) On(SW_RATIONAL);
-  return mapinto(result);
-}
-
-// calculate big enough extension for finite fields
-// Idea: first calculate k, such that q^k > S (->thesis, -> getextension)
-// Second, search k with gcd(k,m_i)=1, where m_i is the degree of the i'th
-// minimal polynomial. Then the minpoly f_i remains irrd. over q^k and we
-// have enough elements to plug in.
-static int
-getextension( IntList & degreelist, int n){
-  int charac= getCharacteristic();
-  setCharacteristic(0); // need it for k !
-  int k=1, m=1, length=degreelist.length();
-  IntListIterator i;
-
-  for (i=degreelist; i.hasItem(); i++) m= m*i.getItem();
-  int q=charac;
-  while (q <= ((n*m)*(n*m)/2)) { k= k+1; q= q*charac;}
-  int l=0;
-  do {
-    for (i=degreelist; i.hasItem(); i++){
-      l= l+1;
-      if ( gcd0(k,i.getItem()) == 1){
-        DEBOUTLN(CERR, "getextension: gcd == 1, l=",l);
-        if ( l==length ){ setCharacteristic(charac);  return k; }
-      }
-      else { DEBOUTMSG(CERR, "getextension: Next iteration"); break; }
-    }
-    k= k+1; l=0;
-  }
-  while ( 1 );
-}
-
-// calculate a "primitive element"
-// K must have more than S elements (->thesis, -> getextension)
-static CFList
-simpleextension(const CFList & Astar, const Variable & Extension,
-                CanonicalForm & R){
-  CFList Returnlist, Bstar=Astar;
-  CanonicalForm s, g;
-
-  DEBOUTLN(CERR, "simpleextension: Astar= ", Astar);
-  DEBOUTLN(CERR, "simpleextension:     R= ", R);
-  DEBOUTLN(CERR, "simpleextension: Extension= ", Extension);
-  if ( Astar.length() == 1 ){ R= Astar.getFirst();}
-  else{
-    R=Bstar.getFirst(); Bstar.removeFirst();
-    for ( CFListIterator i=Bstar; i.hasItem(); i++){
-      DEBOUTLN(CERR, "simpleextension: f(x)= ", i.getItem());
-      DEBOUTLN(CERR, "simpleextension: P(x)= ", R);
-      sqrf_norm(i.getItem(), R, Extension, s, g, R);
-      // spielt die Repraesentation eine Rolle?
-      // muessen wir die Nachfolger aendern, wenn s != 0 ?
-      DEBOUTLN(CERR, "simpleextension: g= ", g);
-      if ( s != 0 ) DEBOUTLN(CERR, "simpleextension: s= ", s);
-      else DEBOUTLN(CERR, "simpleextension: s= ", s);
-      DEBOUTLN(CERR, "simpleextension: R= ", R);
-      Returnlist.insert(s);
-    }
-  }
-
-  return Returnlist;
-}
-
-CanonicalForm alg_lc(const CanonicalForm &f)
-{
-  if (f.level()>0)
-  {
-    return alg_lc(f.LC());
-  }
-  //assert(f.inCoeffDomain());
-  return f;
-}
-
-// the heart of the algorithm: the one from Trager
-static CFFList
-alg_factor( const CanonicalForm & f, const CFList & Astar, const Variable & vminpoly, const Varlist & oldord, const CFList & as)
-{
-  CFFList L, Factorlist;
-  CanonicalForm R, Rstar, s, g, h;
-  CFList substlist;
-
-  DEBINCLEVEL(CERR,"alg_factor");
-  DEBOUTLN(CERR, "alg_factor: f= ", f);
-
-  //out_cf("start alg_factor:",f,"\n");
-  substlist= simpleextension(Astar, vminpoly, Rstar);
-  DEBOUTLN(CERR, "alg_factor: substlist= ", substlist);
-  DEBOUTLN(CERR, "alg_factor: minpoly Rstar= ", Rstar);
-  DEBOUTLN(CERR, "alg_factor: vminpoly= ", vminpoly);
-
-  sqrf_norm(f, Rstar, vminpoly, s, g, R );
-  //out_cf("sqrf_norm R:",R,"\n");
-  //out_cf("sqrf_norm s:",s,"\n");
-  //out_cf("sqrf_norm g:",g,"\n");
-  DEBOUTLN(CERR, "alg_factor: g= ", g);
-  DEBOUTLN(CERR, "alg_factor: s= ", s);
-  DEBOUTLN(CERR, "alg_factor: R= ", R);
-  Off(SW_RATIONAL);
-  Variable X;
-  if (getAlgVar(R,X))
-  {
-    // factorize R over alg.extension with X
-//CERR << "alg: "<< X << " mipo=" << getMipo(X,Variable('X')) <<"\n";
-    if (R.isUnivariate())
-    {
-      DEBOUTLN(CERR, "alg_factor: factorize( ", R);
-      Factorlist =  factorize( R, X );
-    }
-    else
-    {
-      #if 1
-      Variable XX;
-      CanonicalForm mipo=getMipo(X,XX);
-      CFList as(mipo);
-      DEBOUTLN(CERR, "alg_factor: newfactoras( ", R);
-      int success=1;
-      Factorlist = newfactoras(R, as , success);
-      #else
-      // factor R over k
-      DEBOUTLN(CERR, "alg_factor: Factorize( ", R);
-      Factorlist = Factorize(R);
-      #endif
-    }
-  }
-  else
-  {
-    // factor R over k
-    DEBOUTLN(CERR, "alg_factor: Factorize( ", R);
-    Factorlist = Factorize(R);
-  }
-  On(SW_RATIONAL);
-  DEBOUTLN(CERR, "alg_factor: Factorize(R)= ", Factorlist);
-  if ( !Factorlist.getFirst().factor().inCoeffDomain() )
-    Factorlist.insert(CFFactor(1,1));
-  if ( Factorlist.length() == 2 && Factorlist.getLast().exp()== 1)
-  { // irreduzibel (first entry is a constant)
-    L.append(CFFactor(f,1));
-  }
-  else
-  {
-    DEBOUTLN(CERR, "alg_factor: g= ", g);
-    CanonicalForm gnew= g(s,s.mvar());
-    DEBOUTLN(CERR, "alg_factor: gnew= ", gnew);
-    g=gnew;
-    for ( CFFListIterator i=Factorlist; i.hasItem(); i++)
-    {
-      CanonicalForm fnew=i.getItem().factor();
-      fnew= fnew(s,s.mvar());
-      DEBOUTLN(CERR, "alg_factor: fnew= ", fnew);
-      DEBOUTLN(CERR, "alg_factor: substlist= ", substlist);
-      for ( CFListIterator ii=substlist; ii.hasItem(); ii++){
-        DEBOUTLN(CERR, "alg_factor: item= ", ii.getItem());
-        fnew= fnew(ii.getItem(), ii.getItem().mvar());
-        DEBOUTLN(CERR, "alg_factor: fnew= ", fnew);
-      }
-      if (degree(i.getItem().factor()) > 0 )
-      {
-          h=alg_gcd(g,fnew,as);
-        DEBOUTLN(CERR, "  alg_factor: h= ", h);
-        DEBOUTLN(CERR, "  alg_factor: oldord= ", oldord);
-        if ( degree(h) > 0 )
-        { //otherwise it's a constant
-          g= divide(g, h,as);
-          DEBOUTLN(CERR, "alg_factor: g/h= ", g);
-          DEBOUTLN(CERR, "alg_factor: s= ", s);
-          DEBOUTLN(CERR, "alg_factor: substlist= ", substlist);
-          //out_cf("new g:",g,"\n");
-          L.append(CFFactor(h,1));
-        }
-        //else printf("degree <=1\n");
-      }
-    }
-    // we are not interested in a
-    // constant (over K_r, which can be a polynomial!)
-    if (degree(g, f.mvar())>0){ L.append(CFFactor(g,1)); }
-  }
-  CFFList LL;
-  if (getCharacteristic()>0)
-  {
-    CFFListIterator i=L;
-    CanonicalForm c_fac=1;
-    CanonicalForm c;
-    for(;i.hasItem(); i++ )
-    {
-      CanonicalForm ff=i.getItem().factor();
-      c=alg_lc(ff);
-      int e=i.getItem().exp();
-      ff/=c;
-      if (!ff.isOne()) LL.append(CFFactor(ff,e));
-      while (e>0) { c_fac*=c;e--; }
-    }
-    if (!c_fac.isOne()) LL.insert(CFFactor(c_fac,1));
-  }
-  else
-  {
-    LL=L;
-  }
-  //CFFListIterator i=LL;
-  //for(;i.hasItem(); i++ )
-  //  out_cf("end alg_f:",i.getItem().factor(),"\n");
-  //printf("end alg_factor\n");
-  DEBOUTLN(CERR, "alg_factor: L= ", LL);
-  DEBDECLEVEL(CERR,"alg_factor");
-  return LL;
-}
-
-static CFFList
-endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ){
-  CanonicalForm F=f, g, q,r;
-  CFFList Output;
-  CFList One, Two, asnew, as=AS;
-  CFListIterator i,ii;
-  VarlistIterator j;
-  Variable vg;
-
-  for (i=as; i.hasItem(); i++){
-    g= i.getItem();
-    if (g.deriv() == 0 ){
-      DEBOUTLN(CERR, "Inseperable extension detected: ", g);
-      for (j=uord; j.hasItem(); j++){
-        if ( degree(g,j.getItem()) > 0 ) vg= j.getItem();
-      }
-      // Now we have the highest transzendental in vg;
-      DEBOUTLN(CERR, "Transzendental is ", vg);
-      CanonicalForm gg=-1*g[0];
-      divrem(gg,vg,q,r); r= gg-q*vg;   gg= gg-r;
-      //DEBOUTLN(CERR, "q= ", q); DEBOUTLN(CERR, "r= ", r);
-      DEBOUTLN(CERR, "  that is ", gg);
-      DEBOUTLN(CERR, "  maps to ", g+gg);
-      One.insert(gg); Two.insert(g+gg);
-      // Now transform all remaining polys in as:
-      int x=0;
-      for (ii=i; ii.hasItem(); ii++){
-        if ( x != 0 ){
-          divrem(ii.getItem(), gg, q,r);
-//          CERR << ii.getItem() << " divided by " << gg << "\n";
-          DEBOUTLN(CERR, "q= ", q); DEBOUTLN(CERR, "r= ", r);
-          ii.append(ii.getItem()+q*g); ii.remove(1);
-          DEBOUTLN(CERR, "as= ", as);
-        }
-        x+= 1;
-      }
-      // Now transform F:
-      divrem(F, gg, q,r);
-      F= F+q*g;
-      DEBOUTLN(CERR, "new F= ", F);
-    }
-    else{ asnew.append(i.getItem());  }// just the identity
-  }
-  // factor F with minimal polys given in asnew:
-  DEBOUTLN(CERR, "Factor F=  ", F);
-  DEBOUTLN(CERR, "  with as= ", asnew);
-  int success=0;
-  CFFList factorlist= newcfactor(F,asnew, success);
-  DEBOUTLN(CERR, "  gives =  ", factorlist);
-  DEBOUTLN(CERR, "One= ", One);
-  DEBOUTLN(CERR, "Two= ", Two);
-
-  // Transform back:
-  for ( CFFListIterator k=factorlist; k.hasItem(); k++){
-    CanonicalForm factor= k.getItem().factor();
-    ii=One;
-    for (i=Two; i.hasItem(); i++){
-      DEBOUTLN(CERR, "Mapping ", i.getItem());
-      DEBOUTLN(CERR, "     to ", ii.getItem());
-      DEBOUTLN(CERR, "     in ", factor);
-      divrem(factor,i.getItem(),q,r); r=factor -q*i.getItem();
-      DEBOUTLN(CERR, "q= ", q); DEBOUTLN(CERR, "r= ", r);
-      factor= ii.getItem()*q +r; //
-      ii++;
-    }
-    Output.append(CFFactor(factor,k.getItem().exp()));
-  }
-
-  return Output;
-}
-
-
-// 1) prepares data
-// 2) for char=p we distinguish 3 cases:
-//           no transcendentals, seperable and inseperable extensions
-CFFList
-newfactoras( const CanonicalForm & f, const CFList & as, int &success){
-  Variable vf=f.mvar();
-  CFListIterator i;
-  CFFListIterator jj;
-  CFList reduceresult;
-  CFFList result;
-
-  success=1;
-  DEBINCLEVEL(CERR, "newfactoras");
-  DEBOUTLN(CERR, "newfactoras called with f= ", f);
-  DEBOUTLN(CERR, "               content(f)= ", content(f));
-  DEBOUTLN(CERR, "                       as= ", as);
-  DEBOUTLN(CERR, "newfactoras: cls(vf)= ", cls(vf));
-  DEBOUTLN(CERR, "newfactoras: cls(as.getLast())= ", cls(as.getLast()));
-  DEBOUTLN(CERR, "newfactoras: degree(f,vf)= ", degree(f,vf));
-
-// F1: [Test trivial cases]
-// 1) first trivial cases:
-  if ( (cls(vf) <= cls(as.getLast())) ||  degree(f,vf)<=1 ){
-// ||( (as.length()==1) && (degree(f,vf)==3) && (degree(as.getFirst()==2)) )
-    DEBDECLEVEL(CERR,"newfactoras");
-    return CFFList(CFFactor(f,1));
-  }
-
-// 2) List of variables:
-// 2a) Setup list of those polys in AS having degree(AS[i], AS[i].mvar()) > 1
-// 2b) Setup variableordering
-  CFList Astar;
-  Variable x;
-  CanonicalForm elem;
-  Varlist ord, uord,oldord;
-  for ( int ii=1; ii< level(vf) ; ii++ ) { uord.append(Variable(ii));  }
-  oldord= uord; oldord.append(vf);
-
-  for ( i=as; i.hasItem(); i++ ){
-    elem= i.getItem();
-    x= elem.mvar();
-    if ( degree(elem,x) > 1){ // otherwise it's not an extension
-      Astar.append(elem);
-      ord.append(x);
-    }
-  }
-  uord= Difference(uord,ord);
-  DEBOUTLN(CERR, "Astar is: ", Astar);
-  DEBOUTLN(CERR, "ord is: ", ord);
-  DEBOUTLN(CERR, "uord is: ", uord);
-
-// 3) second trivial cases: we already prooved irr. of f over no extensions
-  if ( Astar.length() == 0 ){
-    DEBDECLEVEL(CERR,"newfactoras");
-    return CFFList(CFFactor(f,1));
-  }
-
-// 4) Try to obtain a partial factorization using prop2 and prop3
-//    Use with caution! We have to proof these propositions first!
-  // Not yet implemented
-
-// 5) Look if elements in uord actually occure in any of the minimal
-//    polynomials. If no element of uord occures in any of the minimal
-//   polynomials, we don't have transzendentals.
-  Varlist newuord=Var_is_in_AS(uord,Astar);
-  DEBOUTLN(CERR, "newuord is: ", newuord);
-
-  CFFList Factorlist;
-  Varlist gcdord= Union(ord,newuord); gcdord.append(f.mvar());
-  // This is for now. we need alg_sqrfree implemented!
-  CanonicalForm Fgcd;
-          Fgcd= alg_gcd(f,f.deriv(),Astar);
-  if ( Fgcd == 0 ) DEBOUTMSG(CERR, "WARNING: p'th root ?");
-  if (( degree(Fgcd, f.mvar()) > 0) && (!(f.deriv().isZero())) ){
-    DEBOUTLN(CERR, "Nontrivial GCD found of ", f);
-    CanonicalForm Ggcd= divide(f, Fgcd,Astar);
-    DEBOUTLN(CERR, "  split into ", Fgcd);
-    DEBOUTLN(CERR, "         and ", Ggcd);
-    Fgcd= pp(Fgcd); Ggcd= pp(Ggcd);
-    DEBDECLEVEL(CERR,"newfactoras");
-    return myUnion(newfactoras(Fgcd,as,success) , newfactoras(Ggcd,as,success));
-  }
-  if ( getCharacteristic() > 0 ){
-
-    // First look for extension!
-    IntList degreelist;
-    Variable vminpoly;
-    for (i=Astar; i.hasItem(); i++){degreelist.append(degree(i.getItem()));}
-    int extdeg= getextension(degreelist, degree(f));
-    DEBOUTLN(CERR, "Extension needed of degree ", extdeg);
-
-    // Now the real stuff!
-    if ( newuord.length() == 0 ){ // no transzendentals
-      DEBOUTMSG(CERR, "No transzendentals!");
-      if ( extdeg > 1 ){
-        CanonicalForm MIPO= generate_mipo( extdeg, vminpoly);
-        DEBOUTLN(CERR, "Minpoly produced ", MIPO);
-        vminpoly= rootOf(MIPO);
-      }
-      Factorlist= alg_factor(f, Astar, vminpoly, oldord, as);
-      DEBDECLEVEL(CERR,"newfactoras");
-      return Factorlist;
-    }
-    else if ( inseperable(Astar) > 0 ){ // Look if extensions are seperable
-      // a) Use Endler
-      DEBOUTMSG(CERR, "Inseperable extensions! Using Endler!");
-      CFFList templist= endler(f,Astar, newuord);
-      DEBOUTLN(CERR, "Endler gives: ", templist);
-      return templist;
-    }
-    else{ // we are on the save side: Use trager
-      DEBOUTMSG(CERR, "Only seperable extensions!");
-      if (extdeg > 1 ){
-        CanonicalForm MIPO=generate_mipo(extdeg, vminpoly );
-        vminpoly= rootOf(MIPO);
-        DEBOUTLN(CERR, "Minpoly generated: ", MIPO);
-        DEBOUTLN(CERR, "vminpoly= ", vminpoly);
-        DEBOUTLN(CERR, "degree(vminpoly)= ", degree(vminpoly));
-      }
-      Factorlist= alg_factor(f, Astar, vminpoly, oldord, as);
-      DEBDECLEVEL(CERR,"newfactoras");
-      return Factorlist;
-    }
-  }
-  else{ // char=0 apply trager directly
-    DEBOUTMSG(CERR, "Char=0! Apply Trager!");
-    Variable vminpoly;
-    Factorlist= alg_factor(f, Astar, vminpoly, oldord, as);
-      DEBDECLEVEL(CERR,"newfactoras");
-      return Factorlist;
-  }
-
-  DEBDECLEVEL(CERR,"newfactoras");
-  return CFFList(CFFactor(f,1));
-}
-
-CFFList
-newcfactor(const CanonicalForm & f, const CFList & as, int & success ){
-  Off(SW_RATIONAL);
-  CFFList Output, output, Factors=Factorize(f); On(SW_RATIONAL);
-  Factors.removeFirst();
-
-  if ( as.length() == 0 ){ success=1; return Factors;}
-  if ( cls(f) <= cls(as.getLast()) ) { success=1; return Factors;}
-
-  success=1;
-  for ( CFFListIterator i=Factors; i.hasItem(); i++ ){
-    output=newfactoras(i.getItem().factor(),as, success);
-    for ( CFFListIterator j=output; j.hasItem(); j++)
-      Output = myappend(Output,CFFactor(j.getItem().factor(),j.getItem().exp()*i.getItem().exp()));
-  }
-  return Output;
-}
Index: ctory/libfac/charset/alg_factor.h
===================================================================
--- factory/libfac/charset/alg_factor.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,33 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////
-
-#ifndef INCL_NEW_ALGFACTOR_H
-#define INCL_NEW_ALGFACTOR_H
-
-#include <factory.h>
-#include <tmpl_inst.h>  // for typedef's
-
-// missing class: IntGenerator:
-class IntGenerator : public CFGenerator
-{
-private:
-    int current;
-public:
-    IntGenerator() : current(0) {}
-    ~IntGenerator() {}
-    bool hasItems() const;
-    void reset() { current = 0; }
-    CanonicalForm item() const;
-    void next();
-    void operator++ () { next(); }
-    void operator++ ( int ) { next(); }
-};
-
-CFFList newfactoras( const CanonicalForm & f, const CFList & as, int &success);
-/*BEGINPUBLIC*/
-CFFList newcfactor(const CanonicalForm & f, const CFList & as, int & success );
-/*ENDPUBLIC*/
-
-#endif /* INCL_ALGFACTOR_H */
Index: ctory/libfac/charset/algfactor.cc
===================================================================
--- factory/libfac/charset/algfactor.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,182 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////
-// FACTORY - Includes
-#include <factory.h>
-// Factor - Includes
-#include <tmpl_inst.h>
-#include <Factor.h>
-#include <helpstuff.h>
-// Charset - Includes
-#include "csutil.h"
-#include "charset.h"
-#include "reorder.h"
-#include "alg_factor.h"
-// some CC's need this:
-#include "algfactor.h"
-
-#ifdef ALGFACTORDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-
-#include <libfac/factor/debug.h>
-#include "timing.h"
-TIMING_DEFINE_PRINT(newfactoras_time)
-
-int hasVar(const CanonicalForm &f, const Variable &v);
-
-static CFFList
-myminus( const CFFList & Inputlist, const CFFactor & TheFactor){
-  CFFList Outputlist ;
-  CFFactor copy;
-
-  for ( CFFListIterator i=Inputlist ; i.hasItem() ; i++ ){
-    copy = i.getItem();
-    if ( copy.factor() != TheFactor.factor() ){
-      Outputlist.append( copy );
-    }
-  }
-  return Outputlist;
-}
-
-static CFFList
-myDifference(const CFFList & Inputlist1,const CFFList & Inputlist2){
-  CFFList Outputlist=Inputlist1;
-
-  for ( CFFListIterator i=Inputlist2 ; i.hasItem() ; i++ )
-    Outputlist = myminus(Outputlist, i.getItem() );
-
-  return Outputlist;
-}
-
-
-// return 1 if as is quasilinear; 0 if not.
-static int
-isquasilinear( const CFList & as ){
-  if (as.length() <= 1) { return 1; }
-  else {
-    CFList AS=as;
-    AS.removeFirst(); // we are not interested in the first elem
-    for ( CFListIterator i=AS; i.hasItem(); i++)
-      if ( degree(i.getItem()) > 1 ) return 0;
-  }
-return 1;
-}
-
-#ifdef CHARSETNADEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-#include <libfac/factor/debug.h>
-static CFList
-charsetnA(const CFList & AS, const CFList &PS, PremForm & Remembern, const Variable & vf ){
-  CFList QS = PS, RS = PS, Cset;
-  int nas= AS.length() +1;
-
-  DEBOUTLN(CERR, "charsetnA: called with ps= ", PS);
-  while ( ! RS.isEmpty() ) {
-    Cset = BasicSet( QS );
-    DEBOUTLN(CERR, "charsetnA: Cset= ", Cset);
-    Cset=Union(Cset,AS);
-    DEBOUTLN(CERR, "charsetnA: Cset= ", Cset);
-    Remembern.FS1 = Union(Remembern.FS1, initalset1(Cset));
-    DEBOUTLN(CERR, "charsetnA: Remembern.FS1= ", Remembern.FS1);
-    DEBOUTLN(CERR, "charsetnA: Remembern.FS2= ", Remembern.FS2);
-    RS = CFList();
-    if ( Cset.length() == nas && degree(Cset.getLast(),vf) > 0 ) {
-      CFList D = Difference( QS, Cset );
-      DEBOUT(CERR, "charsetnA: Difference( ", QS);
-      DEBOUT(CERR, " , ", Cset);
-      DEBOUTLN(CERR, " ) = ", D);
-      for ( CFListIterator i = D; i.hasItem(); ++i ) {
-        CanonicalForm r = Prem( i.getItem(), Cset );
-        DEBOUT(CERR,"charsetnA: Prem(", i.getItem()  );
-        DEBOUT(CERR, ",", Cset);
-        DEBOUTLN(CERR,") = ", r);
-        if ( r != 0 ){
-          //removefactor( r, Remembern );
-            RS=Union(RS,CFList(r));
-        }
-      }
-      if ( ! checkok(RS,Remembern.FS2)) return CFList(CanonicalForm(1));
-      DEBOUTLN(CERR, "charsetnA: RS= ", RS);
-      //QS = Union( QS, RS );
-      QS=Union(AS,RS); QS.append(Cset.getLast());
-      DEBOUTLN(CERR, "charsetnA: QS= Union(QS,RS)= ", QS);
-    }
-    else{ return CFList(CanonicalForm(1)); }
-  }
-  DEBOUTLN(CERR, "charsetnA: Removed factors: ", Remembern.FS2);
-  DEBOUTLN(CERR, "charsetnA: Remembern.FS1: ", Remembern.FS1);
-
-  return Cset;
-}
-
-#ifdef ALGFACTORDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-#include <libfac/factor/debug.h>
-// compute the GCD of f and g over the algebraic field having
-// adjoing ascending set as
-CanonicalForm
-algcd(const CanonicalForm & F, const CanonicalForm & g, const CFList & as, const Varlist & order){
-  CanonicalForm f=F;
-  int nas= as.length()+1; // the length the new char. set should have!
-  Variable vf=f.mvar();
-
-//   for ( VarlistIterator i=order; i.hasItem() ; i++ ){
-//     vf= i.getItem();
-//     nas--;
-//     if ( nas==0 ) break;
-//   }
-//   nas= as.length()+1;
-
-  DEBOUTLN(CERR, "algcd called with f= ", f);
-  DEBOUTLN(CERR, "                  g= ", g);
-  DEBOUTLN(CERR, "                 as= ", as);
-  DEBOUTLN(CERR, "              order= ", order);
-  DEBOUTLN(CERR, "         choosen vf= ", vf);
-
-  // check trivial case:
-  if ( degree(f, order.getLast())==0 || degree(g, order.getLast())==0)
-  {
-    DEBOUTLN(CERR, "algcd Result= ", 1);
-    return CanonicalForm(1);
-  }
-
-  CFList bs; bs.append(f); bs.append(g);
-  PremForm Remembern;
-  CFList cs=charsetnA(as,bs,Remembern,vf);
-  DEBOUTLN(CERR, "CharSetA((as,bs))= ", cs);
-
-//    for ( VarlistIterator i=order; i.hasItem() ; i++ ){
-//      DEBOUTLN(CERR, "vf= ", i.getItem());
-//      DEBOUTLN(CERR, "CharSetA((as,bs))= " , charsetnA(as,bs,Remembern,i.getItem()));
-//    }
-
-  CanonicalForm result;
-  if (cs.length()==nas)
-  {
-    result= cs.getLast();
-    CanonicalForm c=vcontent(result,Variable(1));
-    //CanonicalForm c=result.Lc();
-    result/=c;
-    for(CFListIterator i=as;i.hasItem(); i++ )
-    {
-      if(hasVar(result,i.getItem().mvar()))
-      {
-        c=vcontent(result,Variable(i.getItem().level()+1));
-        result/=c;
-      }
-    }
-  }
-  else result= CanonicalForm(1);
-  DEBOUTLN(CERR, "algcd Result= ", result);
-  return result;
-}
Index: ctory/libfac/charset/algfactor.h
===================================================================
--- factory/libfac/charset/algfactor.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,17 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////
-
-#ifndef INCL_ALGFACTOR_H
-#define INCL_ALGFACTOR_H
-
-#include <factory.h>
-#include <tmpl_inst.h>  // for typedef's
-
-CanonicalForm algcd(const CanonicalForm & f, const CanonicalForm & g, const CFList & as, const Varlist & order);
-/*BEGINPUBLIC*/
-int hasVar(const CanonicalForm &f, const Variable &v);
-/*ENDPUBLIC*/
-
-#endif /* INCL_ALGFACTOR_H */
Index: ctory/libfac/charset/charset.cc
===================================================================
--- factory/libfac/charset/charset.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,553 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-/////////////////////////////////////////////////////////////
-// FACTORY - Includes
-#include <factory.h>
-#ifdef HAVE_IOSTREAM
-#define CIN std::cin
-#else
-#define CIN cin
-#endif
-// Factor - Includes
-#include <SqrFree.h>
-#include <Factor.h>
-#include <interrupt.h>
-// Charset - Includes
-#include "csutil.h"
-#include "algfactor.h"
-#include "alg_factor.h"
-// Some CC's need this:
-#include "charset.h"
-
-#ifdef BASICSETDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-
-#include <libfac/factor/debug.h>
-#include "timing.h"
-TIMING_DEFINE_PRINT(subfactorize_time)
-
-
-// forward declarations:
-static CFList     irras(CFList & AS, int &ja, CanonicalForm & reducible);
-
-#ifdef BASICSETDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-#include <libfac/factor/debug.h>
-
-// the next computes a characteristic set (a basic set in Wang's sense)
-CFList
-BasicSet( const CFList &PS )
-{
-    CFList QS = PS, BS, RS;
-    CanonicalForm b;
-    int cb;
-
-    DEBOUTLN(CERR, "BasicSet: called with ps= ", PS);
-    if ( PS.length() < 2 ) return PS;
-    while ( ! QS.isEmpty() ) {
-        b = lowestRank( QS );
-        cb = rank( b );
-        DEBOUTLN(CERR, "BasicSet: choose b  = ", b);
-        DEBOUTLN(CERR, "BasicSet: it's rank = ", cb);
-        BS=Union(CFList(b),BS);//BS.append( b );
-        if ( rank( b ) == 0 )
-            return Union(PS, CFList(b)) ; // b should be the first elem!
-        else {
-            RS = CFList();
-            // QS:= {q \in QS -{B} | q is reduced wrt b}
-            // We can process whole QS, because b is not reduced wrt. b
-            for ( CFListIterator i = QS; i.hasItem(); ++i )
-                if ( degree( i.getItem(), cb ) < degree( b ) )
-                    //RS.append( i.getItem() );
-                    RS = Union(CFList(i.getItem()),RS);
-            QS = RS;
-        }
-    }
-    DEBOUTLN(CERR, "BasicSet: returning bs= ", BS);
-    return BS;
-}
-
-int
-checkok( const CFList & PS, CFList & FS2){
-  CanonicalForm elem;
-
-  for ( CFListIterator i=PS; i.hasItem(); i++){
-    elem= i.getItem();
-    for (CFListIterator j=FS2; j.hasItem(); j++){
-      if (elem == j.getItem()){
-         //        FS2= Difference(FS2,CFList(elem));
-         return 0;
-      }
-    }
-  }
-  return 1;
-}
-
-#ifdef MCHARSETNDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-#include <libfac/factor/debug.h>
-
-// The modified CharSet (an extended characteristic set with certain factors
-// canceled; this is a characteristic set in Wang's sense)
-CFList
-MCharSetN( const CFList &PS, PremForm & Remembern ){
-  CFList QS = PS, RS = PS, CSet, OLDCS;
-
-  DEBOUTLN(CERR, "MCharSetN: called with ps= ", PS);
-  while ( ! RS.isEmpty() ) {
-    CSet = BasicSet( QS );
-    OLDCS=CSet;
-    DEBOUTLN(CERR, "MCharSetN: CS= ", CSet);
-//     if ( getNumVars(CSet.getFirst()) > 1 ){
-//       //CSet = removecontent(CSet, Remembern);
-// #ifdef MCHARSETNDEBUG
-//       CERR << "MCharSetN: CSet= " << CSet << "\n";
-// #endif
-//     }
-    Remembern.FS1 = Union(Remembern.FS1, initalset1(CSet));
-    DEBOUTLN(CERR, "MCharSetN: Remembern.FS1= ", Remembern.FS1);
-    DEBOUTLN(CERR, "MCharSetN: Remembern.FS2= ", Remembern.FS2);
-    RS = CFList();
-    if ( rank( CSet.getFirst() ) != 0 ) {
-      CFList D = Difference( QS, CSet );
-      DEBOUT(CERR, "MCharSetN: Difference( ", QS);
-      DEBOUT(CERR, " , ", CSet);
-      DEBOUTLN(CERR, " ) = ", D);
-//CERR << "MCharSetN: Difference( " << QS << " , " << CSet << " ) = " << D << "\n";
-      //PremForm Oldremember=Remembern;
-      //PremForm Newremember=Remembern;
-      for ( CFListIterator i = D; i.hasItem(); ++i ) {
-        CanonicalForm r = Prem( i.getItem(), CSet );
-        DEBOUT(CERR,"MCharSetN: Prem(", i.getItem()  );
-        DEBOUT(CERR, ",", CSet);
-        DEBOUTLN(CERR,") = ", r);
-//CERR << "MCharSetN: Prem("<< i.getItem() << "," << CSet << ") = " << r << "\n";
-        if ( r != 0 ){
-          //removefactor( r, Newremember );
-          removefactor( r, Remembern );
-          //Remembern.FS2 = Union(Remembern.FS2, Newremember.FS2);
-          //Newremember = Oldremember;
-          //if ( cls(r) > 0 )
-            //RS=Union(CFList(r),RS);//RS.append( r );
-            RS=Union(RS,CFList(r));
-        }
-      }
-      if ( ! checkok(RS,Remembern.FS2)) return CFList(CanonicalForm(1));
-      DEBOUTLN(CERR, "MCharSetN: RS= ", RS);
-      //QS = Union( QS, RS );
-      QS = Union(OLDCS,RS);
-      DEBOUTLN(CERR, "MCharSetN: QS= Union(QS,RS)= ", QS);
-    }
-    else{ return CFList(CanonicalForm(1)); }
-  }
-  DEBOUTLN(CERR, "MCharSetN: Removed factors: ", Remembern.FS2);
-  DEBOUTLN(CERR, "MCharSetN: Remembern.FS1: ", Remembern.FS1);
-
-  return CSet;
-}
-
-
-CFList
-mcharset( const CFList &PS, PremForm & Remembern ){
-  CFList cs= MCharSetN(PS, Remembern );
-  CFList rs= remsetb(Difference(PS,cs),cs);
-
-  DEBOUTLN(CERR, "mcharset: cs= ", cs);
-  DEBOUTLN(CERR, "mcharset: rs= ", rs);
-  if ( rs.length() > 0 )
-    cs= mcharset(Union(PS,Union(cs,rs)), Remembern);
-  return cs;
-}
-
-// the "original" extended characteristic set
-CFList
-CharSet( const CFList &PS ){
-  CFList QS = PS, RS = PS, CSet;
-
-  while ( ! RS.isEmpty() ) {
-    CSet = BasicSet( QS );
-    DEBOUTLN(CERR, "CharSet: CSet= ", CSet);
-    RS = CFList();
-    if ( rank( CSet.getFirst() ) != 0 ) {
-      CFList D = Difference( QS, CSet );
-      for ( CFListIterator i = D; i.hasItem(); ++i ) {
-        CanonicalForm r = Prem( i.getItem(), CSet );
-        if ( r != 0 )  RS=Union(CFList(r),RS);//RS.append( r );
-      }
-      QS = Union( QS, RS );
-    }
-  }
-  return CSet;
-}
-
-static CFList
-charseta( const CFList & PS ){
-  CFList QS = PS, RS = PS, CSet;
-
-  while ( ! RS.isEmpty() ) {
-    CSet = CharSet( QS );
-    RS = CFList();
-    if ( rank( CSet.getFirst() ) != 0 ) {
-      CFList D = Difference( QS, CSet );
-      for ( CFListIterator i = D; i.hasItem(); ++i ) {
-        CanonicalForm r = Prem( i.getItem(), CSet );
-        if ( r != 0 )  RS=Union(CFList(r),RS);//RS.append( r );
-      }
-      QS = Union(CSet,Union( QS, RS ));
-    }
-    else return CFList(CanonicalForm(1));
-  }
-  return CSet;
-}
-
-static bool
-contractsub( const CFList & cs1, const CFList & cs2 ){
-  CFListIterator i;
-
-  for ( i=cs1; i.hasItem(); i++ )
-    if ( Prem(i.getItem(),cs2 ) != 0 ) return false;
-  CFList is=initalset1(cs1);
-  for ( i=is; i.hasItem(); i++ )
-    if ( Prem(i.getItem(),cs2 ) == 0 ) return false;
-  return true;
-}
-
-static ListCFList
-contract( const ListCFList & cs){
-  ListCFList mem,ts;
-  CFList iitem,jitem;
-
-  if ( cs.length() < 2 ) return cs;
-
-  for ( ListCFListIterator i=cs; i.hasItem(); i++ ){
-    iitem=i.getItem();
-    if ( ! member(iitem, mem))
-      for ( ListCFListIterator j=i; j.hasItem(); j++){
-        jitem=j.getItem();
-        if ( ! same( iitem, jitem ) )
-          if ( ! member(jitem, mem))
-            if ( contractsub(iitem, jitem) ){
-              ts.append(jitem); mem.append(jitem);
-            }
-            else
-              if ( contractsub(jitem, iitem) ){
-                ts.append(iitem);
-              }
-      }
-  }
-  return Minus(cs,ts);
-}
-
-static ListCFList
-adjoin(const CFList & is, const CFList & qs, const ListCFList & qh ){
-  ListCFList iss,qhi;
-  ListCFListIterator j;
-  CFList iscopy,itt;
-  CFListIterator i;
-  CanonicalForm elem;
-  int ind, length;
-
-  for ( i=is ; i.hasItem(); i++ ){
-    elem=i.getItem();
-    if ( cls(elem) > 0 ) iscopy=Union(CFList(elem),iscopy);
-  }
-  if ( iscopy.isEmpty() ) return iss;
-  qhi = MyDifference(qh,qs);
-  length = qhi.length();
-  for ( i =iscopy; i.hasItem(); i++){
-    itt = Union(qs,CFList(i.getItem()));
-    ind = 0;
-    if ( length > 0 )
-      for ( j=qhi; j.hasItem(); j++ )
-        if ( subset(j.getItem(),itt )) ind=1;
-    if ( ind == 0 ) iss.append(itt);
-  }
-  return iss;
-}
-
-static ListCFList
-adjoinb(const CFList & is, const CFList & qs, const ListCFList & qh ,const CFList & cs){
-  ListCFList iss,qhi;
-  ListCFListIterator j;
-  CFList iscopy,itt;
-  CFListIterator i;
-  CanonicalForm elem;
-  int ind, length;
-
-  for ( i=is ; i.hasItem(); i++ ){
-    elem=i.getItem();
-    if ( cls(elem) > 0 ) iscopy=Union(CFList(elem),iscopy);
-  }
-  if ( iscopy.isEmpty() ) return iss;
-  qhi = MyDifference(qh,qs);
-  length = qhi.length();
-  for ( i =iscopy; i.hasItem(); i++){
-    itt = Union(Union(qs,CFList(i.getItem())),cs);
-    ind = 0;
-    if ( length > 0 )
-      for ( j=qhi; j.hasItem(); j++ )
-        if ( subset(j.getItem(),itt )) ind=1;
-    if ( ind == 0 ) {iss.append(itt);}
-  }
-  return iss;
-}
-
-static ListCFList
-sort( const ListCFList & list_to_sort ){
-  ListCFList output,copy=list_to_sort;
-  CFList l,qs1,elem;
-
-  l = copy.getLast(); copy.removeLast();
-  if ( copy.length() == 0 ){ return ListCFList(l); }
-  for ( ListCFListIterator i=copy ; i.hasItem(); i++ ){
-    elem = i.getItem();
-    if ( elem.length() > l.length() ) {
-      output = MyUnion( ListCFList(l), output);
-      l= elem;
-    }
-    else{ output = MyUnion(output, ListCFList(elem) ); }
-  }
-  //output = MyUnion(ListCFList(l),sort(output));
-  output = MyUnion(ListCFList(l),output);
-  return output;
-}
-
-#ifdef IRRCHARSERIESDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-#include <libfac/factor/debug.h>
-
-ListCFList
-IrrCharSeries( const CFList &PS, int opt ){
-  CanonicalForm reducible,reducible2;
-  CFList qs,cs,factorset,is,ts;
-  ListCFList pi,ppi,qqi,qsi,iss,qhi= ListCFList(PS);
-  int nr_of_iteration=0,ts2,highestlevel=0;
-
-//  CERR << getCharacteristic() << "\n";
-  for ( CFListIterator Ps=PS; Ps.hasItem(); Ps++ )
-    if ( level(Ps.getItem() ) > highestlevel ) highestlevel = level(Ps.getItem()) ;
-//  for ( int xx=1; xx <= highestlevel; xx++)
-//   CERR << Variable(xx) ;
-//  CERR << "\n";
-//  for ( CFListIterator Ps=PS; Ps.hasItem(); Ps++ )
-//    CERR << Ps.getItem() << ", " ;//<< "\n";
-//  CERR <<  "\n";
-  while ( ! qhi.isEmpty() ) {
-    qhi=sort(qhi);
-    DEBOUTLN(CERR, "qhi is: ", qhi);
-    qs=qhi.getFirst();
-    DEBOUTLN(CERR, "qs  is: ", qs);
-    DEBOUTLN(CERR, "ppi is: ", ppi);
-    ListCFList ppi1,ppi2;
-    select(ppi,qs.length(),ppi1,ppi2);
-    DEBOUTLN(CERR, "ppi1 is: ", ppi1);
-    DEBOUTLN(CERR, "ppi2 is: ", ppi2);
-    qqi = MyUnion(ppi2,qqi);
-    DEBOUTLN(CERR, "qqi is: ", qqi);
-    if ( nr_of_iteration == 0 ){ nr_of_iteration += 1; ppi = ListCFList(); }
-    else{ nr_of_iteration += 1; ppi = MyUnion(ListCFList(qs),ppi1); }
-    DEBOUTLN(CERR,"ppi is: ", ppi);
-    PremForm Remembern;
-    cs = MCharSetN(qs,Remembern);
-    DEBOUTLN(CERR, "cs is: ", cs);
-    DEBOUTLN(CERR, "factorset is: ", Remembern.FS2);
-    cs = removecontent(cs,Remembern);
-    factorset=Remembern.FS2;
-    DEBOUTLN(CERR, "cs (after removecontent) is: ", cs);
-    DEBOUTLN(CERR, "factorset is: ", factorset);
-    // Hier: removecontent einfuegen!!!!
-    if ( cls(cs.getFirst()) > 0 ){
-      ts = irras(cs,ts2, reducible);
-
-      // INTERRUPTHANDLER
-      if ( interrupt_handle() ) return ListCFList() ;
-      // INTERRUPTHANDLER
-
-      DEBOUTLN(CERR, "ts is: ", ts);
-      DEBOUTLN(CERR, "ts2 is: ", ts2);
-      // next is preliminary: should be ==0
-      if ( ts2 <= 0 ){ //irreducible
-        if ( ! subset(cs,qs) ){
-          DEBOUTMSG(CERR, "cs is not a subset of qs");
-          cs = charseta(Union(qs,cs));
-          DEBOUTLN(CERR, "new cs is: ", cs);
-        }
-        if ( ! member(cs,pi) ){
-          pi = MyUnion(pi, ListCFList(cs));
-          DEBOUTMSG(CERR, "cs is not a member of pi");
-          DEBOUTLN(CERR, "pi is: ", pi);
-          if ( cls(cs.getFirst()) > 0 ){
-            ts = irras(cs,ts2,reducible);
-
-            // INTERRUPTHANDLER
-            if ( interrupt_handle() ) return ListCFList() ;
-            // INTERRUPTHANDLER
-
-            DEBOUTLN(CERR, "ts is: ", ts);
-            DEBOUTLN(CERR, "ts2 is: ", ts2);
-            // next is preliminary: should be ==0
-            if ( ts2 <= 0 ){ //irreducible
-              qsi = MyUnion(qsi,ListCFList(cs));
-              DEBOUTLN(CERR, "qsi is: ", qsi);
-              if ( cs.length() == highestlevel ){
-                DEBOUTLN(CERR, "cs.length() == nops(ord) :", cs.length());
-                is = factorps(factorset);
-              }
-              else{
-                DEBOUT(CERR,"cs.length() != nops(ord) :", cs.length());
-                DEBOUTLN(CERR, "  nops(ord)= ", highestlevel);
-                is = Union(initalset1(cs),factorps(factorset));
-              }
-              DEBOUTLN(CERR, "is is: ", is);
-              iss = adjoin(is,qs,qqi);
-              DEBOUTLN(CERR, "iss is: ", iss);
-            }
-          }
-          else{ iss = adjoin(factorps(factorset),qs,qqi); }
-        }
-        else{
-          DEBOUTMSG(CERR, "cs is a member of pi");
-          iss = adjoin(factorps(factorset),qs,qqi); }
-        DEBOUTLN(CERR, "iss is: ", iss);
-        DEBOUTLN(CERR, "   factorps(factorset)= ", factorps(factorset));
-        DEBOUTLN(CERR, "   qs= ", qs);
-        DEBOUTLN(CERR, "   qqi= ", qqi);
-      }
-      // next is preliminary: should be !=0
-      if ( ts2 > 0 ){
-        is = factorps(factorset);
-        DEBOUTLN(CERR, "is is: ", is);
-        if ( ts2 > 1 ){
-          // setup cst: need it later for adjoinb
-          CFList cst;
-          for ( CFListIterator i=cs ; i.hasItem(); i++){
-            if ( i.getItem() == reducible ) { break; }
-            else { cst.append(i.getItem()); }
-          }
-          is = Union(initalset1(cst), is);
-          iss = MyUnion(adjoin(is,qs,qqi), adjoinb(ts,qs,qqi,cst));
-        }
-        else{ iss = adjoin(Union(is,ts),qs,qqi); }
-        DEBOUTLN(CERR, "iss is: ", iss);
-      }
-    }
-    else{
-      iss = adjoin(factorps(factorset),qs,qqi);
-      DEBOUTMSG(CERR, "case: cs is a constant.");
-      DEBOUTLN(CERR, "  qs = ", qs);
-      DEBOUTLN(CERR, "  qqi = ", qqi);
-      DEBOUTLN(CERR, "  iss = adjoin(factorps(factorset),qs,qqi) = ",iss);
-    }
-    if ( qhi.length() > 1 ){ qhi.removeFirst(); qhi = MyUnion(qhi,iss); }
-    else{ qhi = iss; }
-    DEBOUTLN(CERR, "iss is: ", iss);
-  }
-  if ( ! qsi.isEmpty() ){
-    DEBOUTLN(CERR, "qsi before contract= ", qsi);
-    if ( opt == 0 ){
-       return contract( qsi );
-    }
-    else { return qsi; }
-  }
-  else{ return ListCFList() ; }
-}
-
-// tests for characteristic sets
-//////////////////////////////////
-#ifdef IRRASDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-
-#include <libfac/factor/debug.h>
-
-static CFList
-irras( CFList & AS, int & ja, CanonicalForm & reducible)
-{
-  CFFList qs;
-  CFList ts,as;
-  CanonicalForm elem;
-  int ind=1,nr=0, success=-1;
-  CFListIterator i;
-
-  ja = 0;
-  DEBOUTLN(CERR, "irras: called with: AS= ", AS);
-  for ( i=AS; i.hasItem(); i++ )
-  {
-    elem = i.getItem();
-    nr += 1;
-    DEBOUT(CERR, "irras: factoring: ", elem);
-    if ( degree(elem) > 1 ) // linear poly's are irreduzible
-    {
-      qs = Factorize(elem);
-      // remove a constant
-      if (qs.getFirst().factor().degree()==0) qs.removeFirst();
-    }
-    else
-    {
-      qs=(CFFactor(elem,1));
-    }
-    DEBOUTLN(CERR, "  = ", qs);
-    // INTERRUPTHANDLER
-    if ( interrupt_handle() ) return CFList() ;
-    // INTERRUPTHANDLER
-
-    if ( (qs.length() >= 2 ) || (qs.getFirst().exp() > 1))
-    {
-      DEBOUTLN(CERR, "irras: Setting ind=0, ja= ", nr);
-      ja=nr; ind=0; reducible= elem;
-      break;
-    }
-    //    else{ as.append(elem) ; }
-  }
-  //  CERR << "ind= " << ind << "\n";
-  if ( (ind == 1) ) //&& ( as.length() > 1) )
-  {
-    if ( irreducible(AS) )
-    { // as quasilinear? => irreducible!
-      ja = 0;
-      DEBOUTLN(CERR, "as is irreducible. as= ", AS);
-    }
-    else
-    {
-      i=AS;
-      for ( nr=1; nr< AS.length(); nr++)
-      {
-        as.append(i.getItem());
-        i++;
-        if ( degree(i.getItem()) > 1 )
-        {  // search for a non linear elem
-          elem=i.getItem();
-          //if (as.length()==1)
-          //  qs = Factorize2(elem,as.getFirst());
-          //else
-            qs= newfactoras(elem,as,success);
-          if ( qs.length() > 1 || qs.getFirst().exp() > 1 )
-          { //found elem is reducible
-            reducible=elem;
-            ja=nr+1;
-            break;
-          }
-        }
-      }
-    }
-  }
-  for ( CFFListIterator k=qs; k.hasItem();k++)
-    ts.append(k.getItem().factor());
-  return ts;
-}
-
-///////////////////////////////////////////////////////////////////////////////
Index: ctory/libfac/charset/charset.h
===================================================================
--- factory/libfac/charset/charset.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,20 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-
-#ifndef INCL_CHARSET_H
-#define INCL_CHARSET_H
-
-#include <factory.h>
-#include <tmpl_inst.h>  // for typedef's
-
-CFList     BasicSet( const CFList &PS );
-CFList     CharSet( const CFList &PS );
-CFList     mcharset( const CFList &PS, PremForm & Remembern );
-int        checkok( const CFList & PS, CFList & FS2);
-/*BEGINPUBLIC*/
-CFList     MCharSetN( const CFList &PS, PremForm & Remembern );
-ListCFList IrrCharSeries( const CFList &PS, int opt=0 );
-/*ENDPUBLIC*/
-
-#endif /* INCL_CHARSET_H */
Index: ctory/libfac/charset/csutil.cc
===================================================================
--- factory/libfac/charset/csutil.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,983 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-/////////////////////////////////////////////////////////////
-// FACTORY - Includes
-#include <factory.h>
-// Factor - Includes
-#include <tmpl_inst.h>
-#include <Factor.h>
-#include <SqrFree.h>
-#include <helpstuff.h>
-#include <homogfactor.h>
-// Charset - Includes
-#include "csutil.h"
-extern void out_cf(char *s1,const CanonicalForm &f,char *s2);
-extern CanonicalForm alg_lc(const CanonicalForm &f);
-extern int hasAlgVar(const CanonicalForm &f);
-
-static bool
-lowerRank ( const CanonicalForm & f, const CanonicalForm & g, int & ind )
-{
-  int df, dg;
-  Variable vf = f.mvar(), vg = g.mvar();
-
-  if ( f.inCoeffDomain() )
-  {
-    if ( g.inCoeffDomain() ) ind= 1;
-    return true;//( vg > vf );
-  }
-  else if ( g.inCoeffDomain() ) return false;
-  else if ( vf < vg ) return true;
-  else if ( vf == vg )
-  {
-    df = degree( f ); dg = degree( g );
-    if ( df < dg ) return true;
-    else if ( df == dg ) return lowerRank( LC( f ), LC( g ) , ind);
-    else return false;
-  }
-  return false;
-}
-
-CanonicalForm
-lowestRank( const CFList & F )
-{
-  CFListIterator i = F;
-  CanonicalForm f;
-  int ind=0;
-  if ( ! i.hasItem() )        return f;
-  f = i.getItem(); ++i;
-  while ( i.hasItem() )
-  {
-    //CERR << "comparing " << f << "  and " << i.getItem()
-    // << " == " << lowerRank( i.getItem(), f, ind ) << "\n";
-    if ( lowerRank( i.getItem(), f, ind ) )
-    {
-      if ( ind )
-      {
-        CFList Itemlist= get_Terms(i.getItem());
-        CFList Flist= get_Terms(f);
-
-        // Have to further compare number of terms!
-        //CERR << "compare terms! f= " << Flist.length() << "  item= "
-        //     << Itemlist.length() <<"\n";
-        if ( Itemlist.length() < Flist.length()) f = i.getItem();
-        ind=0;
-      }
-      else
-      {
-        f = i.getItem();
-      }
-    }
-    ++i;
-  }
-  return f;
-}
-
-// old version
-// CanonicalForm
-// prem ( const CanonicalForm &f, const CanonicalForm &g )
-// {
-//   CanonicalForm ff, gg, cg;
-//   int df, dg;
-//   bool reord;
-//   Variable vf, vg, v;
-//
-//   if ( (vf = f.mvar()) < (vg = g.mvar()) ) return f;
-//   else {
-//     if ( vf == vg ) {
-//       ff = f; gg = g;
-//       reord = false;
-//       v = vg;
-//     }
-//     else {
-//       v = Variable(level(f.mvar()) + 1);
-//       ff = swapvar(f,vg,v);
-//       gg = swapvar(g,vg,v);
-//       reord=true;
-//     }
-//     cg = ini( gg, v );
-//     dg = degree( gg, v );
-//     while ( ( df = degree( ff, v ) ) >= dg )
-//       ff = cg * ff - power( v, df-dg ) * gg * LC( ff, v );
-//     if ( reord ) {
-//       return swapvar( ff, vg, v );
-//     }
-//     else
-//       return ff;
-//   }
-// }
-
-CanonicalForm
-Prem ( const CanonicalForm &f, const CanonicalForm &g )
-{
-  CanonicalForm ff, gg, l, test, lu, lv, t, retvalue;
-  int df, dg;
-  bool reord;
-  Variable vf, vg, v;
-
-  if ( (vf = f.mvar()) < (vg = g.mvar()) ) return f;
-  else
-  {
-    if ( vf == vg )
-    {
-      ff = f; gg = g;
-      reord = false;
-      v = vg;
-    }
-    else
-    {
-      v = Variable(level(f.mvar()) + 1);
-      ff = swapvar(f,vg,v);
-      gg = swapvar(g,vg,v);
-      reord=true;
-    }
-    dg = degree( gg, v );
-    df = degree( ff, v );
-    if (dg <= df) {l=LC(gg); gg = gg -LC(gg)*power(v,dg);}
-    else { l = 1; }
-    while ( ( dg <= df  ) && ( !ff.isZero()) )
-    {
-      // CERR << "Start gcd..." << "\n";
-      test = gcd(l,LC(ff));
-      //CERR << "gcd(" << l << "," << LC(ff) << ")= " << test << "\n";
-      lu = l/test; lv = LC(ff)/test;
-      t = power(v,df-dg) * gg * lv;
-      if ( df == 0 ){ ff = ff.genZero(); }
-      else { ff = ff - LC(ff)*power(v,df); }
-      ff = lu*ff - t;
-      df = degree( ff, v );
-    }
-    if ( reord )
-    {
-      retvalue= swapvar( ff, vg, v );
-    }
-    else
-    {
-      retvalue= ff;
-    }
-    return retvalue;
-  }
-}
-
-static CanonicalForm
-Sprem ( const CanonicalForm &f, const CanonicalForm &g, CanonicalForm & m, CanonicalForm & q )
-{
-  CanonicalForm ff, gg, l, test, retvalue;
-  int df, dg,n;
-  bool reord;
-  Variable vf, vg, v;
-
-  if ( (vf = f.mvar()) < (vg = g.mvar()) )
-  {
-    m=CanonicalForm(0); q=CanonicalForm(0);
-    return f;
-  }
-  else
-  {
-    if ( vf == vg )
-    {
-      ff = f; gg = g;
-      reord = false;
-      v = vg; // == x
-    }
-    else
-    {
-      v = Variable(level(f.mvar()) + 1);
-      ff = swapvar(f,vg,v); // == r
-      gg = swapvar(g,vg,v); // == v
-      reord=true;
-    }
-    dg = degree( gg, v ); // == dv
-    df = degree( ff, v ); // == dr
-    if (dg <= df) {l=LC(gg); gg = gg -LC(gg)*power(v,dg);}
-    else { l = 1; }
-    n= 0;
-    while ( ( dg <= df  ) && ( !ff.isZero()) )
-    {
-      test= power(v,df-dg) * gg * LC(ff);
-      if ( df == 0 ){ff= ff.genZero();}
-      else {ff= ff - LC(ff)*power(v,df);}
-      ff = l*ff-test;
-      df= degree(ff,v);
-      n++;
-    }
-    if ( reord )
-    {
-      retvalue= swapvar( ff, vg, v );
-    }
-    else
-    {
-      retvalue= ff;
-    }
-    m= power(l,n);
-    if ( fdivides(g,m*f-retvalue) )
-      q= (m*f-retvalue)/g;
-    else
-      q= CanonicalForm(0);
-    return retvalue;
-  }
-}
-
-CanonicalForm
-divide( const CanonicalForm & ff, const CanonicalForm & f, const CFList & as)
-{
-  CanonicalForm r,m,q;
-
-  //out_cf("divide f=",ff,"\n");
-  //out_cf("divide g=",f,"\n");
-  if (f.inCoeffDomain())
-  {
-    bool b=!isOn(SW_RATIONAL);
-    On(SW_RATIONAL);
-    q=ff/f;
-    if (b) Off(SW_RATIONAL);
-  }
-  else
-    r= Sprem(ff,f,m,q); //result in q, ignore r,m
-  //CERR << "r= " << r << "  , m= " << m << "  , q= " << q << "\n";
-  r= Prem(q,as);
-  //CERR << "r= " << r << "\n";
-  //out_cf(" ->",r,"\n");
-  return r;
-}
-
-// This function allows as to be empty; in that case, it is equivalent
-// to the previous version (treating no variables as algebraic).
-static CanonicalForm
-myfitting( const CanonicalForm &f, const CFList &as )
-{
- CanonicalForm rem=f;
-
- if ( !(rem.isZero()) )
- {
-   if ( getCharacteristic() > 0 )
-     return num((rem/lc(rem)));
-   else
-   {
-     On(SW_RATIONAL);
-     CanonicalForm temp= mapinto(rem);
-//      CERR << "temp= " << temp << "\n";
-//      CERR << "lc(temp)= " << lc(temp) << "\n";
-//      CERR << "temp/lc(temp)= " << temp/lc(temp) << "\n";
-//      CERR << "num(rem/lc(rem))= " << num(rem/lc(rem)) << "\n";
-
-     // If as is of length 1, and its polynomial is level 1, then
-     // we treat the first variable as algebraic and invert the leading
-     // coefficient where this variable is part of the coefficient domain.
-
-     if (as.length() == 1 && level(as.getFirst()) == 1)
-     {
-       CanonicalForm lcoeff = temp;
-       while (level(lcoeff) > 1)
-       {
-         lcoeff = LC(lcoeff);
-       }
-       // out_cf("myfitting: lcoeff = ", lcoeff, "\n");
-
-       CanonicalForm p = as.getFirst();
-       // out_cf("myfitting: p = ", p, "\n");
-
-       CanonicalForm unused, inverse;
-
-       extgcd(lcoeff, p, inverse, unused);
-       // out_cf("myfitting: inverse = ", inverse, "\n");
-
-       // This may leave temp with non-integral coefficients,
-       // which will be cleaned up below.
-       temp = temp * inverse;
-       // out_cf("myfitting: temp = ", temp, "\n");
-     }
-
-     temp= bCommonDen(temp/lc(temp))*(temp/lc(temp));
-     Off(SW_RATIONAL);
-     rem= mapinto(temp);
-     return rem;
-   }
- }
- else
-   return rem;
-}
-
-CanonicalForm
-Prem( const CanonicalForm &f, const CFList &L )
-{
-  CanonicalForm rem = f;
-  CFListIterator i = L;
-  for ( i.lastItem(); i.hasItem(); i-- )
-  {
-    //CERR << "   PREM: Prem(" << rem << "," ;
-    rem = Prem( rem, i.getItem() );
-    //CERR << "   PREM: Prem(" << rem << "," << i.getItem() << ")  = " << rem << "\n";
-  }
-  return myfitting(rem, CFList());
-}
-
-CanonicalForm
-Prem( const CanonicalForm &f, const CFList &L, const CFList &as )
-{
-  CanonicalForm rem = f;
-  CFListIterator i = L;
-  for ( i.lastItem(); i.hasItem(); i-- )
-  {
-    //CERR << "   PREM: Prem(" << rem << "," ;
-    rem = Prem( rem, i.getItem() );
-    //CERR << "   PREM: Prem(" << rem << "," << i.getItem() << ")  = " << rem << "\n";
-  }
-  return myfitting(rem, as);
-}
-
-CFList
-Prem( const CFList &AS, const CFList &L )
-{
-  CFList Output;
-
-  for ( CFListIterator i=AS; i.hasItem(); i++ )
-    Output = Union(CFList(Prem(i.getItem(),L)), Output);
-
-  return Output;
-}
-
-static CanonicalForm
-premasb( const CanonicalForm & f, const CFList & as)
-{
-  CanonicalForm remd=f;
-  CFList AS=as;
-
-  if ( as.length() > 1 )
-  {
-    AS.removeFirst(); // get rid of first elem
-    CanonicalForm elem;
-    while ( ! AS.isEmpty() )
-    { // thats true for at least the first iteration
-      elem= AS.getLast();
-      remd= Prem(remd,elem);
-      AS.removeLast();
-    }
-  }
-  CanonicalForm a,b;
-  if ( mydivremt(remd, as.getFirst(), a,b )){ remd= remd.genZero();}
-  else { remd= Prem(remd, as.getFirst()); }
-
-  return remd;
-}
-
-CFList
-remsetb( const CFList & ps, const CFList & as)
-{
-  CFList output;
-  CanonicalForm elem;
-  for (CFListIterator i=ps; i.hasItem(); i++)
-  {
-    elem= premasb(i.getItem(),as);
-    if ( !elem.isZero() ) output.append(elem);
-  }
-  return output;
-}
-
-// for characteristic sets
-//////////////////////////////////
-// replace the power of factors of polys in as by 1 if any
-static CFList
-nopower( const CanonicalForm & init )
-{
-  CFFList sqrfreelist;// = Factorize(init);//SqrFree(init);
-  CFList output;
-  CanonicalForm elem;
-  int count=0;
-
-  for ( CFIterator j=init; j.hasTerms(); j++ )
-    if (!(j.coeff().isOne()) ) count++;
-  //  if ( init != 1 ){
-  //  CERR << "nopower: f is " << init << "\n";
-  //  CERR << "nopower: count is " << count << "\n";}
-  if ( count > 1 ) sqrfreelist = CFFList( CFFactor(init,1));
-  else
-  {
-    sqrfreelist = Factorize(init);
-    //sqrfreelist.removeFirst();
-  }
-  for ( CFFListIterator i=sqrfreelist; i.hasItem(); i++ )
-  {
-    elem=i.getItem().factor();
-    if ( cls(elem) > 0 ) output.append(elem);
-  }
-  return output;
-}
-
-// remove the content of polys in PS; add the removed content to
-// Remembern.FS2 ( the set of removed factors )
-CFList
-removecontent ( const CFList & PS, PremForm & Remembern )
-{
-  CFListIterator i=PS;
-  if ((!i.hasItem()) || ( cls(PS.getFirst()) == 0 )) return PS;
-
-  CFList output;
-  CanonicalForm cc,elem;
-
-  for (; i.hasItem(); i++)
-  {
-    elem = i.getItem();
-    cc = content(elem, elem.mvar());
-    if ( cls(cc) > 0 )
-    {
-      output.append(elem/cc);
-      Remembern.FS2 = Union(CFList(cc), Remembern.FS2);
-    }
-    else{ output.append(elem); }
-  }
-  return output;
-}
-
-// remove possible factors in Remember.FS1 from poly r
-// Remember.FS2 contains all factors removed before
-void
-removefactor( CanonicalForm & r , PremForm & Remembern)
-{
-  int test;
-  CanonicalForm a,b,testelem;
-  CFList testlist;
-  int n=level(r);
-  CFListIterator j ;
-
-  for ( int J=1; J<= n ; J++ )
-  {
-    testlist.append(CanonicalForm(Variable(J)));
-  }
-
-  //  testlist = Union(Remembern.FS1, testlist); // add candidates
-
-  // remove already removed factors
-  for ( j = Remembern.FS2 ; j.hasItem(); j++ )
-  {
-    testelem = j.getItem();
-    while ( 1 )
-    {
-      test = mydivremt(r,testelem,a,b);
-      if ( test && b.isZero() ) r = a;
-      else break;
-    }
-  }
-
-  // Let's look if we have other canditates to remove
-  for ( j = testlist ; j.hasItem(); j++ )
-  {
-    testelem = j.getItem();
-//    if ( testelem != r && testelem != r.mvar() ){
-    if ( testelem != r )
-    {
-      while ( 1 )
-      {
-        test = divremt(r,testelem,a,b);
-        if ( test && b.isZero() )
-        {
-          Remembern.FS2= Union(Remembern.FS2, CFList(testelem));
-          r = a;
-          if ( r == 1 ) break;
-        }
-        else break;
-      }
-    }
-  }
-  //  CERR << "Remembern.FS1 = " << Remembern.FS1 << "\n";
-  //  CERR << "Remembern.FS2 = " << Remembern.FS2 << "\n";
-  //  Remembern.FS1 = Difference(Remembern.FS1, Remembern.FS2);
-  //  CERR << "  New Remembern.FS1 = " << Remembern.FS1 << "\n";
-}
-
-
-// all irreducible nonconstant factors of a set of polynomials
-CFList
-factorps( const CFList &ps )
-{
-  CFList qs;
-  CFFList q;
-  CanonicalForm elem;
-
-  for ( CFListIterator i=ps; i. hasItem(); i++ )
-  {
-    q=Factorize(i.getItem());
-    q.removeFirst();
-    // Next can be simplified ( first (already removed) elem in q is the only constant
-    for ( CFFListIterator j=q; j.hasItem(); j++ )
-    {
-      elem = j.getItem().factor();
-      if ( getNumVars(elem) > 0 )
-        qs= Union(qs, CFList(myfitting(elem, CFList())));
-    }
-  }
-  return qs;
-}
-
-// the initial of poly f wrt to the order of the variables
-static CanonicalForm
-inital( const CanonicalForm &f )
-{
-  CanonicalForm leadcoeff;
-
-  if ( cls(f) == 0 ) {return f.genOne(); }
-  else
-  {
-    leadcoeff = LC(f,lvar(f));
-    //    if ( leadcoeff != 0 )
-    return myfitting(leadcoeff, CFList()); //num(leadcoeff/lc(leadcoeff));
-    //    else return leadcoeff;
-  }
-}
-
-// the set of all nonconstant factors of initals of polys in as
-// CFList
-// initalset(const CFList &as){
-//   CanonicalForm elem;
-//   CFList is, iss,iniset;
-
-//   for ( CFListIterator i=as ; i.hasItem(); i++ ){
-//     elem = inital(i.getItem());
-//     if ( cls(elem) > 0 ) is.append(elem);
-//   }
-//   iss = factorps(is);
-//   for ( CFListIterator j=iss; j.hasItem();j++ ){
-//     elem = j.getItem();
-//     if ( cls(elem) > 0 ) iniset.append(num(elem/lc(elem)));
-//   }
-//   return iniset;
-// }
-
-// the set of nonconstant initials of Cset
-// with certain repeated factors cancelled
-CFList
-initalset1(const CFList & Cset)
-{
-  CFList temp;
-  CFList initals;
-  CanonicalForm init;
-
-  for ( CFListIterator i = Cset ; i.hasItem(); i++ )
-  {
-    initals= nopower( inital(i.getItem()) );
-    //    init= inital(i.getItem());
-    for ( CFListIterator j = initals; j.hasItem(); j++)
-    {
-      init = j.getItem();
-      if ( cls(init) > 0 )
-        temp= Union(temp, CFList(init));
-    }
-  }
-  return temp;
-}
-
-// the set of nonconstant initials of Cset of those polys
-// not having their cls higher than reducible
-// with certain repeated factors cancelled
-CFList
-initalset2(const CFList & Cset, const CanonicalForm & reducible)
-{
-  CFList temp;
-  CFList initals;
-  CanonicalForm init;
-  int clsred = cls(reducible);
-
-  for ( CFListIterator i = Cset ; i.hasItem(); i++ )
-  {
-    init = i.getItem();
-    if ( cls(init) < clsred )
-    {
-      initals= nopower( inital(init) );
-      //    init= inital(i.getItem());
-      for ( CFListIterator j = initals; j.hasItem(); j++)
-      {
-        init = j.getItem();
-        if ( cls(init) > 0 )
-          temp= Union(temp, CFList(init));
-      }
-    }
-  }
-  return temp;
-}
-
-//replace the power of factors of poly in CF init by 1 if any
-// and return the sqrfree poly
-// static CanonicalForm
-// nopower1( const CanonicalForm & init ){
-//   CFFList returnlist=Factorize(init);
-//   CanonicalForm elem, test=init.genOne();
-//   for ( CFFListIterator i= returnlist; i.hasItem(); i++){
-//     elem = i.getItem().factor();
-//     if ( cls(elem)>0 ) test *= elem;
-//   }
-//   return test;
-// }
-
-// the sequence of distinct factors of f
-//CF pfactor( ..... )
-
-// //////////////////////////////////////////
-// // for IrrCharSeries
-
-#ifdef IRRCHARSERIESDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-#include <libfac/factor/debug.h>
-// examine the irreducibility of as for IrrCharSeries
-int
-irreducible( const CFList & AS)
-{
-// AS is given by AS = { A1, A2, .. Ar }, d_i = degree(Ai)
-
-// 1) we test: if d_i > 1, d_j =1 for all j<>i, then AS is irreducible.
-  bool deg1=true;
-  for ( CFListIterator i = AS ; i.hasItem(); i++ )
-  {
-    if ( degree(i.getItem()) > 1 )
-    {
-      if ( deg1 ) deg1=0;
-      else return 0; // found 2nd poly with deg > 1
-    }
-  }
-  return 1;
-}
-
-
-// select an item from PS for irras
-CFList
-select( const ListCFList & PS)
-{
-  return PS.getFirst();
-}
-
-// divide list ppi in elems having length <= and > length
-void
-select( const ListCFList & ppi, int length, ListCFList & ppi1, ListCFList & ppi2)
-{
-  CFList elem;
-  for ( ListCFListIterator i=ppi ; i.hasItem(); i++ )
-  {
-    elem = i.getItem();
-    if ( ! elem.isEmpty() )
-      if ( length <= elem.length() ){ ppi2.append(elem); }
-      else { ppi1.append(elem); }
-  }
-}
-
-
-//////////////////////////////////////////////////////////////
-// help-functions for sets
-
-// is f in F ?
-static bool
-member( const CanonicalForm &f, const CFList &F)
-{
-  for ( CFListIterator i=F; i.hasItem(); i++ )
-    if ( i.getItem() == f ) return 1;
-  return 0;
-}
-
-// are list A and B the same?
-bool
-same( const CFList &A, const CFList &B )
-{
-  CFListIterator i;
-
-  for (i = A; i.hasItem(); i++)
-    if (! member(i.getItem(), B) )  return 0;
-  for (i = B; i.hasItem(); i++)
-    if (! member(i.getItem(), A) )  return 0;
-  return 1;
-}
-
-
-// is List cs contained in List of lists pi?
-bool
-member( const CFList & cs, const ListCFList & pi )
-{
-  ListCFListIterator i;
-  CFList elem;
-
-  for ( i=pi; i.hasItem(); i++)
-  {
-    elem = i.getItem();
-    if ( same(cs,elem) ) return 1;
-  }
-  return 0;
-}
-
-// is PS a subset of Cset ?
-bool
-subset( const CFList &PS, const CFList &Cset )
-{
-  //  CERR << "subset: called with: " << PS << "   " << Cset << "\n";
-  for ( CFListIterator i=PS; i.hasItem(); i++ )
-    if ( ! member(i.getItem(), Cset) )
-    {
-      //      CERR << "subset: " << i.getItem() << "  is not a member of " << Cset << "\n";
-      return 0;
-    }
-  return 1;
-}
-
-// Union of two List of Lists
-ListCFList
-MyUnion( const ListCFList & a, const ListCFList &b )
-{
-  ListCFList output;
-  ListCFListIterator i;
-  CFList elem;
-
-  for ( i = a ; i.hasItem(); i++ )
-  {
-    elem=i.getItem();
-    if ( (! elem.isEmpty()) && ( ! member(elem,output)) )
-    {
-      output.append(elem);
-    }
-  }
-
-  for ( i = b ; i.hasItem(); i++ )
-  {
-    elem=i.getItem();
-    if ( (! elem.isEmpty()) && ( ! member(elem,output)) )
-    {
-      output.append(elem);
-    }
-  }
-  return output;
-}
-
-//if list b is member of the list of lists remove b and return the rest
-ListCFList
-MyDifference( const ListCFList & a, const CFList &b)
-{
-  ListCFList output;
-  ListCFListIterator i;
-  CFList elem;
-
-  for ( i = a ; i.hasItem(); i++ )
-  {
-    elem=i.getItem();
-    if ( (! elem.isEmpty()) && ( ! same(elem,b)) )
-    {
-      output.append(elem);
-    }
-  }
-return output;
-}
-
-// remove all elements of b from list of lists a and return the rest
-ListCFList
-Minus( const ListCFList & a, const ListCFList & b)
-{
-  ListCFList output=a;
-
-  for ( ListCFListIterator i=b; i.hasItem(); i++ )
-    output = MyDifference(output, i.getItem() );
-
-  return output;
-}
-
-#if 0
-static CanonicalForm alg_lc(const CanonicalForm &f, const CFList as)
-{
-  for(CFListIterator i=as; i.hasItem(); i++)
-  {
-    if (f.mvar()==i.getItem().mvar()) return f;
-  }
-  if (f.level()>0)
-  {
-    return alg_lc(f.LC(),as);
-  }
-  return CanonicalForm(1);
-}
-#endif
-
-CanonicalForm alg_gcd(const CanonicalForm & fff, const CanonicalForm &ggg,
-                      const CFList &as)
-{
-  CanonicalForm f=fff;
-  CanonicalForm g=ggg;
-  f=Prem(f,as);
-  g=Prem(g,as);
-  if ( f.isZero() )
-  {
-    if ( g.lc().sign() < 0 ) return -g;
-    else                     return g;
-  }
-  else  if ( g.isZero() )
-  {
-    if ( f.lc().sign() < 0 ) return -f;
-    else                     return f;
-  }
-  //out_cf("alg_gcd(",fff," , ");
-  //out_cf("",ggg,")\n");
-  CanonicalForm res;
-  // does as appear in f and g ?
-  bool has_alg_var=false;
-  for ( CFListIterator j=as;j.hasItem(); j++ )
-  {
-    Variable v=j.getItem().mvar();
-    if (hasVar(f,v)) {has_alg_var=true; /*break;*/}
-    if (hasVar(g,v)) {has_alg_var=true; /*break;*/}
-    //out_cf("as:",j.getItem(),"\n");
-  }
-  if (!has_alg_var)
-  {
-    if ((hasAlgVar(f))
-    || (hasAlgVar(g)))
-    {
-      Varlist ord;
-      for ( CFListIterator j=as;j.hasItem(); j++ )
-        ord.append(j.getItem().mvar());
-      res=algcd(f,g,as,ord);
-    }
-    else
-      res=gcd(f,g);
-    //out_cf("gcd=",res,"\n");
-    //out_cf("of f=",fff," , ");
-    //out_cf("and g=",ggg,"\n");
-
-    return res;
-  }
-
-  int mvf=f.level();
-  int mvg=g.level();
-  if (mvg > mvf)
-  {
-    CanonicalForm tmp=f; f=g; g=tmp;
-    int tmp2=mvf; mvf=mvg; mvg=tmp2;
-  }
-  if (g.inBaseDomain() || f.inBaseDomain())
-  {
-    //printf("const\n");
-    //out_cf("of f=",fff," , ");
-    //out_cf("and g=",ggg,"\n");
-    return CanonicalForm(1);
-  }
-
-  // gcd of all coefficients:
-  CFIterator i=f;
-  CanonicalForm c_gcd=i.coeff(); i++;
-  while( i.hasTerms())
-  {
-    c_gcd=alg_gcd(i.coeff(),c_gcd,as);
-    if (c_gcd.inBaseDomain()) break;
-    i++;
-  }
-  //printf("f.mvar=%d (%d), g.mvar=%d (%d)\n",f.level(),mvf,g.level(),mvg);
-  if (mvf!=mvg) // => mvf > mvg
-  {
-    res=alg_gcd(g,c_gcd,as);
-    //out_cf("alg_gcd1=",res,"\n");
-    //out_cf("of f=",fff," , ");
-    //out_cf("and g=",ggg,"\n");
-    return res;
-  }
-  // now: mvf==mvg, f.level()==g.level()
-  if (!c_gcd.inBaseDomain())
-  {
-    i=g;
-    while( i.hasTerms())
-    {
-      c_gcd=alg_gcd(i.coeff(),c_gcd,as);
-      if (c_gcd.inBaseDomain()) break;
-      i++;
-    }
-  }
-
-  //f/=c_gcd;
-  //g/=c_gcd;
-  if (!c_gcd.isOne())
-  {
-    f=divide(f,c_gcd,as);
-    g=divide(g,c_gcd,as);
-  }
-
-  CFList gg;
-  CanonicalForm r=1;
-  while (1)
-  {
-    //printf("f.mvar=%d, g.mvar=%d\n",f.level(),g.level());
-    gg=as;
-    if (!g.inCoeffDomain()) gg.append(g);
-    //out_cf("Prem(",f," , ");
-    //out_cf("",g,")\n");
-    if (g.inCoeffDomain()|| g.isZero())
-    {
-      //printf("in coeff domain:");
-      if (g.isZero()) { //printf("0\n");
-        i=f;
-        CanonicalForm f_gcd=i.coeff(); i++;
-        while( i.hasTerms())
-        {
-          f_gcd=alg_gcd(i.coeff(),f_gcd,as);
-          if (f_gcd.inBaseDomain()) break;
-          i++;
-        }
-        //out_cf("g=0 -> f:",f,"\n");
-        //out_cf("f_gcd:",f_gcd,"\n");
-        //out_cf("c_gcd:",c_gcd,"\n");
-        //f/=f_gcd;
-        f=divide(f,f_gcd,as);
-        //out_cf("f/f_gcd:",f,"\n");
-        f*=c_gcd;
-        //out_cf("f*c_gcd:",f,"\n");
-        CanonicalForm r_lc=alg_lc(f);
-        //out_cf("r_lc:",r_lc,"\n");
-        //f/=r_lc;
-        f=divide(f,r_lc,as);
-        //out_cf(" -> gcd:",f,"\n");
-        return f;
-      }
-      else { //printf("c\n");
-        return c_gcd;}
-    }
-    else if (g.level()==f.level()) r=Prem(f,gg,as);
-    else
-    {
-      //printf("diff. level: %d, %d\n", f.level(), g.level());
-      // g and f have different levels
-      //out_cf("c_gcd=",c_gcd,"\n");
-    //out_cf("of f=",fff," , ");
-    //out_cf("and g=",ggg,"\n");
-      return c_gcd;
-    }
-    //out_cf("->",r,"\n");
-    f=g;
-    g=r;
-  }
-  if (degree(f,Variable(mvg))==0)
-  {
-  // remark: mvf == mvg == f.level() ==g.level()
-    //out_cf("c_gcd=",c_gcd,"\n");
-    //out_cf("of f=",fff," , ");
-    //out_cf("and g=",ggg,"\n");
-    return c_gcd;
-  }
-  //out_cf("f=",f,"\n");
-  i=f;
-  CanonicalForm k=i.coeff(); i++;
-  //out_cf("k=",k,"\n");
-  while( i.hasTerms())
-  {
-    if (k.inCoeffDomain()) break;
-    k=alg_gcd(i.coeff(),k,as);
-    //out_cf("k=",k,"\n");
-    i++;
-  }
-  //out_cf("end-k=",k,"\n");
-  f/=k;
-  //out_cf("f/k=",f,"\n");
-  res=c_gcd*f;
-  CanonicalForm r_lc=alg_lc(res);
-  res/=r_lc;
-  //CanonicalForm r_lc=alg_lc(res,as);
-  //res/=r_lc;
-  //out_cf("alg_gcd2=",res,"\n");
-  //  out_cf("of f=",fff," , ");
-  //  out_cf("and g=",ggg,"\n");
-  //return res;
-  //if (res.level()<fff.level() && res.level() < ggg.level())
-  //  return alg_gcd(alg_gcd(fff,res,as),ggg,as);
-  //else
-    return res;
-}
Index: ctory/libfac/charset/csutil.h
===================================================================
--- factory/libfac/charset/csutil.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,77 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-
-#ifndef INCL_CSUTIL_H
-#define INCL_CSUTIL_H
-
-#include <factory.h>
-#include "algfactor.h"
-#include <tmpl_inst.h>
-
-// inline function's:
-
-inline int 
-cls ( const CanonicalForm & f ){ if ( getNumVars(f) == 0 ) {return 0;} else {return f.level();} }
-
-inline int 
-rank ( const CanonicalForm & f ){ return cls(f); }
-
-inline CanonicalForm 
-ini ( const CanonicalForm & f ){ return LC(f); }
-
-inline CanonicalForm 
-ini ( const CanonicalForm & f , const Variable v ){ return LC(f,v); }
-
-inline Variable 
-lvar ( const CanonicalForm & f ){ return f.mvar(); }
-
-///////////////////////////////////////////////////////////////
-// a class definition needed in charset.cc for Prem
-///////////////////////////////////////////////////////////////
-/*BEGINPUBLIC*/
-
-class PremForm {
-public:
-  CFList FS1;
-  CFList FS2;
-  inline PremForm& operator=( const PremForm&  value ){
-    if ( this != &value ){
-      FS1 = value.FS1;
-      FS2 = value.FS2;
-    }
-    return *this;
-  }
-};
-
-/*ENDPUBLIC*/
-
-// functions from csutil.cc:
-/*BEGINPUBLIC*/
-CanonicalForm  Prem( const CanonicalForm &f, const CanonicalForm &g );
-CanonicalForm  Prem( const CanonicalForm &f, const CFList &L );
-CFList         Prem( const CFList &AS, const CFList &L );
-CanonicalForm alg_gcd(const CanonicalForm &, const CanonicalForm &, const CFList &);
-/*ENDPUBLIC*/
-CanonicalForm  divide( const CanonicalForm & ff, const CanonicalForm & f, const CFList & as);
-CFList         remsetb( const CFList & ps, const CFList & as);
-CanonicalForm  lowestRank( const CFList & F );
-
-CFList         removecontent ( const CFList & PS, PremForm & Remembern );
-void           removefactor( CanonicalForm & r , PremForm & Remembern);
-CFList         factorps( const CFList &ps );
-//CFList         initalset(const CFList & CSet);
-CFList         initalset1(const CFList & CSet);
-CFList         initalset2(const CFList & CSet, const CanonicalForm & reducible);
-int            irreducible( const CFList & ASet);
-CFList         select( const ListCFList & PSet);
-void           select( const ListCFList & ppi, int length, ListCFList & ppi1, 
-		       ListCFList & ppi2);
-bool           same( const CFList &A, const CFList &B );
-bool           member( const CFList & cs, const ListCFList & pi );
-bool           subset( const CFList &PSet, const CFList &CSet );
-ListCFList     MyUnion( const ListCFList & a, const ListCFList &b );
-ListCFList     MyDifference( const ListCFList & a, const CFList &b);
-ListCFList     Minus( const ListCFList & a, const ListCFList &b);
-#endif /* INCL_CSUTIL_H */
-
Index: ctory/libfac/charset/reorder.cc
===================================================================
--- factory/libfac/charset/reorder.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,405 +1,0 @@
-////////////////////////////////////////////////////////////
-// This is really experimental. What is the best order of the variables for
-// an ideal? Clearly, if a variable only occures in one and only one polynomial
-// this variable should be assigned the highest level.
-// But what for the others?
-//
-// The strategy used here is o.k. for *most* of the examples. But there are
-// examples where this strategy doesn't give the best possible answer.
-// So, use this at your own risk! The order given may increase or decrease
-// computing time for your example!
-/////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-// FACTORY - Includes
-#include <factory.h>
-// Factor - Includes
-#include <tmpl_inst.h>
-#include "homogfactor.h"
-// Charset - Includes
-
-// some CC's need this:
-#include "reorder.h"
-
-#ifdef REORDERDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-
-#include <libfac/factor/debug.h>
-#include "timing.h"
-TIMING_DEFINE_PRINT(neworder_time)
-
-#define __ARRAY_INIT__ -1
-
-// the maximal degree of polys in PS wrt. variable x
-static int
-degpsmax( const CFList & PS, const Variable & x, 
-	  Intarray & A, Intarray & C){
-  int varlevel = level(x);
-  if ( A[varlevel] != __ARRAY_INIT__ ) return A[varlevel];
-  int max=0,temp, count=0;
-  
-  for ( CFListIterator i=PS; i.hasItem();i++){
-    temp = degree(i.getItem(),x);
-    if ( temp > max ) {max = temp; count = 0; }
-    if ( temp == max) { count += max; } // we count the number of polys
-  }
-  A[varlevel] = max; C[varlevel] = count;
-  return max;
-}
-
-// the minimal non-zero degree of polys in PS wrt. x
-// returns 0 if variable x doesn't occure in any of the polys
-static int
-degpsmin( const CFList & PS, const Variable & x, Intarray & A, Intarray & B,
-	  Intarray & C, Intarray & D){
-  int varlevel = level(x);
-  if ( B[varlevel] != __ARRAY_INIT__ ) return B[varlevel];
-  int min=degpsmax(PS,x,A,C), temp, count=0;
-
-  if (min==0) {
-    B[varlevel] = min; D[varlevel] = min;
-    return min;
-  }
-  else
-    for ( CFListIterator i=PS; i.hasItem();i++){
-      temp = degree(i.getItem(),x);
-      if ( temp < min && temp != 0 ){ min = temp; count = 0; }
-      if ( temp == min) { count += min;} // we count the number of polys
-    }
-  B[varlevel] = min; D[varlevel] = count;
-  return min;
-}
-
-// the minimal total degree of lcoeffs of polys in PS wrt. x
-// for those polys having degree degpsmin in x.
-// F will be assigned the minimal number of terms of those lcoeffs
-static int
-Tdeg( const CFList & PS, const Variable & x, Intarray & A, Intarray & B,
-      Intarray & C, Intarray & D, Intarray & E, Intarray & F){
-  int k= degpsmin(PS,x,A,B,C,D), 
-    varlevel= level(x), min=0;
-
-  if ( E[varlevel] != __ARRAY_INIT__ ) return E[varlevel];
-  if (k == 0){
-    E[varlevel]= 0; F[varlevel]= 0;
-  }
-  else{
-    int nopslc=0;
-    CFList LCdegList;
-    CanonicalForm elem;
-    CFListIterator i;
-
-    for ( i=PS; i.hasItem(); i++ ){
-      elem = i.getItem();
-      if ( degree(elem,x) == k ) LCdegList.append(LC(elem,x));
-    }
-    
-    if ( LCdegList.length() > 0 ){
-      CFList TermList;
-      int newmin, newnopslc;
-
-      min= totaldegree(LCdegList.getFirst());
-      TermList= get_Terms(LCdegList.getFirst()); 
-      nopslc= TermList.length();
-      for ( i=LCdegList; i.hasItem(); i++){
-	elem= i.getItem();
-	newmin= totaldegree(elem);
-	TermList= get_Terms(elem);
-	newnopslc= TermList.length();
-	if ( newmin < min ) min= newmin; 
-	if ( newnopslc < nopslc ) nopslc= newnopslc;
-      }
-      
-    }
-    E[varlevel]= min;
-    F[varlevel]= nopslc;
-  }
-  return min;
-}
-
-// The number of the poly in which Variable x first occures
-static int
-nr_of_poly( const CFList & PS, const Variable & x, Intarray & G){
-  int min=0, varlevel=level(x);
-  if ( G[varlevel] != __ARRAY_INIT__ ) return G[varlevel];
-  for ( CFListIterator i=PS; i.hasItem(); i++ ){
-    min += 1;
-    if ( degree(i.getItem(),x) > 0 ) break;
-  }
-  G[varlevel]= min;
-  return min;
-}
-
-static int
-degord( const Variable & x, const Variable & y, const CFList & PS,
-	Intarray & A, Intarray & B, Intarray & C, Intarray & D,
-	Intarray & E, Intarray & F, Intarray & G){
-  int xlevel= level(x), ylevel= level(y);
-
-  if      (degpsmax(PS,y,A,C) < degpsmax(PS,x,A,C))         return 1;
-  else if (degpsmax(PS,x,A,C) < degpsmax(PS,y,A,C) )        return 0;
-  else if (C[ylevel] < C[xlevel])                           return 1;
-  else if (C[xlevel] < C[ylevel])                           return 0;
-  else if (degpsmin(PS,x,A,B,C,D) < degpsmin(PS,y,A,B,C,D)) return 1;
-  else if (degpsmin(PS,y,A,B,C,D) < degpsmin(PS,x,A,B,C,D)) return 0;
-  else if (D[ylevel] < D[xlevel])                           return 1;
-  else if (D[xlevel] < D[ylevel])                           return 0;
-  else if (Tdeg(PS,y,A,B,C,D,E,F) < Tdeg(PS,x,A,B,C,D,E,F)) return 1;
-  else if (Tdeg(PS,x,A,B,C,D,E,F) < Tdeg(PS,y,A,B,C,D,E,F)) return 0;
-  else if (F[ylevel] < F[xlevel])                           return 1;
-  else if (F[xlevel] < F[ylevel])                           return 0;
-  else if (nr_of_poly(PS,x,G) <= nr_of_poly(PS,y,G))        return 1;
-  else return 0;
-
-}
-
-// determine the highest variable of all involved Variables in PS
-// NOTE:
-//    this doesn't give always the correct answer:
-//    If a variable is assigned the highest level in the definition of the
-//    original ring, but doesn't occure in any of the 
-//    polynomials, get_max_var returns the variable with a level lower than 
-//    the highest level.
-//    Is there a workaround?
-// But for the redefinition of the ring this doesn't matter due to the
-// implementation of neworder().
-
-static Variable
-get_max_var(const CFList & PS){
-  Variable x=PS.getFirst().mvar(), y;
-  for (CFListIterator i=PS; i.hasItem(); i++){
-    y = i.getItem().mvar();
-    if ( y > x ) x=y;
-  }
-  return x;
-}
-
-
-// determine if variable x is in one and only one of the polynomials in PS
-// first criterion for neworder
-static CFList
-only_in_one( const CFList & PS , const Variable & x){
-  CFList output;
-
-  for ( CFListIterator i=PS; i.hasItem(); i++ ){
-    if ( degree(i.getItem(),x) >= 1 ) output.insert(i.getItem());
-    if ( output.length() >= 2 ) break;
-  }
-  return output;
-}
-
-// initialize all Arrays (of same range) with __ARRAY_INIT__
-static void
-initArray(const int highest_level, Intarray & A, Intarray & B, Intarray & C, 
-	  Intarray & D, Intarray & E, Intarray & F, Intarray & G){ 
-
-  for ( int i=1 ; i <= highest_level; i ++){
-    A[i] = __ARRAY_INIT__; B[i] = __ARRAY_INIT__; 
-    C[i] = __ARRAY_INIT__; D[i] = __ARRAY_INIT__;
-    E[i] = __ARRAY_INIT__; F[i] = __ARRAY_INIT__;
-    G[i] = __ARRAY_INIT__;
-  }
-}
-
-// now for the second criterion; a little more complex
-//
-// idea: set up seven arrays of lenth highest_level 
-//       (of which some entries may be empty, because of only_in_one!)
-//   A saves maxdegree of Variable x in A(level(x))
-//   B saves mindegree of Variable x in B(level(x))
-//   C saves the number of polys in PS which have degree A(level(x)) in 
-//     D(level(x))
-//   D saves the number of polys in PS which have degree B(level(x)) in 
-//     D(level(x))
-//   E saves the minimal total degree of lcoeffs of polys wrt x in E(level(x))
-//   F saves the minimal number of terms of lcoeffs of E(level(x)) in F(~)
-//   G saves nr of poly Variable x has first deg <> 0
-
-#define __INIT_GAP__ 3
-static Varlist
-reorderb(const Varlist & difference, const CFList & PS, 
-	 const int highest_level){
-  Intarray A(1, highest_level), B(1, highest_level), C(1, highest_level), 
-    D(1, highest_level), E(1, highest_level), F(1, highest_level),
-    G(1, highest_level);
-  initArray(highest_level,A,B,C,D,E,F,G);
-  int i=0, j, n=difference.length(), gap=1+__INIT_GAP__;
-  Variable temp;
-  Array<Variable> v(0,n);
-  VarlistIterator J;
-
-  for (J= difference; J.hasItem(); J++ ){ 
-    v[i]= J.getItem(); 
-    i++ ; 
-  }
-  
-  while ( gap <= n) gap = __INIT_GAP__ * gap+1;
-  gap /= __INIT_GAP__;
-  DEBOUTLN(CERR, "gap is ", gap);
-  
-  while ( gap > 0 ){
-    for ( i=gap; i<= n-1; i++){
-      temp = v[i];
-      for ( j= i-gap; j >=0 ; j-=gap){
-	if (degord(v[j],temp, PS, A,B,C,D,E,F,G))  break;
-	v[j+gap] = v[j];
-	//CERR << "v[" << j+gap << "]= " << v[j+gap] << "\n";
-      }
-      v[j+gap] = temp;
-      //CERR << "v[" << j+gap << "]= " << v[j+gap] << "\n";
-    }
-    gap /= __INIT_GAP__;
-  }
-  Varlist output;
-  for (i=0; i<= n-1; i++)
-    output.append(v[i]);
-  DEBOUTLN(CERR, "A= ", A);  DEBOUTLN(CERR, "B= ", B);  
-  DEBOUTLN(CERR, "C= ", C);  DEBOUTLN(CERR, "D= ", D);
-  DEBOUTLN(CERR, "E= ", E);  DEBOUTLN(CERR, "F= ", F);
-  DEBOUTLN(CERR, "G= ", G);
-  return output;
-}
-
-// set up a new orderd list of Variables.
-// we try to reorder the variables heuristically optimal.
-Varlist
-neworder( const CFList & PolyList ){
-  CFList PS= PolyList, PS1=PolyList;
-  Varlist oldorder, reorder, difference;
-
-  DEBINCLEVEL(CERR, "neworder");
-  TIMING_START(neworder_time);
-
-  int highest_level= level(get_max_var(PS));
-  DEBOUTLN(CERR, "neworder: highest_level=   ", highest_level);
-  DEBOUTLN(CERR, "neworder: that is variable ", Variable(highest_level));
-
-  // set up oldorder and first criterion: only_in_one
-  for (int i=highest_level; i>=1; i--){
-    oldorder.insert(Variable(i));
-    CFList is_one= only_in_one(PS1, Variable(i)); 
-    if ( is_one.length() == 1 ){
-      DEBOUTLN(CERR, "Found a variable which is in only one Polynomial: ", 
-	       Variable(i));
-      DEBOUTLN(CERR, ".... in the Polynomial: ", is_one.getFirst());
-      reorder.insert(Variable(i));
-      PS1 = Difference(PS1, is_one);
-      DEBOUTLN(CERR, "New cutted list is: ", PS1);
-    }
-    else if ( is_one.length() == 0 ){
-      DEBOUTLN(CERR, "Found a variable which is in no polynomial: ", 
-	       Variable(i));
-      DEBOUTMSG(CERR, "... assigning it the highest level.");
-      reorder.append(Variable(i)); // assigne it the highest level
-      PS1 = Difference(PS1, is_one); 
-    }
-  }
-  difference = Difference(oldorder,reorder);
-  DEBOUTLN(CERR, "Missing variables are: ", difference);
-  // rearrange the ordering of the variables!
-  difference = reorderb(difference, PS, highest_level);
-  DEBOUTLN(CERR, "second criterion gives: ", difference);
-  reorder = Union(reorder, difference);
-  DEBOUTLN(CERR, "old order was:     ", oldorder);
-  DEBOUTLN(CERR, "New order will be: ", Union(reorder, Difference(oldorder,reorder)));
-  DEBDECLEVEL(CERR, "neworder");
-  TIMING_END(neworder_time);
-
-  TIMING_PRINT(neworder_time, "\ntime used for neworder   : ");
-
-
-  return Union(reorder,Difference(oldorder,reorder));
-}
-
-// the same as above, only returning a list of CanonicalForms
-CFList
-newordercf(const CFList & PolyList ){
-  Varlist reorder= neworder(PolyList);
-  CFList output;
-
-  for (VarlistIterator i=reorder; i.hasItem(); i++)
-    output.append(CanonicalForm(i.getItem()));
-
-  return output;
-}
-
-// the same as above, only returning a list of ints
-IntList
-neworderint(const CFList & PolyList ){
-  Varlist reorder= neworder(PolyList);
-  IntList output;
-
-  for (VarlistIterator i=reorder; i.hasItem(); i++)
-    output.append(level(i.getItem()));
-
-  return output;
-}
-
-// swapvar a whole list of CanonicalForms
-static CFList
-swapvar( const CFList & PS, const Variable & x, const Variable & y){
-  CFList ps;
-
-  for (CFListIterator i= PS; i.hasItem(); i++)
-    ps.append(swapvar(i.getItem(),x,y));
-  return ps;
-}
-
-static CFFList
-swapvar( const CFFList & PS, const Variable & x, const Variable & y){
-  CFFList ps;
-
-  for (CFFListIterator i= PS; i.hasItem(); i++)
-    ps.append(CFFactor(swapvar(i.getItem().factor(),x,y),i.getItem().exp()));
-  return ps;
-}
-
-// a library function: we reorganize the global variable ordering
-CFList
-reorder( const Varlist & betterorder, const CFList & PS){
-  int i=1, n = betterorder.length();
-  Intarray v(1,n);
-  CFList ps=PS;
-
-  //initalize:
-  for (VarlistIterator j = betterorder; j.hasItem(); j++){
-    v[i]= level(j.getItem()); i++;
-  }
-  DEBOUTLN(CERR, "reorder: Original ps=  ", ps);
-  // reorder:
-  for (i=1; i <= n; i++)
-    ps=swapvar(ps,Variable(v[i]),Variable(n+i));
-  DEBOUTLN(CERR, "reorder: Reorganized ps= ", ps); 
-  return ps;
-}
-
-CFFList
-reorder( const Varlist & betterorder, const CFFList & PS){
-  int i=1, n = betterorder.length();
-  Intarray v(1,n);
-  CFFList ps=PS;
-
-  //initalize:
-  for (VarlistIterator j = betterorder; j.hasItem(); j++){
-    v[i]= level(j.getItem()); i++;
-  }
-  DEBOUTLN(CERR, "reorder: Original ps=  ", ps);
-  // reorder:
-  for (i=1; i <= n; i++)
-    ps=swapvar(ps,Variable(v[i]),Variable(n+i));
-  DEBOUTLN(CERR, "reorder: Reorganized ps= ", ps); 
-  return ps;
-}
-
-ListCFList
-reorder(const Varlist & betterorder, const ListCFList & Q){
-  ListCFList Q1;
-
-  for ( ListCFListIterator i=Q; i.hasItem(); i++)
-    Q1.append(reorder(betterorder, i.getItem()));
-  return Q1;
-}
-
Index: ctory/libfac/charset/reorder.h
===================================================================
--- factory/libfac/charset/reorder.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,42 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-#ifndef INCL_REORDER_H
-#define INCL_REORDER_H
-
-#include <factory.h>
-#include <tmpl_inst.h>  // for typedef's
-
-/*BEGINPUBLIC*/
-// the next three give you a heuristically optimal reorderd list of the
-// variables. For internal and external (e.g. Singular/Macaulay2) library use.
-// This is really experimental!
-// See the comments in reorder.cc.
-// 
-// this gives you a heuristically optimal ordering for the ring variables
-// if you use the irreducible characteristic series.
-Varlist  neworder( const CFList & PolyList );
-// the same as neworder(...) only returning a list of CanonicalForm 's
-// (i.e. the variables as CanonicalForms)
-CFList   newordercf(const CFList & PolyList );
-// the same as neworder(...) only returning a list of int 's (i.e. the levels)
-IntList  neworderint(const CFList & PolyList );
-
-// for library internal use only:
-// next function reorders the variables in PS:
-// a code segment to use:
-// ...
-// #include <tmpl_inst.h> // for typedef's
-// CFList PS= <setup-your-list-of-CanonicalForms>;
-// Varlist betterorder= neworder(PS);
-// PS= reorder(betterorder,PS); // reorder variables in PS from oldorder 
-//                                 to betterorder
-// ListCFList Q= IrrCharSeries( PS );
-// Q= reorder(betterorder,Q);   // revert ordering to oldorder
-// 
-CFList reorder( const Varlist & betterorder, const CFList & PS);
-CFFList reorder( const Varlist & betterorder, const CFFList & PS);
-ListCFList reorder(const Varlist & betterorder, const ListCFList & Q);
-/*ENDPUBLIC*/
-
-#endif /* INCL_REORDER_H */
Index: ctory/libfac/charset/tests/charsettest
===================================================================
--- factory/libfac/charset/tests/charsettest	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,47 +1,0 @@
-#!/bin/csh
-set OS=`uname`
-if ( $OS == "Linux" ) then
-	set ECHO="/bin/echo -e"
-	set MAKE=make
-else if ( $OS == "SunOS" ) then
-	set ECHO=/usr/5bin/echo
-	set MAKE=gmake
-else
-	set ECHO=echo
-	set MAKE=make
-endif
-
-(cd .. ; $MAKE opttestcs )
-
-$ECHO "\n\ntesting CharSet:\c"
-$ECHO "\nt1  \c" 
-../testcs < t1  
-$ECHO "\nt2  \c"
-../testcs < t2
-$ECHO "\nt3  \c"
-../testcs < t3
-$ECHO "\nt4  \c"
-../testcs < t4
-$ECHO "\nt5  \c"
-../testcs < t5
-$ECHO "\nt6  \c"
-../testcs < t6
-$ECHO "\nt7  \c"
-../testcs < t7
-$ECHO "\nt8  \c"
-../testcs < t8
-$ECHO "\nt9  \c"
-../testcs < t9
-
-$ECHO "\nw1 \c"
-../testcs < w1
-$ECHO "\nw2 \c"
-../testcs < w2
-$ECHO "\nw3 \c"
-../testcs < w3
-$ECHO "\nw4 \c"
-../testcs < w4
-
-$ECHO "\nx1 \c"
-../testcs < x1
-
Index: ctory/libfac/charset/tests/hans1
===================================================================
--- factory/libfac/charset/tests/hans1	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,12 +1,0 @@
-32003
-abcdefh
--1*a-1*d+e+f+h;
--2*a^2+2*a*d+2*c*e+2*b*f-1*a-1;
-3*a^3-3*a^2*d+3*c^2*e+3*b^2*f+3*a^2+4*a-1*d;
-6*a^3-6*a^2*d+6*b*e*g+6*a^2-3*a*d+4*a-1*d;
--4*a^4+4*a^3*d+4*c^3*e+4*b^3*f-6*a^3-10*a^2+4*a*d-1*a-1;
--8*a^4+8*a^3*d+8*b*c*e*g-12*a^3+4*a^2*d-14*a^2+4*a*d-3*a-1;
--12*a^4+12*a^3*d+12*b^2*e*g-18*a^3+12*a^2*d-14*a^2+8*a*d-1*a-1;
-24*a^4-24*a^3*d+36*a^3-24*a^2*d+26*a^2-8*a*d+7*a+1;
-0;
-
Index: ctory/libfac/charset/tests/hans2
===================================================================
--- factory/libfac/charset/tests/hans2	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,8 +1,0 @@
-0
-abcdefghj
-d*b-e*a;
-c*e-f*b;
-g*e-h*d;
-h*f-j*e;
-0;
-
Index: ctory/libfac/charset/tests/mcharsettest
===================================================================
--- factory/libfac/charset/tests/mcharsettest	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,51 +1,0 @@
-#!/bin/csh
-set OS=`uname`
-if ( $OS == "Linux" ) then
-	set ECHO="/bin/echo -e"
-	set MAKE=make
-else if ( $OS == "SunOS" ) then
-	set ECHO=/usr/5bin/echo
-	set MAKE=gmake
-else
-	set ECHO=echo
-	set MAKE=make
-endif
-
-(cd .. ; $MAKE testmcs )
-
-$ECHO "\n\ntesting CharSet:\c"
-$ECHO "\nt1  \c" 
-../testmcs < t1  
-$ECHO "\nt2  \c"
-../testmcs < t2
-$ECHO "\nt3  \c"
-../testmcs < t3
-$ECHO "\nt4  \c"
-../testmcs < t4
-$ECHO "\nt5  \c"
-../testmcs < t5
-$ECHO "\nt6  \c"
-../testmcs < t6
-$ECHO "\nt7  \c"
-../testmcs < t7
-$ECHO "\nt8  \c"
-../testmcs < t8
-$ECHO "\nt9  \c"
-../testmcs < f9
-
-$ECHO "\nw1 \c"
-../testmcs < w1
-$ECHO "\nw2 \c"
-../testmcs < w2
-$ECHO "\nw3 \c"
-../testmcs < w3
-$ECHO "\nw4 \c"
-../testmcs < w4
-
-$ECHO "\nx1 \c"
-../testmcs < x1
-
-$ECHO "\n"
-$ECHO 
-# long time section:
-$ECHO "\n Long-time section!\n"
Index: ctory/libfac/charset/tests/t1
===================================================================
--- factory/libfac/charset/tests/t1	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,8 +1,0 @@
-31991
-abcd
-a*b*c-b*c*d-c*d*a-d*a*b;
-a^3-b^3-a^3*b^3+c^3+d^3;
-a*b+b*c+c*d+d*a;
-a^2;
-c*a*b+a*b+a+b;
-0;
Index: ctory/libfac/charset/tests/t2
===================================================================
--- factory/libfac/charset/tests/t2	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,6 +1,0 @@
-31991
-xyz
-x^3-y^2;
-x^3-z^2;
-y^3-z^2;
-0;
Index: ctory/libfac/charset/tests/t3
===================================================================
--- factory/libfac/charset/tests/t3	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,8 +1,0 @@
-31991
-abcdef
-a*b*c+a*b+a*e;
-a-b*d*e;
-d*e*f+f;
-f-e;
-a-a*b;
-0;
Index: ctory/libfac/charset/tests/t4
===================================================================
--- factory/libfac/charset/tests/t4	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,6 +1,0 @@
-31991
-xyz
-x^3-x^2+y^2;
-x-y^3;
-x*y*z+z^3;
-0;
Index: ctory/libfac/charset/tests/t5
===================================================================
--- factory/libfac/charset/tests/t5	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,5 +1,0 @@
-31991
-xy
-x^2+y^2-1;
-x*y;
-0;
Index: ctory/libfac/charset/tests/t6
===================================================================
--- factory/libfac/charset/tests/t6	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,10 +1,0 @@
-31991
-caloqhjnbdpkmgef
-a^4*b^3*c^3-e^2*f^4+a^3*b^2*e;
-a*b*d^3-q^8;
-a*b*g^4*d^2-g^3-g^2;
-a^4-a^5-a^3+k^2*o^2*p;
-q^3*j^3*m*n;
-n^3-n^2+a*b*c;
-p^4-p^3-p^5*b^2-a*b*c*d^3-q^2*j^2;
-0;
Index: ctory/libfac/charset/tests/t7
===================================================================
--- factory/libfac/charset/tests/t7	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,6 +1,0 @@
-31991
-xyzt
-t^2+x*t^2-y*t-x*y*t+x*y+3*y;
-x*t+z-x*y;
-z*t-2*y^2-x*y-1;
-0;
Index: ctory/libfac/charset/tests/t8
===================================================================
--- factory/libfac/charset/tests/t8	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,10 +1,0 @@
-31991
-dcaflohjnbspkmge
-a^4*b^3*c^3-e^2*f^4+a^3*b^2*e;
-a*b*d^3-s^8;
-a*b*g^4*d^2-g^3-g^2;
-a^4-a^5-a^3+k^2*o^2*p;
-s^3*j^3*m*n;
-n^3-n^2+a*b*c;
-p^4-p^3-p^5*b^2-a*b*c*d^3-s^2*j^2;
-0;
Index: ctory/libfac/charset/tests/t8a
===================================================================
--- factory/libfac/charset/tests/t8a	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,10 +1,0 @@
-31991
-ponmlkjigfedcba
-a^4*b^3*c^3-e^2*f^4+a^3*b^2*e;
-a*b*d^3-i^8;
-a*b*g^4*d^2-g^3-g^2;
-a^4-a^5-a^3+k^2*o^2*p;
-i^3*j^3*m*n;
-n^3-n^2+a*b*c;
-p^4-p^3-p^5*b^2-a*b*c*d^3-i^2*j^2;
-0;
Index: ctory/libfac/charset/tests/t9
===================================================================
--- factory/libfac/charset/tests/t9	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,8 +1,0 @@
-31991
-dcba
-a*b*c-b*c*d-c*d*a-d*a*b;
-a^3-b^3-a^3*b^3+c^3+d^3;
-a*b+b*c+c*d+d*a;
-a^2;
-c*a*b+a*b+a+b;
-0;
Index: ctory/libfac/charset/tests/w1
===================================================================
--- factory/libfac/charset/tests/w1	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,6 +1,0 @@
-31991
-xyzt
-t^2+x*t^2-y*t-x*y*t+x*y+3*y;
-x*t+z-x*y;
-z*t-2*y^2-x*y-1;
-0;
Index: ctory/libfac/charset/tests/w2
===================================================================
--- factory/libfac/charset/tests/w2	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,11 +1,0 @@
-31991
-acbdefgh
-h+f+e-d-a;
-2*f*b+2*e*c-1-a-2*a^2+2*a*d;
-3*f*b^2+3*e*c^2-d-3*a^2*d+4*a+3*a^2+2*a^3;
-6*e*g*b-d-3*a*d-6*a^2*d+4*a+6*a^2+6*a^3;
-4*f*b^2+4*e*c^3-1-a-10*a^2-6*a^3-4*a^4+4*d*a+4*a^3*d;
-8*e*c*g*b-1-3*a-14*a^2-12*a^3-8*a^4-4*a*d+4*a^2*d+8*a^3*d;
-12*e*c*g*b-1-a-14*a^2-18*a^3-12*a^4+8*a*d+12*a^2*d+12*a^3*d;
-1+7*a+26*a^2+36*a^3+24*a^4-8*a*d-24*a^2*d-24*a^3*d;
-0;
Index: ctory/libfac/charset/tests/w3
===================================================================
--- factory/libfac/charset/tests/w3	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,15 +1,0 @@
-31991
-abcdefghkj
--j+a^2*b^2*c^2*d^2*e+a^2*b^2*c^2*d^2*f+a^2*b^2*c^2*d*e^2+2*a^2*b^2*c^2*d*e*f+a^2*b^2*c^2*d*f^2+a^2*b^2*c^2*e^2*f+a^2*b^2*c^2*e*f^2+a^2*d*h-b^2*f*g*c^2*e*k*g-h-k;
-2*a*d*h+2*a*b^2*c^2*e*f^2+2*a*b^2*c^2*d*f^2+2*a*b^2*c^2*e^2*f+4*a*b^2*c^2*d*e*f+2*a*b^2*c^2*d^2*f+2*a*b^2*c^2*d*e^2+2*a*b^2*c^2*d^2*e;
--2*b*c^2*e*f*g^2*k+2*a^2*b*c^2*e*f^2+2*a^2*b*c^2*d*f^2+2*a^2*b*c^2*e^2*f+4*a^2*b*c^2*d*e*f+2*a^2*b*c^2*d^2*f+2*a^2*b*c^2*d*e^2+2*a^2*b*c^2*d^2*e;
--2*b^2*c*e*f*g^2*k+2*a^2*b^2*c*e*f^2+2*a^2*b^2*c*d*f^2+2*a^2*b^2*c*e^2*f+4*a^2*b^2*c*d*e*f+2*a^2*b^2*c*d^2*f+2*a^2*b^2*c*d*e^2+2*a^2*b^2*c*d^2*e;
-a^2*h+a^2*b^2*c^2*f^2+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+a^2*b^2*c^2*e^2+2*a^2*b^2*c^2*d*e;
--b^2*c^2*f*g^2*k+a^2*b^2*c^2*f^2+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+2*a^2*b^2*c^2*d*e+a^2*b^2*c^2*d^2;
--b^2*c^2*e*g^2*k+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+a^2*b^2*c^2*e^2+2*a^2*b^2*c^2*d*e+a^2*b^2*c^2*d^2;
--2*b^2*c^2*e*f*g*k;
-a^2*d-1;
--b^2*c^2*e*f*g^2-1;
-0;
-
-
Index: ctory/libfac/charset/tests/w3a
===================================================================
--- factory/libfac/charset/tests/w3a	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,14 +1,0 @@
-31991
-abcdefghij
--6*b*c^2*e*f*g^2+2*a^2*b*c^2*e*f^2+2*a^2*b*c^2*d*f^2+2*a^2*b*c^2*e^2*f+4*a^2*b*c^2*d*e*f+2*a^2*b*c^2*d^2*f+2*a^2*b*c^2*d*e^2+2*a^2*b*c^2*d^2*e;
--j-b^2*c^2*e*f*g^2-1+a^2*d*h-h+a^2*b^2*c^2*e*f^2+a^2*b^2*c^2*d*f^2+a^2*b^2*c^2*e^2*f+2*a^2*b^2*c^2*d*e*f+a^2*b^2*c^2*d^2*f+a^2*b^2*c^2*d*e^2+a^2*b^2*c^2*d^2*e;
--8*b^2*c*e*f*g^2+2*a^2*b^2*c*e*f^2+2*a^2*b^2*c*d*f^2+2*a^2*b^2*c*e^2*f+4*a^2*b^2*c*d*e*f+2*a^2*b^2*c*d^2*f+2*a^2*b^2*c*d*e^2+2*a^2*b^2*c*d^2*e;
--16*b^2*c^2*e*f*g;
--7*b^2*c^2*e*g^2+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+a^2*b^2*c^2*e^2+2*a^2*b^2*c^2*d*e+a^2*b^2*c^2*d^2;
--6*b^2*c^2*f*g^2+a^2*b^2*c^2*f^2+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+2*a^2*b^2*c^2*d*e+a^2*b^2*c^2*d^2;
-a^2*d-1;
--b^2*c^2*e*f*g^2-1;
-2*a*d*h+2*a*b^2*c^2*e*f^2+2*a*b^2*c^2*d*f^2+2*a*b^2*c^2*e^2*f+4*a*b^2*c^2*d*e*f+2*a*b^2*c^2*d^2*f+2*a*b^2*c^2*d*e^2+2*a*b^2*c^2*d^2*e;
-a^2*h+a^2*b^2*c^2*f^2+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+a^2*b^2*c^2*e^2+2*a^2*b^2*c^2*d*e;
-0;
-
Index: ctory/libfac/charset/tests/w4
===================================================================
--- factory/libfac/charset/tests/w4	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,6 +1,0 @@
-31991
-zyxr
-x^2+y^2+z^2-r^2;
-x*y+z^2-1;
-x*y*z-x^2-y^2-z+1;
-0;
Index: ctory/libfac/charset/tests/x1
===================================================================
--- factory/libfac/charset/tests/x1	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,6 +1,0 @@
-31991
-abcxyz
-a*(x+y+z)-(x-y-z);
-b*(x+z)-(x+y-z);
-c*(x-y+z)-(x+y);
-0;
Index: ctory/libfac/charset/tests/x2
===================================================================
--- factory/libfac/charset/tests/x2	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,23 +1,0 @@
-31991
-abcdefghjklmnopqr
-d*k;
-e*g+d*j+c*k+l;
-b*h;
-e*l;
-b*f+b*g+a*h+d*h+b*k+h+o;
-a*f+d*f+a*g+d*g+c*h+e*h+b*j+a*k+d*k+b*l+f+g+k+m+n+q;
-c*f+e*f+c*g+e*g+a*j+d*j+c*k+e*k+a*l+d*l+j+l+p+r-1;
-c*j+e*j+c*l+e*l;
-e*j+c*l+2*e*l;
-e*f+e*g+d*j+c*k+2*e*k+a*l+2*d*l+l+r;
-d*f+d*g+e*h+a*k+2*d*k+b*l+k+q;
-d*h+b*k;
-e*k+d*l;
-2*c*j+e*j+c*l;
-c*f+2*c*g+e*g+a*j+d*j+c*k+2*j+l+p;
-a*g+d*g+c*h+b*j+f+2*g+k+n;
-b*g+h;
-e*j+c*l;
-d*g+k;
-0;
-
Index: ctory/libfac/charset/tests/x3
===================================================================
--- factory/libfac/charset/tests/x3	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,13 +1,0 @@
-31991
-rstuvwxyz
-s*u+r*v;
-t*u+r*w;
-t*v+s*w;
-s*x+r*y;
-t*x+r*z;
-t*y+s*z;
-v*x+u*y;
-w*x+u*z;
-w*y+v*z;
-0;
-
Index: ctory/libfac/charset/tests/x4
===================================================================
--- factory/libfac/charset/tests/x4	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,36 +1,0 @@
-31991
-abcdef
-a*d*e*f+3/2*b*e^2*f-1/2*c*e*f^2;
-    a*d^2*f+5/4*b*d*e*f+1/4*c*d*f^2;
-    a*d^2*e+3/4*b*d*e^2+7/4*c*d*e*f;
-    a*c*d*e+3/2*b*c*e^2-1/2*c^2*e*f;
-    a*c*d^2+5/4*b*c*d*e+1/4*c^2*d*f;
-    a*b*d*f+3/2*b^2*e*f-1/2*b*c*f^2;
-    a*b*d*e+3/4*b^2*e^2-a*c*d*f+1/2*b*c*e*f-1/4*c^2*f^2;
-    a*b*d^2+3/4*b^2*d*e+7/4*b*c*d*f;
-    a*b*c*d+3/2*b^2*c*e-1/2*b*c^2*f;
-    a^2*d*f+5/4*a*b*e*f+1/4*a*c*f^2;
-    a^2*d*e+3/4*a*b*e^2+7/4*a*c*e*f;
-    a^2*d^2-9/16*b^2*e^2+2*a*c*d*f-9/8*b*c*e*f+7/16*c^2*f^2;
-    a^2*c*d+5/4*a*b*c*e+1/4*a*c^2*f;
-    a^2*b*d+3/4*a*b^2*e+7/4*a*b*c*f;
-    b*c^3*d+1/4*c*d^3*e;
-    b^2*c^2*e-1/3*b*c^3*f+2/3*c*d^2*e*f;
-    b^2*c^2*d-1/2*a*d^4-3/8*b*d^3*e-1/8*c*d^3*f;
-    b^3*c*e-1/3*b^2*c^2*f+2/3*b*d^2*e*f;
-    b^3*c*d+3/4*b*d^3*f;
-    a*c^3*e-1/3*c*d*e^3;
-    a*c^3*d-3/4*b*c^3*e-1/2*c*d^2*e^2+1/4*c^4*f;
-    a*b*c^2*f-c*d*e*f^2;
-    a*b*c^2*e-c*d*e^2*f;
-    a*b^2*c*f-b*d*e*f^2;
-    a*b^3*f-3*b*d*f^3;
-    a*b^3*d+3/4*b^4*e-1/4*b^3*c*f-3/2*b*d^2*f^2;
-    a^2*c^2*e-2/3*a*d*e^3-1/2*b*e^4+1/6*c*e^3*f;
-    a^2*b*c*f+3/2*b*e^2*f^2-1/2*c*e*f^3;
-    a^2*b*c*e+3/2*b*e^3*f-1/2*c*e^2*f^2;
-    a^2*b^2*f-2*a*d*f^3+3/2*b*e*f^3-1/2*c*f^4;
-    a^3*c*e+4/3*a*e^3*f;
-    a^3*b*f+4*a*e*f^3;
-    a^4*d+3/4*a^3*b*e+1/4*a^3*c*f-2*a*e^2*f^2;
-0;
Index: ctory/libfac/charset/tests/x5
===================================================================
--- factory/libfac/charset/tests/x5	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,11 +1,0 @@
-32003
-abcdefgh
-h+f+e-(d+a);
-2*f*b+2*e*c-(1+a+2*a^2-2*d*a);
-3*f*b^2+3*e*c^2-(d*(1+3*a^2)-4*a-3*a^2-3*a^3);
-6*e*g*b-(d*(1+3*a+6*a^2)-4*a-6*a^2-6*a^3);
-4*f*b^3+4*e*c^3-(1+a+10*a^2+6*a^3+4*a^4-4*d*(a+a^3));
-8*e*c*g*b-(1+3*a+14*a^2+12*a^3+8*a^4-d*(4*a+4*a^2+8*a^3));
-12*e*g*b^2-(1+a+14*a^2+18*a^3+12*a^4-d*(8*a+12*a^2+12*a^3));
-1+7*a+26*a^2+36*a^3+24*a^4-d*(8*a+24*a^2+24*a^3);
-0;
Index: ctory/libfac/charset/tests/x9
===================================================================
--- factory/libfac/charset/tests/x9	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,6 +1,0 @@
-31991
-xy
-x^2;
-x*y;
-0;
-
Index: ctory/libfac/configure
===================================================================
--- factory/libfac/configure	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,1396 +1,0 @@
-#! /bin/sh
-
-# Guess values for system-dependent variables and create Makefiles.
-# Generated automatically using autoconf version 2.13 
-# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-
-# Defaults:
-ac_help=
-ac_default_prefix=/usr/local
-# Any additions from configure.in:
-ac_help="$ac_help
-  --with-debug    build with debugging options turned on"
-ac_help="$ac_help
-  --with-NOSTREAMIO : do not require iostream include nor library"
-
-# Initialize some variables set by options.
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-build=NONE
-cache_file=./config.cache
-exec_prefix=NONE
-host=NONE
-no_create=
-nonopt=NONE
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-target=NONE
-verbose=
-x_includes=NONE
-x_libraries=NONE
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-# Initialize some other variables.
-subdirs=
-MFLAGS= MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-# Maximum number of lines to put in a shell here document.
-ac_max_here_lines=12
-
-ac_prev=
-for ac_option
-do
-
-  # If the previous option needs an argument, assign it.
-  if test -n "$ac_prev"; then
-    eval "$ac_prev=\$ac_option"
-    ac_prev=
-    continue
-  fi
-
-  case "$ac_option" in
-  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
-  *) ac_optarg= ;;
-  esac
-
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
-  case "$ac_option" in
-
-  -bindir | --bindir | --bindi | --bind | --bin | --bi)
-    ac_prev=bindir ;;
-  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
-    bindir="$ac_optarg" ;;
-
-  -build | --build | --buil | --bui | --bu)
-    ac_prev=build ;;
-  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
-    build="$ac_optarg" ;;
-
-  -cache-file | --cache-file | --cache-fil | --cache-fi \
-  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
-    ac_prev=cache_file ;;
-  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
-  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
-    cache_file="$ac_optarg" ;;
-
-  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
-    ac_prev=datadir ;;
-  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
-  | --da=*)
-    datadir="$ac_optarg" ;;
-
-  -disable-* | --disable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
-    # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
-      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
-    fi
-    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
-    eval "enable_${ac_feature}=no" ;;
-
-  -enable-* | --enable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
-    # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
-      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
-    fi
-    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
-    case "$ac_option" in
-      *=*) ;;
-      *) ac_optarg=yes ;;
-    esac
-    eval "enable_${ac_feature}='$ac_optarg'" ;;
-
-  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
-  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
-  | --exec | --exe | --ex)
-    ac_prev=exec_prefix ;;
-  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
-  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
-  | --exec=* | --exe=* | --ex=*)
-    exec_prefix="$ac_optarg" ;;
-
-  -gas | --gas | --ga | --g)
-    # Obsolete; use --with-gas.
-    with_gas=yes ;;
-
-  -help | --help | --hel | --he)
-    # Omit some internal or obsolete options to make the list less imposing.
-    # This message is too long to be a string in the A/UX 3.1 sh.
-    cat << EOF
-Usage: configure [options] [host]
-Options: [defaults in brackets after descriptions]
-Configuration:
-  --cache-file=FILE       cache test results in FILE
-  --help                  print this message
-  --no-create             do not create output files
-  --quiet, --silent       do not print \`checking...' messages
-  --version               print the version of autoconf that created configure
-Directory and file names:
-  --prefix=PREFIX         install architecture-independent files in PREFIX
-                          [$ac_default_prefix]
-  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-                          [same as prefix]
-  --bindir=DIR            user executables in DIR [EPREFIX/bin]
-  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
-  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
-  --datadir=DIR           read-only architecture-independent data in DIR
-                          [PREFIX/share]
-  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
-  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
-                          [PREFIX/com]
-  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
-  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
-  --includedir=DIR        C header files in DIR [PREFIX/include]
-  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
-  --infodir=DIR           info documentation in DIR [PREFIX/info]
-  --mandir=DIR            man documentation in DIR [PREFIX/man]
-  --srcdir=DIR            find the sources in DIR [configure dir or ..]
-  --program-prefix=PREFIX prepend PREFIX to installed program names
-  --program-suffix=SUFFIX append SUFFIX to installed program names
-  --program-transform-name=PROGRAM
-                          run sed PROGRAM on installed program names
-EOF
-    cat << EOF
-Host type:
-  --build=BUILD           configure for building on BUILD [BUILD=HOST]
-  --host=HOST             configure for HOST [guessed]
-  --target=TARGET         configure for TARGET [TARGET=HOST]
-Features and packages:
-  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --x-includes=DIR        X include files are in DIR
-  --x-libraries=DIR       X library files are in DIR
-EOF
-    if test -n "$ac_help"; then
-      echo "--enable and --with options recognized:$ac_help"
-    fi
-    exit 0 ;;
-
-  -host | --host | --hos | --ho)
-    ac_prev=host ;;
-  -host=* | --host=* | --hos=* | --ho=*)
-    host="$ac_optarg" ;;
-
-  -includedir | --includedir | --includedi | --included | --include \
-  | --includ | --inclu | --incl | --inc)
-    ac_prev=includedir ;;
-  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
-  | --includ=* | --inclu=* | --incl=* | --inc=*)
-    includedir="$ac_optarg" ;;
-
-  -infodir | --infodir | --infodi | --infod | --info | --inf)
-    ac_prev=infodir ;;
-  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
-    infodir="$ac_optarg" ;;
-
-  -libdir | --libdir | --libdi | --libd)
-    ac_prev=libdir ;;
-  -libdir=* | --libdir=* | --libdi=* | --libd=*)
-    libdir="$ac_optarg" ;;
-
-  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
-  | --libexe | --libex | --libe)
-    ac_prev=libexecdir ;;
-  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
-  | --libexe=* | --libex=* | --libe=*)
-    libexecdir="$ac_optarg" ;;
-
-  -localstatedir | --localstatedir | --localstatedi | --localstated \
-  | --localstate | --localstat | --localsta | --localst \
-  | --locals | --local | --loca | --loc | --lo)
-    ac_prev=localstatedir ;;
-  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
-  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
-  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
-    localstatedir="$ac_optarg" ;;
-
-  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
-    ac_prev=mandir ;;
-  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
-    mandir="$ac_optarg" ;;
-
-  -nfp | --nfp | --nf)
-    # Obsolete; use --without-fp.
-    with_fp=no ;;
-
-  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c)
-    no_create=yes ;;
-
-  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
-  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
-    no_recursion=yes ;;
-
-  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
-  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
-  | --oldin | --oldi | --old | --ol | --o)
-    ac_prev=oldincludedir ;;
-  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
-  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
-  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
-    oldincludedir="$ac_optarg" ;;
-
-  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
-    ac_prev=prefix ;;
-  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
-    prefix="$ac_optarg" ;;
-
-  -program-prefix | --program-prefix | --program-prefi | --program-pref \
-  | --program-pre | --program-pr | --program-p)
-    ac_prev=program_prefix ;;
-  -program-prefix=* | --program-prefix=* | --program-prefi=* \
-  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
-    program_prefix="$ac_optarg" ;;
-
-  -program-suffix | --program-suffix | --program-suffi | --program-suff \
-  | --program-suf | --program-su | --program-s)
-    ac_prev=program_suffix ;;
-  -program-suffix=* | --program-suffix=* | --program-suffi=* \
-  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
-    program_suffix="$ac_optarg" ;;
-
-  -program-transform-name | --program-transform-name \
-  | --program-transform-nam | --program-transform-na \
-  | --program-transform-n | --program-transform- \
-  | --program-transform | --program-transfor \
-  | --program-transfo | --program-transf \
-  | --program-trans | --program-tran \
-  | --progr-tra | --program-tr | --program-t)
-    ac_prev=program_transform_name ;;
-  -program-transform-name=* | --program-transform-name=* \
-  | --program-transform-nam=* | --program-transform-na=* \
-  | --program-transform-n=* | --program-transform-=* \
-  | --program-transform=* | --program-transfor=* \
-  | --program-transfo=* | --program-transf=* \
-  | --program-trans=* | --program-tran=* \
-  | --progr-tra=* | --program-tr=* | --program-t=*)
-    program_transform_name="$ac_optarg" ;;
-
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil)
-    silent=yes ;;
-
-  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
-    ac_prev=sbindir ;;
-  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
-  | --sbi=* | --sb=*)
-    sbindir="$ac_optarg" ;;
-
-  -sharedstatedir | --sharedstatedir | --sharedstatedi \
-  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
-  | --sharedst | --shareds | --shared | --share | --shar \
-  | --sha | --sh)
-    ac_prev=sharedstatedir ;;
-  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
-  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
-  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
-  | --sha=* | --sh=*)
-    sharedstatedir="$ac_optarg" ;;
-
-  -site | --site | --sit)
-    ac_prev=site ;;
-  -site=* | --site=* | --sit=*)
-    site="$ac_optarg" ;;
-
-  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
-    ac_prev=srcdir ;;
-  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
-    srcdir="$ac_optarg" ;;
-
-  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
-  | --syscon | --sysco | --sysc | --sys | --sy)
-    ac_prev=sysconfdir ;;
-  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
-  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
-    sysconfdir="$ac_optarg" ;;
-
-  -target | --target | --targe | --targ | --tar | --ta | --t)
-    ac_prev=target ;;
-  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
-    target="$ac_optarg" ;;
-
-  -v | -verbose | --verbose | --verbos | --verbo | --verb)
-    verbose=yes ;;
-
-  -version | --version | --versio | --versi | --vers)
-    echo "configure generated by autoconf version 2.13"
-    exit 0 ;;
-
-  -with-* | --with-*)
-    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
-    # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
-      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
-    fi
-    ac_package=`echo $ac_package| sed 's/-/_/g'`
-    case "$ac_option" in
-      *=*) ;;
-      *) ac_optarg=yes ;;
-    esac
-    eval "with_${ac_package}='$ac_optarg'" ;;
-
-  -without-* | --without-*)
-    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
-    # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
-      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
-    fi
-    ac_package=`echo $ac_package| sed 's/-/_/g'`
-    eval "with_${ac_package}=no" ;;
-
-  --x)
-    # Obsolete; use --with-x.
-    with_x=yes ;;
-
-  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
-  | --x-incl | --x-inc | --x-in | --x-i)
-    ac_prev=x_includes ;;
-  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
-  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
-    x_includes="$ac_optarg" ;;
-
-  -x-libraries | --x-libraries | --x-librarie | --x-librari \
-  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
-    ac_prev=x_libraries ;;
-  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
-  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
-    x_libraries="$ac_optarg" ;;
-
-  -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
-    ;;
-
-  *)
-    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
-      echo "configure: warning: $ac_option: invalid host type" 1>&2
-    fi
-    if test "x$nonopt" != xNONE; then
-      { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
-    fi
-    nonopt="$ac_option"
-    ;;
-
-  esac
-done
-
-if test -n "$ac_prev"; then
-  { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
-fi
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-# File descriptor usage:
-# 0 standard input
-# 1 file creation
-# 2 errors and warnings
-# 3 some systems may open it to /dev/tty
-# 4 used on the Kubota Titan
-# 6 checking for... messages and results
-# 5 compiler messages saved in config.log
-if test "$silent" = yes; then
-  exec 6>/dev/null
-else
-  exec 6>&1
-fi
-exec 5>./config.log
-
-echo "\
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-" 1>&5
-
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Also quote any args containing shell metacharacters.
-ac_configure_args=
-for ac_arg
-do
-  case "$ac_arg" in
-  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c) ;;
-  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
-  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
-  *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
-  ac_configure_args="$ac_configure_args '$ac_arg'" ;;
-  *) ac_configure_args="$ac_configure_args $ac_arg" ;;
-  esac
-done
-
-# NLS nuisances.
-# Only set these to C if already set.  These must not be set unconditionally
-# because not all systems understand e.g. LANG=C (notably SCO).
-# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
-# Non-C LC_CTYPE values break the ctype check.
-if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
-if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo > confdefs.h
-
-# A filename unique to this package, relative to the directory that
-# configure is in, which we can look for to find out if srcdir is correct.
-ac_unique_file=factor.h
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
-  ac_srcdir_defaulted=yes
-  # Try the directory containing this script, then its parent.
-  ac_prog=$0
-  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
-  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
-  srcdir=$ac_confdir
-  if test ! -r $srcdir/$ac_unique_file; then
-    srcdir=..
-  fi
-else
-  ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
-  if test "$ac_srcdir_defaulted" = yes; then
-    { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
-  else
-    { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
-  fi
-fi
-srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
-
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
-  if test "x$prefix" != xNONE; then
-    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
-  else
-    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
-  fi
-fi
-for ac_site_file in $CONFIG_SITE; do
-  if test -r "$ac_site_file"; then
-    echo "loading site script $ac_site_file"
-    . "$ac_site_file"
-  fi
-done
-
-if test -r "$cache_file"; then
-  echo "loading cache $cache_file"
-  . $cache_file
-else
-  echo "creating cache $cache_file"
-  > $cache_file
-fi
-
-ac_ext=c
-# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cc_cross
-
-ac_exeext=
-ac_objext=o
-if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
-  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
-  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
-    ac_n= ac_c='
-' ac_t='	'
-  else
-    ac_n=-n ac_c= ac_t=
-  fi
-else
-  ac_n= ac_c='\c' ac_t=
-fi
-
-
-
-
-libfac_name="\"Factorization and characteristic sets library\""
-
-libfac_version="3.1.3"
-cat >> confdefs.h <<EOF
-#define LIBFAC_VERSION "$libfac_version"
-EOF
-
-
-libfac_date="\"March 2011\""
-cat >> confdefs.h <<EOF
-#define LIBFAC_DATE $libfac_date
-EOF
-
-
-libfac_author="\"M. Messollen\""
-
-
-
-libfac="libfac"
-
-libfac_g="libfac-g"
-
-libsingfac="libsingfac"
-
-libsingfac_g="libsingfac-g"
-
-factorH="factor.h"
-
-
-
-# Check whether --with-debug or --without-debug was given.
-if test "${with_debug+set}" = set; then
-  withval="$with_debug"
-  :
-fi
-
-
-targetname="libsingfac"
-
-# Check whether --with-NOSTREAMIO or --without-NOSTREAMIO was given.
-if test "${with_NOSTREAMIO+set}" = set; then
-  withval="$with_NOSTREAMIO"
-  :
-fi
-
-
-if test "$with_NOSTREAMIO" = yes; then
-  cat >> confdefs.h <<\EOF
-#define NOSTREAMIO 1
-EOF
-
-fi
-
-if (test "x${prefix} != xNONE && test "${prefix} != "/usr/local") || \
-  test "${ac_default_prefix}" != "/usr/local" || \
-  test "${includedir}" != '${prefix}/include'; then
-  CPPFLAGS="-I${includedir} ${CPPFLAGS}"
-fi
-CPPFLAGS="-I./factor ${CPPFLAGS}"
-
-if (test "x${prefix} != xNONE && test "${prefix} != "/usr/local") || \
-  test "${ac_default_prefix}" != "/usr/local" || \
-  test "${libdir}" != '${prefix}/lib'; then
-  LDFLAGS="-L${libdir} ${LDFLAGS}"
-fi
-LDFLAGS="-L. ${LDFLAGS}"
-
-if test "${CXXFLAGS+set}" != set; then
-  ac_cxxflags_set=no
-  if test "$with_debug" = yes; then
-    CXXFLAGS="-g"
-  else
-    CXXFLAGS="-O"
-    cat >> confdefs.h <<\EOF
-#define NDEBUG 1
-EOF
-
-  fi
-fi
-
-ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cxx_cross
-
-for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
-do
-# Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:668: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$CXX"; then
-  ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_CXX="$ac_prog"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-fi
-fi
-CXX="$ac_cv_prog_CXX"
-if test -n "$CXX"; then
-  echo "$ac_t""$CXX" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-test -n "$CXX" && break
-done
-test -n "$CXX" || CXX="gcc"
-
-
-echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:700: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
-
-ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cxx_cross
-
-cat > conftest.$ac_ext << EOF
-
-#line 711 "configure"
-#include "confdefs.h"
-
-int main(){return(0);}
-EOF
-if { (eval echo configure:716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  ac_cv_prog_cxx_works=yes
-  # If we can't run a trivial program, we are probably using a cross compiler.
-  if (./conftest; exit) 2>/dev/null; then
-    ac_cv_prog_cxx_cross=no
-  else
-    ac_cv_prog_cxx_cross=yes
-  fi
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  ac_cv_prog_cxx_works=no
-fi
-rm -fr conftest*
-ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cxx_cross
-
-echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
-if test $ac_cv_prog_cxx_works = no; then
-  { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
-fi
-echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:742: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
-echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
-cross_compiling=$ac_cv_prog_cxx_cross
-
-echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
-echo "configure:747: checking whether we are using GNU C++" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.C <<EOF
-#ifdef __GNUC__
-  yes;
-#endif
-EOF
-if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:756: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
-  ac_cv_prog_gxx=yes
-else
-  ac_cv_prog_gxx=no
-fi
-fi
-
-echo "$ac_t""$ac_cv_prog_gxx" 1>&6
-
-if test $ac_cv_prog_gxx = yes; then
-  GXX=yes
-else
-  GXX=
-fi
-
-ac_test_CXXFLAGS="${CXXFLAGS+set}"
-ac_save_CXXFLAGS="$CXXFLAGS"
-CXXFLAGS=
-echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
-echo "configure:775: checking whether ${CXX-g++} accepts -g" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  echo 'void f(){}' > conftest.cc
-if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
-  ac_cv_prog_cxx_g=yes
-else
-  ac_cv_prog_cxx_g=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS="$ac_save_CXXFLAGS"
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi
-
-echo $ac_n "checking how to run the C++ preprocessor""... $ac_c" 1>&6
-echo "configure:807: checking how to run the C++ preprocessor" >&5
-if test -z "$CXXCPP"; then
-if eval "test \"`echo '$''{'ac_cv_prog_CXXCPP'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cxx_cross
-  CXXCPP="${CXX-g++} -E"
-  cat > conftest.$ac_ext <<EOF
-#line 820 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:825: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
-  :
-else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  CXXCPP=/lib/cpp
-fi
-rm -f conftest*
-  ac_cv_prog_CXXCPP="$CXXCPP"
-ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cxx_cross
-fi
-fi
-CXXCPP="$ac_cv_prog_CXXCPP"
-echo "$ac_t""$CXXCPP" 1>&6
-
-
-echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:851: checking whether ${MAKE-make} sets \${MAKE}" >&5
-set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
-if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftestmake <<\EOF
-all:
-	@echo 'ac_maketemp="${MAKE}"'
-EOF
-# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
-if test -n "$ac_maketemp"; then
-  eval ac_cv_prog_make_${ac_make}_set=yes
-else
-  eval ac_cv_prog_make_${ac_make}_set=no
-fi
-rm -f conftestmake
-fi
-if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  SET_MAKE=
-else
-  echo "$ac_t""no" 1>&6
-  SET_MAKE="MAKE=${MAKE-make}"
-fi
-
-# Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:880: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_RANLIB="ranlib"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-  test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
-fi
-fi
-RANLIB="$ac_cv_prog_RANLIB"
-if test -n "$RANLIB"; then
-  echo "$ac_t""$RANLIB" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-# Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
-echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:910: checking for $ac_word" >&5
-if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  if test -n "$AR"; then
-  ac_cv_prog_AR="$AR" # Let the user override the test.
-else
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
-  ac_dummy="$PATH"
-  for ac_dir in $ac_dummy; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
-      ac_cv_prog_AR="ar"
-      break
-    fi
-  done
-  IFS="$ac_save_ifs"
-fi
-fi
-AR="$ac_cv_prog_AR"
-if test -n "$AR"; then
-  echo "$ac_t""$AR" 1>&6
-else
-  echo "$ac_t""no" 1>&6
-fi
-
-if test -z "$AR"; then
-  { echo "configure: error: Need ar" 1>&2; exit 1; }
-fi
-
-
-ac_safe=`echo "factory.h" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for factory.h""... $ac_c" 1>&6
-echo "configure:943: checking for factory.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 948 "configure"
-#include "confdefs.h"
-#include <factory.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:953: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
-else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-  :
-else
-  echo "$ac_t""no" 1>&6
-echo "configure: warning: factory.h not found! Install factory before building libfac!" 1>&2
-fi
-
-
-
-
-if test x${GXX} = xyes; then
-
-  if test "$ac_cxxflags_set" = no; then
-    if test "$with_debug" = yes; then
-       CXXFLAGS="-O -g"
-    else
-       CXXFLAGS="-O3 "
-    fi
-# check whether CXX accepts -fno-rtti
-
-ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cxx_cross
-
-echo $ac_n "checking whether gcc accepts -fno-rtti""... $ac_c" 1>&6
-echo "configure:996: checking whether gcc accepts -fno-rtti" >&5
-tmp_flags=${CXXFLAGS}
-CXXFLAGS="${CXXFLAGS} -fno-rtti"
-if eval "test \"`echo '$''{'ac_cv_cxx_have_rtti'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 1003 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:1010: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
-  rm -rf conftest*
-  ac_cv_cxx_have_rtti=yes
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_cv_cxx_have_rtti=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""${ac_cv_cxx_have_rtti}" 1>&6
-CXXFLAGS=$tmp_flags
-if test "${ac_cv_cxx_have_rtti}" = yes; then
-CXXFLAGS="$CXXFLAGS -fno-rtti"
-fi
-
-echo $ac_n "checking whether gcc accepts -fno-exceptions""... $ac_c" 1>&6
-echo "configure:1030: checking whether gcc accepts -fno-exceptions" >&5
-tmp_flags=${CXXFLAGS}
-CXXFLAGS="${CXXFLAGS} -fno-exceptions"
-if eval "test \"`echo '$''{'ac_cv_cxx_have_exceptions'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 1037 "configure"
-#include "confdefs.h"
-
-int main() {
-
-; return 0; }
-EOF
-if { (eval echo configure:1044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
-  rm -rf conftest*
-  ac_cv_cxx_have_exceptions=yes
-else
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  ac_cv_cxx_have_exceptions=no
-fi
-rm -f conftest*
-
-fi
-
-echo "$ac_t""${ac_cv_cxx_have_exceptions}" 1>&6
-CXXFLAGS=$tmp_flags
-if test "${ac_cv_cxx_have_exceptions}" = yes; then
-CXXFLAGS="$CXXFLAGS -fno-exceptions"
-fi
-
-
-ac_ext=C
-# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
-ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
-cross_compiling=$ac_cv_prog_cxx_cross
-
-
-  fi
-  CXXTEMPLFLAGS="-fno-implicit-templates"
-
-
-else
-  CXXTEMPFLAGS=""
-fi
-
-
-trap '' 1 2 15
-cat > confcache <<\EOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs.  It is not useful on other systems.
-# If it contains results you don't want to keep, you may remove or edit it.
-#
-# By default, configure uses ./config.cache as the cache file,
-# creating it if it does not exist already.  You can give configure
-# the --cache-file=FILE option to use a different cache file; that is
-# what configure does when it calls configure scripts in
-# subdirectories, so they share the cache.
-# Giving --cache-file=/dev/null disables caching, for debugging configure.
-# config.status only pays attention to the cache file if you give it the
-# --recheck option to rerun configure.
-#
-EOF
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(set) 2>&1 |
-  case `(ac_space=' '; set | grep ac_space) 2>&1` in
-  *ac_space=\ *)
-    # `set' does not quote correctly, so add quotes (double-quote substitution
-    # turns \\\\ into \\, and sed turns \\ into \).
-    sed -n \
-      -e "s/'/'\\\\''/g" \
-      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
-    ;;
-  *)
-    # `set' quotes correctly as required by POSIX, so do not add quotes.
-    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
-    ;;
-  esac >> confcache
-if cmp -s $cache_file confcache; then
-  :
-else
-  if test -w $cache_file; then
-    echo "updating cache $cache_file"
-    cat confcache > $cache_file
-  else
-    echo "not updating unwritable cache $cache_file"
-  fi
-fi
-rm -f confcache
-
-trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Any assignment to VPATH causes Sun make to only execute
-# the first set of double-colon rules, so remove it if not needed.
-# If there is a colon in the path, we need to keep it.
-if test "x$srcdir" = x.; then
-  ac_vpsub='/^[ 	]*VPATH[ 	]*=[^:]*$/d'
-fi
-
-trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
-
-DEFS=-DHAVE_CONFIG_H
-
-# Without the "./", some shells look in PATH for config.status.
-: ${CONFIG_STATUS=./config.status}
-
-echo creating $CONFIG_STATUS
-rm -f $CONFIG_STATUS
-cat > $CONFIG_STATUS <<EOF
-#! /bin/sh
-# Generated automatically by configure.
-# Run this file to recreate the current configuration.
-# This directory was configured as follows,
-# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
-#
-# $0 $ac_configure_args
-#
-# Compiler output produced by configure, useful for debugging
-# configure, is in ./config.log if it exists.
-
-ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
-for ac_option
-do
-  case "\$ac_option" in
-  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
-    exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-  -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
-    echo "$CONFIG_STATUS generated by autoconf version 2.13"
-    exit 0 ;;
-  -help | --help | --hel | --he | --h)
-    echo "\$ac_cs_usage"; exit 0 ;;
-  *) echo "\$ac_cs_usage"; exit 1 ;;
-  esac
-done
-
-ac_given_srcdir=$srcdir
-
-trap 'rm -fr `echo "Makefile factor/version.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-# Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
-$ac_vpsub
-$extrasub
-s%@SHELL@%$SHELL%g
-s%@CFLAGS@%$CFLAGS%g
-s%@CPPFLAGS@%$CPPFLAGS%g
-s%@CXXFLAGS@%$CXXFLAGS%g
-s%@FFLAGS@%$FFLAGS%g
-s%@DEFS@%$DEFS%g
-s%@LDFLAGS@%$LDFLAGS%g
-s%@LIBS@%$LIBS%g
-s%@exec_prefix@%$exec_prefix%g
-s%@prefix@%$prefix%g
-s%@program_transform_name@%$program_transform_name%g
-s%@bindir@%$bindir%g
-s%@sbindir@%$sbindir%g
-s%@libexecdir@%$libexecdir%g
-s%@datadir@%$datadir%g
-s%@sysconfdir@%$sysconfdir%g
-s%@sharedstatedir@%$sharedstatedir%g
-s%@localstatedir@%$localstatedir%g
-s%@libdir@%$libdir%g
-s%@includedir@%$includedir%g
-s%@oldincludedir@%$oldincludedir%g
-s%@infodir@%$infodir%g
-s%@mandir@%$mandir%g
-s%@libfac_name@%$libfac_name%g
-s%@libfac_version@%$libfac_version%g
-s%@libfac_date@%$libfac_date%g
-s%@libfac_author@%$libfac_author%g
-s%@libfac@%$libfac%g
-s%@libfac_g@%$libfac_g%g
-s%@libsingfac@%$libsingfac%g
-s%@libsingfac_g@%$libsingfac_g%g
-s%@factorH@%$factorH%g
-s%@targetname@%$targetname%g
-s%@CXX@%$CXX%g
-s%@CXXCPP@%$CXXCPP%g
-s%@SET_MAKE@%$SET_MAKE%g
-s%@RANLIB@%$RANLIB%g
-s%@AR@%$AR%g
-s%@CXXTEMPLFLAGS@%$CXXTEMPLFLAGS%g
-
-CEOF
-EOF
-
-cat >> $CONFIG_STATUS <<\EOF
-
-# Split the substitutions into bite-sized pieces for seds with
-# small command number limits, like on Digital OSF/1 and HP-UX.
-ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
-ac_file=1 # Number of current file.
-ac_beg=1 # First line for current file.
-ac_end=$ac_max_sed_cmds # Line after last line for current file.
-ac_more_lines=:
-ac_sed_cmds=""
-while $ac_more_lines; do
-  if test $ac_beg -gt 1; then
-    sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
-  else
-    sed "${ac_end}q" conftest.subs > conftest.s$ac_file
-  fi
-  if test ! -s conftest.s$ac_file; then
-    ac_more_lines=false
-    rm -f conftest.s$ac_file
-  else
-    if test -z "$ac_sed_cmds"; then
-      ac_sed_cmds="sed -f conftest.s$ac_file"
-    else
-      ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
-    fi
-    ac_file=`expr $ac_file + 1`
-    ac_beg=$ac_end
-    ac_end=`expr $ac_end + $ac_max_sed_cmds`
-  fi
-done
-if test -z "$ac_sed_cmds"; then
-  ac_sed_cmds=cat
-fi
-EOF
-
-cat >> $CONFIG_STATUS <<EOF
-
-CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
-  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case "$ac_file" in
-  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
-       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
-  *) ac_file_in="${ac_file}.in" ;;
-  esac
-
-  # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
-
-  # Remove last slash and all that follows it.  Not all systems have dirname.
-  ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
-  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
-    # The file is in a subdirectory.
-    test ! -d "$ac_dir" && mkdir "$ac_dir"
-    ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
-    # A "../" for each directory in $ac_dir_suffix.
-    ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
-  else
-    ac_dir_suffix= ac_dots=
-  fi
-
-  case "$ac_given_srcdir" in
-  .)  srcdir=.
-      if test -z "$ac_dots"; then top_srcdir=.
-      else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
-  /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
-  *) # Relative path.
-    srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
-    top_srcdir="$ac_dots$ac_given_srcdir" ;;
-  esac
-
-
-  echo creating "$ac_file"
-  rm -f "$ac_file"
-  configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
-  case "$ac_file" in
-  *Makefile*) ac_comsub="1i\\
-# $configure_input" ;;
-  *) ac_comsub= ;;
-  esac
-
-  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
-  sed -e "$ac_comsub
-s%@configure_input@%$configure_input%g
-s%@srcdir@%$srcdir%g
-s%@top_srcdir@%$top_srcdir%g
-" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
-fi; done
-rm -f conftest.s*
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s%^\([ 	]*\)#\([ 	]*define[ 	][ 	]*\)'
-ac_dB='\([ 	][ 	]*\)[^ 	]*%\1#\2'
-ac_dC='\3'
-ac_dD='%g'
-# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
-ac_uA='s%^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
-ac_uB='\([ 	]\)%\1#\2define\3'
-ac_uC=' '
-ac_uD='\4%g'
-# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_eA='s%^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
-ac_eB='$%\1#\2define\3'
-ac_eC=' '
-ac_eD='%g'
-
-if test "${CONFIG_HEADERS+set}" != set; then
-EOF
-cat >> $CONFIG_STATUS <<EOF
-  CONFIG_HEADERS="factor/version.h"
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-fi
-for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
-  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case "$ac_file" in
-  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
-       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
-  *) ac_file_in="${ac_file}.in" ;;
-  esac
-
-  echo creating $ac_file
-
-  rm -f conftest.frag conftest.in conftest.out
-  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
-  cat $ac_file_inputs > conftest.in
-
-EOF
-
-# Transform confdefs.h into a sed script conftest.vals that substitutes
-# the proper values into config.h.in to produce config.h.  And first:
-# Protect against being on the right side of a sed subst in config.status.
-# Protect against being in an unquoted here document in config.status.
-rm -f conftest.vals
-cat > conftest.hdr <<\EOF
-s/[\\&%]/\\&/g
-s%[\\$`]%\\&%g
-s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
-s%ac_d%ac_u%gp
-s%ac_u%ac_e%gp
-EOF
-sed -n -f conftest.hdr confdefs.h > conftest.vals
-rm -f conftest.hdr
-
-# This sed command replaces #undef with comments.  This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >> conftest.vals <<\EOF
-s%^[ 	]*#[ 	]*undef[ 	][ 	]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
-EOF
-
-# Break up conftest.vals because some shells have a limit on
-# the size of here documents, and old seds have small limits too.
-
-rm -f conftest.tail
-while :
-do
-  ac_lines=`grep -c . conftest.vals`
-  # grep -c gives empty output for an empty file on some AIX systems.
-  if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
-  # Write a limited-size here document to conftest.frag.
-  echo '  cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
-  sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
-  echo 'CEOF
-  sed -f conftest.frag conftest.in > conftest.out
-  rm -f conftest.in
-  mv conftest.out conftest.in
-' >> $CONFIG_STATUS
-  sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
-  rm -f conftest.vals
-  mv conftest.tail conftest.vals
-done
-rm -f conftest.vals
-
-cat >> $CONFIG_STATUS <<\EOF
-  rm -f conftest.frag conftest.h
-  echo "/* $ac_file.  Generated automatically by configure.  */" > conftest.h
-  cat conftest.in >> conftest.h
-  rm -f conftest.in
-  if cmp -s $ac_file conftest.h 2>/dev/null; then
-    echo "$ac_file is unchanged"
-    rm -f conftest.h
-  else
-    # Remove last slash and all that follows it.  Not all systems have dirname.
-      ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
-      if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
-      # The file is in a subdirectory.
-      test ! -d "$ac_dir" && mkdir "$ac_dir"
-    fi
-    rm -f $ac_file
-    mv conftest.h $ac_file
-  fi
-fi; done
-
-EOF
-cat >> $CONFIG_STATUS <<EOF
-
-EOF
-cat >> $CONFIG_STATUS <<\EOF
-
-exit 0
-EOF
-chmod +x $CONFIG_STATUS
-rm -fr confdefs* $ac_clean_files
-test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
Index: ctory/libfac/configure.in
===================================================================
--- factory/libfac/configure.in	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,168 +1,0 @@
-dnl
-dnl Process this file with autoconf to produce a configure script.
-dnl
-
-dnl
-dnl Initialisation
-dnl
-AC_INIT(factor.h)
-AC_CONFIG_HEADER(factor/version.h)
-
-dnl
-dnl Set up variables for Makefile.in
-dnl
-dnl Change libfac variables here:
-libfac_name="\"Factorization and characteristic sets library\""
-AC_SUBST(libfac_name)
-libfac_version="3.1.3"
-AC_DEFINE_UNQUOTED(LIBFAC_VERSION,"$libfac_version")
-AC_SUBST(libfac_version)
-libfac_date="\"March 2011\""
-AC_DEFINE_UNQUOTED(LIBFAC_DATE,$libfac_date)
-AC_SUBST(libfac_date)
-libfac_author="\"M. Messollen\""
-AC_SUBST(libfac_author)
-
-AC_SUBST(libfac)
-libfac="libfac"
-AC_SUBST(libfac_g)
-libfac_g="libfac-g"
-AC_SUBST(libsingfac)
-libsingfac="libsingfac"
-AC_SUBST(libsingfac_g)
-libsingfac_g="libsingfac-g"
-AC_SUBST(factorH)
-factorH="factor.h"
-AC_SUBST(targetname)
-
-dnl
-dnl Parse options
-dnl
-
-AC_ARG_WITH(
-  debug,
-  [  --with-debug    build with debugging options turned on])
-
-targetname="libsingfac"
-
-AC_ARG_WITH(
-  NOSTREAMIO,
-  [  --with-NOSTREAMIO : do not require iostream include nor library])
-
-if test "$with_NOSTREAMIO" = yes; then
-  AC_DEFINE(NOSTREAMIO)
-fi
-
-dnl
-dnl add to -I and -L, if necessary
-dnl
-if (test "x${prefix} != xNONE && test "${prefix} != "/usr/local") || \
-  test "${ac_default_prefix}" != "/usr/local" || \
-  test "${includedir}" != '${prefix}/include'; then
-  CPPFLAGS="-I${includedir} ${CPPFLAGS}"
-fi
-CPPFLAGS="-I./factor ${CPPFLAGS}"
-
-if (test "x${prefix} != xNONE && test "${prefix} != "/usr/local") || \
-  test "${ac_default_prefix}" != "/usr/local" || \
-  test "${libdir}" != '${prefix}/lib'; then
-  LDFLAGS="-L${libdir} ${LDFLAGS}"
-fi
-LDFLAGS="-L. ${LDFLAGS}"
-
-if test "${CXXFLAGS+set}" != set; then
-  ac_cxxflags_set=no
-  if test "$with_debug" = yes; then
-    CXXFLAGS="-g"
-  else
-    CXXFLAGS="-O"
-    AC_DEFINE(NDEBUG)
-  fi
-fi
-
-dnl
-dnl Checks for programs.
-dnl
-AC_LANG_CPLUSPLUS
-AC_PROG_CXX
-AC_REQUIRE_CPP
-AC_PROG_MAKE_SET
-AC_PROG_RANLIB
-AC_CHECK_PROG(AR,ar,ar)
-if test -z "$AR"; then
-  AC_MSG_ERROR(Need ar)
-fi
-
-dnl
-dnl programs for installation
-dnl
-dnl ac_save_path=${PATH}
-dnl PATH="$PATH:.."
-dnl AC_PROG_INSTALL
-dnl AC_PATH_PROG(MKINSTALLDIRS, mkinstalldirs, -mkdir -p)
-dnl PATH="$ac_save_path"
-
-dnl
-dnl Checks for header files.
-dnl
-AC_CHECK_HEADER(factory.h,,AC_MSG_WARN(factory.h not found! Install factory before building libfac!))
-
-dnl
-dnl Checks for libraries.
-dnl
-
-dnl
-dnl Checks for typedefs, structures, and compiler characteristics.
-dnl
-
-dnl
-dnl Last, but not least, customize CFLAGS
-dnl
-if test x${GXX} = xyes; then
-
-  if test "$ac_cxxflags_set" = no; then
-    if test "$with_debug" = yes; then
-       CXXFLAGS="-O -g"
-    else
-       CXXFLAGS="-O3 "
-    fi
-# check whether CXX accepts -fno-rtti
-AC_LANG_SAVE
-AC_LANG_CPLUSPLUS
-AC_MSG_CHECKING(whether gcc accepts -fno-rtti)
-tmp_flags=${CXXFLAGS}
-CXXFLAGS="${CXXFLAGS} -fno-rtti"
-AC_CACHE_VAL(ac_cv_cxx_have_rtti,
-AC_TRY_COMPILE(,,ac_cv_cxx_have_rtti=yes,ac_cv_cxx_have_rtti=no)
-)
-AC_MSG_RESULT(${ac_cv_cxx_have_rtti})
-CXXFLAGS=$tmp_flags
-if test "${ac_cv_cxx_have_rtti}" = yes; then
-CXXFLAGS="$CXXFLAGS -fno-rtti"
-fi
-
-AC_MSG_CHECKING(whether gcc accepts -fno-exceptions)
-tmp_flags=${CXXFLAGS}
-CXXFLAGS="${CXXFLAGS} -fno-exceptions"
-AC_CACHE_VAL(ac_cv_cxx_have_exceptions,
-AC_TRY_LINK(,,ac_cv_cxx_have_exceptions=yes,ac_cv_cxx_have_exceptions=no)
-)
-AC_MSG_RESULT(${ac_cv_cxx_have_exceptions})
-CXXFLAGS=$tmp_flags
-if test "${ac_cv_cxx_have_exceptions}" = yes; then
-CXXFLAGS="$CXXFLAGS -fno-exceptions"
-fi
-
-
-AC_LANG_RESTORE
-
-  fi
-  CXXTEMPLFLAGS="-fno-implicit-templates"
-
-
-else
-  CXXTEMPFLAGS=""
-fi
-AC_SUBST(CXXTEMPLFLAGS)
-
-AC_OUTPUT(Makefile)
Index: ctory/libfac/factor/Factor.cc
===================================================================
--- factory/libfac/factor/Factor.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,1179 +1,0 @@
-///////////////////////////////////////////////////////////////////////////////
-static const char * errmsg = "\nYou found a bug!\nPlease inform singular@mathematik.uni-kl.de\nPlease include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you.";
-///////////////////////////////////////////////////////////////////////////////
-// FACTORY - Includes
-#include <factory.h>
-#ifndef NOSTREAMIO
-#ifdef HAVE_IOSTREAM
-#include <iostream>
-#define CERR std::cerr
-#define CIN std::cin
-#elif defined(HAVE_IOSTREAM_H)
-#include <iostream.h>
-#define CERR cerr
-#define CIN cin
-#endif
-#endif
-// Factor - Includes
-#include "tmpl_inst.h"
-#include "SqrFree.h"
-#include "helpstuff.h"
-#include "MVMultiHensel.h"
-#include "Truefactor.h"
-#include "homogfactor.h"
-#include "interrupt.h"
-// some CC's need this:
-#include "Factor.h"
-
-#include "alg_factor.h"
-void out_cf(char *s1,const CanonicalForm &f,char *s2);
-void out_cff(CFFList &L);
-
-
-#ifdef FACTORDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-
-#include <libfac/factor/debug.h>
-#include "timing.h"
-TIMING_DEFINE_PRINT(factorize_time)
-TIMING_DEFINE_PRINT(sqrfree_time)
-TIMING_DEFINE_PRINT(discr_time)
-TIMING_DEFINE_PRINT(evaluate_time)
-TIMING_DEFINE_PRINT(hensel_time)
-TIMING_DEFINE_PRINT(truefactor_time)
-
-/*
-* a wrapper for factorize over algebraic extensions:
-* does a sanity check and, if nec., a conversion
-* before calling factorize(f,alpha)
-* ( in factorize, alpha.level() must be < 0 )
-*/
-CFFList factorize2 ( const CanonicalForm & f,
-                     const Variable & alpha, const CanonicalForm & mipo )
-{
-  if (alpha.level() <0)
-  {
-    return factorize(f,alpha);
-  }
-  else
-  {
-    bool repl=(f.mvar() != alpha);
-    //out_cf("f2 - factor:",f,"\n");
-    //out_cf("f2 - ext:",alpha,"\n");
-    //out_cf("f2 - mipo:",mipo,"\n");
-    Variable X=rootOf(mipo);
-    CanonicalForm F=f;
-    if (repl) F=replacevar(f,alpha,X);
-    //out_cf("call - factor:",F,"\n");
-    //out_cf("call - ext:",X,"\n");
-    //out_cf("call - mipo:",getMipo(X,'A'),"\n");
-    CFFList L=factorize(F,X);
-    CFFListIterator i=L;
-    if (repl)
-    {
-      CFFList Outputlist;
-      for(;i.hasItem(); i++ )
-      {
-        Outputlist.append(CFFactor(
-        replacevar(i.getItem().factor(),X,alpha),
-        i.getItem().exp()));
-      }
-      return Outputlist;
-    }
-    else return L;
-  }
-}
-///////////////////////////////////////////////////////////////
-// Choose a main variable if the user didn`t wish a          //
-// special one. Returns level of main variable.              //
-///////////////////////////////////////////////////////////////
-static int
-choose_main_variable( const CanonicalForm & f, int Mainvar=0){
-  CanonicalForm remlc, newlc;
-  int n= level(f), mainvar= Mainvar;
-
-  if (mainvar != 0) return mainvar ; // We force use of the wished mainvar
-  remlc= LC(f,n); mainvar = n;
-  if ( totaldegree(remlc)==0 ){ remlc=f.genOne() ; }
-  DEBOUTLN(CERR, "remlc= " , remlc);
-  for ( int i=n-1; i>=1; i-- )
-  {
-    newlc= LC(f,i);
-    if ( totaldegree(newlc)==0 ){ newlc=f.genOne() ; }
-    DEBOUTLN(CERR, "newlc= " , newlc);
-    if ( (remlc.isOne()) && (newlc.isOne()) ){ // take care of the degrees
-      if ( degree(f,i) < degree(f,mainvar) ){
-        remlc= newlc;
-        mainvar= i;
-      }
-    }
-    else  if ( (! remlc.isOne() ) && ( newlc.isOne() ) ){
-      remlc= newlc;
-      mainvar= i;
-    }
-  }
-  return mainvar;
-}
-
-///////////////////////////////////////////////////////////////
-// Check if the derivative is nonzero for oldmainvar.        //
-// Returns the level of the choosen main variable.           //
-///////////////////////////////////////////////////////////////
-static int
-necessary_condition( const CanonicalForm & F, int oldmainvar){
-  CanonicalForm g;
-  int n=level(F);
-
-  g= swapvar(F,oldmainvar,n);
-  g= g.deriv();
-  if ( g.isZero() )
-  {
-    for ( int i=n; i>=1; i-- )
-    {
-      g= swapvar(F,i,n);
-      g= g.deriv();
-      if ( ! g.isZero() ) return i;
-    }
-  }
-  return oldmainvar;
-}
-
-///////////////////////////////////////////////////////////////
-// Make F monic. Return monic polynomial.                    //
-///////////////////////////////////////////////////////////////
-static CanonicalForm
-make_monic( const CanonicalForm & F, const CanonicalForm & lt)
-{
-  CanonicalForm intermediatpoly,f;
-  Variable x(level(F));
-
-  if ( degree(lt) == 0 ) f= 1/lt * F ;
-  else
-  {
-    intermediatpoly= power(lt,degree(F)-1);
-    for ( int i=0; i<=degree(F); i++ )
-      if ( ! F[i].isZero())
-        f+= (F[i] * intermediatpoly*power(x,i))/power(lt,i);
-  }
-  return f;
-}
-
-///////////////////////////////////////////////////////////////
-// Decide whether num/denum (num,denum both from the         //
-// FiniteFielddomain)  lies in the RationalDomain.           //
-// If false, return num/denum else return the zero poly from //
-// the FiniteFielddomain.                                    //
-///////////////////////////////////////////////////////////////
-static CanonicalForm
-is_rational( const CanonicalForm & num, const CanonicalForm & denum ){
-  CanonicalForm a, b;
-  int retvalue;
-
-  retvalue= mydivremt(num,denum,a,b);
-  if ( retvalue && b == num.genZero() ) // num/denum from FFdomain
-    return a;
-  else // num/denum is rational
-    return num.genZero();
-}
-
-///////////////////////////////////////////////////////////////
-// lt_is_product returns 1 iff lt is a product, 0 iff lt is  //
-// a sum.                                                    //
-///////////////////////////////////////////////////////////////
-static int
-lt_is_product( const CanonicalForm & lt ){
-  CFList result;
-
-  result= get_Terms(lt);
-  if ( result.length() > 1 ) return 0;
-  else return 1;
-}
-
-///////////////////////////////////////////////////////////////
-// Reverse the make_monic transformation.                    //
-// Return the list of factors.                               //
-///////////////////////////////////////////////////////////////
-static CFFList
-not_monic( const CFFList & TheList, const CanonicalForm & ltt, const CanonicalForm & F, int levelF)
-{
-  CFFList Returnlist,IntermediateList;
-  CFFListIterator i;
-  CanonicalForm intermediate,lt= ltt,savelc;
-  CanonicalForm numerator,denumerator,test,a,b;
-  Variable x(level(F));
-  int test1;
-
-  if ( lt.isOne() ) return TheList; // the poly was already monic
-  if ( TheList.length() <= 1 ) // only one factor to substitute back
-  {
-    if ( totaldegree(lt) == 0 ) // lt is type numeric
-      Returnlist.append( CFFactor(lt*TheList.getFirst().factor(),
-                                  TheList.getFirst().exp()) );
-    else
-    {
-      intermediate = F(x*lt, levelF)/power(lt,degree(F,levelF)-1);
-      Returnlist.append(CFFactor(intermediate,TheList.getFirst().exp()));
-    }
-  }
-  else // more then one factor
-  {
-    IntermediateList= TheList;
-    if ( totaldegree(lt) == 0 ){ // lt is type numeric;(SqrFree-use, see above)
-      Returnlist.append( CFFactor(lt*IntermediateList.getFirst().factor()
-                                  , IntermediateList.getFirst().exp()) );
-      IntermediateList.removeFirst();
-      Returnlist= Union(Returnlist,IntermediateList);
-    }
-    else // lt is a) a product or b) a sum of terms
-    {
-      if ( lt_is_product(lt) ) // case a)
-      {
-        DEBOUTLN(CERR, "lt_is_product: ", lt);
-        savelc= content(lt) ; // can we simplify to savelc= lc(lt); ?
-        while ( getNumVars(savelc) != 0 )
-          savelc= content(savelc);
-        for ( i=TheList; i.hasItem();i++ )
-        {
-          numerator= i.getItem().factor();
-          numerator= numerator(x*lt,levelF); // x <- x*lt
-          denumerator= power(lt,degree(F,levelF)-1); // == lt^(1-degree(F,x)
-          while (numerator.genZero() == is_rational(numerator, denumerator))
-            numerator*= lt;
-          intermediate= is_rational(numerator,denumerator);
-
-          Returnlist.append( CFFactor(lc(content(intermediate))*intermediate/content(intermediate), i.getItem().exp() ) );
-        }
-        // Now we add a test. If product(factors)/F is a multiple of
-        // savelc, we have to add 1/multiplicity to the factors
-        IntermediateList= Returnlist;
-        intermediate= 1;
-        for ( CFFListIterator j=IntermediateList; j.hasItem(); j++)
-          intermediate*= j.getItem().factor();
-        test1= mydivremt( intermediate,F,a,b);
-        if ( test1 && b == intermediate.genZero() ) // Yupp!
-        {
-          IntermediateList.append(CFFactor(1/a,1));
-          Returnlist= IntermediateList;
-        }
-        else { Returnlist= IntermediateList; }
-      }
-      else // case b)
-      {
-        DEBOUTLN(CERR, "lt_is_sum: ", lt);
-        CanonicalForm save_denumerator= 1;
-        for ( i=TheList; i.hasItem(); i++ )
-        {
-          numerator= i.getItem().factor();
-          numerator= numerator(x*lt,levelF); // x <- x*lt
-          denumerator= power(lt,degree(numerator,levelF)); // == lt^(-degree(numerator,x)
-          test= content(numerator,x);
-          test1= mydivremt(denumerator,test,a,b);
-          if ( test1 && b == numerator.genZero() ) // Yupp!
-          {
-            save_denumerator*= a;
-            Returnlist.append(CFFactor(numerator/test ,1));
-          }
-          else
-          {
-            factoryError("libfac: ERROR: not_monic1: case lt is a sum.");
-          }
-        }
-        // Now we add a test if we did the right thing:
-        // save_denumerator should be a multiple of the leading coeff
-        test1= mydivremt(save_denumerator,lt,a,b);
-        if ( test1 && b == save_denumerator.genZero() ) // Yupp!
-          // We have to multiply one of the factors with
-          // the multiplicity of the save_denumerator <-> lc
-          // the following will do what we want
-          Returnlist= myUnion( CFFList(CFFactor(1/a,1)),Returnlist) ;
-        else
-        {
-          factoryError("libfac: ERROR: not_monic2: case lt is a sum.");
-        }
-      }
-    }
-  }
-  DEBOUTLN(CERR,"Returnlist: ", Returnlist);
-  return Returnlist;
-}
-
-///////////////////////////////////////////////////////////////
-// Substitute the (Variable,Value)-Pair(s) from Substitution-//
-// list into the polynomial F. Returns the resulting poly.   //
-///////////////////////////////////////////////////////////////
-static CanonicalForm
-substitutePoly( const CanonicalForm & F, const SFormList & Substitutionlist){
-  CanonicalForm f= F;
-
-  for ( SFormListIterator i=Substitutionlist; i.hasItem(); i++ )
-    f= f(i.getItem().exp(),level(i.getItem().factor()));
-  return f;
-}
-
-///////////////////////////////////////////////////////////////
-// Find specialization values for the poly F. Returns 0 if   //
-// procedure failed, 1 otherwise. On success Substitutionlist//
-// holds (Variable,Value)-pairs. On failure we only have a   //
-// partitial list.                                           //
-///////////////////////////////////////////////////////////////
-//      *** This is the version with extensions ***          //
-///////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////
-// is CF g ok?                                               //
-///////////////////////////////////////////////////////////////
-static int
-various_tests( const CanonicalForm & g, int deg, int vars_left)
-{
-  CFMap m;
-
-  if ( degree(g) == deg ) // degrees match
-    if ( level(compress(g,m)) == (vars_left) ) // exactly one variable less
-      if ( SqrFreeTest(g,1) ) // poly is sqrfree
-        if ( gcd(g,g.deriv()).isOne() ) // Discriminante != 0
-           return 1;
-  return 0;
-}
-
-///////////////////////////////////////////////////////////////
-// specialize one variable over the given field.             //
-///////////////////////////////////////////////////////////////
-// substitutes in poly f of degree deg with former
-// former_nr_of_variables variables the variable nr_of_variable ;
-// this is done in the field of Char getCharacteristic() and
-// Extension given by Extgenerator.
-///////////////////////////////////////////////////////////////
-static int
-specialize_variable( CanonicalForm & f, int deg, SFormList & Substitutionlist, int nr_of_variable,
-                     int former_nr_of_variables, CFGenerator & Extgenerator ){
-  CanonicalForm g;
-  Variable x(nr_of_variable);
-
-  DEBOUTLN(CERR, "specialize_variable: called with: ", f);
-  for ( Extgenerator.reset(); Extgenerator.hasItems(); Extgenerator.next() ){
-    DEBOUTLN(CERR, "  specialize_variable: trying:  ", Extgenerator.item());
-    g= f( Extgenerator.item(), x );
-    DEBOUTLN(CERR, "  specialize_variable: resulting g= ", g);
-    if ( various_tests(g,deg,former_nr_of_variables - nr_of_variable ) ){
-      Substitutionlist.insert(SForm(x,Extgenerator.item())); // append (Var,value) pair
-      f= g;
-      return 1;
-    }
-  }
-  return 0;
-}
-static int
-specialize_agvariable( CanonicalForm & f, int deg, SFormList & Substitutionlist, int nr_of_variable,
-                     int former_nr_of_variables, AlgExtGenerator & Extgenerator ){
-  CanonicalForm g;
-  Variable x(nr_of_variable);
-
-  DEBOUTLN(CERR, "specialize_variable: called with: ", f);
-  for ( Extgenerator.reset(); Extgenerator.hasItems(); Extgenerator.next() ){
-    DEBOUTLN(CERR, "  specialize_variable: trying:  ", Extgenerator.item());
-    g= f( Extgenerator.item(), x );
-    DEBOUTLN(CERR, "  specialize_variable: resulting g= ", g);
-    if ( various_tests(g,deg,former_nr_of_variables - nr_of_variable ) ){
-      Substitutionlist.insert(SForm(x,Extgenerator.item())); // append (Var,value) pair
-      f= g;
-      return 1;
-    }
-  }
-  return 0;
-}
-
-///////////////////////////////////////////////////////////////
-// generate a minpoly of degree degree_of_Extension in the   //
-// field getCharacteristik()^Extension.                      //
-///////////////////////////////////////////////////////////////
-CanonicalForm
-generate_mipo( int degree_of_Extension , const Variable & Extension ){
-  FFRandom gen;
-  if ( degree(Extension) > 0 ) GFRandom gen;
-  else {
-    if ( degree(Extension) == 0 ) FFRandom gen;
-    else
-    {
-      factoryError("libfac: evaluate: Extension not inFF() or inGF() !");
-    }
-  }
-  return find_irreducible( degree_of_Extension, gen, Variable(1) );
-}
-
-///////////////////////////////////////////////////////////////
-// Try to find a specialization for f over the field of char //
-// f.getCharacteristic() and (possible) extension defined by //
-// the variable Extension .                                  //
-// Returns 1 iff specialisation was found, 0 otherwise.      //
-// If 0 is returned there are variables left to substitute.  //
-// We check if Substitutionlist.length() > 0, i.e. we        //
-// previously tried to find specialization values for some   //
-// values. We take them and work with the resulting poly.    //
-///////////////////////////////////////////////////////////////
-static int
-try_specializePoly(const CanonicalForm & f, const Variable & Extension, int deg, SFormList & Substitutionlist, int ii,int j)
-{
-  int ok,i= ii;
-  CanonicalForm ff= f;
-
-  if ( Substitutionlist.length() > 0 ){ // we formerly tried to specialize
-    ff= substitutePoly(f,Substitutionlist); // substitute found values
-    i= Substitutionlist.length() + 1;
-  }
-
-  if ( degree(Extension) > 0 )
-  { // working over Extensions
-    DEBOUTLN(CERR, "try_specializePoly: working over Extensions: ", Extension);
-    if (Extension.level() > 0)
-    {
-    //  AlgExtGenerator g(Extension,minpoly );
-    //  for ( int k=i ; k<j ; k++ ) // try to find specialization for all
-    //  {                           // variables (# = k ) beginning with the
-    //                             // starting value i
-    //    ok= specialize_agvariable( ff, deg, Substitutionlist, k, j, g );
-    //    if ( ! ok ) return 0; // we failed
-    //  }
-      #ifndef NDEBUG
-        //printf("libfac: try_specializePoly: extension level >0\n");
-      #endif
-      return 0; // we failed
-    }
-    else
-    {
-      AlgExtGenerator g(Extension);
-      for ( int k=i ; k<j ; k++ ) // try to find specialization for all
-      {                           // variables (# = k ) beginning with the
-                                 // starting value i
-        ok= specialize_agvariable( ff, deg, Substitutionlist, k, j, g );
-        if ( ! ok ) return 0; // we failed
-      }
-    }
-  }
-  else{ // working over the ground-field
-    FFGenerator g;
-    DEBOUTMSG(CERR, "try_specializePoly: working over the ground-field.");
-    for ( int k=i ; k<j ; k++ ){
-      ok= specialize_variable( ff, deg, Substitutionlist, k, j, g );
-      if ( ! ok ) return 0; // we failed
-    }
-  }
-  return 1;
-}
-
-static int
-specializePoly(const CanonicalForm & f, Variable & Extension, int deg, SFormList & Substitutionlist, int i,int j){
-  Variable minpoly= Extension;
-  int ok,extended= degree(Extension), working_over_extension;
-
-  // Remember if we are working over an extension-field
-  if ( extended >= 2 )    { working_over_extension = 1; }
-  else                    { working_over_extension = 0; extended = 1; }
-  // First try:
-  ok = try_specializePoly(f,minpoly,deg,Substitutionlist,i,j);
-  while ( ! ok ){ // we have to extend!
-    extended+= 1;
-    if ( ! working_over_extension ){
-      minpoly= rootOf(generate_mipo( extended,Extension ));
-      Extension= minpoly;
-      ok= try_specializePoly(f,minpoly,deg,Substitutionlist,i,j);
-    }
-    else
-    {
-      factoryError("libfac: spezializePoly ERROR: Working over given extension-field not yet implemented!");
-      return 0;
-    }
-  }
-  return 1;
-}
-
-
-// This is a procedure to play with: lot's of parameters!
-// returns: 0  iff no success (possibly because Extension isn't great enough
-//          >0 iff g (univariate) splits into n factors;
-// if n>0 BestEvaluationpoint contains the choice of values for the variables
-//
-// tries to find at least maxtries evaluation points
-// if g factored sametries into the same number of poly's the procedure stops
-// if we tried failtries evaluations not found valid, we stop. Perhaps
-// Extension isn't big enough!
-static int
-evaluate( int maxtries, int sametries, int failtries, const CanonicalForm &f , const Variable & Extension, const CanonicalForm &mipo, SFormList & BestEvaluationpoint, CFFList & BestFactorisation ){
-  int minfactors=degree(f),degf=degree(f),n=level(f.mvar())-1;
-  SFormList minEvaluation;
-  CFFList minFactorisation;
-  int samefactors=0, failedfactor=0, tried=0;
-  FFRandom gen;
-  CFFList unilist;
-
-  if ( degree(Extension) >0 ) GFRandom gen;
-  else
-  {
-    if ( degree(Extension) == 0 ) FFRandom gen;
-    else
-    {
-      factoryError("libfac: evaluate: Extension not inFF() or inGF() !");
-    }
-  }
-  REvaluation k(1,n,gen);
-  k.nextpoint();
-  for ( int i=1; i<=maxtries ; i++)
-  {
-    // k.nextpoint();
-    SFormList Substitutionlist;
-    for ( int j=1; j<=n; j++ )
-     Substitutionlist.insert(SForm(Variable(j),k[j]));
-    k.nextpoint();
-    CanonicalForm g=substitutePoly(f,Substitutionlist);
-    if ( various_tests(g, degf,1) )
-    { // found a valid point
-      failedfactor = 0; tried += 1;
-      if ( degree(Extension) == 0   )
-        unilist = factorize(g,1); // poly is sqr-free!
-      else
-      {
-        unilist = factorize2(g,Extension,mipo);
-      }
-      if (unilist.length() <= minfactors )
-      {
-        minfactors=unilist.length();
-        minEvaluation=Substitutionlist;
-        minFactorisation=unilist;
-      }
-      else samefactors +=1;
-
-      if (unilist.length() == 1 ) // wow! we found f is irreducible!
-      {
-        BestEvaluationpoint=minEvaluation;
-        BestFactorisation=minFactorisation;
-        return 1;
-      }
-
-      if ( samefactors >= sametries ) // now we stop ( maybe polynomial *has*
-                                      // minfactors factors? )
-      {
-        BestEvaluationpoint=minEvaluation;
-        BestFactorisation=minFactorisation;
-        return minfactors;
-      }
-
-    }
-    else
-      failedfactor += 1;
-
-    if ( failedfactor >= failtries ) // now we stop ( perhaps Extension isn't
-                                     // big enough )
-    {
-      if ( tried == 0 )
-        return 0;
-      else
-      {
-        BestEvaluationpoint=minEvaluation;
-        BestFactorisation=minFactorisation;
-        return minfactors;
-      }
-    }
-  }
-  BestEvaluationpoint=minEvaluation;
-  BestFactorisation=minFactorisation;
-  return minfactors;
-}
-
-///////////////////////////////////////////////////////////////
-// A factorization routine for a sqrfree polynomial.         //
-// Returns the list of factors.                              //
-///////////////////////////////////////////////////////////////
-CFFList
-Factorized( const CanonicalForm & F, const CanonicalForm & alpha, int Mainvar)
-{
-  CanonicalForm f,lt,ff,ffuni;
-  Variable Extension=alpha.mvar();
-  CFFList Outputlist,UnivariateFactorlist,Outputlist2;
-  SFormList Substitutionlist, Evaluationpoint;
-  CFFactor copy;
-  int mainvar=Mainvar,success,oldmainvar;
-  CFMap m;
-
-  // INTERRUPTHANDLER
-  if ( interrupt_handle() ) return CFFList() ;
-  // INTERRUPTHANDLER
-
-  if (F.inCoeffDomain()) {  return CFFList(CFFactor(F,1)); }
-  if ( F.isUnivariate() ) // could have lost one Variable elsewhere
-  {
-    if ( degree(Extension) == 0 )
-    {
-      TIMING_START(evaluate_time);
-      Outputlist = factorize(F,1); // poly is sqr-free
-      TIMING_END(evaluate_time);
-      return Outputlist;
-    }
-    else
-    {
-      if (Extension.level()<0)
-      DEBOUTLN(CERR, "Univ. Factorization over extension of degree ",
-               degree(getMipo(Extension,'x')) );
-      else
-      DEBOUTLN(CERR, "Univ. Factorization over extension of level ??",
-                Extension.level());
-      TIMING_START(evaluate_time);
-      Outputlist = factorize2(F,Extension,alpha);
-      TIMING_END(evaluate_time);
-      return Outputlist;
-    }
-  }
-
-  if ( Mainvar ) oldmainvar=Mainvar; else oldmainvar=level(F);
-  // First choose a main variable; this may be revisted in the next step
-  mainvar = choose_main_variable(F);
-  // Let`s look if @f/@mainvar is nonzero
-  mainvar = necessary_condition(F,mainvar);
-  // Now we have definetly choosen a main variable
-  // swap poly such that the mainvar has highest level
-  f=swapvar(F,mainvar,level(F));
-
-  // INTERRUPTHANDLER
-  if ( interrupt_handle() ) return CFFList() ;
-  // INTERRUPTHANDLER
-
-  if ( oldmainvar != mainvar ){
-    DEBOUTSL(CERR); DEBOUT(CERR,"Swapped poly ", F);
-    DEBOUT(CERR, " in ", f); DEBOUTNL(CERR);
-    DEBOUTSL(CERR); DEBOUT(CERR,"Swapped  ", oldmainvar );
-    DEBOUT(CERR, " <-- ", mainvar ); DEBOUT(CERR, "  Mainvar= ", f.mvar());
-    DEBOUTNL(CERR);
-    ff = f.deriv();
-    TIMING_START(discr_time);
-    ffuni = gcd(f,ff);
-    TIMING_END(discr_time);
-    if ( !(ffuni.isOne()) ){ //discriminante nonzero: split poly
-      DEBOUTLN(CERR,"Nontrivial GCD of f= ", f);
-      DEBOUTLN(CERR,"             and @f= ", ff);
-      DEBOUTLN(CERR,"          GCD(f,@f)= ", ffuni);
-      ff=f/ffuni;
-      CFFList Outputlist_a, Outputlist_b;
-      Outputlist_a = Factorized(ff,alpha);
-      DEBOUTLN(CERR, "Outputlist_a = ", Outputlist_a);
-      Outputlist_b = Factorized(ffuni,alpha);
-      DEBOUTLN(CERR, "Outputlist_b = ", Outputlist_b);
-      Outputlist = myUnion(Outputlist_a, Outputlist_b);
-      // have to back-swapvar the factors....
-      for ( CFFListIterator i=Outputlist; i.hasItem(); i++ ){
-        copy=i.getItem();
-        Outputlist2.append(CFFactor(swapvar(copy.factor(),oldmainvar,mainvar),copy.exp()));
-      }
-      DEBOUTLN(CERR, "Outputlist2 (a+b swapped) (to return) = ", Outputlist2);
-      return Outputlist2;
-    }
-  }
-
-  // Check special cases
-  for ( int i=1; i<=level(F); i++)
-  {
-    if ( degree(f,Variable(i) ) == 1 )
-    //test trivial case; only true iff F is primitiv w.r.t every variable; else check (if F=ax+b) gcd(a,b)=1 ?
-    {
-      DEBOUTLN(CERR, "Trivial case: ", F);
-      Outputlist.append(CFFactor(F,1));
-      return Outputlist;
-    }
-  }
-
-  // Look at the leading term:
-  lt = LC(f);
-  DEBOUTLN(CERR, "Leading term: ", lt);
-  //if ( lt != f.genOne() )
-  if ( !lt.isOne() )
-  {
-    // make the polynomial monic in the main variable
-    ff = make_monic(f,lt); ffuni = ff;
-    DEBOUTLN(CERR, "make_monic returned: ", ff);
-  }
-  else{ ff= f; ffuni= ff; }
-
-  TIMING_START(evaluate_time);
-  success=evaluate(min(10,max(degree(ff), 5)), min(degree(ff),3), min(degree(ff),3), ff, Extension, alpha, Substitutionlist,UnivariateFactorlist);
-  DEBOUTLN(CERR,  "Returned from evaluate: success: ", success);
-  for ( SFormListIterator ii=Substitutionlist; ii.hasItem(); ii++ )
-  {
-    DEBOUTLN(CERR, "Substituting ", ii.getItem().factor());
-    DEBOUTLN(CERR, "       with value: ", ii.getItem().exp());
-  }
-
-  if ( success==0 ) // evalute wasn't successfull
-  {
-    success= specializePoly(ffuni,Extension,degree(ff),Substitutionlist,1,getNumVars(compress(ff,m)));
-    DEBOUTLN(CERR,  "Returned from specializePoly: success: ", success);
-    if (success == 0 ) // No spezialisation could be found
-    {
-      factoryError("libfac: Factorize: ERROR: Not able to find a valid specialization!");
-      Outputlist.append(CFFactor(F,1));
-      return Outputlist;
-    }
-
-    // INTERRUPTHANDLER
-    if ( interrupt_handle() ) return CFFList() ;
-    // INTERRUPTHANDLER
-
-    ffuni = substitutePoly(ff,Substitutionlist);
-    // We now have an univariat poly; factorize that
-    if ( degree(Extension) == 0   )
-    {
-      DEBOUTMSG(CERR, "Univ. Factorization over the ground field");
-      UnivariateFactorlist = factorize(ffuni,1); // univ. poly is sqr-free!
-    }
-    else
-    {
-      DEBOUTLN(CERR, "Univ. Factorization over extension of degree ",
-               degree(getMipo(Extension,'x')) );
-      UnivariateFactorlist = factorize2(ffuni,Extension,alpha);
-    }
-  }
-  else
-  {
-    ffuni = substitutePoly(ff,Substitutionlist);
-  }
-    TIMING_END(evaluate_time);
-  if (UnivariateFactorlist.length() == 1)
-  { // poly is irreduzibel
-    DEBOUTLN(CERR, "Univ. poly is irreduzible: ", UnivariateFactorlist);
-    Outputlist.append(CFFactor(F,1));
-    return Outputlist;
-  }
-  else
-  { // we have factors
-    DEBOUTSL(CERR);
-    DEBOUT(CERR, "Univariate poly has " , UnivariateFactorlist.length());
-    DEBOUT(CERR, " factors:  ", ffuni);
-    DEBOUT(CERR, " = ", UnivariateFactorlist); DEBOUTNL(CERR);
-
-    // INTERRUPTHANDLER
-    if ( interrupt_handle() ) return CFFList() ;
-    // INTERRUPTHANDLER
-
-    TIMING_START(hensel_time);
-    Outputlist = MultiHensel(ff,UnivariateFactorlist,Substitutionlist, alpha);
-    DEBOUTLN(CERR, "Outputlist after MultiHensel: ", Outputlist);
-    TIMING_END(hensel_time);
-
-    // INTERRUPTHANDLER
-    if ( interrupt_handle() ) return CFFList() ;
-    // INTERRUPTHANDLER
-
-    TIMING_START(truefactor_time);
-    Outputlist = Truefactors(ff, level(ff), Substitutionlist, Outputlist);
-    DEBOUTLN(CERR, "Outputlist after Truefactors: ", Outputlist);
-    TIMING_END(truefactor_time);
-
-    // INTERRUPTHANDLER
-    if ( interrupt_handle() ) return CFFList() ;
-    // INTERRUPTHANDLER
-
-    //if ( lt != f.genOne() )
-    if ( !lt.isOne() )
-    {
-      Outputlist = not_monic(Outputlist,lt,ff,level(ff));
-      DEBOUTLN(CERR, "not_monic returned: ", Outputlist);
-    }
-
-    // have to back-swapvar the factors....
-    for ( CFFListIterator i=Outputlist; i.hasItem(); i++ )
-    {
-      copy=i.getItem();
-      Outputlist2.append(CFFactor(swapvar(copy.factor(),oldmainvar,mainvar),copy.exp()));
-    }
-
-    return Outputlist2;
-  }
-}
-
-int cmpCF( const CFFactor & f, const CFFactor & g );
-
-///////////////////////////////////////////////////////////////
-// The user front-end for a uni/multivariate factorization   //
-// routine. F needs not to be SqrFree.                       //
-// Option of * choosing a  main variable (n.y.i.)            //
-//           * choosing an algebraic extension (n.y.u.)      //
-//           * ensuring poly is sqrfree (n.y.i.)             //
-// use Factorize(F,alpha,is_SqrFree) if not over Zp[x]/Q[x]  //
-///////////////////////////////////////////////////////////////
-int find_mvar(const CanonicalForm &f);
-CFFList Factorize(const CanonicalForm & F, int is_SqrFree )
-{
-  //out_cf("Factorize ",F,"\n");
-  CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2;
-  ListIterator<CFFactor> i,j;
-  CanonicalForm g=1,unit=1,r=1;
-  Variable minpoly; // dummy
-  int exp;
-  CFMap m;
-
-  // INTERRUPTHANDLER
-  if ( interrupt_handle() ) return CFFList() ;
-  // INTERRUPTHANDLER
-
-  DEBINCLEVEL(CERR, "Factorize");
-  DEBOUTLN(CERR, "Called with F= ", F);
-  if (( getCharacteristic() == 0 ) || (F.isUnivariate()))
-  { // char == 0
-    TIMING_START(factorize_time);
-    //CERR << "Factoring in char=0 of " << F << " = " << Outputlist << "\n";
-    Outputlist= factorize(F);
-    // Factorization in char=0 doesn't sometimes return at least two elements!!!
-    if ( getNumVars(Outputlist.getFirst().factor()) != 0 )
-      Outputlist.insert(CFFactor(1,1));
-    //CERR << "  Factorize in char=0: returning with: " << Outputlist << "\n";
-    TIMING_END(factorize_time);
-    DEBDECLEVEL(CERR, "Factorize");
-    TIMING_PRINT(factorize_time, "\ntime used for factorization   : ");
-    return Outputlist;
-  }
-  TIMING_START(factorize_time);
-  // search an "optimal" main variavble
-  int mv=F.level();
-  if ((mv != LEVELBASE) /* && (! F.isUnivariate()) */)
-  {
-     mv=find_mvar(F);
-     if (mv!=F.level())
-     {
-       swapvar(F,Variable(mv),F.mvar());
-     }
-  }
-
-  ///////
-  // Maybe it`s better to add a sqrfree-test before?
-  // (If gcd is fast...)
-  ///////
-  //  if ( ! SqrFreeTest(F) ){
-  if ( ! is_SqrFree )
-  {
-    TIMING_START(sqrfree_time);
-    SqrFreeList = SqrFreeMV(F) ; // first sqrfree the polynomial
-    // don't use sqrFree(F), factory's internal sqrFree for multiv.
-    // Polynomials; it's wrong!! Ex.: char=p   f= x^p*(y+1);
-    // SqrFreeMV(f)= ( y+1, (x)^p ), sqrFree(f)= ( y+1 ) .
-    TIMING_END(sqrfree_time);
-
-    // INTERRUPTHANDLER
-    if ( interrupt_handle() ) return CFFList() ;
-    // INTERRUPTHANDLER
-
-  }
-  else
-    SqrFreeList.append(CFFactor(F,1));
-
-  DEBOUTLN(CERR, "SqrFreeMV= ", SqrFreeList);
-  for ( i=SqrFreeList; i.hasItem(); i++ )
-  {
-    DEBOUTLN(CERR, "Factor under consideration: ", i.getItem().factor());
-    // We need a compress on each list item ! Maybe we have less variables!
-    g =compress(i.getItem().factor(),m);
-    exp = i.getItem().exp();
-    if ( getNumVars(g) ==0 ) // a constant; Exp==1
-      Outputlist.append( CFFactor(g,1) ) ;
-    else// a real polynomial
-      if ( g.isUnivariate() )
-      {
-        //out_cf("univ. poly: ",g,"\n");
-        Intermediatelist=factorize(g,1); // poly is sqr-free!
-        for ( j=Intermediatelist; j.hasItem(); j++ )
-          //Normally j.getItem().exp() should be 1
-          Outputlist.append( CFFactor( m(j.getItem().factor()),exp*j.getItem().exp()));
-      }
-      else
-      { // multivariate polynomial
-        if ( g.isHomogeneous() )
-        {
-          DEBOUTLN(CERR, "Poly is homogeneous! : ", g);
-          // Now we can substitute one variable to 1, factorize and then
-          // look on the resulting factors and their monomials for
-          // backsubstitution of the substituted variable.
-          Intermediatelist = HomogFactor(g, minpoly, 0);
-        }
-        else // not homogeneous
-          Intermediatelist = Factorized(g, minpoly, 0);
-
-        // INTERRUPTHANDLER
-        if ( interrupt_handle() ) return CFFList() ;
-        // INTERRUPTHANDLER
-
-        for ( j=Intermediatelist; j.hasItem(); j++ )
-          //Normally j.getItem().exp() should be 1
-          Outputlist= myappend( Outputlist, CFFactor(m(j.getItem().factor()),exp*j.getItem().exp()));
-      }
-  }
-  g=1; unit=1;
-  DEBOUTLN(CERR, "Outputlist is ", Outputlist);
-  for ( i=Outputlist; i.hasItem(); i++ )
-    if ( level(i.getItem().factor()) > 0 )
-    {
-      unit = lc(i.getItem().factor());
-      if ( getNumVars(unit) == 0 )
-      { // a constant; possibly 1
-        Outputlist2.append(CFFactor(i.getItem().factor()/unit , i.getItem().exp()));
-        g *=power(i.getItem().factor()/unit,i.getItem().exp());
-      }
-      else
-      {
-        Outputlist2.append(i.getItem());
-        g *=power(i.getItem().factor(),i.getItem().exp());
-      }
-    }
-
-  r=F/g;
-  Outputlist2.insert(CFFactor(r,1));
-
-  if ((mv!=F.level()) && (! F.isUnivariate() ))
-  {
-    CFFListIterator J=Outputlist2;
-    for ( ; J.hasItem(); J++)
-    {
-      swapvar(J.getItem().factor(),Variable(mv),F.mvar());
-    }
-    swapvar(F,Variable(mv),F.mvar());
-  }
-  DEBDECLEVEL(CERR, "Factorize");
-  TIMING_END(factorize_time);
-
-  TIMING_PRINT(sqrfree_time, "\ntime used for sqrfree   : ");
-  TIMING_PRINT(discr_time, "time used for discriminante   : ");
-  TIMING_PRINT(evaluate_time, "time used for evaluation and univ. factorization  : ");
-  TIMING_PRINT(hensel_time, "time used for hensel-lift   : ");
-  TIMING_PRINT(truefactor_time, "time used for truefactors   : ");
-  TIMING_PRINT(factorize_time, "\ntime used for factorization   : ");
-
-  if(isOn(SW_USE_NTL_SORT)) Outputlist2.sort(cmpCF);
-
-  return Outputlist2;
-}
-
-///////////////////////////////////////////////////////////////
-// The user front-end for a uni/multivariate factorization   //
-// routine. F needs not to be SqrFree.                       //
-// Option of * choosing a  main variable (n.y.i.)            //
-//           * choosing an algebraic extension (n.y.u.)      //
-//           * ensuring poly is sqrfree (n.y.i.)             //
-///////////////////////////////////////////////////////////////
-static bool fdivides2(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &minpoly)
-{
-  if (!minpoly.isZero())
-  {
-  #if 0
-    Variable Alpha=minpoly.mvar();
-    Variable X=rootOf(minpoly);
-    CanonicalForm rF=replacevar(F,Alpha,X);
-    CanonicalForm rG=replacevar(G,Alpha,X);
-    return fdivides(rF,rG);;
-  #else
-    if (degree(F,F.mvar()) > degree(G,F.mvar())) return false;
-    return true;
-    //CanonicalForm a,b;
-    //mydivrem(G,F,a,b);
-    //if (b.isZero()) return true;
-    //else return false;
-  #endif
-  }
-  else
-   return fdivides(F,G);
-}
-
-CFFList
-Factorize(const CanonicalForm & F, const CanonicalForm & minpoly, int is_SqrFree )
-{
-  //out_cf("Factorize: F=",F,"\n");
-  //out_cf("           minpoly:",minpoly,"\n");
-  CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2;
-  ListIterator<CFFactor> i,j;
-  CanonicalForm g=1,unit=1,r=1;
-  //Variable minpoly; // reserved (-> Factorisation over algebraic Extensions)
-  int exp;
-  CFMap m;
-
-  // INTERRUPTHANDLER
-  if ( interrupt_handle() ) return CFFList() ;
-  // INTERRUPTHANDLER
-
-  DEBINCLEVEL(CERR, "Factorize");
-  DEBOUTLN(CERR, "Called with F= ", F);
-  if ( getCharacteristic() == 0 )
-  { // char == 0
-    TIMING_START(factorize_time);
-    //CERR << "Factoring in char=0 of " << F << " = " << Outputlist << "\n";
-    #if 0
-    // SHOULD: Outputlist= factorize(F,minpoly);
-    Outputlist= factorize(F);
-    #else
-    if (!minpoly.isZero())
-    {
-      if ( F.isHomogeneous() )
-      {
-        DEBOUTLN(CERR, "Poly is homogeneous! : ", F);
-        // Now we can substitute one variable to 1, factorize and then
-        // look on the resulting factors and their monomials for
-        // backsubstitution of the substituted variable.
-        Outputlist=HomogFactor(F, minpoly, 0);
-      }
-      else
-      {
-        CFList as(minpoly);
-        //CFFList sqF=sqrFree(F); // sqrFreeZ
-        CFFList sqF=SqrFreeMV(F,minpoly);
-        if (sqF.isEmpty()) sqF=sqrFree(F);
-        CFFList G,H;
-        CanonicalForm fac;
-        int d;
-        ListIterator<CFFactor> i,k;
-        for ( i = sqF; i.hasItem(); ++i )
-        {
-          d = i.getItem().exp();
-          fac = i.getItem().factor();
-          int success=1;
-          G = newfactoras( fac, as, success);
-          for ( k = G; k.hasItem(); ++k )
-          {
-            fac = k.getItem().factor();
-            int dd = k.getItem().exp();
-            H.append( CFFactor( fac , d*dd ) );
-          }
-        }
-        Outputlist = H;
-      }
-    }
-    else // minpoly==0
-      Outputlist=factorize(F);
-    #endif
-    // Factorization in char=0 doesn't sometimes return at least two elements!!!
-    if ( getNumVars(Outputlist.getFirst().factor()) != 0 )
-      Outputlist.insert(CFFactor(1,1));
-    //CERR << "  Factorize in char=0: returning with: " << Outputlist << "\n";
-    TIMING_END(factorize_time);
-    DEBDECLEVEL(CERR, "Factorize");
-    TIMING_PRINT(factorize_time, "\ntime used for factorization   : ");
-    //out_cff(Outputlist);
-    return Outputlist;
-  }
-  TIMING_START(factorize_time);
-  // search an "optimal" main variavble
-  int mv=F.level();
-  if (mv != LEVELBASE && ! F.isUnivariate() )
-  {
-     mv=find_mvar(F);
-     if (mv!=F.level())
-     {
-       swapvar(F,Variable(mv),F.mvar());
-     }
-  }
-
-  ///////
-  // Maybe it`s better to add a sqrfree-test before?
-  // (If gcd is fast...)
-  ///////
-  //  if ( ! SqrFreeTest(F) ){
-  if ( ! is_SqrFree )
-  {
-    TIMING_START(sqrfree_time);
-    SqrFreeList = SqrFreeMV(F, minpoly) ; // first sqrfree the polynomial
-    // don't use sqrFree(F), factory's internal sqrFree for multiv.
-    // Polynomials; it's wrong!! Ex.: char=p   f= x^p*(y+1);
-    // SqrFreeMV(f)= ( y+1, (x)^p ), sqrFree(f)= ( y+1 ) .
-    TIMING_END(sqrfree_time);
-
-    // INTERRUPTHANDLER
-    if ( interrupt_handle() ) return CFFList() ;
-    // INTERRUPTHANDLER
-
-  }
-  else
-    SqrFreeList.append(CFFactor(F,1));
-  DEBOUTLN(CERR, "SqrFreeMV= ", SqrFreeList);
-  for ( i=SqrFreeList; i.hasItem(); i++ )
-  {
-    DEBOUTLN(CERR, "Factor under consideration: ", i.getItem().factor());
-    // We need a compress on each list item ! Maybe we have less variables!
-    g =compress(i.getItem().factor(),m);
-    exp = i.getItem().exp();
-    if ( getNumVars(g) ==0 ) // a constant; Exp==1
-      Outputlist.append( CFFactor(g,1) ) ;
-    else// a real polynomial
-    {
-      if ( g.isUnivariate() )
-      {
-        Variable alpha=rootOf(minpoly);
-        Intermediatelist=factorize2(g,alpha,minpoly); // poly is sqr-free!
-        for ( j=Intermediatelist; j.hasItem(); j++ )
-          //Normally j.getItem().exp() should be 1
-          Outputlist.append(
-           CFFactor( m(replacevar(j.getItem().factor(),alpha,minpoly.mvar())),
-             exp*j.getItem().exp()));
-      }
-      else // multivariate polynomial
-      {
-        if ( g.isHomogeneous() )
-        {
-          DEBOUTLN(CERR, "Poly is homogeneous! : ", g);
-          // Now we can substitute one variable to 1, factorize and then
-          // look on the resulting factors and their monomials for
-          // backsubstitution of the substituted variable.
-          Intermediatelist = HomogFactor(g, minpoly, 0);
-        }
-        else // not homogeneous
-          Intermediatelist = Factorized(g, minpoly, 0);
-
-        // INTERRUPTHANDLER
-        if ( interrupt_handle() ) return CFFList() ;
-        // INTERRUPTHANDLER
-
-        for ( j=Intermediatelist; j.hasItem(); j++ )
-          //Normally j.getItem().exp() should be 1
-          Outputlist= myappend( Outputlist, CFFactor(m(j.getItem().factor()),exp*j.getItem().exp()));
-      }
-    }
-  }
-  g=1; unit=1;
-  DEBOUTLN(CERR, "Outputlist is ", Outputlist);
-  for ( i=Outputlist; i.hasItem(); i++ )
-    if ( level(i.getItem().factor()) > 0 )
-    {
-      unit = lc(i.getItem().factor());
-      if ( getNumVars(unit) == 0 ){ // a constant; possibly 1
-        Outputlist2.append(CFFactor(i.getItem().factor()/unit , i.getItem().exp()));
-        g *=power(i.getItem().factor()/unit,i.getItem().exp());
-      }
-      else
-      {
-        Outputlist2.append(i.getItem());
-        g *=power(i.getItem().factor(),i.getItem().exp());
-      }
-    }
-
-  r=F/g;
-  Outputlist2.insert(CFFactor(r,1));
-
-  if ((mv!=F.level()) && (! F.isUnivariate() ))
-  {
-    CFFListIterator J=Outputlist2;
-    for ( ; J.hasItem(); J++)
-    {
-      swapvar(J.getItem().factor(),Variable(mv),F.mvar());
-    }
-    swapvar(F,Variable(mv),F.mvar());
-  }
-
-  DEBDECLEVEL(CERR, "Factorize");
-  TIMING_END(factorize_time);
-
-  TIMING_PRINT(sqrfree_time, "\ntime used for sqrfree   : ");
-  TIMING_PRINT(discr_time, "time used for discriminante   : ");
-  TIMING_PRINT(evaluate_time, "time used for evaluation and univ. factorization  : ");
-  TIMING_PRINT(hensel_time, "time used for hensel-lift   : ");
-  TIMING_PRINT(truefactor_time, "time used for truefactors   : ");
-  TIMING_PRINT(factorize_time, "\ntime used for factorization   : ");
-
-  if(isOn(SW_USE_NTL_SORT)) Outputlist2.sort(cmpCF);
-
-  //out_cff(Outputlist2);
-  return Outputlist2;
-}
-
Index: ctory/libfac/factor/Factor.h
===================================================================
--- factory/libfac/factor/Factor.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,14 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-///////////////////////////////////////////////////////////////////////////////
-#ifndef FACTOR_H
-#define FACTOR_H
-CanonicalForm generate_mipo( int degree_of_Extension , const Variable & Extension );
-CFFList Factorized( const CanonicalForm & F, const CanonicalForm & mipo, int Mainvar=0);
-/*BEGINPUBLIC*/
-CFFList Factorize( const CanonicalForm & F, int is_SqrFree=0 ) ;
-CFFList Factorize( const CanonicalForm & F, const CanonicalForm & mi, int is_SqrFree=0 ) ;
-/*ENDPUBLIC*/
-
-#endif /* FACTOR_H */
-
Index: ctory/libfac/factor/MVMultiHensel.cc
===================================================================
--- factory/libfac/factor/MVMultiHensel.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,482 +1,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-///////////////////////////////////////////////////////////////////////////////
-// FACTORY - Includes
-#include <factory.h>
-#ifndef NOSTREAMIO
-#ifdef HAVE_IOSTREAM
-#include <iostream>
-#define OSTREAM std::ostream
-#define ISTREAM std::istream
-#define CERR std::cerr
-#define CIN std::cin
-#elif defined(HAVE_IOSTREAM_H)
-#include <iostream.h>
-#define OSTREAM ostream
-#define ISTREAM istream
-#define CERR cerr
-#define CIN cin
-#endif
-#endif
-// Factor - Includes
-#include "tmpl_inst.h"
-#include "helpstuff.h"
-// some CC's need this:
-#include "MVMultiHensel.h"
-
-#ifndef NOSTREAMIO
-void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
-#endif
-
-extern int libfac_interruptflag;
-
-#ifdef HENSELDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-
-#include <libfac/factor/debug.h>
-#include "interrupt.h"
-#include "timing.h"
-
-///////////////////////////////////////////////////////////////
-// some class definition needed in MVMultiHensel
-///////////////////////////////////////////////////////////////
-typedef bool Boolean;
-
-class DiophantForm
-{
- public:
-   CanonicalForm One;
-   CanonicalForm Two;
-   inline DiophantForm& operator=( const DiophantForm&  value )
-   {
-     if ( this != &value )
-     {
-       One = value.One;
-       Two = value.Two;
-     }
-     return *this;
-   }
-};
-
-// We remember an already calculated value; simple class for RememberArray
-class RememberForm
-{
-public:
-  inline RememberForm operator=( CanonicalForm & value )
-  {
-    this->calculated = true;
-    this->poly = value;
-    return *this;
-  }
-  RememberForm() : poly(0), calculated(false) {}
-  Boolean calculated;
-  CanonicalForm poly;
-};
-
-// Array to remember already calculated values; used for the diophantine
-// equation s*f + t*g = x^i
-class RememberArray
-{
-public:
-// operations performed on arrays
-  RememberArray( int sz )
-  {
-    size = sz;
-    ia = new RememberForm[size];
-//    assert( ia != 0 ); // test if we got the memory
-    init( sz );
-  }
-  ~RememberArray(){ delete [] ia; }
-  inline RememberForm& operator[]( int index )
-  {
-    return ia[index];
-  }
-  bool checksize(int i) {return i<size;}
-protected:
-  void init( int )
-  {
-    for ( int ix=0; ix < size; ++ix)
-    {
-      ia[ix].calculated=false;
-      ia[ix].poly=0;
-    }
-  }
-// internal data representation
-  int size;
-  RememberForm *ia;
-};
-
-///////////////////////////////////////////////////////////////
-// Solve the Diophantine equation: ( levelU == mainvar )     //
-//            s*F1 + t*F2 = (mainvar)^i                      //
-// Returns s and t.                                          //
-///////////////////////////////////////////////////////////////
-static DiophantForm
-diophant( int levelU , const CanonicalForm & F1 , const CanonicalForm & F2 ,
-          int i , RememberArray & A, RememberArray & B,
-          const CanonicalForm &alpha )
-{
-  DiophantForm Retvalue;
-  CanonicalForm s,t,q,r;
-  Variable x(levelU);
-
-  DEBOUT(CERR, "diophant: called with: ", F1);
-  DEBOUT(CERR, "  ", F2); DEBOUTLN(CERR, "  ", i);
-
-  // Did we solve the diophantine equation yet?
-  // If so, return the calculated values
-  if (A.checksize(i) && A[i].calculated && B[i].calculated )
-  {
-    Retvalue.One=A[i].poly;
-    Retvalue.Two=B[i].poly;
-    return Retvalue;
-  }
-
-  // Degrees ok? degree(F1,mainvar) + degree(F2,mainvar) <= i ?
-  if ( (degree(F1,levelU) + degree(F2,levelU) ) <= i )
-  {
-    if (!interrupt_handle()) factoryError("libfac: diophant ERROR: degree too large!"); /*  (%d + %d <= %d)",degree(F1,levelU), degree(F2,levelU), i);*/
-    Retvalue.One=F1;Retvalue.Two=F2;
-    return Retvalue;
-  }
-
-  if ( i == 0 )
-  { // call the extended gcd
-    r=extgcd(F1,F2,s,t);
-    // check if gcd(F1,F2) <> 1 , i.e. F1 and F2 are not relatively prime
-    if ( ! r.isOne() )
-    {
-      if (r.degree()<1) // some constant != 1 ?
-      {
-        Retvalue.One=s/r;Retvalue.Two=t/r;
-        return Retvalue;
-      }
-      else if (alpha!=0)
-      {
-        Variable Alpha=alpha.mvar();
-        if (r.mvar()==Alpha)   // from field extension ?
-        {
-          Variable X=rootOf(alpha);
-          r=replacevar(r,Alpha,X);
-          s=replacevar(s,Alpha,X);
-          t=replacevar(t,Alpha,X);
-          s/=r;
-          t/=r;
-          s=replacevar(s,X,Alpha);
-          t=replacevar(t,X,Alpha);
-          Retvalue.One=s; Retvalue.Two=t;
-          return Retvalue;
-        }
-      } 
-      if (!interrupt_handle())
-        factoryError("libfac: diophant ERROR: F1 and F2 are not relatively prime! ");
-      Retvalue.One=s/r;Retvalue.Two=t/r;
-      return Retvalue;
-    }
-    Retvalue.One = s; Retvalue.Two = t;
-  }
-  else
-  { // recursively call diophant
-    Retvalue=diophant(levelU,F1,F2,i-1,A,B,alpha);
-    Retvalue.One *= x; // createVar(levelU,1);
-    Retvalue.Two *= x; // createVar(levelU,1);
-
-    if (interrupt_handle()) return Retvalue;
-
-    // Check degrees.
-
-    if ( degree(Retvalue.One,levelU) > degree(F2,levelU) )
-    {
-      // Make degree(Retvalue.one,mainvar) < degree(F2,mainvar)
-      divrem(Retvalue.One,F2,q,r);
-      Retvalue.One = r; Retvalue.Two += F1*q;
-    }
-    else
-    {
-      if ( degree(Retvalue.Two,levelU) >= degree(F1,levelU) )
-      {
-        // Make degree(Retvalue.Two,mainvar) <= degree(F1,mainvar)
-        divrem(Retvalue.Two,F1,q,r);
-        Retvalue.One += F2*q; Retvalue.Two = r;
-      }
-    }
-
-  }
-  if (A.checksize(i))
-  {
-    A[i].poly = Retvalue.One ;
-    B[i].poly = Retvalue.Two ;
-    A[i].calculated = true ; B[i].calculated = true ;
-  }
-  DEBOUT(CERR, "diophant: Returnvalue is: ", Retvalue.One);
-  DEBOUTLN(CERR, "  ", Retvalue.Two);
-
-  return  Retvalue;
-}
-
-///////////////////////////////////////////////////////////////
-// A more efficient way to solve s*F1 + t*F2 = W             //
-// as in Wang and Rothschild [Wang&Roth75].                  //
-///////////////////////////////////////////////////////////////
-static CanonicalForm
-make_delta( int levelU, const CanonicalForm & W,
-            const CanonicalForm & F1, const CanonicalForm & F2,
-            RememberArray & A, RememberArray & B,
-            const CanonicalForm &alpha)
-{
-  CanonicalForm Retvalue;
-  DiophantForm intermediate;
-
-  DEBOUT(CERR, "make_delta: W= ", W);
-  DEBOUTLN(CERR, "  degree(W,levelU)= ", degree(W,levelU) );
-
-  if ( levelU == level(W) ) // same level, good
-  {
-    for ( CFIterator i=W; i.hasTerms(); i++)
-    {
-      intermediate=diophant(levelU,F1,F2,i.exp(),A,B,alpha);
-      Retvalue += intermediate.One * i.coeff();
-
-      if (interrupt_handle()) return Retvalue;
-    }
-  }
-  else // level(W) < levelU ; i.e. degree(w,levelU) == 0
-  {
-    intermediate=diophant(levelU,F1,F2,0,A,B,alpha);
-    Retvalue = W * intermediate.One;
-  }
-  DEBOUTLN(CERR, "make_delta: Returnvalue= ", Retvalue);
-  return Retvalue;
-}
-
-static CanonicalForm
-make_square( int levelU, const CanonicalForm & W,
-             const CanonicalForm & F1, const CanonicalForm & F2,
-             RememberArray & A, RememberArray & B,const CanonicalForm &alpha)
-{
-  CanonicalForm Retvalue;
-  DiophantForm intermediate;
-
-  DEBOUT(CERR, "make_square: W= ", W );
-  DEBOUTLN(CERR, "  degree(W,levelU)= ", degree(W,levelU));
-
-  if ( levelU == level(W) ) // same level, good
-  {
-    for ( CFIterator i=W; i.hasTerms(); i++)
-    {
-      intermediate=diophant(levelU,F1,F2,i.exp(),A,B,alpha);
-      Retvalue += i.coeff() * intermediate.Two;
-
-      if (interrupt_handle()) return Retvalue;
-    }
-  }
-  else // level(W) < levelU ; i.e. degree(w,levelU) == 0
-  {
-    intermediate=diophant(levelU,F1,F2,0,A,B,alpha);
-    Retvalue = W * intermediate.Two;
-  }
-  DEBOUTLN(CERR, "make_square: Returnvalue= ", Retvalue);
-
-  return Retvalue;
-}
-
-
-///////////////////////////////////////////////////////////////
-// Multivariat Hensel routine for two factors F and G .      //
-// U is the monic univariat polynomial; we manage two arrays //
-// to remember already calculated values for the diophantine //
-// equation. This is suggested by Joel Moses [Moses71] .     //
-// Return the fully lifted factors.                          //
-///////////////////////////////////////////////////////////////
-static DiophantForm
-mvhensel( const CanonicalForm & U , const CanonicalForm & F ,
-          const CanonicalForm & G , const SFormList & Substitutionlist,
-          const CanonicalForm &alpha)
-{
-  CanonicalForm V,Fk=F,Gk=G,Rk,W,D,S;
-  int  levelU=level(U), degU=subvardegree(U,levelU); // degree(U,{x_1,..,x_(level(U)-1)})
-  DiophantForm Retvalue;
-  RememberArray A(degree(F,levelU)+degree(G,levelU)+1);
-  RememberArray B(degree(F,levelU)+degree(G,levelU)+1);
-
-  DEBOUTLN(CERR, "mvhensel called with: U= ", U);
-  DEBOUTLN(CERR, "                      F= ", F);
-  DEBOUTLN(CERR, "                      G= ", G);
-  DEBOUTLN(CERR, "                   degU= ", degU);
-
-  V=change_poly(U,Substitutionlist,0); // change x_i <- x_i + a_i for all i
-  Rk = F*G-V;
-#ifdef HENSELDEBUG2
-  CERR << "mvhensel: V = " << V << "\n"
-       << "          Fk= " << F << "\n"
-       << "          Gk= " << G << "\n"
-       << "          Rk= " << Rk << "\n";
-#endif
-  for ( int k=2; k<=degU+1; k++)
-  {
-    W = mod_power(Rk,k,levelU);
-#ifdef HENSELDEBUG2
-    CERR << "mvhensel: Iteration: " << k << "\n";
-    CERR << "mvhensel: W= " << W << "\n";
-#endif
-    D = make_delta(levelU,W,F,G,A,B,alpha);
-#ifdef HENSELDEBUG2
-    CERR << "mvhensel: D= " << D << "\n";
-#endif
-    S = make_square(levelU,W,F,G,A,B,alpha);
-#ifdef HENSELDEBUG2
-    CERR << "mvhensel: S= " << S << "\n";
-#endif
-    Rk += S*D - D*Fk - S*Gk;
-#ifdef HENSELDEBUG2
-    CERR << "mvhensel: Rk= " << Rk << "\n";
-#endif
-    Fk -= S;
-#ifdef HENSELDEBUG2
-    CERR << "mvhensel: Fk= " << Fk << "\n";
-#endif
-    Gk -= D;
-#ifdef HENSELDEBUG2
-    CERR << "mvhensel: Gk= " << Gk << "\n";
-#endif
-    if ( Rk.isZero() ) break;
-    if (interrupt_handle()) break;
-  }
-  Retvalue.One = change_poly(Fk,Substitutionlist,1);
-  Retvalue.Two = change_poly(Gk,Substitutionlist,1);
-
-  DEBOUTLN(CERR, "mvhensel: Retvalue: ", Retvalue.One);
-  DEBOUTLN(CERR, "                    ", Retvalue.Two);
-
-  return Retvalue ;
-}
-
-///////////////////////////////////////////////////////////////
-// Recursive Version of MultiHensel.                         //
-///////////////////////////////////////////////////////////////
-CFFList
-multihensel( const CanonicalForm & mF, const CFFList & Factorlist,
-             const SFormList & Substitutionlist,
-             const CanonicalForm &alpha)
-{
-  CFFList Returnlist,factorlist=Factorlist;
-  DiophantForm intermediat;
-  CanonicalForm Pl,Pr;
-  int n = factorlist.length();
-
-  DEBOUT(CERR, "multihensel: called with ", mF);
-  DEBOUTLN(CERR, "  ", factorlist);
-
-  if ( n == 1 )
-  {
-    Returnlist.append(CFFactor(mF,1));
-  }
-  else
-  {
-    if ( n == 2 )
-    {
-      intermediat= mvhensel(mF, factorlist.getFirst().factor(),
-                            Factorlist.getLast().factor(),
-                            Substitutionlist,alpha);
-      Returnlist.append(CFFactor(intermediat.One,1));
-      Returnlist.append(CFFactor(intermediat.Two,1));
-    }
-    else  // more then two factors
-    {
-#ifdef HENSELDEBUG2
-      CERR << "multihensel: more than two factors!" << "\n";
-#endif
-      Pl=factorlist.getFirst().factor(); factorlist.removeFirst();
-      Pr=Pl.genOne();
-      for ( ListIterator<CFFactor> i=factorlist; i.hasItem(); i++ )
-        Pr *=  i.getItem().factor() ;
-#ifdef HENSELDEBUG2
-      CERR << "multihensel: Pl,Pr, factorlist: " << Pl << "  " << Pr
-           << "  " << factorlist << "\n";
-#endif
-      intermediat= mvhensel(mF,Pl,Pr,Substitutionlist,alpha);
-      Returnlist.append(CFFactor(intermediat.One,1));
-      Returnlist=Union( multihensel(intermediat.Two,factorlist,Substitutionlist,alpha), 
-                        Returnlist);
-    }
-  }
-  return Returnlist;
-}
-
-///////////////////////////////////////////////////////////////
-// Generalized Hensel routine.                               //
-// mF is the monic multivariat polynomial, Factorlist is the //
-// list of factors, Substitutionlist represents the ideal    //
-// <x_1+a_1, .. , x_r+a_r>, where r=level(mF)-1 .            //
-// Returns the list of fully lifted factors.                 //
-///////////////////////////////////////////////////////////////
-CFFList
-MultiHensel( const CanonicalForm & mF, const CFFList & Factorlist,
-             const SFormList & Substitutionlist, const CanonicalForm &alpha)
-{
-  CFFList Ll;
-  CFFList Returnlist,Retlistinter,factorlist=Factorlist;
-  CFFListIterator i;
-  DiophantForm intermediat;
-  CanonicalForm Pl,Pr;
-  int n = factorlist.length(),h=n/2, k;
-
-  DEBOUT(CERR, "MultiHensel: called with ", mF);
-  DEBOUTLN(CERR, "  ", factorlist);
-  DEBOUT(CERR,"           : n,h = ", n);
-  DEBOUTLN(CERR,"  ", h);
-
-  if ( n == 1 )
-  {
-    Returnlist.append(CFFactor(mF,1));
-  }
-  else
-  {
-    if ( n == 2 )
-    {
-      intermediat= mvhensel(mF, factorlist.getFirst().factor(),
-                            Factorlist.getLast().factor(),
-                            Substitutionlist,alpha);
-      Returnlist.append(CFFactor(intermediat.One,1));
-      Returnlist.append(CFFactor(intermediat.Two,1));
-    }
-    else  // more then two factors
-    {
-      for ( k=1 ; k<=h; k++)
-      {
-        Ll.append(factorlist.getFirst());
-        factorlist.removeFirst();
-      }
-
-      DEBOUTLN(CERR, "MultiHensel: Ll= ", Ll);
-      DEBOUTLN(CERR, "     factorlist= ", factorlist);
-
-      Pl = 1; Pr = 1;
-      for ( i = Ll; i.hasItem(); i++)
-        Pl *= i.getItem().factor();
-      DEBOUTLN(CERR, "MultiHensel: Pl= ", Pl);
-      for ( i = factorlist; i.hasItem(); i++)
-        Pr *= i.getItem().factor();
-      DEBOUTLN(CERR, "MultiHensel: Pr= ", Pr);
-      intermediat = mvhensel(mF,Pl,Pr,Substitutionlist,alpha);
-      // divison test for intermediat.One and intermediat.Two ?
-      CanonicalForm a,b;
-      // we add a division test now for intermediat.One and intermediat.Two
-      if ( mydivremt (mF,intermediat.One,a,b) && b == mF.genZero() )
-        Retlistinter.append(CFFactor(intermediat.One,1) );
-      if ( mydivremt (mF,intermediat.Two,a,b) && b == mF.genZero() )
-        Retlistinter.append(CFFactor(intermediat.Two,1)  );
-
-      Ll = MultiHensel(intermediat.One, Ll, Substitutionlist,alpha);
-      Returnlist = MultiHensel(intermediat.Two, factorlist, Substitutionlist,alpha);
-      Returnlist = Union(Returnlist,Ll);
-
-      Returnlist = Union(Retlistinter,Returnlist);
-
-    }
-  }
-  return Returnlist;
-}
Index: ctory/libfac/factor/MVMultiHensel.h
===================================================================
--- factory/libfac/factor/MVMultiHensel.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,15 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-/////////////////////////////////////////////////////////////
-#ifndef MULTIHENSEL_H
-#define MULTIHENSEL_H
-// recursive version:
-CFFList multihensel( const CanonicalForm & mF, const CFFList & Factorlist,
-                     const SFormList & Substitutionlist,
-                     const CanonicalForm &alpha);
-// this is the real one (quasiparallel):
-CFFList MultiHensel( const CanonicalForm & mF, const CFFList & Factorlist,
-                     const SFormList & Substitutionlist,
-                     const CanonicalForm &alpha);
-
-#endif /* MULTIHENSEL_H */
Index: ctory/libfac/factor/SqrFree.cc
===================================================================
--- factory/libfac/factor/SqrFree.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,433 +1,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-static const char * errmsg = "\nYou found a bug!\nPlease inform singular@mathematik.uni-kl.de\n Please include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you.";
-///////////////////////////////////////////////////////////////////////////////
-// FACTORY - Includes
-
-#include<factory/factory.h>
-
-#ifndef NOSTREAMIO
-#ifdef HAVE_IOSTREAM
-#include <iostream>
-#define OSTREAM std::ostream
-#define ISTREAM std::istream
-#define CERR std::cerr
-#define CIN std::cin
-#elif defined(HAVE_IOSTREAM_H)
-#include <iostream.h>
-#define OSTREAM ostream
-#define ISTREAM istream
-#define CERR cerr
-#define CIN cin
-#endif
-#endif
-// Factor - Includes
-#include "tmpl_inst.h"
-#include "helpstuff.h"
-// some CC's need this:
-#include "SqrFree.h"
-
-#ifdef SQRFREEDEBUG
-# define DEBUGOUTPUT
-#else
-# undef DEBUGOUTPUT
-#endif
-
-#include <libfac/factor/debug.h>
-#include "timing.h"
-
-TIMING_DEFINE_PRINT(squarefree_time)
-TIMING_DEFINE_PRINT(gcd_time)
-
-static inline CFFactor
-Powerup( const CFFactor & F , int exp=1)
-{
-  return CFFactor(F.factor(), exp*F.exp()) ;
-}
-
-static CFFList
-Powerup( const CFFList & Inputlist , int exp=1 )
-{
-  CFFList Outputlist;
-
-  for ( CFFListIterator i=Inputlist; i.hasItem(); i++ )
-    Outputlist.append(Powerup(i.getItem(), exp));
-  return Outputlist ;
-}
-
-///////////////////////////////////////////////////////////////
-// Compute the Pth root of a polynomial in characteristic p  //
-// f must be a polynomial which we can take the Pth root of. //
-// Domain is q=p^m , f a uni/multivariate polynomial         //
-///////////////////////////////////////////////////////////////
-static CanonicalForm
-PthRoot( const CanonicalForm & f )
-{
-  CanonicalForm RES, R = f;
-  int n= max(level(R),getNumVars(R)), p= getCharacteristic();
-
-  if (n==0)
-  { // constant
-    if (R.inExtension()) // not in prime field; f over |F(q=p^k)
-    {
-      R = power(R,Powerup(p,getGFDegree() - 1)) ;
-    }
-    // if f in prime field, do nothing
-    return R;
-  }
-  // we assume R is a Pth power here
-  RES = R.genZero();
-  Variable x(n);
-  for (int i=0; i<= (int) (degree(R,level(R))/p) ; i++)
-    RES += PthRoot( R[i*p] ) * power(x,i);
-  return RES;
-}
-
-///////////////////////////////////////////////////////////////
-// Compute the Pth root of a polynomial in characteristic p  //
-// f must be a polynomial which we can take the Pth root of. //
-// Domain is q=p^m , f a uni/multivariate polynomial         //
-///////////////////////////////////////////////////////////////
-static CanonicalForm
-PthRoot( const CanonicalForm & f ,const CanonicalForm & mipo)
-{
-  CanonicalForm RES, R = f;
-  int n= max(level(R),getNumVars(R)), p= getCharacteristic();
-  int mipodeg=-1;
-  if (f.level()==mipo.level()) mipodeg=mipo.degree();
-  else if ((f.level()==1) &&(!mipo.isZero()))
-  {
-    Variable t;
-    CanonicalForm tt=getMipo(mipo.mvar(),t);
-    mipodeg=degree(tt,t);
-  }
-
-  if ((n==0)
-  ||(mipodeg!=-1))
-  { // constant
-    if (R.inExtension()) // not in prime field; f over |F(q=p^k)
-    {
-      R = power(R,Powerup(p,getGFDegree() - 1)) ;
-    }
-    else if ((f.level()==mipo.level())
-    ||((f.level()==1) &&(!mipo.isZero())))
-    {
-      R = power(R,Powerup(p,mipodeg - 1)) ;
-      R=mod(R, mipo);
-    }
-    // if f in prime field, do nothing
-    return R;
-  }
-  // we assume R is a Pth power here
-  RES = R.genZero();
-  Variable x(n);
-  for (int i=0; i<= (int) (degree(R,level(R))/p) ; i++)
-    RES += PthRoot( R[i*p], mipo ) * power(x,i);
-  return RES;
-}
-
-///////////////////////////////////////////////////////////////
-// A uni/multivariate SqrFreeTest routine.                   //
-// Cheaper to run if all you want is a test.                 //
-// Works for charcteristic 0 and q=p^m                       //
-// Returns 1 if poly r is SqrFree, 0 if SqrFree will do some //
-// kind of factorization.                                    //
-// Would be much more effcient iff we had *good*             //
-//  uni/multivariate gcd's and/or gcdtest's                  //
-///////////////////////////////////////////////////////////////
-int
-SqrFreeTest( const CanonicalForm & r, int opt)
-{
-  CanonicalForm f=r, g;
-  int n=level(f);
-
-  if (getNumVars(f)==0) return 1 ; // a constant is SqrFree
-  if ( f.isUnivariate() )
-  {
-    g= f.deriv();
-    if ( getCharacteristic() > 0 && g.isZero() ) return 0 ;
-    // Next: it would be best to have a *univariate* gcd-test which returns
-    // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials )
-    g = gcd(f,g);
-    if ( g.isOne() || (-g).isOne() ) return 1;
-    else
-      if ( getNumVars(g) == 0 ) return 1;// <- totaldegree!!!
-      else return 0 ;
-  }
-  else
-  { // multivariate case
-    for ( int k=1; k<=n; k++ )
-    {
-      g = swapvar(f,k,n); g = content(g);
-      // g = 1 || -1 : sqr-free, g poly : not sqr-free, g number : opt helps
-      if ( ! (g.isOne() || (-g).isOne() || getNumVars(g)==0 ) ) {
-        if ( opt==0 ) return 0;
-        else {
-          if ( SqrFreeTest(g,1) == 0 ) return 0;
-          g = swapvar(g,k,n);
-          f /=g ;
-        }
-      }
-    }
-    // Now f is primitive
-    n = level(f); // maybe less indeterminants
-    //    if ( totaldegree(f) <= 1 ) return 1;
-
-    // Let`s look if it is a Pth root
-    if ( getCharacteristic() > 0 )
-      for (int k=1; k<=n; k++ )
-      {
-        g=swapvar(f,k,n); g=g.deriv();
-        if ( ! g.isZero() ) break ;
-        else if ( k==n) return 0 ; // really is Pth root
-      }
-    g = f.deriv() ;
-    // Next: it would be best to have a *multivariate* gcd-test which returns
-    // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials )
-    g= gcd(f,g);
-    if ( g.isOne() || (-g).isOne() || (g==f) || (getNumVars(g)==0) ) return 1 ;
-    else return 0 ;
-  }
-  factoryError("libfac: ERROR: SqrFreeTest: we should never fall trough here!");
-  return 0;
-}
-
-///////////////////////////////////////////////////////////////
-// A uni/multivariate SqrFree routine.Works for polynomials  //
-// which don\'t have a constant as the content.              //
-// Works for charcteristic 0 and q=p^m                       //
-// returns a list of polys each of sqrfree, but gcd(f_i,f_j) //
-// needs not to be 1 !!!!!                                   //
-///////////////////////////////////////////////////////////////
-static CFFList
-SqrFreed( const CanonicalForm & r , const CanonicalForm &mipo=0)
-{
-  CanonicalForm h, g, f = r;
-  CFFList Outputlist;
-  int n = level(f);
-
-  DEBINCLEVEL(CERR, "SqrFreed");
-  DEBOUTLN(CERR, "Called with r= ", r);
-  if (getNumVars(f)==0 )
-  { // just a constant; return it
-    Outputlist= CFFactor(f,1);
-    return Outputlist ;
-  }
-
-// We look if we do have a content; if so, SqrFreed the content
-// and continue computations with pp(f)
-  for (int k=1; k<=n; k++)
-  {
-    if ((mipo.isZero())/*||(k!=1)*/)
-    {
-      g = swapvar(f,k,n); g = content(g);
-      if ( ! (g.isOne() || (-g).isOne() || (degree(g)==0) ))
-      {
-        g = swapvar(g,k,n);
-        DEBOUTLN(CERR, "We have a content: ", g);
-        Outputlist = myUnion(SqrFreeMV(g,mipo),Outputlist); // should we add a
-                                                // SqrFreeTest(g) first ?
-        DEBOUTLN(CERR, "Outputlist is now: ", Outputlist);
-        f /=g;
-        DEBOUTLN(CERR, "f is now: ", f);
-      }
-    }
-  }
-
-// Now f is primitive; Let`s look if f is univariate
-  if ( f.isUnivariate() )
-  {
-    DEBOUTLN(CERR, "f is univariate: ", f);
-    g = content(f);
-    if ( ! (g.isOne() || (-g).isOne() ) )
-    {
-      Outputlist= myappend(Outputlist,CFFactor(g,1)) ;
-      f /= g;
-    }
-    Outputlist = Union(sqrFree(f),Outputlist) ;
-    DEBOUTLN(CERR, "Outputlist after univ. sqrFree(f) = ", Outputlist);
-    DEBDECLEVEL(CERR, "SqrFreed");
-    return Outputlist ;
-  }
-
-// Linear?
-  if ( totaldegree(f) <= 1 )
-  {
-    Outputlist= myappend(Outputlist,CFFactor(f,1)) ;
-    DEBDECLEVEL(CERR, "SqrFreed");
-    return Outputlist ;
-  }
-
-// is it Pth root?
-  n=level(f); // maybe less indeterminants
-  g= f.deriv();
-  if ( getCharacteristic() > 0 && g.isZero() )
-  {  // Pth roots only apply to char > 0
-    for (int k=1; k<=n; k++)
-    {
-      if ((mipo.isZero())/*||(k!=1)*/)
-      {
-        g=swapvar(f,k,n) ;
-        g = g.deriv();
-
-        if ( ! g.isZero() )
-        { // can`t be Pth root
-          CFFList Outputlist2= SqrFreed(swapvar(f,k,n));
-          for (CFFListIterator inter=Outputlist2; inter.hasItem(); inter++)
-          {
-            Outputlist= myappend(Outputlist, CFFactor(swapvar(inter.getItem().factor(),k,n), inter.getItem().exp()));
-          }
-          return Outputlist;
-        }
-      }
-    }
-    // really is Pth power
-    DEBOUTLN(CERR, "f is a p'th root: ", f);
-    CFMap m;
-    g = compress(f,m);
-    if (mipo.isZero())
-      f = m(PthRoot(g));
-    else
-      f = m(PthRoot(g,mipo));
-    DEBOUTLN(CERR, "  that is       : ", f);
-    // now : Outputlist union ( SqrFreed(f) )^getCharacteristic()
-    Outputlist=myUnion(Powerup(SqrFreeMV(f),getCharacteristic()),Outputlist);
-    DEBDECLEVEL(CERR, "SqrFreed");
-    return Outputlist ;
-  }
-  g = f.deriv();
-  DEBOUTLN(CERR, "calculating gcd of ", f);
-  DEBOUTLN(CERR, "               and ", g);
-  h = gcd(f,pp(g));  h /= lc(h);
-  DEBOUTLN(CERR,"gcd(f,g)= ",h);
-  if ( (h.isOne()) || ( h==f) || ((-h).isOne()) || getNumVars(h)==0 )
-  { // no common factor
-    Outputlist= myappend(Outputlist,CFFactor(f,1)) ;
-    DEBOUTLN(CERR, "Outputlist= ", Outputlist);
-    DEBDECLEVEL(CERR, "SqrFreed");
-    return Outputlist ;
-  }
-  else
-  { // we can split into two nontrivial pieces
-    f /= h; // Now we have split the poly into f and h
-    g = lc(f);
-    if ( !g.isOne() && getNumVars(g) == 0 )
-    {
-       Outputlist= myappend(Outputlist,CFFactor(g,1)) ;
-       f /= g;
-    }
-    DEBOUTLN(CERR, "Split into f= ", f);
-    DEBOUTLN(CERR, "       and h= ", h);
-    // For char > 0 the polys f and h can have Pth roots; so we need a test
-    // Test is disabled because timing is the same
-
-//    if ( SqrFreeTest(f,0) )
-//      Outputlist= myappend(Outputlist,CFFactor(f,1)) ;
-//    else
-    Outputlist=myUnion(Outputlist, SqrFreeMV(f));
-//    if ( SqrFreeTest(h,0) )
-//      Outputlist= myappend(Outputlist,CFFactor(h,1)) ;
-//    else
-    Outputlist=myUnion(Outputlist,SqrFreeMV(h));
-    DEBOUTLN(CERR, "Returning list ", Outputlist);
-    DEBDECLEVEL(CERR, "SqrFreed");
-    return Outputlist ;
-  }
-  factoryError("libfac: ERROR: SqrFreed: we should never fall trough here!");
-  DEBDECLEVEL(CERR, "SqrFreed");
-  return Outputlist; // for safety purpose
-}
-
-///////////////////////////////////////////////////////////////
-// The user front-end for the SqrFreed routine.              //
-// Input can have a constant as content                      //
-///////////////////////////////////////////////////////////////
-CFFList
-SqrFreeMV( const CanonicalForm & r , const CanonicalForm & mipo )
-{
-  CanonicalForm g=icontent(r), f = r;
-  CFFList Outputlist, Outputlist2,tmpOutputlist;
-
-  DEBINCLEVEL(CERR, "SqrFreeMV");
-  DEBOUTLN(CERR,"Called with f= ", f);
-
-  // Take care of stupid users giving us constants
-  if ( getNumVars(f) == 0 )
-  { // a constant ; Exp==1 even if f==0
-      Outputlist= myappend(Outputlist,CFFactor(f,1));
-  }
-  else
-  {
-      // Now we are sure: we have a nonconstant polynomial
-      g = lc(f);
-      while ( getNumVars(g) != 0 ) g=content(g);
-      if ( ! g.isOne() ) Outputlist= myappend(Outputlist,CFFactor(g,1)) ;
-      f /= g;
-      if ( getNumVars(f) != 0 ) // a real polynomial
-      {
-        if (!mipo.isZero())
-        {
-          #if 0
-          Variable alpha=rootOf(mipo);
-          CanonicalForm ff=replacevar(f,mipo.mvar(),alpha);
-          tmpOutputlist=SqrFreeMV(ff,0);
-          ff=replacevar(f,alpha,mipo.mvar());
-          for ( CFFListIterator i=tmpOutputlist; i.hasItem(); i++ )
-          {
-            ff=i.getItem().factor();
-            ff /= ff.Lc();
-            ff=replacevar(ff,alpha,mipo.mvar());
-            Outputlist=myappend(Outputlist,CFFactor(ff,1));
-          }
-          #else
-          Outputlist=myUnion(SqrFreed(f,mipo),Outputlist) ;
-          #endif
-        }
-        else
-          Outputlist=myUnion(SqrFreed(f),Outputlist) ;
-      }
-  }
-  DEBOUTLN(CERR,"Outputlist = ", Outputlist);
-  for ( CFFListIterator i=Outputlist; i.hasItem(); i++ )
-    if ( getNumVars(i.getItem().factor()) > 0 )
-      Outputlist2.append(i.getItem());
-
-  DEBOUTLN(CERR,"Outputlist2 = ", Outputlist2);
-  DEBDECLEVEL(CERR, "SqrFreeMV");
-  return Outputlist2 ;
-}
-
-CFFList SqrFree(const CanonicalForm & r )
-{
-  CFFList outputlist, sqrfreelist = SqrFreeMV(r);
-  CFFListIterator i;
-  CanonicalForm elem;
-  int n=totaldegree(r);
-
-  DEBINCLEVEL(CERR, "SqrFree");
-
-  if ( sqrfreelist.length() < 2 )
-  {
-    DEBDECLEVEL(CERR, "SqrFree");
-    return sqrfreelist;
-  }
-  for ( int j=1; j<=n; j++ )
-  {
-    elem =1;
-    for ( i = sqrfreelist; i.hasItem() ; i++ )
-    {
-      if ( i.getItem().exp() == j ) elem *= i.getItem().factor();
-    }
-    if ( !(elem.isOne()) ) outputlist.append(CFFactor(elem,j));
-  }
-  elem=1;
-  for ( i=outputlist; i.hasItem(); i++ )
-    if ( getNumVars(i.getItem().factor()) > 0 )
-      elem*= power(i.getItem().factor(),i.getItem().exp());
-  elem= r/elem;
-  outputlist.insert(CFFactor(elem,1));
-
-  DEBOUTLN(CERR, "SqrFree returns list:", outputlist);
-  DEBDECLEVEL(CERR, "SqrFree");
-  return outputlist;
-}
Index: ctory/libfac/factor/SqrFree.h
===================================================================
--- factory/libfac/factor/SqrFree.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,13 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-///////////////////////////////////////////////////////////////////////////////
-#ifndef SQRFREE_H
-#define SQRFREE_H
-
-/*BEGINPUBLIC*/
-// CFFList SqrFree( const CanonicalForm & f ) ;
-CFFList SqrFreeMV( const CanonicalForm & f , const CanonicalForm & mipo=0) ;
-/*ENDPUBLIC*/
-int     SqrFreeTest( const CanonicalForm & r, int opt=1) ;
-CFFList SqrFree( const CanonicalForm & f ) ;
-#endif /* SQRFREE_H */
Index: ctory/libfac/factor/Truefactor.cc
===================================================================
--- factory/libfac/factor/Truefactor.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,423 +1,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-///////////////////////////////////////////////////////////////////////////////
-// Factory - Includes
-#include <factory.h>
-#ifndef NOSTREAMIO
-#ifdef HAVE_IOSTREAM
-#include <iostream>
-#define OSTREAM std::ostream
-#define ISTREAM std::istream
-#define CERR std::cerr
-#define CIN std::cin
-#elif defined(HAVE_IOSTREAM_H)
-#include <iostream.h>
-#define OSTREAM ostream
-#define ISTREAM istream
-#define CERR cerr
-#define CIN cin
-#endif
-#endif
-// Factor - Includes
-#include "tmpl_inst.h"
-#include "helpstuff.h"
-// some CC's need this:
-#include "Truefactor.h"
-
-#ifdef TRUEFACTORDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-
-#include <libfac/factor/debug.h>
-#include "timing.h"
-
-int hasAlgVar(const CanonicalForm &f, const Variable &v)
-{
-  if (f.inBaseDomain()) return 0;
-  if (f.inCoeffDomain())
-  {
-    if (f.mvar()==v) return 1;
-    return hasAlgVar(f.LC(),v);
-  }
-  if (f.inPolyDomain())
-  {
-    if (hasAlgVar(f.LC(),v)) return 1;
-    for( CFIterator i=f; i.hasTerms(); i++)
-    {
-      if (hasAlgVar(i.coeff(),v)) return 1;
-    }
-  }
-  return 0;
-}
-
-int hasVar(const CanonicalForm &f, const Variable &v)
-{
-  if (f.inBaseDomain()) return 0;
-  if (f.inCoeffDomain())
-  {
-    if (f.mvar()==v) return 1;
-    return hasAlgVar(f.LC(),v);
-  }
-  if (f.inPolyDomain())
-  {
-    if (f.mvar()==v) return 1;
-    if (hasVar(f.LC(),v)) return 1;
-    for( CFIterator i=f; i.hasTerms(); i++)
-    {
-      if (hasVar(i.coeff(),v)) return 1;
-    }
-  }
-  return 0;
-}
-
-int hasAlgVar(const CanonicalForm &f)
-{
-  if (f.inBaseDomain()) return 0;
-  if (f.inCoeffDomain())
-  {
-    if (f.level()!=0)
-    {
-      //CERR << "hasAlgVar:" << f.mvar() <<"\n";
-      return 1;
-    }
-    return hasAlgVar(f.LC());
-  }
-  if (f.inPolyDomain())
-  {
-    if (hasAlgVar(f.LC())) return 1;
-    for( CFIterator i=f; i.hasTerms(); i++)
-    {
-      if (hasAlgVar(i.coeff())) return 1;
-    }
-  }
-  return 0;
-}
-
-///////////////////////////////////////////////////////////////
-// generate all different k-subsets of the set with n        //
-// elements and return them in returnlist.                   //
-///////////////////////////////////////////////////////////////
-static void
-combinat( int k, int n, List<IntList> & returnlist ){
-  ListIntList ListofLists;
-  IntList intermediate,intermediate2;
-  int value,j;
-
-  if ( k == 1 ){                     // k=1
-    for ( j=1; j<=n; j++)
-      returnlist.append( IntList(j) );
-  }
-  else{                              // k-1 --> k
-    combinat(k-1,n,returnlist);  // generate (k-1,n)
-    for ( ListIntListIterator l=returnlist; l.hasItem(); l++ ){
-      intermediate = l.getItem();
-      value = intermediate.getLast();
-      if ( value != n )
-        for ( j=value+1; j<=n; j++ ){
-          intermediate2 = intermediate; intermediate2.append(j);
-          ListofLists.append( intermediate2 );
-        }
-    }
-    returnlist = ListofLists;
-  }
-}
-
-///////////////////////////////////////////////////////////////
-// Return the CanonicalForm number nr in  Factorlist.        //
-///////////////////////////////////////////////////////////////
-static CanonicalForm
-getItemNr(int nr, const CFFList & Factorlist ){
-  ListIterator<CFFactor> i=Factorlist;
-  int Nr=nr;
-
-  for ( Nr=1; Nr<nr; Nr++ ) i++;
-  return i.getItem().factor();
-}
-
-///////////////////////////////////////////////////////////////
-// Generate all sets of m factors out of LiftedFactors list. //
-///////////////////////////////////////////////////////////////
-static CFFList
-combine( int m, const CFFList & LiftedFactors ){
-  CFFList result;
-  ListIntList CombinatList;
-  CanonicalForm intermediate;
-
-  combinat(m, LiftedFactors.length(), CombinatList);
-  for ( ListIntListIterator j=CombinatList ; j.hasItem(); j++ ){
-    intermediate=1;
-    for ( IntListIterator k=j.getItem(); k.hasItem(); k++ )
-      intermediate *= getItemNr(k.getItem(), LiftedFactors);
-    if (!hasAlgVar(intermediate))
-    result.append(CFFactor(intermediate,1));
-  }
-  return result;
-}
-
-///////////////////////////////////////////////////////////////
-// Remove element elem from the list L.                      //
-///////////////////////////////////////////////////////////////
-static CFFList
-Remove_from_List( const CFFList & L, const CanonicalForm & elem ){
-  CFFList Returnlist;
-
-  DEBOUTLN(CERR, "Remove_from_List called with L= ",L);
-  DEBOUTLN(CERR, "                     and  elem= ",elem);
-  for ( ListIterator<CFFactor> i = L ; i.hasItem(); i++)
-    if ( i.getItem().factor() != elem )
-      Returnlist.append( i.getItem() );
-
-  return Returnlist;
-}
-
-///////////////////////////////////////////////////////////////
-// Here we solve:          G= F mod ( P, S^h )               //
-///////////////////////////////////////////////////////////////
-static CanonicalForm
-Multmod_power( const CanonicalForm & F, const SFormList & Substituionlist, int h, int levelF){
-  CanonicalForm G;
-
-  G= change_poly(F, Substituionlist, 0);
-  G= mod_power(G, h, levelF);
-  G= change_poly(G, Substituionlist, 1);
-
-  return G;
-}
-
-///////////////////////////////////////////////////////////////
-// Determine the right degree for the list of combinations   //
-// of factors, i.e. delete any element from list CombL which //
-// degree in the main variable levelU exceeeds degU.         //
-///////////////////////////////////////////////////////////////
-static CFFList
-Rightdegree( const CFFList & CombL, int degU, int levelU ){
-  CFFList Returnlist;
-  CFFactor factor;
-
-  for ( ListIterator<CFFactor> i= CombL; i.hasItem(); i++ ){
-    factor= i.getItem();
-    if ( degree(factor.factor(), levelU) <= degU )
-      Returnlist.append(factor);
-  }
-
-  return Returnlist;
-}
-
-///////////////////////////////////////////////////////////////
-// We have properly lifted all the specialized factors. See  //
-// which one works.                                          //
-// We use the (modified) algorithm TRUEFACTORS given by      //
-// Paul S. Wang and Linda Preiss Rothschild:                 //
-// Factoring Multivariate Polynomials Over the Integers      //
-// Math. Comp. V29 Nr131 (July 1975) p. 935-950              //
-///////////////////////////////////////////////////////////////
-CFFList
-Truefactors( const CanonicalForm Ua, int levelU, const SFormList & SubstitutionList, const CFFList & PiList){
-  CanonicalForm U=Ua,a,b,Y;
-  CFFactor factor;
-  CFFList L,FAC,E_all;
-  int c,r = PiList.length(),degU, onemore,M, h = subvardegree(Ua,levelU) + 1;
-  ListIterator<CFFactor> i;
-
-  //CERR << "SubstitutionList="<< SubstitutionList<<"\n";
-// step 1: simply test the generated factors alone
-  for ( i= PiList; i.hasItem();i++){
-    factor = i.getItem();
-    //CanonicalForm test_f=change_poly(factor.factor(),SubstitutionList,0);
-    CanonicalForm test_f=factor.factor();
-    //CERR <<"f:" << factor.factor() << " -> test_f:"<<test_f <<"\n";
-    //CERR << "           1:" << change_poly(factor.factor(),SubstitutionList,1) <<"\n";
-    c= mydivremt(U,test_f,a,b);
-    if (  c  && b == U.genZero() && !hasAlgVar(test_f))
-    // factor.getFactor() divides U
-    {
-      //CERR << " teilt:" << test_f <<"\n";
-      U= a;
-      FAC.append(factor);
-    }
-    else{
-      //CERR << " teilt nicht:" << test_f <<"\n";
-      L.append(factor);
-    }
-  }
-  DEBOUTLN(CERR,"Truefactors: (step1) L  = ", L);
-  DEBOUTLN(CERR,"                     FAC= ", FAC);
-
-// step 2: Do we have to check combinations?
-  degU = L.length();
-  if ( degU == 0 ) // No elements: Return
-    return FAC;
-  else
-    if ( degU < 4 ){ // Less then four elements: no combinations possible
-      FAC.append( CFFactor(U,1) );
-      return FAC;
-    }
-    else {
-      M = 1; r = r - FAC.length(); degU = degree(U, levelU)/2;
-    }
-
-  DEBOUTLN(CERR,"Truefactors: (step2) M   = ", M);
-  DEBOUTLN(CERR,"                     r   = ", r);
-  DEBOUTLN(CERR,"                     degU= ", degU);
-
-// Now do the real work!
-// Test all the combinations of possible factors.
-
-  onemore=1;
-// steps 3 to 6
-  while (1)
-  {
-    // step 3 iff onemore == 1
-    if ( onemore ) M+= 1;  else onemore = 1;
-    // step 4
-    if ( U.isOne() ) break; // Return FAC
-    if ( ( r == 1 ) || ( M >= ( r-1 ) ) || ( M > degU ) )
-    {
-      FAC.append( CFFactor(U,1) );
-      break; // Return FAC union {U}
-    }
-    // step 5
-    E_all = combine(M, L); // generate all combinations of M elements from L
-    DEBOUTLN(CERR,"Truefactors: (step5) E_all= ", E_all);
-    // select combinations with the degree not to exceed degU:
-    E_all = Rightdegree( E_all, degU, levelU );
-    DEBOUTLN(CERR,"Truefactors: (step5) E_all(Rightdegree)= ", E_all);
-    if ( E_all.length() == 0 )
-    {
-      FAC.append( CFFactor(U,1) );
-      break; // Return FAC union {U}
-    }
-    for ( i=E_all; i.hasItem(); i++)
-    {
-      factor = i.getItem();
-      Y = Multmod_power( factor.factor(), SubstitutionList, h, levelU);
-      DEBOUTLN(CERR, "Truefactors: (step6) Testing Y  = ", Y);
-      c = mydivremt(U,Y,a,b);
-      //      if (  c  && b == U.genZero()) { // Y divides U
-      if ( c && b.isZero() )
-      {
-        DEBOUT(CERR,"Truefactors: (step6): ",Y );
-        DEBOUTLN(CERR, "  divides  ",U);
-        U = a;
-        FAC.append(Y); // Y is a real factor
-        onemore = 0;
-        degU = degree(U, levelU)/2; // new degU
-        // L = L \ {factor}
-        // Hier ist noch etwas faul; wir muessen (f=prod(f_i)) die f_i
-        // entfernen und nicht f!
-        L = Remove_from_List( L, factor.factor() );
-        r -= 1;
-        // delete from L any element with degree greater than degU
-        L = Rightdegree( L, degU, levelU );
-      }
-    }
-  }
-  return FAC;
-}
-
-///////////////////////////////////////////////////////////////
-// Check if poly f is in Fp (returns true) or in Fp(a)       //
-///////////////////////////////////////////////////////////////
-static bool is_in_Fp( const CanonicalForm & f )
-{
-  if ( f.inCoeffDomain() )
-    return f.inBaseDomain() ;
-  else
-  {
-    CFIterator i=f;
-    bool ok=true;
-    while ( ok && i.hasTerms() )
-    {
-      ok = is_in_Fp( i.coeff() );
-      i++ ;
-    }
-    return ok;
-  }
-}
-
-///////////////////////////////////////////////////////////////
-// We have factors which possibly lie in an extension of the //
-// base field. If one of these is not over the base field,   //
-// find its norm by (the theoretically handicapped method    //
-// of) multiplying by other elements.                        //
-///////////////////////////////////////////////////////////////
-CFFList TakeNorms(const CFFList & PiList)
-{
-  CFFList CopyPossibleFactors, PossibleFactors, TrueFactors;
-  CFFListIterator i;
-  CFFactor Factor;
-  CanonicalForm intermediate;
-  ListIntList CombinatList;
-  ListIntListIterator j;
-  IntListIterator k;
-
-  // First check if the factors in PiList already lie in Fp-Domain
-  for ( i=PiList; i.hasItem(); i++ )
-  {
-    Factor = i.getItem();
-    if ( is_in_Fp( Factor.factor() ) )
-      TrueFactors.append(Factor);
-    else
-      PossibleFactors.append(Factor);
-  }
-  // Now we have to check if combinations of the remaining factors
-  // (now in PossibleFactors) do lie in Fp-Domain
-  if ( PossibleFactors.length() > 0 ) // there are (at least two) items
-  {
-    int n=2;
-    if ( PossibleFactors.length() < n )  // a little check
-    {
-      factoryError("libfac: ERROR: TakeNorms less then two items remaining!");
-    }
-    while ( n < PossibleFactors.length() )
-    {
-      // generate all combinations of n elements
-      combinat(n, PossibleFactors.length(), CombinatList);
-      for ( j=CombinatList ; j.hasItem(); j++ )
-      {
-        intermediate=1;
-        for ( k=j.getItem(); k.hasItem(); k++ )
-          intermediate *= getItemNr( k.getItem(), PossibleFactors );
-        if ( is_in_Fp( intermediate ) )
-        {
-          TrueFactors.append(intermediate); // found a true factor
-          CopyPossibleFactors=PossibleFactors; // save list
-          for ( k=j.getItem(); k.hasItem(); k++ )
-            //remove combined factors from PossibleFactors
-            PossibleFactors=Remove_from_List(PossibleFactors,
-                                getItemNr( k.getItem(), CopyPossibleFactors ));
-          n-=1; // look for the same number of combined factors:
-          break;
-        }
-        else
-        {
-          //CERR << "Schade!" << "\n";
-        }
-        DEBOUT(CERR, "Truefactor: Combined ", n);
-        DEBOUTLN(CERR, " factors to: ", intermediate);
-      }
-      n += 1;
-    }
-  // All remaining factors in PossibleFactors multiplied
-  // should lie in Fp domain
-    if ( PossibleFactors.length() >=1 )
-    {
-      for ( i=PossibleFactors; i.hasItem(); i++ )
-        intermediate *= i.getItem().factor();
-      // a last check:
-      if ( is_in_Fp(intermediate) )
-      {
-        TrueFactors.append(CFFactor(intermediate,1));
-      }
-      else
-      {
-        factoryError("libfac: TakeNorms: somethings wrong with remaining factors!");
-      }
-    }
-  }
-  return TrueFactors;
-}
-
-////////////////////////////////////////////////////////////
Index: ctory/libfac/factor/Truefactor.h
===================================================================
--- factory/libfac/factor/Truefactor.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,10 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-///////////////////////////////////////////////////////////////////////////////
-#ifndef TRUEFACTOR_H
-#define TRUEFACTOR_H
-
-CFFList Truefactors( const CanonicalForm Ua, int levelU, const SFormList & SubstitutionList, const CFFList & PiList);
-CFFList TakeNorms(const CFFList & PiList);
-#endif /* TRUEFACTOR_H */
-
Index: ctory/libfac/factor/class.cc
===================================================================
--- factory/libfac/factor/class.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,40 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-
-// #pragma implementation
-
-#include "class.h"
-
-template <class T>
-Substitution<T>& Substitution<T>::operator= ( const Substitution<T>& f )
-{
-    if ( this != &f ) {
-	_factor = f._factor;
-	_exp = f._exp;
-    }
-    return *this;
-}
-
-template <class T>
-Substitution<T>& Substitution<T>::operator= ( const T & f )
-{
-    _factor = f;
-    _exp = 1;
-    return *this;
-}
-
-template <class T>
-int operator== ( const Substitution<T> &f1, const Substitution<T> &f2 )
-{
-    return (f1.exp() == f2.exp()) && (f1.factor() == f2.factor());
-}
-
-#ifndef NOSTREAMIO
-template <class T>
-void Substitution<T>::print ( OSTREAM& s ) const
-{
-	s << "(" << factor() << ")^" << exp();
-}
-#endif
-
Index: ctory/libfac/factor/class.h
===================================================================
--- factory/libfac/factor/class.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,57 +1,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-///////////////////////////////////////////////////////////////////////////////
-#ifndef INCL_CLASS_H
-#define INCL_CLASS_H
-
-// #pragma interface
-
-#ifndef NOSTREAMIO
-#ifdef HAVE_IOSTREAM
-#include <iostream>
-#define OSTREAM std::ostream
-#define ISTREAM std::istream
-#elif defined(HAVE_IOSTREAM_H)
-#include <iostream.h>
-#define OSTREAM ostream
-#define ISTREAM istream
-#endif
-#endif
-
-template <class T>
-class Substitution {
-private:
-    T _factor;
-    T _exp;
-public:
-    Substitution() : _factor(1), _exp(0) {}
-    Substitution( const Substitution<T> & f ) : _factor(f._factor), _exp(f._exp) {}
-    Substitution( const T & f, const T & e ) : _factor(f), _exp(e) {}
-    Substitution( const T & f ) : _factor(f), _exp(1) {}
-    ~Substitution() {}
-    Substitution<T>& operator= ( const Substitution<T>& );
-    Substitution<T>& operator= ( const T& );
-    T factor() const { return _factor; }
-    T exp() const { return _exp; }
-//     T value() const { return power( _factor, _exp ); }
-//     Factor<T>& operator+= ( int i ) { _exp += i; return *this; }
-//     Factor<T>& operator*= ( int i ) { _exp *= i; return *this; }
-//     Substitution<T>& operator*= ( const T & f ) { _factor *= f; _exp *= f; return *this; }
-#ifndef NOSTREAMIO
-    void print ( OSTREAM& ) const;
-    friend OSTREAM& operator<< ( OSTREAM & os, const Substitution<T> & f )
-    {
-	f.print( os );
-	return os;
-    }
-#endif
-};
-template <class T>
-int operator== ( const Substitution<T>&, const Substitution<T>& );
-
-// #ifdef IMPL_CLASS_H
-// #include "class.cc"
-// #endif
-
-#endif /* INCL_CLASS_H */
-
Index: ctory/libfac/factor/debug.h
===================================================================
--- factory/libfac/factor/debug.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,61 +1,0 @@
-////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////
-// It is possible to include this file multiple times for different 
-// settings of FACDEBUG and/or DEBUGOUTPUT
-
-#undef ASSERT
-#undef __ASSERT
-#undef STICKYASSERT
-#undef DEBOUT
-#undef DEBOUTLN
-#undef DEBINCLEVEL
-#undef DEBDECLEVEL
-#undef DEBOUTSL
-#undef DEBOUTMSG
-#undef DEBOUTNL
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef NDEBUG
-#define ASSERT(ignore1,ignore2)((void)0)
-#else
-#define ASSERT(expression,message) \
-((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__)))
-#endif
-
-#define STICKYASSERT(expression,message) \
-((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__)))
-
-#define __ASSERT(expression, message, file, line)  \
-(fprintf( stderr, "error: %s\n%s:%u: failed assertion `%s'\n", \
- message, file, line, expression ), abort(), 0 )
-
-#ifdef DEBUGOUTPUT
-void deb_inc_level(); // use this helper routines from factory
-void deb_dec_level(); // use this helper routines from factory
-extern char * deb_level_msg; // from factory
-#define DEBINCLEVEL(stream,msg) \
-(stream << "\n" << deb_level_msg << "entering << " << msg << " >>" << "\n", deb_inc_level())
-#define DEBDECLEVEL(stream,msg) \
-(deb_dec_level(), stream << deb_level_msg << "leaving << " << msg << " >>" << "\n")
-#define DEBOUTSL(stream) \
-(stream << deb_level_msg, stream.flush())
-#define DEBOUT(stream,msg,object) \
-(stream << deb_level_msg << msg << object, stream.flush())
-#define DEBOUTLN(stream,msg,object) \
-(stream << deb_level_msg << msg << object << "\n")
-#define DEBOUTMSG(stream,msg) \
-(stream << deb_level_msg << msg << "\n")
-#define DEBOUTNL(stream) \
-(stream << "\n")
-#else
-#define DEBINCLEVEL(stream,msg)
-#define DEBDECLEVEL(stream,msg)
-#define DEBOUTSL(stream)
-#define DEBOUT(stream,msg,object)
-#define DEBOUTLN(stream,msg,object)
-#define DEBOUTMSG(stream,msg)
-#define DEBOUTNL(stream)
-#endif
-
Index: ctory/libfac/factor/helpstuff.cc
===================================================================
--- factory/libfac/factor/helpstuff.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,173 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-// FACTORY - Includes
-#include <factory.h>
-// Factor - Includes
-#include "tmpl_inst.h"
-// some CC's need this:
-#include "helpstuff.h"
-
-bool
-mydivremt ( const CanonicalForm& f, const CanonicalForm& g, CanonicalForm& a, CanonicalForm& b )
-{
-  bool retvalue;
-  CanonicalForm aa,bb;
-  retvalue = divremt(f,g,a,bb);
-  aa= f-g*a;
-  if ( aa==bb ) { b=bb; }
-  else { b=aa; }
-  return retvalue;
-}
-
-// Now some procedures used in SqrFree and in Factor
-///////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////
-// We have to include a version of <CFFList>.append(CFFactor)//
-// and Union( CFFList, CFFList)                              //
-// because we have to look for multiplicities in SqrFree.    //
-// e.g.: SqrFree( f^3 ) with char <> 3                       //
-///////////////////////////////////////////////////////////////
-CFFList
-myappend( const CFFList & Inputlist, const CFFactor & TheFactor)
-{
-  CFFList Outputlist ;
-  CFFactor copy;
-  CFFListIterator i;
-  int exp=0;
-
-  for ( i=Inputlist ; i.hasItem() ; i++ )
-  {
-    copy = i.getItem();
-    if ( copy.factor() == TheFactor.factor() )
-      exp += copy.exp();
-    else
-      Outputlist.append(copy);
-  }
-  Outputlist.append( CFFactor(TheFactor.factor(), exp + TheFactor.exp()));
-  return Outputlist;
-}
-
-CFFList
-myUnion(const CFFList & Inputlist1,const CFFList & Inputlist2)
-{
-  CFFList Outputlist;
-  CFFListIterator i;
-
-  for ( i=Inputlist1 ; i.hasItem() ; i++ )
-    Outputlist = myappend(Outputlist, i.getItem() );
-  for ( i=Inputlist2 ; i.hasItem() ; i++ )
-    Outputlist = myappend(Outputlist, i.getItem() );
-
-  return Outputlist;
-}
-
-int
-Powerup( const int base , const int exp)
-{
-  int retvalue=1;
-  if ( exp == 0 )  return retvalue ;
-  else for ( int i=1 ; i <= exp; i++ ) retvalue *= base ;
-
-  return retvalue;
-}
-
-// Now some procedures used in MVMultiHensel and in Truefactors
-///////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////
-// mod_power: Return f mod I^k, where I is now the ideal     //
-// {x_1, .. x_(level(f)-1)}. Computation mod I^k is simply   //
-// done by dropping all the terms of degree >= k in          //
-// x_1, .. x_(level(f)-1); e.g. x_1*x_2 == 0 mod I^2 .       //
-// modpower: the real work is done here; called by mod_power //
-///////////////////////////////////////////////////////////////
-static void
-modpower( const CanonicalForm & f, int k , int td,
-          const CanonicalForm & t, CanonicalForm & result)
-{
-
-  if ( td >= k ) return;
-  if ( getNumVars(f) == 0 ) result += f*t;
-  else{
-    Variable x(level(f));
-    for ( CFIterator i=f; i.hasTerms(); i++)
-      modpower(i.coeff(),k,td+i.exp(),t*power(x,i.exp()),result);
-  }
-}
-
-CanonicalForm
-mod_power( const CanonicalForm & f, int k, int levelU)
-{
-  CanonicalForm result,dummy;
-  Variable x(levelU);
-
-  if ( levelU > level(f) )
-    modpower(f,k,0,1,result);
-  else
-  {
-    for ( CFIterator i=f; i.hasTerms(); i++)
-    {
-      dummy = 0;
-      modpower(i.coeff(),k,0,1,dummy);
-      result += dummy * power(x,i.exp());
-// the following works, but is slower
-//    int degf=degree(f);
-//    for ( int i=0; i<=degf;i++){
-//      result+= mod_power(f[i],k,levelU)*power(x,i);
-    }
-  }
-
-  return result;
-}
-
-///////////////////////////////////////////////////////////////
-// Return the deg of F in the Variables x_1,..,x_(levelF-1)  //
-///////////////////////////////////////////////////////////////
-int
-subvardegree( const CanonicalForm & F, int levelF )
-{
-  int n=0,m=degree(F,levelF),newn=0;
-
-  for ( int k=0; k<=m; k++ )
-  {
-    newn = totaldegree( F[k] );
-    if ( newn > n ) n=newn;
-  }
-  return n;
-}
-
-///////////////////////////////////////////////////////////////
-// Change poly:  x_i <- x_i +- a_i    for i= 1,..,level(f)-1 //
-///////////////////////////////////////////////////////////////
-CanonicalForm
-change_poly( const CanonicalForm & f , const SFormList & Substitutionlist ,int directionback )
-{
-  CanonicalForm F=f,g,k;
-  int level_i;
-//  Variable x;
-
-  for ( SFormListIterator i=Substitutionlist; i.hasItem(); i++)
-  {
-  // now we can access: i.getItem().factor()  -> level(~) gives x_i
-  //                    i.getItem().exp()     -> gives a_i
-  // ==> g = x_i ; k = a_i
-    level_i=level(i.getItem().factor());
-    g = power(
-                       Variable(level_i),1
-                       );
-    k= i.getItem().exp();
-    if ( directionback )
-    {
-      if ( degree(F, level_i) != 0 )
-        F=F(g-k, level_i /*level(i.getItem().factor())*/); // x_i <-- x_i - a_i
-    }
-    else
-    {
-      if ( degree(F, level_i) != 0 )
-        F=F(g+k, level_i /*level(i.getItem().factor())*/); // x_i <-- x_i +a_i
-    }
-  }
-
-  return F;
-}
Index: ctory/libfac/factor/helpstuff.h
===================================================================
--- factory/libfac/factor/helpstuff.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,28 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-#ifndef HELPSTUFF_H
-#define HELPSTUFF_H
-bool mydivremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
-///////////////////////////////////////////////////////////////
-// Now some procedures used in MVMultiHensel and in Truefactors
-///////////////////////////////////////////////////////////////
-CanonicalForm mod_power( const CanonicalForm & f, int k, int levelU);
-int subvardegree( const CanonicalForm & F, int levelF );
-CanonicalForm change_poly( const CanonicalForm & f , const SFormList & Substitutionlist, int directionback );
-
-///////////////////////////////////////////////////////////////
-// Now some procedures used in SqrFree and in Factor
-///////////////////////////////////////////////////////////////
-CFFList myappend( const CFFList & Inputlist, const CFFactor & TheFactor) ;
-CFFList myUnion(const CFFList & Inputlist1,const CFFList & Inputlist2);
-int Powerup( const int base , const int exp=1);
-inline int min ( const int a, const int b ){
-  return (a<=b ? a:b);
-}
-inline int max ( const int a, const int b ){
-  return (a>b ? a:b);
-}
-
-#endif /* HELPSTUFF_H */
-
Index: ctory/libfac/factor/homogfactor.cc
===================================================================
--- factory/libfac/factor/homogfactor.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,199 +1,0 @@
-////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////
-// FACTORY - Includes
-#include <factory.h>
-#ifdef HAVE_IOSTREAM
-#include <iostream>
-#define OSTREAM std::ostream
-#define ISTREAM std::istream
-#define CERR std::cerr
-#define CIN std::cin
-#elif defined(HAVE_IOSTREAM_H)
-#include <iostream.h>
-#define OSTREAM ostream
-#define ISTREAM istream
-#define CERR cerr
-#define CIN cin
-#endif
-
-// Factor - Includes
-#include "tmpl_inst.h"
-#include "Factor.h"
-// some CC's need it:
-#include "homogfactor.h"
-
-void out_cf(char *s1,const CanonicalForm &f,char *s2);
-
-#ifdef HFACTORDEBUG
-#  define DEBUGOUTPUT
-#else
-#  undef DEBUGOUTPUT
-#endif
-
-#include <libfac/factor/debug.h>
-#include "timing.h"
-TIMING_DEFINE_PRINT(hfactorize_time)
-
-#if 0
-///////////////////////////////////////////////////////////////
-// get_Terms: Split the polynomial in the containing terms.  //
-// getTerms: the real work is done here.                     // 
-///////////////////////////////////////////////////////////////
-static void 
-getTerms( const CanonicalForm & f, const CanonicalForm & t, CFList & result ){
-
-  if ( getNumVars(f) == 0 ) result.append(f*t);
-  else{ 
-    Variable x(level(f));
-    for ( CFIterator i=f; i.hasTerms(); i++ )
-      getTerms( i.coeff(), t*power(x,i.exp()), result);
-  }
-}
-
-CFList 
-get_Terms( const CanonicalForm & f ){
-  CFList result,dummy,dummy2;
-  CFIterator i;
-  CFListIterator j;
-
-  if ( getNumVars(f) == 0 ) result.append(f);
-  else{
-    Variable _x(level(f));
-    for ( i=f; i.hasTerms(); i++ ){
-      getTerms(i.coeff(), 1, dummy);
-      for ( j=dummy; j.hasItem(); j++ )
-	result.append(j.getItem() * power(_x, i.exp()));
-
-      dummy= dummy2; // have to initalize new
-    }
-  }
-  return result;
-}
-#endif
-
-#if 0
-///////////////////////////////////////////////////////////////
-// is_homogeneous returns 1 iff f is homogeneous, 0 otherwise//
-///////////////////////////////////////////////////////////////
-bool
-is_homogeneous( const CanonicalForm & f){
-  CFList termlist= get_Terms(f);
-  CFListIterator i;
-  int deg= totaldegree(termlist.getFirst());
-
-  for ( i=termlist; i.hasItem(); i++ )
-    if ( totaldegree(i.getItem()) != deg ) return 0;
-  return 1;
-  // now: return f.isHomogeneous();
-}
-#endif
-
-#if 0
-///////////////////////////////////////////////////////////////
-// get_max_degree_Variable returns Variable with             //
-// highest degree. We assume f is *not* a constant!          //
-///////////////////////////////////////////////////////////////
-static Variable
-get_max_degree_Variable(const CanonicalForm & f){
-  ASSERT( ( ! f.inCoeffDomain() ), "no constants" );
-  int max=0, maxlevel=0, n=level(f);
-  for ( int i=1; i<=n; i++ )
-    if (degree(f,Variable(i)) >= max) {
-      max= degree(f,Variable(i)); maxlevel= i;
-    }
-  return Variable(maxlevel);
-}
-#endif
-
-#if 0
-///////////////////////////////////////////////////////////////
-// homogenize homogenizes f with Variable x                  //
-///////////////////////////////////////////////////////////////
-static CanonicalForm
-homogenize( const CanonicalForm & f, const Variable & x){
-  CFList Newlist, Termlist= get_Terms(f); 
-  int maxdeg=totaldegree(f), deg;
-  CFListIterator i;
-  CanonicalForm elem, result=f.genZero();
-  
-  for (i=Termlist; i.hasItem(); i++){
-    elem= i.getItem();
-    deg = totaldegree(elem);
-    if ( deg < maxdeg )
-      Newlist.append(elem * power(x,maxdeg-deg));
-    else
-      Newlist.append(elem);
-  }
-  for (i=Newlist; i.hasItem(); i++) // rebuild 
-    result += i.getItem();
-    
-  return result;
-}
-#endif
-
-// we assume g is square-free
-CFFList
-HomogFactor( const CanonicalForm & g, const CanonicalForm  & minpoly, const int Mainvar )
-{
-  DEBINCLEVEL(CERR, "HomogFactor");
-  Variable xn = get_max_degree_Variable(g);
-  //out_cf("HomogFactor:",g,"\n");
-  int d_xn = degree(g,xn);
-  CanonicalForm F = g(1,xn);
-
-  DEBOUTLN(CERR, "xn= ", xn);
-  DEBOUTLN(CERR, "d_xn=   ", d_xn);
-  DEBOUTLN(CERR, "F= ", F);  
-  //out_cf("HomogFactor:subst ",F,"\n");
-
-  // should we do this for low degree polys g ? e.g. quadratic?
-  // 
-  CFFList Homoglist;
-  CFFListIterator j;
-  if (minpoly.isZero())
-    Homoglist = factorize(F, 1);
-  else
-  {
-    CFFList Intermediatelist;
-    CFMap n;
-    Intermediatelist = Factorized(compress(F,n), minpoly, Mainvar);
-    for ( j=Intermediatelist; j.hasItem(); j++ )
-      Homoglist.append(CFFactor( n(j.getItem().factor()), j.getItem().exp()) );
-  }
-  // Now we have uncompressed factors in Homoglist
-  DEBOUTLN(CERR, "F factors as: ", Homoglist);
-  CFFList Unhomoglist;
-  CanonicalForm unhomogelem;
-  if ((!(minpoly.isZero())) &&(getCharacteristic() == 0) )
-  {
-    for ( j=Homoglist; j.hasItem(); j++ )
-    {
-      // assume that minpoly.level() < level of all "real" variables of g
-      DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor()); 
-      unhomogelem= homogenize(j.getItem().factor(),xn,
-                         Variable(minpoly.level()+1),g.mvar());
-      DEBOUTLN(CERR, "      that is ", unhomogelem);
-      Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp()));
-      d_xn -= degree(unhomogelem,xn)*j.getItem().exp();
-    }
-  }
-  else
-  {
-    for ( j=Homoglist; j.hasItem(); j++ )
-    {
-      DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor()); 
-      unhomogelem= homogenize(j.getItem().factor(),xn);
-      DEBOUTLN(CERR, "      that is ", unhomogelem);
-      //out_cf("unhomogelem:",unhomogelem,"\n");
-      Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp()));
-      d_xn -= degree(unhomogelem,xn)*j.getItem().exp();
-    }
-  }
-  DEBOUTLN(CERR, "Power of xn to append is ", d_xn);
-  if ( d_xn != 0 ) // have to append xn^(d_xn)
-    Unhomoglist.append(CFFactor(CanonicalForm(xn),d_xn));
-
-  DEBDECLEVEL(CERR, "HomogFactor");
-  return Unhomoglist;
-}
-
Index: ctory/libfac/factor/homogfactor.h
===================================================================
--- factory/libfac/factor/homogfactor.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,8 +1,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-///////////////////////////////////////////////////////////////////////////////
-#ifndef HFACTOR_H
-#define HFACTOR_H
-CFList  get_Terms( const CanonicalForm & f );
-CFFList HomogFactor( const CanonicalForm & g, const CanonicalForm  & minpoly, const int Mainvar );
-#endif /* HFACTOR_H */
Index: ctory/libfac/factor/interrupt.h
===================================================================
--- factory/libfac/factor/interrupt.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,22 +1,0 @@
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef INTERRUPT_H
-#define INTERRUPT_H
-// FACTORY - Includes
-#include <factory.h>
-// Factor - Includes
-#include "tmpl_inst.h"
-
-/*BEGINPUBLIC*/
-// Set this to a nonzero value to interrupt the computation
-extern int libfac_interruptflag;
-/*ENDPUBLIC*/
-
-inline int
-interrupt_handle( )
-{
-  if ( libfac_interruptflag ){ return 1; }
-  return 0;
-}
-
-#endif /* INTERRUPT_H */
Index: ctory/libfac/factor/test.cc
===================================================================
--- factory/libfac/factor/test.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,43 +1,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// factory - Includes
-//       (x+y+z)*(x+y-z)*(x-y+z)*(x-y-z)*x*y;
-#include <factory.h>
-// Factor - Includes
-#include "tmpl_inst.h"
-#include "Factor.h"
-#include "SqrFree.h"
-
-main()
-{
-    CanonicalForm f,g;
-    int charac;
-    CFFList Factorlist;
-    CFFactor copy;
-
-//    cout << " Characteristic = "; 
-    cin >> charac;
-    setCharacteristic(charac);
-    On(SW_SYMMETRIC_FF);
-    g=1;
-//    cout << " f = "; 
-    cin >> f;
-//    cout << " f = " << f  << endl;
-//    cout << " f(SqrFree)= " << endl;
-//    cout << SqrFree(f) << endl << endl;
-//cout << "gcd(f,f.deriv())= gcd(" << f << "," << f.deriv() << ")= " << gcd(f,f.deriv()) << endl;
-//cout << "gcd(f,f.deriv())= gcd(" << f << "," << f.deriv() << ")= " << gcd(f,f.deriv()) << endl;
-        Factorlist = Factorize( f );
-        cout << Factorlist ;//<< endl;
-// Ueberpruefen:
-    for ( CFFListIterator i=Factorlist ; i.hasItem(); i++){
-	copy = i.getItem();
-	if ( getNumVars(copy.factor()) > 0 )
-	     for ( int j=1; j<=copy.exp(); j++)
-	     g *= copy.factor();
-	else g *= copy.factor();
-    }
-    if ( (f-g) != f.genZero() ){
-	cerr << "\nList and f differ: f= " << f << "  g= " << g << endl;
-	cerr << "List= " << Factorlist << endl;
-    }
-}
Index: ctory/libfac/factor/timing.h
===================================================================
--- factory/libfac/factor/timing.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,94 +1,0 @@
-/* emacs edit mode for this file is -*- C++ -*- */
-
-/* It should be possible to include this file multiple times for different */
-/* settings of TIMING */
-
-#undef TIMING_START
-#undef TIMING_END
-#undef TIMING_END_AND_PRINT
-#undef TIMING_DEFINE_PRINT
-#undef TIMING_DEFINE_PRINTPROTO
-#undef TIMING_PRINT
-
-#ifdef TIMING
-#include <time.h>
-#if ! defined(WINNT) || defined(__GNUC__)
-#include <sys/times.h>
-#include <sys/param.h>
-#endif
-#ifndef NOSTREAMIO
-#ifdef HAVE_CSTDIO
-#include <cstdio>
-#else
-#include <stdio.h>
-#endif
-#endif
-
-// need to be adjusted on your machine:
-// the number of ticks per second: HZ
-#if ! defined (HZ) && defined (CLOCKS_PER_SEC)
-#define HZ CLOCKS_PER_SEC
-#endif
-#if ! defined (HZ)  && defined (CLK_TCK)
-#define HZ CLK_TCK
-#endif
-#ifndef HZ
-#ifdef sun
-#define HZ 60.0
-#else
-#define HZ 100.0
-#endif
-#endif
-
-#if defined(WINNT) && ! defined(__GNUC__)
-
-#define TIMING_START(t) { clock_t timing_ ## t ## _start, timing_ ## t ## _end; \
-  timing_ ## t ## _start = clock();
-#define TIMING_END(t) timing_ ## t ## _end = clock(); \
-timing_ ## t ## _time += timing_ ## t ## _end - timing_ ## t ## _start; }
-#define TIMING_END_AND_PRINT(t, msg) times( &timing_ ## t ## _end ); \
-  fprintf( stderr, "%s%.2f sec\n", msg, \
-	   float( timing_ ## t ## _end - timing_ ## t ## _start ) / HZ ); \
-  timing_ ## t ## _time += timing_ ## t ## _end - timing_ ## t ## _start; }
-#define TIMING_DEFINE_PRINT(t) clock_t timing_ ## t ## _time; \
-void timing_print_ ## t ( char * msg ) { \
-  fprintf( stderr, "%s%.2f sec\n", msg, float(timing_ ## t ## _time) / HZ ); \
-} \
-void timing_reset_ ## t () { \
-  timing_ ## t ## _time = 0; \
-}
-
-#else /* ! WINNT */
-
-#define TIMING_START(t) { struct tms timing_ ## t ## _start, timing_ ## t ## _end; \
-  times( &timing_ ## t ## _start );
-#define TIMING_END(t) times( &timing_ ## t ## _end ); \
-  timing_ ## t ## _time += timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime; }
-#define TIMING_END_AND_PRINT(t, msg) times( &timing_ ## t ## _end ); \
-  fprintf( stderr, "%s%.2f sec\n", msg, \
-	   float( timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime ) / HZ ); \
-  timing_ ## t ## _time += timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime; }
-#define TIMING_DEFINE_PRINT(t) long timing_ ## t ## _time; \
-void timing_print_ ## t ( char * msg ) { \
-  fprintf( stderr, "%s%.2f sec\n", msg, float(timing_ ## t ## _time) / HZ ); \
-} \
-void timing_reset_ ## t () { \
-  timing_ ## t ## _time = 0; \
-}
-#endif /* ! WINNT */
-
-/* macros common to all platforms */
-#define TIMING_DEFINE_PRINTPROTO(t) void timing_print_ ## t ( char * ); \
-  void timing_reset_ ## t ();
-#define TIMING_PRINT(t, msg) timing_print_ ## t ( msg );
-#define TIMING_RESET(t) timing_reset_ ## t ();
-
-#else /* TIMING */
-#define TIMING_START(t)
-#define TIMING_END(t)
-#define TIMING_END_AND_PRINT(t, msg)
-#define TIMING_DEFINE_PRINT(t)
-#define TIMING_DEFINE_PRINTPROTO(t)
-#define TIMING_PRINT(t, msg)
-#define TIMING_RESET(t)
-#endif /* TIMING */
Index: ctory/libfac/factor/tmpl_inst.cc
===================================================================
--- factory/libfac/factor/tmpl_inst.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,62 +1,0 @@
-////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-////////////////////////////////////////////////////////////
-
-#include "config.h"
-
-// #include <factory/factoryconf.h>
-
-// #include "factory.h"
-#include "cf_iter.h"
-#include "canonicalform.h"
-#include "cf_assert.h"
-#include "cf_reval.h"
-
-#include "templates/ftmpl_array.cc"
-#include "templates/ftmpl_factor.cc"
-#include "templates/ftmpl_list.cc"
-#include "templates/ftmpl_functions.h"
-#include "templates/ftmpl_matrix.cc"
-
-// place here your own template stuff, not instantiated by factory
-#include <libfac/factor/tmpl_inst.h>
-#include <libfac/factor/class.cc>
-
-template class List<int>;
-template class ListIterator<int>;
-
-template class List<IntList>;
-template class ListIterator<IntList>;
-
-template class Substitution<CanonicalForm>;
-template class List<SForm>;
-template class ListIterator<SForm>;
-
-#ifndef NOSTREAMIO
-template OSTREAM & operator << ( OSTREAM &, const List<int> & );
-template OSTREAM & operator << ( OSTREAM &, const List<IntList> & );
-#endif
-
-// for charsets:
-template class List<CFList>;
-template class ListIterator<CFList>;
-template class List<Variable>;
-template class ListIterator<Variable> ;
-
-template List<Variable> Union ( const List<Variable>&, const List<Variable>& );
-template List<Variable> Difference ( const List<Variable>&, const List<Variable>& );
-
-#ifndef NOSTREAMIO
-template OSTREAM & operator << ( OSTREAM &, const List<CFList> & );
-template OSTREAM & operator << ( OSTREAM &, const List<Variable> & );
-template OSTREAM & operator << ( OSTREAM &, const Array<int> & );
-#endif
-
-template class Array<int>;
-template class Array<Variable>;
-
-// for database
-#ifdef HAVE_DATABASE
-template class List<CFFList>;
-template class ListIterator<CFFList>;
-#endif /* HAVE_DATABASE */
Index: ctory/libfac/factor/tmpl_inst.h
===================================================================
--- factory/libfac/factor/tmpl_inst.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,48 +1,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-///////////////////////////////////////////////////////////////////////////////
-#ifndef TMPL_INST_H
-#define TMPL_INST_H
-
-#include <libfac/factor/class.h>
-//typedef CanonicalForm CF;
-//typedef List<CanonicalForm> CFList;
-//typedef ListIterator<CanonicalForm> CFListIterator;
-/*BEGINPUBLIC*/
-typedef List<CFList> ListCFList;
-/*ENDPUBLIC*/
-typedef ListIterator<CFList> ListCFListIterator ;
-
-//typedef Factor<CanonicalForm> CFFactor;
-//typedef List<CFFactor> CFFList;
-//typedef ListIterator<CFFactor> CFFListIterator;
-
-/*BEGINPUBLIC*/
-typedef List<int> IntList ;
-typedef ListIterator<int> IntListIterator ;
-/*ENDPUBLIC*/
-typedef List<IntList> ListIntList;
-typedef ListIterator<IntList> ListIntListIterator ;
-
-typedef Substitution<CanonicalForm> SForm ;
-typedef List<SForm> SFormList;
-typedef ListIterator<SForm> SFormListIterator;
-
-/*BEGINPUBLIC*/
-typedef List<Variable> Varlist;
-typedef ListIterator<Variable> VarlistIterator;
-/*ENDPUBLIC*/
-
-typedef Array<int> Intarray;
-
-#ifdef HAVE_DATABASE
-typedef List<CFFList> ListCFFList;
-typedef ListIterator<CFFList> ListCFFListIterator;
-#endif
-
-//typedef Array<CFArray> CCFArray ;
-//typedef Array<CCFArray> CCCFArray ;
-
-#endif /* TMPL_INST_H */
-
-
Index: ctory/libfac/factor/version.cc
===================================================================
--- factory/libfac/factor/version.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,14 +1,0 @@
-///////////////////////////////////////////////////////////////////////////////
-// emacs edit mode for this file is -*- C++ -*-
-///////////////////////////////////////////////////////////////////////////////
-
-/*
-#include "version.h"
-
-const char * libfac_name = "Factorization and characteristic sets library";
-const char * libfac_version = LIBFAC_VERSION;
-const char * libfac_date = LIBFAC_DATE;
-const char * libfac_author = "M. Messollen";
-*/
-
-int    libfac_interruptflag = 0;
Index: ctory/libfac/factor/version.h.in
===================================================================
--- factory/libfac/factor/version.h.in	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,2 +1,0 @@
-#undef LIBFAC_VERSION
-#undef LIBFAC_DATE
Index: ctory/libfac/header.tpl
===================================================================
--- factory/libfac/header.tpl	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,41 +1,0 @@
-// Header file for libfac.a
-// Created by -- makeheader --
-///////////////////////////////////////
-#ifndef FACTOR_H
-#define FACTOR_H
-
-#include <factory.h>
-
-.INCLUDE factor/interrupt.h
-
-// some values you can ask for:
-extern const char * libfac_name;
-extern const char * libfac_version;
-extern const char * libfac_date;
-extern const char * libfac_author;
-
-//// Note: second argument for Factorize is for internal use only.
-.INCLUDE factor/Factor.h
-.INCLUDE factor/MVMultiHensel.h
-
-//// Note: InternalSqrFree does only the work needed for factorization.
-.INCLUDE factor/SqrFree.h
-.INCLUDE factor/Truefactor.h
-.INCLUDE factor/class.h
-
-.INCLUDE factor/helpstuff.h
-.INCLUDE factor/tmpl_inst.h
-.INCLUDE factor/homogfactor.h
-.INCLUDE factor/debug.h
-.INCLUDE factor/timing.h
-
-////////////////////////////////////////
-/// from charsets:
-.INCLUDE charset/csutil.h
-.INCLUDE charset/charset.h
-
-.INCLUDE charset/reorder.h
-
-.INCLUDE charset/algfactor.h
-
-#endif /* FACTOR_H */
Index: ctory/libfac/libfac.h
===================================================================
--- factory/libfac/libfac.h	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,99 +1,0 @@
-// Header file for libfac.a
-// Created by -- makeheader --
-///////////////////////////////////////
-#ifndef FACTOR_H
-#define FACTOR_H
-
-#include <factory/factory.h>
-
-// Set this to a nonzero value to interrupt the computation
-extern int libfac_interruptflag;
-
-/*
-// some values you can ask for:
-extern const char * libfac_name;
-extern const char * libfac_version;
-extern const char * libfac_date;
-extern const char * libfac_author;
-*/
-
-/*
-CFFList Factorize( const CanonicalForm & F, const CanonicalForm & mipo, int is_SqrFree=0 ) ;
-CFFList newfactoras( const CanonicalForm & f, const CFList & as, int &success);
-CFFList newcfactor( const CanonicalForm & f, const CFList & as, int &success);
-*/
-
-
-//// Note: InternalSqrFree does only the work needed for factorization.
-// CFFList SqrFree( const CanonicalForm & f ) ;
-
-typedef List<CFList> ListCFList;
-typedef List<int> IntList ;
-
-// typedef ListIterator<int> IntListIterator ;
-// typedef List<Variable> Varlist;
-// typedef ListIterator<Variable> VarlistIterator;
-
-////////////////////////////////////////
-/// from charsets:
-/*
-class PremForm {
-public:
-  CFList FS1;
-  CFList FS2;
-  inline PremForm& operator=( const PremForm&  value ){
-    if ( this != &value ){
-      FS1 = value.FS1;
-      FS2 = value.FS2;
-    }
-    return *this;
-  }
-};
-
-
-CanonicalForm  Prem( const CanonicalForm &f, const CanonicalForm &g );
-CanonicalForm  Prem( const CanonicalForm &f, const CFList &L );
-CFList         Prem( const CFList &AS, const CFList &L );
-CFList     MCharSetN( const CFList &PS, PremForm & Remembern );
-*/
-
-
-/// Char. set
-ListCFList IrrCharSeries( const CFList &PS, int opt=0 );
-
-/*
-// the next three give you a heuristically optimal reorderd list of the
-// variables. For internal and external (e.g. Singular/Macaulay2) library use.
-// This is really experimental!
-// See the comments in reorder.cc.
-// 
-// this gives you a heuristically optimal ordering for the ring variables
-// if you use the irreducible characteristic series.
-Varlist  neworder( const CFList & PolyList );
-// the same as neworder(...) only returning a list of CanonicalForm 's
-// (i.e. the variables as CanonicalForms)
-CFList   newordercf(const CFList & PolyList );
-*/
-
-/// the same as neworder(...) only returning a list of int 's (i.e. the levels)
-IntList  neworderint(const CFList & PolyList );
-
-/*
-// for library internal use only:
-// next function reorders the variables in PS:
-// a code segment to use:
-// ...
-// #include <tmpl_inst.h> // for typedef's
-// CFList PS= <setup-your-list-of-CanonicalForms>;
-// Varlist betterorder= neworder(PS);
-// PS= reorder(betterorder,PS); // reorder variables in PS from oldorder 
-//                                 to betterorder
-// ListCFList Q= IrrCharSeries( PS );
-// Q= reorder(betterorder,Q);   // revert ordering to oldorder
-// 
-CFList reorder( const Varlist & betterorder, const CFList & PS);
-CFFList reorder( const Varlist & betterorder, const CFFList & PS);
-ListCFList reorder(const Varlist & betterorder, const ListCFList & Q);
-*/
-
-#endif /* FACTOR_H */
Index: ctory/libfac/mkinstalldirs
===================================================================
--- factory/libfac/mkinstalldirs	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,32 +1,0 @@
-#!/bin/sh
-# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman@prep.ai.mit.edu>
-# Created: 1993-05-16
-# Last modified: 1994-03-25
-# Public domain
-
-errstatus=0
-
-for file in ${1+"$@"} ; do 
-   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
-   shift
-
-   pathcomp=
-   for d in ${1+"$@"} ; do
-     pathcomp="$pathcomp$d"
-     case "$pathcomp" in
-       -* ) pathcomp=./$pathcomp ;;
-     esac
-
-     if test ! -d "$pathcomp"; then
-        echo "mkdir $pathcomp" 1>&2
-        mkdir "$pathcomp" || errstatus=$?
-     fi
-
-     pathcomp="$pathcomp/"
-   done
-done
-
-exit $errstatus
-
-# mkinstalldirs ends here
Index: ctory/libfac/test.cc
===================================================================
--- factory/libfac/test.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,68 +1,0 @@
-//static char rcsid[] = "$Id$";
-///////////////////////////////////////////////////////////////////////////////
-// Factor - Includes
-#include "libfac.h"
-#include <string.h>
-
-#ifdef HAVE_IOSTREAM
-#include <iostream>
-#define CERR std::cerr
-#define COUT std::cout
-#define CIN std::cin
-#elif defined(HAVE_IOSTREAM_H)
-#include <iostream.h>
-#define CERR cerr
-#define COUT cout
-#define CIN cin
-#endif
-
-
-
-void
-setVarNames ( char * vnames )
-{
-    int i, n = strlen( vnames );
-    Variable dummy;
-    for ( i = 0; i < n; i++ )
-        dummy = Variable( i+1, vnames[i] );
-}
-
-main()
-{
-    CanonicalForm f,g;
-    int charac;
-    CFFList Factorlist;
-    CFFactor copy;
-
-COUT << libfac_name  <<", Version " << libfac_version << "\n";
-//    COUT << " Characteristic = "; 
-    CIN >> charac;
-    setCharacteristic(charac);
-    On(SW_SYMMETRIC_FF);
-    On(SW_USE_EZGCD);
-//////////////////////////////////////////////////////////////
-//  char vnames[30];
-////  cout << " vnames = "; 
-//  cin >> vnames;
-//
-//  setVarNames( vnames );
-//
-//////////////////////////////////////////////////////////////
-//    COUT << " f = "; 
-//    CIN >> f;
-//    COUT << f  << " mod " << charac << " = " ;
-//    Factorlist= Factorize( f,0 );
-//     COUT << Factorlist ;//<< "\n";
-// Ueberpruefen:
-//    g=1;
-//    for ( CFFListIterator i=Factorlist ; i.hasItem(); i++){
-//	copy = i.getItem();
-//	if ( getNumVars(copy.factor()) > 0 )
-//	     for ( int j=1; j<=copy.exp(); j++)
-//	     g *= copy.factor();
-//	else g *= copy.factor();
- //   }
-//    if ( (f-g) != f.genZero() ){
-//	CERR << "\nList and f differ: f= " << f << "  g= " << g << "\n";
- //   }
-}
Index: ctory/libfac/testcs.cc
===================================================================
--- factory/libfac/testcs.cc	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,75 +1,0 @@
-
-#include <factory.h>
-#include <libfac.h>
-#ifdef HAVE_IOSTREAM
-#include <iostream>
-#define COUT std::cout
-#define CIN std::cin
-#elif defined(HAVE_IOSTREAM_H)
-#include <iostream.h>
-#define COUT cout
-#define CIN cin
-#endif
-
-
-// testing: Characteristic Sets
-void
-setVarNames ( char * vnames )
-{
-    int i, n = strlen( vnames );
-    Variable dummy;
-    for ( i = 0; i < n; i++ )
-	dummy = Variable( i+1, vnames[i] );
-}
-
-main()
-{
-  int reord=0; // use strategy for reordering?
-  int charac;
-  COUT << " Characteristic = "; CIN >> charac;
-  setCharacteristic(charac);
-  On(SW_SYMMETRIC_FF);
-  char vnames[30];
-  COUT << " vnames = "; CIN >> vnames;
-
-  setVarNames( vnames );
-
-  CFList F1,F2;
-  ListCFList Q;
-  CanonicalForm f;
-  CFListIterator I ;
-  int i = 1;
-  PremForm Remembern;
-  Varlist betterorder;
-
-  COUT << " f[" << i << "] = "; cin >> f;
-  while ( f != 0 ) {
-    F1.append( f ); i++;
-    COUT << " f[" << i << "] = "; cin >> f;
-  }
-  F2=F1;
-  COUT << "\n";
-
-  COUT << "F = " << F1 << "\n";
-  if (reord){
-    betterorder= neworder(F1);
-    COUT << "new orderd vars: " << betterorder << "\n";
-    F1=reorder(betterorder,F1);
-    COUT << "new F= " << F1 << "\n";
-  }
-//   COUT << "\nUsing Modified CharSet:" << "\n";
-//   F2 = MCharSetN( F1, Remembern );
-//   COUT << "MCsN(F) = " << F2 << "\n";
-//   COUT << "Factors removed: " << Remembern.FS2 << "\n";
-//   COUT << "Possible Factors considered: " << Remembern.FS1 << "\n";
-//   for ( I = F2; I.hasItem(); I++ )
-//     COUT << "  vars: " << getVars( I.getItem() ) << "\n";
-  COUT << "\nUsing IrrCharSeries:" << "\n";
-  Q= IrrCharSeries( F1 );
-  COUT << "ics(F) = " << Q << "\n";
-  if (reord){
-    Q=reorder(betterorder,Q);
-    COUT << "reorderd ics(F) = " << Q << "\n";
-  }
-}
-
Index: ctory/libfac/tests/factor/f1
===================================================================
--- factory/libfac/tests/factor/f1	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-x^14-1;
-#
-#(x-1)*(x+1)*(x^6+x^5+x^4+x^3+x^2+x+1)*(x^6-x^5+x^4-x^3+x^2-x+1)
Index: ctory/libfac/tests/factor/f10
===================================================================
--- factory/libfac/tests/factor/f10	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(x^2-10748*y*x+y^2)*(y^2+x^2)*(x^2+10748*y*x+y^2);
-#
-#
Index: ctory/libfac/tests/factor/f11
===================================================================
--- factory/libfac/tests/factor/f11	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(3*z^3+2*w*z-10*y^2+45*x^3)*(w^2*z^3+47*x*y-w^2);
-#
-#
Index: ctory/libfac/tests/factor/f12
===================================================================
--- factory/libfac/tests/factor/f12	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(10*y+x^3+9)*(6*x*y^2+x+y+x^3+15);
-#
-#
Index: ctory/libfac/tests/factor/f13
===================================================================
--- factory/libfac/tests/factor/f13	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(x-w)*(y-w)*(x-y)*(z-w)*(x-z)*(y-z);
-#
-#
Index: ctory/libfac/tests/factor/f14
===================================================================
--- factory/libfac/tests/factor/f14	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(x^3*y+x^3*z+z-11)*(x^2*z^2+x^2*y^2+y+90);
-#
-#leading coefficient is a sum
Index: ctory/libfac/tests/factor/f15
===================================================================
--- factory/libfac/tests/factor/f15	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(z+x*y+10)*(x*z+y+30)*(y*z+x+20);
-#
-#
Index: ctory/libfac/tests/factor/f16
===================================================================
--- factory/libfac/tests/factor/f16	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-w^2*x^7*y^6*12*z^5+31962*z^2*y^5*x^7+87*z^5*y^3*x^7+31967*z^2*y^7*x^8+31759*z^2*y^5*x^8+31988*z^2*y^7*x^7+54*z^2*y^6*x^10+522*z^2*y^4*x^10+9*z^5*y^5*x^7+z^2*y^5*x^6*w^2+3*z^8*y^3*x^6*w^2+2*z^6*y^3*x^6*w^3+31989*z^3*y^3*x^6*w^3+31977*z^2*y^5*x^6*w^4+31988*z^5*y^3*x^6*w^2+414*z^2*y^5*x^7*w^2+42*z^2*y^7*x^7*w^2+14*z^5*y^5*x^6*w^4+31990*z^5*y^5*x^6*w^2+31973*z^2*y^4*x^9*w^2+58*z^3*y^3*x^7*w+31955*z^8*y^4*x^7*w^2+6*z^3*y^5*x^7*w+31967*z^6*y^4*x^7*w^3+96*z^5*y^6*x^8*w^2+31983*z^5*y^5*x^7*w^2+31823*z^5*y^6*x^7*w^4+31775*z^5*y^5*x^10*w^2+18*z^5*y^4*x^9*w^2;
-#
-#( 5333, (z)^2, (x)^6, (y)^3, -13785, -z^3+10663*w*z-10661*x*y^2+10659*w^2*y^2+10664*y^2-6*x^3*y, 3309*w^2*x*y*z^3+7722*w^2*z^3-8825*x*y^2+x-7722*w^2 )
Index: ctory/libfac/tests/factor/f17
===================================================================
--- factory/libfac/tests/factor/f17	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(x^2*y+x*y+1)*(x^2*y+2*x*y+3)*(2*x^2*y+3*x*y+5)*(3*x^2*y+4*x*y+7);
-#
-#
Index: ctory/libfac/tests/factor/f18
===================================================================
--- factory/libfac/tests/factor/f18	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(z^3+x*y*z+y^2+x^3)*(x*(z^4+1)+z+x^3*y^2);
-#
-#
Index: ctory/libfac/tests/factor/f19
===================================================================
--- factory/libfac/tests/factor/f19	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(x^2-x*z+z*y+2)*(x^2+3*x-y^2-15);
-#
-#
Index: ctory/libfac/tests/factor/f2
===================================================================
--- factory/libfac/tests/factor/f2	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-x^8 + x +1 ;
-#
-# (x**4-994*x**3-1479*x**2+15362*x+7108)*(x**2+993*x-3200)*(x**2+x+1)
Index: ctory/libfac/tests/factor/f20
===================================================================
--- factory/libfac/tests/factor/f20	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(x*z^2+2*x*z*w+x*w^2+z^2+w+2*z*w)*(x*z^2+2*x*z*w+x*w^2+z);
-#
-#
Index: ctory/libfac/tests/factor/f21
===================================================================
--- factory/libfac/tests/factor/f21	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-x^10 - y^4;
-#
-#
Index: ctory/libfac/tests/factor/f21a
===================================================================
--- factory/libfac/tests/factor/f21a	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-5
-x^10 - y^4;
-#
-#
Index: ctory/libfac/tests/factor/f22
===================================================================
--- factory/libfac/tests/factor/f22	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(x^3*(z+y)+z-11)*(x^2*(z^2+y^2)+y+90);
-#
-#
Index: ctory/libfac/tests/factor/f23
===================================================================
--- factory/libfac/tests/factor/f23	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(y*z^3+x*y*z+y^2+x^3)*(x*(z^4+1)+z+x^3*y^2);
-#
-#
Index: ctory/libfac/tests/factor/f24
===================================================================
--- factory/libfac/tests/factor/f24	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(z^2-x^3*y+3)*(z^2+x^3*y^4)*(y^4*z^2+x^2*z+5);
-#
-#
Index: ctory/libfac/tests/factor/f25
===================================================================
--- factory/libfac/tests/factor/f25	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(z^2+x^3*y^4+u^2)*((y^2+x)*z^2 + 3*u^2*x^3*y^4*z+19*y^2)*(u^2*y^4*z^2+x^2*z+5);
-#
-#
Index: ctory/libfac/tests/factor/f26
===================================================================
--- factory/libfac/tests/factor/f26	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(w^4*z^3-x*y^2*z^2-w^4*x^5*y^6-w^2*x^3*y)*(-1*x^5-z^3+y*z+x^2*y^3)*(w^4*z^6+y^2*z^3-w^2*x^2*y^2*z^2+x^5*z-x^4*y^2-w^3*x^3*y);
-#
-#
Index: ctory/libfac/tests/factor/f27
===================================================================
--- factory/libfac/tests/factor/f27	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(z+y+x-3)*(z+y+x-3)*(z+y+x-3)*(z+y+x-2)*(z+y+x-2);
-#
-#
Index: ctory/libfac/tests/factor/f28
===================================================================
--- factory/libfac/tests/factor/f28	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(-15*y^2*z^16+29*w^4*x^12*y^12*z^3+21*x^3*z^2+3*w^15*y^20)*(-1*z^31-w^12*z^20+y^18-y^14+x^2*y^2+x^21+w^2);
-#
-#
Index: ctory/libfac/tests/factor/f29
===================================================================
--- factory/libfac/tests/factor/f29	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-1;
-#
-#
Index: ctory/libfac/tests/factor/f3
===================================================================
--- factory/libfac/tests/factor/f3	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,3 +1,0 @@
-31991
--9944*(x^2-5265*x+14343)*(x^2+5943*x-3555)*(x-8995)*(x-15035) ;
-#
Index: ctory/libfac/tests/factor/f32
===================================================================
--- factory/libfac/tests/factor/f32	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(z+y+x-3)*(z+y+x-3)*(z+y+x-3);
-#
-#
Index: ctory/libfac/tests/factor/f33
===================================================================
--- factory/libfac/tests/factor/f33	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(3*z^3+2*w*z-9*y^3-y^2+45*x^3)*(w^2*z^3+47*x*y-w^2);
-#
-#
Index: ctory/libfac/tests/factor/f34
===================================================================
--- factory/libfac/tests/factor/f34	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-(22*y^5-18*x^4*y^5-26*x^3*y^4-38*x^2*y^4+29*x^2*y^3-41*x^4*y^2+37*x^4)*(33*x^5*y^6+11*y^2+35*x^3*y-22*x^4);
-#
-#
Index: ctory/libfac/tests/factor/f35
===================================================================
--- factory/libfac/tests/factor/f35	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-x^6*y^3*z^2*(3*z^3+2*w*z-8*x*y^2+14*w^2*y^2-y^2+18*x^3*y)*(w^2*z^3-12*w^2*x*y*z^3+3*x*y^2+29*x-w^2);
-#
-#
Index: ctory/libfac/tests/factor/f36
===================================================================
--- factory/libfac/tests/factor/f36	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,5 +1,0 @@
-101
-(a-b)*(a^4-7*b* c-4)*(a^5-b+c-11*d^3+1);
-#
-# From Dan Grayson
-#
Index: ctory/libfac/tests/factor/f37
===================================================================
--- factory/libfac/tests/factor/f37	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-2
-(x+y^2)*(x^2+y);
-#
-#
Index: ctory/libfac/tests/factor/f38
===================================================================
--- factory/libfac/tests/factor/f38	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-5
-(x+y^2)*(x^2+y)*(x+y^4)*(x^4+y);
-#
-#
Index: ctory/libfac/tests/factor/f39
===================================================================
--- factory/libfac/tests/factor/f39	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,6 +1,0 @@
-2
-(x+y^2)*(x^2+y)*(x+y^4)*(x^4+y);
-b^2+b+1;
-b^2+b+1;
-#
-#
Index: ctory/libfac/tests/factor/f4
===================================================================
--- factory/libfac/tests/factor/f4	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-3
-x^3 - y^3;
-#
-# (x-y)^3
Index: ctory/libfac/tests/factor/f40
===================================================================
--- factory/libfac/tests/factor/f40	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,5 +1,0 @@
-3
-(x+y^2)*(x^2+y)*(x+y^4)*(x^4+y);
-b^2+b+2;
-#
-#
Index: ctory/libfac/tests/factor/f41
===================================================================
--- factory/libfac/tests/factor/f41	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,3 +1,0 @@
-2
-x*(x+y)*(x^2+x+y^2)*(x^2+x+y+1)*(x^2+x+y^2+1);
-#
Index: ctory/libfac/tests/factor/f42
===================================================================
--- factory/libfac/tests/factor/f42	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,6 +1,0 @@
-2
-x*(x+y)*(x^2+x+y^2)*(x^2+x+y+1)*(x^2+x+y^2+1)*(x^3+x+y^3)*(x^3+x+y+1)*(x^3+x+y^3+1)*(x^3+x+y^3+y+1)*(x^3+x+y^3+y^2+1);
-x^2+x+1;
-x^3+x+1;
-x^4+x+1;
-#
Index: ctory/libfac/tests/factor/f43
===================================================================
--- factory/libfac/tests/factor/f43	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-5
-(x*z+y+30)*(y*z+x+20)*(z+x*y+10);
-b^2+3;
-
Index: ctory/libfac/tests/factor/f5
===================================================================
--- factory/libfac/tests/factor/f5	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991
-x^4 + y^3 + z^5 ;
-#
-# irreduzible
Index: ctory/libfac/tests/factor/f6
===================================================================
--- factory/libfac/tests/factor/f6	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991;
-(3*z^2+2*y^2+x^2)*(4*z^2-3*y^2+2*x^2);
-#
-#
Index: ctory/libfac/tests/factor/f7
===================================================================
--- factory/libfac/tests/factor/f7	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,5 +1,0 @@
-31991
-(y*z+x*y^2+9)*(y*z+x*z+x^2*y);
-#
-#
-
Index: ctory/libfac/tests/factor/f8
===================================================================
--- factory/libfac/tests/factor/f8	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,5 +1,0 @@
-31991
-(x+y+z)*(z-y+x)*(x-z-y);
-#
-#
-
Index: ctory/libfac/tests/factor/f9
===================================================================
--- factory/libfac/tests/factor/f9	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-31991;
-(y*z-x*z+x^2+2)*(z^3-y^2+x^2+3*x-15);
-#
-#
Index: ctory/libfac/tests/factor/p1
===================================================================
--- factory/libfac/tests/factor/p1	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,60 +1,0 @@
-32003
--573002*x^10+240517*x^9*y+396389*x^8*y^2+535082*x^7*y^3+288429*x^6*y^4
-+763919*x^5*y^5+3766*x^4*y^6-649376*x^3*y^7-59851*x^2*y^8-542799*x*y^9+20979*y^10
--461020*x^9*z-650459*x^8*y*z-944957*x^7*y^2*z+1677170*x^6*y^3*z+1666154*x^5*y^4*z
--1232710*x^4*y^5*z+862729*x^3*y^6*z-618762*x^2*y^7*z-705768*x*y^8*z-187036*y^9*z-741032*x^8*z^2
-+1446654*x^7*y*z^2-643320*x^6*y^2*z^2-1635676*x^5*y^3*z^2-189420*x^4*y^4*z^2+682529*x^3*y^5*z^2
--450284*x^2*y^6*z^2-327970*x*y^7*z^2+66106*y^8*z^2+386688*x^7*z^3+198264*x^6*y*z^3-757313*x^5*y^2*z^3+2008508*x^4*y^3*z^3-675589*x^3*y^4*z^3-2338517*x^2*y^5*z^3+413997*x*y^6*z^3+150157*y^7*z^3
-+115299*x^6*z^4+1838075*x^5*y*z^4-821489*x^4*y^2*z^4-772496*x^3*y^3*z^4+94982*x^2*y^4*z^4
-+552427*x*y^5*z^4+894534*y^6*z^4-173749*x^5*z^5-1322895*x^4*y*z^5+545850*x^3*y^2*z^5
-+1506535*x^2*y^3*z^5+31641*x*y^4*z^5+858761*y^5*z^5+188464*x^4*z^6+676365*x^3*y*z^6
--1175321*x^2*y^2*z^6-94611*x*y^3*z^6+365391*y^4*z^6-300517*x^3*z^7-74262*x^2*y*z^7
-+756469*x*y^2*z^7+702099*y^3*z^7+651058*x^2*z^8+261997*x*y*z^8+70610*y^2*z^8-493574*x*z^9
-+129784*y*z^9+265065*z^10-532141*x^9*w-285474*x^8*y*w-1300132*x^7*y^2*w+908974*x^6*y^3*w
--1966687*x^5*y^4*w-127968*x^4*y^5*w+58220*x^3*y^6*w+41679*x^2*y^7*w+479035*x*y^8*w+466832*y^9*w
-+1566035*x^8*z*w+1817709*x^7*y*z*w-688806*x^6*y^2*z*w-748313*x^5*y^3*z*w-1930577*x^4*y^4*z*w
--957911*x^3*y^5*z*w+81915*x^2*y^6*z*w+133232*x*y^7*z*w+980198*y^8*z*w-110745*x^7*z^2*w
--1370738*x^6*y*z^2*w-1182195*x^5*y^2*z^2*w+3215028*x^4*y^3*z^2*w-2006230*x^3*y^4*z^2*w
-+2364130*x^2*y^5*z^2*w+1457270*x*y^6*z^2*w+1484168*y^7*z^2*w+1648545*x^6*z^3*w+772215*x^5*y*z^3*w
-+554722*x^4*y^2*z^3*w+667926*x^3*y^3*z^3*w+375356*x^2*y^4*z^3*w+3601160*x*y^5*z^3*w
-+625131*y^6*z^3*w-2510503*x^5*z^4*w-2729919*x^4*y*z^4*w+1243946*x^3*y^2*z^4*w
-+2503349*x^2*y^3*z^4*w+1909123*x*y^4*z^4*w+588366*y^5*z^4*w+94641*x^4*z^5*w+1274333*x^3*y*z^5*w
-+1615834*x^2*y^2*z^5*w-1286036*x*y^3*z^5*w-491438*y^4*z^5*w-864129*x^3*z^6*w+96287*x^2*y*z^6*w
--1641596*x*y^2*z^6*w-479951*y^3*z^6*w+865513*x^2*z^7*w+37697*x*y*z^7*w-425879*y^2*z^7*w
--246899*x*z^8*w-1043521*y*z^8*w-615277*z^9*w-353183*x^8*w^2+1903124*x^7*y*w^2+307847*x^6*y^2*w^2
-+153254*x^5*y^3*w^2+4494*x^4*y^4*w^2+775116*x^3*y^5*w^2+84747*x^2*y^6*w^2+1970329*x*y^7*w^2
-+248796*y^8*w^2-200676*x^7*z*w^2-1283772*x^6*y*z*w^2+312236*x^5*y^2*z*w^2+258350*x^4*y^3*z*w^2
-+899318*x^3*y^4*z*w^2+879951*x^2*y^5*z*w^2-197099*x*y^6*z*w^2+1027373*y^7*z*w^2
--939408*x^6*z^2*w^2+1231368*x^5*y*z^2*w^2+811932*x^4*y^2*z^2*w^2+136753*x^3*y^3*z^2*w^2
--1060314*x^2*y^4*z^2*w^2-373787*x*y^5*z^2*w^2-419717*y^6*z^2*w^2-602528*x^5*z^3*w^2
--279785*x^4*y*z^3*w^2+140803*x^3*y^2*z^3*w^2+1245653*x^2*y^3*z^3*w^2+611906*x*y^4*z^3*w^2
--1166551*y^5*z^3*w^2-878201*x^4*z^4*w^2+597628*x^3*y*z^4*w^2-220458*x^2*y^2*z^4*w^2
--3038116*x*y^3*z^4*w^2-2785259*y^4*z^4*w^2-425903*x^3*z^5*w^2-316206*x^2*y*z^5*w^2
--3764903*x*y^2*z^5*w^2-2194636*y^3*z^5*w^2-185521*x^2*z^6*w^2+419827*x*y*z^6*w^2
--70946*y^2*z^6*w^2+561958*x*z^7*w^2-513594*y*z^7*w^2-487215*z^8*w^2-902070*x^7*w^3
-+260239*x^6*y*w^3-1618965*x^5*y^2*w^3+1123916*x^4*y^3*w^3-1107669*x^3*y^4*w^3-1433250*x^2*y^5*w^3
-+665446*x*y^6*w^3-1463775*y^7*w^3+778712*x^6*z*w^3-80174*x^5*y*z*w^3-93922*x^4*y^2*z*w^3
-+1249290*x^3*y^3*z*w^3+1272307*x^2*y^4*z*w^3+513673*x*y^5*z*w^3-322676*y^6*z*w^3
--634533*x^5*z^2*w^3-1875741*x^4*y*z^2*w^3-2698209*x^3*y^2*z^2*w^3+937176*x^2*y^3*z^2*w^3
--2883756*x*y^4*z^2*w^3-1430757*y^5*z^2*w^3+485806*x^4*z^3*w^3+731831*x^3*y*z^3*w^3
-+2196178*x^2*y^2*z^3*w^3-1491104*x*y^3*z^3*w^3-1456373*y^4*z^3*w^3-206031*x^3*z^4*w^3+314576*x^2*y*z^4*w^3-225867*x*y^2*z^4*w^3-2750466*y^3*z^4*w^3-1087247*x^2*z^5*w^3+2172840*x*y*z^5*w^3
--541045*y^2*z^5*w^3+624945*x*z^6*w^3+1085162*y*z^6*w^3+565094*z^7*w^3-457315*x^6*w^4
-+342040*x^5*y*w^4-681000*x^4*y^2*w^4+297164*x^3*y^3*w^4+689*x^2*y^4*w^4+529745*x*y^5*w^4
--1310613*y^6*w^4-786298*x^5*z*w^4-1023635*x^4*y*z*w^4-2098764*x^3*y^2*z*w^4+1733995*x^2*y^3*z*w^4
-+1561806*x*y^4*z*w^4+133720*y^5*z*w^4-240204*x^4*z^2*w^4+1124674*x^3*y*z^2*w^4
-+2411690*x^2*y^2*z^2*w^4-600532*x*y^3*z^2*w^4-71275*y^4*z^2*w^4+128215*x^3*z^3*w^4
-+567626*x^2*y*z^3*w^4+973911*x*y^2*z^3*w^4-562780*y^3*z^3*w^4-894759*x^2*z^4*w^4
-+1265582*x*y*z^4*w^4+509433*y^2*z^4*w^4-671007*x*z^5*w^4+345729*y*z^5*w^4+80717*z^6*w^4
-+1144765*x^5*w^5+137320*x^4*y*w^5+390809*x^3*y^2*w^5+207350*x^2*y^3*w^5+65943*x*y^4*w^5
--1283191*y^5*w^5-109804*x^4*z*w^5+951743*x^3*y*z*w^5-154107*x^2*y^2*z*w^5-394628*x*y^3*z*w^5
--3201737*y^4*z*w^5+2307230*x^3*z^2*w^5-1082386*x^2*y*z^2*w^5-240669*x*y^2*z^2*w^5
--1274548*y^3*z^2*w^5-1768397*x^2*z^3*w^5-2788826*x*y*z^3*w^5+1689141*y^2*z^3*w^5
--1051474*x*z^4*w^5+126201*y*z^4*w^5-789876*z^5*w^5-288558*x^4*w^6-697110*x^3*y*w^6
-+659535*x^2*y^2*w^6-1659535*x*y^3*w^6+371290*y^4*w^6-1605798*x^3*z*w^6+63599*x^2*y*z*w^6
-+273476*x*y^2*z*w^6-774681*y^3*z*w^6-113162*x^2*z^2*w^6+861980*x*y*z^2*w^6
-+1824646*y^2*z^2*w^6-275200*x*z^3*w^6+1083821*y*z^3*w^6+803980*z^4*w^6
-+912560*x^3*w^7-373953*x^2*y*w^7+635559*x*y^2*w^7+2023871*y^3*w^7-252773*x^2*z*w^7
--1013176*x*y*z*w^7-356255*y^2*z*w^7+412544*x*z^2*w^7-199680*y*z^2*w^7+190561*z^3*w^7
-+33346*x^2*w^8-1189055*x*y*w^8+246983*y^2*w^8-220965*x*z*w^8-273745*y*z*w^8-493392*z^2*w^8
-+411602*x*w^9+853400*y*w^9+1110886*z*w^9-580548*w^10;
-
Index: ctory/libfac/tests/factor/p2
===================================================================
--- factory/libfac/tests/factor/p2	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,2 +1,0 @@
-32003
-x^25+y^23+z^18+x^4*y^10+x^8*y^5+2*x^5*y^8+x^5*y^5*z^3+x^6*y^6;
Index: ctory/libfac/tests/factor/p3
===================================================================
--- factory/libfac/tests/factor/p3	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,3 +1,0 @@
-32003
-a^3*b^3*f^4+186*a^2*b^4*c*f^3+11532*a*b^5*c^2*f^2+14307*b^6*c^3*f;
-# laesst sich nicht mit Maple faktorisieren!
Index: ctory/libfac/tests/factor/p4
===================================================================
--- factory/libfac/tests/factor/p4	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,4 +1,0 @@
-32003
-f^3*u^3-4*f^2*g*v*y*u^2 + (8*f^3*v^2*y+6*f^2*g*v^2*x+4*f*g^2*v^2*y^2)*u
--8*f^3*v^3*x-4*f*g^2*v^3*x*y + g^3*v^3*x^2;
-
Index: ctory/libfac/tests/factor/p5.3
===================================================================
--- factory/libfac/tests/factor/p5.3	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,8 +1,0 @@
-3
-s^85+(t)*s^84+(t^2)*s^83+(-1*t^18)*s^67+(-1*t^19)*s^66+(t^20)*s^65
-+(t^21)*s^64+(t^22)*s^63+(-1*t^24)*s^61+(-1*t^25)*s^60+(t^29)*s^56
-+(t^38)*s^47+(-1*t^39)*s^46+(-1*t^40)*s^45+(-1*t^42)*s^43+(-1*t^43)*s^42
-+(-1*t^45)*s^40+(-1*t^46)*s^39+(t^47)*s^38+(t^56)*s^29+(-1*t^60)*s^25
-+(-1*t^61)*s^24+(t^63)*s^22+(t^64)*s^21+(t^65)*s^20+(-1*t^66)*s^19
-+(-1*t^67)*s^18+(t^83)*s^2+(t^84)*s+(t^85);
-
Index: ctory/libfac/tests/factortest
===================================================================
--- factory/libfac/tests/factortest	(revision 4093f96acfcc6419c56ee983c447099c3b87a36e)
+++ 	(revision )
@@ -1,118 +1,0 @@
-#!/bin/csh
-# Make various tests for the factorization. 
-
-set OS=`uname`
-if ( $OS == "Linux" ) then
-	set ECHO="/bin/echo -e"
-else if ( $OS == "SunOS" ) then
-	set ECHO=/usr/5bin/echo
-else
-	set ECHO=echo
-endif
-$ECHO "\n\ntesting univariate factorization:\c"
-$ECHO "\nf1  \c" 
-../test < factor/f1  
-$ECHO "\nf2  \c"
-../test < factor/f2
-$ECHO "\nf3  \c"
-../test < factor/f3
-
-$ECHO "\n\ntesting multivariate factorization:"
-$ECHO "\nf4  \c"
-../test < factor/f4
-$ECHO "\nf5  \c"
-../test < factor/f5
-$ECHO "\nf6  \c"
-../test < factor/f6
-$ECHO "\nf7  \c"
-../test < factor/f7
-$ECHO "\nf8  \c"
-../test < factor/f8
-$ECHO "\nf9  \c"
-../test < factor/f9
-$ECHO "\nf10 \c"
-../test < factor/f10
-#$ECHO "\nf11 \c"
-#../test < factor/f11
-$ECHO "\nf12 \c"
-../test < factor/f12
-$ECHO "\nf12 \c"
-../test < factor/f13
-$ECHO "\nf14 \c"
-../test < factor/f14
-$ECHO "\nf15 \c"
-../test < factor/f15
-$ECHO "\nf16  -- skipping; takes long time.  See the Long-time section!\c"
-$ECHO "\nf17 \c"
-../test < factor/f17
-$ECHO "\nf18 \c"
-../test < factor/f18
-$ECHO "\nf19 \c"
-../test < factor/f19
-$ECHO "\nf20 \c"
-../test < factor/f20
-$ECHO "\nf21 \c"
-../test < factor/f21
-$ECHO "\nf21a \c"
-../test < factor/f21a
-$ECHO "\nf22 \c"
-../test < factor/f22
-$ECHO "\nf23 \c"
-../test < factor/f23
-$ECHO "\nf24 -- skipping; takes long time.  See the Long-time section!\c"
-$ECHO "\nf25 -- skipping; takes long time.  See the Long-time section!\c"
-$ECHO "\nf26 -- skipping; takes long time.  See the Long-time section!\c"
-$ECHO "\nf27 \c"
-../test < factor/f27
-$ECHO "\nf28 -- skipping; takes long time.  See the Long-time section!\c"
-$ECHO "\nf29 -- Test suite not available.\c"
-#../test < factor/f29
-$ECHO "\nf30 -- Test suite not available.\c"
-#../test < factor/f30
-$ECHO "\nf31 -- Test suite not available.\c"
-#../test < factor/f31
-$ECHO "\nf32 \c"
-../test < factor/f32
-$ECHO "\nf33 \c"
-../test < factor/f33
-$ECHO "\nf34 \c"
-../test < factor/f34
-$ECHO "\nf35 -- skipping; takes long time.  See the Long-time section!\c"
-$ECHO "\nf36 \c"
-../test < factor/f36
-$ECHO "\nf37 \c"
-../test < factor/f37
-$ECHO "\nf38 \c"
-../test < factor/f38
-$ECHO "\n"
-$ECHO "Tests from Gerhard Pfister:"
-$ECHO "p1   -- skipping; takes long time.  See the Long-time section!\c"
-$ECHO "\np2 \c"
-../test < factor/p2
-$ECHO "\np3 \c"
-../test < factor/p3
-$ECHO "\np4 \c"
-../test < factor/p4
-$ECHO "\np5 \c"
-../test < factor/p5.3
-
-$ECHO "\n"  
-# need-extensions section:
-$ECHO "\n Need-extensions section!\n"
-$ECHO "\nf39 \c"
-../test < factor/f39
-$ECHO "\nf40 \c"
-../test < factor/f40
-$ECHO "\nf41 \c"
-../test < factor/f41
-$ECHO "\nf42 \c"
-../test < factor/f42
-$ECHO "\nf43 \c"
-../test < factor/f43
-
-
-$ECHO "\n"
-$ECHO 
-# long time section:
-$ECHO "\n Long-time section!\n"
-$ECHO "\n ... Skipping!\n"
Index: libfac/00README
===================================================================
--- libfac/00README	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/00README	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,199 @@
+This is the file 00README.libfac for version 0.3.2 of Singular-libfac.
+
+######### What is Singular-libfac?
+Singular-libfac is an extension to Singular-factory
+(see the Singular-factory documentation for details about Singular-factory
+and what it does; look at REQUIREMENTS how to get Singular-factory), 
+which implements factorization of polynomials over finite fields and algorithms
+for manipulation of polynomial ideals via the characteristic set methods 
+(e.g., calculating the characteristic set and the irreducible characteristic 
+series).
+
+Note: Singular-libfac is just beta-code (as long version is < 1.0.0).
+There are bugs, I think. Please help to test this code!
+Submit a bug-report if you found a bug!
+
+######### Copyright #####################
+the Copyright is given in the file COPYING
+
+######### REQUIREMENTS ###################
+* You need the library Singular-factory, which is part of Singular, to compile
+this code. Get it from 
+  ftp://www.mathematik.uni-kl.de/pub/Math/Singular/Factory  or
+  http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/Factory
+  
+* gcc 2.7.2 ( earlier versions of gcc *may* work as well as any other ANSI C++
+  compiler; it is reported that gcc 2.6.3 works also, but beware of gcc 2.7.0;
+  it has some serious C++ bugs )
+
+* GNU Make version 3.74 or above ( earlier versions of GNU make *may* work )
+
+######### INSTALLATION ###################
+Using configure
+For the library type:
+  configure [--with-debug] [--with-Singular] [--includedir=path-to-factory.h]
+  make
+this will produce libfac.a or libsingfac.a (depending on --with-Singular).
+The only difference between libfac.a and libsingfac.a is: we don't instantiate
+any templates for libsingfac.a.
+
+If you want to produce a test file, type:
+  configure [--with-debug] [--libdir=path-to-libcf.a] [--includedir=path-to-factory.h]
+  make tests
+this will produce libfac.a and a binary called test. "test" is then used to 
+test some examples for factorization.
+
+ If you have found a bug in an unmodified version (beside the KNOWN BUGS, see 
+KNOWN BUGS section later), *please* email me: mmessollen@web.de
+Please include the characteristic and the ideal(s)/polynomial(s) you tried as
+well as the factoryversion you used (Best to include all your input!).
+
+As I am no longer at the university, please allow some days for an answer.
+
+Have fun!
+ Michael Messollen ( mmessollen@web.de )
+
+##### 
+I would like to thank Dongming Wang <Dongming.Wang@imag.fr> who showed me the 
+power of the Characteristic Set methods and from whom I learned a lot about 
+this topic.
+If you want to learn about characteristic sets, the next is a good point
+to start with:
+    Dongming Wang:
+    An Implementation of the Characteristic Set Method in Maple.
+    In: Automated Practical Reasoning: Algebraic Approaches 
+    (J. Pfalzgraf and D. Wang, eds.), Springer-Verlag, 
+    Wien-New York, 1995, pp. 187-201.
+
+
+########### KNOWN BUGS ############################
+o The  irreducible characteristic series stuff doesn't work for some problems.
+  You will get a warning:
+         "Factorization over algebraic function field required!"
+  if this program needs factorization over an algebraic function field, which
+  is not yet implemented (but I'm working on it).
+  Don't trust the result you'll get in such a case!!!!!!
+Since version 0.3.0 this problem is gone. (or should be :-) )
+
+o The performance of the irreducible characteristic series stuff heavily
+  depends on the ordering of the variables in some cases. No (nearly) optimal
+  ordering of the variables is chosen automatically, right now. 
+  E.g.: if your ideal is (t^10-x, t^31-t^6-t-y, t^8-z) and you choose the
+  variable ordering with t > z > y > x, the calculation of the irreducible 
+  characteristic series will take hours; if you choose t as the variable with 
+  the lowest level, you will get the answer immediately (the ideal is an 
+  irreducible characteristic series with the ordering z > y > x > t ).
+  I am thinking about the problem how to choose the ordering automatically. 
+Since version 0.2 of the library:
+(There is now a function: Varlist neworder(const CFList & PolyList ),
+ which returns a list of heuristically optimal reordered variables;
+ if you use the library for programming purpose, look at factor.h how to
+ use this function in your code)
+For users of Macaulay2 and/or Singular: look at the documentation of the
+respective program, if and how this is incorporated.
+
+o Factorization is slow for large polynomials. There are mainly two reasons
+  for this:
+   a) the factorization algorithm is shipped with no "tricks" yet. (I'm working
+      on that, but it heavily depends on b) )
+   b) factory has an extremely slow GCD-algorithm for the case of 
+      characteristic  p>0 ( people are working on it )
+  There will be a quite different, faster factorization algorithm in the 
+  future.
+
+Problems will be fixed in a later version of libfac .
+
+######### Changes:
+Version coding scheme: major.minor.bugfixnumber
+          e.g.: 0.1 major=0 minor=1 no bugfixnumber (no bugfix incorporated)
+
+V0.1	o Initial version for alpha-testers
+
+V0.2	o Added neworder(..) and reorder(..) for IrrCharSeries
+	o Added external strings (in factor/version.cc):
+	    libfac_name     - the name of the game
+	    libfac_version  - the version number
+	    libfac_date     - the date libfac_version was released
+	    libfac_author   - who wants to know?
+	o added support for factorization of homogeneous polynomials (in 
+          factor/homogfactor.cc), 
+          reorganized code in factor/Factor.cc and factor/Factor.h
+	o added files factor/debug.cc, factor/debug.h, factor/timing.h; 
+	  mainly for internal use
+
+V0.2.1  o changed lc == 1 to lc == unit in choose_mainvar (factor/Factor.cc)
+        o changed cerr and cout messages for use with Singular (all .cc files)
+          (why the hell don't they use libiostream?)
+        o added configure -- basics only; (old)Makefile changed to 
+          Makefile.dist (if nothing works...) 
+          Makefile produced with configure uses GNU coding standards
+	o released Apr 25 1997
+
+V0.2.2	o Added ranlib in Makefile.in after installing - Sun's seem to need it
+	o Put -I. before CPPFLAGS in Makefile.in
+	o hardcoded ./install-sh and ./mkinstalldirs in Makefile.in for 
+	  INSTALL; some machines have a broken install (e.g. HP )
+	  commented out the search for AC_PROG_INSTALL in configure.in
+	o Internal note: Singular now contains definitions from class.cc and
+	  tmpl_inst.h in claptmpl.cc
+	o released May 15 1997
+
+V0.2.3	o Added factor/interrupt.cc and interrupt.h to support interrupting
+	  calculations: We define a global variable "libfac_interruptflag"
+          in factor/version.cc which, if not zero, interrupts the ongoing
+	  calculation. Factorize() will then return an empty list (CFFList), 
+	  IrrCharSeries will return an empty list of lists (ListCFList).
+	  Modified: factor/Factor.cc and charset/charset.cc for this purpose.
+	o version for Macaulay2-Testers
+	o released May 28 1997
+
+V0.2.4	o Changed factor/SqrFree.cc (SqrFreed): Have to interchange variables 
+          if one derivative is zero but not all (e.g. no p'th power)
+	  example: (y^12+x^10)^2 mod 5
+	  Internal note: have to look at SqrFreeTest!!
+	o Changed factor/Factor.cc (Factorize): multiplied exponent of factors
+	  into Output (should be one if Sqrfree doesn't fail); this is for
+	  security only (and should be removed later..)
+	o Changed factor/helpstuff (myappend): added support for lists with
+	  multiple copies of one element (this doesn't happen for this 
+	  algorithms... but you never know)
+	o Changed factor/interrupt.{cc|h}: Removed interrupt.cc; added (inline)
+	  code to interrupt.h; factor.h will now define the external variable
+	  "libfac_interruptflag"
+	  Doesn't any longer issue any message about user-interrupt - the 
+	  CA-System, which has control, should warn user that calculation is 
+	  aborted. Removed libfac_messageflag from factor/version.cc
+	o Summary: removed: factor/interrupt.cc
+		   changed: factor/SqrFree.cc factor/Factor.cc 
+			    factor/helpstuff.cc Makefile.in configure.in 
+			    factor/interrupt.h factor.h factor/version.cc 
+	o Internal note: something changed in unvivariate factorization over
+	  extension fields from factory-1.2b to 1.2c: same polynomial now uses
+	  4 to 12 times longer to factor! Perhaps it's this new random 
+          generator?
+	o released May 30 1997
+
+V0.3.0a	o changed configure.in: will not override CFLAGS or CXXFLAGS if set in
+	  the environment
+	o added new functionality in charset/algfacor.{cc/h} :
+          now we should be able to factorize over any field needed for the
+	  charset-algorithm. (Internal note: perhaps there are still problems
+	  for the char=0 case because of the factory implementation vs. gmp)
+	o for this,  changed charset/csutil.{cc/h} and charset/charset.{cc/h}
+	o include #include <file.h> in file.cc for some CC's
+	o Internal note: need more interrupt handles enabled;
+			 set up test examples for char=0 and char>0;
+	o released Jun 25 1997
+
+V0.3.0b o implemented Tragers algorithm; this is now the default used in 
+          charsets (file: charsets/alg_factor.cc)
+        o for char=0 case there are some problems with factory;
+          for char=p there seems to be an internal factory memory-problem in
+          some cases
+        o released Sep 11 1997
+
+V0.3.1  o now ready for cygwin32
+	o released Jan 15 1998
+
+V0.3.2	o New Copyright
+	o released Jan 31 2001
Index: libfac/CMakeLists.txt
===================================================================
--- libfac/CMakeLists.txt	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/CMakeLists.txt	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,124 @@
+# -*- mode: cmake; -*-
+cmake_minimum_required(VERSION 2.6)
+cmake_policy(VERSION 2.6)
+if(POLICY CMP0011)
+  cmake_policy(SET CMP0011 NEW)
+endif(POLICY CMP0011)
+
+project(libfac)
+string(TOUPPER ${PROJECT_NAME} UPPER_PROJECT_NAME)
+
+# have the full monty in makefiles
+set(CMAKE_VERBOSE_MAKEFILE true)
+
+set(LIBFAC_V_MAJOR 3)
+set(LIBFAC_V_MINOR 1)
+set(LIBFAC_V_PATCH 0)
+set(LIBFAC_NAME   "Factorization and characteristic sets library")
+set(LIBFAC_DATE   "Aug 2008")
+set(LIBFAC_AUTHOR "M. Messollen")
+
+#OPTION(WITH_SINGULAR "build for use with Singular" Off)
+#OPTION(WITH_SINGULARERROR "use error reporting from Singular" Off)
+OPTION(WITH_NOSTREAMIO    "do not require iostream include nor library" Off)
+set(ADD_DEFS "NOSTREAMIO;${_OSDEF};HAVE_CONFIG_H;SINGULAR")
+
+
+###################################################################################################
+# No user settings below
+###################################################################################################
+include(LibfacMacros)
+
+###################################################################################################
+if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
+  message(STATUS "Have compiler: '${CMAKE_CXX_COMPILER_ID}'")
+  if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
+
+    #set(CMAKE_CXX_FLAGS "-W -Wall -Wextra -Wno-non-virtual-dtor")
+    set(CMAKE_CXX_FLAGS "-w --no-rtti -pipe ")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-implicit-templates")
+    #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+
+    set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fomit-frame-pointer -DNDEBUG")
+
+    set(CMAKE_CXX_FLAGS_DEBUG "-Werror -O0 -g -ggdb -Wreturn-type -fno-omit-frame-pointer")
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wunused-variable -Wunused-parameter")
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wunused-function -Wunused")
+    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Woverloaded-virtual -Wno-system-headers")
+
+    # gprof and gcov support
+    set(CMAKE_CXX_FLAGS_PROFILE "-O0 -g -ggdb -Wreturn-type -Woverloaded-virtual")
+    set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_PROFILE} -Wno-system-headers -pg")
+    set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_PROFILE} -fprofile-arcs -ftest-coverage")
+  endif (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
+endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
+
+###########################################################
+# Where are the additional libraries installed? Note: provide includes
+# path here, subsequent checks will resolve everything else
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/charset)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/factor)
+include_directories(${CMAKE_BINARY_DIR})
+include_directories(${CMAKE_SOURCE_DIR})
+include_directories(${CMAKE_BINARY_DIR}/factory)
+include_directories(${CMAKE_SOURCE_DIR}/factory)
+
+libfac_mk_version(LIBFAC_VERSION_H)
+
+
+##
+## src and objects
+##
+
+set(FACTORSRC1  factor/SqrFree.cc factor/Factor.cc 
+		factor/MVMultiHensel.cc factor/Truefactor.cc 
+		factor/helpstuff.cc  factor/version.cc 
+		factor/homogfactor.cc )
+set(FACTORSRC2 	factor/tmpl_inst.cc)
+set(FACTORSRC  	${FACTORSRC2} ${FACTORSRC1})
+
+
+set(FACTORINCL 	${LIBFAC_VERSION_H} 
+  factor/Factor.h factor/MVMultiHensel.h
+  factor/Truefactor.h factor/tmpl_inst.h factor/SqrFree.h
+  factor/helpstuff.h factor/debug.h factor/timing.h 
+  factor/homogfactor.h     factor/interrupt.h)
+set(CHARSETINCL charset/csutil.h charset/charset.h charset/reorder.h
+  charset/alg_factor.h charset/algfactor.h)
+
+set(charset_srcs  charset/csutil.cc charset/charset.cc
+  charset/reorder.cc charset/alg_factor.cc charset/algfactor.cc
+)
+
+# define libraries
+add_library(fac ${LIBFAC_VERSION_H} ${FACTORSRC} ${CHARSETSRC})
+set_source_files_properties(${FACTORSRC} PROPERTIES OBJECT_DEPENDS 
+  ${FACTORYCONF_H})
+#add_dependencies(fac ${FACTORY_TARGET})
+
+# debug library
+#add_library(fac_g ${LIBFAC_VERSION_H} ${FACTORSRC} ${CHARSETSRC})
+#set_target_properties(fac_g PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_DEBUG})
+
+# profile library
+#add_library(fac_p ${LIBFAC_VERSION_H} ${FACTORSRC} ${CHARSETSRC})
+#set_target_properties(fac_p PROPERTIES COMPILE_FLAGS ${CMAKE_CXX_FLAGS_PROFILE})
+
+#
+# libraries for Singular
+if( WITH_SINGULAR )
+  message(STATUS "Compiling libfac for Singular: creating libsingfac.a")
+  add_library(singfac ${LIBFAC_VERSION_H} ${FACTORSRC1} ${charset_srcs})
+  set_target_properties(singfac PROPERTIES 
+    COMPILE_DEFINITION "${ADD_DEFS};SINGULAR")
+
+#  # debug library
+#  add_library(singfac_g ${LIBFAC_VERSION_H} ${FACTORSRC1} ${charset_srcs})
+#  set_target_properties(singfac_g PROPERTIES COMPILE_FLAGS "-DSINGULAR ${CMAKE_CXX_FLAGS_DEBUG}")
+
+#  # profile library
+#  add_library(singfac_p ${LIBFAC_VERSION_H} ${FACTORSRC1} ${charset_srcs})
+#  set_target_properties(singfac_p PROPERTIES COMPILE_FLAGS "-DSINGULAR ${CMAKE_CXX_FLAG_PROFILE}")
+endif( WITH_SINGULAR )
Index: libfac/COPYING
===================================================================
--- libfac/COPYING	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/COPYING	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,45 @@
+                        SINGULAR version 3-1
+			   Singular-Libfac
+
+                     University of Kaiserslautern
+
+      Department of Mathematics and  Centre for Computer Algebra
+
+              Author: Michael Messollen <mmessollen@web.de>
+
+                        Copyright (C) 1996-2010
+
+
+                               *NOTICE*
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation ( version 2 or version 3 of the License );
+with the following additional remarks:
+
+This package is part of the software SINGULAR. The GPL is valid for
+this package, other packages may have other copyrights.
+
+Their copyrights and licences can be found in the accompanying files
+which are distributed along with these packages.
+
+For details see the author's notice in the file 00README.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA  02111-1307  USA (see GPL)
+
+Please send any comments or bug reports to
+<singular@mathematik.uni-kl.de>.
+
+Availability
+============
+
+The latest information about SINGULAR is always available from
+`http://www.singular.uni-kl.de'.
+
Index: libfac/ChangeLog
===================================================================
--- libfac/ChangeLog	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/ChangeLog	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,88 @@
+Fri Feb 14 16:53:42 CET 2003 * hannes: bugfix
+       could not factorize x2+xy+y2 in Fp(a)[x,y], a2+a+1=0
+       added wrapper factorize2 with sanity checks/typ conversions
+
+Thu Nov  7 11:29:33 MET 2002 Hans Schoenemann <hannes@mathematik.uni-kl.de>
+       * interface to NTL
+       * many fixes
+
+Wed Aug 22 16:35:00 CEST 2001 Hans Schoenemann <hannes@mathematik.uni-kl.de>
+       * HAVE_SINGULAR_ERROR/NOSTREAMIO handling in configure
+       * search for main var in Factorize
+       * code clean up
+
+Thu Jun 28 18:27:55 CEST 2001 Hans Schoenemann <hannes@mathematik.uni-kl.de>
+
+       * fixes to resultant, newfactoras, IrrCharSeries, Factorize
+
+Tue Apr 10 15:34:04 CEST 2001 Hans Schoenemann <hannes@mathematik.uni-kl.de>
+
+       * changed copyright notice to GPL
+
+Wed Jun 03 14:42:51 1998    <pohl@FUECHSE>
+
+        * Makefile.in (CPPFLAGS): include paths fixed so that Windows
+        NT will find Factor.h before factor.h
+
+1998-05-25  Olaf Bachmann  <obachman@mathematik.uni-kl.de>
+
+        * charset/alg_factor.cc: replaced identifiers 'random' by
+        'myrandom' to avoid name conflicts with the built-in (stdlib)
+        library function 'random' which might be a macro -- and, actually
+        is  under gcc v 2.6.3
+
+
+Wed Apr 22 16:12:16 1998  Jens Schmidt  <schmidt@mathematik.uni-kl.de>
+
+        * header.tpl, factor.h, factor/version.cc (libfac_name,
+          libgac_version, libfac_date, libfac_athur): defined/declared
+           const
+
+Thu Mar 12 14:32:06 1998  Jens Schmidt  <schmidt@mathematik.uni-kl.de>
+
+        * charset/csutil.cc, charset/alg_factor.cc: all references to
+          `common_den()' replaced by `bCommonDen()'
+
+Fri Feb 27 11:32:02 1998  Jens Schmidt  <schmidt@mathematik.uni-kl.de>
+
+        * factor/tmpl_inst.cc: template names adapted (`*.cc' ->
+          `ftmpl_*.cc')
+
+Tue May 13 11:32:11 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
+
+        * Makefile.in (uninstall): took out template installation
+        (all): added OPTOBJ target so that the dir is created, if necessary
+
+Sun May 25 14:06:12 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
+
+        * configure.in: Fixed handling of CXXFLAGS -- it is not touched if
+          set as env var
+
+Fri May 23 11:10:18 1997  Olaf Bachmann  <obachman@schlupp.mathematik.uni-kl.de (Olaf Bachmann)>
+
+        * configure.in (CXXFLAGS): Check whether they are set before value
+          is assigned
+
+Tue May 13 20:09:03 1997  Olaf Bachmann  <obachman@schlupp.mathematik.uni-kl.de (Olaf Bachmann)>
+
+        * configure.in: Exit with error if factory.h was not found and
+          --enable-factory option was not explicitely given
+
+Tue May 13 11:32:11 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
+
+        * Makefile.in (uninstall): took out template installation
+
+Tue May  6 09:30:51 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
+
+        * Added ranlib after installing libs -- Suns seem to need it
+
+        * configure.in: Manuallu put INSTALL into Makefile.in
+
+Mon May  5 15:43:58 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
+
+        * added installation of templates
+
+Sat May  3 19:58:53 1997  Olaf Bachmann  <obachman@ratchwum.mathematik.uni-kl.de (Olaf Bachmann)>
+
+        * Makefile.in (CPPFLAGS): Put -I. before other CPPFLAGS
+
Index: libfac/Makefile.am
===================================================================
--- libfac/Makefile.am	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/Makefile.am	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,54 @@
+noinst_LTLIBRARIES=libfac.la libfac_g.la
+
+CXXTEMPLFLAGS =  ## -fno-implicit-templates
+
+libfac_la_CFLAGS   = -O3 -fomit-frame-pointer ${PIPE}
+libfac_g_la_CFLAGS = ${PIPE}
+
+libfac_la_CXXFLAGS   = -O3 -fomit-frame-pointer ${PIPE} ${CXXTEMPLFLAGS}
+libfac_g_la_CXXFLAGS = -g -Wextra -Wall -pedantic -Wno-long-long ${PIPE} ${CXXTEMPLFLAGS}
+# -fdiagnostics-show-option 
+
+AM_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/.. -I${top_builddir} -I${top_builddir}/.. -I${srcdir} -I${builddir} -I${srcdir}/.. -I${builddir}/.. -I${srcdir}/../include  -I${builddir}/../include -I${srcdir}/factor  -I${builddir}/factor -I${srcdir}/charset -I${builddir}/charset ${GMP_CFLAGS} ${NTL_CFLAGS}
+
+libfac_la_CPPFLAGS   = ${AM_CPPFLAGS} -DNDEBUG -DOM_NDEBUG -DHAVE_CONFIG_H
+libfac_g_la_CPPFLAGS = ${AM_CPPFLAGS} -DHAVE_CONFIG_H
+
+FACTORSRC1 =	factor/SqrFree.cc factor/Factor.cc \
+		factor/MVMultiHensel.cc factor/Truefactor.cc \
+		factor/helpstuff.cc factor/homogfactor.cc factor/version.cc
+
+FACTORSRC2 =	factor/tmpl_inst.cc  
+
+FACTORSRC = 	$(FACTORSRC1) $(FACTORSRC2) 
+
+
+CHARSETSRC1 =	charset/csutil.cc charset/charset.cc charset/reorder.cc charset/alg_factor.cc charset/algfactor.cc
+
+CHARSETSRC = 	$(CHARSETSRC1)
+
+
+SOURCES  = $(FACTORSRC) $(CHARSETSRC)
+
+noinst_HEADERS = factor/SqrFree.h factor/Factor.h \
+    factor/MVMultiHensel.h factor/Truefactor.h \
+    factor/helpstuff.h factor/homogfactor.h \
+    factor/class.h factor/debug.h factor/interrupt.h factor/timing.h \
+    factor/tmpl_inst.h \
+    charset/csutil.h charset/charset.h charset/reorder.h charset/alg_factor.h charset/algfactor.h 
+
+libfac_la_SOURCES   = $(SOURCES)
+libfac_g_la_SOURCES = $(SOURCES)
+
+
+libfac_includedir=$(includedir)/factory/libfac
+
+libfac_include_HEADERS   = libfac.h 
+
+EXTRA_DIST = factor/class.cc \
+      factor/test.cc test.cc testcs.cc header.tpl \
+      tests charset/tests bin \
+      ChangeLog 00README 
+
+
+
Index: libfac/Makefile.dist
===================================================================
--- libfac/Makefile.dist	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/Makefile.dist	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,156 @@
+#################################################
+factoryversion = 1.2b
+factorypath = ../factory/$(factoryversion)
+RM = /bin/rm -f
+MV = /bin/mv
+AR = ar cr
+RANLIB = ranlib
+LIBPREFX = libfac
+OPTMARK =
+LIBFAC = $(LIBPREFIX)$(OPTMARK).a
+LIBFAC-G = $(LIBPREFIX)-g$(OPTMARK).a 
+SINGLIBFAC = libsingfac$(OPTMARK).a
+SINGLIBFAC-G = libsingfac-g$(OPTMARK).a  
+
+STRIP = strip
+# define the debugging flags here
+#
+FACDEFINES = 
+CHARDEFINES =
+DEFINES = $(FACDEFINES) $(CHARDEFINES)
+WARN = -Wall
+ALLFLAGS = -fno-implicit-templates 
+DEBFLAGS= -g $(DEFINES) $(ALLFLAGS)
+DEBFLAGSTMPL= -g $(DEFINES) 
+OPTFLAGS = -O3 $(DEFINES) $(ALLFLAGS) 
+OPTFLAGSTMPL= -O3 $(DEFINES) 
+
+IFLAGS =  -I/usr/local/include -I$(factorypath)  -I./factor
+CXX = gcc 
+OPTCXX = gcc
+CXXFLAGS = $(WARN) 
+
+# some machines don't like `gcc` as the linker for C++ code...
+# e.g. the SUN Sparc, so we use `g++` as the linker
+LD = g++ $(ALLFLAGS)
+OPTLD = g++ -s $(ALLFLAGS) 
+LDFLAGS=
+LIBPATH = -L/usr/local/lib -L$(factorypath) -L.
+
+.SUFFIXES:      .cc .h .o
+
+DEBOBJ/%.o: %.cc ; $(CXX) -c $< $(CXXFLAGS) $(IFLAGS) $(DEBFLAGS) -o $@
+
+OPTOBJ/%.o: %.cc ; $(OPTCXX) -c $< $(CXXFLAGS) $(IFLAGS) $(OPTFLAGS) -o $@
+
+DEBOBJ/%.o: charset/%.cc ; $(CXX) -c $< $(CXXFLAGS) $(IFLAGS) $(DEBFLAGS) -o $@
+
+OPTOBJ/%.o: charset/%.cc ; $(OPTCXX) -c $< $(CXXFLAGS) $(IFLAGS) $(OPTFLAGS) -o $@
+
+DEBOBJ/%.o: factor/%.cc ; $(CXX) -c $< $(CFLAGS) $(IFLAGS) $(DEBFLAGS) -o $@
+
+OPTOBJ/%.o: factor/%.cc ; $(OPTCXX) -c $< $(CFLAGS) $(IFLAGS) $(OPTFLAGS) -o $@
+
+
+FACTORSRC1 =	factor/SqrFree.cc factor/Factor.cc \
+		factor/MVMultiHensel.cc factor/Truefactor.cc \
+		factor/helpstuff.cc  factor/debug.cc factor/version.cc \
+		factor/homogfactor.cc
+FACTORSRC1 =	factor/tmpl_inst.cc
+FACTORSRC = 	$(FACTORSRC2) $(FACTORSRC1)
+CHARSETSRC1 =	charset/csutil.cc charset/charset.cc charset/reorder.cc
+CHARSETSRC = 	$(CHARSETSRC1)
+FACTORINCL =	factor/Factor.h factor/MVMultiHensel.h factor/Truefactor.h \
+		factor/tmpl_inst.h factor/SqrFree.h factor/helpstuff.h \
+		factor/debug.h factor/timing.h factor/homogfactor.h
+CHARSETINCL =	charset/csutil.h charset/charset.h charset/reorder.h
+
+OPTFACTOROBJ1 =	OPTOBJ/SqrFree.o OPTOBJ/Factor.o OPTOBJ/MVMultiHensel.o \
+		OPTOBJ/Truefactor.o OPTOBJ/helpstuff.o OPTOBJ/version.o \
+		OPTOBJ/homogfactor.o
+OPTFACTOROBJ2 =	OPTOBJ/tmpl_inst.o
+OPTFACTOROBJ =	$(OPTFACTOROBJ2) $(OPTFACTOROBJ1)
+
+DEBFACTOROBJ1 =	DEBOBJ/SqrFree.o DEBOBJ/Factor.o DEBOBJ/MVMultiHensel.o \
+		DEBOBJ/Truefactor.o DEBOBJ/helpstuff.o DEBOBJ/version.o \
+		DEBOBJ/homogfactor.o
+DEBFACTOROBJ2 =	DEBOBJ/tmpl_inst.o
+DEBFACTOROBJ =	$(DEBFACTOROBJ2) $(DEBFACTOROBJ1)
+
+CHARSETOPTOBJ =	OPTOBJ/csutil.o OPTOBJ/charset.o OPTOBJ/reorder.o
+
+CHARSETDEBOBJ =	DEBOBJ/csutil.o DEBOBJ/charset.o DEBOBJ/reorder.o
+
+LIBS = -lfac -lcf -lmem -lgmp -lm #-lPW
+OPTLIBS = -lfac -lcf-optimize -lmem-optimize -lgmp -lm
+DEBLIBS = -lfac-g -lcf-debug -lmem-debug -lgmp -lm
+
+debtest:	libfac-g DEBOBJ/test.o
+		$(LD) -o test $(LIBPATH) DEBOBJ/test.o $(DEBLIBS)
+
+opttest:	libfac OPTOBJ/test.o
+		$(OPTLD) -o test $(LIBPATH) OPTOBJ/test.o $(OPTLIBS)
+
+libfac.a:	$(OPTFACTOROBJ) $(CHARSETOPTOBJ)
+		$(AR) $(LIBFAC) $(OPTFACTOROBJ) $(CHARSETOPTOBJ)
+		$(RANLIB) $(LIBFAC)
+libfac:		libfac.a
+
+libfac-g.a:	$(DEBFACTOROBJ) $(CHARSETDEBOBJ)
+		$(AR) $(LIBFAC-G) $(DEBFACTOROBJ) $(CHARSETDEBOBJ)
+		$(RANLIB) $(LIBFAC-G)
+libfac-g:	libfac-g.a
+
+singlibfac.a:	$(OPTFACTOROBJ1) $(CHARSETOPTOBJ)
+		$(AR) $(SINGLIBFAC) $(OPTFACTOROBJ1) $(CHARSETOPTOBJ)
+		$(RANLIB) $(SINGLIBFAC)
+singlibfac:	singlibfac.a
+
+singlibfac-g.a:	$(DEBFACTOROBJ1) $(CHARSETDEBOBJ)
+		$(AR) $(SINGLIBFAC-G) $(DEBFACTOROBJ1) $(CHARSETDEBOBJ)
+		$(RANLIB) $(SINGLIBFAC-G)
+singlibfac-g:	singlibfac-g.a
+
+debtests:	debtest
+		(cd tests ; factortest )
+
+opttests:	opttest
+		(cd tests ; factortest )
+
+tests:		opttests
+
+newdepend: $(FACTORINCL) $(CHARSETINCL)
+	./bin/makedep -P OPTOBJ $(IFLAGS) $(FACTORSRC1) \
+				> OPTOBJ/optdepend
+	./bin/makedep -P DEBOBJ $(DEFINES) $(IFLAGS) $(FACTORSRC1) \
+				> DEBOBJ/debdepend
+depend:	newdepend
+
+clean:
+	$(RM)   test $(LIBFAC) $(LIBFAC-G) $(SINGLIBFAC) $(SINGLIBFAC-g)
+
+cleanall:	clean
+	( cd charset; make cleanall )
+	$(RM)   OPTOBJ/optdepend DEBOBJ/debdepend  \
+		DEBOBJ/*.o OPTOBJ/*.o \
+
+archive:	cleanall
+		(cd charset ; make cleanall )
+	rm -f ../libfac.tgz
+
+	gtar -zcvf ../libfac.tgz  . 
+
+disk:		archive
+	mcopy ../libfac.tgz a:\libfac.tgz
+	mcopy ../libfac.tgz a:\libfac1.tgz
+
+unpack:
+	mcopy a:\libfac.tgz ../libfac.tgz
+	gtar zxvf ../libfac.tgz
+	( cd charset ; make dirs )
+
+
+DEBOBJ/tmpl_inst.o: factor/tmpl_inst.cc ; $(CXX) -c $< $(CFLAGS) $(DEBFLAGSTMPL) $(IFLAGS) -o $@
+
+OPTOBJ/tmpl_inst.o: factor/tmpl_inst.cc ; $(OPTCXX) -c $< $(CFLAGS) $(OPTFLAGSTMPL) $(IFLAGS) -o $@
+
Index: libfac/Makefile.in.SAVE_LIBFAC
===================================================================
--- libfac/Makefile.in.SAVE_LIBFAC	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/Makefile.in.SAVE_LIBFAC	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,200 @@
+#################################################
+SHELL		= /bin/sh
+RM		= -rm -f
+#################################################
+TARGETNAME		= @targetname@
+LIBFACNAME		= @libfac_name@
+LIBFACVERSION		= @libfac_version@
+LIBFACDATE		= @libfac_date@
+LIBFACAUTHOR		= @libfac_author@
+LIBFACNAME		= @libfac@
+SINGLIBFACNAME		= @libsingfac@
+LIBFACINCLUDE		= @factorH@
+#################################################
+## 
+## various paths
+##
+srcdir		= @srcdir@
+prefix 		= @prefix@
+exec_prefix	= @exec_prefix@
+libdir 		= @libdir@
+includedir	= @includedir@
+
+## 
+## various programs
+##
+AR		= @AR@ cr
+RANLIB		= @RANLIB@
+CXX		= @CXX@
+INSTALL		= ./install-sh -c
+INSTALL_DATA	= ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+MKINSTALLDIRS	= ./mkinstalldirs
+
+##
+## compiler and linker options
+##
+CXXFLAGS	= @CXXFLAGS@
+CXXTEMPLFLAGS	= @CXXTEMPLFLAGS@
+CPPFLAGS	= -I${srcdir}/factor -I${srcdir}/charset -I${srcdir} -I.. -I${prefix} @CPPFLAGS@ 
+DEFS		= @DEFS@ 
+LDFLAGS		= @LDFLAGS@
+LIBS		= -lfac -lcf -lcfmem -lgmp @LIBS@
+
+##
+## src and objects
+##
+
+FACTORSRC1 =	factor/SqrFree.cc factor/Factor.cc \
+		factor/MVMultiHensel.cc factor/Truefactor.cc \
+		factor/helpstuff.cc  factor/version.cc \
+		factor/homogfactor.cc 
+FACTORSRC2 =	factor/tmpl_inst.cc
+FACTORSRC = 	$(FACTORSRC2) $(FACTORSRC1)
+
+CHARSETSRC1 =	charset/csutil.cc charset/charset.cc charset/reorder.cc
+CHARSETSRC = 	$(CHARSETSRC1)
+
+FACTORINCL =	factor/Factor.h factor/MVMultiHensel.h factor/Truefactor.h \
+		factor/tmpl_inst.h factor/SqrFree.h factor/helpstuff.h \
+		factor/debug.h factor/timing.h factor/homogfactor.h \
+                factor/interrupt.h
+CHARSETINCL =	charset/csutil.h charset/charset.h charset/reorder.h \
+		charset/alg_factor.h charset/algfactor.h
+
+OPTFACTOROBJ1 =	OPTOBJ/SqrFree.o OPTOBJ/Factor.o OPTOBJ/MVMultiHensel.o \
+		OPTOBJ/Truefactor.o OPTOBJ/helpstuff.o OPTOBJ/version.o \
+		OPTOBJ/homogfactor.o
+OPTFACTOROBJ2 =	OPTOBJ/tmpl_inst.o
+OPTFACTOROBJ =	$(OPTFACTOROBJ2) $(OPTFACTOROBJ1)
+
+OPTCHARSETOBJ =	OPTOBJ/csutil.o OPTOBJ/charset.o OPTOBJ/reorder.o \
+		OPTOBJ/alg_factor.o OPTOBJ/algfactor.o
+
+DEBOBJ = $(OPTFACTOROBJ1:%.o=%.og) $(OPTCHARSETOBJ:%.o=%.og)
+PROFOBJ = $(OPTFACTOROBJ1:%.o=%.op) $(OPTCHARSETOBJ:%.o=%.op)
+
+##
+## Primary targets
+##
+
+.SUFFIXES:      .cc .h .o .op .og
+
+all: OPTOBJ ${TARGETNAME} libsingfac_g.a
+
+OPTOBJ:
+	${MKINSTALLDIRS} OPTOBJ
+
+OPTOBJ/%.o: %.cc OPTOBJ
+	$(CXX) $(CXXFLAGS) $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/%.o: charset/%.cc OPTOBJ
+	$(CXX) $(CXXFLAGS) $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/%.o: factor/%.cc OPTOBJ
+	$(CXX) $(CXXFLAGS) $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/tmpl_inst.o: factor/tmpl_inst.cc  OPTOBJ
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/%.op: %.cc  OPTOBJ
+	$(CXX) -O -pg $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/%.op: charset/%.cc  OPTOBJ
+	$(CXX) -O -pg $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/%.op: factor/%.cc OPTOBJ
+	$(CXX) -O -pg $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/tmpl_inst.op: factor/tmpl_inst.cc  OPTOBJ
+	$(CXX) -O -pg $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/%.og: %.cc  OPTOBJ
+	$(CXX) -g $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/%.og: charset/%.cc  OPTOBJ
+	$(CXX) -g $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/%.og: factor/%.cc OPTOBJ
+	$(CXX) -g $(CXXTEMPLFLAGS) $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+OPTOBJ/tmpl_inst.og: factor/tmpl_inst.cc  OPTOBJ
+	$(CXX) -g $(CPPFLAGS) $(DEFS) -c $< -o $@
+
+libfac:		OPTOBJ libfac.a
+
+libsingfac:	OPTOBJ libsingfac.a
+
+libsingfac_g:	OPTOBJ libsingfac_g.a
+
+libfac.a:	$(OPTFACTOROBJ) $(OPTCHARSETOBJ)
+		$(AR) ${LIBFACNAME}.a $(OPTFACTOROBJ) $(OPTCHARSETOBJ)
+		$(RANLIB) ${LIBFACNAME}.a
+
+libsingfac.a:	$(OPTFACTOROBJ1) $(OPTCHARSETOBJ)
+		$(AR) ${SINGLIBFACNAME}.a $(OPTFACTOROBJ1) $(OPTCHARSETOBJ)
+		$(RANLIB) ${SINGLIBFACNAME}.a
+
+libsingfac_g.a:	$(DEBOBJ)
+		$(AR) $@ $^
+		$(RANLIB) $@
+
+libsingfac_p.a:	$(PROFOBJ)
+		$(AR) $@ $^
+		$(RANLIB) $@
+
+install-nolns: install
+
+install install-libsingular:	all
+	${MKINSTALLDIRS} ${includedir}
+	${MKINSTALLDIRS} ${libdir}
+	${INSTALL_DATA} ${LIBFACINCLUDE} ${includedir}
+	${INSTALL_DATA} ${TARGETNAME}.a ${libdir}
+	-${INSTALL_DATA} libsingfac_g.a ${libdir}
+	$(RANLIB) ${libdir}/${TARGETNAME}.a
+	-$(RANLIB) ${libdir}/libsingfac_g.a
+
+install_all: install libsingfac_p.a
+	-${INSTALL_DATA} libsingfac_p.a ${libdir}
+	-$(RANLIB) ${libdir}/libsingfac_p.a
+
+uninstall: 
+	$(RM) ${includedir}/${LIBFACINCLUDE}
+	$(RM) ${libdir}/${LIBFACNAME}.a
+	$(RM) ${libdir}/${SINGLIBFACNAME}.a
+
+mostlyclean:
+	$(RM)	test testcs ${LIBFACNAME}.a ${SINGLIBFACNAME}.a \
+		libsingfac_g.a libsingfac_p.a 
+
+clean:	mostlyclean
+	$(RM) OPTOBJ/optdepend OPTOBJ/debdepend  \
+	      OPTOBJ/*.op OPTOBJ/*.og OPTOBJ/*.o
+
+distclean:	clean
+	$(RM) config.cache config.log config.status Makefile
+
+dist:	distclean
+	$(RM) ../libfac-${LIBFACVERSION}.tgz
+	(cd .. ; gtar -zcvf libfac-${LIBFACVERSION}.tgz libfac-${LIBFACVERSION})
+
+depend:
+	@echo "No make depend available!"
+
+########## From here on: Only for internal use!
+#################################################
+
+factest:	libfac OPTOBJ/test.o   
+		$(CXX) -o test $(LDFLAGS) OPTOBJ/test.o $(LIBS)
+
+factests:	factest
+		(cd tests ; factortest )
+
+charsettest:	libfac	OPTOBJ/testcs.o
+		$(CXX) -o testcs $(LDFLAGS) OPTOBJ/testcs.o $(LIBS)
+
+#charsettests:	charsettest
+#		(cd tests ; charsettest )
+
+tests:		factests
+
Index: libfac/bin/makedep
===================================================================
--- libfac/bin/makedep	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/bin/makedep	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,70 @@
+#!/usr/local/bin/perl
+
+# Usage: makedep [options] [files]
+
+# Configuration parameters.
+
+$CPP = "gcc -E";
+# $CPP = "cc -P";
+# $CPP = "/lib/cpp";
+
+# Process switches.
+
+$noglobincludes = 1;
+$prefix = "";
+
+while ($ARGV[0] =~ /^-/) {
+    $_ = shift;
+    if (/^-D(.*)/) {
+	$defines .= " -D" . ($1 ? $1 : shift);
+    }
+    elsif (/^-I(.*)/) {
+	$includes .= " -I" . ($1 ? $1 : shift);
+    }
+    elsif (/^-d(.*)/) {
+	$dir = ($1 ? $1 : shift);
+    }
+    elsif (/^-G/) {
+	$noglobincludes = 0;
+    }
+    elsif (/^-P/) {
+	$prefix .= ($1 ? $1 : shift) . "/";
+    }
+    else {
+	die "Unrecognized switch: $_\n";
+    }
+}
+
+# Do each file on command line.
+
+foreach $file (@ARGV) {
+    open(CPP,"$CPP $defines $includes $file|")
+	|| die "Can't run cpp: $!\n";
+
+    # Scan output for line directives.
+
+    %seen = ();
+    while (<CPP>) {
+	next unless /^#/;
+	next unless ($filename) = /^# \d.*"(.*)"/;
+	$seen{$filename}++;
+    }
+    close CPP;
+
+    # Figure out the corresponding object file name.
+
+    ($ofile = $file) =~ s/\.c$/.o/;
+    ($ofile = $ofile) =~ s/\.C$/.o/;
+    ($ofile = $ofile) =~ s/\.cpp$/.o/;
+    ($ofile = $ofile) =~ s/\.cxx$/.o/;
+    ($ofile = $ofile) =~ s/\.cc$/.o/;
+    $ofile =~ s#.*/##;
+    $ofile = "$dir/$ofile" if $dir;
+
+    # Print out the dependencies.
+
+    foreach (sort keys(%seen)) {
+        print "$prefix$ofile: $_\n" unless ( /^\// && $noglobincludes );
+    }
+    print "\n";
+}
Index: libfac/bin/makeheader
===================================================================
--- libfac/bin/makeheader	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/bin/makeheader	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,51 @@
+#!/usr/local/bin/perl
+
+###
+### makeheader - generate a header file out of several header file (ver 1.1)
+###
+
+if ( ( $#ARGV == 0 ) && ( $ARGV[0] eq '-help' ) ) {
+    die "\nThis is makeheader, a header file generation tool.\n\n" .
+	"   with makeheader it is possible to generate a single header\n" .
+	"   file out of several other header files\n" .
+	"   the parts to be included in the generated header file have\n" .
+	"   to be marked with /*BEGINPUBLIC*/ and /*ENDPUBLIC*/\n" .
+        "   to include a header file into the generated header file use\n" .
+	"   the command .INCLUDE name.h on a single line\n\n" .
+        "usage: makeheader <template> <outfile>\n\n";
+}
+
+if ( $#ARGV < 1 ) {
+    die "usage: makeheader <template> <outfile>\n\n";
+}
+
+$infile = shift( @ARGV );
+$outfile = shift( @ARGV );
+
+open( INFILE, $infile ) || 
+    die "makeheader: can not open template file $infile for reading!\n";
+open( OUTFILE, ">$outfile" ) ||
+    die "makeheader: can not open header file $outfile for writing!\n";
+
+while( $currentline = <INFILE> ) {
+    if ( index( $currentline, ".INCLUDE" ) == 0 ) {
+	$currentline =~ s/.INCLUDE //;
+	open( INCLFILE, $currentline ) ||
+	    die "can not open included file '$currentline' for reading!\n";
+	while ( $inclline = <INCLFILE> ) {
+	    if ( index( $inclline, "/*BEGINPUBLIC*/" ) >= 0 ) {
+		while (( $inclline = <INCLFILE> ) &&
+		       ( index( $inclline, "/*ENDPUBLIC*/" ) < 0 )) {
+		    print OUTFILE $inclline;
+		}
+	    }
+	}
+    }
+    else {
+	print OUTFILE $currentline;
+    }
+}
+
+close OUTFILE;
+close INFILE;
+
Index: libfac/charset/alg_factor.cc
===================================================================
--- libfac/charset/alg_factor.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/alg_factor.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,768 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////
+// FACTORY - Includes
+#include <factory.h>
+// Factor - Includes
+#include <tmpl_inst.h>
+#include <Factor.h>
+#include <SqrFree.h>
+#include <helpstuff.h>
+// Charset - Includes
+#include "csutil.h"
+#include "charset.h"
+#include "reorder.h"
+#include "algfactor.h"
+// some CC's need this:
+#include "alg_factor.h"
+
+void out_cf(char *s1,const CanonicalForm &f,char *s2);
+
+#ifdef ALGFACTORDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+
+#include <libfac/factor/debug.h>
+
+static Varlist
+Var_is_in_AS(const Varlist & uord, const CFList & Astar);
+
+int getAlgVar(const CanonicalForm &f, Variable &X)
+{
+  if (f.inBaseDomain()) return 0;
+  if (f.inCoeffDomain())
+  {
+    if (f.level()!=0)
+    {
+      X= f.mvar();
+      return 1;
+    }
+    return getAlgVar(f.LC(),X);
+  }
+  if (f.inPolyDomain())
+  {
+    if (getAlgVar(f.LC(),X)) return 1;
+    for( CFIterator i=f; i.hasTerms(); i++)
+    {
+      if (getAlgVar(i.coeff(),X)) return 1;
+    }
+  }
+  return 0;
+}
+
+////////////////////////////////////////////////////////////////////////
+// This implements the algorithm of Trager for factorization of
+// (multivariate) polynomials over algebraic extensions and so called
+// function field extensions.
+////////////////////////////////////////////////////////////////////////
+
+// // missing class: IntGenerator:
+bool IntGenerator::hasItems() const
+{
+    return 1;
+}
+
+CanonicalForm IntGenerator::item() const
+//int IntGenerator::item() const
+{
+  //return current; //CanonicalForm( current );
+  return mapinto(CanonicalForm( current ));
+}
+
+void IntGenerator::next()
+{
+    current++;
+}
+
+// replacement for factory's broken psr
+static CanonicalForm
+mypsr ( const CanonicalForm &rr, const CanonicalForm &vv, const Variable & x ){
+  CanonicalForm r=rr, v=vv, l, test, lu, lv, t, retvalue;
+  int dr, dv, d,n=0;
+
+
+  dr = degree( r, x );
+  dv = degree( v, x );
+  if (dv <= dr) {l=LC(v,x); v = v -l*power(x,dv);}
+  else { l = 1; }
+  d= dr-dv+1;
+  while ( ( dv <= dr  ) && ( r != r.genZero()) ){
+    test = power(x,dr-dv)*v*LC(r,x);
+    if ( dr == 0 ) { r= CanonicalForm(0); }
+    else { r= r - LC(r,x)*power(x,dr); }
+    r= l*r -test;
+    dr= degree(r,x);
+    n+=1;
+  }
+  r= power(l, d-n)*r;
+  return r;
+}
+
+// replacement for factory's broken resultant
+static CanonicalForm
+resultante( const CanonicalForm & f, const CanonicalForm& g, const Variable & v ){
+  bool on_rational = isOn(SW_RATIONAL);
+  On(SW_RATIONAL);
+  CanonicalForm cd = bCommonDen( f );
+  CanonicalForm fz = f * cd;
+  cd = bCommonDen( g );
+  CanonicalForm gz = g * cd;
+  if (!on_rational)  Off(SW_RATIONAL);
+
+return resultant(fz,gz,v);
+}
+
+// sqr-free routine for algebraic extensions
+// we need it! Ex.: f=c^2+2*a*c-1; as=[a^2+1]; f=(c+a)^2
+//static CFFList alg_sqrfree( const CanonicalForm & f )
+//{
+//  CFFList L;
+//
+//  L.append(CFFactor(f,1));
+//  return L;
+//}
+
+// Calculates a square free norm
+// Input: f(x, alpha) a square free polynomial over K(alpha),
+// alpha is defined by the minimal polynomial Palpha
+// K has more than S elements (S is defined in thesis; look getextension)
+static void
+sqrf_norm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
+           CFGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
+           CanonicalForm & R){
+  Variable y=PPalpha.mvar(),vf=f.mvar();
+  CanonicalForm temp, Palpha=PPalpha, t;
+  int sqfreetest=0;
+  CFFList testlist;
+  CFFListIterator i;
+
+  DEBOUTLN(CERR, "sqrf_norm_sub:      f= ", f);
+  DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
+  myrandom.reset();   s=f.mvar()-myrandom.item()*Palpha.mvar();   g=f;
+  R= CanonicalForm(0);
+  DEBOUTLN(CERR, "sqrf_norm_sub: myrandom s= ", s);
+
+  // Norm, resultante taken with respect to y
+  while ( !sqfreetest ){
+    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
+    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
+    DEBOUTLN(CERR, "sqrf_norm_sub: R= ", R);
+    // sqfree check ; R is a polynomial in K[x]
+    if ( getCharacteristic() == 0 )
+    {
+      temp= gcd(R, R.deriv(vf));
+      DEBOUTLN(CERR, "sqrf_norm_sub: temp= ", temp);
+      if (degree(temp,vf) != 0 || temp == temp.genZero() ){ sqfreetest= 0; }
+      else { sqfreetest= 1; }
+      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
+    }
+    else{
+      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
+      // Look at SqrFreeTest!
+      // (z+a^5+w)^4 with z<w<a should not give sqfreetest=1 !
+      // for now we use this workaround with Factorize...
+      // ...but it should go away soon!!!!
+      Variable X;
+      if (getAlgVar(R,X))
+      {
+        if (R.isUnivariate())
+          testlist=factorize( R, X );
+        else
+          testlist= Factorize(R, X, 0);
+      }
+      else
+        testlist= Factorize(R);
+      DEBOUTLN(CERR, "testlist= ", testlist);
+      testlist.removeFirst();
+      sqfreetest=1;
+      for ( i=testlist; i.hasItem(); i++)
+        if ( i.getItem().exp() > 1 && degree(i.getItem().factor(), R.mvar()) > 0) { sqfreetest=0; break; }
+      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
+    }
+    if ( ! sqfreetest ){
+      myrandom.next();
+      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
+      if ( getCharacteristic() == 0 ) t= CanonicalForm(mapinto(myrandom.item()));
+      else t= CanonicalForm(myrandom.item());
+      s= f.mvar()+t*Palpha.mvar(); // s defines backsubstitution
+      DEBOUTLN(CERR, "sqrf_norm_sub: testing s= ", s);
+      g= f(f.mvar()-t*Palpha.mvar(), f.mvar());
+      DEBOUTLN(CERR, "             gives g= ", g);
+    }
+  }
+}
+static void
+sqrf_agnorm_sub( const CanonicalForm & f, const CanonicalForm & PPalpha,
+           AlgExtGenerator & myrandom, CanonicalForm & s,  CanonicalForm & g,
+           CanonicalForm & R){
+  Variable y=PPalpha.mvar(),vf=f.mvar();
+  CanonicalForm temp, Palpha=PPalpha, t;
+  int sqfreetest=0;
+  CFFList testlist;
+  CFFListIterator i;
+
+  DEBOUTLN(CERR, "sqrf_norm_sub:      f= ", f);
+  DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
+  myrandom.reset();   s=f.mvar()-myrandom.item()*Palpha.mvar();   g=f;
+  R= CanonicalForm(0);
+  DEBOUTLN(CERR, "sqrf_norm_sub: myrandom s= ", s);
+
+  // Norm, resultante taken with respect to y
+  while ( !sqfreetest ){
+    DEBOUTLN(CERR, "sqrf_norm_sub: Palpha= ", Palpha);
+    R = resultante(Palpha, g, y); R= R* bCommonDen(R);
+    DEBOUTLN(CERR, "sqrf_norm_sub: R= ", R);
+    // sqfree check ; R is a polynomial in K[x]
+    if ( getCharacteristic() == 0 )
+    {
+      temp= gcd(R, R.deriv(vf));
+      DEBOUTLN(CERR, "sqrf_norm_sub: temp= ", temp);
+      if (degree(temp,vf) != 0 || temp == temp.genZero() ){ sqfreetest= 0; }
+      else { sqfreetest= 1; }
+      DEBOUTLN(CERR, "sqrf_norm_sub: sqfreetest= ", sqfreetest);
+    }
+    else{
+      DEBOUTMSG(CERR, "Starting SqrFreeTest(R)!");
+      // Look at SqrFreeTest!
+      // (z+a^5+w)^4 with z<w<a should not give sqfreetest=1 !
+      // for now we use this workaround with Factorize...
+      // ...but it should go away soon!!!!
+      Variable X;
+      if (getAlgVar(R,X))
+      {
+        if (R.isUnivariate())
+          testlist=factorize( R, X );
+        else
+          testlist= Factorize(R, X, 0);
+      }
+      else
+        testlist= Factorize(R);
+      DEBOUTLN(CERR, "testlist= ", testlist);
+      testlist.removeFirst();
+      sqfreetest=1;
+      for ( i=testlist; i.hasItem(); i++)
+        if ( i.getItem().exp() > 1 && degree(i.getItem().factor(), R.mvar()) > 0) { sqfreetest=0; break; }
+      DEBOUTLN(CERR, "SqrFreeTest(R)= ", sqfreetest);
+    }
+    if ( ! sqfreetest ){
+      myrandom.next();
+      DEBOUTLN(CERR, "sqrf_norm_sub generated new myrandom item: ", myrandom.item());
+      if ( getCharacteristic() == 0 ) t= CanonicalForm(mapinto(myrandom.item()));
+      else t= CanonicalForm(myrandom.item());
+      s= f.mvar()+t*Palpha.mvar(); // s defines backsubstitution
+      DEBOUTLN(CERR, "sqrf_norm_sub: testing s= ", s);
+      g= f(f.mvar()-t*Palpha.mvar(), f.mvar());
+      DEBOUTLN(CERR, "             gives g= ", g);
+    }
+  }
+}
+
+static void
+sqrf_norm( const CanonicalForm & f, const CanonicalForm & PPalpha,
+           const Variable & Extension, CanonicalForm & s,  CanonicalForm & g,
+           CanonicalForm & R){
+
+  DEBOUTLN(CERR, "sqrf_norm:      f= ", f);
+  DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha);
+  if ( getCharacteristic() == 0 ) {
+    IntGenerator myrandom;
+    DEBOUTMSG(CERR, "sqrf_norm: no extension, char=0");
+    sqrf_norm_sub(f,PPalpha, myrandom, s,g,R);
+    DEBOUTLN(CERR, "sqrf_norm:      f= ", f);
+    DEBOUTLN(CERR, "sqrf_norm: Palpha= ", PPalpha);
+    DEBOUTLN(CERR, "sqrf_norm:      s= ", s);
+    DEBOUTLN(CERR, "sqrf_norm:      g= ", g);
+    DEBOUTLN(CERR, "sqrf_norm:      R= ", R);
+  }
+  else if ( degree(Extension) > 0 ){ // working over Extensions
+    DEBOUTLN(CERR, "sqrf_norm: degree of extension is ", degree(Extension));
+    AlgExtGenerator myrandom(Extension);
+    sqrf_agnorm_sub(f,PPalpha, myrandom, s,g,R);
+  }
+  else{
+    FFGenerator myrandom;
+    DEBOUTMSG(CERR, "sqrf_norm: degree of extension is 0");
+    sqrf_norm_sub(f,PPalpha, myrandom, s,g,R);
+  }
+}
+
+static Varlist
+Var_is_in_AS(const Varlist & uord, const CFList & Astar){
+  Varlist output;
+  CanonicalForm elem;
+  Variable x;
+
+  for ( VarlistIterator i=uord; i.hasItem(); i++){
+    x=i.getItem();
+    for ( CFListIterator j=Astar; j.hasItem(); j++ ){
+      elem= j.getItem();
+      if ( degree(elem,x) > 0 ){ // x actually occures in Astar
+        output.append(x);
+        break;
+      }
+    }
+  }
+  return output;
+}
+
+// Look if Minimalpolynomials in Astar define seperable Extensions
+// Must be a power of p: i.e. y^{p^e}-x
+static int
+inseperable(const CFList & Astar){
+  CanonicalForm elem;
+  int Counter= 1;
+
+  if ( Astar.length() == 0 ) return 0;
+  for ( CFListIterator i=Astar; i.hasItem(); i++){
+    elem= i.getItem();
+    if ( elem.deriv() == elem.genZero() ) return Counter;
+    else Counter += 1;
+  }
+  return 0;
+}
+
+// calculate gcd of f and g in char=0
+static CanonicalForm
+gcd0( CanonicalForm f, CanonicalForm g ){
+  int charac= getCharacteristic();
+  int save=isOn(SW_RATIONAL);
+  setCharacteristic(0); Off(SW_RATIONAL);
+  CanonicalForm ff= mapinto(f), gg= mapinto(g);
+  CanonicalForm result= gcd(ff,gg);
+  setCharacteristic(charac); 
+  if (save) On(SW_RATIONAL);
+  return mapinto(result);
+}
+
+// calculate big enough extension for finite fields
+// Idea: first calculate k, such that q^k > S (->thesis, -> getextension)
+// Second, search k with gcd(k,m_i)=1, where m_i is the degree of the i'th
+// minimal polynomial. Then the minpoly f_i remains irrd. over q^k and we
+// have enough elements to plug in.
+static int
+getextension( IntList & degreelist, int n){
+  int charac= getCharacteristic();
+  setCharacteristic(0); // need it for k !
+  int k=1, m=1, length=degreelist.length();
+  IntListIterator i;
+
+  for (i=degreelist; i.hasItem(); i++) m= m*i.getItem();
+  int q=charac;
+  while (q <= ((n*m)*(n*m)/2)) { k= k+1; q= q*charac;}
+  int l=0;
+  do {
+    for (i=degreelist; i.hasItem(); i++){
+      l= l+1;
+      if ( gcd0(k,i.getItem()) == 1){
+        DEBOUTLN(CERR, "getextension: gcd == 1, l=",l);
+        if ( l==length ){ setCharacteristic(charac);  return k; }
+      }
+      else { DEBOUTMSG(CERR, "getextension: Next iteration"); break; }
+    }
+    k= k+1; l=0;
+  }
+  while ( 1 );
+}
+
+// calculate a "primitive element"
+// K must have more than S elements (->thesis, -> getextension)
+static CFList
+simpleextension(const CFList & Astar, const Variable & Extension,
+                CanonicalForm & R){
+  CFList Returnlist, Bstar=Astar;
+  CanonicalForm s, g;
+
+  DEBOUTLN(CERR, "simpleextension: Astar= ", Astar);
+  DEBOUTLN(CERR, "simpleextension:     R= ", R);
+  DEBOUTLN(CERR, "simpleextension: Extension= ", Extension);
+  if ( Astar.length() == 1 ){ R= Astar.getFirst();}
+  else{
+    R=Bstar.getFirst(); Bstar.removeFirst();
+    for ( CFListIterator i=Bstar; i.hasItem(); i++){
+      DEBOUTLN(CERR, "simpleextension: f(x)= ", i.getItem());
+      DEBOUTLN(CERR, "simpleextension: P(x)= ", R);
+      sqrf_norm(i.getItem(), R, Extension, s, g, R);
+      // spielt die Repraesentation eine Rolle?
+      // muessen wir die Nachfolger aendern, wenn s != 0 ?
+      DEBOUTLN(CERR, "simpleextension: g= ", g);
+      if ( s != 0 ) DEBOUTLN(CERR, "simpleextension: s= ", s);
+      else DEBOUTLN(CERR, "simpleextension: s= ", s);
+      DEBOUTLN(CERR, "simpleextension: R= ", R);
+      Returnlist.insert(s);
+    }
+  }
+
+  return Returnlist;
+}
+
+CanonicalForm alg_lc(const CanonicalForm &f)
+{
+  if (f.level()>0)
+  {
+    return alg_lc(f.LC());
+  }
+  //assert(f.inCoeffDomain());
+  return f;
+}
+
+// the heart of the algorithm: the one from Trager
+static CFFList
+alg_factor( const CanonicalForm & f, const CFList & Astar, const Variable & vminpoly, const Varlist & oldord, const CFList & as)
+{
+  CFFList L, Factorlist;
+  CanonicalForm R, Rstar, s, g, h;
+  CFList substlist;
+
+  DEBINCLEVEL(CERR,"alg_factor");
+  DEBOUTLN(CERR, "alg_factor: f= ", f);
+
+  //out_cf("start alg_factor:",f,"\n");
+  substlist= simpleextension(Astar, vminpoly, Rstar);
+  DEBOUTLN(CERR, "alg_factor: substlist= ", substlist);
+  DEBOUTLN(CERR, "alg_factor: minpoly Rstar= ", Rstar);
+  DEBOUTLN(CERR, "alg_factor: vminpoly= ", vminpoly);
+
+  sqrf_norm(f, Rstar, vminpoly, s, g, R );
+  //out_cf("sqrf_norm R:",R,"\n");
+  //out_cf("sqrf_norm s:",s,"\n");
+  //out_cf("sqrf_norm g:",g,"\n");
+  DEBOUTLN(CERR, "alg_factor: g= ", g);
+  DEBOUTLN(CERR, "alg_factor: s= ", s);
+  DEBOUTLN(CERR, "alg_factor: R= ", R);
+  Off(SW_RATIONAL);
+  Variable X;
+  if (getAlgVar(R,X))
+  {
+    // factorize R over alg.extension with X
+//CERR << "alg: "<< X << " mipo=" << getMipo(X,Variable('X')) <<"\n";
+    if (R.isUnivariate())
+    {
+      DEBOUTLN(CERR, "alg_factor: factorize( ", R);
+      Factorlist =  factorize( R, X );
+    }
+    else
+    {
+      #if 1
+      Variable XX;
+      CanonicalForm mipo=getMipo(X,XX);
+      CFList as(mipo);
+      DEBOUTLN(CERR, "alg_factor: newfactoras( ", R);
+      int success=1;
+      Factorlist = newfactoras(R, as , success);
+      #else
+      // factor R over k
+      DEBOUTLN(CERR, "alg_factor: Factorize( ", R);
+      Factorlist = Factorize(R);
+      #endif
+    }
+  }
+  else
+  {
+    // factor R over k
+    DEBOUTLN(CERR, "alg_factor: Factorize( ", R);
+    Factorlist = Factorize(R);
+  }
+  On(SW_RATIONAL);
+  DEBOUTLN(CERR, "alg_factor: Factorize(R)= ", Factorlist);
+  if ( !Factorlist.getFirst().factor().inCoeffDomain() )
+    Factorlist.insert(CFFactor(1,1));
+  if ( Factorlist.length() == 2 && Factorlist.getLast().exp()== 1)
+  { // irreduzibel (first entry is a constant)
+    L.append(CFFactor(f,1));
+  }
+  else
+  {
+    DEBOUTLN(CERR, "alg_factor: g= ", g);
+    CanonicalForm gnew= g(s,s.mvar());
+    DEBOUTLN(CERR, "alg_factor: gnew= ", gnew);
+    g=gnew;
+    for ( CFFListIterator i=Factorlist; i.hasItem(); i++)
+    {
+      CanonicalForm fnew=i.getItem().factor();
+      fnew= fnew(s,s.mvar());
+      DEBOUTLN(CERR, "alg_factor: fnew= ", fnew);
+      DEBOUTLN(CERR, "alg_factor: substlist= ", substlist);
+      for ( CFListIterator ii=substlist; ii.hasItem(); ii++){
+        DEBOUTLN(CERR, "alg_factor: item= ", ii.getItem());
+        fnew= fnew(ii.getItem(), ii.getItem().mvar());
+        DEBOUTLN(CERR, "alg_factor: fnew= ", fnew);
+      }
+      if (degree(i.getItem().factor()) > 0 )
+      {
+          h=alg_gcd(g,fnew,as);
+        DEBOUTLN(CERR, "  alg_factor: h= ", h);
+        DEBOUTLN(CERR, "  alg_factor: oldord= ", oldord);
+        if ( degree(h) > 0 )
+        { //otherwise it's a constant
+          g= divide(g, h,as);
+          DEBOUTLN(CERR, "alg_factor: g/h= ", g);
+          DEBOUTLN(CERR, "alg_factor: s= ", s);
+          DEBOUTLN(CERR, "alg_factor: substlist= ", substlist);
+          //out_cf("new g:",g,"\n");
+          L.append(CFFactor(h,1));
+        }
+        //else printf("degree <=1\n");
+      }
+    }
+    // we are not interested in a
+    // constant (over K_r, which can be a polynomial!)
+    if (degree(g, f.mvar())>0){ L.append(CFFactor(g,1)); }
+  }
+  CFFList LL;
+  if (getCharacteristic()>0)
+  {
+    CFFListIterator i=L;
+    CanonicalForm c_fac=1;
+    CanonicalForm c;
+    for(;i.hasItem(); i++ )
+    {
+      CanonicalForm ff=i.getItem().factor();
+      c=alg_lc(ff);
+      int e=i.getItem().exp();
+      ff/=c;
+      if (!ff.isOne()) LL.append(CFFactor(ff,e));
+      while (e>0) { c_fac*=c;e--; }
+    }
+    if (!c_fac.isOne()) LL.insert(CFFactor(c_fac,1));
+  }
+  else
+  {
+    LL=L;
+  }
+  //CFFListIterator i=LL;
+  //for(;i.hasItem(); i++ )
+  //  out_cf("end alg_f:",i.getItem().factor(),"\n");
+  //printf("end alg_factor\n");
+  DEBOUTLN(CERR, "alg_factor: L= ", LL);
+  DEBDECLEVEL(CERR,"alg_factor");
+  return LL;
+}
+
+static CFFList
+endler( const CanonicalForm & f, const CFList & AS, const Varlist & uord ){
+  CanonicalForm F=f, g, q,r;
+  CFFList Output;
+  CFList One, Two, asnew, as=AS;
+  CFListIterator i,ii;
+  VarlistIterator j;
+  Variable vg;
+
+  for (i=as; i.hasItem(); i++){
+    g= i.getItem();
+    if (g.deriv() == 0 ){
+      DEBOUTLN(CERR, "Inseperable extension detected: ", g);
+      for (j=uord; j.hasItem(); j++){
+        if ( degree(g,j.getItem()) > 0 ) vg= j.getItem();
+      }
+      // Now we have the highest transzendental in vg;
+      DEBOUTLN(CERR, "Transzendental is ", vg);
+      CanonicalForm gg=-1*g[0];
+      divrem(gg,vg,q,r); r= gg-q*vg;   gg= gg-r;
+      //DEBOUTLN(CERR, "q= ", q); DEBOUTLN(CERR, "r= ", r);
+      DEBOUTLN(CERR, "  that is ", gg);
+      DEBOUTLN(CERR, "  maps to ", g+gg);
+      One.insert(gg); Two.insert(g+gg);
+      // Now transform all remaining polys in as:
+      int x=0;
+      for (ii=i; ii.hasItem(); ii++){
+        if ( x != 0 ){
+          divrem(ii.getItem(), gg, q,r);
+//          CERR << ii.getItem() << " divided by " << gg << "\n";
+          DEBOUTLN(CERR, "q= ", q); DEBOUTLN(CERR, "r= ", r);
+          ii.append(ii.getItem()+q*g); ii.remove(1);
+          DEBOUTLN(CERR, "as= ", as);
+        }
+        x+= 1;
+      }
+      // Now transform F:
+      divrem(F, gg, q,r);
+      F= F+q*g;
+      DEBOUTLN(CERR, "new F= ", F);
+    }
+    else{ asnew.append(i.getItem());  }// just the identity
+  }
+  // factor F with minimal polys given in asnew:
+  DEBOUTLN(CERR, "Factor F=  ", F);
+  DEBOUTLN(CERR, "  with as= ", asnew);
+  int success=0;
+  CFFList factorlist= newcfactor(F,asnew, success);
+  DEBOUTLN(CERR, "  gives =  ", factorlist);
+  DEBOUTLN(CERR, "One= ", One);
+  DEBOUTLN(CERR, "Two= ", Two);
+
+  // Transform back:
+  for ( CFFListIterator k=factorlist; k.hasItem(); k++){
+    CanonicalForm factor= k.getItem().factor();
+    ii=One;
+    for (i=Two; i.hasItem(); i++){
+      DEBOUTLN(CERR, "Mapping ", i.getItem());
+      DEBOUTLN(CERR, "     to ", ii.getItem());
+      DEBOUTLN(CERR, "     in ", factor);
+      divrem(factor,i.getItem(),q,r); r=factor -q*i.getItem();
+      DEBOUTLN(CERR, "q= ", q); DEBOUTLN(CERR, "r= ", r);
+      factor= ii.getItem()*q +r; //
+      ii++;
+    }
+    Output.append(CFFactor(factor,k.getItem().exp()));
+  }
+
+  return Output;
+}
+
+
+// 1) prepares data
+// 2) for char=p we distinguish 3 cases:
+//           no transcendentals, seperable and inseperable extensions
+CFFList
+newfactoras( const CanonicalForm & f, const CFList & as, int &success){
+  Variable vf=f.mvar();
+  CFListIterator i;
+  CFFListIterator jj;
+  CFList reduceresult;
+  CFFList result;
+
+  success=1;
+  DEBINCLEVEL(CERR, "newfactoras");
+  DEBOUTLN(CERR, "newfactoras called with f= ", f);
+  DEBOUTLN(CERR, "               content(f)= ", content(f));
+  DEBOUTLN(CERR, "                       as= ", as);
+  DEBOUTLN(CERR, "newfactoras: cls(vf)= ", cls(vf));
+  DEBOUTLN(CERR, "newfactoras: cls(as.getLast())= ", cls(as.getLast()));
+  DEBOUTLN(CERR, "newfactoras: degree(f,vf)= ", degree(f,vf));
+
+// F1: [Test trivial cases]
+// 1) first trivial cases:
+  if ( (cls(vf) <= cls(as.getLast())) ||  degree(f,vf)<=1 ){
+// ||( (as.length()==1) && (degree(f,vf)==3) && (degree(as.getFirst()==2)) )
+    DEBDECLEVEL(CERR,"newfactoras");
+    return CFFList(CFFactor(f,1));
+  }
+
+// 2) List of variables:
+// 2a) Setup list of those polys in AS having degree(AS[i], AS[i].mvar()) > 1
+// 2b) Setup variableordering
+  CFList Astar;
+  Variable x;
+  CanonicalForm elem;
+  Varlist ord, uord,oldord;
+  for ( int ii=1; ii< level(vf) ; ii++ ) { uord.append(Variable(ii));  }
+  oldord= uord; oldord.append(vf);
+
+  for ( i=as; i.hasItem(); i++ ){
+    elem= i.getItem();
+    x= elem.mvar();
+    if ( degree(elem,x) > 1){ // otherwise it's not an extension
+      Astar.append(elem);
+      ord.append(x);
+    }
+  }
+  uord= Difference(uord,ord);
+  DEBOUTLN(CERR, "Astar is: ", Astar);
+  DEBOUTLN(CERR, "ord is: ", ord);
+  DEBOUTLN(CERR, "uord is: ", uord);
+
+// 3) second trivial cases: we already prooved irr. of f over no extensions
+  if ( Astar.length() == 0 ){
+    DEBDECLEVEL(CERR,"newfactoras");
+    return CFFList(CFFactor(f,1));
+  }
+
+// 4) Try to obtain a partial factorization using prop2 and prop3
+//    Use with caution! We have to proof these propositions first!
+  // Not yet implemented
+
+// 5) Look if elements in uord actually occure in any of the minimal
+//    polynomials. If no element of uord occures in any of the minimal
+//   polynomials, we don't have transzendentals.
+  Varlist newuord=Var_is_in_AS(uord,Astar);
+  DEBOUTLN(CERR, "newuord is: ", newuord);
+
+  CFFList Factorlist;
+  Varlist gcdord= Union(ord,newuord); gcdord.append(f.mvar());
+  // This is for now. we need alg_sqrfree implemented!
+  CanonicalForm Fgcd;
+          Fgcd= alg_gcd(f,f.deriv(),Astar);
+  if ( Fgcd == 0 ) DEBOUTMSG(CERR, "WARNING: p'th root ?");
+  if (( degree(Fgcd, f.mvar()) > 0) && (!(f.deriv().isZero())) ){
+    DEBOUTLN(CERR, "Nontrivial GCD found of ", f);
+    CanonicalForm Ggcd= divide(f, Fgcd,Astar);
+    DEBOUTLN(CERR, "  split into ", Fgcd);
+    DEBOUTLN(CERR, "         and ", Ggcd);
+    Fgcd= pp(Fgcd); Ggcd= pp(Ggcd);
+    DEBDECLEVEL(CERR,"newfactoras");
+    return myUnion(newfactoras(Fgcd,as,success) , newfactoras(Ggcd,as,success));
+  }
+  if ( getCharacteristic() > 0 ){
+
+    // First look for extension!
+    IntList degreelist;
+    Variable vminpoly;
+    for (i=Astar; i.hasItem(); i++){degreelist.append(degree(i.getItem()));}
+    int extdeg= getextension(degreelist, degree(f));
+    DEBOUTLN(CERR, "Extension needed of degree ", extdeg);
+
+    // Now the real stuff!
+    if ( newuord.length() == 0 ){ // no transzendentals
+      DEBOUTMSG(CERR, "No transzendentals!");
+      if ( extdeg > 1 ){
+        CanonicalForm MIPO= generate_mipo( extdeg, vminpoly);
+        DEBOUTLN(CERR, "Minpoly produced ", MIPO);
+        vminpoly= rootOf(MIPO);
+      }
+      Factorlist= alg_factor(f, Astar, vminpoly, oldord, as);
+      DEBDECLEVEL(CERR,"newfactoras");
+      return Factorlist;
+    }
+    else if ( inseperable(Astar) > 0 ){ // Look if extensions are seperable
+      // a) Use Endler
+      DEBOUTMSG(CERR, "Inseperable extensions! Using Endler!");
+      CFFList templist= endler(f,Astar, newuord);
+      DEBOUTLN(CERR, "Endler gives: ", templist);
+      return templist;
+    }
+    else{ // we are on the save side: Use trager
+      DEBOUTMSG(CERR, "Only seperable extensions!");
+      if (extdeg > 1 ){
+        CanonicalForm MIPO=generate_mipo(extdeg, vminpoly );
+        vminpoly= rootOf(MIPO);
+        DEBOUTLN(CERR, "Minpoly generated: ", MIPO);
+        DEBOUTLN(CERR, "vminpoly= ", vminpoly);
+        DEBOUTLN(CERR, "degree(vminpoly)= ", degree(vminpoly));
+      }
+      Factorlist= alg_factor(f, Astar, vminpoly, oldord, as);
+      DEBDECLEVEL(CERR,"newfactoras");
+      return Factorlist;
+    }
+  }
+  else{ // char=0 apply trager directly
+    DEBOUTMSG(CERR, "Char=0! Apply Trager!");
+    Variable vminpoly;
+    Factorlist= alg_factor(f, Astar, vminpoly, oldord, as);
+      DEBDECLEVEL(CERR,"newfactoras");
+      return Factorlist;
+  }
+
+  DEBDECLEVEL(CERR,"newfactoras");
+  return CFFList(CFFactor(f,1));
+}
+
+CFFList
+newcfactor(const CanonicalForm & f, const CFList & as, int & success ){
+  Off(SW_RATIONAL);
+  CFFList Output, output, Factors=Factorize(f); On(SW_RATIONAL);
+  Factors.removeFirst();
+
+  if ( as.length() == 0 ){ success=1; return Factors;}
+  if ( cls(f) <= cls(as.getLast()) ) { success=1; return Factors;}
+
+  success=1;
+  for ( CFFListIterator i=Factors; i.hasItem(); i++ ){
+    output=newfactoras(i.getItem().factor(),as, success);
+    for ( CFFListIterator j=output; j.hasItem(); j++)
+      Output = myappend(Output,CFFactor(j.getItem().factor(),j.getItem().exp()*i.getItem().exp()));
+  }
+  return Output;
+}
Index: libfac/charset/alg_factor.h
===================================================================
--- libfac/charset/alg_factor.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/alg_factor.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,33 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////
+
+#ifndef INCL_NEW_ALGFACTOR_H
+#define INCL_NEW_ALGFACTOR_H
+
+#include <factory.h>
+#include <tmpl_inst.h>  // for typedef's
+
+// missing class: IntGenerator:
+class IntGenerator : public CFGenerator
+{
+private:
+    int current;
+public:
+    IntGenerator() : current(0) {}
+    ~IntGenerator() {}
+    bool hasItems() const;
+    void reset() { current = 0; }
+    CanonicalForm item() const;
+    void next();
+    void operator++ () { next(); }
+    void operator++ ( int ) { next(); }
+};
+
+CFFList newfactoras( const CanonicalForm & f, const CFList & as, int &success);
+/*BEGINPUBLIC*/
+CFFList newcfactor(const CanonicalForm & f, const CFList & as, int & success );
+/*ENDPUBLIC*/
+
+#endif /* INCL_ALGFACTOR_H */
Index: libfac/charset/algfactor.cc
===================================================================
--- libfac/charset/algfactor.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/algfactor.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,182 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////
+// FACTORY - Includes
+#include <factory.h>
+// Factor - Includes
+#include <tmpl_inst.h>
+#include <Factor.h>
+#include <helpstuff.h>
+// Charset - Includes
+#include "csutil.h"
+#include "charset.h"
+#include "reorder.h"
+#include "alg_factor.h"
+// some CC's need this:
+#include "algfactor.h"
+
+#ifdef ALGFACTORDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+
+#include <libfac/factor/debug.h>
+#include "timing.h"
+TIMING_DEFINE_PRINT(newfactoras_time)
+
+int hasVar(const CanonicalForm &f, const Variable &v);
+
+static CFFList
+myminus( const CFFList & Inputlist, const CFFactor & TheFactor){
+  CFFList Outputlist ;
+  CFFactor copy;
+
+  for ( CFFListIterator i=Inputlist ; i.hasItem() ; i++ ){
+    copy = i.getItem();
+    if ( copy.factor() != TheFactor.factor() ){
+      Outputlist.append( copy );
+    }
+  }
+  return Outputlist;
+}
+
+static CFFList
+myDifference(const CFFList & Inputlist1,const CFFList & Inputlist2){
+  CFFList Outputlist=Inputlist1;
+
+  for ( CFFListIterator i=Inputlist2 ; i.hasItem() ; i++ )
+    Outputlist = myminus(Outputlist, i.getItem() );
+
+  return Outputlist;
+}
+
+
+// return 1 if as is quasilinear; 0 if not.
+static int
+isquasilinear( const CFList & as ){
+  if (as.length() <= 1) { return 1; }
+  else {
+    CFList AS=as;
+    AS.removeFirst(); // we are not interested in the first elem
+    for ( CFListIterator i=AS; i.hasItem(); i++)
+      if ( degree(i.getItem()) > 1 ) return 0;
+  }
+return 1;
+}
+
+#ifdef CHARSETNADEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+#include <libfac/factor/debug.h>
+static CFList
+charsetnA(const CFList & AS, const CFList &PS, PremForm & Remembern, const Variable & vf ){
+  CFList QS = PS, RS = PS, Cset;
+  int nas= AS.length() +1;
+
+  DEBOUTLN(CERR, "charsetnA: called with ps= ", PS);
+  while ( ! RS.isEmpty() ) {
+    Cset = BasicSet( QS );
+    DEBOUTLN(CERR, "charsetnA: Cset= ", Cset);
+    Cset=Union(Cset,AS);
+    DEBOUTLN(CERR, "charsetnA: Cset= ", Cset);
+    Remembern.FS1 = Union(Remembern.FS1, initalset1(Cset));
+    DEBOUTLN(CERR, "charsetnA: Remembern.FS1= ", Remembern.FS1);
+    DEBOUTLN(CERR, "charsetnA: Remembern.FS2= ", Remembern.FS2);
+    RS = CFList();
+    if ( Cset.length() == nas && degree(Cset.getLast(),vf) > 0 ) {
+      CFList D = Difference( QS, Cset );
+      DEBOUT(CERR, "charsetnA: Difference( ", QS);
+      DEBOUT(CERR, " , ", Cset);
+      DEBOUTLN(CERR, " ) = ", D);
+      for ( CFListIterator i = D; i.hasItem(); ++i ) {
+        CanonicalForm r = Prem( i.getItem(), Cset );
+        DEBOUT(CERR,"charsetnA: Prem(", i.getItem()  );
+        DEBOUT(CERR, ",", Cset);
+        DEBOUTLN(CERR,") = ", r);
+        if ( r != 0 ){
+          //removefactor( r, Remembern );
+            RS=Union(RS,CFList(r));
+        }
+      }
+      if ( ! checkok(RS,Remembern.FS2)) return CFList(CanonicalForm(1));
+      DEBOUTLN(CERR, "charsetnA: RS= ", RS);
+      //QS = Union( QS, RS );
+      QS=Union(AS,RS); QS.append(Cset.getLast());
+      DEBOUTLN(CERR, "charsetnA: QS= Union(QS,RS)= ", QS);
+    }
+    else{ return CFList(CanonicalForm(1)); }
+  }
+  DEBOUTLN(CERR, "charsetnA: Removed factors: ", Remembern.FS2);
+  DEBOUTLN(CERR, "charsetnA: Remembern.FS1: ", Remembern.FS1);
+
+  return Cset;
+}
+
+#ifdef ALGFACTORDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+#include <libfac/factor/debug.h>
+// compute the GCD of f and g over the algebraic field having
+// adjoing ascending set as
+CanonicalForm
+algcd(const CanonicalForm & F, const CanonicalForm & g, const CFList & as, const Varlist & order){
+  CanonicalForm f=F;
+  int nas= as.length()+1; // the length the new char. set should have!
+  Variable vf=f.mvar();
+
+//   for ( VarlistIterator i=order; i.hasItem() ; i++ ){
+//     vf= i.getItem();
+//     nas--;
+//     if ( nas==0 ) break;
+//   }
+//   nas= as.length()+1;
+
+  DEBOUTLN(CERR, "algcd called with f= ", f);
+  DEBOUTLN(CERR, "                  g= ", g);
+  DEBOUTLN(CERR, "                 as= ", as);
+  DEBOUTLN(CERR, "              order= ", order);
+  DEBOUTLN(CERR, "         choosen vf= ", vf);
+
+  // check trivial case:
+  if ( degree(f, order.getLast())==0 || degree(g, order.getLast())==0)
+  {
+    DEBOUTLN(CERR, "algcd Result= ", 1);
+    return CanonicalForm(1);
+  }
+
+  CFList bs; bs.append(f); bs.append(g);
+  PremForm Remembern;
+  CFList cs=charsetnA(as,bs,Remembern,vf);
+  DEBOUTLN(CERR, "CharSetA((as,bs))= ", cs);
+
+//    for ( VarlistIterator i=order; i.hasItem() ; i++ ){
+//      DEBOUTLN(CERR, "vf= ", i.getItem());
+//      DEBOUTLN(CERR, "CharSetA((as,bs))= " , charsetnA(as,bs,Remembern,i.getItem()));
+//    }
+
+  CanonicalForm result;
+  if (cs.length()==nas)
+  {
+    result= cs.getLast();
+    CanonicalForm c=vcontent(result,Variable(1));
+    //CanonicalForm c=result.Lc();
+    result/=c;
+    for(CFListIterator i=as;i.hasItem(); i++ )
+    {
+      if(hasVar(result,i.getItem().mvar()))
+      {
+        c=vcontent(result,Variable(i.getItem().level()+1));
+        result/=c;
+      }
+    }
+  }
+  else result= CanonicalForm(1);
+  DEBOUTLN(CERR, "algcd Result= ", result);
+  return result;
+}
Index: libfac/charset/algfactor.h
===================================================================
--- libfac/charset/algfactor.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/algfactor.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,17 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////
+
+#ifndef INCL_ALGFACTOR_H
+#define INCL_ALGFACTOR_H
+
+#include <factory.h>
+#include <tmpl_inst.h>  // for typedef's
+
+CanonicalForm algcd(const CanonicalForm & f, const CanonicalForm & g, const CFList & as, const Varlist & order);
+/*BEGINPUBLIC*/
+int hasVar(const CanonicalForm &f, const Variable &v);
+/*ENDPUBLIC*/
+
+#endif /* INCL_ALGFACTOR_H */
Index: libfac/charset/charset.cc
===================================================================
--- libfac/charset/charset.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/charset.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,553 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+/////////////////////////////////////////////////////////////
+// FACTORY - Includes
+#include <factory.h>
+#ifdef HAVE_IOSTREAM
+#define CIN std::cin
+#else
+#define CIN cin
+#endif
+// Factor - Includes
+#include <SqrFree.h>
+#include <Factor.h>
+#include <interrupt.h>
+// Charset - Includes
+#include "csutil.h"
+#include "algfactor.h"
+#include "alg_factor.h"
+// Some CC's need this:
+#include "charset.h"
+
+#ifdef BASICSETDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+
+#include <libfac/factor/debug.h>
+#include "timing.h"
+TIMING_DEFINE_PRINT(subfactorize_time)
+
+
+// forward declarations:
+static CFList     irras(CFList & AS, int &ja, CanonicalForm & reducible);
+
+#ifdef BASICSETDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+#include <libfac/factor/debug.h>
+
+// the next computes a characteristic set (a basic set in Wang's sense)
+CFList
+BasicSet( const CFList &PS )
+{
+    CFList QS = PS, BS, RS;
+    CanonicalForm b;
+    int cb;
+
+    DEBOUTLN(CERR, "BasicSet: called with ps= ", PS);
+    if ( PS.length() < 2 ) return PS;
+    while ( ! QS.isEmpty() ) {
+        b = lowestRank( QS );
+        cb = rank( b );
+        DEBOUTLN(CERR, "BasicSet: choose b  = ", b);
+        DEBOUTLN(CERR, "BasicSet: it's rank = ", cb);
+        BS=Union(CFList(b),BS);//BS.append( b );
+        if ( rank( b ) == 0 )
+            return Union(PS, CFList(b)) ; // b should be the first elem!
+        else {
+            RS = CFList();
+            // QS:= {q \in QS -{B} | q is reduced wrt b}
+            // We can process whole QS, because b is not reduced wrt. b
+            for ( CFListIterator i = QS; i.hasItem(); ++i )
+                if ( degree( i.getItem(), cb ) < degree( b ) )
+                    //RS.append( i.getItem() );
+                    RS = Union(CFList(i.getItem()),RS);
+            QS = RS;
+        }
+    }
+    DEBOUTLN(CERR, "BasicSet: returning bs= ", BS);
+    return BS;
+}
+
+int
+checkok( const CFList & PS, CFList & FS2){
+  CanonicalForm elem;
+
+  for ( CFListIterator i=PS; i.hasItem(); i++){
+    elem= i.getItem();
+    for (CFListIterator j=FS2; j.hasItem(); j++){
+      if (elem == j.getItem()){
+         //        FS2= Difference(FS2,CFList(elem));
+         return 0;
+      }
+    }
+  }
+  return 1;
+}
+
+#ifdef MCHARSETNDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+#include <libfac/factor/debug.h>
+
+// The modified CharSet (an extended characteristic set with certain factors
+// canceled; this is a characteristic set in Wang's sense)
+CFList
+MCharSetN( const CFList &PS, PremForm & Remembern ){
+  CFList QS = PS, RS = PS, CSet, OLDCS;
+
+  DEBOUTLN(CERR, "MCharSetN: called with ps= ", PS);
+  while ( ! RS.isEmpty() ) {
+    CSet = BasicSet( QS );
+    OLDCS=CSet;
+    DEBOUTLN(CERR, "MCharSetN: CS= ", CSet);
+//     if ( getNumVars(CSet.getFirst()) > 1 ){
+//       //CSet = removecontent(CSet, Remembern);
+// #ifdef MCHARSETNDEBUG
+//       CERR << "MCharSetN: CSet= " << CSet << "\n";
+// #endif
+//     }
+    Remembern.FS1 = Union(Remembern.FS1, initalset1(CSet));
+    DEBOUTLN(CERR, "MCharSetN: Remembern.FS1= ", Remembern.FS1);
+    DEBOUTLN(CERR, "MCharSetN: Remembern.FS2= ", Remembern.FS2);
+    RS = CFList();
+    if ( rank( CSet.getFirst() ) != 0 ) {
+      CFList D = Difference( QS, CSet );
+      DEBOUT(CERR, "MCharSetN: Difference( ", QS);
+      DEBOUT(CERR, " , ", CSet);
+      DEBOUTLN(CERR, " ) = ", D);
+//CERR << "MCharSetN: Difference( " << QS << " , " << CSet << " ) = " << D << "\n";
+      //PremForm Oldremember=Remembern;
+      //PremForm Newremember=Remembern;
+      for ( CFListIterator i = D; i.hasItem(); ++i ) {
+        CanonicalForm r = Prem( i.getItem(), CSet );
+        DEBOUT(CERR,"MCharSetN: Prem(", i.getItem()  );
+        DEBOUT(CERR, ",", CSet);
+        DEBOUTLN(CERR,") = ", r);
+//CERR << "MCharSetN: Prem("<< i.getItem() << "," << CSet << ") = " << r << "\n";
+        if ( r != 0 ){
+          //removefactor( r, Newremember );
+          removefactor( r, Remembern );
+          //Remembern.FS2 = Union(Remembern.FS2, Newremember.FS2);
+          //Newremember = Oldremember;
+          //if ( cls(r) > 0 )
+            //RS=Union(CFList(r),RS);//RS.append( r );
+            RS=Union(RS,CFList(r));
+        }
+      }
+      if ( ! checkok(RS,Remembern.FS2)) return CFList(CanonicalForm(1));
+      DEBOUTLN(CERR, "MCharSetN: RS= ", RS);
+      //QS = Union( QS, RS );
+      QS = Union(OLDCS,RS);
+      DEBOUTLN(CERR, "MCharSetN: QS= Union(QS,RS)= ", QS);
+    }
+    else{ return CFList(CanonicalForm(1)); }
+  }
+  DEBOUTLN(CERR, "MCharSetN: Removed factors: ", Remembern.FS2);
+  DEBOUTLN(CERR, "MCharSetN: Remembern.FS1: ", Remembern.FS1);
+
+  return CSet;
+}
+
+
+CFList
+mcharset( const CFList &PS, PremForm & Remembern ){
+  CFList cs= MCharSetN(PS, Remembern );
+  CFList rs= remsetb(Difference(PS,cs),cs);
+
+  DEBOUTLN(CERR, "mcharset: cs= ", cs);
+  DEBOUTLN(CERR, "mcharset: rs= ", rs);
+  if ( rs.length() > 0 )
+    cs= mcharset(Union(PS,Union(cs,rs)), Remembern);
+  return cs;
+}
+
+// the "original" extended characteristic set
+CFList
+CharSet( const CFList &PS ){
+  CFList QS = PS, RS = PS, CSet;
+
+  while ( ! RS.isEmpty() ) {
+    CSet = BasicSet( QS );
+    DEBOUTLN(CERR, "CharSet: CSet= ", CSet);
+    RS = CFList();
+    if ( rank( CSet.getFirst() ) != 0 ) {
+      CFList D = Difference( QS, CSet );
+      for ( CFListIterator i = D; i.hasItem(); ++i ) {
+        CanonicalForm r = Prem( i.getItem(), CSet );
+        if ( r != 0 )  RS=Union(CFList(r),RS);//RS.append( r );
+      }
+      QS = Union( QS, RS );
+    }
+  }
+  return CSet;
+}
+
+static CFList
+charseta( const CFList & PS ){
+  CFList QS = PS, RS = PS, CSet;
+
+  while ( ! RS.isEmpty() ) {
+    CSet = CharSet( QS );
+    RS = CFList();
+    if ( rank( CSet.getFirst() ) != 0 ) {
+      CFList D = Difference( QS, CSet );
+      for ( CFListIterator i = D; i.hasItem(); ++i ) {
+        CanonicalForm r = Prem( i.getItem(), CSet );
+        if ( r != 0 )  RS=Union(CFList(r),RS);//RS.append( r );
+      }
+      QS = Union(CSet,Union( QS, RS ));
+    }
+    else return CFList(CanonicalForm(1));
+  }
+  return CSet;
+}
+
+static bool
+contractsub( const CFList & cs1, const CFList & cs2 ){
+  CFListIterator i;
+
+  for ( i=cs1; i.hasItem(); i++ )
+    if ( Prem(i.getItem(),cs2 ) != 0 ) return false;
+  CFList is=initalset1(cs1);
+  for ( i=is; i.hasItem(); i++ )
+    if ( Prem(i.getItem(),cs2 ) == 0 ) return false;
+  return true;
+}
+
+static ListCFList
+contract( const ListCFList & cs){
+  ListCFList mem,ts;
+  CFList iitem,jitem;
+
+  if ( cs.length() < 2 ) return cs;
+
+  for ( ListCFListIterator i=cs; i.hasItem(); i++ ){
+    iitem=i.getItem();
+    if ( ! member(iitem, mem))
+      for ( ListCFListIterator j=i; j.hasItem(); j++){
+        jitem=j.getItem();
+        if ( ! same( iitem, jitem ) )
+          if ( ! member(jitem, mem))
+            if ( contractsub(iitem, jitem) ){
+              ts.append(jitem); mem.append(jitem);
+            }
+            else
+              if ( contractsub(jitem, iitem) ){
+                ts.append(iitem);
+              }
+      }
+  }
+  return Minus(cs,ts);
+}
+
+static ListCFList
+adjoin(const CFList & is, const CFList & qs, const ListCFList & qh ){
+  ListCFList iss,qhi;
+  ListCFListIterator j;
+  CFList iscopy,itt;
+  CFListIterator i;
+  CanonicalForm elem;
+  int ind, length;
+
+  for ( i=is ; i.hasItem(); i++ ){
+    elem=i.getItem();
+    if ( cls(elem) > 0 ) iscopy=Union(CFList(elem),iscopy);
+  }
+  if ( iscopy.isEmpty() ) return iss;
+  qhi = MyDifference(qh,qs);
+  length = qhi.length();
+  for ( i =iscopy; i.hasItem(); i++){
+    itt = Union(qs,CFList(i.getItem()));
+    ind = 0;
+    if ( length > 0 )
+      for ( j=qhi; j.hasItem(); j++ )
+        if ( subset(j.getItem(),itt )) ind=1;
+    if ( ind == 0 ) iss.append(itt);
+  }
+  return iss;
+}
+
+static ListCFList
+adjoinb(const CFList & is, const CFList & qs, const ListCFList & qh ,const CFList & cs){
+  ListCFList iss,qhi;
+  ListCFListIterator j;
+  CFList iscopy,itt;
+  CFListIterator i;
+  CanonicalForm elem;
+  int ind, length;
+
+  for ( i=is ; i.hasItem(); i++ ){
+    elem=i.getItem();
+    if ( cls(elem) > 0 ) iscopy=Union(CFList(elem),iscopy);
+  }
+  if ( iscopy.isEmpty() ) return iss;
+  qhi = MyDifference(qh,qs);
+  length = qhi.length();
+  for ( i =iscopy; i.hasItem(); i++){
+    itt = Union(Union(qs,CFList(i.getItem())),cs);
+    ind = 0;
+    if ( length > 0 )
+      for ( j=qhi; j.hasItem(); j++ )
+        if ( subset(j.getItem(),itt )) ind=1;
+    if ( ind == 0 ) {iss.append(itt);}
+  }
+  return iss;
+}
+
+static ListCFList
+sort( const ListCFList & list_to_sort ){
+  ListCFList output,copy=list_to_sort;
+  CFList l,qs1,elem;
+
+  l = copy.getLast(); copy.removeLast();
+  if ( copy.length() == 0 ){ return ListCFList(l); }
+  for ( ListCFListIterator i=copy ; i.hasItem(); i++ ){
+    elem = i.getItem();
+    if ( elem.length() > l.length() ) {
+      output = MyUnion( ListCFList(l), output);
+      l= elem;
+    }
+    else{ output = MyUnion(output, ListCFList(elem) ); }
+  }
+  //output = MyUnion(ListCFList(l),sort(output));
+  output = MyUnion(ListCFList(l),output);
+  return output;
+}
+
+#ifdef IRRCHARSERIESDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+#include <libfac/factor/debug.h>
+
+ListCFList
+IrrCharSeries( const CFList &PS, int opt ){
+  CanonicalForm reducible,reducible2;
+  CFList qs,cs,factorset,is,ts;
+  ListCFList pi,ppi,qqi,qsi,iss,qhi= ListCFList(PS);
+  int nr_of_iteration=0,ts2,highestlevel=0;
+
+//  CERR << getCharacteristic() << "\n";
+  for ( CFListIterator Ps=PS; Ps.hasItem(); Ps++ )
+    if ( level(Ps.getItem() ) > highestlevel ) highestlevel = level(Ps.getItem()) ;
+//  for ( int xx=1; xx <= highestlevel; xx++)
+//   CERR << Variable(xx) ;
+//  CERR << "\n";
+//  for ( CFListIterator Ps=PS; Ps.hasItem(); Ps++ )
+//    CERR << Ps.getItem() << ", " ;//<< "\n";
+//  CERR <<  "\n";
+  while ( ! qhi.isEmpty() ) {
+    qhi=sort(qhi);
+    DEBOUTLN(CERR, "qhi is: ", qhi);
+    qs=qhi.getFirst();
+    DEBOUTLN(CERR, "qs  is: ", qs);
+    DEBOUTLN(CERR, "ppi is: ", ppi);
+    ListCFList ppi1,ppi2;
+    select(ppi,qs.length(),ppi1,ppi2);
+    DEBOUTLN(CERR, "ppi1 is: ", ppi1);
+    DEBOUTLN(CERR, "ppi2 is: ", ppi2);
+    qqi = MyUnion(ppi2,qqi);
+    DEBOUTLN(CERR, "qqi is: ", qqi);
+    if ( nr_of_iteration == 0 ){ nr_of_iteration += 1; ppi = ListCFList(); }
+    else{ nr_of_iteration += 1; ppi = MyUnion(ListCFList(qs),ppi1); }
+    DEBOUTLN(CERR,"ppi is: ", ppi);
+    PremForm Remembern;
+    cs = MCharSetN(qs,Remembern);
+    DEBOUTLN(CERR, "cs is: ", cs);
+    DEBOUTLN(CERR, "factorset is: ", Remembern.FS2);
+    cs = removecontent(cs,Remembern);
+    factorset=Remembern.FS2;
+    DEBOUTLN(CERR, "cs (after removecontent) is: ", cs);
+    DEBOUTLN(CERR, "factorset is: ", factorset);
+    // Hier: removecontent einfuegen!!!!
+    if ( cls(cs.getFirst()) > 0 ){
+      ts = irras(cs,ts2, reducible);
+
+      // INTERRUPTHANDLER
+      if ( interrupt_handle() ) return ListCFList() ;
+      // INTERRUPTHANDLER
+
+      DEBOUTLN(CERR, "ts is: ", ts);
+      DEBOUTLN(CERR, "ts2 is: ", ts2);
+      // next is preliminary: should be ==0
+      if ( ts2 <= 0 ){ //irreducible
+        if ( ! subset(cs,qs) ){
+          DEBOUTMSG(CERR, "cs is not a subset of qs");
+          cs = charseta(Union(qs,cs));
+          DEBOUTLN(CERR, "new cs is: ", cs);
+        }
+        if ( ! member(cs,pi) ){
+          pi = MyUnion(pi, ListCFList(cs));
+          DEBOUTMSG(CERR, "cs is not a member of pi");
+          DEBOUTLN(CERR, "pi is: ", pi);
+          if ( cls(cs.getFirst()) > 0 ){
+            ts = irras(cs,ts2,reducible);
+
+            // INTERRUPTHANDLER
+            if ( interrupt_handle() ) return ListCFList() ;
+            // INTERRUPTHANDLER
+
+            DEBOUTLN(CERR, "ts is: ", ts);
+            DEBOUTLN(CERR, "ts2 is: ", ts2);
+            // next is preliminary: should be ==0
+            if ( ts2 <= 0 ){ //irreducible
+              qsi = MyUnion(qsi,ListCFList(cs));
+              DEBOUTLN(CERR, "qsi is: ", qsi);
+              if ( cs.length() == highestlevel ){
+                DEBOUTLN(CERR, "cs.length() == nops(ord) :", cs.length());
+                is = factorps(factorset);
+              }
+              else{
+                DEBOUT(CERR,"cs.length() != nops(ord) :", cs.length());
+                DEBOUTLN(CERR, "  nops(ord)= ", highestlevel);
+                is = Union(initalset1(cs),factorps(factorset));
+              }
+              DEBOUTLN(CERR, "is is: ", is);
+              iss = adjoin(is,qs,qqi);
+              DEBOUTLN(CERR, "iss is: ", iss);
+            }
+          }
+          else{ iss = adjoin(factorps(factorset),qs,qqi); }
+        }
+        else{
+          DEBOUTMSG(CERR, "cs is a member of pi");
+          iss = adjoin(factorps(factorset),qs,qqi); }
+        DEBOUTLN(CERR, "iss is: ", iss);
+        DEBOUTLN(CERR, "   factorps(factorset)= ", factorps(factorset));
+        DEBOUTLN(CERR, "   qs= ", qs);
+        DEBOUTLN(CERR, "   qqi= ", qqi);
+      }
+      // next is preliminary: should be !=0
+      if ( ts2 > 0 ){
+        is = factorps(factorset);
+        DEBOUTLN(CERR, "is is: ", is);
+        if ( ts2 > 1 ){
+          // setup cst: need it later for adjoinb
+          CFList cst;
+          for ( CFListIterator i=cs ; i.hasItem(); i++){
+            if ( i.getItem() == reducible ) { break; }
+            else { cst.append(i.getItem()); }
+          }
+          is = Union(initalset1(cst), is);
+          iss = MyUnion(adjoin(is,qs,qqi), adjoinb(ts,qs,qqi,cst));
+        }
+        else{ iss = adjoin(Union(is,ts),qs,qqi); }
+        DEBOUTLN(CERR, "iss is: ", iss);
+      }
+    }
+    else{
+      iss = adjoin(factorps(factorset),qs,qqi);
+      DEBOUTMSG(CERR, "case: cs is a constant.");
+      DEBOUTLN(CERR, "  qs = ", qs);
+      DEBOUTLN(CERR, "  qqi = ", qqi);
+      DEBOUTLN(CERR, "  iss = adjoin(factorps(factorset),qs,qqi) = ",iss);
+    }
+    if ( qhi.length() > 1 ){ qhi.removeFirst(); qhi = MyUnion(qhi,iss); }
+    else{ qhi = iss; }
+    DEBOUTLN(CERR, "iss is: ", iss);
+  }
+  if ( ! qsi.isEmpty() ){
+    DEBOUTLN(CERR, "qsi before contract= ", qsi);
+    if ( opt == 0 ){
+       return contract( qsi );
+    }
+    else { return qsi; }
+  }
+  else{ return ListCFList() ; }
+}
+
+// tests for characteristic sets
+//////////////////////////////////
+#ifdef IRRASDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+
+#include <libfac/factor/debug.h>
+
+static CFList
+irras( CFList & AS, int & ja, CanonicalForm & reducible)
+{
+  CFFList qs;
+  CFList ts,as;
+  CanonicalForm elem;
+  int ind=1,nr=0, success=-1;
+  CFListIterator i;
+
+  ja = 0;
+  DEBOUTLN(CERR, "irras: called with: AS= ", AS);
+  for ( i=AS; i.hasItem(); i++ )
+  {
+    elem = i.getItem();
+    nr += 1;
+    DEBOUT(CERR, "irras: factoring: ", elem);
+    if ( degree(elem) > 1 ) // linear poly's are irreduzible
+    {
+      qs = Factorize(elem);
+      // remove a constant
+      if (qs.getFirst().factor().degree()==0) qs.removeFirst();
+    }
+    else
+    {
+      qs=(CFFactor(elem,1));
+    }
+    DEBOUTLN(CERR, "  = ", qs);
+    // INTERRUPTHANDLER
+    if ( interrupt_handle() ) return CFList() ;
+    // INTERRUPTHANDLER
+
+    if ( (qs.length() >= 2 ) || (qs.getFirst().exp() > 1))
+    {
+      DEBOUTLN(CERR, "irras: Setting ind=0, ja= ", nr);
+      ja=nr; ind=0; reducible= elem;
+      break;
+    }
+    //    else{ as.append(elem) ; }
+  }
+  //  CERR << "ind= " << ind << "\n";
+  if ( (ind == 1) ) //&& ( as.length() > 1) )
+  {
+    if ( irreducible(AS) )
+    { // as quasilinear? => irreducible!
+      ja = 0;
+      DEBOUTLN(CERR, "as is irreducible. as= ", AS);
+    }
+    else
+    {
+      i=AS;
+      for ( nr=1; nr< AS.length(); nr++)
+      {
+        as.append(i.getItem());
+        i++;
+        if ( degree(i.getItem()) > 1 )
+        {  // search for a non linear elem
+          elem=i.getItem();
+          //if (as.length()==1)
+          //  qs = Factorize2(elem,as.getFirst());
+          //else
+            qs= newfactoras(elem,as,success);
+          if ( qs.length() > 1 || qs.getFirst().exp() > 1 )
+          { //found elem is reducible
+            reducible=elem;
+            ja=nr+1;
+            break;
+          }
+        }
+      }
+    }
+  }
+  for ( CFFListIterator k=qs; k.hasItem();k++)
+    ts.append(k.getItem().factor());
+  return ts;
+}
+
+///////////////////////////////////////////////////////////////////////////////
Index: libfac/charset/charset.h
===================================================================
--- libfac/charset/charset.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/charset.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,20 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+
+#ifndef INCL_CHARSET_H
+#define INCL_CHARSET_H
+
+#include <factory.h>
+#include <tmpl_inst.h>  // for typedef's
+
+CFList     BasicSet( const CFList &PS );
+CFList     CharSet( const CFList &PS );
+CFList     mcharset( const CFList &PS, PremForm & Remembern );
+int        checkok( const CFList & PS, CFList & FS2);
+/*BEGINPUBLIC*/
+CFList     MCharSetN( const CFList &PS, PremForm & Remembern );
+ListCFList IrrCharSeries( const CFList &PS, int opt=0 );
+/*ENDPUBLIC*/
+
+#endif /* INCL_CHARSET_H */
Index: libfac/charset/csutil.cc
===================================================================
--- libfac/charset/csutil.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/csutil.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,983 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+/////////////////////////////////////////////////////////////
+// FACTORY - Includes
+#include <factory.h>
+// Factor - Includes
+#include <tmpl_inst.h>
+#include <Factor.h>
+#include <SqrFree.h>
+#include <helpstuff.h>
+#include <homogfactor.h>
+// Charset - Includes
+#include "csutil.h"
+extern void out_cf(char *s1,const CanonicalForm &f,char *s2);
+extern CanonicalForm alg_lc(const CanonicalForm &f);
+extern int hasAlgVar(const CanonicalForm &f);
+
+static bool
+lowerRank ( const CanonicalForm & f, const CanonicalForm & g, int & ind )
+{
+  int df, dg;
+  Variable vf = f.mvar(), vg = g.mvar();
+
+  if ( f.inCoeffDomain() )
+  {
+    if ( g.inCoeffDomain() ) ind= 1;
+    return true;//( vg > vf );
+  }
+  else if ( g.inCoeffDomain() ) return false;
+  else if ( vf < vg ) return true;
+  else if ( vf == vg )
+  {
+    df = degree( f ); dg = degree( g );
+    if ( df < dg ) return true;
+    else if ( df == dg ) return lowerRank( LC( f ), LC( g ) , ind);
+    else return false;
+  }
+  return false;
+}
+
+CanonicalForm
+lowestRank( const CFList & F )
+{
+  CFListIterator i = F;
+  CanonicalForm f;
+  int ind=0;
+  if ( ! i.hasItem() )        return f;
+  f = i.getItem(); ++i;
+  while ( i.hasItem() )
+  {
+    //CERR << "comparing " << f << "  and " << i.getItem()
+    // << " == " << lowerRank( i.getItem(), f, ind ) << "\n";
+    if ( lowerRank( i.getItem(), f, ind ) )
+    {
+      if ( ind )
+      {
+        CFList Itemlist= get_Terms(i.getItem());
+        CFList Flist= get_Terms(f);
+
+        // Have to further compare number of terms!
+        //CERR << "compare terms! f= " << Flist.length() << "  item= "
+        //     << Itemlist.length() <<"\n";
+        if ( Itemlist.length() < Flist.length()) f = i.getItem();
+        ind=0;
+      }
+      else
+      {
+        f = i.getItem();
+      }
+    }
+    ++i;
+  }
+  return f;
+}
+
+// old version
+// CanonicalForm
+// prem ( const CanonicalForm &f, const CanonicalForm &g )
+// {
+//   CanonicalForm ff, gg, cg;
+//   int df, dg;
+//   bool reord;
+//   Variable vf, vg, v;
+//
+//   if ( (vf = f.mvar()) < (vg = g.mvar()) ) return f;
+//   else {
+//     if ( vf == vg ) {
+//       ff = f; gg = g;
+//       reord = false;
+//       v = vg;
+//     }
+//     else {
+//       v = Variable(level(f.mvar()) + 1);
+//       ff = swapvar(f,vg,v);
+//       gg = swapvar(g,vg,v);
+//       reord=true;
+//     }
+//     cg = ini( gg, v );
+//     dg = degree( gg, v );
+//     while ( ( df = degree( ff, v ) ) >= dg )
+//       ff = cg * ff - power( v, df-dg ) * gg * LC( ff, v );
+//     if ( reord ) {
+//       return swapvar( ff, vg, v );
+//     }
+//     else
+//       return ff;
+//   }
+// }
+
+CanonicalForm
+Prem ( const CanonicalForm &f, const CanonicalForm &g )
+{
+  CanonicalForm ff, gg, l, test, lu, lv, t, retvalue;
+  int df, dg;
+  bool reord;
+  Variable vf, vg, v;
+
+  if ( (vf = f.mvar()) < (vg = g.mvar()) ) return f;
+  else
+  {
+    if ( vf == vg )
+    {
+      ff = f; gg = g;
+      reord = false;
+      v = vg;
+    }
+    else
+    {
+      v = Variable(level(f.mvar()) + 1);
+      ff = swapvar(f,vg,v);
+      gg = swapvar(g,vg,v);
+      reord=true;
+    }
+    dg = degree( gg, v );
+    df = degree( ff, v );
+    if (dg <= df) {l=LC(gg); gg = gg -LC(gg)*power(v,dg);}
+    else { l = 1; }
+    while ( ( dg <= df  ) && ( !ff.isZero()) )
+    {
+      // CERR << "Start gcd..." << "\n";
+      test = gcd(l,LC(ff));
+      //CERR << "gcd(" << l << "," << LC(ff) << ")= " << test << "\n";
+      lu = l/test; lv = LC(ff)/test;
+      t = power(v,df-dg) * gg * lv;
+      if ( df == 0 ){ ff = ff.genZero(); }
+      else { ff = ff - LC(ff)*power(v,df); }
+      ff = lu*ff - t;
+      df = degree( ff, v );
+    }
+    if ( reord )
+    {
+      retvalue= swapvar( ff, vg, v );
+    }
+    else
+    {
+      retvalue= ff;
+    }
+    return retvalue;
+  }
+}
+
+static CanonicalForm
+Sprem ( const CanonicalForm &f, const CanonicalForm &g, CanonicalForm & m, CanonicalForm & q )
+{
+  CanonicalForm ff, gg, l, test, retvalue;
+  int df, dg,n;
+  bool reord;
+  Variable vf, vg, v;
+
+  if ( (vf = f.mvar()) < (vg = g.mvar()) )
+  {
+    m=CanonicalForm(0); q=CanonicalForm(0);
+    return f;
+  }
+  else
+  {
+    if ( vf == vg )
+    {
+      ff = f; gg = g;
+      reord = false;
+      v = vg; // == x
+    }
+    else
+    {
+      v = Variable(level(f.mvar()) + 1);
+      ff = swapvar(f,vg,v); // == r
+      gg = swapvar(g,vg,v); // == v
+      reord=true;
+    }
+    dg = degree( gg, v ); // == dv
+    df = degree( ff, v ); // == dr
+    if (dg <= df) {l=LC(gg); gg = gg -LC(gg)*power(v,dg);}
+    else { l = 1; }
+    n= 0;
+    while ( ( dg <= df  ) && ( !ff.isZero()) )
+    {
+      test= power(v,df-dg) * gg * LC(ff);
+      if ( df == 0 ){ff= ff.genZero();}
+      else {ff= ff - LC(ff)*power(v,df);}
+      ff = l*ff-test;
+      df= degree(ff,v);
+      n++;
+    }
+    if ( reord )
+    {
+      retvalue= swapvar( ff, vg, v );
+    }
+    else
+    {
+      retvalue= ff;
+    }
+    m= power(l,n);
+    if ( fdivides(g,m*f-retvalue) )
+      q= (m*f-retvalue)/g;
+    else
+      q= CanonicalForm(0);
+    return retvalue;
+  }
+}
+
+CanonicalForm
+divide( const CanonicalForm & ff, const CanonicalForm & f, const CFList & as)
+{
+  CanonicalForm r,m,q;
+
+  //out_cf("divide f=",ff,"\n");
+  //out_cf("divide g=",f,"\n");
+  if (f.inCoeffDomain())
+  {
+    bool b=!isOn(SW_RATIONAL);
+    On(SW_RATIONAL);
+    q=ff/f;
+    if (b) Off(SW_RATIONAL);
+  }
+  else
+    r= Sprem(ff,f,m,q); //result in q, ignore r,m
+  //CERR << "r= " << r << "  , m= " << m << "  , q= " << q << "\n";
+  r= Prem(q,as);
+  //CERR << "r= " << r << "\n";
+  //out_cf(" ->",r,"\n");
+  return r;
+}
+
+// This function allows as to be empty; in that case, it is equivalent
+// to the previous version (treating no variables as algebraic).
+static CanonicalForm
+myfitting( const CanonicalForm &f, const CFList &as )
+{
+ CanonicalForm rem=f;
+
+ if ( !(rem.isZero()) )
+ {
+   if ( getCharacteristic() > 0 )
+     return num((rem/lc(rem)));
+   else
+   {
+     On(SW_RATIONAL);
+     CanonicalForm temp= mapinto(rem);
+//      CERR << "temp= " << temp << "\n";
+//      CERR << "lc(temp)= " << lc(temp) << "\n";
+//      CERR << "temp/lc(temp)= " << temp/lc(temp) << "\n";
+//      CERR << "num(rem/lc(rem))= " << num(rem/lc(rem)) << "\n";
+
+     // If as is of length 1, and its polynomial is level 1, then
+     // we treat the first variable as algebraic and invert the leading
+     // coefficient where this variable is part of the coefficient domain.
+
+     if (as.length() == 1 && level(as.getFirst()) == 1)
+     {
+       CanonicalForm lcoeff = temp;
+       while (level(lcoeff) > 1)
+       {
+         lcoeff = LC(lcoeff);
+       }
+       // out_cf("myfitting: lcoeff = ", lcoeff, "\n");
+
+       CanonicalForm p = as.getFirst();
+       // out_cf("myfitting: p = ", p, "\n");
+
+       CanonicalForm unused, inverse;
+
+       extgcd(lcoeff, p, inverse, unused);
+       // out_cf("myfitting: inverse = ", inverse, "\n");
+
+       // This may leave temp with non-integral coefficients,
+       // which will be cleaned up below.
+       temp = temp * inverse;
+       // out_cf("myfitting: temp = ", temp, "\n");
+     }
+
+     temp= bCommonDen(temp/lc(temp))*(temp/lc(temp));
+     Off(SW_RATIONAL);
+     rem= mapinto(temp);
+     return rem;
+   }
+ }
+ else
+   return rem;
+}
+
+CanonicalForm
+Prem( const CanonicalForm &f, const CFList &L )
+{
+  CanonicalForm rem = f;
+  CFListIterator i = L;
+  for ( i.lastItem(); i.hasItem(); i-- )
+  {
+    //CERR << "   PREM: Prem(" << rem << "," ;
+    rem = Prem( rem, i.getItem() );
+    //CERR << "   PREM: Prem(" << rem << "," << i.getItem() << ")  = " << rem << "\n";
+  }
+  return myfitting(rem, CFList());
+}
+
+CanonicalForm
+Prem( const CanonicalForm &f, const CFList &L, const CFList &as )
+{
+  CanonicalForm rem = f;
+  CFListIterator i = L;
+  for ( i.lastItem(); i.hasItem(); i-- )
+  {
+    //CERR << "   PREM: Prem(" << rem << "," ;
+    rem = Prem( rem, i.getItem() );
+    //CERR << "   PREM: Prem(" << rem << "," << i.getItem() << ")  = " << rem << "\n";
+  }
+  return myfitting(rem, as);
+}
+
+CFList
+Prem( const CFList &AS, const CFList &L )
+{
+  CFList Output;
+
+  for ( CFListIterator i=AS; i.hasItem(); i++ )
+    Output = Union(CFList(Prem(i.getItem(),L)), Output);
+
+  return Output;
+}
+
+static CanonicalForm
+premasb( const CanonicalForm & f, const CFList & as)
+{
+  CanonicalForm remd=f;
+  CFList AS=as;
+
+  if ( as.length() > 1 )
+  {
+    AS.removeFirst(); // get rid of first elem
+    CanonicalForm elem;
+    while ( ! AS.isEmpty() )
+    { // thats true for at least the first iteration
+      elem= AS.getLast();
+      remd= Prem(remd,elem);
+      AS.removeLast();
+    }
+  }
+  CanonicalForm a,b;
+  if ( mydivremt(remd, as.getFirst(), a,b )){ remd= remd.genZero();}
+  else { remd= Prem(remd, as.getFirst()); }
+
+  return remd;
+}
+
+CFList
+remsetb( const CFList & ps, const CFList & as)
+{
+  CFList output;
+  CanonicalForm elem;
+  for (CFListIterator i=ps; i.hasItem(); i++)
+  {
+    elem= premasb(i.getItem(),as);
+    if ( !elem.isZero() ) output.append(elem);
+  }
+  return output;
+}
+
+// for characteristic sets
+//////////////////////////////////
+// replace the power of factors of polys in as by 1 if any
+static CFList
+nopower( const CanonicalForm & init )
+{
+  CFFList sqrfreelist;// = Factorize(init);//SqrFree(init);
+  CFList output;
+  CanonicalForm elem;
+  int count=0;
+
+  for ( CFIterator j=init; j.hasTerms(); j++ )
+    if (!(j.coeff().isOne()) ) count++;
+  //  if ( init != 1 ){
+  //  CERR << "nopower: f is " << init << "\n";
+  //  CERR << "nopower: count is " << count << "\n";}
+  if ( count > 1 ) sqrfreelist = CFFList( CFFactor(init,1));
+  else
+  {
+    sqrfreelist = Factorize(init);
+    //sqrfreelist.removeFirst();
+  }
+  for ( CFFListIterator i=sqrfreelist; i.hasItem(); i++ )
+  {
+    elem=i.getItem().factor();
+    if ( cls(elem) > 0 ) output.append(elem);
+  }
+  return output;
+}
+
+// remove the content of polys in PS; add the removed content to
+// Remembern.FS2 ( the set of removed factors )
+CFList
+removecontent ( const CFList & PS, PremForm & Remembern )
+{
+  CFListIterator i=PS;
+  if ((!i.hasItem()) || ( cls(PS.getFirst()) == 0 )) return PS;
+
+  CFList output;
+  CanonicalForm cc,elem;
+
+  for (; i.hasItem(); i++)
+  {
+    elem = i.getItem();
+    cc = content(elem, elem.mvar());
+    if ( cls(cc) > 0 )
+    {
+      output.append(elem/cc);
+      Remembern.FS2 = Union(CFList(cc), Remembern.FS2);
+    }
+    else{ output.append(elem); }
+  }
+  return output;
+}
+
+// remove possible factors in Remember.FS1 from poly r
+// Remember.FS2 contains all factors removed before
+void
+removefactor( CanonicalForm & r , PremForm & Remembern)
+{
+  int test;
+  CanonicalForm a,b,testelem;
+  CFList testlist;
+  int n=level(r);
+  CFListIterator j ;
+
+  for ( int J=1; J<= n ; J++ )
+  {
+    testlist.append(CanonicalForm(Variable(J)));
+  }
+
+  //  testlist = Union(Remembern.FS1, testlist); // add candidates
+
+  // remove already removed factors
+  for ( j = Remembern.FS2 ; j.hasItem(); j++ )
+  {
+    testelem = j.getItem();
+    while ( 1 )
+    {
+      test = mydivremt(r,testelem,a,b);
+      if ( test && b.isZero() ) r = a;
+      else break;
+    }
+  }
+
+  // Let's look if we have other canditates to remove
+  for ( j = testlist ; j.hasItem(); j++ )
+  {
+    testelem = j.getItem();
+//    if ( testelem != r && testelem != r.mvar() ){
+    if ( testelem != r )
+    {
+      while ( 1 )
+      {
+        test = divremt(r,testelem,a,b);
+        if ( test && b.isZero() )
+        {
+          Remembern.FS2= Union(Remembern.FS2, CFList(testelem));
+          r = a;
+          if ( r == 1 ) break;
+        }
+        else break;
+      }
+    }
+  }
+  //  CERR << "Remembern.FS1 = " << Remembern.FS1 << "\n";
+  //  CERR << "Remembern.FS2 = " << Remembern.FS2 << "\n";
+  //  Remembern.FS1 = Difference(Remembern.FS1, Remembern.FS2);
+  //  CERR << "  New Remembern.FS1 = " << Remembern.FS1 << "\n";
+}
+
+
+// all irreducible nonconstant factors of a set of polynomials
+CFList
+factorps( const CFList &ps )
+{
+  CFList qs;
+  CFFList q;
+  CanonicalForm elem;
+
+  for ( CFListIterator i=ps; i. hasItem(); i++ )
+  {
+    q=Factorize(i.getItem());
+    q.removeFirst();
+    // Next can be simplified ( first (already removed) elem in q is the only constant
+    for ( CFFListIterator j=q; j.hasItem(); j++ )
+    {
+      elem = j.getItem().factor();
+      if ( getNumVars(elem) > 0 )
+        qs= Union(qs, CFList(myfitting(elem, CFList())));
+    }
+  }
+  return qs;
+}
+
+// the initial of poly f wrt to the order of the variables
+static CanonicalForm
+inital( const CanonicalForm &f )
+{
+  CanonicalForm leadcoeff;
+
+  if ( cls(f) == 0 ) {return f.genOne(); }
+  else
+  {
+    leadcoeff = LC(f,lvar(f));
+    //    if ( leadcoeff != 0 )
+    return myfitting(leadcoeff, CFList()); //num(leadcoeff/lc(leadcoeff));
+    //    else return leadcoeff;
+  }
+}
+
+// the set of all nonconstant factors of initals of polys in as
+// CFList
+// initalset(const CFList &as){
+//   CanonicalForm elem;
+//   CFList is, iss,iniset;
+
+//   for ( CFListIterator i=as ; i.hasItem(); i++ ){
+//     elem = inital(i.getItem());
+//     if ( cls(elem) > 0 ) is.append(elem);
+//   }
+//   iss = factorps(is);
+//   for ( CFListIterator j=iss; j.hasItem();j++ ){
+//     elem = j.getItem();
+//     if ( cls(elem) > 0 ) iniset.append(num(elem/lc(elem)));
+//   }
+//   return iniset;
+// }
+
+// the set of nonconstant initials of Cset
+// with certain repeated factors cancelled
+CFList
+initalset1(const CFList & Cset)
+{
+  CFList temp;
+  CFList initals;
+  CanonicalForm init;
+
+  for ( CFListIterator i = Cset ; i.hasItem(); i++ )
+  {
+    initals= nopower( inital(i.getItem()) );
+    //    init= inital(i.getItem());
+    for ( CFListIterator j = initals; j.hasItem(); j++)
+    {
+      init = j.getItem();
+      if ( cls(init) > 0 )
+        temp= Union(temp, CFList(init));
+    }
+  }
+  return temp;
+}
+
+// the set of nonconstant initials of Cset of those polys
+// not having their cls higher than reducible
+// with certain repeated factors cancelled
+CFList
+initalset2(const CFList & Cset, const CanonicalForm & reducible)
+{
+  CFList temp;
+  CFList initals;
+  CanonicalForm init;
+  int clsred = cls(reducible);
+
+  for ( CFListIterator i = Cset ; i.hasItem(); i++ )
+  {
+    init = i.getItem();
+    if ( cls(init) < clsred )
+    {
+      initals= nopower( inital(init) );
+      //    init= inital(i.getItem());
+      for ( CFListIterator j = initals; j.hasItem(); j++)
+      {
+        init = j.getItem();
+        if ( cls(init) > 0 )
+          temp= Union(temp, CFList(init));
+      }
+    }
+  }
+  return temp;
+}
+
+//replace the power of factors of poly in CF init by 1 if any
+// and return the sqrfree poly
+// static CanonicalForm
+// nopower1( const CanonicalForm & init ){
+//   CFFList returnlist=Factorize(init);
+//   CanonicalForm elem, test=init.genOne();
+//   for ( CFFListIterator i= returnlist; i.hasItem(); i++){
+//     elem = i.getItem().factor();
+//     if ( cls(elem)>0 ) test *= elem;
+//   }
+//   return test;
+// }
+
+// the sequence of distinct factors of f
+//CF pfactor( ..... )
+
+// //////////////////////////////////////////
+// // for IrrCharSeries
+
+#ifdef IRRCHARSERIESDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+#include <libfac/factor/debug.h>
+// examine the irreducibility of as for IrrCharSeries
+int
+irreducible( const CFList & AS)
+{
+// AS is given by AS = { A1, A2, .. Ar }, d_i = degree(Ai)
+
+// 1) we test: if d_i > 1, d_j =1 for all j<>i, then AS is irreducible.
+  bool deg1=true;
+  for ( CFListIterator i = AS ; i.hasItem(); i++ )
+  {
+    if ( degree(i.getItem()) > 1 )
+    {
+      if ( deg1 ) deg1=0;
+      else return 0; // found 2nd poly with deg > 1
+    }
+  }
+  return 1;
+}
+
+
+// select an item from PS for irras
+CFList
+select( const ListCFList & PS)
+{
+  return PS.getFirst();
+}
+
+// divide list ppi in elems having length <= and > length
+void
+select( const ListCFList & ppi, int length, ListCFList & ppi1, ListCFList & ppi2)
+{
+  CFList elem;
+  for ( ListCFListIterator i=ppi ; i.hasItem(); i++ )
+  {
+    elem = i.getItem();
+    if ( ! elem.isEmpty() )
+      if ( length <= elem.length() ){ ppi2.append(elem); }
+      else { ppi1.append(elem); }
+  }
+}
+
+
+//////////////////////////////////////////////////////////////
+// help-functions for sets
+
+// is f in F ?
+static bool
+member( const CanonicalForm &f, const CFList &F)
+{
+  for ( CFListIterator i=F; i.hasItem(); i++ )
+    if ( i.getItem() == f ) return 1;
+  return 0;
+}
+
+// are list A and B the same?
+bool
+same( const CFList &A, const CFList &B )
+{
+  CFListIterator i;
+
+  for (i = A; i.hasItem(); i++)
+    if (! member(i.getItem(), B) )  return 0;
+  for (i = B; i.hasItem(); i++)
+    if (! member(i.getItem(), A) )  return 0;
+  return 1;
+}
+
+
+// is List cs contained in List of lists pi?
+bool
+member( const CFList & cs, const ListCFList & pi )
+{
+  ListCFListIterator i;
+  CFList elem;
+
+  for ( i=pi; i.hasItem(); i++)
+  {
+    elem = i.getItem();
+    if ( same(cs,elem) ) return 1;
+  }
+  return 0;
+}
+
+// is PS a subset of Cset ?
+bool
+subset( const CFList &PS, const CFList &Cset )
+{
+  //  CERR << "subset: called with: " << PS << "   " << Cset << "\n";
+  for ( CFListIterator i=PS; i.hasItem(); i++ )
+    if ( ! member(i.getItem(), Cset) )
+    {
+      //      CERR << "subset: " << i.getItem() << "  is not a member of " << Cset << "\n";
+      return 0;
+    }
+  return 1;
+}
+
+// Union of two List of Lists
+ListCFList
+MyUnion( const ListCFList & a, const ListCFList &b )
+{
+  ListCFList output;
+  ListCFListIterator i;
+  CFList elem;
+
+  for ( i = a ; i.hasItem(); i++ )
+  {
+    elem=i.getItem();
+    if ( (! elem.isEmpty()) && ( ! member(elem,output)) )
+    {
+      output.append(elem);
+    }
+  }
+
+  for ( i = b ; i.hasItem(); i++ )
+  {
+    elem=i.getItem();
+    if ( (! elem.isEmpty()) && ( ! member(elem,output)) )
+    {
+      output.append(elem);
+    }
+  }
+  return output;
+}
+
+//if list b is member of the list of lists remove b and return the rest
+ListCFList
+MyDifference( const ListCFList & a, const CFList &b)
+{
+  ListCFList output;
+  ListCFListIterator i;
+  CFList elem;
+
+  for ( i = a ; i.hasItem(); i++ )
+  {
+    elem=i.getItem();
+    if ( (! elem.isEmpty()) && ( ! same(elem,b)) )
+    {
+      output.append(elem);
+    }
+  }
+return output;
+}
+
+// remove all elements of b from list of lists a and return the rest
+ListCFList
+Minus( const ListCFList & a, const ListCFList & b)
+{
+  ListCFList output=a;
+
+  for ( ListCFListIterator i=b; i.hasItem(); i++ )
+    output = MyDifference(output, i.getItem() );
+
+  return output;
+}
+
+#if 0
+static CanonicalForm alg_lc(const CanonicalForm &f, const CFList as)
+{
+  for(CFListIterator i=as; i.hasItem(); i++)
+  {
+    if (f.mvar()==i.getItem().mvar()) return f;
+  }
+  if (f.level()>0)
+  {
+    return alg_lc(f.LC(),as);
+  }
+  return CanonicalForm(1);
+}
+#endif
+
+CanonicalForm alg_gcd(const CanonicalForm & fff, const CanonicalForm &ggg,
+                      const CFList &as)
+{
+  CanonicalForm f=fff;
+  CanonicalForm g=ggg;
+  f=Prem(f,as);
+  g=Prem(g,as);
+  if ( f.isZero() )
+  {
+    if ( g.lc().sign() < 0 ) return -g;
+    else                     return g;
+  }
+  else  if ( g.isZero() )
+  {
+    if ( f.lc().sign() < 0 ) return -f;
+    else                     return f;
+  }
+  //out_cf("alg_gcd(",fff," , ");
+  //out_cf("",ggg,")\n");
+  CanonicalForm res;
+  // does as appear in f and g ?
+  bool has_alg_var=false;
+  for ( CFListIterator j=as;j.hasItem(); j++ )
+  {
+    Variable v=j.getItem().mvar();
+    if (hasVar(f,v)) {has_alg_var=true; /*break;*/}
+    if (hasVar(g,v)) {has_alg_var=true; /*break;*/}
+    //out_cf("as:",j.getItem(),"\n");
+  }
+  if (!has_alg_var)
+  {
+    if ((hasAlgVar(f))
+    || (hasAlgVar(g)))
+    {
+      Varlist ord;
+      for ( CFListIterator j=as;j.hasItem(); j++ )
+        ord.append(j.getItem().mvar());
+      res=algcd(f,g,as,ord);
+    }
+    else
+      res=gcd(f,g);
+    //out_cf("gcd=",res,"\n");
+    //out_cf("of f=",fff," , ");
+    //out_cf("and g=",ggg,"\n");
+
+    return res;
+  }
+
+  int mvf=f.level();
+  int mvg=g.level();
+  if (mvg > mvf)
+  {
+    CanonicalForm tmp=f; f=g; g=tmp;
+    int tmp2=mvf; mvf=mvg; mvg=tmp2;
+  }
+  if (g.inBaseDomain() || f.inBaseDomain())
+  {
+    //printf("const\n");
+    //out_cf("of f=",fff," , ");
+    //out_cf("and g=",ggg,"\n");
+    return CanonicalForm(1);
+  }
+
+  // gcd of all coefficients:
+  CFIterator i=f;
+  CanonicalForm c_gcd=i.coeff(); i++;
+  while( i.hasTerms())
+  {
+    c_gcd=alg_gcd(i.coeff(),c_gcd,as);
+    if (c_gcd.inBaseDomain()) break;
+    i++;
+  }
+  //printf("f.mvar=%d (%d), g.mvar=%d (%d)\n",f.level(),mvf,g.level(),mvg);
+  if (mvf!=mvg) // => mvf > mvg
+  {
+    res=alg_gcd(g,c_gcd,as);
+    //out_cf("alg_gcd1=",res,"\n");
+    //out_cf("of f=",fff," , ");
+    //out_cf("and g=",ggg,"\n");
+    return res;
+  }
+  // now: mvf==mvg, f.level()==g.level()
+  if (!c_gcd.inBaseDomain())
+  {
+    i=g;
+    while( i.hasTerms())
+    {
+      c_gcd=alg_gcd(i.coeff(),c_gcd,as);
+      if (c_gcd.inBaseDomain()) break;
+      i++;
+    }
+  }
+
+  //f/=c_gcd;
+  //g/=c_gcd;
+  if (!c_gcd.isOne())
+  {
+    f=divide(f,c_gcd,as);
+    g=divide(g,c_gcd,as);
+  }
+
+  CFList gg;
+  CanonicalForm r=1;
+  while (1)
+  {
+    //printf("f.mvar=%d, g.mvar=%d\n",f.level(),g.level());
+    gg=as;
+    if (!g.inCoeffDomain()) gg.append(g);
+    //out_cf("Prem(",f," , ");
+    //out_cf("",g,")\n");
+    if (g.inCoeffDomain()|| g.isZero())
+    {
+      //printf("in coeff domain:");
+      if (g.isZero()) { //printf("0\n");
+        i=f;
+        CanonicalForm f_gcd=i.coeff(); i++;
+        while( i.hasTerms())
+        {
+          f_gcd=alg_gcd(i.coeff(),f_gcd,as);
+          if (f_gcd.inBaseDomain()) break;
+          i++;
+        }
+        //out_cf("g=0 -> f:",f,"\n");
+        //out_cf("f_gcd:",f_gcd,"\n");
+        //out_cf("c_gcd:",c_gcd,"\n");
+        //f/=f_gcd;
+        f=divide(f,f_gcd,as);
+        //out_cf("f/f_gcd:",f,"\n");
+        f*=c_gcd;
+        //out_cf("f*c_gcd:",f,"\n");
+        CanonicalForm r_lc=alg_lc(f);
+        //out_cf("r_lc:",r_lc,"\n");
+        //f/=r_lc;
+        f=divide(f,r_lc,as);
+        //out_cf(" -> gcd:",f,"\n");
+        return f;
+      }
+      else { //printf("c\n");
+        return c_gcd;}
+    }
+    else if (g.level()==f.level()) r=Prem(f,gg,as);
+    else
+    {
+      //printf("diff. level: %d, %d\n", f.level(), g.level());
+      // g and f have different levels
+      //out_cf("c_gcd=",c_gcd,"\n");
+    //out_cf("of f=",fff," , ");
+    //out_cf("and g=",ggg,"\n");
+      return c_gcd;
+    }
+    //out_cf("->",r,"\n");
+    f=g;
+    g=r;
+  }
+  if (degree(f,Variable(mvg))==0)
+  {
+  // remark: mvf == mvg == f.level() ==g.level()
+    //out_cf("c_gcd=",c_gcd,"\n");
+    //out_cf("of f=",fff," , ");
+    //out_cf("and g=",ggg,"\n");
+    return c_gcd;
+  }
+  //out_cf("f=",f,"\n");
+  i=f;
+  CanonicalForm k=i.coeff(); i++;
+  //out_cf("k=",k,"\n");
+  while( i.hasTerms())
+  {
+    if (k.inCoeffDomain()) break;
+    k=alg_gcd(i.coeff(),k,as);
+    //out_cf("k=",k,"\n");
+    i++;
+  }
+  //out_cf("end-k=",k,"\n");
+  f/=k;
+  //out_cf("f/k=",f,"\n");
+  res=c_gcd*f;
+  CanonicalForm r_lc=alg_lc(res);
+  res/=r_lc;
+  //CanonicalForm r_lc=alg_lc(res,as);
+  //res/=r_lc;
+  //out_cf("alg_gcd2=",res,"\n");
+  //  out_cf("of f=",fff," , ");
+  //  out_cf("and g=",ggg,"\n");
+  //return res;
+  //if (res.level()<fff.level() && res.level() < ggg.level())
+  //  return alg_gcd(alg_gcd(fff,res,as),ggg,as);
+  //else
+    return res;
+}
Index: libfac/charset/csutil.h
===================================================================
--- libfac/charset/csutil.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/csutil.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,77 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+
+#ifndef INCL_CSUTIL_H
+#define INCL_CSUTIL_H
+
+#include <factory.h>
+#include "algfactor.h"
+#include <tmpl_inst.h>
+
+// inline function's:
+
+inline int 
+cls ( const CanonicalForm & f ){ if ( getNumVars(f) == 0 ) {return 0;} else {return f.level();} }
+
+inline int 
+rank ( const CanonicalForm & f ){ return cls(f); }
+
+inline CanonicalForm 
+ini ( const CanonicalForm & f ){ return LC(f); }
+
+inline CanonicalForm 
+ini ( const CanonicalForm & f , const Variable v ){ return LC(f,v); }
+
+inline Variable 
+lvar ( const CanonicalForm & f ){ return f.mvar(); }
+
+///////////////////////////////////////////////////////////////
+// a class definition needed in charset.cc for Prem
+///////////////////////////////////////////////////////////////
+/*BEGINPUBLIC*/
+
+class PremForm {
+public:
+  CFList FS1;
+  CFList FS2;
+  inline PremForm& operator=( const PremForm&  value ){
+    if ( this != &value ){
+      FS1 = value.FS1;
+      FS2 = value.FS2;
+    }
+    return *this;
+  }
+};
+
+/*ENDPUBLIC*/
+
+// functions from csutil.cc:
+/*BEGINPUBLIC*/
+CanonicalForm  Prem( const CanonicalForm &f, const CanonicalForm &g );
+CanonicalForm  Prem( const CanonicalForm &f, const CFList &L );
+CFList         Prem( const CFList &AS, const CFList &L );
+CanonicalForm alg_gcd(const CanonicalForm &, const CanonicalForm &, const CFList &);
+/*ENDPUBLIC*/
+CanonicalForm  divide( const CanonicalForm & ff, const CanonicalForm & f, const CFList & as);
+CFList         remsetb( const CFList & ps, const CFList & as);
+CanonicalForm  lowestRank( const CFList & F );
+
+CFList         removecontent ( const CFList & PS, PremForm & Remembern );
+void           removefactor( CanonicalForm & r , PremForm & Remembern);
+CFList         factorps( const CFList &ps );
+//CFList         initalset(const CFList & CSet);
+CFList         initalset1(const CFList & CSet);
+CFList         initalset2(const CFList & CSet, const CanonicalForm & reducible);
+int            irreducible( const CFList & ASet);
+CFList         select( const ListCFList & PSet);
+void           select( const ListCFList & ppi, int length, ListCFList & ppi1, 
+		       ListCFList & ppi2);
+bool           same( const CFList &A, const CFList &B );
+bool           member( const CFList & cs, const ListCFList & pi );
+bool           subset( const CFList &PSet, const CFList &CSet );
+ListCFList     MyUnion( const ListCFList & a, const ListCFList &b );
+ListCFList     MyDifference( const ListCFList & a, const CFList &b);
+ListCFList     Minus( const ListCFList & a, const ListCFList &b);
+#endif /* INCL_CSUTIL_H */
+
Index: libfac/charset/reorder.cc
===================================================================
--- libfac/charset/reorder.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/reorder.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,405 @@
+////////////////////////////////////////////////////////////
+// This is really experimental. What is the best order of the variables for
+// an ideal? Clearly, if a variable only occures in one and only one polynomial
+// this variable should be assigned the highest level.
+// But what for the others?
+//
+// The strategy used here is o.k. for *most* of the examples. But there are
+// examples where this strategy doesn't give the best possible answer.
+// So, use this at your own risk! The order given may increase or decrease
+// computing time for your example!
+/////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+// FACTORY - Includes
+#include <factory.h>
+// Factor - Includes
+#include <tmpl_inst.h>
+#include "homogfactor.h"
+// Charset - Includes
+
+// some CC's need this:
+#include "reorder.h"
+
+#ifdef REORDERDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+
+#include <libfac/factor/debug.h>
+#include "timing.h"
+TIMING_DEFINE_PRINT(neworder_time)
+
+#define __ARRAY_INIT__ -1
+
+// the maximal degree of polys in PS wrt. variable x
+static int
+degpsmax( const CFList & PS, const Variable & x, 
+	  Intarray & A, Intarray & C){
+  int varlevel = level(x);
+  if ( A[varlevel] != __ARRAY_INIT__ ) return A[varlevel];
+  int max=0,temp, count=0;
+  
+  for ( CFListIterator i=PS; i.hasItem();i++){
+    temp = degree(i.getItem(),x);
+    if ( temp > max ) {max = temp; count = 0; }
+    if ( temp == max) { count += max; } // we count the number of polys
+  }
+  A[varlevel] = max; C[varlevel] = count;
+  return max;
+}
+
+// the minimal non-zero degree of polys in PS wrt. x
+// returns 0 if variable x doesn't occure in any of the polys
+static int
+degpsmin( const CFList & PS, const Variable & x, Intarray & A, Intarray & B,
+	  Intarray & C, Intarray & D){
+  int varlevel = level(x);
+  if ( B[varlevel] != __ARRAY_INIT__ ) return B[varlevel];
+  int min=degpsmax(PS,x,A,C), temp, count=0;
+
+  if (min==0) {
+    B[varlevel] = min; D[varlevel] = min;
+    return min;
+  }
+  else
+    for ( CFListIterator i=PS; i.hasItem();i++){
+      temp = degree(i.getItem(),x);
+      if ( temp < min && temp != 0 ){ min = temp; count = 0; }
+      if ( temp == min) { count += min;} // we count the number of polys
+    }
+  B[varlevel] = min; D[varlevel] = count;
+  return min;
+}
+
+// the minimal total degree of lcoeffs of polys in PS wrt. x
+// for those polys having degree degpsmin in x.
+// F will be assigned the minimal number of terms of those lcoeffs
+static int
+Tdeg( const CFList & PS, const Variable & x, Intarray & A, Intarray & B,
+      Intarray & C, Intarray & D, Intarray & E, Intarray & F){
+  int k= degpsmin(PS,x,A,B,C,D), 
+    varlevel= level(x), min=0;
+
+  if ( E[varlevel] != __ARRAY_INIT__ ) return E[varlevel];
+  if (k == 0){
+    E[varlevel]= 0; F[varlevel]= 0;
+  }
+  else{
+    int nopslc=0;
+    CFList LCdegList;
+    CanonicalForm elem;
+    CFListIterator i;
+
+    for ( i=PS; i.hasItem(); i++ ){
+      elem = i.getItem();
+      if ( degree(elem,x) == k ) LCdegList.append(LC(elem,x));
+    }
+    
+    if ( LCdegList.length() > 0 ){
+      CFList TermList;
+      int newmin, newnopslc;
+
+      min= totaldegree(LCdegList.getFirst());
+      TermList= get_Terms(LCdegList.getFirst()); 
+      nopslc= TermList.length();
+      for ( i=LCdegList; i.hasItem(); i++){
+	elem= i.getItem();
+	newmin= totaldegree(elem);
+	TermList= get_Terms(elem);
+	newnopslc= TermList.length();
+	if ( newmin < min ) min= newmin; 
+	if ( newnopslc < nopslc ) nopslc= newnopslc;
+      }
+      
+    }
+    E[varlevel]= min;
+    F[varlevel]= nopslc;
+  }
+  return min;
+}
+
+// The number of the poly in which Variable x first occures
+static int
+nr_of_poly( const CFList & PS, const Variable & x, Intarray & G){
+  int min=0, varlevel=level(x);
+  if ( G[varlevel] != __ARRAY_INIT__ ) return G[varlevel];
+  for ( CFListIterator i=PS; i.hasItem(); i++ ){
+    min += 1;
+    if ( degree(i.getItem(),x) > 0 ) break;
+  }
+  G[varlevel]= min;
+  return min;
+}
+
+static int
+degord( const Variable & x, const Variable & y, const CFList & PS,
+	Intarray & A, Intarray & B, Intarray & C, Intarray & D,
+	Intarray & E, Intarray & F, Intarray & G){
+  int xlevel= level(x), ylevel= level(y);
+
+  if      (degpsmax(PS,y,A,C) < degpsmax(PS,x,A,C))         return 1;
+  else if (degpsmax(PS,x,A,C) < degpsmax(PS,y,A,C) )        return 0;
+  else if (C[ylevel] < C[xlevel])                           return 1;
+  else if (C[xlevel] < C[ylevel])                           return 0;
+  else if (degpsmin(PS,x,A,B,C,D) < degpsmin(PS,y,A,B,C,D)) return 1;
+  else if (degpsmin(PS,y,A,B,C,D) < degpsmin(PS,x,A,B,C,D)) return 0;
+  else if (D[ylevel] < D[xlevel])                           return 1;
+  else if (D[xlevel] < D[ylevel])                           return 0;
+  else if (Tdeg(PS,y,A,B,C,D,E,F) < Tdeg(PS,x,A,B,C,D,E,F)) return 1;
+  else if (Tdeg(PS,x,A,B,C,D,E,F) < Tdeg(PS,y,A,B,C,D,E,F)) return 0;
+  else if (F[ylevel] < F[xlevel])                           return 1;
+  else if (F[xlevel] < F[ylevel])                           return 0;
+  else if (nr_of_poly(PS,x,G) <= nr_of_poly(PS,y,G))        return 1;
+  else return 0;
+
+}
+
+// determine the highest variable of all involved Variables in PS
+// NOTE:
+//    this doesn't give always the correct answer:
+//    If a variable is assigned the highest level in the definition of the
+//    original ring, but doesn't occure in any of the 
+//    polynomials, get_max_var returns the variable with a level lower than 
+//    the highest level.
+//    Is there a workaround?
+// But for the redefinition of the ring this doesn't matter due to the
+// implementation of neworder().
+
+static Variable
+get_max_var(const CFList & PS){
+  Variable x=PS.getFirst().mvar(), y;
+  for (CFListIterator i=PS; i.hasItem(); i++){
+    y = i.getItem().mvar();
+    if ( y > x ) x=y;
+  }
+  return x;
+}
+
+
+// determine if variable x is in one and only one of the polynomials in PS
+// first criterion for neworder
+static CFList
+only_in_one( const CFList & PS , const Variable & x){
+  CFList output;
+
+  for ( CFListIterator i=PS; i.hasItem(); i++ ){
+    if ( degree(i.getItem(),x) >= 1 ) output.insert(i.getItem());
+    if ( output.length() >= 2 ) break;
+  }
+  return output;
+}
+
+// initialize all Arrays (of same range) with __ARRAY_INIT__
+static void
+initArray(const int highest_level, Intarray & A, Intarray & B, Intarray & C, 
+	  Intarray & D, Intarray & E, Intarray & F, Intarray & G){ 
+
+  for ( int i=1 ; i <= highest_level; i ++){
+    A[i] = __ARRAY_INIT__; B[i] = __ARRAY_INIT__; 
+    C[i] = __ARRAY_INIT__; D[i] = __ARRAY_INIT__;
+    E[i] = __ARRAY_INIT__; F[i] = __ARRAY_INIT__;
+    G[i] = __ARRAY_INIT__;
+  }
+}
+
+// now for the second criterion; a little more complex
+//
+// idea: set up seven arrays of lenth highest_level 
+//       (of which some entries may be empty, because of only_in_one!)
+//   A saves maxdegree of Variable x in A(level(x))
+//   B saves mindegree of Variable x in B(level(x))
+//   C saves the number of polys in PS which have degree A(level(x)) in 
+//     D(level(x))
+//   D saves the number of polys in PS which have degree B(level(x)) in 
+//     D(level(x))
+//   E saves the minimal total degree of lcoeffs of polys wrt x in E(level(x))
+//   F saves the minimal number of terms of lcoeffs of E(level(x)) in F(~)
+//   G saves nr of poly Variable x has first deg <> 0
+
+#define __INIT_GAP__ 3
+static Varlist
+reorderb(const Varlist & difference, const CFList & PS, 
+	 const int highest_level){
+  Intarray A(1, highest_level), B(1, highest_level), C(1, highest_level), 
+    D(1, highest_level), E(1, highest_level), F(1, highest_level),
+    G(1, highest_level);
+  initArray(highest_level,A,B,C,D,E,F,G);
+  int i=0, j, n=difference.length(), gap=1+__INIT_GAP__;
+  Variable temp;
+  Array<Variable> v(0,n);
+  VarlistIterator J;
+
+  for (J= difference; J.hasItem(); J++ ){ 
+    v[i]= J.getItem(); 
+    i++ ; 
+  }
+  
+  while ( gap <= n) gap = __INIT_GAP__ * gap+1;
+  gap /= __INIT_GAP__;
+  DEBOUTLN(CERR, "gap is ", gap);
+  
+  while ( gap > 0 ){
+    for ( i=gap; i<= n-1; i++){
+      temp = v[i];
+      for ( j= i-gap; j >=0 ; j-=gap){
+	if (degord(v[j],temp, PS, A,B,C,D,E,F,G))  break;
+	v[j+gap] = v[j];
+	//CERR << "v[" << j+gap << "]= " << v[j+gap] << "\n";
+      }
+      v[j+gap] = temp;
+      //CERR << "v[" << j+gap << "]= " << v[j+gap] << "\n";
+    }
+    gap /= __INIT_GAP__;
+  }
+  Varlist output;
+  for (i=0; i<= n-1; i++)
+    output.append(v[i]);
+  DEBOUTLN(CERR, "A= ", A);  DEBOUTLN(CERR, "B= ", B);  
+  DEBOUTLN(CERR, "C= ", C);  DEBOUTLN(CERR, "D= ", D);
+  DEBOUTLN(CERR, "E= ", E);  DEBOUTLN(CERR, "F= ", F);
+  DEBOUTLN(CERR, "G= ", G);
+  return output;
+}
+
+// set up a new orderd list of Variables.
+// we try to reorder the variables heuristically optimal.
+Varlist
+neworder( const CFList & PolyList ){
+  CFList PS= PolyList, PS1=PolyList;
+  Varlist oldorder, reorder, difference;
+
+  DEBINCLEVEL(CERR, "neworder");
+  TIMING_START(neworder_time);
+
+  int highest_level= level(get_max_var(PS));
+  DEBOUTLN(CERR, "neworder: highest_level=   ", highest_level);
+  DEBOUTLN(CERR, "neworder: that is variable ", Variable(highest_level));
+
+  // set up oldorder and first criterion: only_in_one
+  for (int i=highest_level; i>=1; i--){
+    oldorder.insert(Variable(i));
+    CFList is_one= only_in_one(PS1, Variable(i)); 
+    if ( is_one.length() == 1 ){
+      DEBOUTLN(CERR, "Found a variable which is in only one Polynomial: ", 
+	       Variable(i));
+      DEBOUTLN(CERR, ".... in the Polynomial: ", is_one.getFirst());
+      reorder.insert(Variable(i));
+      PS1 = Difference(PS1, is_one);
+      DEBOUTLN(CERR, "New cutted list is: ", PS1);
+    }
+    else if ( is_one.length() == 0 ){
+      DEBOUTLN(CERR, "Found a variable which is in no polynomial: ", 
+	       Variable(i));
+      DEBOUTMSG(CERR, "... assigning it the highest level.");
+      reorder.append(Variable(i)); // assigne it the highest level
+      PS1 = Difference(PS1, is_one); 
+    }
+  }
+  difference = Difference(oldorder,reorder);
+  DEBOUTLN(CERR, "Missing variables are: ", difference);
+  // rearrange the ordering of the variables!
+  difference = reorderb(difference, PS, highest_level);
+  DEBOUTLN(CERR, "second criterion gives: ", difference);
+  reorder = Union(reorder, difference);
+  DEBOUTLN(CERR, "old order was:     ", oldorder);
+  DEBOUTLN(CERR, "New order will be: ", Union(reorder, Difference(oldorder,reorder)));
+  DEBDECLEVEL(CERR, "neworder");
+  TIMING_END(neworder_time);
+
+  TIMING_PRINT(neworder_time, "\ntime used for neworder   : ");
+
+
+  return Union(reorder,Difference(oldorder,reorder));
+}
+
+// the same as above, only returning a list of CanonicalForms
+CFList
+newordercf(const CFList & PolyList ){
+  Varlist reorder= neworder(PolyList);
+  CFList output;
+
+  for (VarlistIterator i=reorder; i.hasItem(); i++)
+    output.append(CanonicalForm(i.getItem()));
+
+  return output;
+}
+
+// the same as above, only returning a list of ints
+IntList
+neworderint(const CFList & PolyList ){
+  Varlist reorder= neworder(PolyList);
+  IntList output;
+
+  for (VarlistIterator i=reorder; i.hasItem(); i++)
+    output.append(level(i.getItem()));
+
+  return output;
+}
+
+// swapvar a whole list of CanonicalForms
+static CFList
+swapvar( const CFList & PS, const Variable & x, const Variable & y){
+  CFList ps;
+
+  for (CFListIterator i= PS; i.hasItem(); i++)
+    ps.append(swapvar(i.getItem(),x,y));
+  return ps;
+}
+
+static CFFList
+swapvar( const CFFList & PS, const Variable & x, const Variable & y){
+  CFFList ps;
+
+  for (CFFListIterator i= PS; i.hasItem(); i++)
+    ps.append(CFFactor(swapvar(i.getItem().factor(),x,y),i.getItem().exp()));
+  return ps;
+}
+
+// a library function: we reorganize the global variable ordering
+CFList
+reorder( const Varlist & betterorder, const CFList & PS){
+  int i=1, n = betterorder.length();
+  Intarray v(1,n);
+  CFList ps=PS;
+
+  //initalize:
+  for (VarlistIterator j = betterorder; j.hasItem(); j++){
+    v[i]= level(j.getItem()); i++;
+  }
+  DEBOUTLN(CERR, "reorder: Original ps=  ", ps);
+  // reorder:
+  for (i=1; i <= n; i++)
+    ps=swapvar(ps,Variable(v[i]),Variable(n+i));
+  DEBOUTLN(CERR, "reorder: Reorganized ps= ", ps); 
+  return ps;
+}
+
+CFFList
+reorder( const Varlist & betterorder, const CFFList & PS){
+  int i=1, n = betterorder.length();
+  Intarray v(1,n);
+  CFFList ps=PS;
+
+  //initalize:
+  for (VarlistIterator j = betterorder; j.hasItem(); j++){
+    v[i]= level(j.getItem()); i++;
+  }
+  DEBOUTLN(CERR, "reorder: Original ps=  ", ps);
+  // reorder:
+  for (i=1; i <= n; i++)
+    ps=swapvar(ps,Variable(v[i]),Variable(n+i));
+  DEBOUTLN(CERR, "reorder: Reorganized ps= ", ps); 
+  return ps;
+}
+
+ListCFList
+reorder(const Varlist & betterorder, const ListCFList & Q){
+  ListCFList Q1;
+
+  for ( ListCFListIterator i=Q; i.hasItem(); i++)
+    Q1.append(reorder(betterorder, i.getItem()));
+  return Q1;
+}
+
Index: libfac/charset/reorder.h
===================================================================
--- libfac/charset/reorder.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/reorder.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,42 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+#ifndef INCL_REORDER_H
+#define INCL_REORDER_H
+
+#include <factory.h>
+#include <tmpl_inst.h>  // for typedef's
+
+/*BEGINPUBLIC*/
+// the next three give you a heuristically optimal reorderd list of the
+// variables. For internal and external (e.g. Singular/Macaulay2) library use.
+// This is really experimental!
+// See the comments in reorder.cc.
+// 
+// this gives you a heuristically optimal ordering for the ring variables
+// if you use the irreducible characteristic series.
+Varlist  neworder( const CFList & PolyList );
+// the same as neworder(...) only returning a list of CanonicalForm 's
+// (i.e. the variables as CanonicalForms)
+CFList   newordercf(const CFList & PolyList );
+// the same as neworder(...) only returning a list of int 's (i.e. the levels)
+IntList  neworderint(const CFList & PolyList );
+
+// for library internal use only:
+// next function reorders the variables in PS:
+// a code segment to use:
+// ...
+// #include <tmpl_inst.h> // for typedef's
+// CFList PS= <setup-your-list-of-CanonicalForms>;
+// Varlist betterorder= neworder(PS);
+// PS= reorder(betterorder,PS); // reorder variables in PS from oldorder 
+//                                 to betterorder
+// ListCFList Q= IrrCharSeries( PS );
+// Q= reorder(betterorder,Q);   // revert ordering to oldorder
+// 
+CFList reorder( const Varlist & betterorder, const CFList & PS);
+CFFList reorder( const Varlist & betterorder, const CFFList & PS);
+ListCFList reorder(const Varlist & betterorder, const ListCFList & Q);
+/*ENDPUBLIC*/
+
+#endif /* INCL_REORDER_H */
Index: libfac/charset/tests/charsettest
===================================================================
--- libfac/charset/tests/charsettest	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/charsettest	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,47 @@
+#!/bin/csh
+set OS=`uname`
+if ( $OS == "Linux" ) then
+	set ECHO="/bin/echo -e"
+	set MAKE=make
+else if ( $OS == "SunOS" ) then
+	set ECHO=/usr/5bin/echo
+	set MAKE=gmake
+else
+	set ECHO=echo
+	set MAKE=make
+endif
+
+(cd .. ; $MAKE opttestcs )
+
+$ECHO "\n\ntesting CharSet:\c"
+$ECHO "\nt1  \c" 
+../testcs < t1  
+$ECHO "\nt2  \c"
+../testcs < t2
+$ECHO "\nt3  \c"
+../testcs < t3
+$ECHO "\nt4  \c"
+../testcs < t4
+$ECHO "\nt5  \c"
+../testcs < t5
+$ECHO "\nt6  \c"
+../testcs < t6
+$ECHO "\nt7  \c"
+../testcs < t7
+$ECHO "\nt8  \c"
+../testcs < t8
+$ECHO "\nt9  \c"
+../testcs < t9
+
+$ECHO "\nw1 \c"
+../testcs < w1
+$ECHO "\nw2 \c"
+../testcs < w2
+$ECHO "\nw3 \c"
+../testcs < w3
+$ECHO "\nw4 \c"
+../testcs < w4
+
+$ECHO "\nx1 \c"
+../testcs < x1
+
Index: libfac/charset/tests/hans1
===================================================================
--- libfac/charset/tests/hans1	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/hans1	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,12 @@
+32003
+abcdefh
+-1*a-1*d+e+f+h;
+-2*a^2+2*a*d+2*c*e+2*b*f-1*a-1;
+3*a^3-3*a^2*d+3*c^2*e+3*b^2*f+3*a^2+4*a-1*d;
+6*a^3-6*a^2*d+6*b*e*g+6*a^2-3*a*d+4*a-1*d;
+-4*a^4+4*a^3*d+4*c^3*e+4*b^3*f-6*a^3-10*a^2+4*a*d-1*a-1;
+-8*a^4+8*a^3*d+8*b*c*e*g-12*a^3+4*a^2*d-14*a^2+4*a*d-3*a-1;
+-12*a^4+12*a^3*d+12*b^2*e*g-18*a^3+12*a^2*d-14*a^2+8*a*d-1*a-1;
+24*a^4-24*a^3*d+36*a^3-24*a^2*d+26*a^2-8*a*d+7*a+1;
+0;
+
Index: libfac/charset/tests/hans2
===================================================================
--- libfac/charset/tests/hans2	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/hans2	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,8 @@
+0
+abcdefghj
+d*b-e*a;
+c*e-f*b;
+g*e-h*d;
+h*f-j*e;
+0;
+
Index: libfac/charset/tests/mcharsettest
===================================================================
--- libfac/charset/tests/mcharsettest	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/mcharsettest	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,51 @@
+#!/bin/csh
+set OS=`uname`
+if ( $OS == "Linux" ) then
+	set ECHO="/bin/echo -e"
+	set MAKE=make
+else if ( $OS == "SunOS" ) then
+	set ECHO=/usr/5bin/echo
+	set MAKE=gmake
+else
+	set ECHO=echo
+	set MAKE=make
+endif
+
+(cd .. ; $MAKE testmcs )
+
+$ECHO "\n\ntesting CharSet:\c"
+$ECHO "\nt1  \c" 
+../testmcs < t1  
+$ECHO "\nt2  \c"
+../testmcs < t2
+$ECHO "\nt3  \c"
+../testmcs < t3
+$ECHO "\nt4  \c"
+../testmcs < t4
+$ECHO "\nt5  \c"
+../testmcs < t5
+$ECHO "\nt6  \c"
+../testmcs < t6
+$ECHO "\nt7  \c"
+../testmcs < t7
+$ECHO "\nt8  \c"
+../testmcs < t8
+$ECHO "\nt9  \c"
+../testmcs < f9
+
+$ECHO "\nw1 \c"
+../testmcs < w1
+$ECHO "\nw2 \c"
+../testmcs < w2
+$ECHO "\nw3 \c"
+../testmcs < w3
+$ECHO "\nw4 \c"
+../testmcs < w4
+
+$ECHO "\nx1 \c"
+../testmcs < x1
+
+$ECHO "\n"
+$ECHO 
+# long time section:
+$ECHO "\n Long-time section!\n"
Index: libfac/charset/tests/t1
===================================================================
--- libfac/charset/tests/t1	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/t1	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,8 @@
+31991
+abcd
+a*b*c-b*c*d-c*d*a-d*a*b;
+a^3-b^3-a^3*b^3+c^3+d^3;
+a*b+b*c+c*d+d*a;
+a^2;
+c*a*b+a*b+a+b;
+0;
Index: libfac/charset/tests/t2
===================================================================
--- libfac/charset/tests/t2	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/t2	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,6 @@
+31991
+xyz
+x^3-y^2;
+x^3-z^2;
+y^3-z^2;
+0;
Index: libfac/charset/tests/t3
===================================================================
--- libfac/charset/tests/t3	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/t3	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,8 @@
+31991
+abcdef
+a*b*c+a*b+a*e;
+a-b*d*e;
+d*e*f+f;
+f-e;
+a-a*b;
+0;
Index: libfac/charset/tests/t4
===================================================================
--- libfac/charset/tests/t4	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/t4	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,6 @@
+31991
+xyz
+x^3-x^2+y^2;
+x-y^3;
+x*y*z+z^3;
+0;
Index: libfac/charset/tests/t5
===================================================================
--- libfac/charset/tests/t5	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/t5	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,5 @@
+31991
+xy
+x^2+y^2-1;
+x*y;
+0;
Index: libfac/charset/tests/t6
===================================================================
--- libfac/charset/tests/t6	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/t6	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,10 @@
+31991
+caloqhjnbdpkmgef
+a^4*b^3*c^3-e^2*f^4+a^3*b^2*e;
+a*b*d^3-q^8;
+a*b*g^4*d^2-g^3-g^2;
+a^4-a^5-a^3+k^2*o^2*p;
+q^3*j^3*m*n;
+n^3-n^2+a*b*c;
+p^4-p^3-p^5*b^2-a*b*c*d^3-q^2*j^2;
+0;
Index: libfac/charset/tests/t7
===================================================================
--- libfac/charset/tests/t7	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/t7	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,6 @@
+31991
+xyzt
+t^2+x*t^2-y*t-x*y*t+x*y+3*y;
+x*t+z-x*y;
+z*t-2*y^2-x*y-1;
+0;
Index: libfac/charset/tests/t8
===================================================================
--- libfac/charset/tests/t8	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/t8	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,10 @@
+31991
+dcaflohjnbspkmge
+a^4*b^3*c^3-e^2*f^4+a^3*b^2*e;
+a*b*d^3-s^8;
+a*b*g^4*d^2-g^3-g^2;
+a^4-a^5-a^3+k^2*o^2*p;
+s^3*j^3*m*n;
+n^3-n^2+a*b*c;
+p^4-p^3-p^5*b^2-a*b*c*d^3-s^2*j^2;
+0;
Index: libfac/charset/tests/t8a
===================================================================
--- libfac/charset/tests/t8a	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/t8a	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,10 @@
+31991
+ponmlkjigfedcba
+a^4*b^3*c^3-e^2*f^4+a^3*b^2*e;
+a*b*d^3-i^8;
+a*b*g^4*d^2-g^3-g^2;
+a^4-a^5-a^3+k^2*o^2*p;
+i^3*j^3*m*n;
+n^3-n^2+a*b*c;
+p^4-p^3-p^5*b^2-a*b*c*d^3-i^2*j^2;
+0;
Index: libfac/charset/tests/t9
===================================================================
--- libfac/charset/tests/t9	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/t9	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,8 @@
+31991
+dcba
+a*b*c-b*c*d-c*d*a-d*a*b;
+a^3-b^3-a^3*b^3+c^3+d^3;
+a*b+b*c+c*d+d*a;
+a^2;
+c*a*b+a*b+a+b;
+0;
Index: libfac/charset/tests/w1
===================================================================
--- libfac/charset/tests/w1	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/w1	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,6 @@
+31991
+xyzt
+t^2+x*t^2-y*t-x*y*t+x*y+3*y;
+x*t+z-x*y;
+z*t-2*y^2-x*y-1;
+0;
Index: libfac/charset/tests/w2
===================================================================
--- libfac/charset/tests/w2	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/w2	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,11 @@
+31991
+acbdefgh
+h+f+e-d-a;
+2*f*b+2*e*c-1-a-2*a^2+2*a*d;
+3*f*b^2+3*e*c^2-d-3*a^2*d+4*a+3*a^2+2*a^3;
+6*e*g*b-d-3*a*d-6*a^2*d+4*a+6*a^2+6*a^3;
+4*f*b^2+4*e*c^3-1-a-10*a^2-6*a^3-4*a^4+4*d*a+4*a^3*d;
+8*e*c*g*b-1-3*a-14*a^2-12*a^3-8*a^4-4*a*d+4*a^2*d+8*a^3*d;
+12*e*c*g*b-1-a-14*a^2-18*a^3-12*a^4+8*a*d+12*a^2*d+12*a^3*d;
+1+7*a+26*a^2+36*a^3+24*a^4-8*a*d-24*a^2*d-24*a^3*d;
+0;
Index: libfac/charset/tests/w3
===================================================================
--- libfac/charset/tests/w3	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/w3	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,15 @@
+31991
+abcdefghkj
+-j+a^2*b^2*c^2*d^2*e+a^2*b^2*c^2*d^2*f+a^2*b^2*c^2*d*e^2+2*a^2*b^2*c^2*d*e*f+a^2*b^2*c^2*d*f^2+a^2*b^2*c^2*e^2*f+a^2*b^2*c^2*e*f^2+a^2*d*h-b^2*f*g*c^2*e*k*g-h-k;
+2*a*d*h+2*a*b^2*c^2*e*f^2+2*a*b^2*c^2*d*f^2+2*a*b^2*c^2*e^2*f+4*a*b^2*c^2*d*e*f+2*a*b^2*c^2*d^2*f+2*a*b^2*c^2*d*e^2+2*a*b^2*c^2*d^2*e;
+-2*b*c^2*e*f*g^2*k+2*a^2*b*c^2*e*f^2+2*a^2*b*c^2*d*f^2+2*a^2*b*c^2*e^2*f+4*a^2*b*c^2*d*e*f+2*a^2*b*c^2*d^2*f+2*a^2*b*c^2*d*e^2+2*a^2*b*c^2*d^2*e;
+-2*b^2*c*e*f*g^2*k+2*a^2*b^2*c*e*f^2+2*a^2*b^2*c*d*f^2+2*a^2*b^2*c*e^2*f+4*a^2*b^2*c*d*e*f+2*a^2*b^2*c*d^2*f+2*a^2*b^2*c*d*e^2+2*a^2*b^2*c*d^2*e;
+a^2*h+a^2*b^2*c^2*f^2+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+a^2*b^2*c^2*e^2+2*a^2*b^2*c^2*d*e;
+-b^2*c^2*f*g^2*k+a^2*b^2*c^2*f^2+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+2*a^2*b^2*c^2*d*e+a^2*b^2*c^2*d^2;
+-b^2*c^2*e*g^2*k+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+a^2*b^2*c^2*e^2+2*a^2*b^2*c^2*d*e+a^2*b^2*c^2*d^2;
+-2*b^2*c^2*e*f*g*k;
+a^2*d-1;
+-b^2*c^2*e*f*g^2-1;
+0;
+
+
Index: libfac/charset/tests/w3a
===================================================================
--- libfac/charset/tests/w3a	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/w3a	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,14 @@
+31991
+abcdefghij
+-6*b*c^2*e*f*g^2+2*a^2*b*c^2*e*f^2+2*a^2*b*c^2*d*f^2+2*a^2*b*c^2*e^2*f+4*a^2*b*c^2*d*e*f+2*a^2*b*c^2*d^2*f+2*a^2*b*c^2*d*e^2+2*a^2*b*c^2*d^2*e;
+-j-b^2*c^2*e*f*g^2-1+a^2*d*h-h+a^2*b^2*c^2*e*f^2+a^2*b^2*c^2*d*f^2+a^2*b^2*c^2*e^2*f+2*a^2*b^2*c^2*d*e*f+a^2*b^2*c^2*d^2*f+a^2*b^2*c^2*d*e^2+a^2*b^2*c^2*d^2*e;
+-8*b^2*c*e*f*g^2+2*a^2*b^2*c*e*f^2+2*a^2*b^2*c*d*f^2+2*a^2*b^2*c*e^2*f+4*a^2*b^2*c*d*e*f+2*a^2*b^2*c*d^2*f+2*a^2*b^2*c*d*e^2+2*a^2*b^2*c*d^2*e;
+-16*b^2*c^2*e*f*g;
+-7*b^2*c^2*e*g^2+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+a^2*b^2*c^2*e^2+2*a^2*b^2*c^2*d*e+a^2*b^2*c^2*d^2;
+-6*b^2*c^2*f*g^2+a^2*b^2*c^2*f^2+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+2*a^2*b^2*c^2*d*e+a^2*b^2*c^2*d^2;
+a^2*d-1;
+-b^2*c^2*e*f*g^2-1;
+2*a*d*h+2*a*b^2*c^2*e*f^2+2*a*b^2*c^2*d*f^2+2*a*b^2*c^2*e^2*f+4*a*b^2*c^2*d*e*f+2*a*b^2*c^2*d^2*f+2*a*b^2*c^2*d*e^2+2*a*b^2*c^2*d^2*e;
+a^2*h+a^2*b^2*c^2*f^2+2*a^2*b^2*c^2*e*f+2*a^2*b^2*c^2*d*f+a^2*b^2*c^2*e^2+2*a^2*b^2*c^2*d*e;
+0;
+
Index: libfac/charset/tests/w4
===================================================================
--- libfac/charset/tests/w4	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/w4	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,6 @@
+31991
+zyxr
+x^2+y^2+z^2-r^2;
+x*y+z^2-1;
+x*y*z-x^2-y^2-z+1;
+0;
Index: libfac/charset/tests/x1
===================================================================
--- libfac/charset/tests/x1	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/x1	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,6 @@
+31991
+abcxyz
+a*(x+y+z)-(x-y-z);
+b*(x+z)-(x+y-z);
+c*(x-y+z)-(x+y);
+0;
Index: libfac/charset/tests/x2
===================================================================
--- libfac/charset/tests/x2	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/x2	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,23 @@
+31991
+abcdefghjklmnopqr
+d*k;
+e*g+d*j+c*k+l;
+b*h;
+e*l;
+b*f+b*g+a*h+d*h+b*k+h+o;
+a*f+d*f+a*g+d*g+c*h+e*h+b*j+a*k+d*k+b*l+f+g+k+m+n+q;
+c*f+e*f+c*g+e*g+a*j+d*j+c*k+e*k+a*l+d*l+j+l+p+r-1;
+c*j+e*j+c*l+e*l;
+e*j+c*l+2*e*l;
+e*f+e*g+d*j+c*k+2*e*k+a*l+2*d*l+l+r;
+d*f+d*g+e*h+a*k+2*d*k+b*l+k+q;
+d*h+b*k;
+e*k+d*l;
+2*c*j+e*j+c*l;
+c*f+2*c*g+e*g+a*j+d*j+c*k+2*j+l+p;
+a*g+d*g+c*h+b*j+f+2*g+k+n;
+b*g+h;
+e*j+c*l;
+d*g+k;
+0;
+
Index: libfac/charset/tests/x3
===================================================================
--- libfac/charset/tests/x3	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/x3	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,13 @@
+31991
+rstuvwxyz
+s*u+r*v;
+t*u+r*w;
+t*v+s*w;
+s*x+r*y;
+t*x+r*z;
+t*y+s*z;
+v*x+u*y;
+w*x+u*z;
+w*y+v*z;
+0;
+
Index: libfac/charset/tests/x4
===================================================================
--- libfac/charset/tests/x4	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/x4	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,36 @@
+31991
+abcdef
+a*d*e*f+3/2*b*e^2*f-1/2*c*e*f^2;
+    a*d^2*f+5/4*b*d*e*f+1/4*c*d*f^2;
+    a*d^2*e+3/4*b*d*e^2+7/4*c*d*e*f;
+    a*c*d*e+3/2*b*c*e^2-1/2*c^2*e*f;
+    a*c*d^2+5/4*b*c*d*e+1/4*c^2*d*f;
+    a*b*d*f+3/2*b^2*e*f-1/2*b*c*f^2;
+    a*b*d*e+3/4*b^2*e^2-a*c*d*f+1/2*b*c*e*f-1/4*c^2*f^2;
+    a*b*d^2+3/4*b^2*d*e+7/4*b*c*d*f;
+    a*b*c*d+3/2*b^2*c*e-1/2*b*c^2*f;
+    a^2*d*f+5/4*a*b*e*f+1/4*a*c*f^2;
+    a^2*d*e+3/4*a*b*e^2+7/4*a*c*e*f;
+    a^2*d^2-9/16*b^2*e^2+2*a*c*d*f-9/8*b*c*e*f+7/16*c^2*f^2;
+    a^2*c*d+5/4*a*b*c*e+1/4*a*c^2*f;
+    a^2*b*d+3/4*a*b^2*e+7/4*a*b*c*f;
+    b*c^3*d+1/4*c*d^3*e;
+    b^2*c^2*e-1/3*b*c^3*f+2/3*c*d^2*e*f;
+    b^2*c^2*d-1/2*a*d^4-3/8*b*d^3*e-1/8*c*d^3*f;
+    b^3*c*e-1/3*b^2*c^2*f+2/3*b*d^2*e*f;
+    b^3*c*d+3/4*b*d^3*f;
+    a*c^3*e-1/3*c*d*e^3;
+    a*c^3*d-3/4*b*c^3*e-1/2*c*d^2*e^2+1/4*c^4*f;
+    a*b*c^2*f-c*d*e*f^2;
+    a*b*c^2*e-c*d*e^2*f;
+    a*b^2*c*f-b*d*e*f^2;
+    a*b^3*f-3*b*d*f^3;
+    a*b^3*d+3/4*b^4*e-1/4*b^3*c*f-3/2*b*d^2*f^2;
+    a^2*c^2*e-2/3*a*d*e^3-1/2*b*e^4+1/6*c*e^3*f;
+    a^2*b*c*f+3/2*b*e^2*f^2-1/2*c*e*f^3;
+    a^2*b*c*e+3/2*b*e^3*f-1/2*c*e^2*f^2;
+    a^2*b^2*f-2*a*d*f^3+3/2*b*e*f^3-1/2*c*f^4;
+    a^3*c*e+4/3*a*e^3*f;
+    a^3*b*f+4*a*e*f^3;
+    a^4*d+3/4*a^3*b*e+1/4*a^3*c*f-2*a*e^2*f^2;
+0;
Index: libfac/charset/tests/x5
===================================================================
--- libfac/charset/tests/x5	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/x5	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,11 @@
+32003
+abcdefgh
+h+f+e-(d+a);
+2*f*b+2*e*c-(1+a+2*a^2-2*d*a);
+3*f*b^2+3*e*c^2-(d*(1+3*a^2)-4*a-3*a^2-3*a^3);
+6*e*g*b-(d*(1+3*a+6*a^2)-4*a-6*a^2-6*a^3);
+4*f*b^3+4*e*c^3-(1+a+10*a^2+6*a^3+4*a^4-4*d*(a+a^3));
+8*e*c*g*b-(1+3*a+14*a^2+12*a^3+8*a^4-d*(4*a+4*a^2+8*a^3));
+12*e*g*b^2-(1+a+14*a^2+18*a^3+12*a^4-d*(8*a+12*a^2+12*a^3));
+1+7*a+26*a^2+36*a^3+24*a^4-d*(8*a+24*a^2+24*a^3);
+0;
Index: libfac/charset/tests/x9
===================================================================
--- libfac/charset/tests/x9	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/charset/tests/x9	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,6 @@
+31991
+xy
+x^2;
+x*y;
+0;
+
Index: libfac/configure
===================================================================
--- libfac/configure	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/configure	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,1396 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13 
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+  --with-debug    build with debugging options turned on"
+ac_help="$ac_help
+  --with-NOSTREAMIO : do not require iostream include nor library"
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval "$ac_prev=\$ac_option"
+    ac_prev=
+    continue
+  fi
+
+  case "$ac_option" in
+  -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) ac_optarg= ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case "$ac_option" in
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir="$ac_optarg" ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build="$ac_optarg" ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file="$ac_optarg" ;;
+
+  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+  | --da=*)
+    datadir="$ac_optarg" ;;
+
+  -disable-* | --disable-*)
+    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+    fi
+    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+    eval "enable_${ac_feature}=no" ;;
+
+  -enable-* | --enable-*)
+    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+      { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+    fi
+    ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+    case "$ac_option" in
+      *=*) ;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix="$ac_optarg" ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he)
+    # Omit some internal or obsolete options to make the list less imposing.
+    # This message is too long to be a string in the A/UX 3.1 sh.
+    cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+  --cache-file=FILE       cache test results in FILE
+  --help                  print this message
+  --no-create             do not create output files
+  --quiet, --silent       do not print \`checking...' messages
+  --version               print the version of autoconf that created configure
+Directory and file names:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [same as prefix]
+  --bindir=DIR            user executables in DIR [EPREFIX/bin]
+  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
+  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
+  --datadir=DIR           read-only architecture-independent data in DIR
+                          [PREFIX/share]
+  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
+                          [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
+  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
+  --includedir=DIR        C header files in DIR [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
+  --infodir=DIR           info documentation in DIR [PREFIX/info]
+  --mandir=DIR            man documentation in DIR [PREFIX/man]
+  --srcdir=DIR            find the sources in DIR [configure dir or ..]
+  --program-prefix=PREFIX prepend PREFIX to installed program names
+  --program-suffix=SUFFIX append SUFFIX to installed program names
+  --program-transform-name=PROGRAM
+                          run sed PROGRAM on installed program names
+EOF
+    cat << EOF
+Host type:
+  --build=BUILD           configure for building on BUILD [BUILD=HOST]
+  --host=HOST             configure for HOST [guessed]
+  --target=TARGET         configure for TARGET [TARGET=HOST]
+Features and packages:
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --x-includes=DIR        X include files are in DIR
+  --x-libraries=DIR       X library files are in DIR
+EOF
+    if test -n "$ac_help"; then
+      echo "--enable and --with options recognized:$ac_help"
+    fi
+    exit 0 ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host="$ac_optarg" ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir="$ac_optarg" ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir="$ac_optarg" ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir="$ac_optarg" ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir="$ac_optarg" ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst \
+  | --locals | --local | --loca | --loc | --lo)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+    localstatedir="$ac_optarg" ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir="$ac_optarg" ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir="$ac_optarg" ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix="$ac_optarg" ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix="$ac_optarg" ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix="$ac_optarg" ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name="$ac_optarg" ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir="$ac_optarg" ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir="$ac_optarg" ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site="$ac_optarg" ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir="$ac_optarg" ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir="$ac_optarg" ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target="$ac_optarg" ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers)
+    echo "configure generated by autoconf version 2.13"
+    exit 0 ;;
+
+  -with-* | --with-*)
+    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+    fi
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    case "$ac_option" in
+      *=*) ;;
+      *) ac_optarg=yes ;;
+    esac
+    eval "with_${ac_package}='$ac_optarg'" ;;
+
+  -without-* | --without-*)
+    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+    # Reject names that are not valid shell variable names.
+    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+      { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+    fi
+    ac_package=`echo $ac_package| sed 's/-/_/g'`
+    eval "with_${ac_package}=no" ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes="$ac_optarg" ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries="$ac_optarg" ;;
+
+  -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+    ;;
+
+  *)
+    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+      echo "configure: warning: $ac_option: invalid host type" 1>&2
+    fi
+    if test "x$nonopt" != xNONE; then
+      { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+    fi
+    nonopt="$ac_option"
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+  exec 6>/dev/null
+else
+  exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+  case "$ac_arg" in
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c) ;;
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+  *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+  ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+  *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+  esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set.  These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=factor.h
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then its parent.
+  ac_prog=$0
+  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+  test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+  srcdir=$ac_confdir
+  if test ! -r $srcdir/$ac_unique_file; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+  if test "$ac_srcdir_defaulted" = yes; then
+    { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+  else
+    { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+  fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+  if test "x$prefix" != xNONE; then
+    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+  else
+    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+  fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+  if test -r "$ac_site_file"; then
+    echo "loading site script $ac_site_file"
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  echo "loading cache $cache_file"
+  . $cache_file
+else
+  echo "creating cache $cache_file"
+  > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+    ac_n= ac_c='
+' ac_t='	'
+  else
+    ac_n=-n ac_c= ac_t=
+  fi
+else
+  ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+
+libfac_name="\"Factorization and characteristic sets library\""
+
+libfac_version="3.1.3"
+cat >> confdefs.h <<EOF
+#define LIBFAC_VERSION "$libfac_version"
+EOF
+
+
+libfac_date="\"March 2011\""
+cat >> confdefs.h <<EOF
+#define LIBFAC_DATE $libfac_date
+EOF
+
+
+libfac_author="\"M. Messollen\""
+
+
+
+libfac="libfac"
+
+libfac_g="libfac-g"
+
+libsingfac="libsingfac"
+
+libsingfac_g="libsingfac-g"
+
+factorH="factor.h"
+
+
+
+# Check whether --with-debug or --without-debug was given.
+if test "${with_debug+set}" = set; then
+  withval="$with_debug"
+  :
+fi
+
+
+targetname="libsingfac"
+
+# Check whether --with-NOSTREAMIO or --without-NOSTREAMIO was given.
+if test "${with_NOSTREAMIO+set}" = set; then
+  withval="$with_NOSTREAMIO"
+  :
+fi
+
+
+if test "$with_NOSTREAMIO" = yes; then
+  cat >> confdefs.h <<\EOF
+#define NOSTREAMIO 1
+EOF
+
+fi
+
+if (test "x${prefix} != xNONE && test "${prefix} != "/usr/local") || \
+  test "${ac_default_prefix}" != "/usr/local" || \
+  test "${includedir}" != '${prefix}/include'; then
+  CPPFLAGS="-I${includedir} ${CPPFLAGS}"
+fi
+CPPFLAGS="-I./factor ${CPPFLAGS}"
+
+if (test "x${prefix} != xNONE && test "${prefix} != "/usr/local") || \
+  test "${ac_default_prefix}" != "/usr/local" || \
+  test "${libdir}" != '${prefix}/lib'; then
+  LDFLAGS="-L${libdir} ${LDFLAGS}"
+fi
+LDFLAGS="-L. ${LDFLAGS}"
+
+if test "${CXXFLAGS+set}" != set; then
+  ac_cxxflags_set=no
+  if test "$with_debug" = yes; then
+    CXXFLAGS="-g"
+  else
+    CXXFLAGS="-O"
+    cat >> confdefs.h <<\EOF
+#define NDEBUG 1
+EOF
+
+  fi
+fi
+
+ac_ext=C
+# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cxx_cross
+
+for ac_prog in $CCC c++ g++ gcc CC cxx cc++ cl
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:668: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_CXX="$ac_prog"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+CXX="$ac_cv_prog_CXX"
+if test -n "$CXX"; then
+  echo "$ac_t""$CXX" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+test -n "$CXX" && break
+done
+test -n "$CXX" || CXX="gcc"
+
+
+echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:700: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works" >&5
+
+ac_ext=C
+# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cxx_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 711 "configure"
+#include "confdefs.h"
+
+int main(){return(0);}
+EOF
+if { (eval echo configure:716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  ac_cv_prog_cxx_works=yes
+  # If we can't run a trivial program, we are probably using a cross compiler.
+  if (./conftest; exit) 2>/dev/null; then
+    ac_cv_prog_cxx_cross=no
+  else
+    ac_cv_prog_cxx_cross=yes
+  fi
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  ac_cv_prog_cxx_works=no
+fi
+rm -fr conftest*
+ac_ext=C
+# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cxx_cross
+
+echo "$ac_t""$ac_cv_prog_cxx_works" 1>&6
+if test $ac_cv_prog_cxx_works = no; then
+  { echo "configure: error: installation or configuration problem: C++ compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:742: checking whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cxx_cross" 1>&6
+cross_compiling=$ac_cv_prog_cxx_cross
+
+echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6
+echo "configure:747: checking whether we are using GNU C++" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.C <<EOF
+#ifdef __GNUC__
+  yes;
+#endif
+EOF
+if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:756: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+  ac_cv_prog_gxx=yes
+else
+  ac_cv_prog_gxx=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gxx" 1>&6
+
+if test $ac_cv_prog_gxx = yes; then
+  GXX=yes
+else
+  GXX=
+fi
+
+ac_test_CXXFLAGS="${CXXFLAGS+set}"
+ac_save_CXXFLAGS="$CXXFLAGS"
+CXXFLAGS=
+echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6
+echo "configure:775: checking whether ${CXX-g++} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  echo 'void f(){}' > conftest.cc
+if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then
+  ac_cv_prog_cxx_g=yes
+else
+  ac_cv_prog_cxx_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cxx_g" 1>&6
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS="$ac_save_CXXFLAGS"
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
+
+echo $ac_n "checking how to run the C++ preprocessor""... $ac_c" 1>&6
+echo "configure:807: checking how to run the C++ preprocessor" >&5
+if test -z "$CXXCPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CXXCPP'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_ext=C
+# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cxx_cross
+  CXXCPP="${CXX-g++} -E"
+  cat > conftest.$ac_ext <<EOF
+#line 820 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:825: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  :
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  CXXCPP=/lib/cpp
+fi
+rm -f conftest*
+  ac_cv_prog_CXXCPP="$CXXCPP"
+ac_ext=C
+# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cxx_cross
+fi
+fi
+CXXCPP="$ac_cv_prog_CXXCPP"
+echo "$ac_t""$CXXCPP" 1>&6
+
+
+echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
+echo "configure:851: checking whether ${MAKE-make} sets \${MAKE}" >&5
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftestmake <<\EOF
+all:
+	@echo 'ac_maketemp="${MAKE}"'
+EOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+  eval ac_cv_prog_make_${ac_make}_set=yes
+else
+  eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftestmake
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  SET_MAKE=
+else
+  echo "$ac_t""no" 1>&6
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+# Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:880: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_RANLIB="ranlib"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
+fi
+fi
+RANLIB="$ac_cv_prog_RANLIB"
+if test -n "$RANLIB"; then
+  echo "$ac_t""$RANLIB" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+# Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:910: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_prog_AR="ar"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+fi
+fi
+AR="$ac_cv_prog_AR"
+if test -n "$AR"; then
+  echo "$ac_t""$AR" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$AR"; then
+  { echo "configure: error: Need ar" 1>&2; exit 1; }
+fi
+
+
+ac_safe=`echo "factory.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for factory.h""... $ac_c" 1>&6
+echo "configure:943: checking for factory.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 948 "configure"
+#include "confdefs.h"
+#include <factory.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:953: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  :
+else
+  echo "$ac_t""no" 1>&6
+echo "configure: warning: factory.h not found! Install factory before building libfac!" 1>&2
+fi
+
+
+
+
+if test x${GXX} = xyes; then
+
+  if test "$ac_cxxflags_set" = no; then
+    if test "$with_debug" = yes; then
+       CXXFLAGS="-O -g"
+    else
+       CXXFLAGS="-O3 "
+    fi
+# check whether CXX accepts -fno-rtti
+
+ac_ext=C
+# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cxx_cross
+
+echo $ac_n "checking whether gcc accepts -fno-rtti""... $ac_c" 1>&6
+echo "configure:996: checking whether gcc accepts -fno-rtti" >&5
+tmp_flags=${CXXFLAGS}
+CXXFLAGS="${CXXFLAGS} -fno-rtti"
+if eval "test \"`echo '$''{'ac_cv_cxx_have_rtti'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1003 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1010: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  ac_cv_cxx_have_rtti=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_cxx_have_rtti=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""${ac_cv_cxx_have_rtti}" 1>&6
+CXXFLAGS=$tmp_flags
+if test "${ac_cv_cxx_have_rtti}" = yes; then
+CXXFLAGS="$CXXFLAGS -fno-rtti"
+fi
+
+echo $ac_n "checking whether gcc accepts -fno-exceptions""... $ac_c" 1>&6
+echo "configure:1030: checking whether gcc accepts -fno-exceptions" >&5
+tmp_flags=${CXXFLAGS}
+CXXFLAGS="${CXXFLAGS} -fno-exceptions"
+if eval "test \"`echo '$''{'ac_cv_cxx_have_exceptions'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1037 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1044: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  ac_cv_cxx_have_exceptions=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  ac_cv_cxx_have_exceptions=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""${ac_cv_cxx_have_exceptions}" 1>&6
+CXXFLAGS=$tmp_flags
+if test "${ac_cv_cxx_have_exceptions}" = yes; then
+CXXFLAGS="$CXXFLAGS -fno-exceptions"
+fi
+
+
+ac_ext=C
+# CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='${CXX-g++} -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cxx_cross
+
+
+  fi
+  CXXTEMPLFLAGS="-fno-implicit-templates"
+
+
+else
+  CXXTEMPFLAGS=""
+fi
+
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs.  It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already.  You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+  case `(ac_space=' '; set | grep ac_space) 2>&1` in
+  *ac_space=\ *)
+    # `set' does not quote correctly, so add quotes (double-quote substitution
+    # turns \\\\ into \\, and sed turns \\ into \).
+    sed -n \
+      -e "s/'/'\\\\''/g" \
+      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+    ;;
+  *)
+    # `set' quotes correctly as required by POSIX, so do not add quotes.
+    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+    ;;
+  esac >> confcache
+if cmp -s $cache_file confcache; then
+  :
+else
+  if test -w $cache_file; then
+    echo "updating cache $cache_file"
+    cat confcache > $cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[ 	]*VPATH[ 	]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+  case "\$ac_option" in
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+    exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+  -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+    echo "$CONFIG_STATUS generated by autoconf version 2.13"
+    exit 0 ;;
+  -help | --help | --hel | --he | --h)
+    echo "\$ac_cs_usage"; exit 0 ;;
+  *) echo "\$ac_cs_usage"; exit 1 ;;
+  esac
+done
+
+ac_given_srcdir=$srcdir
+
+trap 'rm -fr `echo "Makefile factor/version.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@libfac_name@%$libfac_name%g
+s%@libfac_version@%$libfac_version%g
+s%@libfac_date@%$libfac_date%g
+s%@libfac_author@%$libfac_author%g
+s%@libfac@%$libfac%g
+s%@libfac_g@%$libfac_g%g
+s%@libsingfac@%$libsingfac%g
+s%@libsingfac_g@%$libsingfac_g%g
+s%@factorH@%$factorH%g
+s%@targetname@%$targetname%g
+s%@CXX@%$CXX%g
+s%@CXXCPP@%$CXXCPP%g
+s%@SET_MAKE@%$SET_MAKE%g
+s%@RANLIB@%$RANLIB%g
+s%@AR@%$AR%g
+s%@CXXTEMPLFLAGS@%$CXXTEMPLFLAGS%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+  if test $ac_beg -gt 1; then
+    sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+  else
+    sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+  fi
+  if test ! -s conftest.s$ac_file; then
+    ac_more_lines=false
+    rm -f conftest.s$ac_file
+  else
+    if test -z "$ac_sed_cmds"; then
+      ac_sed_cmds="sed -f conftest.s$ac_file"
+    else
+      ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+    fi
+    ac_file=`expr $ac_file + 1`
+    ac_beg=$ac_end
+    ac_end=`expr $ac_end + $ac_max_sed_cmds`
+  fi
+done
+if test -z "$ac_sed_cmds"; then
+  ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case "$ac_file" in
+  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+  *) ac_file_in="${ac_file}.in" ;;
+  esac
+
+  # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+  # Remove last slash and all that follows it.  Not all systems have dirname.
+  ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+  if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+    # The file is in a subdirectory.
+    test ! -d "$ac_dir" && mkdir "$ac_dir"
+    ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+    # A "../" for each directory in $ac_dir_suffix.
+    ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+  else
+    ac_dir_suffix= ac_dots=
+  fi
+
+  case "$ac_given_srcdir" in
+  .)  srcdir=.
+      if test -z "$ac_dots"; then top_srcdir=.
+      else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+  /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+  *) # Relative path.
+    srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+    top_srcdir="$ac_dots$ac_given_srcdir" ;;
+  esac
+
+
+  echo creating "$ac_file"
+  rm -f "$ac_file"
+  configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+  case "$ac_file" in
+  *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+  *) ac_comsub= ;;
+  esac
+
+  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+  sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ 	]*\)#\([ 	]*define[ 	][ 	]*\)'
+ac_dB='\([ 	][ 	]*\)[^ 	]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
+ac_uB='\([ 	]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+  CONFIG_HEADERS="factor/version.h"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  case "$ac_file" in
+  *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+       ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+  *) ac_file_in="${ac_file}.in" ;;
+  esac
+
+  echo creating $ac_file
+
+  rm -f conftest.frag conftest.in conftest.out
+  ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+  cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h.  And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments.  This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ 	]*#[ 	]*undef[ 	][ 	]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+  ac_lines=`grep -c . conftest.vals`
+  # grep -c gives empty output for an empty file on some AIX systems.
+  if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+  # Write a limited-size here document to conftest.frag.
+  echo '  cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+  sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+  echo 'CEOF
+  sed -f conftest.frag conftest.in > conftest.out
+  rm -f conftest.in
+  mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+  sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+  rm -f conftest.vals
+  mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+  rm -f conftest.frag conftest.h
+  echo "/* $ac_file.  Generated automatically by configure.  */" > conftest.h
+  cat conftest.in >> conftest.h
+  rm -f conftest.in
+  if cmp -s $ac_file conftest.h 2>/dev/null; then
+    echo "$ac_file is unchanged"
+    rm -f conftest.h
+  else
+    # Remove last slash and all that follows it.  Not all systems have dirname.
+      ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+      if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+      # The file is in a subdirectory.
+      test ! -d "$ac_dir" && mkdir "$ac_dir"
+    fi
+    rm -f $ac_file
+    mv conftest.h $ac_file
+  fi
+fi; done
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
Index: libfac/configure.in
===================================================================
--- libfac/configure.in	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/configure.in	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,168 @@
+dnl
+dnl Process this file with autoconf to produce a configure script.
+dnl
+
+dnl
+dnl Initialisation
+dnl
+AC_INIT(factor.h)
+AC_CONFIG_HEADER(factor/version.h)
+
+dnl
+dnl Set up variables for Makefile.in
+dnl
+dnl Change libfac variables here:
+libfac_name="\"Factorization and characteristic sets library\""
+AC_SUBST(libfac_name)
+libfac_version="3.1.3"
+AC_DEFINE_UNQUOTED(LIBFAC_VERSION,"$libfac_version")
+AC_SUBST(libfac_version)
+libfac_date="\"March 2011\""
+AC_DEFINE_UNQUOTED(LIBFAC_DATE,$libfac_date)
+AC_SUBST(libfac_date)
+libfac_author="\"M. Messollen\""
+AC_SUBST(libfac_author)
+
+AC_SUBST(libfac)
+libfac="libfac"
+AC_SUBST(libfac_g)
+libfac_g="libfac-g"
+AC_SUBST(libsingfac)
+libsingfac="libsingfac"
+AC_SUBST(libsingfac_g)
+libsingfac_g="libsingfac-g"
+AC_SUBST(factorH)
+factorH="factor.h"
+AC_SUBST(targetname)
+
+dnl
+dnl Parse options
+dnl
+
+AC_ARG_WITH(
+  debug,
+  [  --with-debug    build with debugging options turned on])
+
+targetname="libsingfac"
+
+AC_ARG_WITH(
+  NOSTREAMIO,
+  [  --with-NOSTREAMIO : do not require iostream include nor library])
+
+if test "$with_NOSTREAMIO" = yes; then
+  AC_DEFINE(NOSTREAMIO)
+fi
+
+dnl
+dnl add to -I and -L, if necessary
+dnl
+if (test "x${prefix} != xNONE && test "${prefix} != "/usr/local") || \
+  test "${ac_default_prefix}" != "/usr/local" || \
+  test "${includedir}" != '${prefix}/include'; then
+  CPPFLAGS="-I${includedir} ${CPPFLAGS}"
+fi
+CPPFLAGS="-I./factor ${CPPFLAGS}"
+
+if (test "x${prefix} != xNONE && test "${prefix} != "/usr/local") || \
+  test "${ac_default_prefix}" != "/usr/local" || \
+  test "${libdir}" != '${prefix}/lib'; then
+  LDFLAGS="-L${libdir} ${LDFLAGS}"
+fi
+LDFLAGS="-L. ${LDFLAGS}"
+
+if test "${CXXFLAGS+set}" != set; then
+  ac_cxxflags_set=no
+  if test "$with_debug" = yes; then
+    CXXFLAGS="-g"
+  else
+    CXXFLAGS="-O"
+    AC_DEFINE(NDEBUG)
+  fi
+fi
+
+dnl
+dnl Checks for programs.
+dnl
+AC_LANG_CPLUSPLUS
+AC_PROG_CXX
+AC_REQUIRE_CPP
+AC_PROG_MAKE_SET
+AC_PROG_RANLIB
+AC_CHECK_PROG(AR,ar,ar)
+if test -z "$AR"; then
+  AC_MSG_ERROR(Need ar)
+fi
+
+dnl
+dnl programs for installation
+dnl
+dnl ac_save_path=${PATH}
+dnl PATH="$PATH:.."
+dnl AC_PROG_INSTALL
+dnl AC_PATH_PROG(MKINSTALLDIRS, mkinstalldirs, -mkdir -p)
+dnl PATH="$ac_save_path"
+
+dnl
+dnl Checks for header files.
+dnl
+AC_CHECK_HEADER(factory.h,,AC_MSG_WARN(factory.h not found! Install factory before building libfac!))
+
+dnl
+dnl Checks for libraries.
+dnl
+
+dnl
+dnl Checks for typedefs, structures, and compiler characteristics.
+dnl
+
+dnl
+dnl Last, but not least, customize CFLAGS
+dnl
+if test x${GXX} = xyes; then
+
+  if test "$ac_cxxflags_set" = no; then
+    if test "$with_debug" = yes; then
+       CXXFLAGS="-O -g"
+    else
+       CXXFLAGS="-O3 "
+    fi
+# check whether CXX accepts -fno-rtti
+AC_LANG_SAVE
+AC_LANG_CPLUSPLUS
+AC_MSG_CHECKING(whether gcc accepts -fno-rtti)
+tmp_flags=${CXXFLAGS}
+CXXFLAGS="${CXXFLAGS} -fno-rtti"
+AC_CACHE_VAL(ac_cv_cxx_have_rtti,
+AC_TRY_COMPILE(,,ac_cv_cxx_have_rtti=yes,ac_cv_cxx_have_rtti=no)
+)
+AC_MSG_RESULT(${ac_cv_cxx_have_rtti})
+CXXFLAGS=$tmp_flags
+if test "${ac_cv_cxx_have_rtti}" = yes; then
+CXXFLAGS="$CXXFLAGS -fno-rtti"
+fi
+
+AC_MSG_CHECKING(whether gcc accepts -fno-exceptions)
+tmp_flags=${CXXFLAGS}
+CXXFLAGS="${CXXFLAGS} -fno-exceptions"
+AC_CACHE_VAL(ac_cv_cxx_have_exceptions,
+AC_TRY_LINK(,,ac_cv_cxx_have_exceptions=yes,ac_cv_cxx_have_exceptions=no)
+)
+AC_MSG_RESULT(${ac_cv_cxx_have_exceptions})
+CXXFLAGS=$tmp_flags
+if test "${ac_cv_cxx_have_exceptions}" = yes; then
+CXXFLAGS="$CXXFLAGS -fno-exceptions"
+fi
+
+
+AC_LANG_RESTORE
+
+  fi
+  CXXTEMPLFLAGS="-fno-implicit-templates"
+
+
+else
+  CXXTEMPFLAGS=""
+fi
+AC_SUBST(CXXTEMPLFLAGS)
+
+AC_OUTPUT(Makefile)
Index: libfac/factor/Factor.cc
===================================================================
--- libfac/factor/Factor.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/Factor.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,1179 @@
+///////////////////////////////////////////////////////////////////////////////
+static const char * errmsg = "\nYou found a bug!\nPlease inform singular@mathematik.uni-kl.de\nPlease include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you.";
+///////////////////////////////////////////////////////////////////////////////
+// FACTORY - Includes
+#include <factory.h>
+#ifndef NOSTREAMIO
+#ifdef HAVE_IOSTREAM
+#include <iostream>
+#define CERR std::cerr
+#define CIN std::cin
+#elif defined(HAVE_IOSTREAM_H)
+#include <iostream.h>
+#define CERR cerr
+#define CIN cin
+#endif
+#endif
+// Factor - Includes
+#include "tmpl_inst.h"
+#include "SqrFree.h"
+#include "helpstuff.h"
+#include "MVMultiHensel.h"
+#include "Truefactor.h"
+#include "homogfactor.h"
+#include "interrupt.h"
+// some CC's need this:
+#include "Factor.h"
+
+#include "alg_factor.h"
+void out_cf(char *s1,const CanonicalForm &f,char *s2);
+void out_cff(CFFList &L);
+
+
+#ifdef FACTORDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+
+#include <libfac/factor/debug.h>
+#include "timing.h"
+TIMING_DEFINE_PRINT(factorize_time)
+TIMING_DEFINE_PRINT(sqrfree_time)
+TIMING_DEFINE_PRINT(discr_time)
+TIMING_DEFINE_PRINT(evaluate_time)
+TIMING_DEFINE_PRINT(hensel_time)
+TIMING_DEFINE_PRINT(truefactor_time)
+
+/*
+* a wrapper for factorize over algebraic extensions:
+* does a sanity check and, if nec., a conversion
+* before calling factorize(f,alpha)
+* ( in factorize, alpha.level() must be < 0 )
+*/
+CFFList factorize2 ( const CanonicalForm & f,
+                     const Variable & alpha, const CanonicalForm & mipo )
+{
+  if (alpha.level() <0)
+  {
+    return factorize(f,alpha);
+  }
+  else
+  {
+    bool repl=(f.mvar() != alpha);
+    //out_cf("f2 - factor:",f,"\n");
+    //out_cf("f2 - ext:",alpha,"\n");
+    //out_cf("f2 - mipo:",mipo,"\n");
+    Variable X=rootOf(mipo);
+    CanonicalForm F=f;
+    if (repl) F=replacevar(f,alpha,X);
+    //out_cf("call - factor:",F,"\n");
+    //out_cf("call - ext:",X,"\n");
+    //out_cf("call - mipo:",getMipo(X,'A'),"\n");
+    CFFList L=factorize(F,X);
+    CFFListIterator i=L;
+    if (repl)
+    {
+      CFFList Outputlist;
+      for(;i.hasItem(); i++ )
+      {
+        Outputlist.append(CFFactor(
+        replacevar(i.getItem().factor(),X,alpha),
+        i.getItem().exp()));
+      }
+      return Outputlist;
+    }
+    else return L;
+  }
+}
+///////////////////////////////////////////////////////////////
+// Choose a main variable if the user didn`t wish a          //
+// special one. Returns level of main variable.              //
+///////////////////////////////////////////////////////////////
+static int
+choose_main_variable( const CanonicalForm & f, int Mainvar=0){
+  CanonicalForm remlc, newlc;
+  int n= level(f), mainvar= Mainvar;
+
+  if (mainvar != 0) return mainvar ; // We force use of the wished mainvar
+  remlc= LC(f,n); mainvar = n;
+  if ( totaldegree(remlc)==0 ){ remlc=f.genOne() ; }
+  DEBOUTLN(CERR, "remlc= " , remlc);
+  for ( int i=n-1; i>=1; i-- )
+  {
+    newlc= LC(f,i);
+    if ( totaldegree(newlc)==0 ){ newlc=f.genOne() ; }
+    DEBOUTLN(CERR, "newlc= " , newlc);
+    if ( (remlc.isOne()) && (newlc.isOne()) ){ // take care of the degrees
+      if ( degree(f,i) < degree(f,mainvar) ){
+        remlc= newlc;
+        mainvar= i;
+      }
+    }
+    else  if ( (! remlc.isOne() ) && ( newlc.isOne() ) ){
+      remlc= newlc;
+      mainvar= i;
+    }
+  }
+  return mainvar;
+}
+
+///////////////////////////////////////////////////////////////
+// Check if the derivative is nonzero for oldmainvar.        //
+// Returns the level of the choosen main variable.           //
+///////////////////////////////////////////////////////////////
+static int
+necessary_condition( const CanonicalForm & F, int oldmainvar){
+  CanonicalForm g;
+  int n=level(F);
+
+  g= swapvar(F,oldmainvar,n);
+  g= g.deriv();
+  if ( g.isZero() )
+  {
+    for ( int i=n; i>=1; i-- )
+    {
+      g= swapvar(F,i,n);
+      g= g.deriv();
+      if ( ! g.isZero() ) return i;
+    }
+  }
+  return oldmainvar;
+}
+
+///////////////////////////////////////////////////////////////
+// Make F monic. Return monic polynomial.                    //
+///////////////////////////////////////////////////////////////
+static CanonicalForm
+make_monic( const CanonicalForm & F, const CanonicalForm & lt)
+{
+  CanonicalForm intermediatpoly,f;
+  Variable x(level(F));
+
+  if ( degree(lt) == 0 ) f= 1/lt * F ;
+  else
+  {
+    intermediatpoly= power(lt,degree(F)-1);
+    for ( int i=0; i<=degree(F); i++ )
+      if ( ! F[i].isZero())
+        f+= (F[i] * intermediatpoly*power(x,i))/power(lt,i);
+  }
+  return f;
+}
+
+///////////////////////////////////////////////////////////////
+// Decide whether num/denum (num,denum both from the         //
+// FiniteFielddomain)  lies in the RationalDomain.           //
+// If false, return num/denum else return the zero poly from //
+// the FiniteFielddomain.                                    //
+///////////////////////////////////////////////////////////////
+static CanonicalForm
+is_rational( const CanonicalForm & num, const CanonicalForm & denum ){
+  CanonicalForm a, b;
+  int retvalue;
+
+  retvalue= mydivremt(num,denum,a,b);
+  if ( retvalue && b == num.genZero() ) // num/denum from FFdomain
+    return a;
+  else // num/denum is rational
+    return num.genZero();
+}
+
+///////////////////////////////////////////////////////////////
+// lt_is_product returns 1 iff lt is a product, 0 iff lt is  //
+// a sum.                                                    //
+///////////////////////////////////////////////////////////////
+static int
+lt_is_product( const CanonicalForm & lt ){
+  CFList result;
+
+  result= get_Terms(lt);
+  if ( result.length() > 1 ) return 0;
+  else return 1;
+}
+
+///////////////////////////////////////////////////////////////
+// Reverse the make_monic transformation.                    //
+// Return the list of factors.                               //
+///////////////////////////////////////////////////////////////
+static CFFList
+not_monic( const CFFList & TheList, const CanonicalForm & ltt, const CanonicalForm & F, int levelF)
+{
+  CFFList Returnlist,IntermediateList;
+  CFFListIterator i;
+  CanonicalForm intermediate,lt= ltt,savelc;
+  CanonicalForm numerator,denumerator,test,a,b;
+  Variable x(level(F));
+  int test1;
+
+  if ( lt.isOne() ) return TheList; // the poly was already monic
+  if ( TheList.length() <= 1 ) // only one factor to substitute back
+  {
+    if ( totaldegree(lt) == 0 ) // lt is type numeric
+      Returnlist.append( CFFactor(lt*TheList.getFirst().factor(),
+                                  TheList.getFirst().exp()) );
+    else
+    {
+      intermediate = F(x*lt, levelF)/power(lt,degree(F,levelF)-1);
+      Returnlist.append(CFFactor(intermediate,TheList.getFirst().exp()));
+    }
+  }
+  else // more then one factor
+  {
+    IntermediateList= TheList;
+    if ( totaldegree(lt) == 0 ){ // lt is type numeric;(SqrFree-use, see above)
+      Returnlist.append( CFFactor(lt*IntermediateList.getFirst().factor()
+                                  , IntermediateList.getFirst().exp()) );
+      IntermediateList.removeFirst();
+      Returnlist= Union(Returnlist,IntermediateList);
+    }
+    else // lt is a) a product or b) a sum of terms
+    {
+      if ( lt_is_product(lt) ) // case a)
+      {
+        DEBOUTLN(CERR, "lt_is_product: ", lt);
+        savelc= content(lt) ; // can we simplify to savelc= lc(lt); ?
+        while ( getNumVars(savelc) != 0 )
+          savelc= content(savelc);
+        for ( i=TheList; i.hasItem();i++ )
+        {
+          numerator= i.getItem().factor();
+          numerator= numerator(x*lt,levelF); // x <- x*lt
+          denumerator= power(lt,degree(F,levelF)-1); // == lt^(1-degree(F,x)
+          while (numerator.genZero() == is_rational(numerator, denumerator))
+            numerator*= lt;
+          intermediate= is_rational(numerator,denumerator);
+
+          Returnlist.append( CFFactor(lc(content(intermediate))*intermediate/content(intermediate), i.getItem().exp() ) );
+        }
+        // Now we add a test. If product(factors)/F is a multiple of
+        // savelc, we have to add 1/multiplicity to the factors
+        IntermediateList= Returnlist;
+        intermediate= 1;
+        for ( CFFListIterator j=IntermediateList; j.hasItem(); j++)
+          intermediate*= j.getItem().factor();
+        test1= mydivremt( intermediate,F,a,b);
+        if ( test1 && b == intermediate.genZero() ) // Yupp!
+        {
+          IntermediateList.append(CFFactor(1/a,1));
+          Returnlist= IntermediateList;
+        }
+        else { Returnlist= IntermediateList; }
+      }
+      else // case b)
+      {
+        DEBOUTLN(CERR, "lt_is_sum: ", lt);
+        CanonicalForm save_denumerator= 1;
+        for ( i=TheList; i.hasItem(); i++ )
+        {
+          numerator= i.getItem().factor();
+          numerator= numerator(x*lt,levelF); // x <- x*lt
+          denumerator= power(lt,degree(numerator,levelF)); // == lt^(-degree(numerator,x)
+          test= content(numerator,x);
+          test1= mydivremt(denumerator,test,a,b);
+          if ( test1 && b == numerator.genZero() ) // Yupp!
+          {
+            save_denumerator*= a;
+            Returnlist.append(CFFactor(numerator/test ,1));
+          }
+          else
+          {
+            factoryError("libfac: ERROR: not_monic1: case lt is a sum.");
+          }
+        }
+        // Now we add a test if we did the right thing:
+        // save_denumerator should be a multiple of the leading coeff
+        test1= mydivremt(save_denumerator,lt,a,b);
+        if ( test1 && b == save_denumerator.genZero() ) // Yupp!
+          // We have to multiply one of the factors with
+          // the multiplicity of the save_denumerator <-> lc
+          // the following will do what we want
+          Returnlist= myUnion( CFFList(CFFactor(1/a,1)),Returnlist) ;
+        else
+        {
+          factoryError("libfac: ERROR: not_monic2: case lt is a sum.");
+        }
+      }
+    }
+  }
+  DEBOUTLN(CERR,"Returnlist: ", Returnlist);
+  return Returnlist;
+}
+
+///////////////////////////////////////////////////////////////
+// Substitute the (Variable,Value)-Pair(s) from Substitution-//
+// list into the polynomial F. Returns the resulting poly.   //
+///////////////////////////////////////////////////////////////
+static CanonicalForm
+substitutePoly( const CanonicalForm & F, const SFormList & Substitutionlist){
+  CanonicalForm f= F;
+
+  for ( SFormListIterator i=Substitutionlist; i.hasItem(); i++ )
+    f= f(i.getItem().exp(),level(i.getItem().factor()));
+  return f;
+}
+
+///////////////////////////////////////////////////////////////
+// Find specialization values for the poly F. Returns 0 if   //
+// procedure failed, 1 otherwise. On success Substitutionlist//
+// holds (Variable,Value)-pairs. On failure we only have a   //
+// partitial list.                                           //
+///////////////////////////////////////////////////////////////
+//      *** This is the version with extensions ***          //
+///////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////
+// is CF g ok?                                               //
+///////////////////////////////////////////////////////////////
+static int
+various_tests( const CanonicalForm & g, int deg, int vars_left)
+{
+  CFMap m;
+
+  if ( degree(g) == deg ) // degrees match
+    if ( level(compress(g,m)) == (vars_left) ) // exactly one variable less
+      if ( SqrFreeTest(g,1) ) // poly is sqrfree
+        if ( gcd(g,g.deriv()).isOne() ) // Discriminante != 0
+           return 1;
+  return 0;
+}
+
+///////////////////////////////////////////////////////////////
+// specialize one variable over the given field.             //
+///////////////////////////////////////////////////////////////
+// substitutes in poly f of degree deg with former
+// former_nr_of_variables variables the variable nr_of_variable ;
+// this is done in the field of Char getCharacteristic() and
+// Extension given by Extgenerator.
+///////////////////////////////////////////////////////////////
+static int
+specialize_variable( CanonicalForm & f, int deg, SFormList & Substitutionlist, int nr_of_variable,
+                     int former_nr_of_variables, CFGenerator & Extgenerator ){
+  CanonicalForm g;
+  Variable x(nr_of_variable);
+
+  DEBOUTLN(CERR, "specialize_variable: called with: ", f);
+  for ( Extgenerator.reset(); Extgenerator.hasItems(); Extgenerator.next() ){
+    DEBOUTLN(CERR, "  specialize_variable: trying:  ", Extgenerator.item());
+    g= f( Extgenerator.item(), x );
+    DEBOUTLN(CERR, "  specialize_variable: resulting g= ", g);
+    if ( various_tests(g,deg,former_nr_of_variables - nr_of_variable ) ){
+      Substitutionlist.insert(SForm(x,Extgenerator.item())); // append (Var,value) pair
+      f= g;
+      return 1;
+    }
+  }
+  return 0;
+}
+static int
+specialize_agvariable( CanonicalForm & f, int deg, SFormList & Substitutionlist, int nr_of_variable,
+                     int former_nr_of_variables, AlgExtGenerator & Extgenerator ){
+  CanonicalForm g;
+  Variable x(nr_of_variable);
+
+  DEBOUTLN(CERR, "specialize_variable: called with: ", f);
+  for ( Extgenerator.reset(); Extgenerator.hasItems(); Extgenerator.next() ){
+    DEBOUTLN(CERR, "  specialize_variable: trying:  ", Extgenerator.item());
+    g= f( Extgenerator.item(), x );
+    DEBOUTLN(CERR, "  specialize_variable: resulting g= ", g);
+    if ( various_tests(g,deg,former_nr_of_variables - nr_of_variable ) ){
+      Substitutionlist.insert(SForm(x,Extgenerator.item())); // append (Var,value) pair
+      f= g;
+      return 1;
+    }
+  }
+  return 0;
+}
+
+///////////////////////////////////////////////////////////////
+// generate a minpoly of degree degree_of_Extension in the   //
+// field getCharacteristik()^Extension.                      //
+///////////////////////////////////////////////////////////////
+CanonicalForm
+generate_mipo( int degree_of_Extension , const Variable & Extension ){
+  FFRandom gen;
+  if ( degree(Extension) > 0 ) GFRandom gen;
+  else {
+    if ( degree(Extension) == 0 ) FFRandom gen;
+    else
+    {
+      factoryError("libfac: evaluate: Extension not inFF() or inGF() !");
+    }
+  }
+  return find_irreducible( degree_of_Extension, gen, Variable(1) );
+}
+
+///////////////////////////////////////////////////////////////
+// Try to find a specialization for f over the field of char //
+// f.getCharacteristic() and (possible) extension defined by //
+// the variable Extension .                                  //
+// Returns 1 iff specialisation was found, 0 otherwise.      //
+// If 0 is returned there are variables left to substitute.  //
+// We check if Substitutionlist.length() > 0, i.e. we        //
+// previously tried to find specialization values for some   //
+// values. We take them and work with the resulting poly.    //
+///////////////////////////////////////////////////////////////
+static int
+try_specializePoly(const CanonicalForm & f, const Variable & Extension, int deg, SFormList & Substitutionlist, int ii,int j)
+{
+  int ok,i= ii;
+  CanonicalForm ff= f;
+
+  if ( Substitutionlist.length() > 0 ){ // we formerly tried to specialize
+    ff= substitutePoly(f,Substitutionlist); // substitute found values
+    i= Substitutionlist.length() + 1;
+  }
+
+  if ( degree(Extension) > 0 )
+  { // working over Extensions
+    DEBOUTLN(CERR, "try_specializePoly: working over Extensions: ", Extension);
+    if (Extension.level() > 0)
+    {
+    //  AlgExtGenerator g(Extension,minpoly );
+    //  for ( int k=i ; k<j ; k++ ) // try to find specialization for all
+    //  {                           // variables (# = k ) beginning with the
+    //                             // starting value i
+    //    ok= specialize_agvariable( ff, deg, Substitutionlist, k, j, g );
+    //    if ( ! ok ) return 0; // we failed
+    //  }
+      #ifndef NDEBUG
+        //printf("libfac: try_specializePoly: extension level >0\n");
+      #endif
+      return 0; // we failed
+    }
+    else
+    {
+      AlgExtGenerator g(Extension);
+      for ( int k=i ; k<j ; k++ ) // try to find specialization for all
+      {                           // variables (# = k ) beginning with the
+                                 // starting value i
+        ok= specialize_agvariable( ff, deg, Substitutionlist, k, j, g );
+        if ( ! ok ) return 0; // we failed
+      }
+    }
+  }
+  else{ // working over the ground-field
+    FFGenerator g;
+    DEBOUTMSG(CERR, "try_specializePoly: working over the ground-field.");
+    for ( int k=i ; k<j ; k++ ){
+      ok= specialize_variable( ff, deg, Substitutionlist, k, j, g );
+      if ( ! ok ) return 0; // we failed
+    }
+  }
+  return 1;
+}
+
+static int
+specializePoly(const CanonicalForm & f, Variable & Extension, int deg, SFormList & Substitutionlist, int i,int j){
+  Variable minpoly= Extension;
+  int ok,extended= degree(Extension), working_over_extension;
+
+  // Remember if we are working over an extension-field
+  if ( extended >= 2 )    { working_over_extension = 1; }
+  else                    { working_over_extension = 0; extended = 1; }
+  // First try:
+  ok = try_specializePoly(f,minpoly,deg,Substitutionlist,i,j);
+  while ( ! ok ){ // we have to extend!
+    extended+= 1;
+    if ( ! working_over_extension ){
+      minpoly= rootOf(generate_mipo( extended,Extension ));
+      Extension= minpoly;
+      ok= try_specializePoly(f,minpoly,deg,Substitutionlist,i,j);
+    }
+    else
+    {
+      factoryError("libfac: spezializePoly ERROR: Working over given extension-field not yet implemented!");
+      return 0;
+    }
+  }
+  return 1;
+}
+
+
+// This is a procedure to play with: lot's of parameters!
+// returns: 0  iff no success (possibly because Extension isn't great enough
+//          >0 iff g (univariate) splits into n factors;
+// if n>0 BestEvaluationpoint contains the choice of values for the variables
+//
+// tries to find at least maxtries evaluation points
+// if g factored sametries into the same number of poly's the procedure stops
+// if we tried failtries evaluations not found valid, we stop. Perhaps
+// Extension isn't big enough!
+static int
+evaluate( int maxtries, int sametries, int failtries, const CanonicalForm &f , const Variable & Extension, const CanonicalForm &mipo, SFormList & BestEvaluationpoint, CFFList & BestFactorisation ){
+  int minfactors=degree(f),degf=degree(f),n=level(f.mvar())-1;
+  SFormList minEvaluation;
+  CFFList minFactorisation;
+  int samefactors=0, failedfactor=0, tried=0;
+  FFRandom gen;
+  CFFList unilist;
+
+  if ( degree(Extension) >0 ) GFRandom gen;
+  else
+  {
+    if ( degree(Extension) == 0 ) FFRandom gen;
+    else
+    {
+      factoryError("libfac: evaluate: Extension not inFF() or inGF() !");
+    }
+  }
+  REvaluation k(1,n,gen);
+  k.nextpoint();
+  for ( int i=1; i<=maxtries ; i++)
+  {
+    // k.nextpoint();
+    SFormList Substitutionlist;
+    for ( int j=1; j<=n; j++ )
+     Substitutionlist.insert(SForm(Variable(j),k[j]));
+    k.nextpoint();
+    CanonicalForm g=substitutePoly(f,Substitutionlist);
+    if ( various_tests(g, degf,1) )
+    { // found a valid point
+      failedfactor = 0; tried += 1;
+      if ( degree(Extension) == 0   )
+        unilist = factorize(g,1); // poly is sqr-free!
+      else
+      {
+        unilist = factorize2(g,Extension,mipo);
+      }
+      if (unilist.length() <= minfactors )
+      {
+        minfactors=unilist.length();
+        minEvaluation=Substitutionlist;
+        minFactorisation=unilist;
+      }
+      else samefactors +=1;
+
+      if (unilist.length() == 1 ) // wow! we found f is irreducible!
+      {
+        BestEvaluationpoint=minEvaluation;
+        BestFactorisation=minFactorisation;
+        return 1;
+      }
+
+      if ( samefactors >= sametries ) // now we stop ( maybe polynomial *has*
+                                      // minfactors factors? )
+      {
+        BestEvaluationpoint=minEvaluation;
+        BestFactorisation=minFactorisation;
+        return minfactors;
+      }
+
+    }
+    else
+      failedfactor += 1;
+
+    if ( failedfactor >= failtries ) // now we stop ( perhaps Extension isn't
+                                     // big enough )
+    {
+      if ( tried == 0 )
+        return 0;
+      else
+      {
+        BestEvaluationpoint=minEvaluation;
+        BestFactorisation=minFactorisation;
+        return minfactors;
+      }
+    }
+  }
+  BestEvaluationpoint=minEvaluation;
+  BestFactorisation=minFactorisation;
+  return minfactors;
+}
+
+///////////////////////////////////////////////////////////////
+// A factorization routine for a sqrfree polynomial.         //
+// Returns the list of factors.                              //
+///////////////////////////////////////////////////////////////
+CFFList
+Factorized( const CanonicalForm & F, const CanonicalForm & alpha, int Mainvar)
+{
+  CanonicalForm f,lt,ff,ffuni;
+  Variable Extension=alpha.mvar();
+  CFFList Outputlist,UnivariateFactorlist,Outputlist2;
+  SFormList Substitutionlist, Evaluationpoint;
+  CFFactor copy;
+  int mainvar=Mainvar,success,oldmainvar;
+  CFMap m;
+
+  // INTERRUPTHANDLER
+  if ( interrupt_handle() ) return CFFList() ;
+  // INTERRUPTHANDLER
+
+  if (F.inCoeffDomain()) {  return CFFList(CFFactor(F,1)); }
+  if ( F.isUnivariate() ) // could have lost one Variable elsewhere
+  {
+    if ( degree(Extension) == 0 )
+    {
+      TIMING_START(evaluate_time);
+      Outputlist = factorize(F,1); // poly is sqr-free
+      TIMING_END(evaluate_time);
+      return Outputlist;
+    }
+    else
+    {
+      if (Extension.level()<0)
+      DEBOUTLN(CERR, "Univ. Factorization over extension of degree ",
+               degree(getMipo(Extension,'x')) );
+      else
+      DEBOUTLN(CERR, "Univ. Factorization over extension of level ??",
+                Extension.level());
+      TIMING_START(evaluate_time);
+      Outputlist = factorize2(F,Extension,alpha);
+      TIMING_END(evaluate_time);
+      return Outputlist;
+    }
+  }
+
+  if ( Mainvar ) oldmainvar=Mainvar; else oldmainvar=level(F);
+  // First choose a main variable; this may be revisted in the next step
+  mainvar = choose_main_variable(F);
+  // Let`s look if @f/@mainvar is nonzero
+  mainvar = necessary_condition(F,mainvar);
+  // Now we have definetly choosen a main variable
+  // swap poly such that the mainvar has highest level
+  f=swapvar(F,mainvar,level(F));
+
+  // INTERRUPTHANDLER
+  if ( interrupt_handle() ) return CFFList() ;
+  // INTERRUPTHANDLER
+
+  if ( oldmainvar != mainvar ){
+    DEBOUTSL(CERR); DEBOUT(CERR,"Swapped poly ", F);
+    DEBOUT(CERR, " in ", f); DEBOUTNL(CERR);
+    DEBOUTSL(CERR); DEBOUT(CERR,"Swapped  ", oldmainvar );
+    DEBOUT(CERR, " <-- ", mainvar ); DEBOUT(CERR, "  Mainvar= ", f.mvar());
+    DEBOUTNL(CERR);
+    ff = f.deriv();
+    TIMING_START(discr_time);
+    ffuni = gcd(f,ff);
+    TIMING_END(discr_time);
+    if ( !(ffuni.isOne()) ){ //discriminante nonzero: split poly
+      DEBOUTLN(CERR,"Nontrivial GCD of f= ", f);
+      DEBOUTLN(CERR,"             and @f= ", ff);
+      DEBOUTLN(CERR,"          GCD(f,@f)= ", ffuni);
+      ff=f/ffuni;
+      CFFList Outputlist_a, Outputlist_b;
+      Outputlist_a = Factorized(ff,alpha);
+      DEBOUTLN(CERR, "Outputlist_a = ", Outputlist_a);
+      Outputlist_b = Factorized(ffuni,alpha);
+      DEBOUTLN(CERR, "Outputlist_b = ", Outputlist_b);
+      Outputlist = myUnion(Outputlist_a, Outputlist_b);
+      // have to back-swapvar the factors....
+      for ( CFFListIterator i=Outputlist; i.hasItem(); i++ ){
+        copy=i.getItem();
+        Outputlist2.append(CFFactor(swapvar(copy.factor(),oldmainvar,mainvar),copy.exp()));
+      }
+      DEBOUTLN(CERR, "Outputlist2 (a+b swapped) (to return) = ", Outputlist2);
+      return Outputlist2;
+    }
+  }
+
+  // Check special cases
+  for ( int i=1; i<=level(F); i++)
+  {
+    if ( degree(f,Variable(i) ) == 1 )
+    //test trivial case; only true iff F is primitiv w.r.t every variable; else check (if F=ax+b) gcd(a,b)=1 ?
+    {
+      DEBOUTLN(CERR, "Trivial case: ", F);
+      Outputlist.append(CFFactor(F,1));
+      return Outputlist;
+    }
+  }
+
+  // Look at the leading term:
+  lt = LC(f);
+  DEBOUTLN(CERR, "Leading term: ", lt);
+  //if ( lt != f.genOne() )
+  if ( !lt.isOne() )
+  {
+    // make the polynomial monic in the main variable
+    ff = make_monic(f,lt); ffuni = ff;
+    DEBOUTLN(CERR, "make_monic returned: ", ff);
+  }
+  else{ ff= f; ffuni= ff; }
+
+  TIMING_START(evaluate_time);
+  success=evaluate(min(10,max(degree(ff), 5)), min(degree(ff),3), min(degree(ff),3), ff, Extension, alpha, Substitutionlist,UnivariateFactorlist);
+  DEBOUTLN(CERR,  "Returned from evaluate: success: ", success);
+  for ( SFormListIterator ii=Substitutionlist; ii.hasItem(); ii++ )
+  {
+    DEBOUTLN(CERR, "Substituting ", ii.getItem().factor());
+    DEBOUTLN(CERR, "       with value: ", ii.getItem().exp());
+  }
+
+  if ( success==0 ) // evalute wasn't successfull
+  {
+    success= specializePoly(ffuni,Extension,degree(ff),Substitutionlist,1,getNumVars(compress(ff,m)));
+    DEBOUTLN(CERR,  "Returned from specializePoly: success: ", success);
+    if (success == 0 ) // No spezialisation could be found
+    {
+      factoryError("libfac: Factorize: ERROR: Not able to find a valid specialization!");
+      Outputlist.append(CFFactor(F,1));
+      return Outputlist;
+    }
+
+    // INTERRUPTHANDLER
+    if ( interrupt_handle() ) return CFFList() ;
+    // INTERRUPTHANDLER
+
+    ffuni = substitutePoly(ff,Substitutionlist);
+    // We now have an univariat poly; factorize that
+    if ( degree(Extension) == 0   )
+    {
+      DEBOUTMSG(CERR, "Univ. Factorization over the ground field");
+      UnivariateFactorlist = factorize(ffuni,1); // univ. poly is sqr-free!
+    }
+    else
+    {
+      DEBOUTLN(CERR, "Univ. Factorization over extension of degree ",
+               degree(getMipo(Extension,'x')) );
+      UnivariateFactorlist = factorize2(ffuni,Extension,alpha);
+    }
+  }
+  else
+  {
+    ffuni = substitutePoly(ff,Substitutionlist);
+  }
+    TIMING_END(evaluate_time);
+  if (UnivariateFactorlist.length() == 1)
+  { // poly is irreduzibel
+    DEBOUTLN(CERR, "Univ. poly is irreduzible: ", UnivariateFactorlist);
+    Outputlist.append(CFFactor(F,1));
+    return Outputlist;
+  }
+  else
+  { // we have factors
+    DEBOUTSL(CERR);
+    DEBOUT(CERR, "Univariate poly has " , UnivariateFactorlist.length());
+    DEBOUT(CERR, " factors:  ", ffuni);
+    DEBOUT(CERR, " = ", UnivariateFactorlist); DEBOUTNL(CERR);
+
+    // INTERRUPTHANDLER
+    if ( interrupt_handle() ) return CFFList() ;
+    // INTERRUPTHANDLER
+
+    TIMING_START(hensel_time);
+    Outputlist = MultiHensel(ff,UnivariateFactorlist,Substitutionlist, alpha);
+    DEBOUTLN(CERR, "Outputlist after MultiHensel: ", Outputlist);
+    TIMING_END(hensel_time);
+
+    // INTERRUPTHANDLER
+    if ( interrupt_handle() ) return CFFList() ;
+    // INTERRUPTHANDLER
+
+    TIMING_START(truefactor_time);
+    Outputlist = Truefactors(ff, level(ff), Substitutionlist, Outputlist);
+    DEBOUTLN(CERR, "Outputlist after Truefactors: ", Outputlist);
+    TIMING_END(truefactor_time);
+
+    // INTERRUPTHANDLER
+    if ( interrupt_handle() ) return CFFList() ;
+    // INTERRUPTHANDLER
+
+    //if ( lt != f.genOne() )
+    if ( !lt.isOne() )
+    {
+      Outputlist = not_monic(Outputlist,lt,ff,level(ff));
+      DEBOUTLN(CERR, "not_monic returned: ", Outputlist);
+    }
+
+    // have to back-swapvar the factors....
+    for ( CFFListIterator i=Outputlist; i.hasItem(); i++ )
+    {
+      copy=i.getItem();
+      Outputlist2.append(CFFactor(swapvar(copy.factor(),oldmainvar,mainvar),copy.exp()));
+    }
+
+    return Outputlist2;
+  }
+}
+
+int cmpCF( const CFFactor & f, const CFFactor & g );
+
+///////////////////////////////////////////////////////////////
+// The user front-end for a uni/multivariate factorization   //
+// routine. F needs not to be SqrFree.                       //
+// Option of * choosing a  main variable (n.y.i.)            //
+//           * choosing an algebraic extension (n.y.u.)      //
+//           * ensuring poly is sqrfree (n.y.i.)             //
+// use Factorize(F,alpha,is_SqrFree) if not over Zp[x]/Q[x]  //
+///////////////////////////////////////////////////////////////
+int find_mvar(const CanonicalForm &f);
+CFFList Factorize(const CanonicalForm & F, int is_SqrFree )
+{
+  //out_cf("Factorize ",F,"\n");
+  CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2;
+  ListIterator<CFFactor> i,j;
+  CanonicalForm g=1,unit=1,r=1;
+  Variable minpoly; // dummy
+  int exp;
+  CFMap m;
+
+  // INTERRUPTHANDLER
+  if ( interrupt_handle() ) return CFFList() ;
+  // INTERRUPTHANDLER
+
+  DEBINCLEVEL(CERR, "Factorize");
+  DEBOUTLN(CERR, "Called with F= ", F);
+  if (( getCharacteristic() == 0 ) || (F.isUnivariate()))
+  { // char == 0
+    TIMING_START(factorize_time);
+    //CERR << "Factoring in char=0 of " << F << " = " << Outputlist << "\n";
+    Outputlist= factorize(F);
+    // Factorization in char=0 doesn't sometimes return at least two elements!!!
+    if ( getNumVars(Outputlist.getFirst().factor()) != 0 )
+      Outputlist.insert(CFFactor(1,1));
+    //CERR << "  Factorize in char=0: returning with: " << Outputlist << "\n";
+    TIMING_END(factorize_time);
+    DEBDECLEVEL(CERR, "Factorize");
+    TIMING_PRINT(factorize_time, "\ntime used for factorization   : ");
+    return Outputlist;
+  }
+  TIMING_START(factorize_time);
+  // search an "optimal" main variavble
+  int mv=F.level();
+  if ((mv != LEVELBASE) /* && (! F.isUnivariate()) */)
+  {
+     mv=find_mvar(F);
+     if (mv!=F.level())
+     {
+       swapvar(F,Variable(mv),F.mvar());
+     }
+  }
+
+  ///////
+  // Maybe it`s better to add a sqrfree-test before?
+  // (If gcd is fast...)
+  ///////
+  //  if ( ! SqrFreeTest(F) ){
+  if ( ! is_SqrFree )
+  {
+    TIMING_START(sqrfree_time);
+    SqrFreeList = SqrFreeMV(F) ; // first sqrfree the polynomial
+    // don't use sqrFree(F), factory's internal sqrFree for multiv.
+    // Polynomials; it's wrong!! Ex.: char=p   f= x^p*(y+1);
+    // SqrFreeMV(f)= ( y+1, (x)^p ), sqrFree(f)= ( y+1 ) .
+    TIMING_END(sqrfree_time);
+
+    // INTERRUPTHANDLER
+    if ( interrupt_handle() ) return CFFList() ;
+    // INTERRUPTHANDLER
+
+  }
+  else
+    SqrFreeList.append(CFFactor(F,1));
+
+  DEBOUTLN(CERR, "SqrFreeMV= ", SqrFreeList);
+  for ( i=SqrFreeList; i.hasItem(); i++ )
+  {
+    DEBOUTLN(CERR, "Factor under consideration: ", i.getItem().factor());
+    // We need a compress on each list item ! Maybe we have less variables!
+    g =compress(i.getItem().factor(),m);
+    exp = i.getItem().exp();
+    if ( getNumVars(g) ==0 ) // a constant; Exp==1
+      Outputlist.append( CFFactor(g,1) ) ;
+    else// a real polynomial
+      if ( g.isUnivariate() )
+      {
+        //out_cf("univ. poly: ",g,"\n");
+        Intermediatelist=factorize(g,1); // poly is sqr-free!
+        for ( j=Intermediatelist; j.hasItem(); j++ )
+          //Normally j.getItem().exp() should be 1
+          Outputlist.append( CFFactor( m(j.getItem().factor()),exp*j.getItem().exp()));
+      }
+      else
+      { // multivariate polynomial
+        if ( g.isHomogeneous() )
+        {
+          DEBOUTLN(CERR, "Poly is homogeneous! : ", g);
+          // Now we can substitute one variable to 1, factorize and then
+          // look on the resulting factors and their monomials for
+          // backsubstitution of the substituted variable.
+          Intermediatelist = HomogFactor(g, minpoly, 0);
+        }
+        else // not homogeneous
+          Intermediatelist = Factorized(g, minpoly, 0);
+
+        // INTERRUPTHANDLER
+        if ( interrupt_handle() ) return CFFList() ;
+        // INTERRUPTHANDLER
+
+        for ( j=Intermediatelist; j.hasItem(); j++ )
+          //Normally j.getItem().exp() should be 1
+          Outputlist= myappend( Outputlist, CFFactor(m(j.getItem().factor()),exp*j.getItem().exp()));
+      }
+  }
+  g=1; unit=1;
+  DEBOUTLN(CERR, "Outputlist is ", Outputlist);
+  for ( i=Outputlist; i.hasItem(); i++ )
+    if ( level(i.getItem().factor()) > 0 )
+    {
+      unit = lc(i.getItem().factor());
+      if ( getNumVars(unit) == 0 )
+      { // a constant; possibly 1
+        Outputlist2.append(CFFactor(i.getItem().factor()/unit , i.getItem().exp()));
+        g *=power(i.getItem().factor()/unit,i.getItem().exp());
+      }
+      else
+      {
+        Outputlist2.append(i.getItem());
+        g *=power(i.getItem().factor(),i.getItem().exp());
+      }
+    }
+
+  r=F/g;
+  Outputlist2.insert(CFFactor(r,1));
+
+  if ((mv!=F.level()) && (! F.isUnivariate() ))
+  {
+    CFFListIterator J=Outputlist2;
+    for ( ; J.hasItem(); J++)
+    {
+      swapvar(J.getItem().factor(),Variable(mv),F.mvar());
+    }
+    swapvar(F,Variable(mv),F.mvar());
+  }
+  DEBDECLEVEL(CERR, "Factorize");
+  TIMING_END(factorize_time);
+
+  TIMING_PRINT(sqrfree_time, "\ntime used for sqrfree   : ");
+  TIMING_PRINT(discr_time, "time used for discriminante   : ");
+  TIMING_PRINT(evaluate_time, "time used for evaluation and univ. factorization  : ");
+  TIMING_PRINT(hensel_time, "time used for hensel-lift   : ");
+  TIMING_PRINT(truefactor_time, "time used for truefactors   : ");
+  TIMING_PRINT(factorize_time, "\ntime used for factorization   : ");
+
+  if(isOn(SW_USE_NTL_SORT)) Outputlist2.sort(cmpCF);
+
+  return Outputlist2;
+}
+
+///////////////////////////////////////////////////////////////
+// The user front-end for a uni/multivariate factorization   //
+// routine. F needs not to be SqrFree.                       //
+// Option of * choosing a  main variable (n.y.i.)            //
+//           * choosing an algebraic extension (n.y.u.)      //
+//           * ensuring poly is sqrfree (n.y.i.)             //
+///////////////////////////////////////////////////////////////
+static bool fdivides2(const CanonicalForm &F, const CanonicalForm &G, const CanonicalForm &minpoly)
+{
+  if (!minpoly.isZero())
+  {
+  #if 0
+    Variable Alpha=minpoly.mvar();
+    Variable X=rootOf(minpoly);
+    CanonicalForm rF=replacevar(F,Alpha,X);
+    CanonicalForm rG=replacevar(G,Alpha,X);
+    return fdivides(rF,rG);;
+  #else
+    if (degree(F,F.mvar()) > degree(G,F.mvar())) return false;
+    return true;
+    //CanonicalForm a,b;
+    //mydivrem(G,F,a,b);
+    //if (b.isZero()) return true;
+    //else return false;
+  #endif
+  }
+  else
+   return fdivides(F,G);
+}
+
+CFFList
+Factorize(const CanonicalForm & F, const CanonicalForm & minpoly, int is_SqrFree )
+{
+  //out_cf("Factorize: F=",F,"\n");
+  //out_cf("           minpoly:",minpoly,"\n");
+  CFFList Outputlist,SqrFreeList,Intermediatelist,Outputlist2;
+  ListIterator<CFFactor> i,j;
+  CanonicalForm g=1,unit=1,r=1;
+  //Variable minpoly; // reserved (-> Factorisation over algebraic Extensions)
+  int exp;
+  CFMap m;
+
+  // INTERRUPTHANDLER
+  if ( interrupt_handle() ) return CFFList() ;
+  // INTERRUPTHANDLER
+
+  DEBINCLEVEL(CERR, "Factorize");
+  DEBOUTLN(CERR, "Called with F= ", F);
+  if ( getCharacteristic() == 0 )
+  { // char == 0
+    TIMING_START(factorize_time);
+    //CERR << "Factoring in char=0 of " << F << " = " << Outputlist << "\n";
+    #if 0
+    // SHOULD: Outputlist= factorize(F,minpoly);
+    Outputlist= factorize(F);
+    #else
+    if (!minpoly.isZero())
+    {
+      if ( F.isHomogeneous() )
+      {
+        DEBOUTLN(CERR, "Poly is homogeneous! : ", F);
+        // Now we can substitute one variable to 1, factorize and then
+        // look on the resulting factors and their monomials for
+        // backsubstitution of the substituted variable.
+        Outputlist=HomogFactor(F, minpoly, 0);
+      }
+      else
+      {
+        CFList as(minpoly);
+        //CFFList sqF=sqrFree(F); // sqrFreeZ
+        CFFList sqF=SqrFreeMV(F,minpoly);
+        if (sqF.isEmpty()) sqF=sqrFree(F);
+        CFFList G,H;
+        CanonicalForm fac;
+        int d;
+        ListIterator<CFFactor> i,k;
+        for ( i = sqF; i.hasItem(); ++i )
+        {
+          d = i.getItem().exp();
+          fac = i.getItem().factor();
+          int success=1;
+          G = newfactoras( fac, as, success);
+          for ( k = G; k.hasItem(); ++k )
+          {
+            fac = k.getItem().factor();
+            int dd = k.getItem().exp();
+            H.append( CFFactor( fac , d*dd ) );
+          }
+        }
+        Outputlist = H;
+      }
+    }
+    else // minpoly==0
+      Outputlist=factorize(F);
+    #endif
+    // Factorization in char=0 doesn't sometimes return at least two elements!!!
+    if ( getNumVars(Outputlist.getFirst().factor()) != 0 )
+      Outputlist.insert(CFFactor(1,1));
+    //CERR << "  Factorize in char=0: returning with: " << Outputlist << "\n";
+    TIMING_END(factorize_time);
+    DEBDECLEVEL(CERR, "Factorize");
+    TIMING_PRINT(factorize_time, "\ntime used for factorization   : ");
+    //out_cff(Outputlist);
+    return Outputlist;
+  }
+  TIMING_START(factorize_time);
+  // search an "optimal" main variavble
+  int mv=F.level();
+  if (mv != LEVELBASE && ! F.isUnivariate() )
+  {
+     mv=find_mvar(F);
+     if (mv!=F.level())
+     {
+       swapvar(F,Variable(mv),F.mvar());
+     }
+  }
+
+  ///////
+  // Maybe it`s better to add a sqrfree-test before?
+  // (If gcd is fast...)
+  ///////
+  //  if ( ! SqrFreeTest(F) ){
+  if ( ! is_SqrFree )
+  {
+    TIMING_START(sqrfree_time);
+    SqrFreeList = SqrFreeMV(F, minpoly) ; // first sqrfree the polynomial
+    // don't use sqrFree(F), factory's internal sqrFree for multiv.
+    // Polynomials; it's wrong!! Ex.: char=p   f= x^p*(y+1);
+    // SqrFreeMV(f)= ( y+1, (x)^p ), sqrFree(f)= ( y+1 ) .
+    TIMING_END(sqrfree_time);
+
+    // INTERRUPTHANDLER
+    if ( interrupt_handle() ) return CFFList() ;
+    // INTERRUPTHANDLER
+
+  }
+  else
+    SqrFreeList.append(CFFactor(F,1));
+  DEBOUTLN(CERR, "SqrFreeMV= ", SqrFreeList);
+  for ( i=SqrFreeList; i.hasItem(); i++ )
+  {
+    DEBOUTLN(CERR, "Factor under consideration: ", i.getItem().factor());
+    // We need a compress on each list item ! Maybe we have less variables!
+    g =compress(i.getItem().factor(),m);
+    exp = i.getItem().exp();
+    if ( getNumVars(g) ==0 ) // a constant; Exp==1
+      Outputlist.append( CFFactor(g,1) ) ;
+    else// a real polynomial
+    {
+      if ( g.isUnivariate() )
+      {
+        Variable alpha=rootOf(minpoly);
+        Intermediatelist=factorize2(g,alpha,minpoly); // poly is sqr-free!
+        for ( j=Intermediatelist; j.hasItem(); j++ )
+          //Normally j.getItem().exp() should be 1
+          Outputlist.append(
+           CFFactor( m(replacevar(j.getItem().factor(),alpha,minpoly.mvar())),
+             exp*j.getItem().exp()));
+      }
+      else // multivariate polynomial
+      {
+        if ( g.isHomogeneous() )
+        {
+          DEBOUTLN(CERR, "Poly is homogeneous! : ", g);
+          // Now we can substitute one variable to 1, factorize and then
+          // look on the resulting factors and their monomials for
+          // backsubstitution of the substituted variable.
+          Intermediatelist = HomogFactor(g, minpoly, 0);
+        }
+        else // not homogeneous
+          Intermediatelist = Factorized(g, minpoly, 0);
+
+        // INTERRUPTHANDLER
+        if ( interrupt_handle() ) return CFFList() ;
+        // INTERRUPTHANDLER
+
+        for ( j=Intermediatelist; j.hasItem(); j++ )
+          //Normally j.getItem().exp() should be 1
+          Outputlist= myappend( Outputlist, CFFactor(m(j.getItem().factor()),exp*j.getItem().exp()));
+      }
+    }
+  }
+  g=1; unit=1;
+  DEBOUTLN(CERR, "Outputlist is ", Outputlist);
+  for ( i=Outputlist; i.hasItem(); i++ )
+    if ( level(i.getItem().factor()) > 0 )
+    {
+      unit = lc(i.getItem().factor());
+      if ( getNumVars(unit) == 0 ){ // a constant; possibly 1
+        Outputlist2.append(CFFactor(i.getItem().factor()/unit , i.getItem().exp()));
+        g *=power(i.getItem().factor()/unit,i.getItem().exp());
+      }
+      else
+      {
+        Outputlist2.append(i.getItem());
+        g *=power(i.getItem().factor(),i.getItem().exp());
+      }
+    }
+
+  r=F/g;
+  Outputlist2.insert(CFFactor(r,1));
+
+  if ((mv!=F.level()) && (! F.isUnivariate() ))
+  {
+    CFFListIterator J=Outputlist2;
+    for ( ; J.hasItem(); J++)
+    {
+      swapvar(J.getItem().factor(),Variable(mv),F.mvar());
+    }
+    swapvar(F,Variable(mv),F.mvar());
+  }
+
+  DEBDECLEVEL(CERR, "Factorize");
+  TIMING_END(factorize_time);
+
+  TIMING_PRINT(sqrfree_time, "\ntime used for sqrfree   : ");
+  TIMING_PRINT(discr_time, "time used for discriminante   : ");
+  TIMING_PRINT(evaluate_time, "time used for evaluation and univ. factorization  : ");
+  TIMING_PRINT(hensel_time, "time used for hensel-lift   : ");
+  TIMING_PRINT(truefactor_time, "time used for truefactors   : ");
+  TIMING_PRINT(factorize_time, "\ntime used for factorization   : ");
+
+  if(isOn(SW_USE_NTL_SORT)) Outputlist2.sort(cmpCF);
+
+  //out_cff(Outputlist2);
+  return Outputlist2;
+}
+
Index: libfac/factor/Factor.h
===================================================================
--- libfac/factor/Factor.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/Factor.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,14 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+///////////////////////////////////////////////////////////////////////////////
+#ifndef FACTOR_H
+#define FACTOR_H
+CanonicalForm generate_mipo( int degree_of_Extension , const Variable & Extension );
+CFFList Factorized( const CanonicalForm & F, const CanonicalForm & mipo, int Mainvar=0);
+/*BEGINPUBLIC*/
+CFFList Factorize( const CanonicalForm & F, int is_SqrFree=0 ) ;
+CFFList Factorize( const CanonicalForm & F, const CanonicalForm & mi, int is_SqrFree=0 ) ;
+/*ENDPUBLIC*/
+
+#endif /* FACTOR_H */
+
Index: libfac/factor/MVMultiHensel.cc
===================================================================
--- libfac/factor/MVMultiHensel.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/MVMultiHensel.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,482 @@
+///////////////////////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+///////////////////////////////////////////////////////////////////////////////
+// FACTORY - Includes
+#include <factory.h>
+#ifndef NOSTREAMIO
+#ifdef HAVE_IOSTREAM
+#include <iostream>
+#define OSTREAM std::ostream
+#define ISTREAM std::istream
+#define CERR std::cerr
+#define CIN std::cin
+#elif defined(HAVE_IOSTREAM_H)
+#include <iostream.h>
+#define OSTREAM ostream
+#define ISTREAM istream
+#define CERR cerr
+#define CIN cin
+#endif
+#endif
+// Factor - Includes
+#include "tmpl_inst.h"
+#include "helpstuff.h"
+// some CC's need this:
+#include "MVMultiHensel.h"
+
+#ifndef NOSTREAMIO
+void out_cf(const char *s1,const CanonicalForm &f,const char *s2);
+#endif
+
+extern int libfac_interruptflag;
+
+#ifdef HENSELDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+
+#include <libfac/factor/debug.h>
+#include "interrupt.h"
+#include "timing.h"
+
+///////////////////////////////////////////////////////////////
+// some class definition needed in MVMultiHensel
+///////////////////////////////////////////////////////////////
+typedef bool Boolean;
+
+class DiophantForm
+{
+ public:
+   CanonicalForm One;
+   CanonicalForm Two;
+   inline DiophantForm& operator=( const DiophantForm&  value )
+   {
+     if ( this != &value )
+     {
+       One = value.One;
+       Two = value.Two;
+     }
+     return *this;
+   }
+};
+
+// We remember an already calculated value; simple class for RememberArray
+class RememberForm
+{
+public:
+  inline RememberForm operator=( CanonicalForm & value )
+  {
+    this->calculated = true;
+    this->poly = value;
+    return *this;
+  }
+  RememberForm() : poly(0), calculated(false) {}
+  Boolean calculated;
+  CanonicalForm poly;
+};
+
+// Array to remember already calculated values; used for the diophantine
+// equation s*f + t*g = x^i
+class RememberArray
+{
+public:
+// operations performed on arrays
+  RememberArray( int sz )
+  {
+    size = sz;
+    ia = new RememberForm[size];
+//    assert( ia != 0 ); // test if we got the memory
+    init( sz );
+  }
+  ~RememberArray(){ delete [] ia; }
+  inline RememberForm& operator[]( int index )
+  {
+    return ia[index];
+  }
+  bool checksize(int i) {return i<size;}
+protected:
+  void init( int )
+  {
+    for ( int ix=0; ix < size; ++ix)
+    {
+      ia[ix].calculated=false;
+      ia[ix].poly=0;
+    }
+  }
+// internal data representation
+  int size;
+  RememberForm *ia;
+};
+
+///////////////////////////////////////////////////////////////
+// Solve the Diophantine equation: ( levelU == mainvar )     //
+//            s*F1 + t*F2 = (mainvar)^i                      //
+// Returns s and t.                                          //
+///////////////////////////////////////////////////////////////
+static DiophantForm
+diophant( int levelU , const CanonicalForm & F1 , const CanonicalForm & F2 ,
+          int i , RememberArray & A, RememberArray & B,
+          const CanonicalForm &alpha )
+{
+  DiophantForm Retvalue;
+  CanonicalForm s,t,q,r;
+  Variable x(levelU);
+
+  DEBOUT(CERR, "diophant: called with: ", F1);
+  DEBOUT(CERR, "  ", F2); DEBOUTLN(CERR, "  ", i);
+
+  // Did we solve the diophantine equation yet?
+  // If so, return the calculated values
+  if (A.checksize(i) && A[i].calculated && B[i].calculated )
+  {
+    Retvalue.One=A[i].poly;
+    Retvalue.Two=B[i].poly;
+    return Retvalue;
+  }
+
+  // Degrees ok? degree(F1,mainvar) + degree(F2,mainvar) <= i ?
+  if ( (degree(F1,levelU) + degree(F2,levelU) ) <= i )
+  {
+    if (!interrupt_handle()) factoryError("libfac: diophant ERROR: degree too large!"); /*  (%d + %d <= %d)",degree(F1,levelU), degree(F2,levelU), i);*/
+    Retvalue.One=F1;Retvalue.Two=F2;
+    return Retvalue;
+  }
+
+  if ( i == 0 )
+  { // call the extended gcd
+    r=extgcd(F1,F2,s,t);
+    // check if gcd(F1,F2) <> 1 , i.e. F1 and F2 are not relatively prime
+    if ( ! r.isOne() )
+    {
+      if (r.degree()<1) // some constant != 1 ?
+      {
+        Retvalue.One=s/r;Retvalue.Two=t/r;
+        return Retvalue;
+      }
+      else if (alpha!=0)
+      {
+        Variable Alpha=alpha.mvar();
+        if (r.mvar()==Alpha)   // from field extension ?
+        {
+          Variable X=rootOf(alpha);
+          r=replacevar(r,Alpha,X);
+          s=replacevar(s,Alpha,X);
+          t=replacevar(t,Alpha,X);
+          s/=r;
+          t/=r;
+          s=replacevar(s,X,Alpha);
+          t=replacevar(t,X,Alpha);
+          Retvalue.One=s; Retvalue.Two=t;
+          return Retvalue;
+        }
+      } 
+      if (!interrupt_handle())
+        factoryError("libfac: diophant ERROR: F1 and F2 are not relatively prime! ");
+      Retvalue.One=s/r;Retvalue.Two=t/r;
+      return Retvalue;
+    }
+    Retvalue.One = s; Retvalue.Two = t;
+  }
+  else
+  { // recursively call diophant
+    Retvalue=diophant(levelU,F1,F2,i-1,A,B,alpha);
+    Retvalue.One *= x; // createVar(levelU,1);
+    Retvalue.Two *= x; // createVar(levelU,1);
+
+    if (interrupt_handle()) return Retvalue;
+
+    // Check degrees.
+
+    if ( degree(Retvalue.One,levelU) > degree(F2,levelU) )
+    {
+      // Make degree(Retvalue.one,mainvar) < degree(F2,mainvar)
+      divrem(Retvalue.One,F2,q,r);
+      Retvalue.One = r; Retvalue.Two += F1*q;
+    }
+    else
+    {
+      if ( degree(Retvalue.Two,levelU) >= degree(F1,levelU) )
+      {
+        // Make degree(Retvalue.Two,mainvar) <= degree(F1,mainvar)
+        divrem(Retvalue.Two,F1,q,r);
+        Retvalue.One += F2*q; Retvalue.Two = r;
+      }
+    }
+
+  }
+  if (A.checksize(i))
+  {
+    A[i].poly = Retvalue.One ;
+    B[i].poly = Retvalue.Two ;
+    A[i].calculated = true ; B[i].calculated = true ;
+  }
+  DEBOUT(CERR, "diophant: Returnvalue is: ", Retvalue.One);
+  DEBOUTLN(CERR, "  ", Retvalue.Two);
+
+  return  Retvalue;
+}
+
+///////////////////////////////////////////////////////////////
+// A more efficient way to solve s*F1 + t*F2 = W             //
+// as in Wang and Rothschild [Wang&Roth75].                  //
+///////////////////////////////////////////////////////////////
+static CanonicalForm
+make_delta( int levelU, const CanonicalForm & W,
+            const CanonicalForm & F1, const CanonicalForm & F2,
+            RememberArray & A, RememberArray & B,
+            const CanonicalForm &alpha)
+{
+  CanonicalForm Retvalue;
+  DiophantForm intermediate;
+
+  DEBOUT(CERR, "make_delta: W= ", W);
+  DEBOUTLN(CERR, "  degree(W,levelU)= ", degree(W,levelU) );
+
+  if ( levelU == level(W) ) // same level, good
+  {
+    for ( CFIterator i=W; i.hasTerms(); i++)
+    {
+      intermediate=diophant(levelU,F1,F2,i.exp(),A,B,alpha);
+      Retvalue += intermediate.One * i.coeff();
+
+      if (interrupt_handle()) return Retvalue;
+    }
+  }
+  else // level(W) < levelU ; i.e. degree(w,levelU) == 0
+  {
+    intermediate=diophant(levelU,F1,F2,0,A,B,alpha);
+    Retvalue = W * intermediate.One;
+  }
+  DEBOUTLN(CERR, "make_delta: Returnvalue= ", Retvalue);
+  return Retvalue;
+}
+
+static CanonicalForm
+make_square( int levelU, const CanonicalForm & W,
+             const CanonicalForm & F1, const CanonicalForm & F2,
+             RememberArray & A, RememberArray & B,const CanonicalForm &alpha)
+{
+  CanonicalForm Retvalue;
+  DiophantForm intermediate;
+
+  DEBOUT(CERR, "make_square: W= ", W );
+  DEBOUTLN(CERR, "  degree(W,levelU)= ", degree(W,levelU));
+
+  if ( levelU == level(W) ) // same level, good
+  {
+    for ( CFIterator i=W; i.hasTerms(); i++)
+    {
+      intermediate=diophant(levelU,F1,F2,i.exp(),A,B,alpha);
+      Retvalue += i.coeff() * intermediate.Two;
+
+      if (interrupt_handle()) return Retvalue;
+    }
+  }
+  else // level(W) < levelU ; i.e. degree(w,levelU) == 0
+  {
+    intermediate=diophant(levelU,F1,F2,0,A,B,alpha);
+    Retvalue = W * intermediate.Two;
+  }
+  DEBOUTLN(CERR, "make_square: Returnvalue= ", Retvalue);
+
+  return Retvalue;
+}
+
+
+///////////////////////////////////////////////////////////////
+// Multivariat Hensel routine for two factors F and G .      //
+// U is the monic univariat polynomial; we manage two arrays //
+// to remember already calculated values for the diophantine //
+// equation. This is suggested by Joel Moses [Moses71] .     //
+// Return the fully lifted factors.                          //
+///////////////////////////////////////////////////////////////
+static DiophantForm
+mvhensel( const CanonicalForm & U , const CanonicalForm & F ,
+          const CanonicalForm & G , const SFormList & Substitutionlist,
+          const CanonicalForm &alpha)
+{
+  CanonicalForm V,Fk=F,Gk=G,Rk,W,D,S;
+  int  levelU=level(U), degU=subvardegree(U,levelU); // degree(U,{x_1,..,x_(level(U)-1)})
+  DiophantForm Retvalue;
+  RememberArray A(degree(F,levelU)+degree(G,levelU)+1);
+  RememberArray B(degree(F,levelU)+degree(G,levelU)+1);
+
+  DEBOUTLN(CERR, "mvhensel called with: U= ", U);
+  DEBOUTLN(CERR, "                      F= ", F);
+  DEBOUTLN(CERR, "                      G= ", G);
+  DEBOUTLN(CERR, "                   degU= ", degU);
+
+  V=change_poly(U,Substitutionlist,0); // change x_i <- x_i + a_i for all i
+  Rk = F*G-V;
+#ifdef HENSELDEBUG2
+  CERR << "mvhensel: V = " << V << "\n"
+       << "          Fk= " << F << "\n"
+       << "          Gk= " << G << "\n"
+       << "          Rk= " << Rk << "\n";
+#endif
+  for ( int k=2; k<=degU+1; k++)
+  {
+    W = mod_power(Rk,k,levelU);
+#ifdef HENSELDEBUG2
+    CERR << "mvhensel: Iteration: " << k << "\n";
+    CERR << "mvhensel: W= " << W << "\n";
+#endif
+    D = make_delta(levelU,W,F,G,A,B,alpha);
+#ifdef HENSELDEBUG2
+    CERR << "mvhensel: D= " << D << "\n";
+#endif
+    S = make_square(levelU,W,F,G,A,B,alpha);
+#ifdef HENSELDEBUG2
+    CERR << "mvhensel: S= " << S << "\n";
+#endif
+    Rk += S*D - D*Fk - S*Gk;
+#ifdef HENSELDEBUG2
+    CERR << "mvhensel: Rk= " << Rk << "\n";
+#endif
+    Fk -= S;
+#ifdef HENSELDEBUG2
+    CERR << "mvhensel: Fk= " << Fk << "\n";
+#endif
+    Gk -= D;
+#ifdef HENSELDEBUG2
+    CERR << "mvhensel: Gk= " << Gk << "\n";
+#endif
+    if ( Rk.isZero() ) break;
+    if (interrupt_handle()) break;
+  }
+  Retvalue.One = change_poly(Fk,Substitutionlist,1);
+  Retvalue.Two = change_poly(Gk,Substitutionlist,1);
+
+  DEBOUTLN(CERR, "mvhensel: Retvalue: ", Retvalue.One);
+  DEBOUTLN(CERR, "                    ", Retvalue.Two);
+
+  return Retvalue ;
+}
+
+///////////////////////////////////////////////////////////////
+// Recursive Version of MultiHensel.                         //
+///////////////////////////////////////////////////////////////
+CFFList
+multihensel( const CanonicalForm & mF, const CFFList & Factorlist,
+             const SFormList & Substitutionlist,
+             const CanonicalForm &alpha)
+{
+  CFFList Returnlist,factorlist=Factorlist;
+  DiophantForm intermediat;
+  CanonicalForm Pl,Pr;
+  int n = factorlist.length();
+
+  DEBOUT(CERR, "multihensel: called with ", mF);
+  DEBOUTLN(CERR, "  ", factorlist);
+
+  if ( n == 1 )
+  {
+    Returnlist.append(CFFactor(mF,1));
+  }
+  else
+  {
+    if ( n == 2 )
+    {
+      intermediat= mvhensel(mF, factorlist.getFirst().factor(),
+                            Factorlist.getLast().factor(),
+                            Substitutionlist,alpha);
+      Returnlist.append(CFFactor(intermediat.One,1));
+      Returnlist.append(CFFactor(intermediat.Two,1));
+    }
+    else  // more then two factors
+    {
+#ifdef HENSELDEBUG2
+      CERR << "multihensel: more than two factors!" << "\n";
+#endif
+      Pl=factorlist.getFirst().factor(); factorlist.removeFirst();
+      Pr=Pl.genOne();
+      for ( ListIterator<CFFactor> i=factorlist; i.hasItem(); i++ )
+        Pr *=  i.getItem().factor() ;
+#ifdef HENSELDEBUG2
+      CERR << "multihensel: Pl,Pr, factorlist: " << Pl << "  " << Pr
+           << "  " << factorlist << "\n";
+#endif
+      intermediat= mvhensel(mF,Pl,Pr,Substitutionlist,alpha);
+      Returnlist.append(CFFactor(intermediat.One,1));
+      Returnlist=Union( multihensel(intermediat.Two,factorlist,Substitutionlist,alpha), 
+                        Returnlist);
+    }
+  }
+  return Returnlist;
+}
+
+///////////////////////////////////////////////////////////////
+// Generalized Hensel routine.                               //
+// mF is the monic multivariat polynomial, Factorlist is the //
+// list of factors, Substitutionlist represents the ideal    //
+// <x_1+a_1, .. , x_r+a_r>, where r=level(mF)-1 .            //
+// Returns the list of fully lifted factors.                 //
+///////////////////////////////////////////////////////////////
+CFFList
+MultiHensel( const CanonicalForm & mF, const CFFList & Factorlist,
+             const SFormList & Substitutionlist, const CanonicalForm &alpha)
+{
+  CFFList Ll;
+  CFFList Returnlist,Retlistinter,factorlist=Factorlist;
+  CFFListIterator i;
+  DiophantForm intermediat;
+  CanonicalForm Pl,Pr;
+  int n = factorlist.length(),h=n/2, k;
+
+  DEBOUT(CERR, "MultiHensel: called with ", mF);
+  DEBOUTLN(CERR, "  ", factorlist);
+  DEBOUT(CERR,"           : n,h = ", n);
+  DEBOUTLN(CERR,"  ", h);
+
+  if ( n == 1 )
+  {
+    Returnlist.append(CFFactor(mF,1));
+  }
+  else
+  {
+    if ( n == 2 )
+    {
+      intermediat= mvhensel(mF, factorlist.getFirst().factor(),
+                            Factorlist.getLast().factor(),
+                            Substitutionlist,alpha);
+      Returnlist.append(CFFactor(intermediat.One,1));
+      Returnlist.append(CFFactor(intermediat.Two,1));
+    }
+    else  // more then two factors
+    {
+      for ( k=1 ; k<=h; k++)
+      {
+        Ll.append(factorlist.getFirst());
+        factorlist.removeFirst();
+      }
+
+      DEBOUTLN(CERR, "MultiHensel: Ll= ", Ll);
+      DEBOUTLN(CERR, "     factorlist= ", factorlist);
+
+      Pl = 1; Pr = 1;
+      for ( i = Ll; i.hasItem(); i++)
+        Pl *= i.getItem().factor();
+      DEBOUTLN(CERR, "MultiHensel: Pl= ", Pl);
+      for ( i = factorlist; i.hasItem(); i++)
+        Pr *= i.getItem().factor();
+      DEBOUTLN(CERR, "MultiHensel: Pr= ", Pr);
+      intermediat = mvhensel(mF,Pl,Pr,Substitutionlist,alpha);
+      // divison test for intermediat.One and intermediat.Two ?
+      CanonicalForm a,b;
+      // we add a division test now for intermediat.One and intermediat.Two
+      if ( mydivremt (mF,intermediat.One,a,b) && b == mF.genZero() )
+        Retlistinter.append(CFFactor(intermediat.One,1) );
+      if ( mydivremt (mF,intermediat.Two,a,b) && b == mF.genZero() )
+        Retlistinter.append(CFFactor(intermediat.Two,1)  );
+
+      Ll = MultiHensel(intermediat.One, Ll, Substitutionlist,alpha);
+      Returnlist = MultiHensel(intermediat.Two, factorlist, Substitutionlist,alpha);
+      Returnlist = Union(Returnlist,Ll);
+
+      Returnlist = Union(Retlistinter,Returnlist);
+
+    }
+  }
+  return Returnlist;
+}
Index: libfac/factor/MVMultiHensel.h
===================================================================
--- libfac/factor/MVMultiHensel.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/MVMultiHensel.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,15 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+/////////////////////////////////////////////////////////////
+#ifndef MULTIHENSEL_H
+#define MULTIHENSEL_H
+// recursive version:
+CFFList multihensel( const CanonicalForm & mF, const CFFList & Factorlist,
+                     const SFormList & Substitutionlist,
+                     const CanonicalForm &alpha);
+// this is the real one (quasiparallel):
+CFFList MultiHensel( const CanonicalForm & mF, const CFFList & Factorlist,
+                     const SFormList & Substitutionlist,
+                     const CanonicalForm &alpha);
+
+#endif /* MULTIHENSEL_H */
Index: libfac/factor/SqrFree.cc
===================================================================
--- libfac/factor/SqrFree.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/SqrFree.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,433 @@
+///////////////////////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+static const char * errmsg = "\nYou found a bug!\nPlease inform singular@mathematik.uni-kl.de\n Please include above information and your input (the ideal/polynomial and characteristic) in your bug-report.\nThank you.";
+///////////////////////////////////////////////////////////////////////////////
+// FACTORY - Includes
+
+#include<factory/factory.h>
+
+#ifndef NOSTREAMIO
+#ifdef HAVE_IOSTREAM
+#include <iostream>
+#define OSTREAM std::ostream
+#define ISTREAM std::istream
+#define CERR std::cerr
+#define CIN std::cin
+#elif defined(HAVE_IOSTREAM_H)
+#include <iostream.h>
+#define OSTREAM ostream
+#define ISTREAM istream
+#define CERR cerr
+#define CIN cin
+#endif
+#endif
+// Factor - Includes
+#include "tmpl_inst.h"
+#include "helpstuff.h"
+// some CC's need this:
+#include "SqrFree.h"
+
+#ifdef SQRFREEDEBUG
+# define DEBUGOUTPUT
+#else
+# undef DEBUGOUTPUT
+#endif
+
+#include <libfac/factor/debug.h>
+#include "timing.h"
+
+TIMING_DEFINE_PRINT(squarefree_time)
+TIMING_DEFINE_PRINT(gcd_time)
+
+static inline CFFactor
+Powerup( const CFFactor & F , int exp=1)
+{
+  return CFFactor(F.factor(), exp*F.exp()) ;
+}
+
+static CFFList
+Powerup( const CFFList & Inputlist , int exp=1 )
+{
+  CFFList Outputlist;
+
+  for ( CFFListIterator i=Inputlist; i.hasItem(); i++ )
+    Outputlist.append(Powerup(i.getItem(), exp));
+  return Outputlist ;
+}
+
+///////////////////////////////////////////////////////////////
+// Compute the Pth root of a polynomial in characteristic p  //
+// f must be a polynomial which we can take the Pth root of. //
+// Domain is q=p^m , f a uni/multivariate polynomial         //
+///////////////////////////////////////////////////////////////
+static CanonicalForm
+PthRoot( const CanonicalForm & f )
+{
+  CanonicalForm RES, R = f;
+  int n= max(level(R),getNumVars(R)), p= getCharacteristic();
+
+  if (n==0)
+  { // constant
+    if (R.inExtension()) // not in prime field; f over |F(q=p^k)
+    {
+      R = power(R,Powerup(p,getGFDegree() - 1)) ;
+    }
+    // if f in prime field, do nothing
+    return R;
+  }
+  // we assume R is a Pth power here
+  RES = R.genZero();
+  Variable x(n);
+  for (int i=0; i<= (int) (degree(R,level(R))/p) ; i++)
+    RES += PthRoot( R[i*p] ) * power(x,i);
+  return RES;
+}
+
+///////////////////////////////////////////////////////////////
+// Compute the Pth root of a polynomial in characteristic p  //
+// f must be a polynomial which we can take the Pth root of. //
+// Domain is q=p^m , f a uni/multivariate polynomial         //
+///////////////////////////////////////////////////////////////
+static CanonicalForm
+PthRoot( const CanonicalForm & f ,const CanonicalForm & mipo)
+{
+  CanonicalForm RES, R = f;
+  int n= max(level(R),getNumVars(R)), p= getCharacteristic();
+  int mipodeg=-1;
+  if (f.level()==mipo.level()) mipodeg=mipo.degree();
+  else if ((f.level()==1) &&(!mipo.isZero()))
+  {
+    Variable t;
+    CanonicalForm tt=getMipo(mipo.mvar(),t);
+    mipodeg=degree(tt,t);
+  }
+
+  if ((n==0)
+  ||(mipodeg!=-1))
+  { // constant
+    if (R.inExtension()) // not in prime field; f over |F(q=p^k)
+    {
+      R = power(R,Powerup(p,getGFDegree() - 1)) ;
+    }
+    else if ((f.level()==mipo.level())
+    ||((f.level()==1) &&(!mipo.isZero())))
+    {
+      R = power(R,Powerup(p,mipodeg - 1)) ;
+      R=mod(R, mipo);
+    }
+    // if f in prime field, do nothing
+    return R;
+  }
+  // we assume R is a Pth power here
+  RES = R.genZero();
+  Variable x(n);
+  for (int i=0; i<= (int) (degree(R,level(R))/p) ; i++)
+    RES += PthRoot( R[i*p], mipo ) * power(x,i);
+  return RES;
+}
+
+///////////////////////////////////////////////////////////////
+// A uni/multivariate SqrFreeTest routine.                   //
+// Cheaper to run if all you want is a test.                 //
+// Works for charcteristic 0 and q=p^m                       //
+// Returns 1 if poly r is SqrFree, 0 if SqrFree will do some //
+// kind of factorization.                                    //
+// Would be much more effcient iff we had *good*             //
+//  uni/multivariate gcd's and/or gcdtest's                  //
+///////////////////////////////////////////////////////////////
+int
+SqrFreeTest( const CanonicalForm & r, int opt)
+{
+  CanonicalForm f=r, g;
+  int n=level(f);
+
+  if (getNumVars(f)==0) return 1 ; // a constant is SqrFree
+  if ( f.isUnivariate() )
+  {
+    g= f.deriv();
+    if ( getCharacteristic() > 0 && g.isZero() ) return 0 ;
+    // Next: it would be best to have a *univariate* gcd-test which returns
+    // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials )
+    g = gcd(f,g);
+    if ( g.isOne() || (-g).isOne() ) return 1;
+    else
+      if ( getNumVars(g) == 0 ) return 1;// <- totaldegree!!!
+      else return 0 ;
+  }
+  else
+  { // multivariate case
+    for ( int k=1; k<=n; k++ )
+    {
+      g = swapvar(f,k,n); g = content(g);
+      // g = 1 || -1 : sqr-free, g poly : not sqr-free, g number : opt helps
+      if ( ! (g.isOne() || (-g).isOne() || getNumVars(g)==0 ) ) {
+        if ( opt==0 ) return 0;
+        else {
+          if ( SqrFreeTest(g,1) == 0 ) return 0;
+          g = swapvar(g,k,n);
+          f /=g ;
+        }
+      }
+    }
+    // Now f is primitive
+    n = level(f); // maybe less indeterminants
+    //    if ( totaldegree(f) <= 1 ) return 1;
+
+    // Let`s look if it is a Pth root
+    if ( getCharacteristic() > 0 )
+      for (int k=1; k<=n; k++ )
+      {
+        g=swapvar(f,k,n); g=g.deriv();
+        if ( ! g.isZero() ) break ;
+        else if ( k==n) return 0 ; // really is Pth root
+      }
+    g = f.deriv() ;
+    // Next: it would be best to have a *multivariate* gcd-test which returns
+    // 0 iff gcdtest(f,g) == 1 or a constant ( for real Polynomials )
+    g= gcd(f,g);
+    if ( g.isOne() || (-g).isOne() || (g==f) || (getNumVars(g)==0) ) return 1 ;
+    else return 0 ;
+  }
+  factoryError("libfac: ERROR: SqrFreeTest: we should never fall trough here!");
+  return 0;
+}
+
+///////////////////////////////////////////////////////////////
+// A uni/multivariate SqrFree routine.Works for polynomials  //
+// which don\'t have a constant as the content.              //
+// Works for charcteristic 0 and q=p^m                       //
+// returns a list of polys each of sqrfree, but gcd(f_i,f_j) //
+// needs not to be 1 !!!!!                                   //
+///////////////////////////////////////////////////////////////
+static CFFList
+SqrFreed( const CanonicalForm & r , const CanonicalForm &mipo=0)
+{
+  CanonicalForm h, g, f = r;
+  CFFList Outputlist;
+  int n = level(f);
+
+  DEBINCLEVEL(CERR, "SqrFreed");
+  DEBOUTLN(CERR, "Called with r= ", r);
+  if (getNumVars(f)==0 )
+  { // just a constant; return it
+    Outputlist= CFFactor(f,1);
+    return Outputlist ;
+  }
+
+// We look if we do have a content; if so, SqrFreed the content
+// and continue computations with pp(f)
+  for (int k=1; k<=n; k++)
+  {
+    if ((mipo.isZero())/*||(k!=1)*/)
+    {
+      g = swapvar(f,k,n); g = content(g);
+      if ( ! (g.isOne() || (-g).isOne() || (degree(g)==0) ))
+      {
+        g = swapvar(g,k,n);
+        DEBOUTLN(CERR, "We have a content: ", g);
+        Outputlist = myUnion(SqrFreeMV(g,mipo),Outputlist); // should we add a
+                                                // SqrFreeTest(g) first ?
+        DEBOUTLN(CERR, "Outputlist is now: ", Outputlist);
+        f /=g;
+        DEBOUTLN(CERR, "f is now: ", f);
+      }
+    }
+  }
+
+// Now f is primitive; Let`s look if f is univariate
+  if ( f.isUnivariate() )
+  {
+    DEBOUTLN(CERR, "f is univariate: ", f);
+    g = content(f);
+    if ( ! (g.isOne() || (-g).isOne() ) )
+    {
+      Outputlist= myappend(Outputlist,CFFactor(g,1)) ;
+      f /= g;
+    }
+    Outputlist = Union(sqrFree(f),Outputlist) ;
+    DEBOUTLN(CERR, "Outputlist after univ. sqrFree(f) = ", Outputlist);
+    DEBDECLEVEL(CERR, "SqrFreed");
+    return Outputlist ;
+  }
+
+// Linear?
+  if ( totaldegree(f) <= 1 )
+  {
+    Outputlist= myappend(Outputlist,CFFactor(f,1)) ;
+    DEBDECLEVEL(CERR, "SqrFreed");
+    return Outputlist ;
+  }
+
+// is it Pth root?
+  n=level(f); // maybe less indeterminants
+  g= f.deriv();
+  if ( getCharacteristic() > 0 && g.isZero() )
+  {  // Pth roots only apply to char > 0
+    for (int k=1; k<=n; k++)
+    {
+      if ((mipo.isZero())/*||(k!=1)*/)
+      {
+        g=swapvar(f,k,n) ;
+        g = g.deriv();
+
+        if ( ! g.isZero() )
+        { // can`t be Pth root
+          CFFList Outputlist2= SqrFreed(swapvar(f,k,n));
+          for (CFFListIterator inter=Outputlist2; inter.hasItem(); inter++)
+          {
+            Outputlist= myappend(Outputlist, CFFactor(swapvar(inter.getItem().factor(),k,n), inter.getItem().exp()));
+          }
+          return Outputlist;
+        }
+      }
+    }
+    // really is Pth power
+    DEBOUTLN(CERR, "f is a p'th root: ", f);
+    CFMap m;
+    g = compress(f,m);
+    if (mipo.isZero())
+      f = m(PthRoot(g));
+    else
+      f = m(PthRoot(g,mipo));
+    DEBOUTLN(CERR, "  that is       : ", f);
+    // now : Outputlist union ( SqrFreed(f) )^getCharacteristic()
+    Outputlist=myUnion(Powerup(SqrFreeMV(f),getCharacteristic()),Outputlist);
+    DEBDECLEVEL(CERR, "SqrFreed");
+    return Outputlist ;
+  }
+  g = f.deriv();
+  DEBOUTLN(CERR, "calculating gcd of ", f);
+  DEBOUTLN(CERR, "               and ", g);
+  h = gcd(f,pp(g));  h /= lc(h);
+  DEBOUTLN(CERR,"gcd(f,g)= ",h);
+  if ( (h.isOne()) || ( h==f) || ((-h).isOne()) || getNumVars(h)==0 )
+  { // no common factor
+    Outputlist= myappend(Outputlist,CFFactor(f,1)) ;
+    DEBOUTLN(CERR, "Outputlist= ", Outputlist);
+    DEBDECLEVEL(CERR, "SqrFreed");
+    return Outputlist ;
+  }
+  else
+  { // we can split into two nontrivial pieces
+    f /= h; // Now we have split the poly into f and h
+    g = lc(f);
+    if ( !g.isOne() && getNumVars(g) == 0 )
+    {
+       Outputlist= myappend(Outputlist,CFFactor(g,1)) ;
+       f /= g;
+    }
+    DEBOUTLN(CERR, "Split into f= ", f);
+    DEBOUTLN(CERR, "       and h= ", h);
+    // For char > 0 the polys f and h can have Pth roots; so we need a test
+    // Test is disabled because timing is the same
+
+//    if ( SqrFreeTest(f,0) )
+//      Outputlist= myappend(Outputlist,CFFactor(f,1)) ;
+//    else
+    Outputlist=myUnion(Outputlist, SqrFreeMV(f));
+//    if ( SqrFreeTest(h,0) )
+//      Outputlist= myappend(Outputlist,CFFactor(h,1)) ;
+//    else
+    Outputlist=myUnion(Outputlist,SqrFreeMV(h));
+    DEBOUTLN(CERR, "Returning list ", Outputlist);
+    DEBDECLEVEL(CERR, "SqrFreed");
+    return Outputlist ;
+  }
+  factoryError("libfac: ERROR: SqrFreed: we should never fall trough here!");
+  DEBDECLEVEL(CERR, "SqrFreed");
+  return Outputlist; // for safety purpose
+}
+
+///////////////////////////////////////////////////////////////
+// The user front-end for the SqrFreed routine.              //
+// Input can have a constant as content                      //
+///////////////////////////////////////////////////////////////
+CFFList
+SqrFreeMV( const CanonicalForm & r , const CanonicalForm & mipo )
+{
+  CanonicalForm g=icontent(r), f = r;
+  CFFList Outputlist, Outputlist2,tmpOutputlist;
+
+  DEBINCLEVEL(CERR, "SqrFreeMV");
+  DEBOUTLN(CERR,"Called with f= ", f);
+
+  // Take care of stupid users giving us constants
+  if ( getNumVars(f) == 0 )
+  { // a constant ; Exp==1 even if f==0
+      Outputlist= myappend(Outputlist,CFFactor(f,1));
+  }
+  else
+  {
+      // Now we are sure: we have a nonconstant polynomial
+      g = lc(f);
+      while ( getNumVars(g) != 0 ) g=content(g);
+      if ( ! g.isOne() ) Outputlist= myappend(Outputlist,CFFactor(g,1)) ;
+      f /= g;
+      if ( getNumVars(f) != 0 ) // a real polynomial
+      {
+        if (!mipo.isZero())
+        {
+          #if 0
+          Variable alpha=rootOf(mipo);
+          CanonicalForm ff=replacevar(f,mipo.mvar(),alpha);
+          tmpOutputlist=SqrFreeMV(ff,0);
+          ff=replacevar(f,alpha,mipo.mvar());
+          for ( CFFListIterator i=tmpOutputlist; i.hasItem(); i++ )
+          {
+            ff=i.getItem().factor();
+            ff /= ff.Lc();
+            ff=replacevar(ff,alpha,mipo.mvar());
+            Outputlist=myappend(Outputlist,CFFactor(ff,1));
+          }
+          #else
+          Outputlist=myUnion(SqrFreed(f,mipo),Outputlist) ;
+          #endif
+        }
+        else
+          Outputlist=myUnion(SqrFreed(f),Outputlist) ;
+      }
+  }
+  DEBOUTLN(CERR,"Outputlist = ", Outputlist);
+  for ( CFFListIterator i=Outputlist; i.hasItem(); i++ )
+    if ( getNumVars(i.getItem().factor()) > 0 )
+      Outputlist2.append(i.getItem());
+
+  DEBOUTLN(CERR,"Outputlist2 = ", Outputlist2);
+  DEBDECLEVEL(CERR, "SqrFreeMV");
+  return Outputlist2 ;
+}
+
+CFFList SqrFree(const CanonicalForm & r )
+{
+  CFFList outputlist, sqrfreelist = SqrFreeMV(r);
+  CFFListIterator i;
+  CanonicalForm elem;
+  int n=totaldegree(r);
+
+  DEBINCLEVEL(CERR, "SqrFree");
+
+  if ( sqrfreelist.length() < 2 )
+  {
+    DEBDECLEVEL(CERR, "SqrFree");
+    return sqrfreelist;
+  }
+  for ( int j=1; j<=n; j++ )
+  {
+    elem =1;
+    for ( i = sqrfreelist; i.hasItem() ; i++ )
+    {
+      if ( i.getItem().exp() == j ) elem *= i.getItem().factor();
+    }
+    if ( !(elem.isOne()) ) outputlist.append(CFFactor(elem,j));
+  }
+  elem=1;
+  for ( i=outputlist; i.hasItem(); i++ )
+    if ( getNumVars(i.getItem().factor()) > 0 )
+      elem*= power(i.getItem().factor(),i.getItem().exp());
+  elem= r/elem;
+  outputlist.insert(CFFactor(elem,1));
+
+  DEBOUTLN(CERR, "SqrFree returns list:", outputlist);
+  DEBDECLEVEL(CERR, "SqrFree");
+  return outputlist;
+}
Index: libfac/factor/SqrFree.h
===================================================================
--- libfac/factor/SqrFree.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/SqrFree.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,13 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+///////////////////////////////////////////////////////////////////////////////
+#ifndef SQRFREE_H
+#define SQRFREE_H
+
+/*BEGINPUBLIC*/
+// CFFList SqrFree( const CanonicalForm & f ) ;
+CFFList SqrFreeMV( const CanonicalForm & f , const CanonicalForm & mipo=0) ;
+/*ENDPUBLIC*/
+int     SqrFreeTest( const CanonicalForm & r, int opt=1) ;
+CFFList SqrFree( const CanonicalForm & f ) ;
+#endif /* SQRFREE_H */
Index: libfac/factor/Truefactor.cc
===================================================================
--- libfac/factor/Truefactor.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/Truefactor.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,423 @@
+///////////////////////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+///////////////////////////////////////////////////////////////////////////////
+// Factory - Includes
+#include <factory.h>
+#ifndef NOSTREAMIO
+#ifdef HAVE_IOSTREAM
+#include <iostream>
+#define OSTREAM std::ostream
+#define ISTREAM std::istream
+#define CERR std::cerr
+#define CIN std::cin
+#elif defined(HAVE_IOSTREAM_H)
+#include <iostream.h>
+#define OSTREAM ostream
+#define ISTREAM istream
+#define CERR cerr
+#define CIN cin
+#endif
+#endif
+// Factor - Includes
+#include "tmpl_inst.h"
+#include "helpstuff.h"
+// some CC's need this:
+#include "Truefactor.h"
+
+#ifdef TRUEFACTORDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+
+#include <libfac/factor/debug.h>
+#include "timing.h"
+
+int hasAlgVar(const CanonicalForm &f, const Variable &v)
+{
+  if (f.inBaseDomain()) return 0;
+  if (f.inCoeffDomain())
+  {
+    if (f.mvar()==v) return 1;
+    return hasAlgVar(f.LC(),v);
+  }
+  if (f.inPolyDomain())
+  {
+    if (hasAlgVar(f.LC(),v)) return 1;
+    for( CFIterator i=f; i.hasTerms(); i++)
+    {
+      if (hasAlgVar(i.coeff(),v)) return 1;
+    }
+  }
+  return 0;
+}
+
+int hasVar(const CanonicalForm &f, const Variable &v)
+{
+  if (f.inBaseDomain()) return 0;
+  if (f.inCoeffDomain())
+  {
+    if (f.mvar()==v) return 1;
+    return hasAlgVar(f.LC(),v);
+  }
+  if (f.inPolyDomain())
+  {
+    if (f.mvar()==v) return 1;
+    if (hasVar(f.LC(),v)) return 1;
+    for( CFIterator i=f; i.hasTerms(); i++)
+    {
+      if (hasVar(i.coeff(),v)) return 1;
+    }
+  }
+  return 0;
+}
+
+int hasAlgVar(const CanonicalForm &f)
+{
+  if (f.inBaseDomain()) return 0;
+  if (f.inCoeffDomain())
+  {
+    if (f.level()!=0)
+    {
+      //CERR << "hasAlgVar:" << f.mvar() <<"\n";
+      return 1;
+    }
+    return hasAlgVar(f.LC());
+  }
+  if (f.inPolyDomain())
+  {
+    if (hasAlgVar(f.LC())) return 1;
+    for( CFIterator i=f; i.hasTerms(); i++)
+    {
+      if (hasAlgVar(i.coeff())) return 1;
+    }
+  }
+  return 0;
+}
+
+///////////////////////////////////////////////////////////////
+// generate all different k-subsets of the set with n        //
+// elements and return them in returnlist.                   //
+///////////////////////////////////////////////////////////////
+static void
+combinat( int k, int n, List<IntList> & returnlist ){
+  ListIntList ListofLists;
+  IntList intermediate,intermediate2;
+  int value,j;
+
+  if ( k == 1 ){                     // k=1
+    for ( j=1; j<=n; j++)
+      returnlist.append( IntList(j) );
+  }
+  else{                              // k-1 --> k
+    combinat(k-1,n,returnlist);  // generate (k-1,n)
+    for ( ListIntListIterator l=returnlist; l.hasItem(); l++ ){
+      intermediate = l.getItem();
+      value = intermediate.getLast();
+      if ( value != n )
+        for ( j=value+1; j<=n; j++ ){
+          intermediate2 = intermediate; intermediate2.append(j);
+          ListofLists.append( intermediate2 );
+        }
+    }
+    returnlist = ListofLists;
+  }
+}
+
+///////////////////////////////////////////////////////////////
+// Return the CanonicalForm number nr in  Factorlist.        //
+///////////////////////////////////////////////////////////////
+static CanonicalForm
+getItemNr(int nr, const CFFList & Factorlist ){
+  ListIterator<CFFactor> i=Factorlist;
+  int Nr=nr;
+
+  for ( Nr=1; Nr<nr; Nr++ ) i++;
+  return i.getItem().factor();
+}
+
+///////////////////////////////////////////////////////////////
+// Generate all sets of m factors out of LiftedFactors list. //
+///////////////////////////////////////////////////////////////
+static CFFList
+combine( int m, const CFFList & LiftedFactors ){
+  CFFList result;
+  ListIntList CombinatList;
+  CanonicalForm intermediate;
+
+  combinat(m, LiftedFactors.length(), CombinatList);
+  for ( ListIntListIterator j=CombinatList ; j.hasItem(); j++ ){
+    intermediate=1;
+    for ( IntListIterator k=j.getItem(); k.hasItem(); k++ )
+      intermediate *= getItemNr(k.getItem(), LiftedFactors);
+    if (!hasAlgVar(intermediate))
+    result.append(CFFactor(intermediate,1));
+  }
+  return result;
+}
+
+///////////////////////////////////////////////////////////////
+// Remove element elem from the list L.                      //
+///////////////////////////////////////////////////////////////
+static CFFList
+Remove_from_List( const CFFList & L, const CanonicalForm & elem ){
+  CFFList Returnlist;
+
+  DEBOUTLN(CERR, "Remove_from_List called with L= ",L);
+  DEBOUTLN(CERR, "                     and  elem= ",elem);
+  for ( ListIterator<CFFactor> i = L ; i.hasItem(); i++)
+    if ( i.getItem().factor() != elem )
+      Returnlist.append( i.getItem() );
+
+  return Returnlist;
+}
+
+///////////////////////////////////////////////////////////////
+// Here we solve:          G= F mod ( P, S^h )               //
+///////////////////////////////////////////////////////////////
+static CanonicalForm
+Multmod_power( const CanonicalForm & F, const SFormList & Substituionlist, int h, int levelF){
+  CanonicalForm G;
+
+  G= change_poly(F, Substituionlist, 0);
+  G= mod_power(G, h, levelF);
+  G= change_poly(G, Substituionlist, 1);
+
+  return G;
+}
+
+///////////////////////////////////////////////////////////////
+// Determine the right degree for the list of combinations   //
+// of factors, i.e. delete any element from list CombL which //
+// degree in the main variable levelU exceeeds degU.         //
+///////////////////////////////////////////////////////////////
+static CFFList
+Rightdegree( const CFFList & CombL, int degU, int levelU ){
+  CFFList Returnlist;
+  CFFactor factor;
+
+  for ( ListIterator<CFFactor> i= CombL; i.hasItem(); i++ ){
+    factor= i.getItem();
+    if ( degree(factor.factor(), levelU) <= degU )
+      Returnlist.append(factor);
+  }
+
+  return Returnlist;
+}
+
+///////////////////////////////////////////////////////////////
+// We have properly lifted all the specialized factors. See  //
+// which one works.                                          //
+// We use the (modified) algorithm TRUEFACTORS given by      //
+// Paul S. Wang and Linda Preiss Rothschild:                 //
+// Factoring Multivariate Polynomials Over the Integers      //
+// Math. Comp. V29 Nr131 (July 1975) p. 935-950              //
+///////////////////////////////////////////////////////////////
+CFFList
+Truefactors( const CanonicalForm Ua, int levelU, const SFormList & SubstitutionList, const CFFList & PiList){
+  CanonicalForm U=Ua,a,b,Y;
+  CFFactor factor;
+  CFFList L,FAC,E_all;
+  int c,r = PiList.length(),degU, onemore,M, h = subvardegree(Ua,levelU) + 1;
+  ListIterator<CFFactor> i;
+
+  //CERR << "SubstitutionList="<< SubstitutionList<<"\n";
+// step 1: simply test the generated factors alone
+  for ( i= PiList; i.hasItem();i++){
+    factor = i.getItem();
+    //CanonicalForm test_f=change_poly(factor.factor(),SubstitutionList,0);
+    CanonicalForm test_f=factor.factor();
+    //CERR <<"f:" << factor.factor() << " -> test_f:"<<test_f <<"\n";
+    //CERR << "           1:" << change_poly(factor.factor(),SubstitutionList,1) <<"\n";
+    c= mydivremt(U,test_f,a,b);
+    if (  c  && b == U.genZero() && !hasAlgVar(test_f))
+    // factor.getFactor() divides U
+    {
+      //CERR << " teilt:" << test_f <<"\n";
+      U= a;
+      FAC.append(factor);
+    }
+    else{
+      //CERR << " teilt nicht:" << test_f <<"\n";
+      L.append(factor);
+    }
+  }
+  DEBOUTLN(CERR,"Truefactors: (step1) L  = ", L);
+  DEBOUTLN(CERR,"                     FAC= ", FAC);
+
+// step 2: Do we have to check combinations?
+  degU = L.length();
+  if ( degU == 0 ) // No elements: Return
+    return FAC;
+  else
+    if ( degU < 4 ){ // Less then four elements: no combinations possible
+      FAC.append( CFFactor(U,1) );
+      return FAC;
+    }
+    else {
+      M = 1; r = r - FAC.length(); degU = degree(U, levelU)/2;
+    }
+
+  DEBOUTLN(CERR,"Truefactors: (step2) M   = ", M);
+  DEBOUTLN(CERR,"                     r   = ", r);
+  DEBOUTLN(CERR,"                     degU= ", degU);
+
+// Now do the real work!
+// Test all the combinations of possible factors.
+
+  onemore=1;
+// steps 3 to 6
+  while (1)
+  {
+    // step 3 iff onemore == 1
+    if ( onemore ) M+= 1;  else onemore = 1;
+    // step 4
+    if ( U.isOne() ) break; // Return FAC
+    if ( ( r == 1 ) || ( M >= ( r-1 ) ) || ( M > degU ) )
+    {
+      FAC.append( CFFactor(U,1) );
+      break; // Return FAC union {U}
+    }
+    // step 5
+    E_all = combine(M, L); // generate all combinations of M elements from L
+    DEBOUTLN(CERR,"Truefactors: (step5) E_all= ", E_all);
+    // select combinations with the degree not to exceed degU:
+    E_all = Rightdegree( E_all, degU, levelU );
+    DEBOUTLN(CERR,"Truefactors: (step5) E_all(Rightdegree)= ", E_all);
+    if ( E_all.length() == 0 )
+    {
+      FAC.append( CFFactor(U,1) );
+      break; // Return FAC union {U}
+    }
+    for ( i=E_all; i.hasItem(); i++)
+    {
+      factor = i.getItem();
+      Y = Multmod_power( factor.factor(), SubstitutionList, h, levelU);
+      DEBOUTLN(CERR, "Truefactors: (step6) Testing Y  = ", Y);
+      c = mydivremt(U,Y,a,b);
+      //      if (  c  && b == U.genZero()) { // Y divides U
+      if ( c && b.isZero() )
+      {
+        DEBOUT(CERR,"Truefactors: (step6): ",Y );
+        DEBOUTLN(CERR, "  divides  ",U);
+        U = a;
+        FAC.append(Y); // Y is a real factor
+        onemore = 0;
+        degU = degree(U, levelU)/2; // new degU
+        // L = L \ {factor}
+        // Hier ist noch etwas faul; wir muessen (f=prod(f_i)) die f_i
+        // entfernen und nicht f!
+        L = Remove_from_List( L, factor.factor() );
+        r -= 1;
+        // delete from L any element with degree greater than degU
+        L = Rightdegree( L, degU, levelU );
+      }
+    }
+  }
+  return FAC;
+}
+
+///////////////////////////////////////////////////////////////
+// Check if poly f is in Fp (returns true) or in Fp(a)       //
+///////////////////////////////////////////////////////////////
+static bool is_in_Fp( const CanonicalForm & f )
+{
+  if ( f.inCoeffDomain() )
+    return f.inBaseDomain() ;
+  else
+  {
+    CFIterator i=f;
+    bool ok=true;
+    while ( ok && i.hasTerms() )
+    {
+      ok = is_in_Fp( i.coeff() );
+      i++ ;
+    }
+    return ok;
+  }
+}
+
+///////////////////////////////////////////////////////////////
+// We have factors which possibly lie in an extension of the //
+// base field. If one of these is not over the base field,   //
+// find its norm by (the theoretically handicapped method    //
+// of) multiplying by other elements.                        //
+///////////////////////////////////////////////////////////////
+CFFList TakeNorms(const CFFList & PiList)
+{
+  CFFList CopyPossibleFactors, PossibleFactors, TrueFactors;
+  CFFListIterator i;
+  CFFactor Factor;
+  CanonicalForm intermediate;
+  ListIntList CombinatList;
+  ListIntListIterator j;
+  IntListIterator k;
+
+  // First check if the factors in PiList already lie in Fp-Domain
+  for ( i=PiList; i.hasItem(); i++ )
+  {
+    Factor = i.getItem();
+    if ( is_in_Fp( Factor.factor() ) )
+      TrueFactors.append(Factor);
+    else
+      PossibleFactors.append(Factor);
+  }
+  // Now we have to check if combinations of the remaining factors
+  // (now in PossibleFactors) do lie in Fp-Domain
+  if ( PossibleFactors.length() > 0 ) // there are (at least two) items
+  {
+    int n=2;
+    if ( PossibleFactors.length() < n )  // a little check
+    {
+      factoryError("libfac: ERROR: TakeNorms less then two items remaining!");
+    }
+    while ( n < PossibleFactors.length() )
+    {
+      // generate all combinations of n elements
+      combinat(n, PossibleFactors.length(), CombinatList);
+      for ( j=CombinatList ; j.hasItem(); j++ )
+      {
+        intermediate=1;
+        for ( k=j.getItem(); k.hasItem(); k++ )
+          intermediate *= getItemNr( k.getItem(), PossibleFactors );
+        if ( is_in_Fp( intermediate ) )
+        {
+          TrueFactors.append(intermediate); // found a true factor
+          CopyPossibleFactors=PossibleFactors; // save list
+          for ( k=j.getItem(); k.hasItem(); k++ )
+            //remove combined factors from PossibleFactors
+            PossibleFactors=Remove_from_List(PossibleFactors,
+                                getItemNr( k.getItem(), CopyPossibleFactors ));
+          n-=1; // look for the same number of combined factors:
+          break;
+        }
+        else
+        {
+          //CERR << "Schade!" << "\n";
+        }
+        DEBOUT(CERR, "Truefactor: Combined ", n);
+        DEBOUTLN(CERR, " factors to: ", intermediate);
+      }
+      n += 1;
+    }
+  // All remaining factors in PossibleFactors multiplied
+  // should lie in Fp domain
+    if ( PossibleFactors.length() >=1 )
+    {
+      for ( i=PossibleFactors; i.hasItem(); i++ )
+        intermediate *= i.getItem().factor();
+      // a last check:
+      if ( is_in_Fp(intermediate) )
+      {
+        TrueFactors.append(CFFactor(intermediate,1));
+      }
+      else
+      {
+        factoryError("libfac: TakeNorms: somethings wrong with remaining factors!");
+      }
+    }
+  }
+  return TrueFactors;
+}
+
+////////////////////////////////////////////////////////////
Index: libfac/factor/Truefactor.h
===================================================================
--- libfac/factor/Truefactor.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/Truefactor.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,10 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+///////////////////////////////////////////////////////////////////////////////
+#ifndef TRUEFACTOR_H
+#define TRUEFACTOR_H
+
+CFFList Truefactors( const CanonicalForm Ua, int levelU, const SFormList & SubstitutionList, const CFFList & PiList);
+CFFList TakeNorms(const CFFList & PiList);
+#endif /* TRUEFACTOR_H */
+
Index: libfac/factor/class.cc
===================================================================
--- libfac/factor/class.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/class.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,40 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+
+// #pragma implementation
+
+#include "class.h"
+
+template <class T>
+Substitution<T>& Substitution<T>::operator= ( const Substitution<T>& f )
+{
+    if ( this != &f ) {
+	_factor = f._factor;
+	_exp = f._exp;
+    }
+    return *this;
+}
+
+template <class T>
+Substitution<T>& Substitution<T>::operator= ( const T & f )
+{
+    _factor = f;
+    _exp = 1;
+    return *this;
+}
+
+template <class T>
+int operator== ( const Substitution<T> &f1, const Substitution<T> &f2 )
+{
+    return (f1.exp() == f2.exp()) && (f1.factor() == f2.factor());
+}
+
+#ifndef NOSTREAMIO
+template <class T>
+void Substitution<T>::print ( OSTREAM& s ) const
+{
+	s << "(" << factor() << ")^" << exp();
+}
+#endif
+
Index: libfac/factor/class.h
===================================================================
--- libfac/factor/class.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/class.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,57 @@
+///////////////////////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+///////////////////////////////////////////////////////////////////////////////
+#ifndef INCL_CLASS_H
+#define INCL_CLASS_H
+
+// #pragma interface
+
+#ifndef NOSTREAMIO
+#ifdef HAVE_IOSTREAM
+#include <iostream>
+#define OSTREAM std::ostream
+#define ISTREAM std::istream
+#elif defined(HAVE_IOSTREAM_H)
+#include <iostream.h>
+#define OSTREAM ostream
+#define ISTREAM istream
+#endif
+#endif
+
+template <class T>
+class Substitution {
+private:
+    T _factor;
+    T _exp;
+public:
+    Substitution() : _factor(1), _exp(0) {}
+    Substitution( const Substitution<T> & f ) : _factor(f._factor), _exp(f._exp) {}
+    Substitution( const T & f, const T & e ) : _factor(f), _exp(e) {}
+    Substitution( const T & f ) : _factor(f), _exp(1) {}
+    ~Substitution() {}
+    Substitution<T>& operator= ( const Substitution<T>& );
+    Substitution<T>& operator= ( const T& );
+    T factor() const { return _factor; }
+    T exp() const { return _exp; }
+//     T value() const { return power( _factor, _exp ); }
+//     Factor<T>& operator+= ( int i ) { _exp += i; return *this; }
+//     Factor<T>& operator*= ( int i ) { _exp *= i; return *this; }
+//     Substitution<T>& operator*= ( const T & f ) { _factor *= f; _exp *= f; return *this; }
+#ifndef NOSTREAMIO
+    void print ( OSTREAM& ) const;
+    friend OSTREAM& operator<< ( OSTREAM & os, const Substitution<T> & f )
+    {
+	f.print( os );
+	return os;
+    }
+#endif
+};
+template <class T>
+int operator== ( const Substitution<T>&, const Substitution<T>& );
+
+// #ifdef IMPL_CLASS_H
+// #include "class.cc"
+// #endif
+
+#endif /* INCL_CLASS_H */
+
Index: libfac/factor/debug.h
===================================================================
--- libfac/factor/debug.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/debug.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,61 @@
+////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////
+// It is possible to include this file multiple times for different 
+// settings of FACDEBUG and/or DEBUGOUTPUT
+
+#undef ASSERT
+#undef __ASSERT
+#undef STICKYASSERT
+#undef DEBOUT
+#undef DEBOUTLN
+#undef DEBINCLEVEL
+#undef DEBDECLEVEL
+#undef DEBOUTSL
+#undef DEBOUTMSG
+#undef DEBOUTNL
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef NDEBUG
+#define ASSERT(ignore1,ignore2)((void)0)
+#else
+#define ASSERT(expression,message) \
+((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__)))
+#endif
+
+#define STICKYASSERT(expression,message) \
+((void)((expression) ? 0 : __ASSERT(#expression, message, __FILE__, __LINE__)))
+
+#define __ASSERT(expression, message, file, line)  \
+(fprintf( stderr, "error: %s\n%s:%u: failed assertion `%s'\n", \
+ message, file, line, expression ), abort(), 0 )
+
+#ifdef DEBUGOUTPUT
+void deb_inc_level(); // use this helper routines from factory
+void deb_dec_level(); // use this helper routines from factory
+extern char * deb_level_msg; // from factory
+#define DEBINCLEVEL(stream,msg) \
+(stream << "\n" << deb_level_msg << "entering << " << msg << " >>" << "\n", deb_inc_level())
+#define DEBDECLEVEL(stream,msg) \
+(deb_dec_level(), stream << deb_level_msg << "leaving << " << msg << " >>" << "\n")
+#define DEBOUTSL(stream) \
+(stream << deb_level_msg, stream.flush())
+#define DEBOUT(stream,msg,object) \
+(stream << deb_level_msg << msg << object, stream.flush())
+#define DEBOUTLN(stream,msg,object) \
+(stream << deb_level_msg << msg << object << "\n")
+#define DEBOUTMSG(stream,msg) \
+(stream << deb_level_msg << msg << "\n")
+#define DEBOUTNL(stream) \
+(stream << "\n")
+#else
+#define DEBINCLEVEL(stream,msg)
+#define DEBDECLEVEL(stream,msg)
+#define DEBOUTSL(stream)
+#define DEBOUT(stream,msg,object)
+#define DEBOUTLN(stream,msg,object)
+#define DEBOUTMSG(stream,msg)
+#define DEBOUTNL(stream)
+#endif
+
Index: libfac/factor/helpstuff.cc
===================================================================
--- libfac/factor/helpstuff.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/helpstuff.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,173 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+// FACTORY - Includes
+#include <factory.h>
+// Factor - Includes
+#include "tmpl_inst.h"
+// some CC's need this:
+#include "helpstuff.h"
+
+bool
+mydivremt ( const CanonicalForm& f, const CanonicalForm& g, CanonicalForm& a, CanonicalForm& b )
+{
+  bool retvalue;
+  CanonicalForm aa,bb;
+  retvalue = divremt(f,g,a,bb);
+  aa= f-g*a;
+  if ( aa==bb ) { b=bb; }
+  else { b=aa; }
+  return retvalue;
+}
+
+// Now some procedures used in SqrFree and in Factor
+///////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////
+// We have to include a version of <CFFList>.append(CFFactor)//
+// and Union( CFFList, CFFList)                              //
+// because we have to look for multiplicities in SqrFree.    //
+// e.g.: SqrFree( f^3 ) with char <> 3                       //
+///////////////////////////////////////////////////////////////
+CFFList
+myappend( const CFFList & Inputlist, const CFFactor & TheFactor)
+{
+  CFFList Outputlist ;
+  CFFactor copy;
+  CFFListIterator i;
+  int exp=0;
+
+  for ( i=Inputlist ; i.hasItem() ; i++ )
+  {
+    copy = i.getItem();
+    if ( copy.factor() == TheFactor.factor() )
+      exp += copy.exp();
+    else
+      Outputlist.append(copy);
+  }
+  Outputlist.append( CFFactor(TheFactor.factor(), exp + TheFactor.exp()));
+  return Outputlist;
+}
+
+CFFList
+myUnion(const CFFList & Inputlist1,const CFFList & Inputlist2)
+{
+  CFFList Outputlist;
+  CFFListIterator i;
+
+  for ( i=Inputlist1 ; i.hasItem() ; i++ )
+    Outputlist = myappend(Outputlist, i.getItem() );
+  for ( i=Inputlist2 ; i.hasItem() ; i++ )
+    Outputlist = myappend(Outputlist, i.getItem() );
+
+  return Outputlist;
+}
+
+int
+Powerup( const int base , const int exp)
+{
+  int retvalue=1;
+  if ( exp == 0 )  return retvalue ;
+  else for ( int i=1 ; i <= exp; i++ ) retvalue *= base ;
+
+  return retvalue;
+}
+
+// Now some procedures used in MVMultiHensel and in Truefactors
+///////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////
+// mod_power: Return f mod I^k, where I is now the ideal     //
+// {x_1, .. x_(level(f)-1)}. Computation mod I^k is simply   //
+// done by dropping all the terms of degree >= k in          //
+// x_1, .. x_(level(f)-1); e.g. x_1*x_2 == 0 mod I^2 .       //
+// modpower: the real work is done here; called by mod_power //
+///////////////////////////////////////////////////////////////
+static void
+modpower( const CanonicalForm & f, int k , int td,
+          const CanonicalForm & t, CanonicalForm & result)
+{
+
+  if ( td >= k ) return;
+  if ( getNumVars(f) == 0 ) result += f*t;
+  else{
+    Variable x(level(f));
+    for ( CFIterator i=f; i.hasTerms(); i++)
+      modpower(i.coeff(),k,td+i.exp(),t*power(x,i.exp()),result);
+  }
+}
+
+CanonicalForm
+mod_power( const CanonicalForm & f, int k, int levelU)
+{
+  CanonicalForm result,dummy;
+  Variable x(levelU);
+
+  if ( levelU > level(f) )
+    modpower(f,k,0,1,result);
+  else
+  {
+    for ( CFIterator i=f; i.hasTerms(); i++)
+    {
+      dummy = 0;
+      modpower(i.coeff(),k,0,1,dummy);
+      result += dummy * power(x,i.exp());
+// the following works, but is slower
+//    int degf=degree(f);
+//    for ( int i=0; i<=degf;i++){
+//      result+= mod_power(f[i],k,levelU)*power(x,i);
+    }
+  }
+
+  return result;
+}
+
+///////////////////////////////////////////////////////////////
+// Return the deg of F in the Variables x_1,..,x_(levelF-1)  //
+///////////////////////////////////////////////////////////////
+int
+subvardegree( const CanonicalForm & F, int levelF )
+{
+  int n=0,m=degree(F,levelF),newn=0;
+
+  for ( int k=0; k<=m; k++ )
+  {
+    newn = totaldegree( F[k] );
+    if ( newn > n ) n=newn;
+  }
+  return n;
+}
+
+///////////////////////////////////////////////////////////////
+// Change poly:  x_i <- x_i +- a_i    for i= 1,..,level(f)-1 //
+///////////////////////////////////////////////////////////////
+CanonicalForm
+change_poly( const CanonicalForm & f , const SFormList & Substitutionlist ,int directionback )
+{
+  CanonicalForm F=f,g,k;
+  int level_i;
+//  Variable x;
+
+  for ( SFormListIterator i=Substitutionlist; i.hasItem(); i++)
+  {
+  // now we can access: i.getItem().factor()  -> level(~) gives x_i
+  //                    i.getItem().exp()     -> gives a_i
+  // ==> g = x_i ; k = a_i
+    level_i=level(i.getItem().factor());
+    g = power(
+                       Variable(level_i),1
+                       );
+    k= i.getItem().exp();
+    if ( directionback )
+    {
+      if ( degree(F, level_i) != 0 )
+        F=F(g-k, level_i /*level(i.getItem().factor())*/); // x_i <-- x_i - a_i
+    }
+    else
+    {
+      if ( degree(F, level_i) != 0 )
+        F=F(g+k, level_i /*level(i.getItem().factor())*/); // x_i <-- x_i +a_i
+    }
+  }
+
+  return F;
+}
Index: libfac/factor/helpstuff.h
===================================================================
--- libfac/factor/helpstuff.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/helpstuff.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,28 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+#ifndef HELPSTUFF_H
+#define HELPSTUFF_H
+bool mydivremt ( const CanonicalForm&, const CanonicalForm&, CanonicalForm&, CanonicalForm& );
+///////////////////////////////////////////////////////////////
+// Now some procedures used in MVMultiHensel and in Truefactors
+///////////////////////////////////////////////////////////////
+CanonicalForm mod_power( const CanonicalForm & f, int k, int levelU);
+int subvardegree( const CanonicalForm & F, int levelF );
+CanonicalForm change_poly( const CanonicalForm & f , const SFormList & Substitutionlist, int directionback );
+
+///////////////////////////////////////////////////////////////
+// Now some procedures used in SqrFree and in Factor
+///////////////////////////////////////////////////////////////
+CFFList myappend( const CFFList & Inputlist, const CFFactor & TheFactor) ;
+CFFList myUnion(const CFFList & Inputlist1,const CFFList & Inputlist2);
+int Powerup( const int base , const int exp=1);
+inline int min ( const int a, const int b ){
+  return (a<=b ? a:b);
+}
+inline int max ( const int a, const int b ){
+  return (a>b ? a:b);
+}
+
+#endif /* HELPSTUFF_H */
+
Index: libfac/factor/homogfactor.cc
===================================================================
--- libfac/factor/homogfactor.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/homogfactor.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,199 @@
+////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////
+// FACTORY - Includes
+#include <factory.h>
+#ifdef HAVE_IOSTREAM
+#include <iostream>
+#define OSTREAM std::ostream
+#define ISTREAM std::istream
+#define CERR std::cerr
+#define CIN std::cin
+#elif defined(HAVE_IOSTREAM_H)
+#include <iostream.h>
+#define OSTREAM ostream
+#define ISTREAM istream
+#define CERR cerr
+#define CIN cin
+#endif
+
+// Factor - Includes
+#include "tmpl_inst.h"
+#include "Factor.h"
+// some CC's need it:
+#include "homogfactor.h"
+
+void out_cf(char *s1,const CanonicalForm &f,char *s2);
+
+#ifdef HFACTORDEBUG
+#  define DEBUGOUTPUT
+#else
+#  undef DEBUGOUTPUT
+#endif
+
+#include <libfac/factor/debug.h>
+#include "timing.h"
+TIMING_DEFINE_PRINT(hfactorize_time)
+
+#if 0
+///////////////////////////////////////////////////////////////
+// get_Terms: Split the polynomial in the containing terms.  //
+// getTerms: the real work is done here.                     // 
+///////////////////////////////////////////////////////////////
+static void 
+getTerms( const CanonicalForm & f, const CanonicalForm & t, CFList & result ){
+
+  if ( getNumVars(f) == 0 ) result.append(f*t);
+  else{ 
+    Variable x(level(f));
+    for ( CFIterator i=f; i.hasTerms(); i++ )
+      getTerms( i.coeff(), t*power(x,i.exp()), result);
+  }
+}
+
+CFList 
+get_Terms( const CanonicalForm & f ){
+  CFList result,dummy,dummy2;
+  CFIterator i;
+  CFListIterator j;
+
+  if ( getNumVars(f) == 0 ) result.append(f);
+  else{
+    Variable _x(level(f));
+    for ( i=f; i.hasTerms(); i++ ){
+      getTerms(i.coeff(), 1, dummy);
+      for ( j=dummy; j.hasItem(); j++ )
+	result.append(j.getItem() * power(_x, i.exp()));
+
+      dummy= dummy2; // have to initalize new
+    }
+  }
+  return result;
+}
+#endif
+
+#if 0
+///////////////////////////////////////////////////////////////
+// is_homogeneous returns 1 iff f is homogeneous, 0 otherwise//
+///////////////////////////////////////////////////////////////
+bool
+is_homogeneous( const CanonicalForm & f){
+  CFList termlist= get_Terms(f);
+  CFListIterator i;
+  int deg= totaldegree(termlist.getFirst());
+
+  for ( i=termlist; i.hasItem(); i++ )
+    if ( totaldegree(i.getItem()) != deg ) return 0;
+  return 1;
+  // now: return f.isHomogeneous();
+}
+#endif
+
+#if 0
+///////////////////////////////////////////////////////////////
+// get_max_degree_Variable returns Variable with             //
+// highest degree. We assume f is *not* a constant!          //
+///////////////////////////////////////////////////////////////
+static Variable
+get_max_degree_Variable(const CanonicalForm & f){
+  ASSERT( ( ! f.inCoeffDomain() ), "no constants" );
+  int max=0, maxlevel=0, n=level(f);
+  for ( int i=1; i<=n; i++ )
+    if (degree(f,Variable(i)) >= max) {
+      max= degree(f,Variable(i)); maxlevel= i;
+    }
+  return Variable(maxlevel);
+}
+#endif
+
+#if 0
+///////////////////////////////////////////////////////////////
+// homogenize homogenizes f with Variable x                  //
+///////////////////////////////////////////////////////////////
+static CanonicalForm
+homogenize( const CanonicalForm & f, const Variable & x){
+  CFList Newlist, Termlist= get_Terms(f); 
+  int maxdeg=totaldegree(f), deg;
+  CFListIterator i;
+  CanonicalForm elem, result=f.genZero();
+  
+  for (i=Termlist; i.hasItem(); i++){
+    elem= i.getItem();
+    deg = totaldegree(elem);
+    if ( deg < maxdeg )
+      Newlist.append(elem * power(x,maxdeg-deg));
+    else
+      Newlist.append(elem);
+  }
+  for (i=Newlist; i.hasItem(); i++) // rebuild 
+    result += i.getItem();
+    
+  return result;
+}
+#endif
+
+// we assume g is square-free
+CFFList
+HomogFactor( const CanonicalForm & g, const CanonicalForm  & minpoly, const int Mainvar )
+{
+  DEBINCLEVEL(CERR, "HomogFactor");
+  Variable xn = get_max_degree_Variable(g);
+  //out_cf("HomogFactor:",g,"\n");
+  int d_xn = degree(g,xn);
+  CanonicalForm F = g(1,xn);
+
+  DEBOUTLN(CERR, "xn= ", xn);
+  DEBOUTLN(CERR, "d_xn=   ", d_xn);
+  DEBOUTLN(CERR, "F= ", F);  
+  //out_cf("HomogFactor:subst ",F,"\n");
+
+  // should we do this for low degree polys g ? e.g. quadratic?
+  // 
+  CFFList Homoglist;
+  CFFListIterator j;
+  if (minpoly.isZero())
+    Homoglist = factorize(F, 1);
+  else
+  {
+    CFFList Intermediatelist;
+    CFMap n;
+    Intermediatelist = Factorized(compress(F,n), minpoly, Mainvar);
+    for ( j=Intermediatelist; j.hasItem(); j++ )
+      Homoglist.append(CFFactor( n(j.getItem().factor()), j.getItem().exp()) );
+  }
+  // Now we have uncompressed factors in Homoglist
+  DEBOUTLN(CERR, "F factors as: ", Homoglist);
+  CFFList Unhomoglist;
+  CanonicalForm unhomogelem;
+  if ((!(minpoly.isZero())) &&(getCharacteristic() == 0) )
+  {
+    for ( j=Homoglist; j.hasItem(); j++ )
+    {
+      // assume that minpoly.level() < level of all "real" variables of g
+      DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor()); 
+      unhomogelem= homogenize(j.getItem().factor(),xn,
+                         Variable(minpoly.level()+1),g.mvar());
+      DEBOUTLN(CERR, "      that is ", unhomogelem);
+      Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp()));
+      d_xn -= degree(unhomogelem,xn)*j.getItem().exp();
+    }
+  }
+  else
+  {
+    for ( j=Homoglist; j.hasItem(); j++ )
+    {
+      DEBOUTLN(CERR, "Homogenizing ",j.getItem().factor()); 
+      unhomogelem= homogenize(j.getItem().factor(),xn);
+      DEBOUTLN(CERR, "      that is ", unhomogelem);
+      //out_cf("unhomogelem:",unhomogelem,"\n");
+      Unhomoglist.append(CFFactor(unhomogelem,j.getItem().exp()));
+      d_xn -= degree(unhomogelem,xn)*j.getItem().exp();
+    }
+  }
+  DEBOUTLN(CERR, "Power of xn to append is ", d_xn);
+  if ( d_xn != 0 ) // have to append xn^(d_xn)
+    Unhomoglist.append(CFFactor(CanonicalForm(xn),d_xn));
+
+  DEBDECLEVEL(CERR, "HomogFactor");
+  return Unhomoglist;
+}
+
Index: libfac/factor/homogfactor.h
===================================================================
--- libfac/factor/homogfactor.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/homogfactor.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,8 @@
+///////////////////////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+///////////////////////////////////////////////////////////////////////////////
+#ifndef HFACTOR_H
+#define HFACTOR_H
+CFList  get_Terms( const CanonicalForm & f );
+CFFList HomogFactor( const CanonicalForm & g, const CanonicalForm  & minpoly, const int Mainvar );
+#endif /* HFACTOR_H */
Index: libfac/factor/interrupt.h
===================================================================
--- libfac/factor/interrupt.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/interrupt.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,22 @@
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef INTERRUPT_H
+#define INTERRUPT_H
+// FACTORY - Includes
+#include <factory.h>
+// Factor - Includes
+#include "tmpl_inst.h"
+
+/*BEGINPUBLIC*/
+// Set this to a nonzero value to interrupt the computation
+extern int libfac_interruptflag;
+/*ENDPUBLIC*/
+
+inline int
+interrupt_handle( )
+{
+  if ( libfac_interruptflag ){ return 1; }
+  return 0;
+}
+
+#endif /* INTERRUPT_H */
Index: libfac/factor/test.cc
===================================================================
--- libfac/factor/test.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/test.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,43 @@
+///////////////////////////////////////////////////////////////////////////////
+// factory - Includes
+//       (x+y+z)*(x+y-z)*(x-y+z)*(x-y-z)*x*y;
+#include <factory.h>
+// Factor - Includes
+#include "tmpl_inst.h"
+#include "Factor.h"
+#include "SqrFree.h"
+
+main()
+{
+    CanonicalForm f,g;
+    int charac;
+    CFFList Factorlist;
+    CFFactor copy;
+
+//    cout << " Characteristic = "; 
+    cin >> charac;
+    setCharacteristic(charac);
+    On(SW_SYMMETRIC_FF);
+    g=1;
+//    cout << " f = "; 
+    cin >> f;
+//    cout << " f = " << f  << endl;
+//    cout << " f(SqrFree)= " << endl;
+//    cout << SqrFree(f) << endl << endl;
+//cout << "gcd(f,f.deriv())= gcd(" << f << "," << f.deriv() << ")= " << gcd(f,f.deriv()) << endl;
+//cout << "gcd(f,f.deriv())= gcd(" << f << "," << f.deriv() << ")= " << gcd(f,f.deriv()) << endl;
+        Factorlist = Factorize( f );
+        cout << Factorlist ;//<< endl;
+// Ueberpruefen:
+    for ( CFFListIterator i=Factorlist ; i.hasItem(); i++){
+	copy = i.getItem();
+	if ( getNumVars(copy.factor()) > 0 )
+	     for ( int j=1; j<=copy.exp(); j++)
+	     g *= copy.factor();
+	else g *= copy.factor();
+    }
+    if ( (f-g) != f.genZero() ){
+	cerr << "\nList and f differ: f= " << f << "  g= " << g << endl;
+	cerr << "List= " << Factorlist << endl;
+    }
+}
Index: libfac/factor/timing.h
===================================================================
--- libfac/factor/timing.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/timing.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,94 @@
+/* emacs edit mode for this file is -*- C++ -*- */
+
+/* It should be possible to include this file multiple times for different */
+/* settings of TIMING */
+
+#undef TIMING_START
+#undef TIMING_END
+#undef TIMING_END_AND_PRINT
+#undef TIMING_DEFINE_PRINT
+#undef TIMING_DEFINE_PRINTPROTO
+#undef TIMING_PRINT
+
+#ifdef TIMING
+#include <time.h>
+#if ! defined(WINNT) || defined(__GNUC__)
+#include <sys/times.h>
+#include <sys/param.h>
+#endif
+#ifndef NOSTREAMIO
+#ifdef HAVE_CSTDIO
+#include <cstdio>
+#else
+#include <stdio.h>
+#endif
+#endif
+
+// need to be adjusted on your machine:
+// the number of ticks per second: HZ
+#if ! defined (HZ) && defined (CLOCKS_PER_SEC)
+#define HZ CLOCKS_PER_SEC
+#endif
+#if ! defined (HZ)  && defined (CLK_TCK)
+#define HZ CLK_TCK
+#endif
+#ifndef HZ
+#ifdef sun
+#define HZ 60.0
+#else
+#define HZ 100.0
+#endif
+#endif
+
+#if defined(WINNT) && ! defined(__GNUC__)
+
+#define TIMING_START(t) { clock_t timing_ ## t ## _start, timing_ ## t ## _end; \
+  timing_ ## t ## _start = clock();
+#define TIMING_END(t) timing_ ## t ## _end = clock(); \
+timing_ ## t ## _time += timing_ ## t ## _end - timing_ ## t ## _start; }
+#define TIMING_END_AND_PRINT(t, msg) times( &timing_ ## t ## _end ); \
+  fprintf( stderr, "%s%.2f sec\n", msg, \
+	   float( timing_ ## t ## _end - timing_ ## t ## _start ) / HZ ); \
+  timing_ ## t ## _time += timing_ ## t ## _end - timing_ ## t ## _start; }
+#define TIMING_DEFINE_PRINT(t) clock_t timing_ ## t ## _time; \
+void timing_print_ ## t ( char * msg ) { \
+  fprintf( stderr, "%s%.2f sec\n", msg, float(timing_ ## t ## _time) / HZ ); \
+} \
+void timing_reset_ ## t () { \
+  timing_ ## t ## _time = 0; \
+}
+
+#else /* ! WINNT */
+
+#define TIMING_START(t) { struct tms timing_ ## t ## _start, timing_ ## t ## _end; \
+  times( &timing_ ## t ## _start );
+#define TIMING_END(t) times( &timing_ ## t ## _end ); \
+  timing_ ## t ## _time += timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime; }
+#define TIMING_END_AND_PRINT(t, msg) times( &timing_ ## t ## _end ); \
+  fprintf( stderr, "%s%.2f sec\n", msg, \
+	   float( timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime ) / HZ ); \
+  timing_ ## t ## _time += timing_ ## t ## _end.tms_utime - timing_ ## t ## _start.tms_utime; }
+#define TIMING_DEFINE_PRINT(t) long timing_ ## t ## _time; \
+void timing_print_ ## t ( char * msg ) { \
+  fprintf( stderr, "%s%.2f sec\n", msg, float(timing_ ## t ## _time) / HZ ); \
+} \
+void timing_reset_ ## t () { \
+  timing_ ## t ## _time = 0; \
+}
+#endif /* ! WINNT */
+
+/* macros common to all platforms */
+#define TIMING_DEFINE_PRINTPROTO(t) void timing_print_ ## t ( char * ); \
+  void timing_reset_ ## t ();
+#define TIMING_PRINT(t, msg) timing_print_ ## t ( msg );
+#define TIMING_RESET(t) timing_reset_ ## t ();
+
+#else /* TIMING */
+#define TIMING_START(t)
+#define TIMING_END(t)
+#define TIMING_END_AND_PRINT(t, msg)
+#define TIMING_DEFINE_PRINT(t)
+#define TIMING_DEFINE_PRINTPROTO(t)
+#define TIMING_PRINT(t, msg)
+#define TIMING_RESET(t)
+#endif /* TIMING */
Index: libfac/factor/tmpl_inst.cc
===================================================================
--- libfac/factor/tmpl_inst.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/tmpl_inst.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,62 @@
+////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+////////////////////////////////////////////////////////////
+
+#include "config.h"
+
+// #include <factory/factoryconf.h>
+
+// #include "factory.h"
+#include "cf_iter.h"
+#include "canonicalform.h"
+#include "cf_assert.h"
+#include "cf_reval.h"
+
+#include "templates/ftmpl_array.cc"
+#include "templates/ftmpl_factor.cc"
+#include "templates/ftmpl_list.cc"
+#include "templates/ftmpl_functions.h"
+#include "templates/ftmpl_matrix.cc"
+
+// place here your own template stuff, not instantiated by factory
+#include <libfac/factor/tmpl_inst.h>
+#include <libfac/factor/class.cc>
+
+template class List<int>;
+template class ListIterator<int>;
+
+template class List<IntList>;
+template class ListIterator<IntList>;
+
+template class Substitution<CanonicalForm>;
+template class List<SForm>;
+template class ListIterator<SForm>;
+
+#ifndef NOSTREAMIO
+template OSTREAM & operator << ( OSTREAM &, const List<int> & );
+template OSTREAM & operator << ( OSTREAM &, const List<IntList> & );
+#endif
+
+// for charsets:
+template class List<CFList>;
+template class ListIterator<CFList>;
+template class List<Variable>;
+template class ListIterator<Variable> ;
+
+template List<Variable> Union ( const List<Variable>&, const List<Variable>& );
+template List<Variable> Difference ( const List<Variable>&, const List<Variable>& );
+
+#ifndef NOSTREAMIO
+template OSTREAM & operator << ( OSTREAM &, const List<CFList> & );
+template OSTREAM & operator << ( OSTREAM &, const List<Variable> & );
+template OSTREAM & operator << ( OSTREAM &, const Array<int> & );
+#endif
+
+template class Array<int>;
+template class Array<Variable>;
+
+// for database
+#ifdef HAVE_DATABASE
+template class List<CFFList>;
+template class ListIterator<CFFList>;
+#endif /* HAVE_DATABASE */
Index: libfac/factor/tmpl_inst.h
===================================================================
--- libfac/factor/tmpl_inst.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/tmpl_inst.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,48 @@
+///////////////////////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+///////////////////////////////////////////////////////////////////////////////
+#ifndef TMPL_INST_H
+#define TMPL_INST_H
+
+#include <libfac/factor/class.h>
+//typedef CanonicalForm CF;
+//typedef List<CanonicalForm> CFList;
+//typedef ListIterator<CanonicalForm> CFListIterator;
+/*BEGINPUBLIC*/
+typedef List<CFList> ListCFList;
+/*ENDPUBLIC*/
+typedef ListIterator<CFList> ListCFListIterator ;
+
+//typedef Factor<CanonicalForm> CFFactor;
+//typedef List<CFFactor> CFFList;
+//typedef ListIterator<CFFactor> CFFListIterator;
+
+/*BEGINPUBLIC*/
+typedef List<int> IntList ;
+typedef ListIterator<int> IntListIterator ;
+/*ENDPUBLIC*/
+typedef List<IntList> ListIntList;
+typedef ListIterator<IntList> ListIntListIterator ;
+
+typedef Substitution<CanonicalForm> SForm ;
+typedef List<SForm> SFormList;
+typedef ListIterator<SForm> SFormListIterator;
+
+/*BEGINPUBLIC*/
+typedef List<Variable> Varlist;
+typedef ListIterator<Variable> VarlistIterator;
+/*ENDPUBLIC*/
+
+typedef Array<int> Intarray;
+
+#ifdef HAVE_DATABASE
+typedef List<CFFList> ListCFFList;
+typedef ListIterator<CFFList> ListCFFListIterator;
+#endif
+
+//typedef Array<CFArray> CCFArray ;
+//typedef Array<CCFArray> CCCFArray ;
+
+#endif /* TMPL_INST_H */
+
+
Index: libfac/factor/version.cc
===================================================================
--- libfac/factor/version.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/version.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,14 @@
+///////////////////////////////////////////////////////////////////////////////
+// emacs edit mode for this file is -*- C++ -*-
+///////////////////////////////////////////////////////////////////////////////
+
+/*
+#include "version.h"
+
+const char * libfac_name = "Factorization and characteristic sets library";
+const char * libfac_version = LIBFAC_VERSION;
+const char * libfac_date = LIBFAC_DATE;
+const char * libfac_author = "M. Messollen";
+*/
+
+int    libfac_interruptflag = 0;
Index: libfac/factor/version.h.in
===================================================================
--- libfac/factor/version.h.in	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/factor/version.h.in	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,2 @@
+#undef LIBFAC_VERSION
+#undef LIBFAC_DATE
Index: libfac/header.tpl
===================================================================
--- libfac/header.tpl	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/header.tpl	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,41 @@
+// Header file for libfac.a
+// Created by -- makeheader --
+///////////////////////////////////////
+#ifndef FACTOR_H
+#define FACTOR_H
+
+#include <factory.h>
+
+.INCLUDE factor/interrupt.h
+
+// some values you can ask for:
+extern const char * libfac_name;
+extern const char * libfac_version;
+extern const char * libfac_date;
+extern const char * libfac_author;
+
+//// Note: second argument for Factorize is for internal use only.
+.INCLUDE factor/Factor.h
+.INCLUDE factor/MVMultiHensel.h
+
+//// Note: InternalSqrFree does only the work needed for factorization.
+.INCLUDE factor/SqrFree.h
+.INCLUDE factor/Truefactor.h
+.INCLUDE factor/class.h
+
+.INCLUDE factor/helpstuff.h
+.INCLUDE factor/tmpl_inst.h
+.INCLUDE factor/homogfactor.h
+.INCLUDE factor/debug.h
+.INCLUDE factor/timing.h
+
+////////////////////////////////////////
+/// from charsets:
+.INCLUDE charset/csutil.h
+.INCLUDE charset/charset.h
+
+.INCLUDE charset/reorder.h
+
+.INCLUDE charset/algfactor.h
+
+#endif /* FACTOR_H */
Index: libfac/libfac.h
===================================================================
--- libfac/libfac.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/libfac.h	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,99 @@
+// Header file for libfac.a
+// Created by -- makeheader --
+///////////////////////////////////////
+#ifndef FACTOR_H
+#define FACTOR_H
+
+#include <factory/factory.h>
+
+// Set this to a nonzero value to interrupt the computation
+extern int libfac_interruptflag;
+
+/*
+// some values you can ask for:
+extern const char * libfac_name;
+extern const char * libfac_version;
+extern const char * libfac_date;
+extern const char * libfac_author;
+*/
+
+/*
+CFFList Factorize( const CanonicalForm & F, const CanonicalForm & mipo, int is_SqrFree=0 ) ;
+CFFList newfactoras( const CanonicalForm & f, const CFList & as, int &success);
+CFFList newcfactor( const CanonicalForm & f, const CFList & as, int &success);
+*/
+
+
+//// Note: InternalSqrFree does only the work needed for factorization.
+// CFFList SqrFree( const CanonicalForm & f ) ;
+
+typedef List<CFList> ListCFList;
+typedef List<int> IntList ;
+
+// typedef ListIterator<int> IntListIterator ;
+// typedef List<Variable> Varlist;
+// typedef ListIterator<Variable> VarlistIterator;
+
+////////////////////////////////////////
+/// from charsets:
+/*
+class PremForm {
+public:
+  CFList FS1;
+  CFList FS2;
+  inline PremForm& operator=( const PremForm&  value ){
+    if ( this != &value ){
+      FS1 = value.FS1;
+      FS2 = value.FS2;
+    }
+    return *this;
+  }
+};
+
+
+CanonicalForm  Prem( const CanonicalForm &f, const CanonicalForm &g );
+CanonicalForm  Prem( const CanonicalForm &f, const CFList &L );
+CFList         Prem( const CFList &AS, const CFList &L );
+CFList     MCharSetN( const CFList &PS, PremForm & Remembern );
+*/
+
+
+/// Char. set
+ListCFList IrrCharSeries( const CFList &PS, int opt=0 );
+
+/*
+// the next three give you a heuristically optimal reorderd list of the
+// variables. For internal and external (e.g. Singular/Macaulay2) library use.
+// This is really experimental!
+// See the comments in reorder.cc.
+// 
+// this gives you a heuristically optimal ordering for the ring variables
+// if you use the irreducible characteristic series.
+Varlist  neworder( const CFList & PolyList );
+// the same as neworder(...) only returning a list of CanonicalForm 's
+// (i.e. the variables as CanonicalForms)
+CFList   newordercf(const CFList & PolyList );
+*/
+
+/// the same as neworder(...) only returning a list of int 's (i.e. the levels)
+IntList  neworderint(const CFList & PolyList );
+
+/*
+// for library internal use only:
+// next function reorders the variables in PS:
+// a code segment to use:
+// ...
+// #include <tmpl_inst.h> // for typedef's
+// CFList PS= <setup-your-list-of-CanonicalForms>;
+// Varlist betterorder= neworder(PS);
+// PS= reorder(betterorder,PS); // reorder variables in PS from oldorder 
+//                                 to betterorder
+// ListCFList Q= IrrCharSeries( PS );
+// Q= reorder(betterorder,Q);   // revert ordering to oldorder
+// 
+CFList reorder( const Varlist & betterorder, const CFList & PS);
+CFFList reorder( const Varlist & betterorder, const CFFList & PS);
+ListCFList reorder(const Varlist & betterorder, const ListCFList & Q);
+*/
+
+#endif /* FACTOR_H */
Index: libfac/mkinstalldirs
===================================================================
--- libfac/mkinstalldirs	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/mkinstalldirs	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,32 @@
+#!/bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Last modified: 1994-03-25
+# Public domain
+
+errstatus=0
+
+for file in ${1+"$@"} ; do 
+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+   shift
+
+   pathcomp=
+   for d in ${1+"$@"} ; do
+     pathcomp="$pathcomp$d"
+     case "$pathcomp" in
+       -* ) pathcomp=./$pathcomp ;;
+     esac
+
+     if test ! -d "$pathcomp"; then
+        echo "mkdir $pathcomp" 1>&2
+        mkdir "$pathcomp" || errstatus=$?
+     fi
+
+     pathcomp="$pathcomp/"
+   done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
Index: libfac/test.cc
===================================================================
--- libfac/test.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/test.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,68 @@
+//static char rcsid[] = "$Id$";
+///////////////////////////////////////////////////////////////////////////////
+// Factor - Includes
+#include "libfac.h"
+#include <string.h>
+
+#ifdef HAVE_IOSTREAM
+#include <iostream>
+#define CERR std::cerr
+#define COUT std::cout
+#define CIN std::cin
+#elif defined(HAVE_IOSTREAM_H)
+#include <iostream.h>
+#define CERR cerr
+#define COUT cout
+#define CIN cin
+#endif
+
+
+
+void
+setVarNames ( char * vnames )
+{
+    int i, n = strlen( vnames );
+    Variable dummy;
+    for ( i = 0; i < n; i++ )
+        dummy = Variable( i+1, vnames[i] );
+}
+
+main()
+{
+    CanonicalForm f,g;
+    int charac;
+    CFFList Factorlist;
+    CFFactor copy;
+
+COUT << libfac_name  <<", Version " << libfac_version << "\n";
+//    COUT << " Characteristic = "; 
+    CIN >> charac;
+    setCharacteristic(charac);
+    On(SW_SYMMETRIC_FF);
+    On(SW_USE_EZGCD);
+//////////////////////////////////////////////////////////////
+//  char vnames[30];
+////  cout << " vnames = "; 
+//  cin >> vnames;
+//
+//  setVarNames( vnames );
+//
+//////////////////////////////////////////////////////////////
+//    COUT << " f = "; 
+//    CIN >> f;
+//    COUT << f  << " mod " << charac << " = " ;
+//    Factorlist= Factorize( f,0 );
+//     COUT << Factorlist ;//<< "\n";
+// Ueberpruefen:
+//    g=1;
+//    for ( CFFListIterator i=Factorlist ; i.hasItem(); i++){
+//	copy = i.getItem();
+//	if ( getNumVars(copy.factor()) > 0 )
+//	     for ( int j=1; j<=copy.exp(); j++)
+//	     g *= copy.factor();
+//	else g *= copy.factor();
+ //   }
+//    if ( (f-g) != f.genZero() ){
+//	CERR << "\nList and f differ: f= " << f << "  g= " << g << "\n";
+ //   }
+}
Index: libfac/testcs.cc
===================================================================
--- libfac/testcs.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/testcs.cc	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,75 @@
+
+#include <factory.h>
+#include <libfac.h>
+#ifdef HAVE_IOSTREAM
+#include <iostream>
+#define COUT std::cout
+#define CIN std::cin
+#elif defined(HAVE_IOSTREAM_H)
+#include <iostream.h>
+#define COUT cout
+#define CIN cin
+#endif
+
+
+// testing: Characteristic Sets
+void
+setVarNames ( char * vnames )
+{
+    int i, n = strlen( vnames );
+    Variable dummy;
+    for ( i = 0; i < n; i++ )
+	dummy = Variable( i+1, vnames[i] );
+}
+
+main()
+{
+  int reord=0; // use strategy for reordering?
+  int charac;
+  COUT << " Characteristic = "; CIN >> charac;
+  setCharacteristic(charac);
+  On(SW_SYMMETRIC_FF);
+  char vnames[30];
+  COUT << " vnames = "; CIN >> vnames;
+
+  setVarNames( vnames );
+
+  CFList F1,F2;
+  ListCFList Q;
+  CanonicalForm f;
+  CFListIterator I ;
+  int i = 1;
+  PremForm Remembern;
+  Varlist betterorder;
+
+  COUT << " f[" << i << "] = "; cin >> f;
+  while ( f != 0 ) {
+    F1.append( f ); i++;
+    COUT << " f[" << i << "] = "; cin >> f;
+  }
+  F2=F1;
+  COUT << "\n";
+
+  COUT << "F = " << F1 << "\n";
+  if (reord){
+    betterorder= neworder(F1);
+    COUT << "new orderd vars: " << betterorder << "\n";
+    F1=reorder(betterorder,F1);
+    COUT << "new F= " << F1 << "\n";
+  }
+//   COUT << "\nUsing Modified CharSet:" << "\n";
+//   F2 = MCharSetN( F1, Remembern );
+//   COUT << "MCsN(F) = " << F2 << "\n";
+//   COUT << "Factors removed: " << Remembern.FS2 << "\n";
+//   COUT << "Possible Factors considered: " << Remembern.FS1 << "\n";
+//   for ( I = F2; I.hasItem(); I++ )
+//     COUT << "  vars: " << getVars( I.getItem() ) << "\n";
+  COUT << "\nUsing IrrCharSeries:" << "\n";
+  Q= IrrCharSeries( F1 );
+  COUT << "ics(F) = " << Q << "\n";
+  if (reord){
+    Q=reorder(betterorder,Q);
+    COUT << "reorderd ics(F) = " << Q << "\n";
+  }
+}
+
Index: libfac/tests/factor/f1
===================================================================
--- libfac/tests/factor/f1	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f1	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+x^14-1;
+#
+#(x-1)*(x+1)*(x^6+x^5+x^4+x^3+x^2+x+1)*(x^6-x^5+x^4-x^3+x^2-x+1)
Index: libfac/tests/factor/f10
===================================================================
--- libfac/tests/factor/f10	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f10	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(x^2-10748*y*x+y^2)*(y^2+x^2)*(x^2+10748*y*x+y^2);
+#
+#
Index: libfac/tests/factor/f11
===================================================================
--- libfac/tests/factor/f11	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f11	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(3*z^3+2*w*z-10*y^2+45*x^3)*(w^2*z^3+47*x*y-w^2);
+#
+#
Index: libfac/tests/factor/f12
===================================================================
--- libfac/tests/factor/f12	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f12	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(10*y+x^3+9)*(6*x*y^2+x+y+x^3+15);
+#
+#
Index: libfac/tests/factor/f13
===================================================================
--- libfac/tests/factor/f13	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f13	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(x-w)*(y-w)*(x-y)*(z-w)*(x-z)*(y-z);
+#
+#
Index: libfac/tests/factor/f14
===================================================================
--- libfac/tests/factor/f14	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f14	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(x^3*y+x^3*z+z-11)*(x^2*z^2+x^2*y^2+y+90);
+#
+#leading coefficient is a sum
Index: libfac/tests/factor/f15
===================================================================
--- libfac/tests/factor/f15	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f15	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(z+x*y+10)*(x*z+y+30)*(y*z+x+20);
+#
+#
Index: libfac/tests/factor/f16
===================================================================
--- libfac/tests/factor/f16	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f16	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+w^2*x^7*y^6*12*z^5+31962*z^2*y^5*x^7+87*z^5*y^3*x^7+31967*z^2*y^7*x^8+31759*z^2*y^5*x^8+31988*z^2*y^7*x^7+54*z^2*y^6*x^10+522*z^2*y^4*x^10+9*z^5*y^5*x^7+z^2*y^5*x^6*w^2+3*z^8*y^3*x^6*w^2+2*z^6*y^3*x^6*w^3+31989*z^3*y^3*x^6*w^3+31977*z^2*y^5*x^6*w^4+31988*z^5*y^3*x^6*w^2+414*z^2*y^5*x^7*w^2+42*z^2*y^7*x^7*w^2+14*z^5*y^5*x^6*w^4+31990*z^5*y^5*x^6*w^2+31973*z^2*y^4*x^9*w^2+58*z^3*y^3*x^7*w+31955*z^8*y^4*x^7*w^2+6*z^3*y^5*x^7*w+31967*z^6*y^4*x^7*w^3+96*z^5*y^6*x^8*w^2+31983*z^5*y^5*x^7*w^2+31823*z^5*y^6*x^7*w^4+31775*z^5*y^5*x^10*w^2+18*z^5*y^4*x^9*w^2;
+#
+#( 5333, (z)^2, (x)^6, (y)^3, -13785, -z^3+10663*w*z-10661*x*y^2+10659*w^2*y^2+10664*y^2-6*x^3*y, 3309*w^2*x*y*z^3+7722*w^2*z^3-8825*x*y^2+x-7722*w^2 )
Index: libfac/tests/factor/f17
===================================================================
--- libfac/tests/factor/f17	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f17	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(x^2*y+x*y+1)*(x^2*y+2*x*y+3)*(2*x^2*y+3*x*y+5)*(3*x^2*y+4*x*y+7);
+#
+#
Index: libfac/tests/factor/f18
===================================================================
--- libfac/tests/factor/f18	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f18	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(z^3+x*y*z+y^2+x^3)*(x*(z^4+1)+z+x^3*y^2);
+#
+#
Index: libfac/tests/factor/f19
===================================================================
--- libfac/tests/factor/f19	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f19	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(x^2-x*z+z*y+2)*(x^2+3*x-y^2-15);
+#
+#
Index: libfac/tests/factor/f2
===================================================================
--- libfac/tests/factor/f2	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f2	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+x^8 + x +1 ;
+#
+# (x**4-994*x**3-1479*x**2+15362*x+7108)*(x**2+993*x-3200)*(x**2+x+1)
Index: libfac/tests/factor/f20
===================================================================
--- libfac/tests/factor/f20	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f20	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(x*z^2+2*x*z*w+x*w^2+z^2+w+2*z*w)*(x*z^2+2*x*z*w+x*w^2+z);
+#
+#
Index: libfac/tests/factor/f21
===================================================================
--- libfac/tests/factor/f21	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f21	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+x^10 - y^4;
+#
+#
Index: libfac/tests/factor/f21a
===================================================================
--- libfac/tests/factor/f21a	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f21a	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+5
+x^10 - y^4;
+#
+#
Index: libfac/tests/factor/f22
===================================================================
--- libfac/tests/factor/f22	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f22	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(x^3*(z+y)+z-11)*(x^2*(z^2+y^2)+y+90);
+#
+#
Index: libfac/tests/factor/f23
===================================================================
--- libfac/tests/factor/f23	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f23	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(y*z^3+x*y*z+y^2+x^3)*(x*(z^4+1)+z+x^3*y^2);
+#
+#
Index: libfac/tests/factor/f24
===================================================================
--- libfac/tests/factor/f24	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f24	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(z^2-x^3*y+3)*(z^2+x^3*y^4)*(y^4*z^2+x^2*z+5);
+#
+#
Index: libfac/tests/factor/f25
===================================================================
--- libfac/tests/factor/f25	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f25	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(z^2+x^3*y^4+u^2)*((y^2+x)*z^2 + 3*u^2*x^3*y^4*z+19*y^2)*(u^2*y^4*z^2+x^2*z+5);
+#
+#
Index: libfac/tests/factor/f26
===================================================================
--- libfac/tests/factor/f26	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f26	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(w^4*z^3-x*y^2*z^2-w^4*x^5*y^6-w^2*x^3*y)*(-1*x^5-z^3+y*z+x^2*y^3)*(w^4*z^6+y^2*z^3-w^2*x^2*y^2*z^2+x^5*z-x^4*y^2-w^3*x^3*y);
+#
+#
Index: libfac/tests/factor/f27
===================================================================
--- libfac/tests/factor/f27	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f27	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(z+y+x-3)*(z+y+x-3)*(z+y+x-3)*(z+y+x-2)*(z+y+x-2);
+#
+#
Index: libfac/tests/factor/f28
===================================================================
--- libfac/tests/factor/f28	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f28	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(-15*y^2*z^16+29*w^4*x^12*y^12*z^3+21*x^3*z^2+3*w^15*y^20)*(-1*z^31-w^12*z^20+y^18-y^14+x^2*y^2+x^21+w^2);
+#
+#
Index: libfac/tests/factor/f29
===================================================================
--- libfac/tests/factor/f29	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f29	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+1;
+#
+#
Index: libfac/tests/factor/f3
===================================================================
--- libfac/tests/factor/f3	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f3	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,3 @@
+31991
+-9944*(x^2-5265*x+14343)*(x^2+5943*x-3555)*(x-8995)*(x-15035) ;
+#
Index: libfac/tests/factor/f32
===================================================================
--- libfac/tests/factor/f32	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f32	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(z+y+x-3)*(z+y+x-3)*(z+y+x-3);
+#
+#
Index: libfac/tests/factor/f33
===================================================================
--- libfac/tests/factor/f33	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f33	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(3*z^3+2*w*z-9*y^3-y^2+45*x^3)*(w^2*z^3+47*x*y-w^2);
+#
+#
Index: libfac/tests/factor/f34
===================================================================
--- libfac/tests/factor/f34	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f34	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+(22*y^5-18*x^4*y^5-26*x^3*y^4-38*x^2*y^4+29*x^2*y^3-41*x^4*y^2+37*x^4)*(33*x^5*y^6+11*y^2+35*x^3*y-22*x^4);
+#
+#
Index: libfac/tests/factor/f35
===================================================================
--- libfac/tests/factor/f35	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f35	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+x^6*y^3*z^2*(3*z^3+2*w*z-8*x*y^2+14*w^2*y^2-y^2+18*x^3*y)*(w^2*z^3-12*w^2*x*y*z^3+3*x*y^2+29*x-w^2);
+#
+#
Index: libfac/tests/factor/f36
===================================================================
--- libfac/tests/factor/f36	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f36	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,5 @@
+101
+(a-b)*(a^4-7*b* c-4)*(a^5-b+c-11*d^3+1);
+#
+# From Dan Grayson
+#
Index: libfac/tests/factor/f37
===================================================================
--- libfac/tests/factor/f37	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f37	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+2
+(x+y^2)*(x^2+y);
+#
+#
Index: libfac/tests/factor/f38
===================================================================
--- libfac/tests/factor/f38	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f38	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+5
+(x+y^2)*(x^2+y)*(x+y^4)*(x^4+y);
+#
+#
Index: libfac/tests/factor/f39
===================================================================
--- libfac/tests/factor/f39	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f39	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,6 @@
+2
+(x+y^2)*(x^2+y)*(x+y^4)*(x^4+y);
+b^2+b+1;
+b^2+b+1;
+#
+#
Index: libfac/tests/factor/f4
===================================================================
--- libfac/tests/factor/f4	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f4	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+3
+x^3 - y^3;
+#
+# (x-y)^3
Index: libfac/tests/factor/f40
===================================================================
--- libfac/tests/factor/f40	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f40	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,5 @@
+3
+(x+y^2)*(x^2+y)*(x+y^4)*(x^4+y);
+b^2+b+2;
+#
+#
Index: libfac/tests/factor/f41
===================================================================
--- libfac/tests/factor/f41	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f41	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,3 @@
+2
+x*(x+y)*(x^2+x+y^2)*(x^2+x+y+1)*(x^2+x+y^2+1);
+#
Index: libfac/tests/factor/f42
===================================================================
--- libfac/tests/factor/f42	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f42	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,6 @@
+2
+x*(x+y)*(x^2+x+y^2)*(x^2+x+y+1)*(x^2+x+y^2+1)*(x^3+x+y^3)*(x^3+x+y+1)*(x^3+x+y^3+1)*(x^3+x+y^3+y+1)*(x^3+x+y^3+y^2+1);
+x^2+x+1;
+x^3+x+1;
+x^4+x+1;
+#
Index: libfac/tests/factor/f43
===================================================================
--- libfac/tests/factor/f43	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f43	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+5
+(x*z+y+30)*(y*z+x+20)*(z+x*y+10);
+b^2+3;
+
Index: libfac/tests/factor/f5
===================================================================
--- libfac/tests/factor/f5	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f5	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991
+x^4 + y^3 + z^5 ;
+#
+# irreduzible
Index: libfac/tests/factor/f6
===================================================================
--- libfac/tests/factor/f6	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f6	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991;
+(3*z^2+2*y^2+x^2)*(4*z^2-3*y^2+2*x^2);
+#
+#
Index: libfac/tests/factor/f7
===================================================================
--- libfac/tests/factor/f7	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f7	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,5 @@
+31991
+(y*z+x*y^2+9)*(y*z+x*z+x^2*y);
+#
+#
+
Index: libfac/tests/factor/f8
===================================================================
--- libfac/tests/factor/f8	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f8	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,5 @@
+31991
+(x+y+z)*(z-y+x)*(x-z-y);
+#
+#
+
Index: libfac/tests/factor/f9
===================================================================
--- libfac/tests/factor/f9	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/f9	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+31991;
+(y*z-x*z+x^2+2)*(z^3-y^2+x^2+3*x-15);
+#
+#
Index: libfac/tests/factor/p1
===================================================================
--- libfac/tests/factor/p1	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/p1	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,60 @@
+32003
+-573002*x^10+240517*x^9*y+396389*x^8*y^2+535082*x^7*y^3+288429*x^6*y^4
++763919*x^5*y^5+3766*x^4*y^6-649376*x^3*y^7-59851*x^2*y^8-542799*x*y^9+20979*y^10
+-461020*x^9*z-650459*x^8*y*z-944957*x^7*y^2*z+1677170*x^6*y^3*z+1666154*x^5*y^4*z
+-1232710*x^4*y^5*z+862729*x^3*y^6*z-618762*x^2*y^7*z-705768*x*y^8*z-187036*y^9*z-741032*x^8*z^2
++1446654*x^7*y*z^2-643320*x^6*y^2*z^2-1635676*x^5*y^3*z^2-189420*x^4*y^4*z^2+682529*x^3*y^5*z^2
+-450284*x^2*y^6*z^2-327970*x*y^7*z^2+66106*y^8*z^2+386688*x^7*z^3+198264*x^6*y*z^3-757313*x^5*y^2*z^3+2008508*x^4*y^3*z^3-675589*x^3*y^4*z^3-2338517*x^2*y^5*z^3+413997*x*y^6*z^3+150157*y^7*z^3
++115299*x^6*z^4+1838075*x^5*y*z^4-821489*x^4*y^2*z^4-772496*x^3*y^3*z^4+94982*x^2*y^4*z^4
++552427*x*y^5*z^4+894534*y^6*z^4-173749*x^5*z^5-1322895*x^4*y*z^5+545850*x^3*y^2*z^5
++1506535*x^2*y^3*z^5+31641*x*y^4*z^5+858761*y^5*z^5+188464*x^4*z^6+676365*x^3*y*z^6
+-1175321*x^2*y^2*z^6-94611*x*y^3*z^6+365391*y^4*z^6-300517*x^3*z^7-74262*x^2*y*z^7
++756469*x*y^2*z^7+702099*y^3*z^7+651058*x^2*z^8+261997*x*y*z^8+70610*y^2*z^8-493574*x*z^9
++129784*y*z^9+265065*z^10-532141*x^9*w-285474*x^8*y*w-1300132*x^7*y^2*w+908974*x^6*y^3*w
+-1966687*x^5*y^4*w-127968*x^4*y^5*w+58220*x^3*y^6*w+41679*x^2*y^7*w+479035*x*y^8*w+466832*y^9*w
++1566035*x^8*z*w+1817709*x^7*y*z*w-688806*x^6*y^2*z*w-748313*x^5*y^3*z*w-1930577*x^4*y^4*z*w
+-957911*x^3*y^5*z*w+81915*x^2*y^6*z*w+133232*x*y^7*z*w+980198*y^8*z*w-110745*x^7*z^2*w
+-1370738*x^6*y*z^2*w-1182195*x^5*y^2*z^2*w+3215028*x^4*y^3*z^2*w-2006230*x^3*y^4*z^2*w
++2364130*x^2*y^5*z^2*w+1457270*x*y^6*z^2*w+1484168*y^7*z^2*w+1648545*x^6*z^3*w+772215*x^5*y*z^3*w
++554722*x^4*y^2*z^3*w+667926*x^3*y^3*z^3*w+375356*x^2*y^4*z^3*w+3601160*x*y^5*z^3*w
++625131*y^6*z^3*w-2510503*x^5*z^4*w-2729919*x^4*y*z^4*w+1243946*x^3*y^2*z^4*w
++2503349*x^2*y^3*z^4*w+1909123*x*y^4*z^4*w+588366*y^5*z^4*w+94641*x^4*z^5*w+1274333*x^3*y*z^5*w
++1615834*x^2*y^2*z^5*w-1286036*x*y^3*z^5*w-491438*y^4*z^5*w-864129*x^3*z^6*w+96287*x^2*y*z^6*w
+-1641596*x*y^2*z^6*w-479951*y^3*z^6*w+865513*x^2*z^7*w+37697*x*y*z^7*w-425879*y^2*z^7*w
+-246899*x*z^8*w-1043521*y*z^8*w-615277*z^9*w-353183*x^8*w^2+1903124*x^7*y*w^2+307847*x^6*y^2*w^2
++153254*x^5*y^3*w^2+4494*x^4*y^4*w^2+775116*x^3*y^5*w^2+84747*x^2*y^6*w^2+1970329*x*y^7*w^2
++248796*y^8*w^2-200676*x^7*z*w^2-1283772*x^6*y*z*w^2+312236*x^5*y^2*z*w^2+258350*x^4*y^3*z*w^2
++899318*x^3*y^4*z*w^2+879951*x^2*y^5*z*w^2-197099*x*y^6*z*w^2+1027373*y^7*z*w^2
+-939408*x^6*z^2*w^2+1231368*x^5*y*z^2*w^2+811932*x^4*y^2*z^2*w^2+136753*x^3*y^3*z^2*w^2
+-1060314*x^2*y^4*z^2*w^2-373787*x*y^5*z^2*w^2-419717*y^6*z^2*w^2-602528*x^5*z^3*w^2
+-279785*x^4*y*z^3*w^2+140803*x^3*y^2*z^3*w^2+1245653*x^2*y^3*z^3*w^2+611906*x*y^4*z^3*w^2
+-1166551*y^5*z^3*w^2-878201*x^4*z^4*w^2+597628*x^3*y*z^4*w^2-220458*x^2*y^2*z^4*w^2
+-3038116*x*y^3*z^4*w^2-2785259*y^4*z^4*w^2-425903*x^3*z^5*w^2-316206*x^2*y*z^5*w^2
+-3764903*x*y^2*z^5*w^2-2194636*y^3*z^5*w^2-185521*x^2*z^6*w^2+419827*x*y*z^6*w^2
+-70946*y^2*z^6*w^2+561958*x*z^7*w^2-513594*y*z^7*w^2-487215*z^8*w^2-902070*x^7*w^3
++260239*x^6*y*w^3-1618965*x^5*y^2*w^3+1123916*x^4*y^3*w^3-1107669*x^3*y^4*w^3-1433250*x^2*y^5*w^3
++665446*x*y^6*w^3-1463775*y^7*w^3+778712*x^6*z*w^3-80174*x^5*y*z*w^3-93922*x^4*y^2*z*w^3
++1249290*x^3*y^3*z*w^3+1272307*x^2*y^4*z*w^3+513673*x*y^5*z*w^3-322676*y^6*z*w^3
+-634533*x^5*z^2*w^3-1875741*x^4*y*z^2*w^3-2698209*x^3*y^2*z^2*w^3+937176*x^2*y^3*z^2*w^3
+-2883756*x*y^4*z^2*w^3-1430757*y^5*z^2*w^3+485806*x^4*z^3*w^3+731831*x^3*y*z^3*w^3
++2196178*x^2*y^2*z^3*w^3-1491104*x*y^3*z^3*w^3-1456373*y^4*z^3*w^3-206031*x^3*z^4*w^3+314576*x^2*y*z^4*w^3-225867*x*y^2*z^4*w^3-2750466*y^3*z^4*w^3-1087247*x^2*z^5*w^3+2172840*x*y*z^5*w^3
+-541045*y^2*z^5*w^3+624945*x*z^6*w^3+1085162*y*z^6*w^3+565094*z^7*w^3-457315*x^6*w^4
++342040*x^5*y*w^4-681000*x^4*y^2*w^4+297164*x^3*y^3*w^4+689*x^2*y^4*w^4+529745*x*y^5*w^4
+-1310613*y^6*w^4-786298*x^5*z*w^4-1023635*x^4*y*z*w^4-2098764*x^3*y^2*z*w^4+1733995*x^2*y^3*z*w^4
++1561806*x*y^4*z*w^4+133720*y^5*z*w^4-240204*x^4*z^2*w^4+1124674*x^3*y*z^2*w^4
++2411690*x^2*y^2*z^2*w^4-600532*x*y^3*z^2*w^4-71275*y^4*z^2*w^4+128215*x^3*z^3*w^4
++567626*x^2*y*z^3*w^4+973911*x*y^2*z^3*w^4-562780*y^3*z^3*w^4-894759*x^2*z^4*w^4
++1265582*x*y*z^4*w^4+509433*y^2*z^4*w^4-671007*x*z^5*w^4+345729*y*z^5*w^4+80717*z^6*w^4
++1144765*x^5*w^5+137320*x^4*y*w^5+390809*x^3*y^2*w^5+207350*x^2*y^3*w^5+65943*x*y^4*w^5
+-1283191*y^5*w^5-109804*x^4*z*w^5+951743*x^3*y*z*w^5-154107*x^2*y^2*z*w^5-394628*x*y^3*z*w^5
+-3201737*y^4*z*w^5+2307230*x^3*z^2*w^5-1082386*x^2*y*z^2*w^5-240669*x*y^2*z^2*w^5
+-1274548*y^3*z^2*w^5-1768397*x^2*z^3*w^5-2788826*x*y*z^3*w^5+1689141*y^2*z^3*w^5
+-1051474*x*z^4*w^5+126201*y*z^4*w^5-789876*z^5*w^5-288558*x^4*w^6-697110*x^3*y*w^6
++659535*x^2*y^2*w^6-1659535*x*y^3*w^6+371290*y^4*w^6-1605798*x^3*z*w^6+63599*x^2*y*z*w^6
++273476*x*y^2*z*w^6-774681*y^3*z*w^6-113162*x^2*z^2*w^6+861980*x*y*z^2*w^6
++1824646*y^2*z^2*w^6-275200*x*z^3*w^6+1083821*y*z^3*w^6+803980*z^4*w^6
++912560*x^3*w^7-373953*x^2*y*w^7+635559*x*y^2*w^7+2023871*y^3*w^7-252773*x^2*z*w^7
+-1013176*x*y*z*w^7-356255*y^2*z*w^7+412544*x*z^2*w^7-199680*y*z^2*w^7+190561*z^3*w^7
++33346*x^2*w^8-1189055*x*y*w^8+246983*y^2*w^8-220965*x*z*w^8-273745*y*z*w^8-493392*z^2*w^8
++411602*x*w^9+853400*y*w^9+1110886*z*w^9-580548*w^10;
+
Index: libfac/tests/factor/p2
===================================================================
--- libfac/tests/factor/p2	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/p2	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,2 @@
+32003
+x^25+y^23+z^18+x^4*y^10+x^8*y^5+2*x^5*y^8+x^5*y^5*z^3+x^6*y^6;
Index: libfac/tests/factor/p3
===================================================================
--- libfac/tests/factor/p3	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/p3	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,3 @@
+32003
+a^3*b^3*f^4+186*a^2*b^4*c*f^3+11532*a*b^5*c^2*f^2+14307*b^6*c^3*f;
+# laesst sich nicht mit Maple faktorisieren!
Index: libfac/tests/factor/p4
===================================================================
--- libfac/tests/factor/p4	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/p4	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,4 @@
+32003
+f^3*u^3-4*f^2*g*v*y*u^2 + (8*f^3*v^2*y+6*f^2*g*v^2*x+4*f*g^2*v^2*y^2)*u
+-8*f^3*v^3*x-4*f*g^2*v^3*x*y + g^3*v^3*x^2;
+
Index: libfac/tests/factor/p5.3
===================================================================
--- libfac/tests/factor/p5.3	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factor/p5.3	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,8 @@
+3
+s^85+(t)*s^84+(t^2)*s^83+(-1*t^18)*s^67+(-1*t^19)*s^66+(t^20)*s^65
++(t^21)*s^64+(t^22)*s^63+(-1*t^24)*s^61+(-1*t^25)*s^60+(t^29)*s^56
++(t^38)*s^47+(-1*t^39)*s^46+(-1*t^40)*s^45+(-1*t^42)*s^43+(-1*t^43)*s^42
++(-1*t^45)*s^40+(-1*t^46)*s^39+(t^47)*s^38+(t^56)*s^29+(-1*t^60)*s^25
++(-1*t^61)*s^24+(t^63)*s^22+(t^64)*s^21+(t^65)*s^20+(-1*t^66)*s^19
++(-1*t^67)*s^18+(t^83)*s^2+(t^84)*s+(t^85);
+
Index: libfac/tests/factortest
===================================================================
--- libfac/tests/factortest	(revision 18500b278c2d1587c78c8502e401e80745031231)
+++ libfac/tests/factortest	(revision 18500b278c2d1587c78c8502e401e80745031231)
@@ -0,0 +1,118 @@
+#!/bin/csh
+# Make various tests for the factorization. 
+
+set OS=`uname`
+if ( $OS == "Linux" ) then
+	set ECHO="/bin/echo -e"
+else if ( $OS == "SunOS" ) then
+	set ECHO=/usr/5bin/echo
+else
+	set ECHO=echo
+endif
+$ECHO "\n\ntesting univariate factorization:\c"
+$ECHO "\nf1  \c" 
+../test < factor/f1  
+$ECHO "\nf2  \c"
+../test < factor/f2
+$ECHO "\nf3  \c"
+../test < factor/f3
+
+$ECHO "\n\ntesting multivariate factorization:"
+$ECHO "\nf4  \c"
+../test < factor/f4
+$ECHO "\nf5  \c"
+../test < factor/f5
+$ECHO "\nf6  \c"
+../test < factor/f6
+$ECHO "\nf7  \c"
+../test < factor/f7
+$ECHO "\nf8  \c"
+../test < factor/f8
+$ECHO "\nf9  \c"
+../test < factor/f9
+$ECHO "\nf10 \c"
+../test < factor/f10
+#$ECHO "\nf11 \c"
+#../test < factor/f11
+$ECHO "\nf12 \c"
+../test < factor/f12
+$ECHO "\nf12 \c"
+../test < factor/f13
+$ECHO "\nf14 \c"
+../test < factor/f14
+$ECHO "\nf15 \c"
+../test < factor/f15
+$ECHO "\nf16  -- skipping; takes long time.  See the Long-time section!\c"
+$ECHO "\nf17 \c"
+../test < factor/f17
+$ECHO "\nf18 \c"
+../test < factor/f18
+$ECHO "\nf19 \c"
+../test < factor/f19
+$ECHO "\nf20 \c"
+../test < factor/f20
+$ECHO "\nf21 \c"
+../test < factor/f21
+$ECHO "\nf21a \c"
+../test < factor/f21a
+$ECHO "\nf22 \c"
+../test < factor/f22
+$ECHO "\nf23 \c"
+../test < factor/f23
+$ECHO "\nf24 -- skipping; takes long time.  See the Long-time section!\c"
+$ECHO "\nf25 -- skipping; takes long time.  See the Long-time section!\c"
+$ECHO "\nf26 -- skipping; takes long time.  See the Long-time section!\c"
+$ECHO "\nf27 \c"
+../test < factor/f27
+$ECHO "\nf28 -- skipping; takes long time.  See the Long-time section!\c"
+$ECHO "\nf29 -- Test suite not available.\c"
+#../test < factor/f29
+$ECHO "\nf30 -- Test suite not available.\c"
+#../test < factor/f30
+$ECHO "\nf31 -- Test suite not available.\c"
+#../test < factor/f31
+$ECHO "\nf32 \c"
+../test < factor/f32
+$ECHO "\nf33 \c"
+../test < factor/f33
+$ECHO "\nf34 \c"
+../test < factor/f34
+$ECHO "\nf35 -- skipping; takes long time.  See the Long-time section!\c"
+$ECHO "\nf36 \c"
+../test < factor/f36
+$ECHO "\nf37 \c"
+../test < factor/f37
+$ECHO "\nf38 \c"
+../test < factor/f38
+$ECHO "\n"
+$ECHO "Tests from Gerhard Pfister:"
+$ECHO "p1   -- skipping; takes long time.  See the Long-time section!\c"
+$ECHO "\np2 \c"
+../test < factor/p2
+$ECHO "\np3 \c"
+../test < factor/p3
+$ECHO "\np4 \c"
+../test < factor/p4
+$ECHO "\np5 \c"
+../test < factor/p5.3
+
+$ECHO "\n"  
+# need-extensions section:
+$ECHO "\n Need-extensions section!\n"
+$ECHO "\nf39 \c"
+../test < factor/f39
+$ECHO "\nf40 \c"
+../test < factor/f40
+$ECHO "\nf41 \c"
+../test < factor/f41
+$ECHO "\nf42 \c"
+../test < factor/f42
+$ECHO "\nf43 \c"
+../test < factor/f43
+
+
+$ECHO "\n"
+$ECHO 
+# long time section:
+$ECHO "\n Long-time section!\n"
+$ECHO "\n ... Skipping!\n"
