# Example of CDDLib usage: H-representation and V-representation

**URL:** <https://discourse.julialang.org/t/example-of-cddlib-usage-h-representation-and-v-representation/51980>\
**Category:** General Usage\
**Tags:** examples\
**Created:** [December 17, 2020, 12:42pm UTC](https://discourse.julialang.org/t/example-of-cddlib-usage-h-representation-and-v-representation/51980 "2020-12-17T12:42:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stla/32/20382_2.png) [@stla](https://discourse.julialang.org/u/stla)\
**Post date:** [December 17, 2020, 12:42pm UTC](https://discourse.julialang.org/t/example-of-cddlib-usage-h-representation-and-v-representation/51980/1 "2020-12-17T12:42:35Z")

</div>

Hello,

I’m trying to use [CDDLib](https://github.com/JuliaPolyhedra/CDDLib.jl) but I’m lost.

Given a set of inequalities represented as a matrix and a vector, how to get the H-representation of the corresponding polyhedron? Then, how to get its V-representation, and vice-versa?

I looked at the tests and the issues but to no avail.

---

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stla/32/20382_2.png) [@stla](https://discourse.julialang.org/u/stla)\
**Post date:** [December 17, 2020, 12:59pm UTC](https://discourse.julialang.org/t/example-of-cddlib-usage-h-representation-and-v-representation/51980/2 "2020-12-17T12:59:28Z")

</div>

Ah I have a working example:

```julia
using Polyhedra
A = [-1//1 0//1; 0//1 -1//1; 1//1 1//1]
b = [1//1; -1//1; 5//1]
h = hrep(A, b)
p = polyhedron(h)
points(p)

```

The V-representation: `p.vrep`.

We can retrieve it as follows:

```julia
pts = collect(points(p))
lns = collect(lines(p))
rys = collect(rays(p))
vrep(pts, lns, rys)

```

Still investigating…

---

<div class="post-metadata">

**Author:** ![stla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stla/32/20382_2.png) [@stla](https://discourse.julialang.org/u/stla)\
**Post date:** [December 22, 2020, 6:15pm UTC](https://discourse.julialang.org/t/example-of-cddlib-usage-h-representation-and-v-representation/51980/3 "2020-12-22T18:15:14Z")

</div>

Now I’ve found how to go from the V-rep to the H-rep:

```julia
V = vrep(pts, lns, rys)
P2 = polyhedron(V)
H2 = hrep(P2).halfspaces
A = map(x -> x.a, H2)
b = map(x -> x.β, H2)

```

To use `CCDLib`, it suffices to do `polyhedron(V, CDDLib.Library(:exact))`.
