我想知道是否有人知道使用sigma的总和的julia等效函数。 例如,如果我想要这种总和(不确定如何显示sigma符号,那么这里是我正在寻找的图片):
c和x都是我在代码中先前定义的矩阵。 有谁知道如何在朱莉娅编码这个或julia是否具有相同的功能? 我使用sum更简单的向量和,但我不确定这是否会转化为更大的矩阵。 有任何想法吗?
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?
最满意答案
如果你在谈论普通的朱莉娅变量
c = rand(5,3) x = rand(5,3) @show sum(c.*x)但是,如果你指的是JuMP(根据你以前的问题),那么使用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 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)更多推荐
发布评论