朱莉娅的总和表示法?(Sum notation in julia?)

系统教程 行业动态 更新时间:2024-06-14 16:57:39
朱莉娅的总和表示法?(Sum notation in julia?)

我想知道是否有人知道使用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)

更多推荐

本文发布于:2023-04-13 12:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/ae0f85f4f811edc7f7d814b90848d350.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:总和   朱莉   Sum   julia   notation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!