File: README.md

package info (click to toggle)
normaliz 3.9.4%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 27,624 kB
  • sloc: cpp: 39,173; makefile: 2,008; python: 715; sh: 6
file content (154 lines) | stat: -rw-r--r-- 4,874 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
[![Build Status](https://github.com/Normaliz/PyNormaliz/workflows/Run%20tests/badge.svg)](https://github.com/Normaliz/PyNormaliz/actions)

# PyNormaliz - A python interface to Normaliz


PyNormaliz provides an interface to [Normaliz](https://www.normaliz.uni-osnabrueck.de) via libNormaliz.
It offers the complete functionality of Normaliz, and can be used interactively from python.
For a first example, see [this introduction](doc/PyNormaliz_Tutorial.pdf) by Richard Sieg (Slighty outdated: for the installation follow the instructions below).

A full documentation is conatined in [Appendix E](doc/PyNormaliz.pdf) of the Normaliz manial.


## Requirements

* python 3.4 or higher
* Normaliz 3.9.0 or higher <https://github.com/Normaliz/Normaliz/releases>

The source packages of the Normaliz realeases contain PyNormaliz.

## Installation

The PyNormaliz install script assumes that you have executed

    ./install_normaliz_with_eantic.sh

within the Normaliz directory. To install PyNormaliz navigate to the Normaliz directory and type

    ./install_pynormaliz.sh --user

## Usage

The command Cone creates a cone (and a lattice), and the member functions
of Cone compute its properties. For a full list of input and output
properties, see the Normaliz manual.

Start by

    import PyNormaliz
    from PyNormaliz import *

To create a simple example, type

    C = Cone(cone = [[1,0],[0,1]])


All possible Normaliz input types can be given as keyword arguments.

The member functions allow the computation of the data of our cone.  For example,

    C.HilbertBasis()

returns what its name says:

    [[0, 1], [1, 0]]

is the matrix of the two Hilbert basis vectors. The ouput matrices of PyNormaliz can be used also in Normaliz input files.

One can pass options to the compute functions as in

    C.HilbertSeries(HSOP = True)

Note that some Normaliz output types must be specially encoded for python. Our Hilbert Series is returned as

    [[1], [1, 1], 0]

to be read as follows: [1] is the numerator polynomial, [1,1] is the vector of exponents of t that occur in the denominator, which is (1-t)(1-t) in our case, and 0 is the shift.  So the Hilbert series is given by the rational function 1/(1-t)(1-t). (Aoso see ee [this introduction](doc/PyNormaliz_Tutorial.pdf).) But we can use

    print_series(C.HilbertSeries(HSOP = True))
    
with the result

        (1)
    ---------
    (1 - t)^2


One can also compute several data simultaneously and specify options ("PrimalMode" only added as an example, not because ot is particularly useful here):

    C.Compute("LatticePoints", "Volume", "PrimalMode")
    
Then

    C.Volume()
    
with the result

    1

This is the lattice length of the diagonal in the square. The euclidean length, that has been computed simultaneously, is returned by

    C.EuclideanVolume()
    
with the expected value

    '1.4142'
    
Floating point numbers are formatted with 4 decimal places and returned as strings (may change). If you want the euclideal volume at the maximum floating point precision, you can use the low level interface which is intermediate between the class Cone and libnormaliz:

    NmzResult(C.cone,"EuclideanVolume")
    1.4142135623730951
    
One can find out whether a single goal has been computed by asking

    C.IsComputed("Automorphisms")
    False
    
If you use Compute instead of IsComputed, then Normaliz tries to compute the goal, and there are situations in which the computation is undesirable.

Algebraic polyhedra can be computed by PyNormaliz as well:

    nf = [ "a2-2", "a", "1.4+/-0.1" ]
    D = Cone( number_field = nf, cone = [["1/7a+3/2", "-5a"],["4/83a-1","97/81"]])

It is important to note that fractions and algebraic numbers must be encoded as strings for the input.

    S = D.SupportHyperplanes()
    S
    [['-1470/433*a+280/433', '-1'], ['-32204/555417*a-668233/555417', '-1']]

Very hard to read! Somewhat better:

    print_matrix(S)
    
              -1470/433*a+280/433 -1
    -32204/555417*a-668233/555417 -1

But we can also get floating point approximations:

    print_matrix(D.SuppHypsFloat())

    -4.1545 -1.0000
    -1.2851 -1.0000

By using Python functions, the functionality of Normaliz can be extended. For example, 
    
    def intersection(cone1, cone2):
        intersection_ineq = cone1.SupportHyperplanes()+cone2.SupportHyperplanes()
        intersection_equat = cone1.Equations()+cone2.Equations()
        C = Cone(inequalities = intersection_ineq, equations = intersection_equat)
        return C
        
computes the intersection of two cones. So

    C1 = Cone(cone=[[1,2],[2,1]])
    C2 = Cone(cone=[[1,1],[1,3]])
    intersection(C1,C2).ExtremeRays()
    
yeilds the result

    [[1, 1], [1, 2]]
    
If you want to see what Normaliz is doing (especually in longer computations) activate the terminal output by

    C.setVerbose(True)