I was wondering if anyone knew of a julia equivalent function to a sum using sigma. For example if I wanted a sum of this sort (unsure of how to show sigma notation, so here is a picture of what I am looking for):
Both c
and x
would be matrices that I would define earlier in the code. Does anyone know how to code this in Julia or whether julia has an equivalent function?
I have used sum
for more simple vector sums, but I am not sure if that would translate to much larger matrices. Any ideas?
If you are talking about plain-old-Julia variables
c = rand(5,3)
x = rand(5,3)
@show sum(c.*x)
But if you are referring to JuMP (based on your previous questions), then use sum{}
:
using JuMP
m = Model()
@variable(m, 0 <= x[i=1:5,j=1:3] <= 1)
c = rand(5,3)
@constraint(m, sum{c[i,j]*x[i,j],i=1:5,j=1:3} <= 10)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With