我试图记住如何计算循环冗余检查中的 XOR 算法的余数以验证网络消息的余数位。
我不应该扔掉那本教科书。
这在代码中很容易完成,但是如何手动完成呢?
我知道它看起来像一个标准的除法算法,但我不记得从那里去哪里得到余数。
___________
1010 | 101101000
Run Code Online (Sandbox Code Playgroud)
注意:我确实在谷歌上搜索过,但无法找到他们在计算剩余部分时映射步骤的地方。
我正在尝试使用运算符重载来定义我的多项式类的基本运算(+, - ,*,/)但是当我运行程序时它会崩溃并且我的计算机冻结.
UPDATE4
好.我成功完成了三次操作,剩下的唯一一次是划分.
这是我得到的:
polinom operator*(const polinom& P) const
{
polinom Result;
constIter i, j, lastItem = Result.poly.end();
Iter it1, it2, first, last;
int nr_matches;
for (i = poly.begin() ; i != poly.end(); i++) {
for (j = P.poly.begin(); j != P.poly.end(); j++)
Result.insert(i->coef * j->coef, i->pow + j->pow);
}
Result.poly.sort(SortDescending());
lastItem--;
while (true) {
nr_matches = 0;
for (it1 = Result.poly.begin(); it1 != lastItem; it1++) {
first = it1;
last = it1;
first++;
for (it2 = first; …Run Code Online (Sandbox Code Playgroud) 人们会期望并希望如果你要求Mathematica找到多项式的根,它应该给出相同的(近似的)答案,无论你是否象征性地做这个,然后找到这些确切答案的数值近似值,或者你是否用数字表示.这是一个例子(在Mathematica 7OS X上运行),这种情况严重失败:
poly = -112 + 1/q^28 + 1/q^26 - 1/q^24 - 6/q^22 - 14/q^20 - 25/q^18 -
38/q^16 - 52/q^14 - 67/q^12 - 81/q^10 - 93/q^8 - 102/q^6 - 108/
q^4 - 111/q^2 - 111 q^2 - 108 q^4 - 102 q^6 - 93 q^8 - 81 q^10 -
67 q^12 - 52 q^14 - 38 q^16 - 25 q^18 - 14 q^20 - 6 q^22 - q^24 +
q^26 + q^28;
Total[q^4 /. …Run Code Online (Sandbox Code Playgroud) 我有一组XY值(即散点图),我想要一个Pascal例程来生成适合这些点的N阶多项式的系数,就像Excel一样.
我有一个名为Term的多样化Java类,如下所示
public Term(int c, int e) throws NegativeExponent {
if (e < 0) throw new NegativeExponent();
coef = c;
expo = (coef == 0) ? 1 : e;
}
Run Code Online (Sandbox Code Playgroud)
我在同一个类中也有一个equals方法,如下所示
@Override
public boolean equals(Object obj) {
}
Run Code Online (Sandbox Code Playgroud)
我坚持如何编码如何比较这两个Term对象
在我的JUnit测试文件中,我使用下面的测试来尝试测试equals方法
import static org.junit.Assert.*;
import org.junit.Test;
public class ConEqTest
{
private int min = Integer.MIN_VALUE;
private int max = Integer.MAX_VALUE;
@Test
public void eq01() throws TError { assertTrue(new Term(-10,0).equals(new Term(-10,0))); }
@Test
public void eq02() throws TError { assertTrue(new Term(0,0).equals(new Term(0,2))); }
Run Code Online (Sandbox Code Playgroud) 如果我在多项式时间子程序中运行多项式次数,那么在指数时间内完成这种方式的一些例子是什么?
"表明对多项式时间子程序的多项式调用次数可能导致指数时间算法." - HW的问题
我需要在 Java 中使用多项式 x^16 + x^12 + x^5 + 1 (0x1081) 计算 CCITT 标准 CRC 的帮助。我在互联网上尝试了很多示例,但每个示例都返回示例中的值以外的其他值。
例如,对于这个数组 [0xFC] [05] [11],结果需要是 [27] [56]。
使用此代码:
public static void main(String[] args) {
byte[] array = new byte[3];
array[0] = (byte) 0xFC;
array[1] = (byte) 0x05;
array[2] = (byte) 0x11;
// array[3] = (byte) 0x00;
// array[4] = (byte) 0x00;
System.out.println(Integer.toHexString(crc16(array)));
}
private static final int POLYNOMIAL = 0x1081;
private static final int PRESET_VALUE = 0xFFFF;
public static int crc16(byte[] data) {
int current_crc_value …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个算法a(0),..., a(n-1),在给定值的情况下n, x_1, ..., x_n, a(n),它将找到:
a(n)*p^n + a(n-1)*p^(n-1) + ... + a(1)*p + a(0) = a(n)(p-x_1)(p-x_2)...(p-x_n)
Run Code Online (Sandbox Code Playgroud)
对于所有真正的p.
在乘以(n)(p-x_1)(p-x_2)后,我想到使用Viete的公式来找到系数.
但事实证明,编写代码并不像我预期的那么明显.
我想只使用代码中的基础知识 - 即循环,if-s加法和乘法 - 没有现成/复杂函数.
首先,我想强调一下,我只需要一个伪代码,而不关心为根和系数定义数组.这就是为什么我会写一个(n),xn.哦,如果我从i = 1开始索引而不是i = 0以便与数学符号同步,我希望它不会打扰你.为了从i = 0开始,我必须重新编写根并引入更多括号.
这就是我到目前为止所提出的:
a(n-1)=0;
for(i=1; i <= n; i++){
a(n-1) = a(n-1) + x_i;
}
a(n-1) = -a(n)*a(n-1);
a(n-2)=0;
for(i=1; i <= n; i++){
for(j=i; j <= n; j++){
a(n-2) = a(n-2)+ x_i * x_j;
}
}
a(n-2) = -a(n)*a(n-2);
a(n-3)=0;
for(i=1; i <= n; …Run Code Online (Sandbox Code Playgroud) 我有等式y = 3(x + 1)^ 2 + 5(x + 1)^ 4.
使用Horner方案,我可以用这种形式评估这个多项式,y = 8 + x(26 + x(33 + x(20 + 5x))),因此需要8次算术运算.
我也可以用这种形式评估它,y =(x + 1)^ 2*((5x + 10)x + 8),需要7次操作.
我被告知这可以在5次操作中完成,但Horner的算法应该是最有效的,它只能在7次操作中完成.我错过了什么吗?
polynomial-math ×10
algorithm ×3
java ×2
bezier ×1
c++ ×1
calculator ×1
computation ×1
crc ×1
crc16 ×1
curve ×1
delphi ×1
equals ×1
for-loop ×1
junit ×1
loops ×1
object ×1
operations ×1
pascal ×1
performance ×1
polynomials ×1
quadratic ×1
regression ×1
xor ×1