帮助理解伪代码
有人可以告诉我如何实现以下伪代码行。
c[k]=c[k] (mod M) with |c[k]|<=M/2
我不明白“with”是什么意思,这是否意味着我必须确保在对 M 进行约减后,c[k] 必须小于或等于 M/2。伪代码中的“with”通常意味着什么(如果有的话)?
请注意,M 是 int 类型。如果有帮助的话,我正在用 Java 实现这个。
提前致谢。
Can someone please tell me how I can implement the following line of pseudo-code.
c[k]=c[k] (mod M) with |c[k]|<=M/2
I do not understand what the 'with' means, does it mean that I have to ensure that after reduction modulo M, c[k] must be less than or equal to M/2. What does 'with' usually mean (if anything) in pseudo-code?
Note that M is of type int. I'm implementing this in Java if it helps.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为这意味着设置
c[k] = c[k] + x*M
,其中-M/2 <= c[k] + x*M <= M/ 2
(选择正整数或负整数x
,以使该结果为真)。例如,如果 M = 5,我们将有:
I think it means set
c[k] = c[k] + x*M
, where-M/2 <= c[k] + x*M <= M/2
(choose the positive or negative integerx
such that this is true).For example, if M = 5, we would have:
唔。草率的伪代码,呵呵。但我认为他是说 c[k] 的绝对值也将小于或等于 M 除以 2 的模值。但这或多或少只是一个猜测。我从未遇到过使用这个术语(the with)的伪代码。也许他只是想让人们知道,由于模运算,c[k] 总是在范围内。
Hmm. Sloppy pseudo-code, heh. But I think he is saying that the absolute value of c[k] will be less than or equal too the modulo value of M divided by 2. This is more or less just a guess however. I have never encountered pseudo code with this terminology (the with) being used. Maybe he is just trying to let people know that c[k] is always insured to be with in bounds because of the modulo arithmetic.
这一定是伪代码吗?通常,伪代码只是描述代码将做什么,但是用更自然的语言(例如更像英语)。在这种情况下,我什至不确定所描述的是什么。此外,我认为“with”不一定有专门的含义,尤其是在没有看到其余内容的上下文的情况下。如果您提供更多信息可能会有所帮助。
Is this necessarily pseudo-code? Typically, pseudo-code is just describing what code will do, but in a more natural language (e.g. more like English). In this case, I'm not exactly sure what is even being described. Additionally, I don't think 'with' necessarily has a specialized meaning, especially without seeing the context of the rest of what is written. It might be helpful if you provide more information.
c[k]=c[k] (mod M) with |c[k]|<=M/2
“With”来自数学,意思是“如果条件为真,则这样做
”标记了这个“java”,所以我使用了Java数学库。
c[k]=c[k] (mod M) with |c[k]|<=M/2
The "With" comes from mathematics, and means "If the condition is true, then do so"
You've tagged this "java", so I used the Java math library.