application: common

This artificial application gathers functionality shared by many "real" applications. While most users can probably do without looking into this, you may find some useful functions here.

Objects

  •  
    Category: Combinatorics

    Base class for permutations of `big' objects

    Properties of PermBase

    •  
      PERMUTATION: Array<Int>

      Mapping of features stored in this subobject onto their order in the parent (non-permuted) object. The features to be permuted can be any discrete objects with identity imparted by their involvement in a larger structure, like graph nodes, cone rays, facets, complex celles, etc.

  •  
    Category: Visualization

    The common base class of all visual objects composed of several simpler objects. Instances of such classes can carry default decoration attributes applied to all contained objects.

    derived from: Visual::Object
  •  
    Category: Visualization

    The common base class of all visualization artifacts produced by various user methods like VISUAL, VISUAL_GRAPH, SCHLEGEL, etc. Visual objects can be passed to functions explicitly calling visualization software like jreality() or povray().

User Functions

  •  
    db_get_type_information ()

    20171204: Made type_information_key undef by default to allow users to pass the key "default" explicitly, otherwise default keys have the form "default.<collection>" as there may be more than one collection in the db with a default type information entry

  •  
  •  

    These are functions that perform arithmetic computations.

    •  
      ceil (a) → Rational

      The ceiling function. Returns the smallest integral number not smaller than a.

      Parameters
      Rationala
      Returns
      Rational
    •  
      denominator (a) → Integer

      Returns the denominator of a in a reduced representation.

      Parameters
      Rationala
      Returns
      Integer
    •  
      denominator (f) → Polynomial

      Returns the denominator of a RationalFunction f.

      Parameters
      RationalFunctionf
      Returns
      Polynomial
    •  
      denominator (f) → Polynomial

      Returns the denominator of a PuiseuxFraction f.

      Parameters
      PuiseuxFractionf
      Returns
      Polynomial
    •  
      div (a, b) → Div

      Compute the quotient and remainder of a and b in one operation.

      Parameters
      Inta
      Intb
      Returns
      Div

      Example:
      • > $d = div(10,3);> print $d->quot; 3> print $d->rem; 1
    •  
      div_exact (a, b) → Integer

      Computes the ratio of two given integral numbers under the assumption that the dividend is a multiple of the divisor.

      Parameters
      Integera
      Integerb
      a divisor of a
      Returns
      Integer

      Example:
      • > print div_exact(10,5); 2
    •  
      ext_gcd (a, b) → ExtGCD

      Compute the greatest common divisor of two numbers (a,b) and accompanying co-factors.

      Parameters
      Inta
      Intb
      Returns
      ExtGCD

      Example:
      • > $GCD = ext_gcd(15,6); The GCD of the numbers can then be accessed like this:> print $GCD->g; 3 The ExtGCD type also stores the Bezout coefficients (thus integers p and q such that g=a*p+b*q)...> print $GCD->p; 1 print $GCD->q; -2 ...and the quotients k1 of a and k2 of b by g.> print $GCD->k1; 5> print $GCD->k2; 2
    •  
      fac (n) → Integer

      Computes the factorial n! = n·(n-1)·(n-2)·...·2·1.

      Parameters
      Intn
      >=0
      Returns
      Integer
      n!
    •  
      floor (a) → Rational

      The floor function. Returns the smallest integral number not larger than a.

      Parameters
      Rationala
      Returns
      Rational

      Example:
      • > print floor(1.8); 1
    •  
      gcd (a, b) → Int

      Computes the greatest common divisor of two integers.

      Parameters
      Inta
      Intb
      Returns
      Int

      Example:
      • > print gcd(6,9); 3
    •  
      gcd (v) → Element

      Compute the greatest common divisor of the elements of the given vector.

      Parameters
      Vector<Element>v
      Returns
      Element

      Example:
      • > $v = new Vector<Int>(3,6,9);> print gcd($v); 3
    •  
      gcd (p, q) → UniPolynomial

      Returns the greatest common divisor of two univariate polynomials.


      Example:
      • We create two UniPolynomials with said coefficient and exponent type:> $p = new UniPolynomial<Rational,Int>([2,2],[3,2]);> $q = new UniPolynomial<Rational,Int>([6,4],[4,2]); Printing them reveals what the constructor does:> print $p; 2*x^3 + 2*x^2> print $q; 6*x^4 + 4*x^2 Now we can calculate their gcd:> print gcd($p,$q); x^2
    •  
      get_var_names () → Array<String>

      Get the current list of variable names used for pretty printing and string parsing of the given polynomial class

    •  
      isfinite (a) → Bool

      Check whether the given number has a finite value.

      Parameters
      SCALARa
      Returns
      Bool

      Example:
      • > print isfinite('inf'); false> print isfinite(23); true
    •  
      isinf (a) → Int

      Check whether the given number has an infinite value. Return -1/+1 for infinity and 0 for all finite values.

      Parameters
      SCALARa
      Returns
      Int

      Example:
      • > print isinf('inf'); 1> print isinf(23); 0
    •  
      is_one (s) → Bool

      Compare with the one (1) value of the corresponding data type.

      Parameters
      SCALARs
      Returns
      Bool
    •  
      is_zero (s) → Bool

      Compare with the zero (0) value of the corresponding data type.

      Parameters
      SCALARs
      Returns
      Bool
    •  
      lcm (a, b) → Int

      Computes the least common multiple of two integers.

      Parameters
      Inta
      Intb
      Returns
      Int

      Example:
      • > print lcm(6,9); 18
    •  
      lcm (v) → Element

      Compute the least common multiple of the elements of the given vector.

      Parameters
      Vector<Element>v
      Returns
      Element

      Example:
      • > $v = new Vector<Integer>(1,3,6,9);> print lcm($v); 18
    •  
      local_var_names (names ...)

      Set the list of variable names for given polynomial class temporarily. The existing name list or the default scheme is restored at the end of the current user cycle, similarly to core::prefer_now.

      Parameters
      Stringnames ...
      variable names, see set_var_names.
    •  
      monomials <Coefficient, Exponent> (n) → UniPolynomial<Coefficient,Exponent>

      Create degree one monomials of the desired polynomial type.

      Type Parameters
      Coefficient
      The polynomial coefficient type. Rational by default.
      Exponent
      The exponent type. Int by default.
      Parameters
      Intn
      The number of variables
      Returns
      UniPolynomial<Coefficient,Exponent>
      when n == 1, Polynomial<Coefficient,Exponent> when n > 1
    •  
      numerator (a) → Integer

      Returns the numerator of a in a reduced representation.

      Parameters
      Rationala
      Returns
      Integer
    •  
      numerator (f) → Polynomial

      Returns the numerator of a RationalFunction f.

      Parameters
      RationalFunctionf
      Returns
      Polynomial
    •  
      numerator (f) → Polynomial

      Returns the numerator of a PuiseuxFraction f.

      Parameters
      PuiseuxFractionf
      Returns
      Polynomial
    •  
      set_var_names (names ...)

      Set the list of variable names used for pretty printing and string parsing of the given polynomial class

      When the number of variables in a polynomial is greater than the size of the name list, the excess variable names are produced from a template "${last_var_name}_{EXCESS}", where EXCESS starts at 0 for the variable corresponding to the last name in the list. If the last name already has a form "{Name}_{Number}", the following variables are enumerated starting from that Number plus 1.

      The default naming scheme consists of a single letter "x", "y", "z", "u", "v", or "w" chosen according to the nesting depth of polynomial types in the coefficient type. That is, variables of simple polynomials (those with pure numerical coefficients) are named x_0, x_1, ..., variables of polynomials with simple polynomial coefficients are named y_0, y_1, etc.

      Parameters
      Stringnames ...
      variable names; may also be bundled in an array an empty list resets to the default naming scheme
    •  
      sum_of_square_roots_naive (input_array) → Map<Rational, Rational>

      Make a naive attempt to sum the square roots of the entries of the input array.

      Parameters
      Array<Rational>input_array
      a list of rational numbers (other coefficents are not implemented).
      Returns
      Map<Rational, Rational>
      a map collecting the coefficients of roots encountered in the sum.

      Example:
      • To obtain sqrt{3/4} + sqrt{245}, type> print sum_of_square_roots_naive(new Array<Rational>([3/4, 245])); {(3 1/2) (5 7)} This output represents sqrt{3}/2 + 7 sqrt{5}. If you are not satisfied with the result, please use a symbolic algebra package.
  •  

    This category contains combinatorial functions.

    •  
      all_permutations (n) → ARRAY

      Returns a list of all permutations of the set {0...n-1} as a perl-array

      Parameters
      Intn
      Returns
      ARRAY

      Example:
      • To store the result in the perl array @a, type this:> @a = all_permutations(3); The array contains pointers to arrays. To access the 0-th pointer, do this:> $a0 = $a[0]; To print the 0-th array itself, you have to dereference it as follows:> print @{ $a0 }; 012 You can loop through @a using foreach. The print statement produces the string obtained by dereferencing the current entry concatenated with the string " ".> foreach( @a ){> print @{ $_ }, " ";> } 012 102 201 021 120 210
    •  
      are_permuted (a, b) → Bool

      Determine whether two arrays a and b are permuted copies of each other.

      Parameters
      Arraya
      Arrayb
      Returns
      Bool

      Example:
      • > print are_permuted([1,8,3,4],[3,8,4,1]); true
    •  
      binomial (n, k) → Int

      Computes the binomial coefficient n choose k. Negative values of n (and k) are supported.

      Parameters
      Intn
      Intk
      Returns
      Int
      n choose k

      Example:
      • Print 6 choose 4 like this:> print binomial(6,4); 15
    •  
      find_permutation (a, b) → Array<Int>

      Returns the permutation that maps a to b.

      Parameters
      Arraya
      Arrayb
      Returns
      Array<Int>

      Example:
      • > $p = find_permutation([1,8,3,4],[3,8,4,1]);> print $p; 2 1 3 0
    •  
      n_fixed_points (p) → Int

      Returns the number of fixed points of the permutation given by p.

      Parameters
      Array<Int>p
      Returns
      Int

      Example:
      • > print n_fixed_points([1,0,2,4,3]); 1
    •  
      permutation_cycles (p) → ARRAY

      Returns the cycles of a permutation given by p.

      Parameters
      Array<Int>p
      Returns
      ARRAY

      Example:
      • > print permutation_cycles([1,0,3,2]); {0 1}{2 3}
    •  
      permutation_cycle_lengths (p) → Array<Int>

      Returns the sorted cycle lengths of a permutation

      Parameters
      Array<Int>p
      Returns
      Array<Int>

      Example:
      • > print permutation_cycle_lengths(new Array<Int>([1,2,0,4,3])); 2 3
    •  
      permutation_matrix <Scalar> (p) → Matrix<Scalar>

      Returns the permutation matrix of the permutation given by p.

      Type Parameters
      Scalar
      default: Int
      Parameters
      Array<Int>p
      Returns
      Matrix<Scalar>

      Example:
      • The following prints the permutation matrix in sparse representation.> print permutation_matrix([1,0,3,2]); (4) (1 1) (4) (0 1) (4) (3 1) (4) (2 1)
    •  
      permutation_order (p) → Int

      Returns the order of a permutation

      Parameters
      Array<Int>p
      Returns
      Int

      Example:
      • > print permutation_order(new Array<Int>([1,2,0,4,3])); 6
    •  
      permutation_sign (p) → Int

      Returns the sign of the permutation given by p.

      Parameters
      Array<Int>p
      Returns
      Int
      +1 or -1

      Example:
      • > print permutation_sign([1,0,3,2]); 1
  •  

    This contains functions for data conversions and type casts.

    •  
      cast <Target> (object) → Object

      Change the type of the polymake object to one of its base types (aka ancestor in the inheritance hierarchy). The object loses all properties that are unknown in the target type.

      Type Parameters
      Target
      the desired new type
      Parameters
      Objectobject
      to be modified
      Returns
      Object
      the same object, but with modified type
    •  
      cols ()

      UNDOCUMENTED

    •  
      cols (A) → Container<Vector>

      Returns an array containing the columns of A.

      Parameters
      MatrixA
      Returns
      Container<Vector>

      Example:
      • The following saves the columns of the vertex matrix of a square in the variable $w and then prints its contents using a foreach loop and concatenating each entry with the string " ".> $w = cols(polytope::cube(2)->VERTICES);> foreach( @$w ){> print @{$_}, " ";> } 1111 -11-11 -1-111
    •  
      concat_rows (A) → Vector

      Concatenates the rows of A.

      Parameters
      MatrixA
      Returns
      Vector

      Examples:
      • Make a vector out of the rows of the vertex matrix of a cube:> $v = concat_rows(polytope::cube(2)->VERTICES);> print $v; 1 -1 -1 1 1 -1 1 -1 1 1 1 1
      • For a sparse matrix, the resulting vector is sparse, too.> $vs = concat_rows(unit_matrix(3));> print $vs; (9) (0 1) (4 1) (8 1)
    •  
      convert_to <Target> (s) → Target

      Explicit conversion to different scalar type.

      Type Parameters
      Target
      Parameters
      SCALARs
      Returns
      Target
    •  
      convert_to <Target> (v) → Vector<Target>

      Explicit conversion to a different element type.

      Type Parameters
      Target
      Parameters
      Vectorv
      Returns
      Vector<Target>

      Example:
      • > $v = new Vector<Rational>(1/2,2/3,3/4);> $vf = convert_to<Float>($v);> print $vf; 0.5 0.6666666667 0.75
    •  
      convert_to <Target> (m) → Matrix<Target>

      Explicit conversion to a different element type.

      Type Parameters
      Target
      Parameters
      Matrixm
      Returns
      Matrix<Target>

      Example:
      • > $M = new Matrix<Rational>([1/2,2],[3,2/3]);> $Mf = convert_to<Float>($M);> print $Mf; 0.5 2 3 0.6666666667
    •  
      convert_to <Target> (m) → Polynomial<Target>

      Explicit conversion to a different coefficient type.

      Type Parameters
      Target
      Parameters
      Polynomialm
      Returns
      Polynomial<Target>
    •  
      convert_to <Target> (m) → UniPolynomial<Target>

      Explicit conversion to a different coefficient type.

      Type Parameters
      Target
      Parameters
      UniPolynomialm
      Returns
      UniPolynomial<Target>
    •  
      dense (v) → Vector

      Return the input vector (which is already in dense form).

      Parameters
      Vectorv
      Returns
      Vector
    •  
      dense (m) → Matrix

      Return the input matrix (which is already in dense form).

      Parameters
      Matrixm
      Returns
      Matrix
    •  
      dense <Element> (v) → Vector<Element>

      Convert to an equivalent dense vector of the same element type.

      Type Parameters
      Element
      Parameters
      SparseVector<Element>v
      Returns
      Vector<Element>
    •  
      dense <Element> (m) → Matrix<Element>

      Convert to an equivalent dense matrix of the same element type.

      Type Parameters
      Element
      Parameters
      SparseMatrix<Element>m
      Returns
      Matrix<Element>
    •  
      dense (m) → Matrix<Int>

      Convert to a dense 0/1 matrix.

      Parameters
      IncidenceMatrixm
      Returns
      Matrix<Int>
    •  
      dense (s, dim) → Vector<Int>

      Convert to a dense 0/1 vector of a given dimension.

      Parameters
      Sets
      Intdim
      Returns
      Vector<Int>
    •  
      index_matrix (m) → IncidenceMatrix

      Get the positions of non-zero entries of a sparse matrix.

      Parameters
      SparseMatrixm
      Returns
      IncidenceMatrix

      Example:
      • > $S = new SparseMatrix([1,2,0,0,0,0],[0,0,5,0,0,32]);> print index_matrix($S); {0 1} {2 5}
    •  
      indices (v) → Set<Int>

      Get the positions of non-zero entries of a sparse vector.

      Parameters
      SparseVectorv
      Returns
      Set<Int>

      Example:
      • > $v = new SparseVector(0,1,1,0,0,0,2,0,3);> print indices($v); {1 2 6 8}
    •  
      lex_ordered (f) → PowerSet<Int>

      Visit the facets of f sorted lexicographically.

      Parameters
      FacetListf
      Returns
      PowerSet<Int>

      Example:
      • > $f = new FacetList(polytope::cube(2)->VERTICES_IN_FACETS);> print lex_ordered($f); {{0 1} {0 2} {1 3} {2 3}}
    •  
      repeat_col (v, i)

      Create a Matrix by repeating the given Vector as cols.

      Parameters
      Vectorv
      Inti

      Example:
      • > $v = new Vector(23,42,666);> $M = repeat_col($v,3);> print $M; 23 23 23 42 42 42 666 666 666
    •  
      repeat_row (v, i)

      Create a Matrix by repeating the given Vector as rows.

      Parameters
      Vectorv
      Inti

      Example:
      • > $v = new Vector(23,42,666);> $M = repeat_row($v,3);> print $M; 23 42 666 23 42 666 23 42 666
    •  
      rows ()

      UNDOCUMENTED

    •  
      rows (A) → Container<Vector>

      Returns an array containing the rows of A.

      Parameters
      MatrixA
      Returns
      Container<Vector>

      Example:
      • The following saves the rows of the vertex matrix of a square in the variable $w and then prints its contents using a foreach loop and concatenating each entry with the string " ".> $w = rows(polytope::cube(2)->VERTICES);> foreach( @$w ){> print @{$_}, " ";> } 1-1-1 11-1 1-11 111
    •  
      support (v) → Set<Int>

      Get the positions of non-zero entries of a vector.

      Parameters
      Vectorv
      Returns
      Set<Int>

      Example:
      • > print support(new Vector(0,23,0,0,23,0,23,0,0,23)); {1 4 6 9}
    •  
      toMatrix <Scalar> (A) → SparseMatrix<Scalar>

      Convert an IncidenceMatrix to a SparseMatrix.

      Type Parameters
      Scalar
      Parameters
      IncidenceMatrixA
      Returns
      SparseMatrix<Scalar>

      Example:
      • > $M = toMatrix<Int>(polytope::cube(2)->VERTICES_IN_FACETS);> print $M->type->full_name; SparseMatrix<Int, NonSymmetric>
    •  
      toTropicalPolynomial (s, vars) → Polynomial<TropicalNumber<Addition,Rational> >

      This converts a string into a tropical polynomial. The syntax for the string is as follows: It is of the form "min(...)" or "max(...)" or "min{...}" or "max{...}", where ... is a comma-separated list of sums of the form "a + bx + c + dy + ...", where a,c are rational numbers, b,d are Ints and x,y are variables. Such a sum can contain several such terms for the same variable and they need not be in any order. Any text that starts with a letter and does not contain any of +-*,(){} or whitespace can be a variable. A term in a sum can be of the form "3x", "3*x", but "x3"will be interpreted as 1 * "x3". Coefficients should not contain letters and there is no evaluation of arithmetic, i.e. "(2+4)*x" does not work (though "2x+4x" would be fine). In fact, further brackets should only be used (but are not necessary!) for single coefficienst, e.g. "(-3)*x". Warning: The parser will remove all brackets before parsing the individual sums. If no further arguments are given, the function will take the number of occuring variables as total number of variables and create a ring for the result. The variables will be sorted alphabetically.

      Parameters
      Strings
      The string to be parsed
      Stringvars
      Optional. A list of variables. If this is given, all variables used in s must match one of the variables in this list.
      Returns
      Polynomial<TropicalNumber<Addition,Rational> >
      , where Addition depends on whether min or max was used in the string.
    •  
      toVector <Scalar> (S, d) → SparseVector<Scalar>

      Create a sparse vector having 1's at positions contained in the given set

      Type Parameters
      Scalar
      type of apparent 1's
      Parameters
      SetS
      Intd
      dimension of the result
      Returns
      SparseVector<Scalar>
    •  
      vector2col (v) → Matrix

      Convert a Vector to a Matrix with a single column.

      Parameters
      Vectorv
      Returns
      Matrix

      Example:
      • This converts a vector into a column and prints it and its type:> $v = new Vector([1,2,3,4]);> $V = vector2col($v);> print $V; 1 2 3 4> print $V->type->full_name; Matrix<Rational, NonSymmetric>
    •  
      vector2row (v) → Matrix

      Convert a Vector to a Matrix with a single row.

      Parameters
      Vectorv
      Returns
      Matrix

      Example:
      • This converts a vector into a row and prints it and its type:> $v = new Vector([1,2,3,4]);> $V = vector2row($v);> print $V; 1 2 3 4> print $V->type->full_name; Matrix<Rational, NonSymmetric>
  •  

    Here you can find the functions to access the polymake database.

    •  
      db_count (query) → Int

      Returns the number of objects in the database db in collection that match the query.

      Parameters
      HASHquery
      Options
      Stringdb
      name of the database, see here or db_info for available databases
      Stringcollection
      name of the collection, see here or db_info for available collections
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Stringusername
      Some databases might have access control.
      Stringpassword
      Some databases might have access control.
      MongoClientclient
      Returns
      Int
    •  
      db_cursor (query) → DBCursor

      Returns a cursor on the entries for the database db in collection that match the query.

      Parameters
      HASHquery
      database query
      Options
      Stringdb
      database name
      Stringcollection
      collection name
      Intskip
      skip the first elements, default: 0
      Intlimit
      limit the number of objects that will be returned (default: no limit)
      HASHsort_by
      sorting of the entries, default by _id
      Stringusername
      Stringpassword
      MongoClientclient
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Returns
      DBCursor
    •  
      db_get_list_col_for_db () → Array

      Returns a list of available collections in a database.

      Options
      Stringdb
      name of the database
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Stringusername
      necessary if reading a database with access control
      Returns
      Array
    •  
      db_get_list_db () → Array

      Returns a list of available databases.

      Options
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Stringusername
      necessary if reading a database with access control
      Returns
      Array
    •  
      db_get_list_db_col () → Array

      Returns a list of available databases and collections (in the form db.collection).

      Options
      Stringdb
      name of the database, default: all available databases
      Stringcollection
      name of the collection, default: all available collections
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Stringusername
      necessary if reading a database with access control
      Returns
      Array
    •  
      db_ids (query) → Array<String>

      Returns the IDs of all objects in the database db in collection that match the query. This is only recommended for a reasonably small number of matching objects. If you expect many such objects you should instead construct a DBCursor.

      Parameters
      HASHquery
      Options
      Stringdb
      name of the database, see here or db_info for available databases
      Stringcollection
      name of the collection, see here or db_info for available collections
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Intlimit
      limit the number of objects that will be returned (default: no limit)
      HASHsort_by
      specify a sorting order
      Intskip
      skip the first elements, default: 0
      Stringusername
      Some databases might have access control.
      Stringpassword
      Some databases might have access control.
      MongoClientclient
      Returns
      Array<String>
    •  
      db_info ()

      Print information about available databases and collections.

      Options
      Stringdb
      name of the database, default: all available databases
      Stringcollection
      name of the collection, default: all available collections
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Stringusername
      necessary if reading a database with access control
    •  
      db_metadata (p) → HASH

      Retrieve the metadata of an object

      Parameters
      Objectp
      the polyDB object
      Returns
      HASH
      metadata the metadata of the database object
    •  
      db_print_metadata (p)

      print the metadata of an object

      Parameters
      Objectp
      the polyDB object
    •  
      db_query (query) → Array<Core::Object>

      Returns all objects in the database db in collection that match the query. This is only recommended for a reasonably small number of matching objects. If you expect many such objects you should instead use a database cursor.

      Parameters
      HASHquery
      Options
      Stringdb
      name of the database, see here or db_info for available databases
      Stringcollection
      name of the collection, see here or db_info for available collections
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Intlimit
      limit the number of objects that will be returned (default: no limit)
      Stringusername
      Some databases might have access control.
      Stringpassword
      Some databases might have access control.
      MongoClientclient
      Intskip
      skip the first elements, default: 0
      HASHsort_by
      specify a sorting order
      Returns
      Array<Core::Object>
    •  
      db_searchable_fields (db, collection) → Array<String>

      Return the list of property names that can be searched in the database for a given database db, collection col and optional template key.

      Parameters
      Stringdb
      name of the database, see here or db_info for available databases
      Stringcollection
      name of the collection, see here or db_info for available collections
      Options
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Returns
      Array<String>
    •  
      db_write_collection_info ()

      Add documentation for a collection You need write access for this.

      Options
      Stringdb
      name of the database the description applies to
      Stringcollection
      name of the collection the description applies to
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Boolreplace
      whether an existing documentation should be updated or replaced
      Stringfile
      a file with the documentation in json format, only one of file and documentation is allowed
      HASHdocumentation
      a perl hash with the documentation, only one of documentation and file is allowed
      Stringusername
      Stringpassword
      Stringpolydb_version
      version number
      Boolverbose
      verbose mode
    •  
      db_write_db_info (db)

      Add a db documentation. You need write access for this.

      Parameters
      Stringdb
      name of the database the description applies to
      Options
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Boolreplace
      whether an existing documentation should be updated or replaced
      Stringfile
      a file with the documentation in json format, only one of file and documentation is allowed
      HASHdocumentation
      a perl hash with the documentation, only one of documentation and file is allowed
      Stringusername
      Stringpassword
      Stringpolydb_version
      version number
      Boolverbose
      verbose mode
  •  

    These are administrative functions. You need admin access to the database for these.

    This category also contains functions that I want to hide from the public because they are not yet completely presentable.

    •  
      db_set_type_information ()

      Set or update type (and template) information for collection col in the database db.

      Note that you need write access to the type database for this.

      Options
      Stringdb
      database name
      Stringcol
      collection name
      Stringkey
      the key of the type information
      Boolreplace
      type information for this database, collection and key already exists and should be replaced
      Stringfile
      a filename containing the type information as json document (only one of file and type_information allowed)
      HASHtype_information
      the type information as per hash (only one of file and type_information allowed)
      Stringusername
      Stringpassword
      StringpolyDB_version
      the version of polyDB this type information applies to
      Boolverbose
  •  

    These are the functions to insert and update objects. You need write access to the database for these.

    •  
      db_insert (obj) → String

      Adds an object obj to the collection col in the database db.

      Note that you need write access to the database for this.

      Parameters
      Core::Objectobj
      Options
      Stringdb
      name of the database
      Stringcollection
      name of the collection
      Stringid
      unique identifier, this is set to the name of the object, a different name should only be used in exceptional cases. This option is only valid if a single object is added.
      Stringcontributor
      set the contributor
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Stringusername
      Stringpassword
      Booluse_type_information
      set to 1 to match properties with a template object
      HASHtype_information
      object template specifying the properties to store
      Stringtype_information_key
      template name to load from the database
      Boolnonew
      set to 1 if you don't want to compute missing properties but only delete surplus ones (only takes effect if use_type_info is also set to 1)
      Boolkeep_all_props
      keep all properties present in the polymake object in the stored xml. Does not effect representation in the db. For this, provide a type information without a property mask
      Boolnoinsert
      dont insert anything, just try evaluate the template
      MongoClientclient
      Returns
      String
    •  
      db_remove (id) → String

      Removes the object with a given id from the collection col in the database db.

      Note that you need write access to the database for this.

      Parameters
      Stringid
      Options
      Stringdb
      name of the database
      Stringcollection
      name of the collection
      Boollocal
      set to 1 if you want to use a local database (on localhost), default 0
      Stringusername
      Stringpassword
      MongoClientclient
      Returns
      String
  •  

    Functions for pretty printing, labels or latex output of polymake types.

    •  
      labeled (data, elem_labels) → String

      Prepares a vector for printing, prepends each element with a label and a colon.

      Parameters
      Vectordata
      to be printed
      Array<String>elem_labels
      optional labels for elements; if data is a Set, or similar, each element will be replaced by its label.
      Returns
      String

      Example:
      • > $v = new Vector(0,1,2);> print labeled($v,["zeroth","first","second"]); zeroth:0 first:1 second:2
    •  
      latex (data, elem_labels) → String

      LaTeX output of a matrix.

      Parameters
      Matrixdata
      to be printed
      Array<String>elem_labels
      optional labels for elements; if data is an IncidenceMatrix, Array<Set>, or similar, each element will be replaced by its label.
      Returns
      String
      to be used with \usepackage{amsmath}
    •  
      numbered (data) → String

      Equivalent to labeled with omitted elem_labels argument.

      Parameters
      Vectordata
      to be printed
      Returns
      String

      Example:
      • > $data = new Vector(23,42,666);> print numbered($data); 0:23 1:42 2:666
    •  
      print_constraints (M)

      Write the rows of a matrix M as inequalities (equations=0) or equations (equations=1) in a readable way. It is possible to specify labels for the coordinates via an optional array coord_labels.

      Parameters
      Matrix<Scalar>M
      the matrix whose rows are to be written
      Options
      Array<String>coord_labels
      changes the labels of the coordinates
      Array<String>row_labels
      changes the labels of the rows
      Boolhomogeneous
      false if the first coordinate should be interpreted as right hand side
      Boolequations
      true if the rows represent equations instead of inequalities

      Example:
      • > $M = new Matrix([1,2,3],[4,5,23]);> print_constraints($M,equations=>1); 0: 2 x1 + 3 x2 = -1 1: 5 x1 + 23 x2 = -4
    •  
      rows_labeled (data, row_labels, elem_labels) → Array<String>

      Prepares a matrix for printing, prepends each row with a label and a colon.

      Parameters
      Matrixdata
      to be printed
      Array<String>row_labels
      labels for the rows
      Array<String>elem_labels
      optional labels for elements; if data is an IncidenceMatrix, Array<Set>, or similar, each element will be replaced by its label.
      Returns
      Array<String>
      each string ending with end-of-line

      Example:
      • > print rows_labeled(polytope::cube(2)->VERTICES,['a','b','c','d']); a:1 -1 -1 b:1 1 -1 c:1 -1 1 d:1 1 1
    •  
      rows_labeled (graph, elem_labels) → Array<String>

      Like above, but specialized for Graphs (defined for convenience: a PTL Graph is not a container)

      Parameters
      Graphgraph
      to be printed
      Array<String>elem_labels
      labels for the elements
      Returns
      Array<String>
      each string ending with end-of-line

      Example:
      • > print rows_labeled(graph::cycle_graph(4)->ADJACENCY, ['a','b','c','d']); a:b d b:a c c:b d d:a c
    •  
      rows_numbered (data) → Array<String>

      Equivalent to rows_labeled with omitted row_labels argument. Formerly called "numbered".

      Parameters
      Matrixdata
      to be printed
      Returns
      Array<String>
      each string ending with end-of-line

      Example:
      • > print rows_numbered(polytope::cube(2)->VERTICES); 0:1 -1 -1 1:1 1 -1 2:1 -1 1 3:1 1 1
  •  

    Operations on graphs.

    •  
      adjacency_matrix (graph) → IncidenceMatrix

      Returns the adjacency matrix of graph nodes. For a normal graph, it will be a kind of IncidenceMatrix, for multigraph, it will be a SparseMatrix<Int>, with entries encoding the number of parallel edges between two nodes.

      Parameters
      Graphgraph
      Returns
      IncidenceMatrix
      both rows and columns correspond to the nodes
    •  
      edges (graph) → EdgeList

      Returns the sequence of all edges of a graph. The edges will appear in ascending order of their tail and head nodes. In the Undirected case, the edges will appear once, ordered by the larger index of their incident nodes.

      Parameters
      Graphgraph
      Returns
      EdgeList
    •  
      induced_subgraph (graph, set) → Graph

      Creates an induced subgraph for the given subset of nodes.

      Parameters
      Graphgraph
      Setset
      indices of selected nodes
      Returns
      Graph

      Example:
      • > $g = new props::Graph(graph::cycle_graph(5)->ADJACENCY);> $s1 = new Set(1,2,3);> print induced_subgraph($g,$s1); (5) (1 {2}) (2 {1 3}) (3 {2})
    •  
      nodes (graph) → Set<Int>

      Returns the sequence of all valid nodes of a graph.

      Parameters
      Graphgraph
      Returns
      Set<Int>

      Example:
      • > print nodes(graph::cycle_graph(5)->ADJACENCY); {0 1 2 3 4}
    •  
      node_edge_incidences <Coord> (graph) → SparseMatrix<Coord>

      Returns the node-edge incidence matrix of a graph.

      Type Parameters
      Coord
      coordinate type for the resulting matrix, default: Int
      Parameters
      Graphgraph
      Returns
      SparseMatrix<Coord>

      Example:
      • > print node_edge_incidences(graph::cycle_graph(5)->ADJACENCY); (5) (0 1) (3 1) (5) (0 1) (1 1) (5) (1 1) (2 1) (5) (2 1) (4 1) (5) (3 1) (4 1)
  •  

    Functions for lattice related computations.

    •  
      eliminate_denominators (v) → Vector<Integer>

      Scale a vector with the least common multiple of the denominators of its coordinates.

      Parameters
      Vectorv
      Returns
      Vector<Integer>

      Example:
      • > $v = new Vector(1/2,1/3,1/4,1/5);> $ve = eliminate_denominators($v);> print $ve; 30 20 15 12
    •  
      eliminate_denominators_entire (v) → Matrix<Integer>

      Scales entire matrix with the least common multiple of the denominators of its coordinates.

      Parameters
      Matrixv
      Returns
      Matrix<Integer>

      Example:
      • > $M = new Matrix([1/2,1/3],[1/5,7],[1/4,4/3]);> $Me = eliminate_denominators_entire($M);> print $Me; 30 20 12 420 15 80
    •  
      eliminate_denominators_entire_affine (v) → Matrix<Integer>

      Scales entire matrix with the least common multiple of the denominators of its coordinates (ignore first column).

      Parameters
      Matrixv
      Returns
      Matrix<Integer>

      Example:
      • > $M = new Matrix([1,1/2,1/3],[1,1/5,7],[1,1/4,4/3]);> $Me = eliminate_denominators_entire_affine($M);> print $Me; 1 30 20 1 12 420 1 15 80
    •  
      eliminate_denominators_in_rows (M) → Matrix<Integer>

      Scale a matrix row-wise with the least common multiple of the denominators of its coordinates.

      Parameters
      MatrixM
      Returns
      Matrix<Integer>

      Example:
      • > $M = new Matrix([1/2,1/3],[1/5,7],[1/4,4/3]);> $Me = eliminate_denominators_in_rows($M);> print $Me; 3 2 1 35 3 16
    •  
      is_integral (v) → Bool

      Checks whether all coordinates of a rational vector are integral.

      Parameters
      Vectorv
      Returns
      Bool

      Example:
      • This rational vector has only integral entries:> $v = new Vector<Rational>(1,2,3,4); polytope > print is_integral($v); true But if we append 1/2, it isn't anymore:> print is_integral($v|1/2); false
    •  
      is_integral (m) → Bool

      Checks whether all coordinates of a rational matrix are integral.

      Parameters
      Matrixm
      Returns
      Bool

      Example:
      • This rational matrix has only integral entries:> $m = new Matrix<Rational>([1,2],[3,4]);> print is_integral($m); true But if we multiply it with 1/2, that is not the case anymore.> print is_integral(1/2 * $m); false
    •  
      primitive (v) → Vector<Integer>

      Scales the vector to a primitive integral vector.

      Parameters
      Vectorv
      Returns
      Vector<Integer>

      Example:
      • > print primitive(new Vector(3,3/2,3,3)); 2 1 2 2
    •  
      primitive (M) → Matrix<Integer>

      Scales each row of the matrix to a primitive integral vector.

      Parameters
      MatrixM
      Returns
      Matrix<Integer>

      Example:
      • > print primitive(new Matrix([1,3/2],[3,1])); 2 3 3 1
    •  
      primitive_affine (v) → Vector<Integer>

      Scales the affine part of a vector to a primitive integral vector.

      Parameters
      Vectorv
      Returns
      Vector<Integer>

      Example:
      • > print primitive_affine(new Vector(1,3/2,1,1)); 1 3 2 2
    •  
      primitive_affine (M) → Matrix<Integer>

      Scales the affine part of each row of the matrix to a primitive integral vector.

      Parameters
      MatrixM
      Returns
      Matrix<Integer>

      Example:
      • > print primitive_affine(new Matrix([1,1,3/2],[1,3,1])); 1 2 3 1 3 1
  •  

    These functions are for algebraic computations and constructions of special matrices.

    •  
      anti_diag (d) → SparseMatrix

      Produces a SparseMatrix from its anti-diagonal.

      Parameters
      Vectord
      the anti-diagonal entries
      Returns
      SparseMatrix

      Example:
      • Try this:> $M = anti_diag(new Vector([0,1,2]));> print $M; (3) (2 2) (3) (1 1) (3) To print a more human-readable representation, use the dense() function:> print dense($M); 0 0 2 0 1 0 0 0 0
    •  
      anti_diag (m1, m2) → SparseMatrix

      Returns a block anti-diagonal matrix with blocks m1 and m2.

      Parameters
      Matrixm1
      Matrixm2
      Returns
      SparseMatrix

      Example:
      • Try this:> $M = anti_diag(unit_matrix(2),unit_matrix(3));> print $M; (5) (2 1) (5) (3 1) (5) (4 1) (5) (0 1) (5) (1 1)
    •  
      barycenter (A) → Vector<Scalar>

      Calculate the average over the rows of a matrix.


      Example:
      • > $A = new Matrix([3,0,0],[0,3,0],[0,0,3]);> print barycenter($A); 1 1 1
    •  
      basis (A) → Pair<Set<Int>, Set<Int>>

      Computes subsets of the rows and columns of A that form a basis for the linear space spanned by A.

      Parameters
      MatrixA
      Returns
      Pair<Set<Int>, Set<Int>>
      The first set corresponds to the rows, the second to the columns.

      Example:
      • Here we have a nice matrix:> $M = new Matrix([[1,0,0,0],[2,0,0,0],[0,1,0,0],[0,0,1,0]]); Let's print bases for the row and column space:> ($row,$col) = basis($M);> print $M->minor($row,All); 1 0 0 0 0 1 0 0 0 0 1 0> print $M->minor(All,$col); 1 0 0 2 0 0 0 1 0 0 0 1
    •  
      basis_affine (A) → Pair<Set<Int>, Set<Int>>

      Does the same as basis ignoring the first column of the matrix.

      Parameters
      MatrixA
      Returns
      Pair<Set<Int>, Set<Int>>
      The first set corresponds to the rows, the second to the columns.
    •  
      basis_cols (A) → Set<Int>

      Computes a subset of the columns of A that form a basis for the linear space spanned by A.

      Parameters
      MatrixA
      Returns
      Set<Int>

      Example:
      • Here we have a nice matrix:> $M = new Matrix([[1,0,0,0],[2,0,0,0],[0,1,0,0],[0,0,1,0]]); Let's print a basis of its column space:> print $M->minor(All,basis_cols($M)); 1 0 0 2 0 0 0 1 0 0 0 1
    •  
      basis_rows (A) → Set<Int>

      Computes a subset of the rows of A that form a basis for the linear space spanned by A.

      Parameters
      MatrixA
      Returns
      Set<Int>

      Example:
      • Here we have a nice matrix:> $M = new Matrix([[1,0,0,0],[2,0,0,0],[0,1,0,0],[0,0,1,0]]); Let's print a basis of its row space:> print $M->minor(basis_rows($M),All); 1 0 0 0 0 1 0 0 0 0 1 0
    •  
      basis_rows_integer (A) → Set<Int>

      Computes a lattice basis of the span of the rows of A.

      Parameters
      MatrixA
      Returns
      Set<Int>
      Indices of the rows of A that constitute a basis.
    •  
      cramer (A, b) → Vector

      Computes the solution of the system Ax = b by applying Cramer's rule

      Parameters
      MatrixA
      must be invertible
      Vectorb
      Returns
      Vector

      Example:
      • from the Wikipedia:> $A = new Matrix([3,2,-1],[2,-2,4],[-1,1/2,-1]);> $b = new Vector(1,-2,0);> print cramer($A,$b); 1 -2 -2
    •  
      det (A) → Scalar

      Computes the determinant of a matrix using Gaussian elimination. If Scalar is not of field type, but element of a Euclidean ring R, type upgrade to element of the quotient field is performed. The result is recast as a Scalar, which is possible without roundoff since the so-computed determinant is an element of the (embedded) ring R.

      Parameters
      Matrix<Scalar>A
      Returns
      Scalar
      det(A)

      Examples:
      • > print det(unit_matrix(3)); 1
      • > $p = new UniPolynomial<Rational,Int>("x2+3x");> $M = new Matrix<UniPolynomial<Rational,Int>>([[$p, $p+1],[$p+1,$p]]);> print det($M); -2*x^2 -6*x - 1
    •  
      diag (d) → SparseMatrix

      Produces a SparseMatrix from its diagonal.

      Parameters
      Vectord
      the diagonal entries
      Returns
      SparseMatrix

      Example:
      • > $v = new Vector(1,2,3,4);> $D = diag($v);> print $D; (4) (0 1) (4) (1 2) (4) (2 3) (4) (3 4)
    •  
      diag (m1, m2) → SparseMatrix

      Returns a block diagonal matrix with blocks m1 and m2.

      Parameters
      Matrixm1
      Matrixm2
      Returns
      SparseMatrix

      Example:
      • > $m1 = new Matrix([1,2],[3,4]);> $m2 = new Matrix([1,0,2],[3,4,0]);> $D = diag($m1,$m2);> print $D; (5) (0 1) (1 2) (5) (0 3) (1 4) 0 0 1 0 2 0 0 3 4 0
    •  
      eigenvalues (A) → Vector<Float>

      Eigenvalues of a matrix

      Parameters
      Matrix<Float>A
      Returns
      Vector<Float>
    •  
      equal_bases (M1, M2) → Bool

      Check whether both matrices are bases of the same linear subspace. Note: It is assumed that they are *bases* of the row space.

      Parameters
      MatrixM1
      MatrixM2
      Returns
      Bool

      Example:
      • > $M1 = new Matrix([1,1,0],[1,0,1],[0,0,1]);> $M2 = new Matrix([1,0,0],[0,1,0],[0,0,1]);> print equal_bases($M1,$M2); true
    •  
      hadamard_product (M1, M2) → Matrix

      Compute the Hadamard product of two matrices with same dimensions.

      Parameters
      MatrixM1
      MatrixM2
      Returns
      Matrix
    •  
      hermite_normal_form (M) → HermiteNormalForm

      Computes the (column) Hermite normal form of an integer matrix. Pivot entries are positive, entries to the left of a pivot are non-negative and strictly smaller than the pivot.

      Parameters
      MatrixM
      Matrix to be transformed.
      Options
      Boolreduced
      If this is false, entries to the left of a pivot are left untouched. True by default
      Returns
      HermiteNormalForm
      object H with H.hnf, H.companion and H.rank with M*H.companion=H.hnf and rank(M) = H.rank.

      Example:
      • The following stores the result for a small matrix M in H and then prints both hnf and companion:> $M = new Matrix<Integer>([1,2],[2,3]);> $H = hermite_normal_form($M);> print $H->hnf; 1 0 0 1> print $H->companion; -3 2 2 -1
    •  
      householder_trafo (b) → Matrix<Float>

      Householder transformation of Vector b. Only the orthogonal matrix reflection H is returned.

      Parameters
      Vector<Float>b
      Returns
      Matrix<Float>
    •  
      inv (A) → Matrix

      Computes the inverse A-1 of an invertible matrix A using Gauss elimination.

      Parameters
      MatrixA
      Returns
      Matrix

      Example:
      • We save the inverse of a small matrix M in the variable $iM:> $M = new Matrix([1,2],[3,4]);> $iM = inv($M); To print the result, type this:> print $iM; -2 1 3/2 -1/2 As we can see, that is in fact the inverse of M.> print $M * $iM; 1 0 0 1
    •  
      lineality_space (A) → Matrix

      Compute the lineality space of a matrix A.

      Parameters
      MatrixA
      Returns
      Matrix

      Example:
      • > $M = new Matrix([1,1,0,0],[1,0,1,0]);> print lineality_space($M); 0 0 0 1
    •  
      lin_solve (A, b) → Vector

      Computes the vector x that solves the system Ax = b

      Parameters
      MatrixA
      must be invertible
      Vectorb
      Returns
      Vector

      Example:
      • from the Wikipedia:> $A = new Matrix([3,2,-1],[2,-2,4],[-1,1/2,-1]);> $b = new Vector(1,-2,0);> print lin_solve($A,$b); 1 -2 -2
    •  
      moore_penrose_inverse (M) → Matrix<Float>

      Moore-Penrose Inverse of a Matrix

      Parameters
      MatrixM
      Returns
      Matrix<Float>
    •  
      normalized (A) → Matrix<Float>

      Normalize a matrix by dividing each row by its length (l2-norm).

      Parameters
      Matrix<Float>A
      Returns
      Matrix<Float>

      Example:
      • > $A = new Matrix<Float>([1.5,2],[2.5,2.5]);> print normalized($A); 0.6 0.8 0.7071067812 0.7071067812
    •  
      null_space (A) → Matrix

      Compute the null space of a matrix A.

      Parameters
      MatrixA
      Returns
      Matrix

      Example:
      • > $A = new Matrix([1,2,0],[2,0,2]);> print null_space($A); -1 1/2 1
    •  
      null_space (b) → Matrix

      Compute the null space of a vector b.

      Parameters
      Vectorb
      Returns
      Matrix

      Example:
      • > $b = new Vector(1,2,3);> print null_space($b); -2 1 0 -3 0 1
    •  
      null_space_integer (A) → SparseMatrix

      Computes the lattice null space of the integer matrix A.

      Parameters
      MatrixA
      Returns
      SparseMatrix
      Has a lattice basis of the null space as rows.
    •  
      ones_matrix <Element> (m, n) → Matrix<Element>

      Creates a matrix with all elements equal to 1.

      Type Parameters
      Element
      default: Rational.
      Parameters
      Intm
      number of rows
      Intn
      number of columns
      Returns
      Matrix<Element>

      Example:
      • The following creates an all-ones matrix with Rational coefficients.> $M = ones_matrix<Rational>(2,3);> print $M; 1 1 1 1 1 1
    •  
      ones_vector <Element> (d) → Vector<Element>

      Creates a vector with all elements equal to 1.

      Type Parameters
      Element
      default: Rational.
      Parameters
      Intd
      vector dimension. If omitted, a vector of dimension 0 is created, which can adjust itself when involved in a block matrix operation.
      Returns
      Vector<Element>

      Example:
      • To create the all-ones Int vector of dimension 3, do this:> $v = ones_vector<Int>(3); You can print the result using the print statement:> print $v; 1 1 1
    •  
      pluecker (V) → Vector

      Compute the vector of maximal minors of a matrix. WARNING: interpretation different in tropical::lifted_pluecker

      Parameters
      MatrixV
      Returns
      Vector
    •  
      project_to_orthogonal_complement (points, orthogonal)

      Projects points into the orthogonal complement of a subspace given via an orthogonal basis. The given points will be overwitten.

      Parameters
      Matrixpoints
      will be changed to orthogonal ones
      Matrixorthogonal
      basis of the subspace
    •  
      qr_decomp (M) → Pair<Matrix,Matrix>

      QR decomposition of a Matrix M with rows > cols


      Example:
      • > $M = new Matrix<Float>([23,4],[6,42]);> $qr = qr_decomp($M);> print $qr->first; 0.9676172724 0.2524218971 0.2524218971 -0.9676172724> print $qr->second; 23.76972865 14.47218877 0 -39.63023785> print $qr->first * $qr->second ; 23 4 6 42
    •  
      rank (A) → Int

      Computes the rank of a matrix.

      Parameters
      MatrixA
      Returns
      Int
    •  
      reduce (A, b) → Vector

      Reduce a vector with a given matrix using Gauss elimination.

      Parameters
      MatrixA
      Vectorb
      Returns
      Vector
    •  
      remove_zero_rows (m) → Matrix

      Remove all zero rows from a matrix.

      Parameters
      Matrixm
      Returns
      Matrix
    •  
      singular_value_decomposition (M) → SingularValueDecomposition

      SVD decomposition of a Matrix. Computes the SVD of a matrix into a diagonal Marix (S), orthogonal square Matrix (U), orthogonal square Matrix (V), such that U*S*V^T=M The first element of the output array is S, the second U and the thrid V.


      Example:
      • > $M = new Matrix<Float>([1,2],[23,24]);> $SVD = singular_value_decomposition($M); The following prints the three matrices, seperated by newline characters.> print $SVD->left_companion ,"\n", $SVD->sigma ,"\n", $SVD->right_companion; 0.06414638608 0.9979404998 0.9979404998 -0.06414638608 33.31011547 0 0 0.6604600341 0.6909846321 -0.7228694476 0.7228694476 0.6909846321
    •  
      smith_normal_form (M, inv) → SmithNormalForm<Integer>

      Compute the Smith normal form of a given matrix M. M = LSR in normal case, or S = LMR in inverted case.

      Parameters
      MatrixM
      must be of integer type
      Boolinv
      optional, if true, compute the inverse of the companion matrices
      Returns
      SmithNormalForm<Integer>

      Example:
      • > $M = new Matrix<Integer>([1,2],[23,24]);> $SNF = smith_normal_form($M); The following line prints the three matrices seperated by newline characters.> print $SNF->left_companion ,"\n", $SNF->form ,"\n", $SNF->right_companion; 1 0 23 1 1 0 0 -22 1 2 0 1
    •  
      solve_left (A, B) → Matrix

      Computes a matrix X that solves the system XA = B. This is useful, for instance, for computing the coordinates of some vectors with respect to a basis. The rows of the matrix solve_left(B,V) are the coordinates of the rows of V with respect to the rows of B.

      Parameters
      MatrixA
      MatrixB
      Returns
      Matrix

      Example:
      • Define the matrices> $V = new Matrix([[-4,2,2],[3,-2,-1]]);> $B = new Matrix([[-1,1,0],[0,-1,1]]); so that the rows of B are a basis of the subspace of vectors with zero coordinate sum. Then the rows of> print solve_left($B, $V); 4 2 -3 -1 contain the coordinates of the rows of V with respect to the rows of B.
    •  
      solve_right (A, B) → Matrix

      Computes a matrix X that solves the system AX = B

      Parameters
      MatrixA
      MatrixB
      Returns
      Matrix

      Examples:
      • A non-degenerate example:> $A = new Matrix([[1,0,0],[1,1,0],[1,0,1],[1,1,1]]);> $B = new Matrix([[1,0,0],[1,0,1],[1,1,0],[1,1,1]]);> print solve_right($A,$B); 1 0 0 0 0 1 0 1 0
      • A degenerate example:> $A = new Matrix([[1,0,0,0,0],[0,1,0,0,0],[1,0,1,0,0],[0,1,1,0,0]]);> $B = new Matrix([[0,1,0,0,0],[1,0,0,0,0],[0,1,1,0,0],[1,0,1,0,0]]);> print solve_right($A,$B); 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
    •  
      sqr (v) → Scalar

      Return the sum of the squared entries of a vector v.

      Parameters
      Vector<Scalar>v
      Returns
      Scalar
    •  
      totally_unimodular (A) → Bool

      The matrix A is totally unimodular if the determinant of each square submatrix equals 0, 1, or -1. This is the naive test (exponential in the size of the matrix).

      For a better implementation try Matthias Walter's polymake extension at https://github.com/xammy/unimodularity-test/wiki/Polymake-Extension.

      Parameters
      MatrixA
      Returns
      Bool

      Example:
      • > $M = new Matrix<Int>([-1,-1,0,0,0,1],[1,0,-1,-1,0,0],[0,1,1,0,-1,0],[0,0,0,1,1,-1]);> print totally_unimodular($M); true
    •  
      trace (A) → Int

      Computes the trace of a matrix.

      Parameters
      MatrixA
      Returns
      Int
      trace(A)

      Example:
      • > $M = new Matrix([1,2,3],[23,24,25],[0,0,1]);> print trace($M); 26
    •  
      transpose (A) → IncidenceMatrix

      Computes the transpose AT of an incidence matrix A, i.e., (aT)ij = aji.

    •  
      transpose (A) → Matrix

      Computes the transpose AT of a matrix A, i.e., (aT)ij = aji.

      Parameters
      MatrixA
      Returns
      Matrix

      Example:
      • > $M = new Matrix([1,2,23],[23,22,21]);> $Mt = transpose($M);> print $Mt; 1 23 2 22 23 21
    •  
      unit_matrix <Element> (d) → SparseMatrix<Element>

      Creates a unit matrix of given dimension

      Type Parameters
      Element
      default: Rational
      Parameters
      Intd
      dimension of the matrix
      Returns
      SparseMatrix<Element>

      Examples:
      • The following stores the 3-dimensional unit matrix (ones on the diagonal and zeros otherwise) in a variable and prints it:> $M = unit_matrix(3);> print $M; (3) (0 1) (3) (1 1) (3) (2 1)
      • The following stores the 3-dimensional unit matrix (ones on the diagonal and zeros otherwise) from type Int in a variable and prints it:> $M = unit_matrix<Int>(3);> print $M->type->full_name; SparseMatrix<Int, Symmetric>
    •  
      unit_vector <Element> (d, pos) → SparseVector<Element>

      Creates a SparseVector of given length d with a one entry at position pos and zeroes elsewhere.

      Type Parameters
      Element
      default: Rational
      Parameters
      Intd
      the dimension of the vector
      Intpos
      the position of the 1
      Returns
      SparseVector<Element>
      # @example The following stores a vector of dimension 5 with a single 1 (as a Rational) at position 2: > $v = unit_vector(5,2); > print $v; | (5) (2 1)

      Examples:
      • The following stores a vector of dimension 5 with a single 1 (as a Int) at position 2:> $v = unit_vector<Int>(5,2);> print $v->type->full_name; SparseVector<Int>
      • The following concatenates a unit vector of dimension 3 with a 1 at position 2 and a unit vector of dimension 2 with a 1 at position 1:> $v = unit_vector(3,2) | unit_vector(2,1);> print $v; (5) (2 1) (4 1)
    •  
      zero_matrix <Element> (i, j) → SparseMatrix<Element>

      Creates a zero matrix of given dimensions

      Type Parameters
      Element
      default: Rational
      Parameters
      Inti
      number of rows
      Intj
      number of columns
      Returns
      SparseMatrix<Element>

      Examples:
      • The following stores a 2x3 matrix with 0 as entries (from type Rational) in a variable and prints it:> $M = zero_matrix(2,3);> print $M; 0 0 0 0 0 0
      • The following stores a 2x3 matrix with 0 as entries from type Int in a variable and prints its type:> $M = zero_matrix<Int>(2,3);> print $M->type->full_name; Matrix<Int, NonSymmetric>
    •  
      zero_vector <Element> (d) → Vector<Element>

      Creates a vector with all elements equal to zero.

      Type Parameters
      Element
      default: Rational
      Parameters
      Intd
      vector dimension. If omitted, a vector of dimension 0 is created, which can adjust itself when involved in a block matrix operation.
      Returns
      Vector<Element>

      Examples:
      • The following stores a vector of dimension 5 with 0 as entries (from type Rational) in a variable and prints it:> $v = zero_vector(5);> print $v; 0 0 0 0 0
      • The following stores a vector of dimension 5 with 0 as entries from type Int in a variable and prints its type:> $v = zero_vector<Int>(5);> print $v->type->full_name; Vector<Int>
      • The following concatenates a vector of dimension 2 of ones and a vector of length 2 of zeros:> $v = ones_vector(2) | zero_vector(2);> print $v; 1 1 0 0
  •  

    This category contains functions performing operations on Sets.

    •  
      incl (s1, s2) → Int

      Analyze the inclusion relation of two sets.

      Parameters
      Sets1
      Sets2
      Returns
      Int
      0 if s1 = s2,
      -1 if s1 ⊂ s2,
      1 if s1 ⊃ s2,
      2 otherwise.

      Example:
      • > $s1 = new Set(1,2,3);> $s2 = $s1 - 1;> print incl($s1, $s2); 1> print incl($s2, $s1); -1> print incl($s1, $s1); 0> print incl($s2, $s1-$s2); 2
    •  
      range (a, b) → Set<Int>

      Create the Set {a, a+1, ..., b-1, b} for ab. See also: sequence

      Parameters
      Inta
      minimal element of the set
      Intb
      maximal element of the set
      Returns
      Set<Int>

      Example:
      • > print range(23,27); {23 24 25 26 27}
    •  
      range_from (a) → Set<Int>

      Create an index range starting at a, the last index is implied by the context. To be used with minor, slice, and similar methods selecting a subset of elements.

      Parameters
      Inta
      start index
      Returns
      Set<Int>

      Example:
      • > $v=new Vector<Int>(10,20,30,40);> print $v->slice(range_from(2)); 30 40
    •  
      scalar2set (s) → Set<SCALAR>

      Returns the singleton set {s}.

      Parameters
      SCALARs
      Returns
      Set<SCALAR>

      Example:
      • > print scalar2set(23); {23}
    •  
      select_subset (s, indices) → Set

      Returns the subset of s given by the indices.

      Parameters
      Sets
      Set<Int>indices
      Returns
      Set

      Example:
      • > $s = new Set<Int>(23,42,666,789);> $ind = new Set<Int>(0,2);> $su = select_subset($s,$ind);> print $su; {23 666}
    •  
      sequence (a, c) → Set<Int>

      Create the Set {a, a+1, ..., a+c-1}. See also: range

      Parameters
      Inta
      the smallest element
      Intc
      the cardinality
      Returns
      Set<Int>

      Example:
      • > print sequence(23,6); {23 24 25 26 27 28}
  •  

    Miscellaneous functions.

    •  
      average (array)

      Returns the average value of the array elements.

      Parameters
      ARRAYarray

      Example:
      • > print average([1,2,3]); 2
    •  
      bounding_box (m) → Matrix

      Compute a column-wise bounding box for the given Matrix m.

      Parameters
      Matrixm
      Returns
      Matrix
      a Matrix with two rows and m->cols columns; row(0) contains lower bounds, row(1) contains upper bounds.
    •  
      distance_matrix (S, d) → Matrix

      Given a metric, return a triangle matrix whose (i,j)-entry contains the distance between point i and j of the point set S for i<j. All entrys below the diagonal are zero. The metric is passed as a perl subroutine mapping two input vectors to a real value.

      Parameters
      MatrixS
      CODEd
      Returns
      Matrix

      Example:
      • The following defines the perl subroutine dist as the euclidean metric and then saves the distance matrix of the 3-cubes vertices in the variable $M:> sub dist($$) {> my $v = $_[0] - $_[1];> return sqrt(new Float($v*$v)); }> $M = distance_matrix(polytope::cube(3)->VERTICES, \&dist);
    •  
      fibonacci (m) → ARRAY

      Returns the first m Fibonacci numbers.

      Parameters
      Intm
      Returns
      ARRAY
    •  
      histogram (data) → Map<Element, Int>

      Produce a histogram of an array: each different element value is mapped on the number of its occurences.

      Parameters
      ARRAYdata
      Returns
      Map<Element, Int>

      Example:
      • > $H = histogram([1,1,2,2,2,3,3,2,3,3,1,1,1,3,2,3]);> print $H; {(1 5) (2 5) (3 6)}
    •  
      index_of (array) → HashMap<Array<Set<Int>>, Int>

      Return a map indexing an array of sets


      Example:
      • > $s1 = new Set(1,2,3);> $s2 = $s1 - 1;> $a = new Array<Set>($s1,$s2,$s1);> print index_of($a); {({1 2 3} 2) ({2 3} 1)}
    •  
      is_nonnegative (data) → Bool

      Checks if a given sequence is nonnegative

      Parameters
      ARRAYdata
      Returns
      Bool

      Example:
      • > print is_nonnegative([1,0,3]); 1
    •  
      is_unimodal (data) → Bool

      Checks if a given sequence is unimodal

      Parameters
      ARRAYdata
      (or Array<Scalar>)
      Returns
      Bool

      Example:
      • > print is_unimodal([1,1,2,3,3,2,2,1]); 1 > print is_unimodal([3,3,2,-1]); 1> print is_unimodal([1,3,2,3]); 0
    •  
      maximum (array)

      Returns the maximal element of an array.

      Parameters
      ARRAYarray

      Example:
      • > print maximum([1,2,3,4,5,6,7,23]); 23
    •  
      median (array)

      Returns the median value of the array elements.

      Parameters
      ARRAYarray

      Example:
      • > print median([1,2,3,9]); 2.5
    •  
      minimum (array)

      Returns the minimal element of an array.

      Parameters
      ARRAYarray

      Example:
      • > print minimum([23,42,666]); 23
    •  
      perturb_matrix (M, eps, not_hom) → Matrix

      Perturb a given matrix M by adding a random matrix. The random matrix consists of vectors that are uniformly distributed on the unit sphere. Optionally, the random matrix can be scaled by a factor eps.

      Parameters
      MatrixM
      Floateps
      the factor by which the random matrix is multiplied default value: 1
      Boolnot_hom
      if set to 1, the first column will also be perturbed; otherwise the first columns of the input matrix M and the perturbed one coincide (useful for working with homogenized coordinates); default value: 0 (homogen. coords)
      Options
      Intseed
      controls the outcome of the random number generator; fixing a seed number guarantees the same outcome.
      Returns
      Matrix
    •  
      rand_perm (n) → Array<Int>

      gives a random permutation

      Parameters
      Intn
      Options
      IntSeed
      Returns
      Array<Int>
      random permutation
  •  

    These functions are for visualization.

    •  
      compose (vis_obj ...) → Visual::Container

      Create a composite drawing of several objects.

      Parameters
      Visual::Objectvis_obj ...
      objects to be drawn together
      Options
      StringTitle
      name of the whole drawing; per default the name of the first Object is taken.
      option list:Visual::Polygons::decorations
      Returns
      Visual::Container
      if called in void context, immediately starts the preferred rendering program.

      Example:
      • Draw a pretty 8-pointed star:> compose(cube(2)->VISUAL, cross(2,sqrt(2))->VISUAL, Title=>"A pretty star.", VertexLabels=>"hidden");
    •  
      compose (vis_container, vis_obj ...) → Visual::Container

      Add new objects to a composite drawing.

      Parameters
      Visual::Containervis_container
      drawing produced by some visualization function
      Visual::Objectvis_obj ...
      objects to be added
      Options
      StringTitle
      new name for the drawing
      anydecorations
      to be applied to all components as default values.
      Returns
      Visual::Container
      if called in void context, immediately starts the preferred rendering program.
    •  
      geomview (vis_obj ...)

      Run geomview to display given visual objects.

      Parameters
      Visual::Objectvis_obj ...
      objects to display
      Options
      StringFile
      "filename" or "AUTO" Store the objects in a gcl (geomview control language) file instead of starting the interactive GUI. The geometric data in OFF format is embedded in the Lisp-style commands, but can be easily extracted using any text editor, if needed.
      The .gcl suffix is automatically added to the file name.
      Specify AUTO if you want the filename be automatically derived from the drawing title.
      You can also use any expression allowed for the open function, including "-" for terminal output, "&HANDLE" for an already opened file handle, or "| program" for a pipe.
    •  
      javaview (vis_obj ...)

      Run JavaView with the given visual objects.

      Contained in extension javaview.
      Parameters
      Visual::Objectvis_obj ...
      objects to display
      Options
      StringFile
      "filename" or "AUTO" Store the object description in a JVX file without starting the interactive GUI. The .jvx suffix is automatically added to the file name.
      Specify AUTO if you want the filename be automatically derived from the drawing title.
      You can also use any expression allowed for the open function, including "-" for terminal output, "&HANDLE" for an already opened file handle, or "| program" for a pipe.
    •  
      jreality (vis_obj ...)

      Run jReality to display given visual objects.

      Contained in extension jreality.
      Parameters
      Visual::Objectvis_obj ...
      objects to display
      Options
      StringFile
      "filename" or "AUTO" Store the object description in a bean shell source file without starting the interactive GUI. The .bsh suffix is automatically added to the file name.
      Specify AUTO if you want the filename be automatically derived from the drawing title.
      You can also use any expression allowed for the open function, including "-" for terminal output, "&HANDLE" for an already opened file handle, or "| program" for a pipe.
    •  
      postscript (vis_obj ...)

      Create a Postscript (tm) drawing with the given visual objects.

      Parameters
      Visual::Objectvis_obj ...
      objects to draw
      Options
      StringFile
      "filename" or "AUTO" Store the drawing in a file without starting the viewer. The .ps suffix is automatically added to the file name.
      Specify AUTO if you want the filename be automatically derived from the drawing title.
      You can also use any expression allowed for the open function, including "-" for terminal output, "&HANDLE" for an already opened file handle, or "| program" for a pipe.
    •  
      povray (vis_obj ...)

      Run POVRAY to display given visual objects.

      Parameters
      Visual::Objectvis_obj ...
      objects to display
      Options
      StringFile
      "filename" or "AUTO" Store the object description in a POVRAY source file without actual rendering. The .pov suffix is automatically added to the file name.
      Specify AUTO if you want the filename be automatically derived from the drawing title.
      You can also use any expression allowed for the open function, including "-" for terminal output, "&HANDLE" for an already opened file handle, or "| program" for a pipe.
    •  
      sketch (vis_obj ...)

      Produce a Sketch input file with given visual objects.

      Parameters
      Visual::Objectvis_obj ...
      objects to display
      Options
      StringFile
      "filename" or "AUTO"
      For the file name you can use any expression allowed for the open function, including "-" for terminal output, "&HANDLE" for an already opened file handle, or "| program" for a pipe. Real file names are automatically completed with the .sk suffix if needed.
      An automatically generated file name is displayed in the verbose mode.
    •  
      static (vis_obj) → Visual::Object

      Suppress creation of dynamic (interactive) scenes.

      Parameters
      Visual::Objectvis_obj
      drawing, e.g. created by VISUAL_GRAPH or SCHLEGEL.
      Returns
      Visual::Object
      if called in void context, immediately starts the preferred rendering program.
    •  
      svg (vis_obj ...)

      Create a Svg drawing with the given visual objects.

      Parameters
      Visual::Objectvis_obj ...
      objects to draw
      Options
      StringFile
      "filename" or "AUTO" Store the drawing in a file without starting the viewer. The .svg suffix is automatically added to the file name.
      Specify AUTO if you want the filename be automatically derived from the drawing title.
      You can also use any expression allowed for the open function, including "-" for terminal output, "&HANDLE" for an already opened file handle, or "| program" for a pipe.
    •  
      threejs (vis_obj)

      Produce an html file with given visual objects.

      Parameters
      Visual::Objectvis_obj
      object to display
      Options
      StringFile
      "filename" or "AUTO"
      For the file name you can use any expression allowed for the open function, including "-" for terminal output, "&HANDLE" for an already opened file handle, or "| program" for a pipe. Real file names are automatically completed with the .html suffix if needed.
      An automatically generated file name is displayed in the verbose mode.
    •  
      tikz (vis_obj)

      Produce a TikZ file with given visual objects.

      Parameters
      Visual::Objectvis_obj
      object to display
      Options
      StringFile
      "filename" or "AUTO"
      For the file name you can use any expression allowed for the open function, including "-" for terminal output, "&HANDLE" for an already opened file handle, or "| program" for a pipe. Real file names are automatically completed with the .tikz suffix if needed.
      An automatically generated file name is displayed in the verbose mode.
    •  
      x3d (vis_obj ...)

      Create an X3D drawing with the given visual objects.

      Parameters
      Visual::Objectvis_obj ...
      objects to draw
      Options
      StringFile
      "filename" or "AUTO" Store the drawing in a file without starting the viewer. The .x3d suffix is automatically added to the file name.
      Specify AUTO if you want the filename be automatically derived from the drawing title.
      You can also use any expression allowed for the open function, including "-" for terminal output, "&HANDLE" for an already opened file handle, or "| program" for a pipe.

Property Types

  •  

    This category contains all "algebraic" types, such as matrices, vectors, polynomials, rings, ...

    •  
      all_rows_or_cols

      Use the keyword "All" for all rows or columns, e.g. when constructing a minor.

    •  
      Matrix <Element, Sym>
      UNDOCUMENTED
      Type Parameters
      Element
      default: Rational
      Sym
      default: NonSymmetric

      User Methods of Matrix

      •  
        anti_diagonal (i) → Vector<Element>

        Returns the anti-diagonal of the matrix.

        Parameters
        Inti
        i=0: the main anti_diagonal (optional)
        i>0: the i-th anti_diagonal below the main anti_diagonal
        i<0: the i-th anti_diagonal above the main anti_diagonal
        Returns
        Vector<Element>
      •  
        clear (r, c)

        Change the dimensions setting all elements to 0.

        Parameters
        Intr
        new number of rows
        Intc
        new number of columns
      •  
        col (i) → Vector<Element>

        Returns the i-th column.

        Parameters
        Inti
        Returns
        Vector<Element>
      •  
        cols () → Int

        Returns the number of columns.

        Returns
        Int
      •  
        diagonal (i) → Vector<Element>

        Returns the diagonal of the matrix.

        Parameters
        Inti
        i=0: the main diagonal (optional)
        i>0: the i-th diagonal below the main diagonal
        i<0: the i-th diagonal above the main diagonal
        Returns
        Vector<Element>
      •  
        div_exact (a) → Matrix

        Divides every entry by a (assuming that every entry is divisible by a).

        Parameters
        Inta
        Returns
        Matrix
      •  
        elem (r, c) → Element

        Returns an element of the matrix. The return value is an `lvalue', that is, it can be modified if the matrix object is mutable.

        Parameters
        Intr
        the row index
        Intc
        the column index
        Returns
        Element
      •  
        minor (r, c) → Matrix

        Returns a minor of the matrix containing the rows in r and the columns in c. You can pass All if you want all rows or columns and ~ for the complement of a set. E.g.

        $A->minor(All, ~[0]);

        will give you the minor of a matrix containing all rows and all but the 0-th column.

        Parameters
        Setr
        the rows
        Setc
        the columns
        Returns
        Matrix
      •  
        resize (r, c)

        Change the dimensions; when growing, set added elements to 0.

        Parameters
        Intr
        new number of rows
        Intc
        new number of columns
      •  
        row (i) → Vector<Element>

        Returns the i-th row.

        Parameters
        Inti
        Returns
        Vector<Element>
      •  
        rows () → Int

        Returns the number of rows.

        Returns
        Int
    •  
      Plucker <Scalar>
      UNDOCUMENTED
      Type Parameters
      Scalar
      default: Rational

      User Methods of Plucker

    •  
      Polynomial <Coefficient, Exponent>
      UNDOCUMENTED
      Type Parameters
      Coefficient
      default: Rational
      Exponent
      default: Int

      User Methods of Polynomial

      •  
        coefficients_as_vector () → Vector<Coefficient>

        The vector of all coefficients. The sorting agrees with monomials_as_matrix.

      •  
        constant_coefficient () → Int

        The constant coefficient.

        Returns
        Int
      •  
        deg () → Int

        The degree of the polynomial

        Returns
        Int
      •  
        embed (nvars) → Polynomial

        Embed the Polynomial in a polynomial ring with the given number of variables. The old variables will be put at the beginning, for more control use mapvars.

        Parameters
        Intnvars
        new number of variables
        Returns
        Polynomial

        Example:
        • > $pm = new Polynomial("1+x_0^2*x_3+x_1+3*x_3");> print $pm->project([1,3]); x_0 + 4*x_1 + 1
      •  
        get_var_names ()

        set the variable names

      •  
        initial_form (v) → Polynomial

        The initial form with respect to a weight-vector v

        Parameters
        Vector<Exponent>v
        weights
        Returns
        Polynomial
      •  
        lc () → Int

        The leading coefficient.

        Returns
        Int
      •  
        lm () → Int

        The exponent of the leading monomial.

        Returns
        Int
      •  
        mapvars (indices, nvars) → Polynomial

        Map the variables of the Polynomial to the given indices. The same index may bei given multiple times and also some may be omitted for embedding with a higher number of variables. The length of the given Array must be the same as the number of variables of the original polynomial.

        Parameters
        Array<Int>indices
        indices of the target variables
        Intnvars
        new number of variables, default: maximal index
        Returns
        Polynomial

        Example:
        • > $pm = new Polynomial("1+x_0^2*x_3+x_1+3*x_3");> print $pm->mapvars([0,1,1,4],6); x_0^2*x_4 + x_1 + 3*x_4 + 1
      •  
        monomial (var_index, n_vars)

        construct a monomial of degree 1 with a given variable

        Parameters
        Intvar_index
        index of the variable
        Intn_vars
        number of variables
      •  
        monomials_as_matrix () → SparseMatrix<Exponent>

        The matrix of all exponent vectors (row-wise). The sorting agrees with coefficients_as_vector.

      •  
        n_vars () → Int

        Number of variables

        Returns
        Int
      •  
        print_ordered (m)

        Print a polynomial with terms sorted according to a given Matrix m.

        Parameters
        Matrixm
      •  
        project () → Polynomial

        Project the Polynomial to the given list of variables. The number of variables will be reduced to the number of indices, i.e. the variables will be renamed. Keeping the names of the variables is possible by using substitute with a Map.

        Returns
        Polynomial

        Example:
        • > $pm = new Polynomial("1+x_0^2*x_3+x_1+3*x_3");> print $pm->project([1,3]); x_0 + 4*x_1 + 1
      •  
        reset_var_names ()

        reset the variable names according to the default naming scheme

      •  
        set_var_names ()

        set the variable names

      •  
        substitute ()

        Substitute a list of values in a Polynomial with Int exponents. Either with an array of values, or with a Map mapping variable indices to values.


        Example:
        • > $pm = new Polynomial("1+x_0^2*x_3+x_1+3*x_3");> print $pm->substitute([0,11,2,3]); 21> $map = new Map<Int,Rational>([0,5/2],[1,1/5],[2,new Rational(7/3)]);> print $pm->substitute($map); 37/4*x_3 + 6/5
      •  
        trivial () → Bool

        The polynomial is zero.

        Returns
        Bool
    •  
      PuiseuxFraction <MinMax, Coefficient, Exponent>
      UNDOCUMENTED
      Type Parameters
      MinMax
      type of tropical addition: either Min or Max
      Coefficient
      default: Rational
      Exponent
      default: Rational

      User Methods of PuiseuxFraction

      •  
        evaluate (m, x, exp) → Matrix<Coefficient>

        Evaluate all PuiseuxFractions in a Matrix at a Rational number (x^exp). Let explcm be the lcm of the denominators of all exponents. If there are no denominators or explcm divides exp, then the evaluation is computed exactly. Otherwise, some rational number close to the root (x^exp)^-explcm will be chosen via an intermediate floating point number.

        Parameters
        Matrixm
        Coefficientx
        Intexp
        (default: 1)
        Returns
        Matrix<Coefficient>
      •  
        evaluate (v, x, exp) → Vector<Coefficient>

        Evaluate all PuiseuxFractions in a Vector at a Rational number (x^exp). Let explcm be the lcm of the denominators of all exponents. If there are no denominators or explcm divides exp, then the evaluation is computed exactly. Otherwise, some rational number close to the root (x^exp)^-explcm will be chosen via an intermediate floating point number.

        Parameters
        Vectorv
        Coefficientx
        Intexp
        (default: 1)
        Returns
        Vector<Coefficient>
      •  
        evaluate (x, exp) → Coefficient

        Evaluate a PuiseuxFraction at a Rational number (x^exp). Let explcm be the lcm of the denominators of all exponents. If there are no denominators or explcm divides exp, then the evaluation is computed exactly. Otherwise, some rational number close to the root (x^exp)^-explcm will be chosen via an intermediate floating point number.

        Parameters
        Coefficientx
        Intexp
        (default: 1)
        Returns
        Coefficient
      •  
        evaluate_float (x) → Float

        Approximate evaluation at x

        Parameters
        Floatx
        Returns
        Float
      •  
        evaluate_float (m, x) → Float

        Approximate evaluation of a Matrix at x

        Parameters
        Matrixm
        Floatx
        Returns
        Float
      •  
        evaluate_float (v, x) → Float

        Approximate evaluation of a Vector at x

        Parameters
        Vectorv
        Floatx
        Returns
        Float
      •  
        val () → TropicalNumber<MinMax>

        The valuation.

    •  
      RationalFunction <Coefficient, Exponent>

      the same with type deduction

      Type Parameters
      Coefficient
      default: Rational
      Exponent
      default: Int
    •  
      SparseMatrix <Element, Sym>

      A SparseMatrix is a two-dimensional associative array with row and column indices as keys; elements equal to the default value (ElementType(), which is 0 for most numerical types) are not stored, but implicitly encoded by the gaps in the key set. Each row and column is organized as an AVL-tree.

      Use dense to convert this into its dense form.

      You can create a new SparseMatrix by entering its entries row by row, as a list of SparseVectors e.g.:

      $A = new SparseMatrix<Int>(<< '.');
      (5) (1 1)
      (5) (4 2)
      (5)
      (5) (0 3) (1 -1)
      .
      derived from: Matrix
      Type Parameters
      Element
      Sym
      one of Symmetric or NonSymmetric, default: NonSymmetric

      User Methods of SparseMatrix

      •  
        resize (r, c)

        Resize the matrix All elements in added rows and/or columns are implicit zeros.

        Parameters
        Intr
        new number of rows
        Intc
        new number of columns
      •  
        squeeze ()

        Removes empty rows and columns. The remaining rows and columns are renumbered without gaps.

      •  
        squeeze_cols ()

        Removes empty columns. The remaining columns are renumbered without gaps.

      •  
        squeeze_rows ()

        Removes empty rows. The remaining rows are renumbered without gaps.

    •  
      SparseVector <Element>

      A SparseVector is an associative container with element indices (coordinates) as keys; elements equal to the default value (ElementType(), which is 0 for most numerical types) are not stored, but implicitly encoded by the gaps in the key set. It is based on an AVL tree.

      The printable representation of a SparseVector looks like a sequence (l) (p1 v1) ... (pk vk), where l is the dimension of the vector and each pair (pi vi) denotes an entry with value vi at position pi. All other entries are zero.

      Use dense to convert this into its dense form.

      You can create a new SparseVector by entering its printable encoding as described above, e.g.:

      $v = new SparseVector<Int>(<< '.');
      (6) (1 1) (2 2)
      .
      derived from: Vector
      Type Parameters
      Element

      User Methods of SparseVector

      •  
        size () → Int

        The number of non-zero entries.

        Returns
        Int
    •  
      UniPolynomial <Coefficient, Exponent>

      A class for univariate polynomials.

      Type Parameters
      Coefficient
      default: Rational
      Exponent
      default: Int

      User Methods of UniPolynomial

      •  
        coefficients_as_vector () → Vector<Coefficient>

        The vector of all coefficients. The sorting agrees with monomials_as_vector.

      •  
        constant_coefficient () → Int

        The constant coefficient.

        Returns
        Int
      •  
        deg () → Exponent

        The highest degree occuring in the polynomial.

        Returns
        Exponent
      •  
        evaluate (x, exp) → Coefficient

        Evaluate a UniPolynomial at a number (x^exp). Note that for non-integral exponents this may require intermediate floating point computations depending on the input: Let explcm be the lcm of the denominators of all exponents. If there are no denominators or explcm divides exp, then the evaluation is computed exactly. Otherwise, some rational number close to the root (x^exp)^-explcm will be chosen via an intermediate floating point number.

        Parameters
        Coefficientx
        Exponentexp
        (default: 1)
        Returns
        Coefficient
      •  
        evaluate_float (x) → Float

        Approximate evaluation of the polynomial at a Float x.

        Parameters
        Floatx
        Returns
        Float
      •  
        get_var_names ()

        get the variable name

      •  
        lc () → Int

        The leading coefficient.

        Returns
        Int
      •  
        lower_deg () → Exponent

        The lowest degree occuring in the polynomial.

        Returns
        Exponent
      •  
        monomial ()

        create a monomial of degree 1

      •  
        monomials_as_vector () → Vector<Exponent>

        The vector of all exponents. The order agrees with coefficients_as_vector.

      •  
        n_vars ()

        Number of variables

      •  
        print_ordered (x)

        Print a polynomial with terms sorted according to exponent*x.

        Parameters
        Exponentx
      •  
        reset_var_names ()

        reset the variable name according to the default naming scheme

      •  
        set_var_names ()

        set the variable name

      •  
        substitute ()

        Substitute some value in a UniPolynomial with Int exponents. When all exponents are positive the argument can be any scalar, matrix or polynomial type. With negative exponents, polynomials are not supported (use RationalFunction instead) and any given matrix must be invertible

    •  
      Vector <Element>

      A type for vectors with entries of type Element.

      You can perform algebraic operations such as addition or scalar multiplication.

      You can create a new Vector by entering its elements, e.g.:

      $v = new Vector<Int>(1,2,3);

      or

      $v = new Vector<Int>([1,2,3]);
      Type Parameters
      Element

      User Methods of Vector

      •  
        dim () → Int

        The length of the vector

        Returns
        Int
      •  
        div_exact (a) → Vector

        Divides every entry by a (assuming that every entry is divisible by a).

        Parameters
        Inta
        Returns
        Vector
      •  
        slice (s) → Vector

        Returns a Vector containing all entries whose index is in a Set s.

        Parameters
        Sets
        indices to select from the vector
        Returns
        Vector
  •  

    These types are needed as return types of arithmetic computations.

    •  
      Div <Scalar>

      The complete result of an integral division, quotient and remainder.

      Type Parameters
      Scalar

      User Methods of Div

      •  
        quot () → Scalar

        The quotient.

        Returns
        Scalar
      •  
        rem () → Scalar

        The remainder.

        Returns
        Scalar
    •  
      ExtGCD

      The complete result of the calculation of the greatest common divisor of two numbers a and b:

      g=gcd(a,b)
      g=a*p+b*q
      a=g*k1
      b=g*k2

      User Methods of ExtGCD

      •  
        g () → Int

        The greatest common divisor of a and b.

        Returns
        Int
      •  
        k1 () → Int

        The factor of a.

        Returns
        Int
      •  
        k2 () → Int

        The factor of b.

        Returns
        Int
      •  
        p () → Int

        The co-factor of a.

        Returns
        Int
      •  
        q () → Int

        The co-factor of b.

        Returns
        Int
    •  
      Max

      tropical addition: max

      User Methods of Max

    •  
      Min

      tropical addition: min

      User Methods of Min

    •  
      TropicalNumber <Addition, Scalar>
      UNDOCUMENTED
      Type Parameters
      Addition
      Scalar
      default: Rational

      User Methods of TropicalNumber

      •  
        orientation () → Int

        The orientation of the associated addition, i.e. +1 if the corresponding 0 is +inf -1 if the corresponding 0 is -inf

        Returns
        Int
      •  
        zero () → Scalar

        The zero element of the tropical semiring of this element.

        Returns
        Scalar
  •  

    These types are auxiliary artifacts helping to build other classes, primarily representing template parameters or enumeration constants. They should not be used alone as property types or function arguments. In the most cases they won't even have user-accessible constructors.

  •  

    This category contains all basic types, in particular those that wrap C++, GMP or perl types such as Int, Integer, Rational, Long, Float, Array, String, ...

    •  
      AccurateFloat

      A wrapper for AccurateFloat.

    •  
      Array <Element>

      An array with elements of type Element. Corresponds to the C++ type Array.

      Type Parameters
      Element

      User Methods of Array

      •  
        size () → Int

        Returns the size.

        Returns
        Int
    •  
      Bool

      Corresponds to the C++ type bool.

    •  
      Float

      Corresponds to the C++ type double.

      User Methods of Float

      •  
        inf ()

        produce an infinitely large positive value

      •  
        minus_inf ()

        produce an infinitely large negative value

    •  
      Int

      Corresponds to the C++ type int.

    •  
      Integer

      An integer of arbitrary size.

      User Methods of Integer

      •  
        inf ()

        produce an infinitely large positive value

      •  
        minus_inf ()

        produce an infinitely large negative value

    •  
      List <Element>

      Corresponds to the C++ type std::list.

      Type Parameters
      Element
    •  
      Long

      Corresponds to the C++ type long. This type is primarily needed for automatic generated function wrappers, because perl integral constants are always kept as a long.

      derived from: Int
    •  
      Pair <First, Second>

      Corresponds to the C++ type std::pair.

      Type Parameters
      First
      Second
    •  
      QuadraticExtension <Field>

      Realizes quadratic extensions of fields.

      You can construct the value a+b\(\sqrt r\) via QuadraticExtension(a, b, r) (where a, b, r are of type Field).

      Type Parameters
      Field
      default: Rational
    •  
      Rational

      A class for rational numbers. You can easily create a Rational like that: $x = 1/2;

      User Methods of Rational

      •  
        inf ()

        Produce an infinitely large positive value.

      •  
        minus_inf ()

        Produce an infinitely large negative value.

    •  
      String

      Corresponds to the C++ type std::string.

    •  
      Text

      Plain text without any imposed structure.

  •  

    Here you can find the functions to access the polymake database.

    •  
      DBCursor

      A database cursor. Initialize it with a database name, a collection name and a query. You can then iterate over the objects matching the query with next. It lazily fetches more objects from the database server. (Note that you have to create a new cursor if you want to start from the beginning.)

    •  
      MongoClient

      A handler for the polyDB database internally controlling the connection to the MongoDB database

  •  

    This contains all property types that are related to graphs.

    •  
      EdgeHashMap <Dir, Element>

      Sparse mapping of edges to data items.

      derived from: GraphMap
      Type Parameters
      Dir
      Element
      data associated with edges

      User Methods of EdgeHashMap

      •  
        edge (from, to)

        Access the data associated with an edge between two given nodes. The new data element is created on demand.

        Parameters
        Intfrom
        source node
        Intto
        target node
      •  
        erase (from, to)

        Delete the data associated with an edge between two given nodes.

        Parameters
        Intfrom
        source node
        Intto
        target node
      •  
        find (from, to) → Iterator

        Access the data associated with an edge between two given nodes.

        Parameters
        Intfrom
        source node
        Intto
        target node
        Returns
        Iterator
        pointing to the data element (must be dereferenced as ${...}) or undef if the element does not exist.
    •  
      EdgeMap <Dir, Element>

      Dense mapping of edges to data items.

      derived from: GraphMap
      Type Parameters
      Dir
      kind of the host graph, Undirected, Directed, UndirectedMulti, or DirectedMulti
      Element
      data associated with edges

      User Methods of EdgeMap

      •  
        edge (from, to)

        Access the data associated with an edge between two given nodes.

        Parameters
        Intfrom
        source node
        Intto
        target node
    •  
      Graph <Dir>
      UNDOCUMENTED
      Type Parameters
      Dir

      User Methods of Graph

      •  
        add_edge (tail_node, head_node) → Int

        In a multigraph, creates a new edge connecting two given nodes. In a normal graph, creates a new edge only if the nodes were not connected yet. Returns the index of the (new) edge.

        Parameters
        Inttail_node
        Inthead_node
        Returns
        Int
      •  
        add_node () → Int

        Add a new node without incident edes.

        Returns
        Int
        index of the new node
      •  
        adjacent_nodes (node) → Set

        Returns the set of indices of nodes adjacent to node.

        Parameters
        Intnode
        Returns
        Set
      •  
        all_edges (tail_node, head_node) → Iterator

        Returns an iterator visiting all (parallel) edges connecting two given nodes.

        Parameters
        Inttail_node
        Inthead_node
        Returns
        Iterator
      •  
        contract_edge (node1, node2)

        Contract the edge(s) between node1 and node2. Reconnects all edges from node2 to node1, deleting the edge(s) between them and, finally, deleting node2.

        Parameters
        Intnode1
        Intnode2
      •  
        degree (node) → Int

        Returns the number of edges incident to node.

        Parameters
        Intnode
        Returns
        Int
      •  
        delete_all_edges (tail_node, head_node)

        Deletes all edges in a multigraph connecting two given nodes.

        Parameters
        Inttail_node
        Inthead_node
      •  
        delete_edge (tail_node, head_node)

        Deletes the edge connecting two given nodes, if there was one. In a multigraph, deletes one arbitrary edge from the parallel bundle.

        Parameters
        Inttail_node
        Inthead_node
      •  
        delete_edge (iterator)

        Delete the edge in a multigraph pointed to by the given iterator

        Parameters
        Iteratoriterator
        as returned by all_edges.
      •  
        delete_node (node)

        Deletes all edges incident to the given node and marks it as invalid. The numeration of other nodes stays unchanged.

        Parameters
        Intnode
      •  
        dim () → Int

        Returns the maximal node index + 1. If the graph does not have gaps caused by node deletion, the result is equivalent to nodes().

        Returns
        Int
      •  
        edge (tail_node, head_node) → Int

        Returns the index of the edge connecting two given nodes. The edge is created if was not there. In a multigraph, an arbitrary edge from the parallel bundle will be picked.

        Parameters
        Inttail_node
        Inthead_node
        Returns
        Int
      •  
        edges () → Int

        Get the total number of edges.

        Returns
        Int
      •  
        edge_exists (tail_node, head_node) → Bool

        Checks whether two given nodes are connected by (at least) one edge.

        Parameters
        Inttail_node
        Inthead_node
        Returns
        Bool
      •  
        has_gaps () → Bool

        Returns true if some nodes have been deleted since the last squeeze operation.

        Returns
        Bool
      •  
        invalid_node (node) → Bool

        Returns true if the given node index is either out of valid range or points to a formerly deleted node.

        Parameters
        Intnode
        Returns
        Bool
      •  
        in_adjacent_nodes (node) → Set

        Returns the set of indices of the nodes that have an edge heading to node.

        Parameters
        Intnode
        Returns
        Set
      •  
        in_degree (node) → Int

        Returns the number of edges heading to node.

        Parameters
        Intnode
        Returns
        Int
      •  
        in_edges (node) → EdgeList

        Returns a sequence of edges heading to (in Directed case) or incident to (in Undirected case) node.

        Parameters
        Intnode
        Returns
        EdgeList
      •  
        nodes () → Int

        Get the total number of nodes.

        Returns
        Int
      •  
        node_exists (node) → Bool

        Check whether the node with given index exists.

        Parameters
        Intnode
        Returns
        Bool
      •  
        node_out_of_range (node) → Bool

        Returns true if the given node index is out of valid range.

        Parameters
        Intnode
        Returns
        Bool
      •  
        out_adjacent_nodes (node) → Set

        Returns the set of indices of the nodes with an edge arriving from node.

        Parameters
        Intnode
        Returns
        Set
      •  
        out_degree (node) → Int

        Returns the number of edges leaving node.

        Parameters
        Intnode
        Returns
        Int
      •  
        out_edges (node) → EdgeList

        Returns a sequence of edges leaving (in Directed case) or incident to (in Undirected case) node.

        Parameters
        Intnode
        Returns
        EdgeList
      •  
        permute_inv_nodes ()

        permute the nodes param perm inverse permutation of node indexes

      •  
        permute_nodes ()

        permute the nodes param perm permutation of node indexes

      •  
        squeeze ()

        Renumbers the valid nodes as to eliminate all gaps left after deleting.

      •  
        squeeze_isolated ()

        Deletes all nodes of degree 0, then renumbers the remaining nodes without gaps.

    •  
      GraphMap <Dir, Element>

      The common abstract base class for all kinds of associative containers that can be attached to a Graph.

      Type Parameters
      Dir
      kind of the host graph: Undirected, Directed, UndirectedMulti, or DirectedMulti
      Element
      data associated with nodes or edges
    •  
      NodeHashMap <Dir, Element>

      Sparse mapping of nodes to data items.

      derived from: GraphMap
      Type Parameters
      Dir
      Element
      data associated with nodes
    •  
      NodeMap <Dir, Element>

      Dense mapping of nodes to data items.

      derived from: GraphMap
      Type Parameters
      Dir
      kind of the host graph, Undirected, Directed, UndirectedMulti, or DirectedMulti
      Element
      data associated with nodes
  •  

    These types are needed as return types of algebraic computations.

    •  
      HermiteNormalForm

      Complete result of the Hermite normal form computation. Contains the following fields: Matrix<Scalar> hnf: the Hermite normal form N of M SparseMatrix<Scalar> companion: unimodular Matrix R such that M*R = N. Int rank: rank of M

    •  
      SingularValueDecomposition

      Complete result of the singular value decomposition of a matrix M, such that left_companion * sigma * transpose(right_companion) = M Contains the following fields:

      Matrix<Float> sigma: the diagonalized matrix
      Matrix<Float> left_companion: matrix of left singular vectors
      Matrix<Float> right_companion: matrix of right singular vectors
    •  
      SmithNormalForm

      Complete result of the Smith normal form computation. Contains the following fields:

      SparseMatrix<Scalar> form: the Smith normal form S of the given matrix M
      List<Pair<Scalar, Int>> torsion: absolute values of the entries greater than 1 of the diagonal together with their multiplicity
      Int rank: rank of M
      SparseMatrix<Scalar> left_companion, right_companion: unimodular matrices L and R such that

      M = LSR in normal case, or S = LMR in inverted case (as specified in the call to smith_normal_form function).

  •  

    In this category you find all property types related to sets, such as Set, Map, HashMap, IncidenceMatrix, ...

    •  
      ApproximateSet <Element>

      A specialization of Sets containing elements of type Element, but where equality is enforced only up to a global epsilon.

      You can for example create a new ApproximateSet with two elements by:

      $s = new ApproximateSet(1.1, 1.2, 1.200000001);
      derived from: Set
      Type Parameters
      Element
      default: Float
    •  
      Bitset

      Container class for dense sets of integers.

      A special class optimized for representation of a constrained range of non-negative integer numbers.

      derived from: Set<Int>
    •  
      FacetList

      A FacetList is a collection of sets of integral numbers from a closed contiguous range [0..n-1]. The contained sets usually encode facets of a simplicial complex, with set elements corresponding to vertices of a complex, therefore the name.

      From the structural perspective, FacetList is interchangeable with IncidenceMatrix, but they significantly differ in supported operations and their performance. IncidenceMatrix offers fast random access to elements, while FacetList is optimized for finding, inserting, and deleting facets fulfilling certain conditions like all subsets or supersets of a given vertex set.

      On perl side, FacetList behaves like a sequence of Set<Int> without random access to facets. Facets are visited in chronological order. Each facet has a unique integral ID generated at the moment of insertion. The IDs can be obtained via call to index() of iterators created by find() methods.

      User Methods of FacetList

      •  
        erase (f) → Bool

        Remove a facet.

        Parameters
        Setf
        facet to remove
        Returns
        Bool
        whether a facet existed before
      •  
        eraseSubsets (s) → Int

        Remove all subsets of a given set

        Parameters
        Sets
        filter for removal
        Returns
        Int
        number of removed facets
      •  
        eraseSupersets (s) → Int

        Remove all supersets of a given set

        Parameters
        Sets
        filter for removal
        Returns
        Int
        number of removed facets
      •  
        find (f) → Iterator

        Look up a facet.

        Parameters
        Setf
        facet to find
        Returns
        Iterator
        pointing to the facet or in an invalid state
      •  
        findSubsets (s) → Iterator

        Find all subsets of a given set.

        Parameters
        Sets
        Returns
        Iterator
        all facets equal to or included in s, visited in lexicographical order
      •  
        findSupersets (s) → Iterator

        Find all supersets of a given set.

        Parameters
        Sets
        Returns
        Iterator
        all facets equal to or including s, visited in reverse chronological order
      •  
        insert (f)

        Add a new facet. It may be a proper subset or a proper superset of existing facets. It must not be empty or coincide with any existing facet.

        Parameters
        Setf
        facet to add.
      •  
        insertMax (f) → Bool

        Add a new facet if and only if there are no facets including it. If this holds, remove all facets that are included in the new one.

        Parameters
        Setf
        facet to add
        Returns
        Bool
        whether the new facet was really included.
      •  
        insertMin (f) → Bool

        Add a new facet if and only if there are no facets included in it. If this holds, remove all facets including the new facet.

        Parameters
        Setf
        facet to add
        Returns
        Bool
        whether the new facet was really included.
      •  
        n_vertices () → Int

        The number of vertices

        Returns
        Int
      •  
        size () → Int

        The number of facets in the list.

        Returns
        Int
    •  
      HashMap <Key, Value>

      An unordered map based on a hash table. Its interface is similar to that of Map, but the order of elements is not stable across polymake sessions and does not correlate with key values.

      Accessing and inserting a value by its key works in constant time O(1).

      You can create a new HashMap mapping Ints to Strings by

      $myhashmap = new HashMap<Int, String>([1, "Monday"], [2, "Tuesday"]);

      On the perl side HashMaps are treated like hashrefs. You can work with a HashMap like you work with a Map (keeping in mind differences in performance and memory demand).

      Type Parameters
      Key
      type of the key values
      Value
      type of the mapped value

      User Methods of HashMap

      •  
        size () → Int

        Size of the map

        Returns
        Int
    •  
      HashSet <Element>

      An unordered set of elements based on a hash table. Can be traversed as a normal container, but the order of elements is not stable across polymake sessions, even if the set is restored from the same data file every time.

      Type Parameters
      Element

      User Methods of HashSet

      •  
        size () → Int

        The cardinality of the set.

        Returns
        Int
    •  
      IncidenceMatrix <Sym>

      A 0/1 incidence matrix.

      Type Parameters
      Sym
      one of Symmetric or NonSymmetric, default: NonSymmetric

      User Methods of IncidenceMatrix

      •  
        col (i) → SparseVector<Int>

        Returns the i-th column.

        Parameters
        Inti
        Returns
        SparseVector<Int>
      •  
        cols () → Int

        Returns the number of columns.

        Returns
        Int
      •  
        elem (r, c) → Bool

        Returns an element of the matrix as a boolean value. The return value is an `lvalue', that is, it can be assigned to, flipped, etc. if the matrix object is mutable.

        Parameters
        Intr
        the row index
        Intc
        the column index
        Returns
        Bool
      •  
        minor (r, c) → IncidenceMatrix

        Returns a minor of the matrix containing the rows in r and the columns in c. You can pass All if you want all rows or columns and ~ for the complement of a set. For example,

        $A->minor(All, ~[0]);

        will give you the minor of a matrix containing all rows and all but the 0-th column.

        Parameters
        Setr
        the rows
        Setc
        the columns
        Returns
        IncidenceMatrix
      •  
        row (i) → SparseVector<Int>

        Returns the i-th row.

        Parameters
        Inti
        Returns
        SparseVector<Int>
      •  
        rows () → Int

        Returns the number of rows.

        Returns
        Int
      •  
        squeeze ()

        Removes empty rows and columns. The remaining rows and columns are renumbered without gaps.

      •  
        squeeze_cols ()

        Removes empty columns. The remaining columns are renumbered without gaps.

      •  
        squeeze_rows ()

        Removes empty rows. The remaining rows are renumbered without gaps.

    •  
      Map <Key, Value>

      Maps are sorted associative containers that contain unique key/value pairs. Maps are sorted by their keys.

      Accessing or inserting a value needs logarithmic time O(log n), where n is the size of the map.

      You can create a new Map mapping Ints to Strings by

      $mymap = new Map<Int, String>([1, "Monday"], [2, "Tuesday"]);

      On the perl side Maps are treated like hashrefs. You can add a new key/value pair by

      $mymap->{3} = "Wednesday";

      (If the key is already contained in the Map, the corresponding value is replaced by the new one.) or ask for the value of a key by

      print $mymap->{1};
      Type Parameters
      Key
      type of the key values
      Value
      type of the mapped value
    •  
      PowerSet <Element>

      A Set whose elements are of type Set<Element>.

      derived from: Set
      Type Parameters
      Element
      default: Int
    •  
      Set <Element>

      A type for ordered sets containing elements of type Element.

      You can for example create a new Set by:

      $s = new Set(2, 3, 5, 7);

      You can perform set theoretic operations:

      $s1 + $s2 union
      $s1 * $s2 intersection
      $s1 - $s2 difference
      $s1 ^ $s2 symmetric difference
      Type Parameters
      Element
      default: Int

      User Methods of Set

      •  
        back () → Int

        The last element of the set, that is, the largest element

        Returns
        Int
      •  
        collect (e) → Bool

        Add to the set, report true if existed formerly.

        Parameters
        Elemente
        element to insert into the set
        Returns
        Bool
      •  
        contains (e) → Bool

        Check if e is contained in the set.

        Parameters
        Elemente
        element check for
        Returns
        Bool
      •  
        front () → Int

        The first element of the set, that is, the smallest element

        Returns
        Int
      •  
        size () → Int

        The cardinality of the set.

        Returns
        Int
  •  

    These property_types are for visualization.

    •  
      Color

      This is a pseudo-type for documentation purposes only. A function expecting an argument or option of type Color can digest an object of type RGB or HSV as well as a string with an RGB value in hex notation "#RRGGBB" or a symbolic color name.

    •  
      Flexible

      This is a pseudo-type for documentation purposes only. Many options of visualization functions modifying the appearance of some set of graphical elements like points, edges, facets, etc. accept a wide range of possible values, allowing for different grades of flexibility (and complexity):

      SCALAR the same attribute value is applied to all elements ARRAY each element gets its individual attribute value HASH elements found in the hash get their individual attribute values, for the rest the appropriate default applies SUB a piece of code computing the attribute value for the given element

      Unless specified explicitly in the detailed option description, the indices, keys, or subroutine arguments used for retrieval of the attribute values are just the zero-based ordinal numbers of the elements.

    •  
      HSV

      A color described as a Hue-Saturation-Value triple. Is convertible to and from an RGB representation.

    •  
      RGB

      A color described as a Red-Green-Blue triple. Can be constructed from a list of three integral values from the range 0..255, or a hex triplet with a leading # symbol, or a list of three floating-point values from the range 0..1, or a symbolic name from the X11 color names.

Common Option Lists

  •  

    These options are for visualization.

    •  
      geometric_options

      Options for visualizing objects with homogeneous coordinates like Polytope, PolyhedralComplex, SubdivisionOfPoints and PointConfiguration.

      Options
      Matrix BoundingBox
      useful for unbounded polyhedra
      Matrix<Float> Transformation
      linear transformation, to be applied after dehomogenization
      Vector<Float> Offset
      shift, to be applied after dehomogenization and the linear transformation
    •  
      geometric_options_linear

      Options for visualizing objects with nonhomogeneous coordinates like Cone, PolyhedralFan and VectorConfiguration.

      Options
      Matrix<Float> Transformation
      linear transformation, to be applied on rays/vectors
    •  
      Visual::PointSet::decorations

      Common attributes modifying the appearance of PointSets and all visual objects derived thereof. Please be aware that no one visualization program interfaced to polymake supports all of them. Unsupported options are normally ignored.

      Options
      String Title
      the name of the drawing
      String Name
      the name of this visual object in the drawing
      Bool Hidden
      if set to true, the visual object is not rendered (useful for interactive visualization programs allowing for switching details on and off)
      String PointLabels
      if set to "hidden", no point labels are displayed
      String VertexLabels
      alias for PointLabels
      Flexible<Color> PointColor
      color of the spheres or rectangles representing the points
      Flexible<Color> VertexColor
      alias for PointColor
      Flexible<Float> PointThickness
      scaling factor for the size of the spheres or rectangles representing the points
      Flexible<Float> VertexThickness
      alias for PointThickness
      Flexible<Color> PointBorderColor
      color of the border line of rectangles representing the points
      Flexible<Float> VertexBorderColor
      alias for PointBorderColor
      Flexible<Float> PointBorderThickness
      scaling factor for the thickness of the border line of rectangles representing the points
      Flexible<Float> VertexBorderThickness
      alias for PointBorderThickness
      Flexible<String> PointStyle
      if set to "hidden", neither point nor its label is rendered
      Flexible<String> VertexStyle
      alias for PointStyle
      Vector<Float> ViewPoint
      ViewPoint for Sketch visualization
      Vector<Float> ViewDirection
      ViewDirection for Sketch visualization
      Vector<Float> ViewUp
      ViewUp for Sketch visualization
      Float Scale
      scale for Sketch visualization
      Flexible<String> LabelAlignment
      Defines the alignment of the vertex labels: left, right or center
    •  
      Visual::Polygon::decorations

      Attributes modifying the appearance of filled polygons.

      imports from: Visual::PointSet::decorations

      Options
      Color FacetColor
      filling color of the polygon
      Float FacetTransparency
      transparency factor of the polygon between 0 (opaque) and 1 (completely translucent)
      String FacetStyle
      if set to "hidden", the inner area of the polygon is not rendered
      Color EdgeColor
      color of the boundary lines
      Float EdgeThickness
      scaling factor for the thickness of the boundary lines
      String EdgeStyle
      if set to "hidden", the boundary lines are not rendered
    •  
      Visual::Polygons::decorations

      Attributes modifying the appearance of a set of polygons (like a polygonal surface).

      imports from: Visual::PointSet::decorations

      Options
      Flexible<Color> FacetColor
      filling color of the polygons
      Flexible<Float> FacetTransparency
      transparency factor of the polygons between 0 (opaque) and 1 (completely translucent)
      Flexible<String> FacetStyle
      if set to "hidden", the inner area of the polygons are not rendered at all
      String FacetLabels
      if set to "hidden", the facet labels are not displayed (in the most cases this is the default behavior)
      Color EdgeColor
      color of the boundary lines
      Float EdgeThickness
      scaling factor for the thickness of the boundary lines
      String EdgeStyle
      if set to "hidden", the boundary lines are not rendered
    •  
      Visual::Wire::decorations

      Attributes modifying the appearance of "wire frameworks". Unlike the rest, the flexible edge attributes are retrieved using the edge iterator as an index/key/argument.

      imports from: Visual::PointSet::decorations

      Options
      Flexible<Color> EdgeColor
      color of the lines representing the edges
      Flexible<Float> EdgeThickness
      scaling factor for the thickness of the lines representing the edges
      EdgeMap<String> EdgeLabels
      textual labels to be placed along the edges
      Flexible<String> EdgeStyle
      if set to "hidden", neither the edge nor its label is rendered