- Timestamp:
- Oct 1, 2016, 3:38:13 PM (7 years ago)
- Branches:
- (u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
- Children:
- 438670d77815ff36a3900d811b1db05f098c9a3d
- Parents:
- e946361c872c62f94d3098cd85858e5069cb55fa
- git-author:
- Yue <ren@mathematik.uni-kl.de>2016-10-01 15:38:13+02:00
- git-committer:
- Yue <ren@mathematik.uni-kl.de>2016-10-04 13:10:39+02:00
- Location:
- Singular/LIB
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/polymake.lib
re946361 r78c0d45 5 5 interface to polymake and TOPCOM 6 6 AUTHOR: Thomas Markwig, email: keilen@mathematik.uni-kl.de 7 Yue Ren, email: ren@mathematik.uni-kl.de 7 8 8 9 WARNING: … … 64 65 ellipticNFDB() displays the 16 normal forms of elliptic polygons 65 66 67 PROCEDURES USING POLYMAKE (LOW LEVEL INTERFACE) 68 boundaryLatticePoints() 69 ehrhartPolynomialCoeff() 70 fVectorP() 71 facetVertexLatticeDistances() 72 facetWidth() 73 facetWidths() 74 gorensteinIndex() 75 gorensteinVector() 76 hStarVector() 77 hVector() 78 hilbertBasis() 79 interiorLatticePoints() 80 isBounded() 81 isCanonical() 82 isCompressed() 83 isGorenstein() 84 isLatticeEmpty() 85 isNormal() 86 isReflexive() 87 isSmooth() 88 isTerminal() 89 isVeryAmple() 90 latticeCodegree() 91 latticeDegree() 92 latticePoints() 93 latticeVolume() 94 maximalFace() 95 maximalValue() 96 minimalFace() 97 minimalValue() 98 minkowskiSum() 99 nBoundaryLatticePoints() 100 nHilbertBasis() 101 nInteriorLatticePoints() 102 nLatticePoints() 103 normalFan() 104 vertexAdjacencyGraph() 105 vertexEdgeGraph() 106 visual() 107 66 108 KEYWORDS: polytope; fan; secondary fan; secondary polytope; polymake; 67 109 Newton polytope; Groebner fan … … 91 133 //////////////////////////////////////////////////////////////////////////////// 92 134 93 static proc mod_init () 94 { 135 static proc mod_init() 136 { 137 intvec save=option(get); 138 option(noredefine); 95 139 LIB "customstd.so"; 96 140 LIB "gfanlib.so"; 97 141 LIB "polymake.so"; 142 option(set,save); 98 143 } 99 144 … … 2483 2528 2484 2529 2485 2530 /////////////////////////////////////////////////////////////////////////////// 2531 // 2532 // wrappers for polymake.so 2533 // 2534 /////////////////////////////////////////////////////////////////////////////// 2535 2536 proc boundaryLatticePoints() 2537 "USAGE: boundaryLatticePoints(p); p polytope 2538 ASSUME: isBounded(p)==1 2539 RETURN: intmat, all lattice points on the relative boundary of p 2540 EXAMPLE: example boundaryLatticePoints; shows an example 2541 " 2542 { 2543 2544 } 2545 example 2546 { 2547 "EXAMPLE:"; echo = 2; 2548 intmat M[3][3]= 2549 1,2,-1, 2550 1,-1,2, 2551 1,-1,-1; 2552 polytope p = polytopeViaPoints(M); 2553 boundaryLatticePoints(p); 2554 intmat N[2][3]= 2555 1,2,0, 2556 1,0,2; 2557 polytope q = polytopeViaPoints(N); 2558 boundaryLatticePoints(q); 2559 } 2560 2561 proc ehrhartPolynomialCoeff() 2562 "USAGE: ehrhartPolynomialCoeff(p); p polytope 2563 ASSUME: isBounded(p)==1 2564 RETURN: intvec, all lattice points on the relative boundary of p 2565 EXAMPLE: example ehrhartPolynomialCoeff; shows an example 2566 " 2567 { 2568 2569 } 2570 example 2571 { 2572 "EXAMPLE:"; echo = 2; 2573 intmat M[6][4]= 2574 1,1,1,2, 2575 1,-1,-1,-2, 2576 1,1,0,0, 2577 1,-1,0,0, 2578 1,0,1,0, 2579 1,0,-1,0; 2580 polytope p = polytopeViaPoints(M); 2581 ehrhartPolynomialCoeff(p); 2582 } 2583 2584 proc fVectorP() 2585 "USAGE: fVectorP(p); p polytope 2586 RETURN: intvec, the f-vector or p 2587 EXAMPLE: example fVectorP; shows an example 2588 " 2589 { 2590 2591 } 2592 example 2593 { 2594 "EXAMPLE:"; echo = 2; 2595 intmat M[6][4]= 2596 1,1,1,2, 2597 1,-1,-1,-2, 2598 1,1,0,0, 2599 1,-1,0,0, 2600 1,0,1,0, 2601 1,0,-1,0; 2602 polytope p = polytopeViaPoints(M); 2603 fVectorP(p); 2604 } 2605 2606 proc facetVertexLatticeDistances() 2607 "USAGE: facetVertexLatticeDistances(p); p polytope 2608 RETURN: intmat, encodes the lattice distances between vertices (columns) and facets (rows) of p. 2609 EXAMPLE: example facetVertexLatticeDistances; shows an example 2610 " 2611 { 2612 2613 } 2614 example 2615 { 2616 "EXAMPLE:"; echo = 2; 2617 intmat M[4][3]= 2618 1,2,0, 2619 1,0,1, 2620 1,2,1, 2621 1,0,0; 2622 polytope p = polytopeViaPoints(M); 2623 facetVertexLatticeDistances(p); 2624 } 2625 2626 proc facetWidth() 2627 "USAGE: facetWidth(p); p polytope 2628 ASSUME: isBounded(p)==1 2629 RETURN: int, maximal integral width going over all facet normals 2630 EXAMPLE: example facetWidth; shows an example 2631 " 2632 { 2633 2634 } 2635 example 2636 { 2637 "EXAMPLE:"; echo = 2; 2638 intmat M[4][3]= 2639 1,2,0, 2640 1,0,1, 2641 1,2,1, 2642 1,0,0; 2643 polytope p = polytopeViaPoints(M); 2644 facetWidth(p); 2645 } 2646 2647 proc facetWidths() 2648 "USAGE: facetWidths(p); p polytope 2649 ASSUME: isBounded(p)==1 2650 RETURN: intvec, vector with the integral widths of all facet normals 2651 EXAMPLE: example facetWidths; shows an example 2652 " 2653 { 2654 2655 } 2656 example 2657 { 2658 "EXAMPLE:"; echo = 2; 2659 intmat M[4][3]= 2660 1,2,0, 2661 1,0,1, 2662 1,2,1, 2663 1,0,0; 2664 polytope p = polytopeViaPoints(M); 2665 facetWidths(p); 2666 } 2667 2668 proc gorensteinIndex() 2669 "USAGE: gorensteinIndex(p); p polytope 2670 ASSUME: isGorenstein(p)==1 2671 RETURN: int, a factor n such that n*p+v is reflexive for some translation v 2672 NOTE: the translation v can be computed via gorensteinVector(p) 2673 EXAMPLE: example gorensteinIndex; shows an example 2674 " 2675 { 2676 2677 } 2678 example 2679 { 2680 "EXAMPLE:"; echo = 2; 2681 intmat M[4][3]=1,1,0, 1,0,1, 1,0,0, 1,1,1; 2682 polytope p = polytopeViaPoints(M); 2683 gorensteinIndex(p); 2684 } 2685 2686 proc gorensteinVector() 2687 "USAGE: gorensteinVector(p); p polytope 2688 ASSUME: isGorenstein(p)==1 2689 RETURN: intvec, a vector v such that n*p+v is reflexive for some factor n 2690 NOTE: the factor n can be computed via gorensteinIndex(p) 2691 EXAMPLE: example gorensteinVector; shows an example 2692 " 2693 { 2694 2695 } 2696 example 2697 { 2698 "EXAMPLE:"; echo = 2; 2699 intmat M[4][3]=1,1,0, 1,0,1, 1,0,0, 1,1,1; 2700 polytope p = polytopeViaPoints(M); 2701 gorensteinVector(p); 2702 } 2703 2704 proc hStarVector() 2705 "USAGE: hStarVector(p); p polytope 2706 RETURN: intvec, the h* vector of p 2707 EXAMPLE: example hStarVector; shows an example 2708 " 2709 { 2710 2711 } 2712 example 2713 { 2714 "EXAMPLE:"; echo = 2; 2715 intmat 2716 M[6][4]= 2717 1,1,1,2, 2718 1,-1,-1,-2, 2719 1,1,0,0, 2720 1,-1,0,0, 2721 1,0,1,0, 2722 1,0,-1,0; 2723 polytope p = polytopeViaPoints(M); 2724 hStarVector(p); 2725 } 2726 2727 proc hVector() 2728 "USAGE: hVector(p); p polytope 2729 RETURN: intvec, the h vector of p 2730 EXAMPLE: example hVector; shows an example 2731 " 2732 { 2733 2734 } 2735 example 2736 { 2737 "EXAMPLE:"; echo = 2; 2738 intmat 2739 M[6][4]= 2740 1,1,1,2, 2741 1,-1,-1,-2, 2742 1,1,0,0, 2743 1,-1,0,0, 2744 1,0,1,0, 2745 1,0,-1,0; 2746 polytope p = polytopeViaPoints(M); 2747 hVector(p); 2748 } 2749 2750 proc hilbertBasis() 2751 "USAGE: hilbertBasis(c); c cone 2752 RETURN: intmat, the Hilbert basis of c intersected with Z^n 2753 EXAMPLE: example hilbertBasis; shows an example 2754 " 2755 { 2756 2757 } 2758 example 2759 { 2760 "EXAMPLE:"; echo = 2; 2761 intmat M[3][3]= 2762 1,2,-1, 2763 1,-1,2, 2764 1,-1,-1; 2765 cone c = coneViaPoints(M); 2766 hilbertBasis(c); 2767 } 2768 2769 proc interiorLatticePoints() 2770 "USAGE: interiorLatticePoints(p); p polytope 2771 ASSUME: isBounded(p)==1 2772 RETURN: intmat, all lattice points in the relative interior of p 2773 EXAMPLE: example interiorLatticePoints; shows an example 2774 " 2775 { 2776 2777 } 2778 example 2779 { 2780 "EXAMPLE:"; echo = 2; 2781 intmat M[3][3]= 2782 1,2,-1, 2783 1,-1,2, 2784 1,-1,-1; 2785 polytope p = polytopeViaPoints(M); 2786 interiorLatticePoints(p); 2787 intmat N[2][3]= 2788 1,2,0, 2789 1,0,2; 2790 polytope q = polytopeViaPoints(N); 2791 interiorLatticePoints(q); 2792 } 2793 2794 proc isBounded() 2795 "USAGE: isBounded(p); p polytope 2796 RETURN: 1, if p is bounded; 0 otherwise 2797 EXAMPLE: example isBounded; shows an example 2798 " 2799 { 2800 2801 } 2802 example 2803 { 2804 "EXAMPLE:"; echo = 2; 2805 intmat M[4][4]= 2806 1,1,0,0, 2807 1,0,1,0, 2808 1,0,0,1, 2809 1,-1,-1,-1; 2810 polytope p = polytopeViaPoints(M); 2811 isBounded(p); 2812 M= 2813 1,1,0,0, 2814 1,0,1,0, 2815 0,0,0,1, 2816 1,-1,-1,-1; 2817 p = polytopeViaPoints(M); 2818 isBounded(p); 2819 } 2820 2821 proc isCanonical() 2822 "USAGE: isCanonical(p); p polytope 2823 RETURN: 1, if p has exactly one interior lattice point; 0 otherwise 2824 EXAMPLE: example isCanonical; shows an example 2825 " 2826 { 2827 2828 } 2829 example 2830 { 2831 "EXAMPLE:"; echo = 2; 2832 intmat M[6][4]= 2833 1,1,1,2, 2834 1,-1,-1,-2, 2835 1,1,0,0, 2836 1,-1,0,0, 2837 1,0,1,0, 2838 1,0,-1,0; 2839 polytope p = polytopeViaPoints(M); 2840 isCanonical(p); 2841 isReflexive(p); 2842 intmat N[3][3]= 2843 1,2,0, 2844 1,0,2, 2845 1,-2,-2; 2846 polytope q = polytopeViaPoints(N); 2847 isCanonical(q); 2848 } 2849 2850 proc isCompressed() 2851 "USAGE: isCompressed(p); p polytope 2852 RETURN: 1, if p has maximal facet width 1; 0 otherwise 2853 EXAMPLE: example isCompressed; shows an example 2854 " 2855 { 2856 2857 } 2858 example 2859 { 2860 "EXAMPLE:"; echo = 2; 2861 intmat M[4][3]= 2862 1,2,0, 2863 1,0,1, 2864 1,2,1, 2865 1,0,0; 2866 polytope p = polytopeViaPoints(M); 2867 isCompressed(p); 2868 intmat N[4][3]= 2869 1,1,0, 2870 1,0,1, 2871 1,1,1, 2872 1,0,0; 2873 polytope q = polytopeViaPoints(N); 2874 isCompressed(q); 2875 } 2876 2877 proc isGorenstein() 2878 "USAGE: isGorenstein(p); p polytope 2879 RETURN: 1, if p is Gorenstein, i.e. reflexive modulo dilatation and translation; 0 otherwise 2880 EXAMPLE: example isGorenstein; shows an example 2881 " 2882 { 2883 2884 } 2885 example 2886 { 2887 "EXAMPLE:"; echo = 2; 2888 intmat M[4][3]= 2889 1,1,0, 2890 1,0,1, 2891 1,0,0, 2892 1,1,1; 2893 polytope p = polytopeViaPoints(M); 2894 isGorenstein(p); 2895 intmat N[3][3]= 2896 1,2,0, 2897 1,0,2, 2898 1,-2,-2; 2899 polytope q = polytopeViaPoints(N); 2900 isGorenstein(q); 2901 } 2902 2903 proc isLatticeEmpty() 2904 "USAGE: isLatticeEmpty(p); p polytope 2905 RETURN: 1, if p contains no lattice points other than the vertices; 0 otherwise 2906 EXAMPLE: example isLatticeEmpty; shows an example 2907 " 2908 { 2909 2910 } 2911 example 2912 { 2913 "EXAMPLE:"; echo = 2; 2914 intmat M[4][3]= 2915 1,1,0, 2916 1,1,1, 2917 1,0,1, 2918 1,0,0; 2919 polytope p = polytopeViaPoints(M); 2920 isLatticeEmpty(p); 2921 intmat N[4][3]= 2922 1,1,0, 2923 1,2,1, 2924 1,0,1, 2925 1,0,0; 2926 polytope q = polytopeViaPoints(N); 2927 isLatticeEmpty(q); 2928 } 2929 2930 proc isNormal() 2931 "USAGE: isNormal(p); p polytope 2932 RETURN: 1, if the projective toric variety defined by p is projectively normal; 0 otherwise 2933 EXAMPLE: example isNormal; shows an example 2934 " 2935 { 2936 2937 } 2938 example 2939 { 2940 "EXAMPLE:"; echo = 2; 2941 intmat M[6][4]= 2942 1,1,1,2, 2943 1,-1,-1,-2, 2944 1,1,0,0, 2945 1,-1,0,0, 2946 1,0,1,0, 2947 1,0,-1,0; 2948 polytope p = polytopeViaPoints(M); 2949 isNormal(p); 2950 } 2951 2952 proc isReflexive() 2953 "USAGE: isReflexive(p); p polytope 2954 RETURN: 1, if p is reflexive; 0 otherwise 2955 EXAMPLE: example isReflexive; shows an example 2956 " 2957 { 2958 2959 } 2960 example 2961 { 2962 "EXAMPLE:"; echo = 2; 2963 intmat M[4][4]= 2964 1,1,0,0, 2965 1,0,1,0, 2966 1,0,0,1, 2967 1,-1,-1,-1; 2968 polytope p = polytopeViaPoints(M); 2969 isReflexive(p); 2970 intmat N[4][4]= 2971 1,2,0,0, 2972 1,0,2,0, 2973 1,0,0,2, 2974 1,-2,-2,-2; 2975 polytope q = polytopeViaPoints(M); 2976 isReflexive(q); 2977 } 2978 2979 proc isSmooth() 2980 "USAGE: isSmooth(c); c cone 2981 isSmooth(f); f fan 2982 isSmooth(p); p polytope 2983 RETURN: 1, if the input is smooth; 0 otherwise 2984 EXAMPLE: example isSmooth; shows an example 2985 " 2986 { 2987 2988 } 2989 example 2990 { 2991 "EXAMPLE:"; echo = 2; 2992 intmat M1[2][2]= 2993 1,0, 2994 0,1; 2995 cone c1 = coneViaPoints(M1); 2996 isSmooth(c1); 2997 intmat M2[3][3]= 2998 1,0, 2999 1,2; 3000 cone c2 = coneViaPoints(M2); 3001 fan F1 = emptyFan(2); 3002 insertCone(F1,c1); 3003 isSmooth(F1); 3004 fan F2 = emptyFan(3); 3005 insertCone(F2,c2); 3006 isSmooth(F2); 3007 intmat Mp[3][3]= 3008 1,-2,-3, 3009 1,1,0, 3010 1,0,1; 3011 polytope p = polytopeViaPoints(Mp); 3012 isSmooth(p); 3013 fan F = normalFan(p); 3014 isSmooth(F); 3015 intmat Mq[4][3]= 3016 1,2,0, 3017 1,0,1, 3018 1,2,1, 3019 1,0,0; 3020 polytope q = polytopeViaPoints(Mq); 3021 isSmooth(q); 3022 } 3023 3024 proc isTerminal() 3025 "USAGE: isTerminal(p); p polytope 3026 RETURN: 1, if p has exactly one interior lattice point and all other lattice points are vertices; 0 otherwise 3027 EXAMPLE: example isTerminal; shows an example 3028 " 3029 { 3030 3031 } 3032 example 3033 { 3034 "EXAMPLE:"; echo = 2; 3035 intmat M[6][4]= 3036 1,1,1,2, 3037 1,-1,-1,-2, 3038 1,1,0,0, 3039 1,-1,0,0, 3040 1,0,1,0, 3041 1,0,-1,0; 3042 polytope p = polytopeViaPoints(M); 3043 isTerminal(p); 3044 isReflexive(p); 3045 intmat N[6][4]= 3046 1,1,1,2, 3047 1,-1,-1,-2, 3048 1,1,1,0, 3049 1,-1,-1,0, 3050 1,-1,1,0, 3051 1,1,-1,0; 3052 polytope q = polytopeViaPoints(N); 3053 isTerminal(q); 3054 isCanonical(q); 3055 } 3056 3057 proc isVeryAmple() 3058 "USAGE: isVeryAmple(p); p polytope 3059 RETURN: 1, if p is very ample; 0 otherwise 3060 EXAMPLE: example isVeryAmple; shows an example 3061 " 3062 { 3063 3064 } 3065 example 3066 { 3067 "EXAMPLE:"; echo = 2; 3068 intmat M[3][3]= 3069 1,1,0, 3070 1,0,1, 3071 1,-1,-1; 3072 polytope p = polytopeViaPoints(M); 3073 isVeryAmple(p); 3074 intmat N[3][4]= 3075 1,1,0,0, 3076 1,0,1,0, 3077 1,1,1,2; 3078 polytope q = polytopeViaPoints(N); 3079 isVeryAmple(q); 3080 } 3081 3082 proc latticeCodegree() 3083 "USAGE: latticeCodegree(p); p polytope 3084 RETURN: int, the smalles number n such that n*p has a relative interior lattice point 3085 NOTE: dimension(p)+1==latticeDegree(p)+latticeCodegree(p) 3086 EXAMPLE: example latticeCodegree; shows an example 3087 " 3088 { 3089 3090 } 3091 example 3092 { 3093 "EXAMPLE:"; echo = 2; 3094 intmat M[4][3]= 3095 1,1,0, 3096 1,1,1, 3097 1,0,1, 3098 1,0,0; 3099 polytope p = polytopeViaPoints(M); 3100 latticeCodegree(p); 3101 intmat N[4][4]= 3102 1,1,0,0, 3103 1,0,1,0, 3104 1,0,0,1, 3105 1,0,0,0; 3106 polytope q = polytopeViaPoints(N); 3107 latticeCodegree(q); 3108 } 3109 3110 proc latticeDegree() 3111 "USAGE: latticeDegree(p); p polytope 3112 RETURN: int, the degree of the Ehrhart polynomial of p 3113 NOTE: dimension(p)+1==latticeDegree(p)+latticeCodegree(p) 3114 EXAMPLE: example latticeDegree; shows an example 3115 " 3116 { 3117 3118 } 3119 example 3120 { 3121 "EXAMPLE:"; echo = 2; 3122 intmat M[4][3]= 3123 1,1,0, 3124 1,1,1, 3125 1,0,1, 3126 1,0,0; 3127 polytope p = polytopeViaPoints(M); 3128 latticeDegree(p); 3129 intmat N[4][4]= 3130 1,1,0,0, 3131 1,0,1,0, 3132 1,0,0,1, 3133 1,0,0,0; 3134 polytope q = polytopeViaPoints(N); 3135 latticeDegree(q); 3136 } 3137 3138 proc latticePoints() 3139 "USAGE: latticePoints(p); p polytope 3140 ASSUME: isBounded(p)==1 3141 RETURN: intmat, all lattice points in p 3142 EXAMPLE: example latticePoints; shows an example 3143 " 3144 { 3145 3146 } 3147 example 3148 { 3149 "EXAMPLE:"; echo = 2; 3150 intmat M[3][3]= 3151 1,2,-1, 3152 1,-1,2, 3153 1,-1,-1; 3154 polytope p = polytopeViaPoints(M); 3155 latticePoints(p); 3156 intmat N[2][3]= 3157 1,2,0, 3158 1,0,2; 3159 polytope q = polytopeViaPoints(N); 3160 latticePoints(q); 3161 } 3162 3163 proc latticeVolume() 3164 "USAGE: latticeVolume(p); p polytope 3165 ASSUME: isBounded(p)==1 3166 RETURN: int, the lattice volume of p 3167 EXAMPLE: example latticeVolume; shows an example 3168 " 3169 { 3170 3171 } 3172 example 3173 { 3174 "EXAMPLE:"; echo = 2; 3175 intmat M[4][3]= 3176 1,1,0, 3177 1,1,1, 3178 1,0,1, 3179 1,0,0; 3180 polytope p = polytopeViaPoints(M); 3181 latticeVolume(p); 3182 intmat N[4][3]= 3183 1,1,0, 3184 1,2,1, 3185 1,0,1, 3186 1,0,0; 3187 polytope q = polytopeViaPoints(N); 3188 latticeVolume(q); 3189 intmat W[4][4]= 3190 1,1,0,0, 3191 1,0,1,0, 3192 1,0,0,1, 3193 1,0,0,0; 3194 polytope r = polytopeViaPoints(W); 3195 latticeVolume(r); 3196 } 3197 3198 proc maximalFace() 3199 "USAGE: maximalFace(p,v); p polytope, v intvec 3200 ASSUME: v lies in the negative dual tail cone of p 3201 RETURN: intmat, vertices of the face of p on which the linear form v is maximal 3202 NOTE: the maximal face is independent of the first coordinate of v 3203 since p is considered as a polytope in the plane (first coordinate) = 1. 3204 EXAMPLE: example maximalFace; shows an example 3205 " 3206 { 3207 3208 } 3209 example 3210 { 3211 "EXAMPLE:"; echo = 2; 3212 intmat M[3][3]= 3213 1,1,0, 3214 1,0,1, 3215 1,-1,-1; 3216 intvec v = 0,1,1; 3217 polytope p = polytopeViaPoints(M); 3218 maximalFace(p,v); 3219 intvec w = -5,1,1; 3220 maximalFace(p,w); 3221 } 3222 3223 proc maximalValue() 3224 "USAGE: maximalValue(p,v); p polytope, v intvec 3225 ASSUME: v lies in the negative dual tail cone of p 3226 RETURN: intmat, vertices of the face of p on which the linear form v is maximal 3227 NOTE: first coordinate of v corresponds to a shift of the maximal value 3228 since p is considered as a polytope in the plane (first coordinate) = 1. 3229 EXAMPLE: example maximalValue; shows an example 3230 " 3231 { 3232 3233 } 3234 example 3235 { 3236 "EXAMPLE:"; echo = 2; 3237 intmat M[3][3]= 3238 1,1,0, 3239 1,0,1, 3240 1,-1,-1; 3241 intvec v = 0,1,1; 3242 polytope p = polytopeViaPoints(M); 3243 maximalValue(p,v); 3244 intvec w = -5,1,1; 3245 maximalValue(p,w); 3246 } 3247 3248 proc minimalFace() 3249 "USAGE: minimalFace(p,v); p polytope, v intvec 3250 ASSUME: v lies in the dual tail cone of p 3251 RETURN: intmat, vertices of the face of p on which the linear form v is minimal 3252 NOTE: the minimal face is independent of the first coordinate of v 3253 since p is considered as a polytope in the plane (first coordinate) = 1. 3254 EXAMPLE: example minimalFace; shows an example 3255 " 3256 { 3257 3258 } 3259 example 3260 { 3261 "EXAMPLE:"; echo = 2; 3262 intmat M[3][3]= 3263 1,1,0, 3264 1,0,1, 3265 1,-1,-1; 3266 intvec v = 0,-1,-1; 3267 polytope p = polytopeViaPoints(M); 3268 minimalFace(p,v); 3269 intvec w = 5,-1,-1; 3270 minimalFace(p,w); 3271 } 3272 3273 proc minimalValue() 3274 "USAGE: minimalValue(p,v); p polytope, v intvec 3275 ASSUME: v lies in the negative dual tail cone of p 3276 RETURN: intmat, vertices of the face of p on which the linear form v is minimal 3277 NOTE: first coordinate of v corresponds to a shift of the minimal value 3278 since p is considered as a polytope in the plane (first coordinate) = 1. 3279 EXAMPLE: example minimalValue; shows an example 3280 " 3281 { 3282 3283 } 3284 example 3285 { 3286 "EXAMPLE:"; echo = 2; 3287 intmat M[3][3]= 3288 1,1,0, 3289 1,0,1, 3290 1,-1,-1; 3291 intvec v = 0,-1,-1; 3292 polytope p = polytopeViaPoints(M); 3293 minimalValue(p,v); 3294 intvec w = 5,-1,-1; 3295 minimalValue(p,w); 3296 } 3297 3298 proc minkowskiSum() 3299 "USAGE: minkowskiSum(c,d); c cone, d cone 3300 minkowskiSum(c,q); c cone, q polytope 3301 minkowskiSum(p,d); p polytope, d cone 3302 minkowskiSum(p,q); p polytope, q polytope 3303 ASSUME: input arguments have the same ambient dimension 3304 RETURN: cone, if both inputs are cones; polytope, otherwise 3305 the minkowski sum of the two input arguments 3306 EXAMPLE: example minkowskiSum; shows an example 3307 " 3308 { 3309 3310 } 3311 example 3312 { 3313 "EXAMPLE:"; echo = 2; 3314 intmat M[3][4]= 3315 1,1,0,0, 3316 1,0,1,0, 3317 1,0,0,0; 3318 intmat N[3][4]= 3319 1,0,0,1, 3320 1,-1,-1,-1, 3321 1,0,0,0; 3322 polytope p = polytopeViaPoints(M); 3323 polytope q = polytopeViaPoints(N); 3324 vertices(minkowskiSum(p,q)); 3325 } 3326 3327 proc nBoundaryLatticePoints() 3328 "USAGE: nBoundaryLatticePoints(p); p polytope 3329 ASSUME: isBounded(p)==1 3330 RETURN: int, the number of lattice points in the relative boundary of p 3331 EXAMPLE: example nBoundaryLatticePoints; shows an example 3332 " 3333 { 3334 3335 } 3336 example 3337 { 3338 "EXAMPLE:"; echo = 2; 3339 intmat M[3][3]= 3340 1,2,-1, 3341 1,-1,2, 3342 1,-1,-1; 3343 polytope p = polytopeViaPoints(M); 3344 nBoundaryLatticePoints(p); 3345 intmat N[2][3]= 3346 1,2,0, 3347 1,0,2; 3348 polytope q = polytopeViaPoints(N); 3349 nBoundaryLatticePoints(q); 3350 } 3351 3352 proc nHilbertBasis() 3353 "USAGE: nHilbertBasis(c); c cone 3354 RETURN: int, the number of elements in the Hilbert basis of c intersected with Z^n 3355 EXAMPLE: example nHilbertBasis; shows an example 3356 " 3357 { 3358 3359 } 3360 example 3361 { 3362 "EXAMPLE:"; echo = 2; 3363 intmat M[3][3]= 3364 1,2,-1, 3365 1,-1,2, 3366 1,-1,-1; 3367 cone c = coneViaPoints(M); 3368 nHilbertBasis(c); 3369 } 3370 3371 proc nInteriorLatticePoints() 3372 "USAGE: nInteriorLatticePoints(p); p polytope 3373 ASSUME: isBounded(p)==1 3374 RETURN: int, the number of lattice points in the relative interior of p 3375 EXAMPLE: example nInteriorLatticePoints; shows an example 3376 " 3377 { 3378 3379 } 3380 example 3381 { 3382 "EXAMPLE:"; echo = 2; 3383 intmat M[3][3]= 3384 1,2,-1, 3385 1,-1,2, 3386 1,-1,-1; 3387 polytope p = polytopeViaPoints(M); 3388 nInteriorLatticePoints(p); 3389 intmat N[2][3]= 3390 1,2,0, 3391 1,0,2; 3392 polytope q = polytopeViaPoints(N); 3393 nInteriorLatticePoints(q); 3394 } 3395 3396 proc nLatticePoints() 3397 "USAGE: nLatticePoints(p); p polytope 3398 ASSUME: isBounded(p)==1 3399 RETURN: intmat, the number of lattice points in p 3400 EXAMPLE: example nLatticePoints; shows an example 3401 " 3402 { 3403 3404 } 3405 example 3406 { 3407 "EXAMPLE:"; echo = 2; 3408 intmat M[3][3]= 3409 1,2,-1, 3410 1,-1,2, 3411 1,-1,-1; 3412 polytope p = polytopeViaPoints(M); 3413 nLatticePoints(p); 3414 intmat N[2][3]= 3415 1,2,0, 3416 1,0,2; 3417 polytope q = polytopeViaPoints(N); 3418 nLatticePoints(q); 3419 } 3420 3421 proc normalFan() 3422 "USAGE: normalFan(p); p polytope 3423 RETURN: fan, the normal fan of p 3424 EXAMPLE: example normalFan; shows an example 3425 " 3426 { 3427 3428 } 3429 example 3430 { 3431 "EXAMPLE:"; echo = 2; 3432 intmat M[6][4] = 3433 1,1,0,0, 3434 1,0,1,0, 3435 1,0,-1,0, 3436 1,0,0,1, 3437 1,0,0,-1, 3438 1,-1,0,0; 3439 polytope p = polytopeViaPoints(M); 3440 normalFan(p); 3441 } 3442 3443 proc vertexAdjacencyGraph() 3444 "USAGE: vertexAdjacencyGraph(p); p polytope 3445 RETURN: list, the first entry is a bigintmat containing all vertices as row vectors, and therefore assigning all vertices an integer. 3446 the second entry is a list of intvecs representing the adjacency graph of the vertices of p, 3447 the intvec in position i contains all vertices j which are connected to vertex i via an edge of p. 3448 EXAMPLE: example vertexAdjacencyGraph; shows an example 3449 " 3450 { 3451 3452 } 3453 example 3454 { 3455 "EXAMPLE:"; echo = 2; 3456 intmat M[6][4] = 3457 1,1,0,0, 3458 1,0,1,0, 3459 1,0,-1,0, 3460 1,0,0,1, 3461 1,0,0,-1, 3462 1,-1,0,0; 3463 polytope p = polytopeViaPoints(M); 3464 vertexAdjacencyGraph(p); 3465 } 3466 3467 proc vertexEdgeGraph() 3468 "USAGE: vertexEdgeGraph(p); p polytope 3469 RETURN: list, the first entry is a bigintmat containing all vertices as row vectors, and therefore assigning all vertices an integer. 3470 the second entry is a list of intvecs representing the edge graph of the vertices of p, 3471 each intvec represents an edge of p connecting vertex i with vertex j. 3472 EXAMPLE: example vertexEdgeGraph; shows an example 3473 " 3474 { 3475 3476 } 3477 example 3478 { 3479 "EXAMPLE:"; echo = 2; 3480 intmat M[6][4] = 3481 1,1,0,0, 3482 1,0,1,0, 3483 1,0,-1,0, 3484 1,0,0,1, 3485 1,0,0,-1, 3486 1,-1,0,0; 3487 polytope p = polytopeViaPoints(M); 3488 vertexEdgeGraph(p); 3489 } 3490 3491 3492 proc visual() 3493 "USAGE: visual(f); f fan 3494 visual(p); p polytope 3495 ASSUME: ambientDimension(f) resp ambientDimension(p) less or equal 3 3496 RETURN: none 3497 EXAMPLE: example visual; shows an example 3498 " 3499 { 3500 3501 } 3502 example 3503 { 3504 "EXAMPLE:"; echo = 2; 3505 intmat M[6][4] = 3506 1,1,0,0, 3507 1,0,1,0, 3508 1,0,-1,0, 3509 1,0,0,1, 3510 1,0,0,-1, 3511 1,-1,0,0; 3512 polytope p = polytopeViaPoints(M); 3513 // visual(p); 3514 fan f = normalFan(p); 3515 // visual(f); 3516 }
Note: See TracChangeset
for help on using the changeset viewer.