Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap more types #61

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/jlpolymake/jlpolymake.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#define JLPOLYMAKE_VERSION_MAJOR 0
#define JLPOLYMAKE_VERSION_MINOR 12
#define JLPOLYMAKE_VERSION_PATCH 0
#define JLPOLYMAKE_VERSION_PATCH 1

#define __JLPOLYMAKE_STR_HELPER(x) #x
#define __JLPOLYMAKE_STR(x) __JLPOLYMAKE_STR_HELPER(x)
Expand Down
91 changes: 65 additions & 26 deletions src/polymake/type_setup.pl
Original file line number Diff line number Diff line change
Expand Up @@ -85,42 +85,60 @@ sub TropicalNumber {
}

sub Vector {
return () if @_ == 0;
my $p = $_[0] eq "Sparse" ? shift : "";
push @$wrap_calls, [lc("wrap_${p}vector"), [$_[0]->[1]]];
return template("${p}Vector", @_);
my $e = shift;
push @$wrap_calls, [lc("wrap_${p}vector"), [$e->[1]]];
return (template("${p}Vector", $e), Vector(@_));
}
sub Matrix {
return () if @_ == 0;
my $p = $_[0] eq "Sparse" ? shift : "";
push @$wrap_calls, [lc("wrap_${p}matrix"), [$_[0]->[1]]];
return template("${p}Matrix", @_);
my $e = shift;
push @$wrap_calls, [lc("wrap_${p}matrix"), [$e->[1]]];
return (template("${p}Matrix", $e), Matrix(@_));
}
sub Array {
push @$wrap_calls, ["wrap_array", [$_[0]->[1]]];
return template("Array", @_);
return () if @_ == 0;
my $e = shift;
push @$wrap_calls, ["wrap_array", [$e->[1]]];
return (template("Array", $e), Array(@_));
}
sub Set {
push @$wrap_calls, ["wrap_set", [$_[0]->[1]]];
return template("Set", @_);
return () if @_ == 0;
my $e = shift;
push @$wrap_calls, ["wrap_set", [$e->[1]]];
return (template("Set", $e), Set(@_));
}
sub Map {
push @$wrap_calls, ["wrap_map", [$_[0]->[1], $_[1]->[1]]];
return template("Map", @_);
return () if @_ == 0;
my $k = shift; my $v = shift;
push @$wrap_calls, ["wrap_map", [$k->[1], $v->[1]]];
return (template("Map", $k, $v), Map(@_));
}
sub Pair {
push @$wrap_calls, ["wrap_pair", [$_[0]->[1], $_[1]->[1]]];
return template(["Pair", "std::pair", "StdPair", "pair"], @_);
return () if @_ == 0;
my $f = shift; my $s = shift;
push @$wrap_calls, ["wrap_pair", [$f->[1], $s->[1]]];
return (template(["Pair", "std::pair", "StdPair", "pair"], $f, $s), Pair(@_));
}
sub List {
push @$wrap_calls, ["wrap_list", [$_[0]->[1]]];
return template(["List", "std::list", "StdList", "list"], @_);
return () if @_ == 0;
my $e = shift;
push @$wrap_calls, ["wrap_list", [$e->[1]]];
return (template(["List", "std::list", "StdList", "list"], $e), List(@_));
}
sub UniPolynomial {
push @$wrap_calls, ["wrap_unipolynomial", [$_[0]->[1], $_[1]->[1]]];
return template("UniPolynomial", @_);
return () if @_ == 0;
my $c = shift; my $e = shift;
push @$wrap_calls, ["wrap_unipolynomial", [$c->[1], $e->[1]]];
return (template("UniPolynomial", $c, $e), UniPolynomial(@_));
}
sub Polynomial {
push @$wrap_calls, ["wrap_polynomial", [$_[0]->[1], $_[1]->[1]]];
return template("Polynomial", @_);
return () if @_ == 0;
my $c = shift; my $e = shift;
push @$wrap_calls, ["wrap_polynomial", [$c->[1], $e->[1]]];
return (template("Polynomial", $c, $e), Polynomial(@_));
}
sub IncidenceMatrix {
my $i = def("IncidenceMatrix");
Expand All @@ -137,18 +155,24 @@ sub Graph {
template($g, Undirected));
}
sub NodeMap {
return () if @_ == 0;
my $e = shift;
my $nm = ["NodeMap", "pm::graph::NodeMap", "NodeMap", "nodemap"];
push @$wrap_calls, ["wrap_nodemap", ["pm::graph::Undirected", $_[0]->[1]]];
push @$wrap_calls, ["wrap_nodemap", ["pm::graph::Directed" , $_[0]->[1]]];
return (template($nm, Directed, @_),
template($nm, Undirected, @_));
push @$wrap_calls, ["wrap_nodemap", ["pm::graph::Undirected", $e->[1]]];
push @$wrap_calls, ["wrap_nodemap", ["pm::graph::Directed" , $e->[1]]];
return (template($nm, Directed, $e),
template($nm, Undirected, $e),
NodeMap(@_));
}
sub EdgeMap {
return () if @_ == 0;
my $e = shift;
my $em = ["EdgeMap", "pm::graph::EdgeMap", "EdgeMap", "edgemap"];
push @$wrap_calls, ["wrap_edgemap", ["pm::graph::Undirected", $_[0]->[1]]];
push @$wrap_calls, ["wrap_edgemap", ["pm::graph::Directed" , $_[0]->[1]]];
return (template($em, Directed, @_),
template($em, Undirected, @_));
push @$wrap_calls, ["wrap_edgemap", ["pm::graph::Undirected", $e->[1]]];
push @$wrap_calls, ["wrap_edgemap", ["pm::graph::Directed" , $e->[1]]];
return (template($em, Directed, $e),
template($em, Undirected, $e),
EdgeMap(@_));
}

# mapped name, C++, CxxWrap, helper (to_...)
Expand Down Expand Up @@ -214,6 +238,9 @@ sub EdgeMap {
Array(Array(Rational)),
Array(Array(Set(Int))),
Array(Matrix(Integer)),
Array(Matrix(Rational)),
Array(Vector(Integer)),
Array(Vector(Rational)),
Array(BigObject),

Pair(Matrix(TropicalNumber(Max,Rational)),Matrix(TropicalNumber(Max,Rational))),
Expand Down Expand Up @@ -249,21 +276,33 @@ sub EdgeMap {
Map(Set(Int),Rational),
Map(Set(Int),Vector(Rational)),
Map(Vector(Int),Integer),
Map(Pair(Int,Int),Int),
Map(Pair(Int,Int),Vector(Integer)),

IncidenceMatrix,
Array(IncidenceMatrix),

Graph,

NodeMap(Int),
NodeMap(double),
NodeMap(Integer),
NodeMap(Rational),
NodeMap(String),
NodeMap(Set(Int)),
NodeMap(Array(Set(Int))),
NodeMap(Vector(double)),
NodeMap(Vector(Rational)),
NodeMap(IncidenceMatrix),

EdgeMap(Int),
EdgeMap(double),
EdgeMap(Integer),
EdgeMap(Rational),
EdgeMap(String),
EdgeMap(Vector(double)),
EdgeMap(Vector(Rational)),
EdgeMap(Array(Array(Int))),

[
"HomologyGroup_Integer",
Expand Down
2 changes: 1 addition & 1 deletion test-prepare.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Pkg

Pkg.add(name="libcxxwrap_julia_jll", version="0.11.2")
Pkg.pin("libcxxwrap_julia_jll")
Pkg.add(name="polymake_jll", version="400.1100.1")
Pkg.add(name="polymake_jll", version="400.1200.1")

using polymake_jll
using libcxxwrap_julia_jll
Expand Down
Loading