@polyvar does not allow two-dimensional variables

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

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

But now I get this error:

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!

This is possible with DynamicPolynomials but not yet with TypedPolynomials.
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.

1 Like

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!

It is not possible with typed polynomials.

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