sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.43k stars 479 forks source link

Add Normaliz optional package #13234

Closed novoselt closed 11 years ago

novoselt commented 12 years ago

Normaliz http://www.mathematik.uni-osnabrueck.de/normaliz/ is one of the dependencies of Macaulay2 (which is also an optional package), but can be of interest on its own as well.

Install the spkg from here

Upstream: Fixed upstream, but not in a stable release.

CC: @johnperry-math

Component: packages: optional

Author: Andrey Novoseltsev

Reviewer: Dmitrii Pasechnik

Merged: sage-5.6.beta0

Issue created by migration from https://trac.sagemath.org/ticket/13234

dimpase commented 12 years ago
comment:2

-static is not supported on MacOSX. There one gets:

...
ar -cr libnormaliz.a cone_property.o hilbert_series.o libnormaliz-templated.o
make normaliz
g++  -I/usr/local/src/sage/sage-5.2.rc0/local/include  -Wall -pedantic -Wno-long-long -O3 -funroll-loops -fopenmp -Wall -pedantic -Wno-long-long -O3 -funroll-loops -fopenmp -static Normaliz.cpp libnormaliz/libnormaliz.a -lgmpxx -lgmp -o normaliz
ld: library not found for -lcrt0.o
collect2: ld returned 1 exit status
make[1]: *** [normaliz] Error 1
make: *** [linknormaliz] Error 2
Error building Normaliz.

It's probably better to build a dynamic library.

dimpase commented 12 years ago
comment:3

Replying to @dimpase:

-static is not supported on MacOSX.

The file source/Makefile.configuration contains lines

##for mac link libgcc not static
NORMFLAGS = -static
#NORMFLAGS = -static-libgcc

If I set switch NORMFLAGS = -static-libgcc then on MacOSX 10.6.8 the spkg builds OK. It's a trivial matter to add an OS recognition to spkg-install and patch the said file if one happens to be on OSX.

novoselt commented 12 years ago
comment:4

Winfried has also suggested to just remove this static option, I've updated the spkg and rewrote the installation script based on pyopenssl.

dimpase commented 12 years ago
comment:5

OK, it builds on MacOSX 10.6. (with Sage 5.4.rc0). However, if I try to use the provided in the spkg Macaulay2 package Normaliz, it does not seem to work. I cd to the directory containing Normaliz.m2, start a standalone M2 version 1.4 within Sage shell, and then I get

i10 : installPackage "Normaliz"
stdio:11:1:(3): error: makeDocumentTag: package cannot be determined: 'Normaliz'
stdio:4:16-4:24: here is the first use of 'Normaliz'

I don't know enough M2 to know how to deal with it.

EDIT: it could be that this just means that a version of Normaliz is already present in this instance of M2 (and indeed, it is). So just ignore this, I guess. We'll sort it out when M2 Sage spkg will be ready.

dimpase commented 12 years ago
comment:6

As well, I don't know how to properly handle the Singular interface. Note that Normaliz provides an interface to Singular, in src/Singular/normaliz.lib.

On the other hand, Singular spkg provides normaliz.lib for version 2.7 of Normaliz. (Which is probably useless without Normaliz installed, and ought to be removed, but this is not for this ticket). I think one should make this spkg install normaliz.lib to its proper place in $SAGE_LOCAL.

Regarding M2 support, it can wait, but this one definitely needs work. I'd be happy to have another look after this is implemented.

novoselt commented 12 years ago
comment:7

It seems to me that M2 just wants to have normaliz executable during installation, the interface package is included in M2 and does not have to be installed from normaliz one. So far my goal was just to have normaliz in sage/local/bin, but I'll look at the Singular library as well. I suspect it may be independent of the rest of normaliz - it is quite a compact program.

dimpase commented 12 years ago
comment:8

Replying to @novoselt:

It seems to me that M2 just wants to have normaliz executable during installation, the interface package is included in M2 and does not have to be installed from normaliz one. So far my goal was just to have normaliz in sage/local/bin, but I'll look at the Singular library as well. I suspect it may be independent of the rest of normaliz - it is quite a compact program.

not according to the following lines

@*Singular and Normaliz exchange data via files. These files are automatically
created and erased behind the scenes. 

in Singular/singular.lib

So it is not something independent.

novoselt commented 11 years ago
comment:9

Added library copying - I misunderstood what was going on, I thought it was a library file as in "objective code", not "Singular module".

dimpase commented 11 years ago
comment:10

after installing the spkg, one can call normaliz from Sage's singular_console(), (or just as sage -singular --- the results are the same) but results don't always make sense. E.g.

sage: singular_console()
                     SINGULAR                                 /  Development
 A Computer Algebra System for Polynomial Computations       /   version 3-1-5
                                                           0<
 by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \   Jul 2012
FB Mathematik der Universitaet, D-67653 Kaiserslautern        \
> LIB "normaliz.lib";
// ** loaded /usr/local/src/sage/sage-5.5.rc0/local/share/singular/normaliz.lib $Id$
> ring R=0,(x,y,z,t),dp;
> ideal I=x^2,y^2,z^3;
> list l=intclMonIdeal(I);
> showNuminvs();
hilbert_basis_elements : 2
number_extreme_rays : 2
rank : 2
index : 1
number_support_hyperplanes : 2
size_triangulation : 1
sum_dets : 1
graded : 1
degree_1_elements : 2
grading : 1,-1
grading_denom : 1
multiplicity : 1
multiplicity_denom : 1
hilbert_series_num : 1
hilbert_series_denom : 1,1
primary : 1
ideal_multiplicity : 2
> 

whereas according to Singular docs the output should be

showNuminvs();
==> hilbert_basis_elements : 9
==> number_extreme_rays : 6
==> rank : 4
==> index : 1
==> number_support_hyperplanes : 5
==> homogeneous : 0
==> primary : 1
==> ideal_multiplicity : 12
dimpase commented 11 years ago

Attachment: t.in.gz

normaliz input for (x2,y2,z^3)

dimpase commented 11 years ago
comment:11

If I try running normaliz directly on the input (roughly) corresponding to this example of the monomial ideal (see attachment: t.in), I get results consistent with Singular docs, see the attachment: t.out. So this looks like an interface problem.

dimpase commented 11 years ago

normaliz output

dimpase commented 11 years ago
comment:12

Attachment: t.out.gz

I also noticed that some normaliz.lib functions are not working as advertised, e.g.

> startNmz();
   ? open: Error for link _ of type: ASCII, mode: r, name: nmz_sing_exec.path
   ? cannot read from `nmz_sing_exec.path`
   ? error occurred in or before normaliz.lib::startNmz line 292: `    string s=read(inf); `
   ? expected string-expression. type 'help string;'
   ? leaving normaliz.lib::startNmz
   skipping text from `;` error at token `)`

instead of this. This is probably minor, as normaliz executable is found in the PATH. To make it work I can do

> setNmzDataPath("/tmp/");
> setNmzFilename("blah");
> writeNmzPaths();
> startNmz();
nmz_exec_path not set
nmz_data_path is /tmp/

If I then try the Singular input as above to compute intclMonIdeal(I) I can see that the files /tmp/blah.* created do not make sense. E.g. /tmp/blah.in is as follows:

1
1
2 
3

which makes little sense.

I would not be surprised if this is an upstream (i.e. normaliz) bug.

dimpase commented 11 years ago
comment:13

Replying to @dimpase:

after installing the spkg, one can call normaliz from Sage's singular_console(), (or just as sage -singular --- the results are the same) but results don't always make sense. E.g.

sage: singular_console()
                     SINGULAR                                 /  Development
 A Computer Algebra System for Polynomial Computations       /   version 3-1-5
                                                           0<
 by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \   Jul 2012
FB Mathematik der Universitaet, D-67653 Kaiserslautern        \
> LIB "normaliz.lib";
// ** loaded /usr/local/src/sage/sage-5.5.rc0/local/share/singular/normaliz.lib $Id$
> ring R=0,(x,y,z,t),dp;

If I rather set ring R=0,(x,y,z),dp; then the result is consistent with Singular's manual. So this looks like a documentation bug rather than anything more serious.

dimpase commented 11 years ago

Upstream: Reported upstream. No feedback yet.

novoselt commented 11 years ago
comment:15

I've added a patched based on the file sent to me by Christof Söger. Now I am getting

                     SINGULAR                                 /  Development
 A Computer Algebra System for Polynomial Computations       /   version 3-1-5
                                                           0<
 by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann     \   Jul 2012
FB Mathematik der Universitaet, D-67653 Kaiserslautern        \
> LIB "normaliz.lib";
// ** loaded /home/novoselt/sage-5.5.rc0/local/share/singular/normaliz.lib $Id$
> ring R=0,(x,y,z,t),dp;
> ideal I=x^2,y^2,z^3;
> list l=intclMonIdeal(I);
No grading specified and cannot find one. Disabling some computations!
> showNuminvs();
hilbert_basis_elements : 9
number_extreme_rays : 6
rank : 4
index : 1
number_support_hyperplanes : 5
size_triangulation : 3
sum_dets : 7
graded : 0
primary : 1
ideal_multiplicity : 12
> 

which seems to be consistent with Singular manual.

novoselt commented 11 years ago

Changed upstream from Reported upstream. No feedback yet. to Fixed upstream, but not in a stable release.

novoselt commented 11 years ago

Attachment: spkg-install.gz

For reviewing only

novoselt commented 11 years ago

For reviewing only

dimpase commented 11 years ago
comment:16

Attachment: 01-adjust-size-of-input-matrix-fix.patch.gz

OK, good - but could you please bump up the version to 2.8.p0, as this is not vanilla upstream.

dimpase commented 11 years ago
comment:17

I've made the spkg bumped up version (linked in the ticket description).

dimpase commented 11 years ago

Description changed:

--- 
+++ 
@@ -1,3 +1,3 @@
 Normaliz http://www.mathematik.uni-osnabrueck.de/normaliz/ is one of the dependencies of Macaulay2 (which is also an optional package), but can be of interest on its own as well.

-http://sage.math.washington.edu/home/novoselt/normaliz-2.8.spkg
+Install the spkg from [here](http://sage.math.washington.edu/home/dima/packages/normaliz-2.8.p0.spkg)
dimpase commented 11 years ago

Reviewer: Dmitrii Pasechnik

novoselt commented 11 years ago
comment:18

Thank you for a thorough review and quick responses despite my long pauses, it was a good spkg-exercise for me!

haraldschilly commented 11 years ago
comment:20

I just copied the spkg into the "optional" subdir on the server and mirrors.

jdemeyer commented 11 years ago

Merged: sage-5.6.beta0