skip to Main Content

I am beginner in the polymake and Perl. The polymake is software for research in polyhedral geometry it is the enriched version of Perl. You can use objects that are inherited from the C++ side of polymake in the interactive shell called "small objects". The one of such small object is Matrix<>, see too matrix_classes. I am not sure that the type of the data is correct with the next code that gives the error message when I want to create matrix $sp:

ERROR: can’t determine the number of columns

use application "fan";
use application "common";

my $dense_unit_matrix = dense(unit_matrix<Int>(6));
my $m_int = new Matrix<Int>(unit_matrix<Int>(5));
my $arr2= new Vector<Int>([(1)x 5]);
my $extended_matrix = ($arr2 | $m_int);
my $arr3 = new Matrix<Int>([[ (1) x 6 ]]);
my $ar = new Matrix<Int>([[2, (-1) x 5]]);

$sp = new Matrix<Int>($dense_unit_matrix, $ar, $extended_matrix, $arr3);

print $dense_unit_matrix->cols,$ar->cols,$extended_matrix->cols,$arr3->cols;

6666 (maybe unlucky number)

I tried to change types of data to Vector, Matrix<Int>, Matrix<Rational>, Arrray

2

Answers


  1. Chosen as BEST ANSWER

    The operator ["/"][1] can be used for the concatenation by row of matrices. In this case my $sp=$dense_unit_matrix/$ar; $sp=$sp/extended_matrix; $sp=$sp/$arr3; works as well.

    [1]: https://polymake.org/doku.php/user_guide/howto/matrix_classes#:~:text=GenericVector%26%2C%20const%20GenericVector%26)%3B-,Create%20a%20block%20matrix,-%2C%20virtually%20appending%20the


  2. I also got the error "can’t determine the number of columns". However, manually concatenation worked for me:

    #! /usr/bin/env perl
    
    use feature qw(say);
    use application "fan";
    use application "common";
    
    my $dense_unit_matrix = dense(unit_matrix<Int>(6));
    my $m_int = new Matrix<Int>(unit_matrix<Int>(5));
    my $arr2= new Vector<Int>([(1)x 5]);
    my $extended_matrix = ($arr2 | $m_int);
    my $arr3 = new Matrix<Int>([[ (1) x 6 ]]);
    my $ar = new Matrix<Int>([[2, (-1) x 5]]);    
    my $sp = new Matrix<Int>([
        @$dense_unit_matrix,
        @$ar,
        @$extended_matrix,
        @$arr3
    ]);
    say $sp;
    

    Output:

    $ polymake --script p.pl
    1 0 0 0 0 0
    0 1 0 0 0 0
    0 0 1 0 0 0
    0 0 0 1 0 0
    0 0 0 0 1 0
    0 0 0 0 0 1
    2 -1 -1 -1 -1 -1
    1 1 0 0 0 0
    1 0 1 0 0 0
    1 0 0 1 0 0
    1 0 0 0 1 0
    1 0 0 0 0 1
    1 1 1 1 1 1
    

    Note:

    The output "6666" that you observed probably came from the last print statement:

    print $dense_unit_matrix->cols,$ar->cols,$extended_matrix->cols,$arr3->cols;
    

    All of these four matrices has 6 columns, so the output will be "6666"

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search