# X' allowed in JuMP model but not transpose(X)

**URL:** https://discourse.julialang.org/t/x-allowed-in-jump-model-but-not-transpose-x/110147
**Category:** Optimization (Mathematical)
**Tags:** jump
**Created:** [February 13, 2024, 11:06am UTC](https://discourse.julialang.org/t/x-allowed-in-jump-model-but-not-transpose-x/110147 "2024-02-13T11:06:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dhendryc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dhendryc/32/206993_2.png) [@dhendryc](https://discourse.julialang.org/u/dhendryc)
#### Post date: [February 13, 2024, 11:06am UTC](https://discourse.julialang.org/t/x-allowed-in-jump-model-but-not-transpose-x/110147/1 "2024-02-13T11:06:33Z")

</div>

Hi,

I have encountered a weird behaviour in JuMP. This works

JuMP.@constraint(model, sum(A[i, :] \* Y\_mat[i,:]’ for i in 1:m) .- sum(μ)\*I .==  
zeros(n,n))

while this does not

```
JuMP.@constraint(model, sum(A[i, :] * transpose(Y_mat[i,:]) for i in 1:m) .- sum(μ)*I .== zeros(n,n))

```

It throws this error  
MethodError: no method matching promote\_array\_mul(::Type{Vector{Float64}}, ::Type{Transpose{VariableRef, Vector{VariableRef}}})

To my understanding, both should be internally the same. Is this a bug or is there a specific reason JuMP does not support transpose() here?

I am on Julia 1.9.0 and JuMP v1.19.0.

---

<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 13, 2024, 7:04pm UTC](https://discourse.julialang.org/t/x-allowed-in-jump-model-but-not-transpose-x/110147/2 "2024-02-13T19:04:23Z")

</div>

Hi @dhendryc, welcome to the forum!

I’ve opened an issue with this bug report: [Missing methods for LinearAlgebra.Transpose · Issue #256 · jump-dev/MutableArithmetics.jl · GitHub](https://github.com/jump-dev/MutableArithmetics.jl/issues/256)

The issue stems from the fact that `x'` is not actually `LinearAlgebra.transpose`, but `LinearAlgebra.adjoint`. (The difference is very subtle.)

```julia
julia> x[1, :]
2-element Vector{VariableRef}:
 x[1,1]
 x[1,2]

julia> x[1, :]'
1×2 adjoint(::Vector{VariableRef}) with eltype VariableRef:
 x[1,1] x[1,2]

julia> transpose(x[1, :])
1×2 transpose(::Vector{VariableRef}) with eltype VariableRef:
 x[1,1] x[1,2]

julia> adjoint(x[1, :])
1×2 adjoint(::Vector{VariableRef}) with eltype VariableRef:
 x[1,1] x[1,2]

```

But this is a bad MethodError, and we can fix to support `transpose` as well.

---

<div class="post-metadata">

### Author: ![dhendryc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dhendryc/32/206993_2.png) [@dhendryc](https://discourse.julialang.org/u/dhendryc)
#### Post date: [February 14, 2024, 10:08am UTC](https://discourse.julialang.org/t/x-allowed-in-jump-model-but-not-transpose-x/110147/3 "2024-02-14T10:08:56Z")

</div>

Hi @odow ,

thank you for the clarification!

It would be nice if JuMP also supported `transpose`. I find it easier to catch modelling errors, `'` can be easily overlooked.

---

<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 14, 2024, 6:39pm UTC](https://discourse.julialang.org/t/x-allowed-in-jump-model-but-not-transpose-x/110147/4 "2024-02-14T18:39:37Z")

</div>

I’ve fixed this in MutableArithmetics.jl, so it just needs a new release. Likely in the next day or two 😄
