# @polyvar does not allow two-dimensional variables

**URL:** <https://discourse.julialang.org/t/polyvar-does-not-allow-two-dimensional-variables/52395>\
**Category:** Optimization (Mathematical)\
**Tags:** package, jump, polynomials\
**Created:** [December 26, 2020, 5:55am UTC](https://discourse.julialang.org/t/polyvar-does-not-allow-two-dimensional-variables/52395 "2020-12-26T05:55:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aliceee](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@aliceee](https://discourse.julialang.org/u/aliceee)\
**Post date:** [December 26, 2020, 5:55am UTC](https://discourse.julialang.org/t/polyvar-does-not-allow-two-dimensional-variables/52395/1 "2020-12-26T05:55:57Z")

</div>

I want define a polyvar with size 2\*3. Several weeks ago, the following code works

```julia
using TypedPolynomials
@polyvar B[1:2,1:3] 

```

But now I get this error:

```julia
Unsupported syntax. Expected x[a:b] for literal integers a and b

```

It only allows something like this: @polyvar B[1:2]. I wonder if anyone can help me with this? How can I define a matrix-sized polyvar? It is kind of important for me because I need to do matrix multiplication with the polyvar. Thanks in advance!

---

<div class="post-metadata">

**Author:** ![blegat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blegat/32/217090_2.png) [@blegat](https://discourse.julialang.org/u/blegat)\
**Post date:** [January 4, 2021, 10:24am UTC](https://discourse.julialang.org/t/polyvar-does-not-allow-two-dimensional-variables/52395/2 "2021-01-04T10:24:50Z")

</div>

This is possible with [DynamicPolynomials](https://github.com/JuliaAlgebra/DynamicPolynomials.jl/) but not yet with [TypedPolynomials](https://github.com/JuliaAlgebra/TypedPolynomials.jl).  
The reason for this is that different variables have different types for TypedPolynomials so the `@polyvar` macro returns a tuple. In DynamicPolynomials, all variables have the same type so th macro returns an `Array`.

---

<div class="post-metadata">

**Author:** ![aliceee](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@aliceee](https://discourse.julialang.org/u/aliceee)\
**Post date:** [February 7, 2021, 5:09pm UTC](https://discourse.julialang.org/t/polyvar-does-not-allow-two-dimensional-variables/52395/3 "2021-02-07T17:09:37Z")

</div>

Thanks for your reply, but it indeed happened with this piece of code. I did not use DynamicPolynomials at all. I wonder if you can help me figure out why.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [February 7, 2021, 6:07pm UTC](https://discourse.julialang.org/t/polyvar-does-not-allow-two-dimensional-variables/52395/4 "2021-02-07T18:07:03Z")

</div>

It is not possible with typed polynomials.

---

<div class="post-metadata">

**Author:** ![aliceee](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@aliceee](https://discourse.julialang.org/u/aliceee)\
**Post date:** [February 7, 2021, 6:15pm UTC](https://discourse.julialang.org/t/polyvar-does-not-allow-two-dimensional-variables/52395/5 "2021-02-07T18:15:42Z")

</div>

Oh I see. I misunderstood blegat’s earlier reply. Thanks!
