Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3、4、5、6号帖之外的勘误,请提交到这里 #7

Open
jeffreybaoshenlee opened this issue Aug 20, 2017 · 12 comments
Open

3、4、5、6号帖之外的勘误,请提交到这里 #7

jeffreybaoshenlee opened this issue Aug 20, 2017 · 12 comments

Comments

@jeffreybaoshenlee
Copy link
Owner

如题。

@bianliangpai
Copy link

第2章,P8-9,“你可能会发现,如果第一个数比第二个数大,那么把两者进行交换以后在进行运算应该会更快一些(例如计算3x15,要比计算15x3更为容易)”
3x15要计算的加法次数肯定要多于15x3啊
这里不知道是不是我没有理解作者的意思,个人感觉显然是15x3计算起来更快

@jeffreybaoshenlee
Copy link
Owner Author

@bianliangpai 您好,感谢您指出这个问题。

本来我应该在这里加上译者注的。我想,作者在这里指的可能不是普通的连加方式。如果按照普通的连加方式来算 15×3,那么自然应该直接展开,变成 15+15+15=45,这样只需要做两次加法,反之,3×15 若是直接展开成连加式,则是 3+3+...+3=45,要做 14 次加法。

作者这么说,可能采用的是早前 multiply1 函数的思路。按照那个函数的算法,应该一直对被乘数(也就是乘号左边的那个数)减半,直到把它化简成 1 为止。所以,如果被乘数比较大(例如 15×3 之中的 15),那么需要化简的次数就比较多。例如要先把 15×3 化简为 7×6+3,然后继续运用 multiply1 算法,把 7×6 这一部分,化简为 3×12+6,接下来还是要用 multiply1 算法,把 3×12 这一部分,化简成 1×24+12,最后又调用一次 multiply1 算法,直接求出 1×24 的结果。这样看来,一共要调用 4 次算法。

假如将两个数的位置对调,把比较小的 3 放在乘号左边,让它充当被乘数,那么第一次调用 multiply1 算法之后,就已经化简成了 1×30+15,接下来只需要再对 1×30 这一部分,调用一次 multiply1 算法,就可结束整个递归过程。这样总共只需要调用两次算法。

@bianliangpai
Copy link

@jeffreybaoshenlee 非常感谢您的解释,这下我理解了

@DoubleNinthLu
Copy link

请问,书中课后习题的参考答案可以从哪里获得?

@jeffreybaoshenlee
Copy link
Owner Author

jeffreybaoshenlee commented Oct 23, 2019

@Concretion ,您好。感谢您阅读本书并指出这个问题。

很抱歉,我当时并没有专门想过这个问题。今天去原书在 informit 网站的页面(https://www.informit.com/store/from-mathematics-to-generic-programming-9780321942043 )看了看,那里没有习题答案。另外,Amazon 的评论(https://www.amazon.com/gp/customer-reviews/R2E9T6LN7KX63P/ref=cm_cr_getr_d_rvw_ttl )也提到了这个问题。

后续如果有动态,我会贴在这个 issue(#8 )里面。

@DoubleNinthLu
Copy link

@jeffreybaoshenlee 非常感谢你的及时回复。

@bianliangpai
Copy link

P19,“(也就是说,它是p的倍数)”
这里是不是应该改为上一句中提到的“它是比p小的那个素数的倍数”?

@bianliangpai
Copy link

P24,公式 3.2 ,等号右边第一项,是不是应该是 x^n+1 ?
公式3.3 等号右边最后一项同理

@jeffreybaoshenlee
Copy link
Owner Author

P19,“(也就是说,它是p的倍数)”
这里是不是应该改为上一句中提到的“它是比p小的那个素数的倍数”?

嗯,您说的对,这里应该把“它是 p 的倍数”改成“它是比 p 小的那个素数的倍数”。感谢您指出这个错误。

@jeffreybaoshenlee
Copy link
Owner Author

P24,公式 3.2 ,等号右边第一项,是不是应该是 x^n+1 ?
公式3.3 等号右边最后一项同理

嗯,我刚才查了原书,这可能是扫描公式的时候出现了错误。感谢您指出这两个错误。

@jeffreybaoshenlee
Copy link
Owner Author

@bianliangpai 抱歉这么久才回复。最近没有看 github,今天刚上来看到。我已经把这三个错误整理到勘误表( #9 )里面了。多谢您指教~

@jeffreybaoshenlee
Copy link
Owner Author

请问,书中课后习题的参考答案可以从哪里获得?

@DoubleNinthLu 您好,最近我又找了找习题答案,发现了这个 Repo: https://github.com/bmershon/fm2gp ,请参考。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants