changelog
- -约 20 个字
-General¶
-Blog¶
-Meta¶
-Obsidian¶
-Social¶
-Minifier¶
-Debugger¶
--
Legend
-❎ - added ✅ - fixed ♻️ - changed 🚫 - removed
-diff --git a/CS/CO/5_/index.html b/CS/CO/5_/index.html index c2dd50a..01931d9 100644 --- a/CS/CO/5_/index.html +++ b/CS/CO/5_/index.html @@ -3950,7 +3950,7 @@
约 78 个字 54 行代码 预计阅读时间 1 分钟
+约 78 个字 53 行代码 预计阅读时间 1 分钟
#include <iostream>
+51
#include <iostream>
using namespace std;
-
-class A
-{
-public:
- A(int i) : mi(i) {}
- A(const A &rhs) : mi(rhs.mi)
- {
- cout << "A::A(&)" << endl;
- }
- A &operator=(const A &rhs)
- {
- mi = rhs.mi;
- cout << "A::operator=()" << endl;
- return *this;
- }
- virtual void f()
- {
- cout << "A::f(), " << mi << endl;
- }
-
-protected:
- int mi;
-};
-
-class B : public A
-{
-public:
- B(int i, int j) : A(i), mj(j) {}
- void f() override
- {
- cout << "B::f(), " << mi << ", " << mj << endl;
- }
-
-private:
- int mj;
-};
-
-int main()
-{
- A a1(1);
- B b(3, 4);
-
- A &ra = b;
- ra.f();
- ra = a1;
- ra.f();
-
- A a2 = b;
- a2.f();
-}
+class A
+{
+public:
+ A(int i) : mi(i) {}
+ A(const A &rhs) : mi(rhs.mi)
+ {
+ cout << "A::A(&)" << endl;
+ }
+ A &operator=(const A &rhs)
+ {
+ mi = rhs.mi;
+ cout << "A::operator=()" << endl;
+ return *this;
+ }
+ virtual void f()
+ {
+ cout << "A::f(), " << mi << endl;
+ }
+
+protected:
+ int mi;
+};
+
+class B : public A
+{
+public:
+ B(int i, int j) : A(i), mj(j) {}
+ void f() override
+ {
+ cout << "B::f(), " << mi << ", " << mj << endl;
+ }
+
+private:
+ int mj;
+};
+
+int main()
+{
+ A a1(1);
+ B b(3, 4);
+
+ A &ra = b;
+ ra.f();
+ ra = a1;
+ ra.f();
+
+ A a2 = b;
+ a2.f();
+}
约 10 个字
+约 14 个字
资源
官方教程 : https://cmake.org/cmake/help/latest/guide/tutorial/index.html
Backlinks:
+| CMake| https://cmake.org/cmake/help/latest/guide/tutorial/index.html |
+约 71 个字
+约 75 个字
Backlinks:
+约 1026 个字 87 行代码 预计阅读时间 6 分钟
+约 1035 个字 88 行代码 预计阅读时间 6 分钟
资料:
@@ -3127,20 +3109,21 @@GNU Make使用过程¶
-
基本介绍¶
+基本介绍¶
-静态模式¶
+静态模式¶
更容易定义多目标的规则
1 2 @@ -3309,7 +3292,7 @@静态模式
prereq-patterns
是目标的依赖模式,它对 target-pattern 形成的模式再进行一次依赖目标的定义。
-* 自动¶
+* 自动¶
GNU 组织建议把编译器为每一个源文件的自动生成的依赖关系放到一个文件中,为每一个
name.c
的文件都生成一个name.d
的 Makefile 文件,.d
文件中就存放对应.c
文件的依赖关系。 通过gcc
命令自动生成依赖文件-
1 @@ -3327,8 +3310,8 @@* 自动&p sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$
书写命令¶
-命令显示¶
+书写命令¶
+命令显示¶
@@ -3347,13 +3330,13 @@
- 通常,make 会把其要执行的命令行在命令执行前输出到屏幕上。当我们用 @ 字符在命令行前,那么,这个命令将不被 make 显示出来,最具代表性的例子是,我们用这个功能来向屏幕显示一些信息。
命令显示命令执行¶
+命令执行¶
-
exec: cd /home/hchen; pwd
不能写在两行上 使得pwd
命令在cd
命令基础上进行嵌套执行¶
+嵌套执行¶
- 优点:模块化¶
-示例¶
+示例¶
+ + +
1 2 3 @@ -3392,6 +3375,39 @@示例&par clean : rm edit $(objects)
+ +Backlinks:
++@@ -3414,7 +3430,7 @@++None
+| GNUMake| 资料: https://seisman.github.io/how-to-write-makefile/introduction.html
+
视频: https://www.youtube.com/watch?v=E1_uuFWibuM&t=1152s |示例&par 2024年4月25日 16:36:37 + 2024年8月2日 13:52:56 diff --git a/Tools/Git/index.html b/Tools/Git/index.html index 09c8030..362aca7 100644 --- a/Tools/Git/index.html +++ b/Tools/Git/index.html @@ -3004,8 +3004,9 @@
Git¶
-+约 353 个字 61 行代码 预计阅读时间 3 分钟
+约 334 个字 75 行代码 预计阅读时间 3 分钟
Docs
@@ -3066,7 +3067,7 @@
Usage&
git log
---
@@ -2710,10 +2852,9 @@ -1 +
usage git init +13
版本回退¶
HEAD表示最新版本,HEAD,HEAD^,HEAD~100表示前一个、前两个、前100个版本
@@ -3237,7 +3238,7 @@代理问题 2024年7月30日 21:38:47 + 2024年8月2日 13:52:56 diff --git a/Tools/Shell/index.html b/Tools/Shell/index.html index 7bd4674..4f4a127 100644 --- a/Tools/Shell/index.html +++ b/Tools/Shell/index.html @@ -131,7 +131,7 @@
- + 跳转至 @@ -599,6 +599,17 @@ + + @@ -609,6 +620,78 @@ + + + + + + @@ -2694,6 +2777,65 @@ + +-+ +
+- + + + streams + + + +
+ +- + + + 关于Unix中的root用户 + + + +
+ +- + + + Bash 编程 + + + +
+ ++ + ++ +
+- + + + prompt + + + +
+ +- + + + Instance + + + +
+ +tools¶
Shell¶
-约 850 个字 42 行代码 预计阅读时间 5 分钟
+约 849 个字 42 行代码 预计阅读时间 5 分钟
环境变量
@@ -2896,7 +3037,7 @@
echo $path
Instance - 2024年7月30日 22:12:27 + 2024年8月2日 13:52:56 diff --git a/Tools/index.html b/Tools/index.html index b1c95a2..dadc588 100644 --- a/Tools/index.html +++ b/Tools/index.html @@ -2696,7 +2696,7 @@
Index
-约 82 个字
+约 75 个字
-@@ -2756,7 +2761,7 @@Note
-Index
- 2024年2月29日 15:46:17 + 2024年8月2日 13:52:56 diff --git "a/Tools/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217/index.html" "b/Tools/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217/index.html" index beaf9c5..b7b36bd 100644 --- "a/Tools/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217/index.html" +++ "b/Tools/\346\255\243\345\210\231\350\241\250\350\276\276\345\274\217/index.html" @@ -2734,7 +2734,7 @@¶ - 2024年5月18日 19:07:47 + 2024年8月2日 13:52:56 diff --git a/_templates/_changelog/index.html b/_templates/_changelog/index.html deleted file mode 100644 index e3b11f0..0000000 --- a/_templates/_changelog/index.html +++ /dev/null @@ -1,2885 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -
changelog - ZZIcarus NOTE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - 跳转至 - - --- -- - - - -- - -- - - - - - - - - --- - - - - - - - - - - ---- - ZZIcarus NOTE - --- - - changelog - - --- -- - - - -- -------- --
- - - - - --- - - - ---- - - - - - - -
-- - - - - - - 封面 - - -
- - - - - - - - - - -- - - - - - - ⚙️ Tools - - -
- - - - - - - - - - -- - - - - - - 课内 - - -
- - - - - - - - - - -- - - - - - - ⌨️ 语言学习 - - -
- - - - - - - - - - -- - - - - - - 杂谈 - - -
- - - - - - - - - - -- - - - - - - Others - - -
- - - - -- - - - - - - - - - - - - - - - -- -- - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/_templates/_page/index.html b/_templates/_note/index.html similarity index 99% rename from _templates/_page/index.html rename to _templates/_note/index.html index bd5f950..d5d8d6c 100644 --- a/_templates/_page/index.html +++ b/_templates/_note/index.html @@ -10,7 +10,7 @@ - + @@ -20,7 +20,7 @@ -ZZIcarus NOTE +NOTE - ZZIcarus NOTE @@ -156,7 +156,7 @@- None + NOTE@@ -2682,7 +2682,7 @@ -ZZIcarus NOTE
+NOTE
约 0 个字
@@ -2709,7 +2709,7 @@ZZIcarus NOTE
- 2024年7月30日 21:38:47 + 2024年8月2日 13:52:56 @@ -2719,7 +2719,7 @@ZZIcarus NOTE
- 2024年7月30日 21:38:47 + 2024年8月2日 13:52:56 diff --git a/_templates/_post/index.html b/_templates/_post/index.html deleted file mode 100644 index 8ad4274..0000000 --- a/_templates/_post/index.html +++ /dev/null @@ -1,2903 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -ZZIcarus NOTE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - 跳转至 - - --- -- - - - -- - -- - - - - - - - - --- - - - - - - - - - - ---- - ZZIcarus NOTE - --- - - None - - --- -- - - - -- -------- --
- - - - - --- - - - ---- - - - - - - -
-- - - - - - - 封面 - - -
- - - - - - - - - - -- - - - - - - ⚙️ Tools - - -
- - - - - - - - - - -- - - - - - - 课内 - - -
- - - - - - - - - - -- - - - - - - ⌨️ 语言学习 - - -
- - - - - - - - - - -- - - - - - - 杂谈 - - -
- - - - - - - - - - -- - - - - - - Others - - -
- - - - -- - - - - - - - - - - - - - - - -- -- - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/images/custom-HomePage.jpg b/images/custom-HomePage.jpg deleted file mode 100644 index 07838c0..0000000 Binary files a/images/custom-HomePage.jpg and /dev/null differ diff --git a/images/custom-wallhaven-85rw5o.jpg b/images/custom-wallhaven-85rw5o.jpg deleted file mode 100644 index 0acb673..0000000 Binary files a/images/custom-wallhaven-85rw5o.jpg and /dev/null differ diff --git a/index.html b/index.html index b434ed5..f1d8658 100644 --- a/index.html +++ b/index.html @@ -2700,36 +2700,17 @@欢迎\(@^0^@)/¶
-约 150 个字 预计阅读时间 1 分钟
+约 23 个字
-站点统计
- 本站共有 92 个页面
- 52643 个字
- 3171 行代码
+ 本站共有 {{ pages }} 个页面
+ {{ words }} 个字
+ {{ codes }} 行代码
-+ diff --git a/search/search_index.json b/search/search_index.json index d3dfdcd..1a128ec 100644 --- a/search/search_index.json +++ b/search/search_index.json @@ -1 +1 @@ -{"config":{"lang":["zh","en"],"separator":"[\\s\\-\\.]+","pipeline":["stemmer"]},"docs":[{"location":"","title":"\u6b22\u8fce\\(@^0^@)/","text":"《一切》 -- -一切都是命运
- 一切都是烟云
- 一切都是没有结局的开始
- 一切都是稍纵即逝的追寻
- 一切欢乐都没有微笑
- 一切苦难都没有泪痕
- 一切语言都是重复
- 一切交往都是初逢
- 一切爱情都在心里
- 一切往事都在梦中
- 一切希望都带着注释
- 一切信仰都带着呻吟
- 一切爆发都有片刻的宁静
- 一切死亡都有冗长的回声
-
-\u7ea6 150 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
\u7ad9\u70b9\u7edf\u8ba1
\u672c\u7ad9\u5171\u6709 92 \u4e2a\u9875\u9762 52643 \u4e2a\u5b57 3171 \u884c\u4ee3\u7801
\u300a\u4e00\u5207\u300b
\u4e00\u5207\u90fd\u662f\u547d\u8fd0 \u4e00\u5207\u90fd\u662f\u70df\u4e91 \u4e00\u5207\u90fd\u662f\u6ca1\u6709\u7ed3\u5c40\u7684\u5f00\u59cb \u4e00\u5207\u90fd\u662f\u7a0d\u7eb5\u5373\u901d\u7684\u8ffd\u5bfb \u4e00\u5207\u6b22\u4e50\u90fd\u6ca1\u6709\u5fae\u7b11 \u4e00\u5207\u82e6\u96be\u90fd\u6ca1\u6709\u6cea\u75d5 \u4e00\u5207\u8bed\u8a00\u90fd\u662f\u91cd\u590d \u4e00\u5207\u4ea4\u5f80\u90fd\u662f\u521d\u9022 \u4e00\u5207\u7231\u60c5\u90fd\u5728\u5fc3\u91cc \u4e00\u5207\u5f80\u4e8b\u90fd\u5728\u68a6\u4e2d \u4e00\u5207\u5e0c\u671b\u90fd\u5e26\u7740\u6ce8\u91ca \u4e00\u5207\u4fe1\u4ef0\u90fd\u5e26\u7740\u547b\u541f \u4e00\u5207\u7206\u53d1\u90fd\u6709\u7247\u523b\u7684\u5b81\u9759 \u4e00\u5207\u6b7b\u4ea1\u90fd\u6709\u5197\u957f\u7684\u56de\u58f0
"},{"location":"CS/","title":"\u8bfe\u5185","text":"\u7ea6 17 \u4e2a\u5b57
\u6982\u8ff0
\u8fd9\u91cc\u653e\u4e00\u4e9bZJU CS\u8bfe\u5185\u7684\u4e1c\u897f
"},{"location":"CS/OOP/","title":"OOP","text":"\u7ea6 4283 \u4e2a\u5b57 651 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 30 \u5206\u949f
INFO
\u4e2a\u4eba\u5728\u8bb0\u8fd9\u90e8\u5206\u7b14\u8bb0\u7684\u65f6\u5019\u4f1a\u6709\u4e00\u90e8\u5206\u62d3\u5c55\u5185\u5bb9\uff0c\u53ef\u80fd\u8003\u8bd5\u5e76\u4e0d\u8981\u6c42\u638c\u63e1;\u4e5f\u6709\u4e00\u90e8\u5206\u5185\u5bb9\u7531\u4e8e\u65f6\u95f4\u539f\u56e0\u6216\u8005\u81ea\u5df1\u89c9\u5f97\u6ca1\u5fc5\u8981\u5199\u4e8e\u662f\u6ca1\u6709\u7740\u58a8\u3002BTW\uff0c\u4e5f\u53ef\u80fd\u4f1a\u6709\u4e00\u4e9b\u9519\u8bef/\u7eb0\u6f0f\uff0c\u6b22\u8fce\u53cd\u9988\uff01
\u672c\u6765\u662f\u60f3\u8981\u628aC++\u7684\u7b14\u8bb0\u4f5c\u4e3a\u6bcf\u4e2a\u70b9\u4e00\u4e2aPage\uff0c\u540e\u6765\u53d1\u73b0\u8fd9\u6837\u4ece\u590d\u4e60OOP\u7684\u89d2\u5ea6\u975e\u5e38\u4e0d\u5229\u3002
\u5185\u5bb9\u6765\u6e90\uff1a\u9648\u7fd4\u8001\u5e08\u4e0a\u8bfe\u5185\u5bb9\u53caPPT\uff0cljj\u8001\u5e08PPT\uff0c\u53ca\u90e8\u5206\u7f51\u7edc\u8d44\u6e90\uff08ljj 21\u5e74\u7684PPT\u4e2d\u5185\u5bb9\u6709\u4e00\u5b9a\u7eb0\u6f0f\uff0c\u770b\u7684\u65f6\u5019\u4e0d\u8981\u76f2\u4ece\uff0c\u6709\u4e00\u90e8\u5206\u89c4\u8303\u5df2\u7ecf\u88ab\u8f83\u65b0\u7684\u89c4\u8303\u53d6\u4ee3;\u4f46\u603b\u4f53\u4e0a\u8fd8\u662f\u633a\u5b9e\u7528\u7684\uff09
- \u4e00\u4e9b\u9898\u76ee\u6536\u96c6\u7684BLOG
- OOP Midterm Review
- \u5386\u5e74\u5377
- 98\u6c47\u603b
- \u65b0\u768498\u6c47\u603b **\u8fd9\u4e2a\u5df2\u7ecf\u5f88\u5168\u9762\u4e86\uff0c\u5efa\u8bae\u770b\u8fd9\u4e2a
- \u7f51\u7ad9\u63a8\u8350
- cpp reference
- modern CPP Programing \u8fd9\u4e2a\u91cc\u9762\u8bb2\u5f97\u5f88\u591a\u4e1c\u897f\u5f88\u5b9e\u7528
- \u9648\u7fd4\u8001\u5e08\u63a8\u8350\u7684\u4e86\u89e3\u7b97\u6cd5\u5e93\u7684\u89c6\u9891
- this pointer \u770b\u8fc7\u4e00\u4e9b\u5173\u4e8eMemory\u7ba1\u7406\u7684\u5185\u5bb9
- \u4e00\u4e9b\u5de5\u5177\u7684\u5b66\u4e60
- CMAKE \u7a0d\u5fae\u770b\u70b9\u4f8b\u5b50\uff0c\u80fd\u660e\u767d\u57fa\u7840\u7528\u6cd5\uff1b\u66f4\u9ad8\u7684\u5c31\u6839\u636e\u4e2a\u4eba\u9700\u8981
\u8bfe\u7a0b\u8bc4\u4ef7/\u603b\u7ed3
\u6388\u8bfe\u6559\u5e08\uff1a\u9648\u7fd4
\u9648\u7fd4\u8001\u5e08\u662fOOP\u8fd9\u95e8\u8bfe\u516c\u8ba4\u7684\u201c\u795e\u201d\uff0c\u5728\u8bfe\u5802\u4e0a\u7528Vim\u6f14\u793a\u4ee3\u7801\u8bb2\u89e3C++\u7279\u6027\uff0c\u5f88\u7b26\u5408\u6211\u5bf9\u7a0b\u5e8f\u5458\u7684\u523b\u677f\u5370\u8c61
\u5173\u4e8e\u8003\u8bd5\uff1a\u8fd9\u95e8\u8bfe\u7684\u8003\u8bd5\u8fd9\u51e0\u5e74\u4e0d\u662f\u5f88\u96be\uff0c\u8003\u524d\u4e00\u5b9a\u5237\u51e0\u5957\u5386\u5e74\u5377\uff0c\u867d\u7136\u98ce\u683c\u5dee\u5f02\u4f1a\u6bd4\u8f83\u5927\uff0c\u4f46\u5bf9\u4e8e\u96be\u70b9\u7684\u8003\u5bdf\u5927\u5dee\u4e0d\u5dee\u3002
\u5206\u6570\u6784\u6210
\u5206\u6570\u6784\u6210\u591a\u4e2a\u6559\u5b66\u73ed\u76f8\u5dee\u4e0d\u5927\u3002\u636e\u6211\u4e2a\u4eba\u4e86\u89e3\uff0c\u7fc1\u607a\u8001\u5e08\u73ed\u4f1a\u6709\u671f\u4e2d\u8003\u8bd5\u3001\u8bfe\u524d\u5c0f\u6d4b\u3001\u7b7e\u5230\uff0c\u5e73\u65f6\u4f5c\u4e1a\u4e5f\u4f1a\u7a0d\u5fae\u591a\u4e00\u70b9\u3002cx\u8001\u5e08\u73ed\u5e73\u65f6\u5206\u57fa\u672c\u7ed9\u6ee1
"},{"location":"CS/OOP/#_1","title":"\u96f6\u788e\u77e5\u8bc6","text":"
- Attendance
- Assignment \u9648\u7fd4\u8001\u5e08\u73ed\u7ea7\u4f5c\u4e1a\u5355\u5468\u4e00\u4e2aLab\uff0c\u53cc\u5468\u662f\u7b80\u5355\u7684\u7a0b\u5e8f\u586b\u7a7a\u3001\u9009\u62e9
- Lab
- \u5e73\u65f6Lab
- Final Lab \u505a\u5e8f\u5217\u5316\u7684\u5904\u7406
- Exam
- Fill in Blank (text) -------- 30 points, 8 problems
- write the output of the given code
- Fill in blank (program) --- 30 points, 2 problems
- single line code completion
- Subjective (function) ----- 20 points, 1 problem \u4f7f\u7528\u4ee3\u7801markdown\u4ee3\u7801\u5757\u5d4c\u8fdb\u53bb\uff0c\u5426\u5219\u53ef\u80fd\u51fa\u73b0\u90e8\u5206\u6d88\u5931
- class design
- function implementation
- Multiple Choice (SA) ----- 20 points, 1 problem \u5355\u9009
- miscellaneous \u6982\u5ff5\u6027\uff0c\u8bed\u8a00\u4e0a\u7684; \u4f8b\u5982\uff0cC++\u8bed\u8a00\u7684\u7279\u6027
mention
\u8fd9\u91cc\u7684\u4e00\u90e8\u5206\u5185\u5bb9\uff08union\uff09\u6211\u53ea\u5728ljj\u768421\u5e74PPT\u4e0a\u770b\u5230\u8fc7\uff0c\u4e0d\u77e5\u9053\u5728\u4e0d\u5728\u8003\u8bd5\u8303\u56f4\u5185
"},{"location":"CS/OOP/#const","title":"const","text":"
const int
int const
\u7b49\u4ef7
int * const p
\u8fd9\u4e2a\u6307\u9488\u662f\u4e00\u4e2a\u5e38\u91cf\uff0c\u5fc5\u987b\u5728\u5b9a\u4e49\u7684\u65f6\u5019\u8d4b\u503c\uff0c\u6307\u5411\u4e00\u4e2aint
\u7c7b\u578b\u7684\u53d8\u91cf
int const *p
\u8fd9\u4e2a\u6307\u9488\u672c\u8eab\u4e0d\u662fconst\uff0c\u6307\u5411\u7684\u5bf9\u8c61\u662fconst\u5bf9\u8c61
int const * const p
\"\u7f1d\u5408\u602a\"\uff08\u7c7b\u7684const\u5bf9\u8c61
"},{"location":"CS/OOP/#inline","title":"inline","text":"
- \u4e0d\u80fd\u8c03\u7528non-const\u51fd\u6570
"},{"location":"CS/OOP/#_2","title":"\u5f15\u7528","text":"
- \u9012\u5f52\u51fd\u6570\u4e0d\u80fd\u58f0\u660e\u4e3ainline\u51fd\u6570
- \u7c7b\u4e2d\u542b\u6709\u51fd\u6570\u4f53\u9ed8\u8ba4\u4e3ainline\u51fd\u6570
\u50cf\u662f\u4e00\u4e2a\u6307\u9488\u5e38\u91cf,\u53ea\u6709\u5728\u521d\u59cb\u5316\u7684\u65f6\u5019\u624d\u4f1a\u8d4b\u503c,\u4e4b\u540e\u5b83\u7684\u503c\u4e0d\u53d8,\u4f46\u662f\u6307\u5411\u7684\u53ef\u80fd\u4f1a\u53d8.
const int &
\u7684\u9650\u5236\u662f\u4e0d\u80fd\u901a\u8fc7\u8fd9\u4e2a\u5f15\u7528\u53d8\u91cf\u5bf9\u503c\u8fdb\u884c\u6539\u53d8."},{"location":"CS/OOP/#static-extern","title":"static & extern","text":"
- \u4e0d\u80fd\u58f0\u660e\u5f15\u7528\u7684\u5f15\u7528\uff0c\u4e5f\u4e0d\u80fd\u5b9a\u4e49\u5f15\u7528\u7684\u6307\u9488\u3002\u5982\uff1a \u4e0b\u4f8b\u4e2d\u7684\u64cd\u4f5c\u662f\u8fbe\u4e0d\u5230\u7684\uff1a
int a;\nint & & ra=a;\nint &*p=&ra; //\u9519\u8bef\n
- \u4e0d\u80fd\u5efa\u7acb\u6570\u7ec4\u7684\u5f15\u7528\uff0c\u56e0\u4e3a\u6570\u7ec4\u662f\u4e00\u4e2a\u7531\u82e5\u5e72\u4e2a\u5143\u7d20\u6240\u7ec4\u6210\u7684\u96c6\u5408\uff0c\u6240\u4ee5\u5c31\u65e0\u6cd5\u5efa\u7acb\u4e00\u4e2a\u6570\u7ec4\u7684\u522b\u540d\u3002
- \u4e0d\u80fd\u5efa\u7acb\u7a7a\u6307\u9488\u7684\u5f15\u7528\uff0c\u5982\uff1a\u4e0d\u80fd\u5efa\u7acb
int &rp=NULL
- \u4e5f\u4e0d\u80fd\u5efa\u7acb\u7a7a\u7c7b\u578bvoid\u7684\u5f15\u7528\uff0c\u5982\u4e0d\u80fd\u5efa\u7acb\uff1a
void &ra=3
- \u5bf9\u4e8e\u4e00\u4e2a\u63a5\u53d7
non-const
\u53d8\u91cf\u7684\u51fd\u6570\u6765\u8bf4,\u4f20\u5165\u7684\u53c2\u6570\u4e00\u5b9a\u8981\u662f\u4e00\u4e2a\u5de6\u503cvoid func (int &);\nfunc (i * 3); // Warning or Error!\n
NOTES
"},{"location":"CS/OOP/#inline-function","title":"inline Function","text":""},{"location":"CS/OOP/#defalut-value","title":"Defalut Value","text":"inline int add(int a,int b){...}\n
"},{"location":"CS/OOP/#_3","title":"\u4f5c\u7528\u57df\u6807\u8bc6\u7b26","text":"
- Defalut value\u5fc5\u987b\u5728\u51fd\u6570\u6700\u53f3\u4fa7
- \u7b2c\u4e00\u4e2a\u7f3a\u7701\u503c\u51fa\u73b0\u4e4b\u540e\uff0c\u540e\u9762\u7684\u6240\u6709\u7f3a\u7701\u503c\u90fd\u9ed8\u8ba4\u4e3a\u7f3a\u7701\u503c
int fun(int I,int j=5,int k); //\u9519\u8bef\nint fun(int I,int k = 1,int j=5); //\u6b63\u786e\nfun(0,0) // Right\nfun(0) // Right\nfun(0,,0) // Wrong\n
::
\u5728\u5c40\u90e8\u533a\u57df\u4f7f\u7528\u5168\u5c40\u7684\u503c"},{"location":"CS/OOP/#union","title":"union","text":"int A = 500;\nint main()\n{\n int A = 40;\n cout << A << \" \" << ::A << endl;\n return 0;\n}\n
The size of the union is equal to the size of the largest data type.
\u6682\u65f6\u611f\u53d7\u4e0d\u5230\u4ed6\u6709\u4ec0\u4e48\u7528
"},{"location":"CS/OOP/#named-casts","title":"Named Casts","text":""},{"location":"CS/OOP/#static_cast","title":"static_cast","text":"
- \u5168\u5c40\u533f\u540dunion\u5fc5\u987b\u662fstatic
\u6839\u636e\u7f16\u8bd1\u65f6\u72b6\u6001\u8fdb\u884ccast\u8f6c\u6362
example
- \u53ea\u80fd\u8f6c\u6362\u76f8\u5173\u7684\u5173\u7cfb
\u4e0d\u80fd\u79fb\u9664const
\u57fa\u7840\u6570\u636e\u7c7b\u578b\u7684\u8f6c\u6362
- \u6d3e\u751f\u7684\u6307\u9488/\u5f15\u7528\u5411\u57fa\u7c7b
- \u57fa\u7c7b\u5411\u6d3e\u751f\u7c7b
\u8f93\u51fa\uff1aclass Base\n{\npublic:\n int val;\n Base(int x) : val(x) { cout << \"Base()\" << endl; }\n};\nclass Derived : public Base\n{\npublic:\n Derived(int x) : Base(x) { cout << \"Derived()\" << endl; }\n};\nclass Another\n{\n};\nint main()\n{\n double b = 1.01;\n int a = static_cast<int>(b);\n Base base(1), *bp;\n Derived d(2), *dp;\n bp = &base;\n // Derived d = static_cast<Derived>(base); \u9519\u8bef\uff01\u53ea\u80fd\u6307\u9488/\u5f15\u7528\n dp = static_cast<Derived *>(bp);\n cout << dp->val << endl;\n dp = &d;\n bp = static_cast<Base *>(dp);\n cout << bp->val << endl;\n return 0;\n}\n
"},{"location":"CS/OOP/#dynamic_cast","title":"dynamic_cast","text":"Base()\nBase()\nDerived()\n1\n2\n
\u83b7\u5f97\u8fd0\u884c\u65f6\u7684\u72b6\u6001
- \u5fc5\u987b\u8981\u662f\u591a\u6001\uff0c\u9700\u8981\u5b58\u5728Virtual Function\u6765\u83b7\u53d6\u8fd0\u884c\u65f6\u4fe1\u606f
- \u53ea\u9700\u8981\u8f6c\u6362\u7684\u57fa\u7c7b\u662f\u591a\u6001\u7c7b\u5c31\u53ef\u4ee5\u8fd0\u884c\uff0c\u4f46\u662f\u53ef\u80fd\u4ea7\u751fnullptr
"},{"location":"CS/OOP/#reinterpret_cast","title":"reinterpret_cast","text":"A *pa = new B;\nC *pc = static_cast<C *>(pa); // OK: but *pa is B!\ncout << pa << endl; // 0xe22580\ncout << pc << endl; // 0xe22580\nB *pb = dynamic_cast<B *>(pa); // OK:\nC *pcDy = dynamic_cast<C *>(pa); // Not OK:\ncout << pb << endl; // 0xe22580\ncout << pcDy << endl; // 0 nullptr\n
\u5e95\u5c42\u8868\u793a\u4e0d\u53d8\uff0c\u4f46\u662f\u7406\u89e3\u4e3a\u53e6\u5916\u4e00\u79cd
"},{"location":"CS/OOP/#const_cast","title":"const_cast","text":"const
const\u4e4b\u95f4\u6709\u533a\u522b\uff1a\u7f16\u8bd1\u65f6\u548c\u7f16\u8bd1\u540e\u83b7\u5f97\u5e38\u91cf\u5728\u7a0b\u5e8f\u4e2d\u8868\u73b0\u4e0d\u540c
"},{"location":"CS/OOP/#namespace","title":"NameSpace","text":"int x = 7;\nconst int a = 7; // if a = x\nint *p;\np = const_cast<int *>(&a);\ncout << a << endl;\ncout << *p << endl;\n*p = 155;\ncout << a << endl;\ncout << *p << endl;\n\n> 7\n> 7\n> 7 // a = 155\n> 155\n
GeeksForGeeks
C++ Reference
"},{"location":"CS/OOP/#mi","title":"\u591a\u91cd\u7ee7\u627f MI","text":"
- \u547d\u540d\u7a7a\u95f4\u53ef\u4ee5\u5b9a\u4e49\u53d8\u91cf\u3001\u51fd\u6570\u3001\u7c7b\u578b
- \u547d\u540d\u7a7a\u95f4\u53ef\u4ee5\u5d4c\u5957
- \u649e\u547d\u540d\u7a7a\u95f4 -> Ambiguities
- \u522b\u540d
namespace short_ns = supercalifragilistic;
- \u5408\u6210
namespace mine { \n using orig::Cat; // use Cat class from orig \n void x(); \n void y();\n}\n
- \u4e0d\u4e00\u5b9a\u5728\u540c\u4e00\u4e2amodule\u4e2d \u53ef\u4ee5\u8de8\u591a\u6587\u4ef6\u5b58\u5728
Protocol / Interface classes
"},{"location":"CS/OOP/#memory","title":"Memory","text":""},{"location":"CS/OOP/#_4","title":"\u5185\u5b58\u57fa\u7840\u77e5\u8bc6","text":""},{"location":"CS/OOP/#_5","title":"\u52a8\u6001\u5185\u5b58\u5206\u914d","text":"\u53e6\u4e00\u5757\u7b14\u8bb0
"},{"location":"CS/OOP/#class","title":"Class","text":"NOTE
\u8003\u8bd5\u7684\u65f6\u5019\u5b9a\u4e49\u7c7b\u7684\u7ed3\u675f\u8981\u8bb0\u5f97\u52a0
;
TODO: \u5de6\u503c\u548c\u53f3\u503c\u5f15\u7528
::Error:: \u975e\u5e38\u91cf\u5f15\u7528\u7684\u521d\u59cb\u503c\u5fc5\u987b\u4e3a\u5de6\u503cC/C++(461)
"},{"location":"CS/OOP/#construct-destruct","title":"construct / destruct","text":"void fun(A &a)\n{\n cout << \"A a\" << a.get();\n}\nint main()\n{\n fun(A());\n return 0;\n}\n
Construct
- \u6ce8\u610f,\u4e00\u4e2a\u7c7b\u7684\u6784\u9020\u51fd\u6570\u4e2d\u542b\u6709\u4e00\u4e2a\u9759\u6001\u53d8\u91cf,\u8fd9\u4e2a\u9759\u6001\u53d8\u91cf\u53ea\u6709\u7b2c\u4e00\u6b21\u8c03\u7528\u624d\u4f1a\u521d\u59cb\u5316
"},{"location":"CS/OOP/#this","title":"this\u6307\u9488","text":"Date::Date(int y, int m, int d) // \u5b9a\u4e49\u6784\u9020\u51fd\u6570\n{\n year = y;\n month = m;\n day = d;\n Time time(11, 11, 11);\n // \u5728\u7c7bDate\u5b9a\u4e49\u7684\u6784\u9020\u51fd\u6570\u4e2d\u5b9a\u4e49\u7c7bTime\u7684\u5bf9\u8c61\uff08\u5c40\u90e8\uff09\n // \u8fd9\u91cc\u4e5f\u53ea\u5b9a\u4e49\u4e00\u6b21\n static Time time1(12, 12, 12);\n // \u5728\u7c7bDate\u5b9a\u4e49\u7684\u6784\u9020\u51fd\u6570\u4e2d\u5b9a\u4e49\u7c7bTime\u7684\u9759\u6001\u5bf9\u8c61\uff08\u5c40\u90e8\uff09\n cout << \"Date Constructor\" << year << \":\" << month << \":\" << day << endl;\n}\n
this
this\u6307\u9488\u662f\u4e00\u4e2a\u9690\u542b\u4e8e\u6bcf\u4e00\u4e2a\u6210\u5458\u51fd\u6570\u4e2d\u7684\u7279\u6b8a\u6307\u9488\u3002\u5b83\u6307\u5411\u6b63\u64cd\u4f5c\u8be5\u6210\u5458\u51fd\u6570\u7684\u5bf9\u8c61\u3002
\u5f53\u5bf9\u4e00\u4e2a\u5bf9\u8c61\u8c03\u7528\u6210\u5458\u51fd\u6570\u65f6\uff0c\u7f16\u8bd1\u7a0b\u5e8f\u5148\u5c06\u5bf9\u8c61\u7684\u5730\u5740\u8d4b\u7ed9this\u6307\u9488\uff0c\u7136\u540e\u8c03\u7528\u6210\u5458\u51fd\u6570\u3002
\u6bcf\u6b21\u6210\u5458\u51fd\u6570\u5b58\u53d6\u6570\u636e\u6210\u5458\u65f6\uff0cC++\u7f16\u8bd1\u5668\u5c06\u6839\u636ethis\u6307\u9488\u6240\u6307\u5411\u7684\u5bf9\u8c61\u6765\u786e\u5b9a\u5e94\u8be5\u5f15\u7528\u54ea\u4e00\u4e2a\u5bf9\u8c61\u7684\u6570\u636e\u6210\u5458\u3002
\u901a\u5e38this\u6307\u9488\u5728\u7cfb\u7edf\u4e2d\u662f\u9690\u542b\u5b58\u5728\u7684\uff0c\u4e5f\u53ef\u4ee5\u628a\u5b83\u663e\u5f0f\u8868\u793a\u51fa\u6765\u3002
"},{"location":"CS/OOP/#copy-control","title":"Copy Control","text":"
- this\u6307\u9488\u662f\u4e00\u4e2aconst\u6307\u9488\uff0c\u4e0d\u80fd\u5728\u7a0b\u5e8f\u4e2d\u4fee\u6539\u5b83\u6216\u7ed9\u5b83\u8d4b\u503c\u3002
- this\u6307\u9488\u662f\u4e00\u4e2a\u5c40\u90e8\u6570\u636e\uff0c\u5b83\u7684\u4f5c\u7528\u57df\u4ec5\u5728\u4e00\u4e2a\u5bf9\u8c61\u7684\u5185\u90e8,\u901a\u8fc7 this \u53ef\u4ee5\u8bbf\u95ee\u7c7b\u7684\u6240\u6709\u6210\u5458\uff0c\u5305\u62ec private\u3001protected\u3001public \u5c5e\u6027\u7684\u3002
- \u6709\u5728\u5bf9\u8c61\u88ab\u521b\u5efa\u4ee5\u540e\u624d\u4f1a\u7ed9 this \u8d4b\u503c\uff0c\u5e76\u4e14\u8fd9\u4e2a\u8d4b\u503c\u7684\u8fc7\u7a0b\u662f\u7f16\u8bd1\u5668\u81ea\u52a8\u5b8c\u6210\u7684\uff0c\u4e0d\u9700\u8981\u7528\u6237\u5e72\u9884\uff0c\u7528\u6237\u4e5f\u4e0d\u80fd\u663e\u5f0f\u5730\u7ed9 this \u8d4b\u503c\u3002
"},{"location":"CS/OOP/#_6","title":"\u62f7\u8d1d\u6784\u9020\u51fd\u6570","text":"class A\n{\npublic:\n A(int i) : mi(i) {}\n A(const A &rhs) : mi(rhs.mi)\n {\n cout << \"A::A(&)\" << endl;\n }\n virtual void f()\n {\n cout << \"A::f(), \" << mi << endl;\n }\nprotected:\n int mi;\n};\n
Copy
\u8c03\u7528\u62f7\u8d1d\u6784\u9020\u51fd\u6570\u7684\u60c5\u51b5\u6709\u4e09\u79cd\uff1a \uff081\uff09\u660e\u786e\u8868\u793a\u7531\u4e00\u4e2a\u5bf9\u8c61\u521d\u59cb\u5316\u53e6\u4e00\u4e2a\u5bf9\u8c61\u3002 \uff082\uff09\u5f53\u5bf9\u8c61\u4f5c\u4e3a\u51fd\u6570\u5b9e\u53c2\u4f20\u9012\u7ed9\u51fd\u6570\u5f62\u53c2\u65f6\u3002 \uff083\uff09\u5f53\u5bf9\u8c61\u4f5c\u4e3a\u51fd\u6570\u7684\u8fd4\u56de\u503c\uff0c\u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u5bf9\u8c61\u3002
- \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u7f16\u8bd1\u5668\u4f1a\u6709\u4e00\u4e2a
- \u539f\u751f\u7c7b\u578b\u503c\u62f7\u8d1d
- class\u8c03\u7528\u5176\u62f7\u8d1d\u51fd\u6570
- \u4f46\u662f\u5bf9\u4e8e\u6307\u9488\u800c\u8a00\uff0c\u5b83\u4e5f\u662f\u503c\u62f7\u8d1d\uff0c\u5bfc\u81f4\u6709\u4e24\u4e2a\u6307\u9488\u6307\u5411\u540c\u4e00\u4e2a\u5143\u7d20\u3002\u8fd9\u5bfc\u81f4\u5b83\u7684\u7ba1\u7406\u4e0d\u660e\u786e\uff0c\u53ef\u80fd\u5bf9\u540c\u4e00\u5757\u5730\u5740\u8fdb\u884c\u4e24\u6b21\u751a\u81f3\u591a\u6b21
delete
. \u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8981\u5bf9\u6790\u6784\u51fd\u6570\u3001\u62f7\u8d1d\u6784\u9020\u51fd\u6570\u8fdb\u884c\u5b9a\u4e49- \u9ed8\u8ba4\u7684\u62f7\u8d1d\u6784\u9020\u51fd\u6570,\u4f1a\u9012\u5f52\u5730\u5bf9\u6240\u6709\u6210\u5458objects\u8c03\u7528copy
Person(const Person &rhs) = delete;
// \u8fd9\u91cc\u9700\u8981\u5bf9\u7c7b\u4e2d\u7684\u5185\u5b58\u8fdb\u884c\u624b\u52a8\u7684\u7ba1\u7406,\u4e0d\u7136\u4e4b\u540edelete\u4f1a\u91cd\u590d\u5220\u9664\u540c\u4e00\u5757\u5185\u5b58\nPerson::Person( const Person& w ) { \n name = new char[::strlen(w.name) + 1]; \n ::strcpy(name, w.name); \n}\n
Why const and why &
- const: \u4e0d\u80fd\u6539\u53d8
- \u5f15\u7528: \u4e0d\u7136\u4f20\u53c2\u6570\u7684\u65f6\u5019\u53d1\u751f\u503c\u4f20\u9012\uff0c\u53c8\u8981\u8c03\u7528\u62f7\u8d1d\u51fd\u6570\uff0c\u9677\u5165\u6b7b\u5faa\u73af
\u7f16\u8bd1\u5668\u4f18\u5316
\u5b9a\u4e49\u90e8\u5206Person copy_func( Person p ) { \n p.print(); \n return p; // copy ctor called! \n} \nPerson nocopy_func( char *who ) { \n return Person( who ); \n} // no copy needed!\n
\u7f16\u8bd1\u5668\u4f18\u5316\u95ee\u9898#include <iostream>\nusing namespace std;\nclass A\n{\npublic:\n A() : value(0) { cout << \"A() \" << endl; };\n A(int a) : value(a) { cout << \"A(int a)\" << endl; };\n A(const A &other)\n {\n this->value = other.value;\n cout << \"A(&)\" << other.value << endl;\n };\n ~A() { cout << \"~A\" << endl; };\n\nprivate:\n int value;\n};\nA f(int a)\n{\n cout << \"f()\" << endl;\n return A(a);\n}\nA bar(A a)\n{\n cout << \"bar\" << endl;\n return a;\n}\n
"},{"location":"CS/OOP/#_7","title":"\u62f7\u8d1d\u8d4b\u503c\u8fd0\u7b97","text":"int main()\n{\n // \u7f16\u8bd1\u5668\u4f18\u5316\n // \u62f7\u8d1d\u6784\u9020\u88ab\u4f18\u5316 \u76f8\u5f53\u4e8e xa = A(5)\n A xa = f(5);\n /*\n f()\n A(int a)\n */\n\n // \u8fdb\u884c\u62f7\u8d1d\u6784\u9020\n A xb = bar(xa);\n /*\n A(&)5 \u53c2\u6570\u4f20\u5165\u4e00\u6b21\u62f7\u8d1d\u6784\u9020\n bar bar \u8c03\u7528\n A(&)5 \u62f7\u8d1d\u6784\u9020 xb = \u4f20\u56de\u53c2\u6570\n ~A \u5e94\u8be5\u662f\u90a3\u4e2a\u53c2\u6570\u88ab\u9500\u6bc1\u4e86\n */\n A xc = A(11);\n}\n
\u62f7\u8d1d\u8d4b\u503c
"},{"location":"CS/OOP/#vector","title":"\u6548\u7387\u95ee\u9898 Vector","text":"
- \u901a\u5e38\u8fd4\u56de\u5de6\u503c\u7684\u5f15\u7528
Cube Cube1(20,20,20),Cube2; \nCube2=Cube1; \n
\u7531\u4e8evector\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u4f1a\u53d1\u751f\u6269\u5bb9\uff0c\u6240\u4ee5\u62f7\u8d1d\u6784\u9020\u4f1a\u591a\u6b21\u8fdb\u884c
\u4f18\u5316\u62f7\u8d1d
\u5c06
alist.push_back(A(0));
\u6539\u4e3aalist.emplace_back(0);
\uff0c\u53ef\u4ee5\u4e0d\u6267\u884c\u62f7\u8d1d\u6784\u9020\u800c\u662f\u76f4\u63a5\u6784\u9020C11 \u7981\u7528copy\uff0c
Person(const Person &rhs) = delete;
"},{"location":"CS/OOP/#friend","title":"Friend","text":"vector<A> alist;\n// push_back\nalist.push_back(A(0));\nalist.push_back(A(1));\nalist.push_back(A(2));\n\nalist.emplace_back(0);\nalist.emplace_back(1);\nalist.emplace_back(2);\n
// Rectangle\u4e2d\u7684\u6210\u5458\u51fd\u6570\u90fd\u53ef\u4ee5\u4f7f\u7528Square\u4e2d\u7684\u6240\u6709\u6210\u5458\nclass Square { \n friend class Rectangle; \nprivate:\n int side; \npublic: \n Square (int a) : side(a) {} \n};\n
"},{"location":"CS/OOP/#_8","title":"\u7ee7\u627f","text":"
- \u53cb\u5143\u7684\u5173\u7cfb\u4e0d\u80fd\u4f20\u9012\u3002
- \u53cb\u5143\u7684\u5173\u7cfb\u662f\u5355\u5411\u7684\u800c\u4e0d\u662f\u53cc\u5411\u7684
\u6784\u9020\u6267\u884c\u987a\u5e8f
example
- \u8c03\u7528\u57fa\u7c7b\u7684\u6784\u9020\u51fd\u6570;
- \u8c03\u7528\u5185\u5d4c\u5bf9\u8c61\u6210\u5458\uff08\u5b50\u5bf9\u8c61\u7c7b\uff09\u7684\u6784\u9020\u51fd\u6570\uff08\u6709\u591a\u4e2a\u5bf9\u8c61\u6210\u5458\u65f6,\u8c03\u7528\u987a\u5e8f\u7531\u5b83\u4eec\u5728\u7c7b\u4e2d\u58f0\u660e\u7684\u987a\u5e8f\u786e\u5b9a\uff09; \u5185\u5d4c\u5bf9\u8c61\u7684\u6784\u9020\u4f18\u5148\u7ea7\u6bd4\u8f83\u9ad8
- \u6d3e\u751f\u7c7b\u7684\u6784\u9020\u51fd\u6570\u4f53\u4e2d\u7684\u5185\u5bb9
- \u540c\u540d\u51fd\u6570\u7684\u7ee7\u627f\u95ee\u9898 \u4e00\u4e2a\u6d3e\u751f\u7c7b\u4e2doverride\uff0c\u5176\u4ed6\u57fa\u7c7b\u540c\u540d\u51fd\u6570\u4e5f\u88ab\u8986\u76d6\u6389(\u5373\u4f7f\u7c7b\u578b\u4e0d\u540c) \u8bb0\u5f97override\u6240\u6709\u7684\u76f8\u5173\u51fd\u6570
Answer#include <iostream>\nstruct X {\n X() {\n std::cout << \"X::X()\" << std::endl;\n }\n ~X() {\n std::cout << \"X::~X()\" << std::endl;\n }\n};\nstruct Y {\n Y() {\n std::cout << \"Y::Y()\" << std::endl;\n }\n ~Y() {\n std::cout << \"Y::~Y()\" << std::endl;\n }\n};\nstruct Parent {\n Parent() {\n std::cout << \"Parent::Parent()\" << std::endl;\n }\n ~Parent() {\n std::cout << \"Parent::~Parent()\" << std::endl;\n }\n X x;\n};\nstruct Child : public Parent {\n Child() {\n std::cout << \"Child::Child()\" << std::endl;\n }\n ~Child() {\n std::cout << \"Child::~Child()\" << std::endl;\n }\n Y y;\n};\nint main() {\n Child c;\n}\n
Line 1: X::X()
Line 2: Parent::Parent()
Line 3: Y::Y()
Line 4: Child::Child()
Line 5: Child::~Child()
Line 6: Y::~Y()
Line 7: Parent::~Parent()
Line 8: X::~X()
- \u57fa\u7c7b\u6784\u9020\u51fd\u6570\u4e0d\u5e26\u53c2\u6570\u65f6\uff0c\u6d3e\u751f\u7c7b\u53ef\u4e0d\u5b9a\u4e49\u6784\u9020\u51fd\u6570\uff0c\u4f46\u57fa\u7c7b\u6784\u9020\u51fd\u6570\u5e26\u6709\u53c2\u6570\uff0c\u5219\u6d3e\u751f\u7c7b\u5fc5\u987b\u5b9a\u4e49\u6784\u9020\u51fd\u6570\u3002
- \u57fa\u7c7b\u548c\u6d3e\u751f\u7c7b\u7684\u6790\u6784\u51fd\u6570\u662f\u5404\u81ea\u72ec\u7acb\u7684\u3002
- \u57fa\u7c7b\u4e2d\u7684Private\u5c5e\u6027\u4e0d\u80fd\u76f4\u63a5\u901a\u8fc7\u6d3e\u751f\u7c7b\u8bbf\u95ee
"},{"location":"CS/OOP/#_9","title":"\u591a\u7ee7\u627f","text":"// \u8fdb\u884c\u521d\u59cb\u5316\u7684\u65f6\u5019,\u57fa\u7c7b\u6ca1\u6709\u65e0\u53c2\u6570\u7684\u6784\u9020\u51fd\u6570,\u6d3e\u751f\u7c7b\u5fc5\u987b\u663e\u5f0f\u5b9a\u4e49\nclass Derived\uff1apublic Base\n{\n Base d; //d\u4e3a\u57fa\u7c7b\u5bf9\u8c61\uff0c\u4f5c\u4e3a\u6d3e\u751f\u7c7b\u7684\u5bf9\u8c61\u6210\u5458\n public\uff1a\n Derived(int i)\uff1aBase(i),d(i)\n { \n cout<<\"Constructing derived class\\n\";\n }\n ~Derived() //\u6d3e\u751f\u7c7b\u7684\u6790\u6784\u51fd\u6570\n { cout<<\"Destructing derived class\\n\"; }\n };\n
\u9ed8\u8ba4\u4e3a
private
"},{"location":"CS/OOP/#_10","title":"\u591a\u6001","text":"
class z\uff1ax,public y
x\u4e3aprivate\u9759\u6001\u591a\u6001\u6027\u2014\u2014\u51fd\u6570\u91cd\u8f7d\u548c\u8fd0\u7b97\u7b26\u91cd\u8f7d\uff1b \u8fd0\u884c\u65f6\u7684\u591a\u6001\u2014\u2014\u7ee7\u627f\u548c\u865a\u51fd\u6570\uff1b
\u9759\u6001 : \u5728\u7f16\u8bd1\u65f6\u5c31\u51b3\u5b9a\u4e86\u51fd\u6570\u6240\u5c5e
"},{"location":"CS/OOP/#virtual","title":"virtual \u865a\u51fd\u6570","text":"class A\n{\npublic:\n void show() { cout << \"A\"; }\n};\nclass B : public A\n{\npublic:\n void show() { cout << \"B\"; }\n};\nint main()\n{\n A a, *pc;\n B b;\n pc = &a;\n pc->show();\n pc = &b;\n pc->show();\n return 0;\n}\n
virtual
- \u901a\u8fc7\u5b9a\u4e49\u865a\u51fd\u6570\u6765\u4f7f\u7528C++\u63d0\u4f9b\u7684\u591a\u6001\u673a\u5236\u65f6\uff0c\u6d3e\u751f\u7c7b\u5e94\u8be5\u4ece\u5b83\u7684\u57fa\u7c7b\u516c\u6709\u6d3e\u751f\u3002\u8d4b\u503c\u517c\u5bb9\u89c4\u5219\u6210\u7acb\u7684\u524d\u63d0\u6761\u4ef6\u662f\u6d3e\u751f\u7c7b\u4ece\u5176\u57fa\u7c7b\u516c\u6709\u6d3e\u751f\u3002
- \u5fc5\u987b\u9996\u5148\u5728\u57fa\u7c7b\u4e2d\u5b9a\u4e49\u865a\u51fd\u6570\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5e94\u8be5\u5728\u7c7b\u7b49\u7ea7\u5185\u9700\u8981\u5177\u6709\u52a8\u6001\u591a\u6001\u6027\u7684\u51e0\u4e2a\u5c42\u6b21\u4e2d\u7684\u6700\u9ad8\u5c42\u7c7b\u5185\u9996\u5148\u58f0\u660e\u865a\u51fd\u6570\u3002
- \u5728\u6d3e\u751f\u7c7b\u5bf9\u57fa\u7c7b\u4e2d\u58f0\u660e\u7684\u865a\u51fd\u6570\u8fdb\u884c\u91cd\u65b0\u5b9a\u4e49\u65f6\uff0c\u5173\u952e\u5b57virtual\u53ef\u4ee5\u5199\u4e5f\u53ef\u4ee5\u4e0d\u5199\u3002
- \u4f7f\u7528\u5bf9\u8c61\u540d\u548c\u70b9\u8fd0\u7b97\u7b26\u7684\u65b9\u5f0f\u4e5f\u53ef\u4ee5\u8c03\u7528\u865a\u51fd\u6570\uff0c\u4f46\u662f\u8fd9\u79cd\u8c03\u7528\u5728\u7f16\u8bd1\u65f6\u8fdb\u884c\u7684\u662f\u9759\u6001\u8054\u7f16\uff0c\u5b83\u6ca1\u6709\u5145\u5206\u5229\u7528\u865a\u51fd\u6570\u7684\u7279\u6027\u3002\u53ea\u6709\u901a\u8fc7\u57fa\u7c7b\u6307\u9488\u8bbf\u95ee\u865a\u51fd\u6570\u65f6\u624d\u80fd\u83b7\u5f97\u8fd0\u884c\u65f6\u7684\u591a\u6001\u6027
- \u865a\u51fd\u6570\u5fc5\u987b\u662f\u5176\u6240\u5728\u7c7b\u7684\u6210\u5458\u51fd\u6570\uff0c\u800c\u4e0d\u80fd\u662f\u53cb\u5143\u51fd\u6570\uff0c\u4e5f\u4e0d\u80fd\u662f\u9759\u6001\u6210\u5458\u51fd\u6570\uff0c\u56e0\u4e3a\u865a\u51fd\u6570\u8c03\u7528\u8981\u9760\u7279\u5b9a\u7684\u5bf9\u8c61\u6765\u51b3\u5b9a\u8be5\u6fc0\u6d3b\u54ea\u4e2a\u51fd\u6570\u3002\u4f46\u662f\u865a\u51fd\u6570\u53ef\u4ee5\u5728\u53e6\u4e00\u4e2a\u7c7b\u4e2d\u88ab\u58f0\u660e\u4e3a\u53cb\u5143\u51fd\u6570
- \u5185\u8054\u51fd\u6570\u4e0d\u80fd\u662f\u865a\u51fd\u6570\uff0c\u56e0\u4e3a\u5185\u8054\u51fd\u6570\u662f\u4e0d\u80fd\u5728\u8fd0\u884c\u4e2d\u52a8\u6001\u786e\u5b9a\u5176\u4f4d\u7f6e\u7684\u3002\u5373\u4f7f\u865a\u51fd\u6570\u5728\u7c7b\u7684\u5185\u90e8\u5b9a\u4e49\uff0c\u7f16\u8bd1\u65f6\u4ecd\u5c06\u5176\u770b\u4f5c\u662f\u975e\u5185\u8054\u7684
- \u6784\u9020\u51fd\u6570\u4e0d\u80fd\u662f\u865a\u51fd\u6570\u3002\u56e0\u4e3a\u865a\u51fd\u6570\u4f5c\u4e3a\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u591a\u6001\u7684\u57fa\u7840\uff0c\u4e3b\u8981\u662f\u9488\u5bf9\u5bf9\u8c61\u7684\uff0c\u800c\u6784\u9020\u51fd\u6570\u662f\u5728\u5bf9\u8c61\u4ea7\u751f\u4e4b\u524d\u8fd0\u884c\u7684\uff0c\u56e0\u6b64\u865a\u6784\u9020\u51fd\u6570\u662f\u6ca1\u6709\u610f\u4e49\u7684
- \u6790\u6784\u51fd\u6570\u53ef\u4ee5\u662f\u865a\u51fd\u6570\uff0c\u800c\u4e14\u901a\u5e38\u8bf4\u660e\u4e3a\u865a\u51fd\u6570
Default Value
\u5728\u865a\u51fd\u6570\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Default value\uff0c\u4f46\u662f\u9700\u8981\u6ce8\u610f\uff1a\u9ed8\u8ba4\u503c\u662f\u5728\u7f16\u8bd1\u65f6\u51b3\u5b9a\u7684\uff0c\u800c\u865a\u51fd\u6570\u662f\u8fd0\u884c\u65f6\u52a8\u6001\u7ed1\u5b9a\u7684
\u7eaf\u865a\u51fd\u6570
virtual void show()=0;
\u81f3\u5c11\u542b\u6709\u4e00\u4e2a\u7eaf\u865a\u51fd\u6570,\u5c31\u662f\u4e00\u4e2a\u62bd\u8c61\u7c7b
- \u62bd\u8c61\u7c7b\u4e0d\u80fd\u5b9a\u4e49\u4e00\u4e2a\u5b9e\u4f8b,\u4e0d\u80fd\u4f5c\u4e3a\u51fd\u6570\u8fd4\u56de\u503c\u6216\u8005\u53c2\u6570
- \u53ef\u4ee5\u5b9a\u4e49\u62bd\u8c61\u7c7b\u7684\u6307\u9488\u6216\u8005\u5f15\u7528
class base\n{\npublic:\n base()\n {\n cout << \"base constructor\" << endl;\n }\n virtual ~base()\n {\n cout << \"base destructor\" << endl;\n }\n};\nclass derived : public base\n{\npublic:\n derived()\n {\n cout << \"derived constructor\" << endl;\n }\n ~derived()\n {\n cout << \"derived destructor\" << endl;\n }\n};\n\nint main()\n{\n base *pb = new derived;\n delete pb;\n}\n
\u63a5\u53e3 Interface
\u5168\u4e3avirtual\u51fd\u6570
"},{"location":"CS/OOP/#overload","title":"\u91cd\u8f7d Overload","text":""},{"location":"CS/OOP/#_11","title":"\u51fd\u6570\u91cd\u8f7d","text":""},{"location":"CS/OOP/#_12","title":"\u8fd0\u7b97\u7b26\u91cd\u8f7d","text":"\u53ef\u4ee5\u91cd\u8f7d\u7684\u7c7b\u578b
+ - * / % ^ & | ~\n= < > += -= *= /= %=\n^= &= |= << >> >>= <<= ==\n!= <= >= ! && || ++ --\n, ->* -> () []\nnew new[]\ndelete delete[]\n
\u4e0d\u53ef\u4ee5
. .* :: ?:\n
\u4e0d\u53ef\u4ee5\u81ea\u5df1\u521b\u9020\u7c7b\u578b
"},{"location":"CS/OOP/#class-member","title":"Class member
","text":"
- No type conversion performed on receiver
"},{"location":"CS/OOP/#global-operators","title":"x + y; // x.operator+(y)\nz = x + y // Good \nz = x + 3 // Good\nz = 3 + y // Error\n// \u4e8c\u5143 binary\nInteger operator+(const Integer & n) const{\n return Integer(i + n.i);\n}\n// \u4e00\u5143 unary\nInteger operator-() const {\n return Integer(-i);\n}\n
Global operators
","text":"
- \u5bf9\u7c7b\u5185
private
\u6ca1\u6709\u8bbf\u95ee\u6743\u9650\uff0c\u53ef\u80fd\u9700\u8981\u662ffriend- \u53c2\u6570\u81f3\u5c11\u6709\u4e00\u4e2a\u662f
class
\u6216\u8005enum
\u7c7b\u578bclass Integer {\npublic:\n friend Integer operator+(const Integer&, const Integer&);\n ...\nprivate:\n int i;\n};\nInteger operator+(const Integer& lhs, const Integer& rhs)\n{\nreturn Integer( lhs.i + rhs.i );\n}\n
"},{"location":"CS/OOP/#detailed","title":"Detailed","text":"z = x + y; // operator+(x, y)\nz = x + 3; // operator+(x, Integer(3))\nz = 3 + y; // operator+(Integer(3), y)\nz = 3 + 7; // Integer(10) \u5148\u6c42\u548c \u540e\u8f6c\u6362\n
+ - * / % ^ & | ~
T operator X(const T& l, const T& r)
! && || < <= == >= >
bool operator X(const T& l, const T& r)
[ ]
E& T::operator [](int index)
\u4e00\u822c\u8fd8\u4f1a\u6709\u4e00\u4e2aconst\u7248\u672c\uff0c\u5426\u5219const\u5bb9\u5668\u65e0\u6cd5\u4f7f\u7528\u8fd4\u56de\u503c
int &Vector::operator [](int index)\n{\n return Element[index];\n}\n
++ -- \u4e00\u5143 \u533a\u5206 prefix postfix
class Integer {\npublic:\n...\n Integer& operator++(); //prefix++\n Integer operator++(int); //postfix++\n Integer& operator--(); //prefix--\n Integer operator--(int); //postfix--\n...\n};\n\nInteger x(5);\n++x; // calls x.operator++();\nx++; // calls x.operator++(0);\n--x; // calls x.operator--();\nx--; // calls x.operator--(0);\n
= \u8d4b\u503c\u8fd0\u7b97\u7b26 \u8fd4\u56de\u7684\u4e00\u5b9a\u8981\u662f\u5f15\u7528\uff0c\u4e00\u822c\u662f
*this
a = b = c
class Cargo{\n public:\n Cargo& operator=(const Cargo&)\n {\n return *this;\n }\n}\n// \u81ea\u52a8\u7248\u672c\uff0c\u6bcf\u4e2a\u5b57\u6bb5\u8c03\u7528 = \nclass Truck{\n Cargo mc;\n}\n\nTruck a,b;\na = b;\n
Copy constructor
\u548cassignment
\u5bf9\u4e8e\u5185\u542b\u7684\u6307\u9488\u53d8\u91cf\uff0c\u8d4b\u503c\u51fd\u6570\u8981\u8003\u8651\u91ca\u653e\u539f\u6765\u7684\u5185\u5b58\uff0c\u4e0d\u8981\u4f7f\u7528\u9ed8\u8ba4 = . \u9632\u6b62\u91cd\u590d\u91ca\u653e\u540c\u4e00\u5757\u5185\u5b58
\u6ce8\u610f
self-assiment!
\uff0cLeft Side\u53ef\u80fd\u672c\u6765\u5c31\u542b\u6709\u5185\u5bb9class A\n{\nprivate:\n char *p;\npublic:\n A& operator=(const A& a){\n if(a == *this){\n ...\n }else{\n delete [] p;\n p = new char[strlen(a.p) + 1];\n strcpy(p,a.p);\n return *this;\n }\n }\n\n}\n
Forbid it
A& operator=(const A&) = delete;\n
( ) functor
functor
overloads the function call operatorstruct F {\n void operator()(int x) const {\n std::cout << x << \"\\n\";\n }\n}; // F is a functor class\nF f; // f is a functor\nf(2); // calls f.operator()\n
void transform(vector<int>& v,int (*f)(int))\n{\n for(int &x : v)\n x = f(x);\n}\n// \u533f\u540d\u51fd\u6570 lambda\nint a = 4;\ntransform(v,[](int x){return x * 2});\n// \u5177\u6709\u73af\u5883\u53d8\u91cf\u7684\u5199\u6cd5\n#include <functional>\nvoid transform(vector<int>& v,const function<int<int>> &f)\n{\n for(int &x : v)\n x = f(x);\n}\n\n// \u6355\u83b7\u73af\u5883\u53d8\u91cf\ntransform(v,[a](int x){#f768a4b1a31b9e3a759b10a13c1e97e6}{return x * a;});\n
\u6784\u9020\u4e86\u4e00\u4e2a\u7c7b\uff08\u51fd\u6570\u5bf9\u8c61\uff09\uff0c\u8fd9\u4e2a\u7c7b\u4e2d\u91cd\u6784
( )
\u7b26\u53f7\uff0c\u53c2\u6570\u5c31\u662f\u7c7b\u4e2d\u7684\u4e00\u4e2a\u53d8\u91cf\uff1b\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b8c\u5168\u53ef\u4ee5\u7531\u4e00\u4e2a\u7c7b\u5b9a\u4e49\uff0c\u6765\u4ee3\u66ffLambda \u51fd\u6570Code
"},{"location":"CS/OOP/#_13","title":"\u9690\u5f0f\u8f6c\u6362","text":"#include <iostream>\n#include <vector>\nusing namespace std;\n\nclass vec3\n{\npublic:\n vec3(int x = 0, int y = 0, int z = 0)\n {\n v[0] = x;\n v[1] = y;\n v[2] = z;\n }\n int operator[](int index) const\n {\n return v[index];\n }\n vec3 &operator+=(const vec3 &rhs)\n {\n for (int i = 0; i < 3; ++i)\n v[i] += rhs.v[i];\n return *this;\n }\n\nprivate:\n int v[3];\n};\n\nvec3 operator+(const vec3 &v1, const vec3 &v2)\n{\n return vec3(v1) += v2;\n}\n\nostream &\noperator<<(ostream &out, const vec3 &v)\n{\n out << '(' << v[0] << ' ' << v[1] << ' ' << v[2] << ')';\n\n return out;\n}\n\nint main()\n{\n vec3 v1(1, 2, 3), v2(4, 5, 6);\n vec3 v = v1 + v2;\n v += v2;\n cout << v << endl;\n}\n
\u9690\u5f0f\u8f6c\u6362
C++\u7684\u7c7b\u578b\u8f6c\u6362
- Built-in conversions
- User-defined type conversions T => C \u901a\u8fc7\u5355\u53c2\u6570\u6784\u9020\u51fd\u6570\u8fdb\u884c
- if
C(T)
is a valid constructor call for C- if
operator C()
is defined for T
explicit
\u4e0d\u5141\u8bb8\u9690\u5f0f\u8f6c\u6362Single argument constructors
class PathName {\nstring name;\npublic:\nexplicit PathName(const string&);\n~ PathName();\n};\n\nstring abc(\"abc\");\nPathName xyz(abc); // OK!\nxyz = abc; // Error! OK if without explicit\n
\u8fd9\u91cc\uff0c\u7531\u4e8e
C(int)
\u4e3aexplicit
\u7c7b\u578b\uff0c\u6240\u4ee5\u5728\u9690\u5f0f\u8f6c\u6362\u65f6\u4e0d\u4f1a\u8003\u8651\u8fd9\u4e2a\u51fd\u6570\uff0c\u901a\u8fc7C(double)
\u8fdb\u884c\u8f6c\u6362class C\n{\npublic:\n explicit C(int)\n {\n cout << \"i\" << endl;\n }\n C(double)\n {\n cout << \"d\" << endl;\n }\n};\nint main()\n{\n C c1(7);\n C c2 = 7;\n return 0;\n}\n> i\n> d\n
Conversion Operator | \u7c7b\u7684\u8f6c\u6362
X::operator T()
- No explicit arguments
- No return type
"},{"location":"CS/OOP/#stream","title":"Stream","text":"class Rational {\npublic:\n operator double() const {\n return numerator / (double)denominator;\n }\n}\nRational r(1,3);\ndouble d = 1.3 * r; // r => double\n
\u4f18\u52bf
- Better type safety
- Extensible
- More object-oriented
\u7c7b\u578b
"},{"location":"CS/OOP/#stream_1","title":"Stream\u6d41","text":"// \u57fa\u7c7b\nistream& operator>>(istream& in, T& obj){\n // \n in >> obj. >> obj.;\n return in;\n}\nostream& operator<<(ostream& out,T& obj){\n return out << \" \";\n}\n
"},{"location":"CS/OOP/#_14","title":"\u8f93\u51fa\u63a7\u5236","text":"
cin
- standard input
cout
- standard output
cerr
- unbuffered error (debugging) output
clog
- buffered error (debugging) output
"},{"location":"CS/OOP/#_15","title":"\u7c7b\u578b\u8f6c\u6362","text":""},{"location":"CS/OOP/#template","title":"Template","text":"
#include <iomanip>
NOTE
\u5339\u914d\u63a8\u5bfc\u987a\u5e8f
\u5e38\u91cf\u4fee\u9970\u7b26\uff1aconst \u548c volatile \u4fee\u9970\u7b26\u5728\u63a8\u5bfc\u8fc7\u7a0b\u4e2d\u4f1a\u88ab\u4fdd\u7559
\u5148\u627e\u662f\u5426\u6709\u5b8c\u5168\u5339\u914d\u7684\u666e\u901a\u51fd\u6570
\u518d\u627e\u662f\u5426\u6709\u5b8c\u5168\u5339\u914d\u7684\u6a21\u677f\u51fd\u6570
\u518d\u627e\u6709\u6ca1\u6709\u901a\u8fc7\u8fdb\u884c\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\u53ef\u4ee5\u8c03\u7528\u7684\u51fd\u6570
\u8981\u5e94\u5bf9\u8fd9\u79cd\u9690\u5f0f\u8f6c\u6362
"},{"location":"CS/OOP/#functional-overloading","title":"Functional Overloading \u51fd\u6570\u91cd\u8f7d","text":"
- \u663e\u5f0f\u58f0\u660e\u4e00\u4e2a\u6a21\u677f
template<class T>\nT max(T x, T y)\n{\n return (x>y)?x:y;\n}\nint max(int, int)\uff1b//\u53ea\u58f0\u660e\u4e00\u4e2a\u975e\u6a21\u677f\u51fd\u6570\u7684\u539f\u578b\nvoid func(int i,char c)\n{\n max(i, i); //\u6b63\u786e ,\u8c03\u7528max(int,int)\n max(c, c); // Error: \u591a\u4e2a\u5339\u914d\u7684\u51fd\u6570\n max(i, c); //\u6b63\u786e ,\u8c03\u7528 max(int,int),\u4f7f\u7528\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\n max(c, i); //\u6b63\u786e ,\u8c03\u7528max(int,int),\u4f7f\u7528\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\n}\n
Defalut value
Error
- \u6709\u9ed8\u8ba4\u503c\u7684\u60c5\u51b5\u4e0b\u518d\u6b21\u5b9a\u4e49\u4f1aError
"},{"location":"CS/OOP/#function","title":"Function \u51fd\u6570\u6a21\u677f","text":"void foo(int i = 5, int j = 4);\nvoid foo(int i, int j = 4)\n{\n cout << i << j << endl;\n}\nint main()\n{\n foo();\n}\n
inline\u7684\u4f4d\u7f6e
template <typename T>\ninline bool compare(const T &a, const T &b)\n{\n return a < b;\n}\nint main()\n{\n cout << compare(5, 1.0); // Error\n cout << compare<int>(5, 1.0); // Good\n}\n
\u4e0d\u5141\u8bb8\u9690\u5f0f\u8f6c\u6362
typename <>\u4e2d\u8fd8\u53ef\u4ee5\u5b58\u5728\u5176\u4ed6\u53d8\u91cf\u751a\u81f3\u662f\u7f3a\u7701\u91cf
- "},{"location":"CS/OOP/#class_1","title":"Class \u7c7b\u6a21\u677f","text":"
\u51fd\u6570\u5339\u914d
template <typename T>\ninline bool compare(const T &a, const T &b)\n{\n return a < b;\n}\nbool compare(const float &a, const float &b)\n{\n return a < b;\n}\nint main()\n{\n cout << compare(5.0, 1.0); // \u8c03\u7528 \u51fd\u6570\u6a21\u677f\n}\n
NOTE
"},{"location":"CS/OOP/#template-specialization","title":"\u6a21\u677f\u7279\u5316 Template specialization","text":"
- \u7c7b\u6a21\u677f\u4e2d\u7684\u90fd\u662f\u6a21\u677f\u51fd\u6570 \u5982\u679c\u5728\u7c7b\u5916\u5b9a\u4e49\u51fd\u6570\uff0c\u8bb0\u5f97
T Class::Function(T a)
```c++ title = \"\u539f\u6a21\u7248\" template class A { / ... / };
```c++ title = \"\u5168\u7279\u5316\"\ntemplate<>\nclass A<int, double, 5> { /* ... */ };\n
```c++ title = \"\u504f\u7279\u5316\" template class A { / ... / }; // \u53e6\u5916\u4e00\u4e2a\u4f8b\u5b50\uff0c\u5c06\u6307\u9488\u7c7b\u578b\u8fdb\u884c partial template class B{ };
\u51fd\u6570\u5339\u914d\u987a\u5e8f\uff1a\n1. \u4f18\u5148\u5bfb\u627e\u5168\u7279\u5316\n2. \n\n## Iterator\n\n> Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.\n\n\u5c01\u88c5\n```c++ \ntemplate<class T>\nclass auto_ptr {\nprivate:\n T *pointee;\npublic:\n /* ... */\n T& operator *() { return *pointee; }\n T* operator ->() { return pointee; }\n};\n
++ * ==
\u6ce8\u610f\u4e0d\u540c\u7684\u5e95\u5c42\u5b9e\u73b0\uff0c\u5176\u5b9e\u5bf9Iterator\u7684\u64cd\u4f5c\u6709\u5f71\u54cd
\u6bd4\u5982\uff0c
set
\u4f7f\u7528\u7ea2\u9ed1\u6811\u4f5c\u4e3a\u5e95\u5c42\u5b9e\u73b0\uff0c\u4f7f\u7528It++
\u5f97\u5230\u7684\u7ed3\u679c\u4e0d\u662f\u6309\u521d\u59cb\u5316\u987a\u5e8f\u6392\u5217\u7684\u5982\u4f55\u83b7\u5f97Iterator\u7684\u7c7b\u578b\u4ee5\u53ca\u5176\u5143\u7d20\u7684\u7c7b\u578b ?
"},{"location":"CS/OOP/#iterator_traits","title":"iterator_traits
","text":""},{"location":"CS/OOP/#catagory","title":"Catagory","text":"template<class I>\nclass iterator_traits\n{\npublic:\n typedef typename I::iterator_category iterator_category;\n typedef typename I::value_type value_type;\n typedef typename I::difference_type differece_type;\n typedef typename I::pointer pointer;\n typedef typename I::reference reference;\n /* ... */\n}\n
category info
"},{"location":"CS/OOP/#_16","title":"\u5f02\u5e38\u5904\u7406","text":"struct input_iterator_tag {};\nstruct output_iterator_tag {};\nstruct forward_iterator_tag\n : public input_iterator_tag {};\nstruct bidirectional_iterator_tag\n : public forward_iterator_tag {};\nstruct random_access_iterator_tag\n : public bidirectional_iterator_tag {};\n
\u6ce8\u610f
Try-Catch Block\u4e2d\uff0c\u5fc5\u987b\u5b58\u5728Try-Catch\u7684\u914d\u5bf9\uff0c\u4f46\u662fcatch\u4e2d\u7684\u53c2\u6570\u53ef\u4ee5\u4e3a\u7a7a\uff0c\u8868\u793a\u8fd9\u91cc\u4e0d\u53bb\u6355\u6349\u5904\u7406\u9519\u8bef
try {\n // -----------------------\n // main logic here\n open the file;\n determine its size;\n allocate that much memory;\n read the file into memory;\n close the file;\n // -----------------------\n} catch ( fileOpenFailed ) {\n doSomething;\n} catch ( sizeDeterminationFailed ) {\n doSomething;\n} catch ( memoryAllocationFailed ) {\n doSomething;\n} catch ( readFailed ) {\n doSomething;\n} catch ( fileCloseFailed ) {\n doSomething;\n}\n
assert
Debug\u7684\u65f6\u5019\u4f1a\u5f88\u6709\u7528\uff0c\u4e5f\u53ef\u4ee5\u653e\u5728Test\u91cc\u9762\u3002\u5728MiniSQL\u91cc\u9762\u6709\u5f88\u591a\u5e94\u7528\u3002
\u66f4\u8be6\u7ec6\u7684\u5185\u5bb9\u53ef\u89c1\u5206\u533a\uff1a\u3010::TODO::\u3011assert(index > 0 && index < size);\n
? throw \u4e00\u4e2a\u5bf9\u8c61\u56de\u53bb\uff0c\u8fd9\u4e2a\u5bf9\u8c61\u4ec0\u4e48\u65f6\u5019\u6790\u6784\uff1f
throw
throw exception
\u629b\u51fa\u5f02\u5e38throw
throw \u540e\u9762\u4e0d\u52a0\u4efb\u4f55\u4e1c\u897f\uff0c\u76f4\u63a5\u4f20\u9012\u7ed9\u4e0a\u5c42\u51fd\u6570\uff0c\u53ea\u80fd\u5728catch\u4e2d\u4f7f\u7528
- re-raises the exception being handled
- valid only within a handler
- \u53ef\u4ee5 throw \u4efb\u610f\u7c7b\u578b\u7684\u6570\u636e
void f0()\n{\n try\n {\n f1();\n }\n catch (double)\n {\n cout << \"f0() double\" << endl;\n }\n cout << \"f0() End\" << endl;\n}\n
\u5c3d\u91cf\u4e0d\u8981\u4f7f\u7528
throw new Exception()
\uff0c\u76f4\u63a5\u4f7f\u7528throw Exception()
\u5426\u5219new\u51fa\u6765\u7684\u5bf9\u8c61\u4e5f\u8981\u81ea\u5df1\u53bb\u91ca\u653e
catch
"},{"location":"CS/OOP/#_17","title":"\u5f02\u5e38\u6307\u5b9a","text":"
catch(...)
catch(Exception)
\u52a8\u6001\u5f02\u5e38\u89c4\u8303\u5df2\u7ecf\u5728C++11\u4e4b\u540e\u88ab\u53d6\u6d88
warning: dynamic exception specifications are deprecated in C++11
\u5f02\u5e38\u6307\u5b9a\u662f\u51fd\u6570\u58f0\u660e\u7684\u4e00\u90e8\u5206\uff0c\u5fc5\u987b\u540c\u65f6\u51fa\u73b0\u5728\u51fd\u6570\u58f0\u660e\u548c\u51fd\u6570\u5b9a\u4e49\u7684\u9996\u884c\u4e2d\uff0c\u5426\u5219\u5728\u8fdb\u884c\u51fd\u6570\u7684\u53e6\u4e00\u6b21\u58f0\u660e\u65f6\uff0c\u7f16\u8bd1\u7cfb\u7edf\u4f1a\u62a5\u544a\u201c\u7c7b\u578b\u4e0d\u5339\u914d\u201d\u3002
\u5339\u914d\u673a\u5236
\u9488\u5bf9\u6bcf\u4e00\u6761catch\uff0c\u4f9d\u6b21\u8fdb\u884c\u5339\u914d\uff0c\u6240\u4ee5\u53ef\u80fd\u5bfc\u81f4\u63d0\u524d\u201c\u622a\u65ad\u201d\u2014\u2014\u57fa\u7c7b\u5904\u7406\u5c06\u6d3e\u751f\u7c7b\u5904\u7406\u9876\u6389
- \u7c7b\u578b\u5b8c\u7f8e\u5339\u914d
- \u57fa\u7c7b\u8f6c\u5316 \u4e00\u5b9a\u8981\u662f\u6307\u9488/\u5f15\u7528\u7c7b\u578b ? TODO
catch(...)
\u6240\u6709\u90fd\u80fd\u5339\u914d\uff0c\u5fc5\u987b\u653e\u5728\u7ed3\u675f\u4f4d\u7f6e\uff0c\u5426\u5219Error// Warning : UnderFlowError will be caught by earlier Exception\ntry\n{\n ...\n}\ncatch (MathError &e)\n{\n cout << \"MathError\" << endl;\n}\ncatch (UnderFlowError &e)\n{\n cout << \"UnderFlow\" << endl;\n}\ncatch (...)\n
\u65e0\u5f02\u5e38\u51fd\u6570
void foo() noexcept{...}
\u5728\u8fd0\u884c\u65f6\u68c0\u67e5\uff0c\u5982\u679c\u8fd0\u884c\u65f6\u4ecd\u7136\u629b\u51fa\u5f02\u5e38\uff0c\u90a3\u4e48\u5c06\u4f1a\u505c\u6b62\u7a0b\u5e8fFILE \u7c7b\u578b\u7684\u6790\u6784\u51fd\u6570\u53ef\u4ee5\u6267\u884c
"},{"location":"CS/OOP/#_18","title":"\u6784\u9020\u5f02\u5e38","text":"f.close()
\uff0c\u65e0\u9700\u5728try blockvoid f()\n{\n // \u4e0d\u4f1a\u53d1\u751f\u5185\u5b58\u6cc4\u6f0f\n X x; // \n Y *p = new Y(); // \u5185\u5b58\n}\n
- \u5728\u8c03\u7528\u6784\u9020\u51fd\u6570\u65f6\u51fa\u73b0\u5f02\u5e38\uff0c\u9000\u51fa
- \u6790\u6784\u51fd\u6570\u4e0d\u4f1a\u88ab\u6267\u884c\uff0c\u4f46\u662f\u5df2\u7ecf\u751f\u6210\u3001\u7533\u8bf7\u7684\u5185\u5b58\u4e0d\u4f1a\u88ab\u91ca\u653e\uff08\u6307\u7684\u662f\u6790\u6784\u4e2d\u4ea7\u751f\u7684\u5185\u5b58\uff0c\u6bd4\u5982
new int
\uff09;example
\n
\u89e3\u51b3\u65b9\u6cd5 - \u5728\u68c0\u6d4b\u5230Exception\u65f6\u624b\u52a8\u91ca\u653e\u5185\u5b58 - \u4e24\u5c42\u6784\u9020\uff0c\u901a\u8fc7\u53e6\u5916\u4e00\u4e2a\u51fd\u6570init\u5b9e\u73b0, \u8ba9\u7528\u6237\u624b\u52a8\u5b9e\u73b0\u7c7b\u7684Init - \u5c06\u539f\u751f\u6307\u9488\u653e\u5165\u4e00\u4e2awarpper\u7c7b - \u4f7f\u7528
unique_ptr
\u7ba1\u7406\u52a8\u6001\u7684\u8d44\u6e90\uff0c\u4f5c\u7528\u4e0a\u76f8\u5f53\u4e8e\u4e00\u4e2aWrapper\u7684\u6a21\u677f\u7c7b"},{"location":"CS/OOP/#_19","title":"\u6790\u6784\u5f02\u5e38","text":"\n
\u4e0d\u80fd\u629b\u51fa\u5f02\u5e38\uff0c\u5c06\u4f1a\u6267\u884c
"},{"location":"CS/OOP/#_20","title":"\u4f7f\u7528","text":"std::terminate()
"},{"location":"CS/OOP/#_21","title":"\u6807\u51c6\u5e93","text":""},{"location":"CS/OOP/#_22","title":"\u667a\u80fd\u6307\u9488","text":"
- \u5728\u4e0e\u5916\u754c\u6a21\u5757\u8fdb\u884c\u4ea4\u4e92\u7684\u65f6\u5019\u4f7f\u7528\u5f02\u5e38\u5904\u7406
- \u5e93\u5185\u90e8\u6700\u597d\u7528
assert
\u6765\u68c0\u67e5\u8fb9\u754c\u6761\u4ef6\u629b\u51fa\u53bb\u6700\u7ec8\u6ca1\u6709catch\u5c06terminate
\u505a\u5230
exception-safe code
\uff0c\u8981\u5b9e\u73b0\u7c7b\u4f3c\u6570\u636e\u5e93\u4e2d\u201c\u539f\u5b50\u6027\u201d\u7684\u64cd\u4f5c\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6a21\u677f\u7c7b\uff0c\u6765
- std::unique_ptr
\u6784\u5efa
// Error\nunique_ptr<A> pa = new A();\n//\nunique_ptr<A> pa(A());\n// \u4e86\u89e3,\u4e0d\u63a8\u8350\u4f7f\u7528new\u53bb\u6784\u5efa\nunique_ptr<A> pa{new A()};\n\nauto pa = make_unique<A>();\n
std::move(source)
string str(\"hello!\");\nstring target(std::move(str));\n\u6240\u6709\u6743\u7684\u8f6c\u8ba9\n\u4e4b\u540e\u7684str\u4e0d\u80fd\u518d\u4f7f\u7528\uff0c\u5176\u4e2d\u7684\u503c\u65f6undefined\u3001\n
pa.get()
\u83b7\u5f97\u539f\u751f\u6307\u9488``
std::shared_ptr
pt.use_count()
\u5f15\u7528\u8ba1\u6570
std::weak_ptr
\u80fd\u591f\u770b\u5230\u7ba1\u7406\u6743\uff0c\u4f46\u662f\u4e0d\u4f1a\u589e\u52a0\u5176
use_count
\u6bd4\u5982\u4e24\u4e2a\u7c7b\uff0c\u5f7c\u6b64\u4e4b\u95f4\u7528shared_ptr\u4e92\u6307\uff0c\u5c06\u9020\u6210\u6b7b\u9501
"},{"location":"CS/OOP/#application","title":"Application","text":""},{"location":"CS/OOP/#_23","title":"\u6392\u5e8f","text":"
std::auto_ptr
(deprecated in C++11)"},{"location":"CS/OOP/#stl","title":"STL","text":""},{"location":"CS/OOP/#map","title":"map","text":"
less
greater
\u51fd\u6570map<string, int> a = {{\"a\", 1}, {\"b\", 2}};\na.emplace(\"c\", 4);\na[\"d\"] = 4;\na.insert({\"e\", 5});\nfor (const auto &[key, value] : a)\n{\n cout << \"Key: \" << key << \", Value: \" << value << endl;\n}\n
\u8fd9\u91cc\u7684i\u4e3apair\u7c7b\u578b
"},{"location":"CS/OOP/#list","title":"list","text":""},{"location":"CS/%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96/","title":"\u3010\u77ed\u5b66\u671f\u3011\u5927\u6570\u636e\u53ef\u89c6\u5316","text":"\u7ea6 324 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
2023 \u65f6\u95f4\u5b89\u6392
\u8bfe\u8868.pdf \u56e0\u4e3a\u7ebf\u4e0b\u4e0a\u8bfe\u7684\u5bb9\u91cf\u95ee\u9898\uff0c\u5e76\u6ca1\u6709\u9009\u4e0a\u5927\u540d\u9f0e\u9f0e\u7684\u8ba1\u7b97\u673a\u7cfb\u7edf\u6982\u8bba\uff0c\u4e8e\u662f\u5728 ljj \u7684\u538b\u8feb\u4e0b\u6beb\u4e0d\u72b9\u8c6b\u5730\u9009\u62e9\u4e86\u8fd9\u95e8\u8bfe\uff08\u3002\u6bd4\u8d77\u8ba1\u6982\uff0c\u8fd9\u95e8\u8bfe\u7b97\u662f\u5f88\u6c34\u5f88\u6c34\u4e86\u3002 \u8fd9\u95e8\u8bfe\u7a0b\u4e3b\u8981\u662f\u4ee5 \u8bb2\u5ea7 + \u52a9\u6559\u8bb2\u89e3 \u7684\u65b9\u5f0f\u5448\u73b0\u3002 \u5176\u4e2d\uff0c\u8bb2\u5ea7\u7684\u90e8\u5206\u591a\u6570\u662f\u7eaf\u82f1\u6587\uff0c\u6709\u4e00\u4e9b\u8001\u5e08\u8bb2\u8ff0\u524d\u6cbf\u7684\u7814\u7a76\uff0c\u5206\u4eab\u4ed6\u4eec\u7684\u7814\u7a76\u5185\u5bb9\uff08\u5f53\u7136\uff0c\u4e0d\u4f1a\u662f\u7279\u522b\u6df1\u5965\u90a3\u79cd\uff0c\u867d\u7136\u6211\u4e5f\u6ca1\u600e\u4e48\u542c\u8fc7\uff09 \u7b2c\u4e00\u5468\u4f1a\u628a\u5f00\u53d1\u8981\u7528\u7684\u4e1c\u897f\u8bb2\u5b8c\uff0c\u7b2c\u4e8c\u5468\u7684\u4e0b\u5348\u65f6\u95f4\u5c31\u7559\u7ed9\u56e2\u961f\u5b8c\u6210\u5927\u4f5c\u4e1a
"},{"location":"CS/%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96/#_1","title":"\u8bfe\u7a0b\u8bc4\u4ef7\u65b9\u5f0f","text":"
Project 1
20%Learn to use visual analytics tools (Tableau, \u2026).
\u4f7f\u7528 Tableau \u505a\u4e00\u4e2a\u7b80\u5355\u7684\u56fe\u8868\u5206\u6790\uff0c\u5199\u4e00\u4efd\u62a5\u544a
Project 2
50%
- Data analysis with visual analytics tools (Python, Tableau, \u2026)
- or a visual analytics system designed by yourself
\u4e3b\u9898\u81ea\u9009 \u4e00\u822c\u4e09\u4eba\u4e3a\u4e00\u7ec4
pre
20%
Attendance
10% \u4f1a\u6709\u70b9\u540d
Bonus
5 pointsProject 2 \u9009\u62e9\u8bbe\u8ba1\u53ef\u89c6\u5316\u5206\u6790\u7cfb\u7edf\u5373\u53ef\u83b7\u5f97
"},{"location":"CS/%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96/#_2","title":"\u5b66\u4ec0\u4e48","text":"
- \u524d\u7aef\u4e09\u4ef6\u5957
Javascript
,css
,html
"},{"location":"CS/AI/","title":"Index","text":"
- \u4e00\u4e9b\u6846\u67b6\u7684\u642d\u5efa\uff0c\u811a\u624b\u67b6\u7684\u4f7f\u7528
REACT
\u6216\u8005Vue
\uff0c\u4e0a\u8bfe\u4f1a\u7b80\u5355\u6559\u4e00\u4e9b React \u7684\u5185\u5bb9\uff08\u4e0d\u5f97\u4e0d\u5410\u69fd\u6559\u5f97\u5f88\u5c11\uff0c\u66f4\u591a\u8fd8\u662f\u662f\u8981\u81ea\u5df1\u5b66\uff09\u7ea6 48 \u4e2a\u5b57
\u4eba\u5de5\u667a\u80fd
\u4efb\u8bfe\u6559\u5e08\uff1a\u8303\u9e64\u9e64 \u6559\u6750\uff1a\u4eba\u5de5\u667a\u80fd\u5bfc\u8bba\uff1a\u6a21\u578b\u4e0e\u7b97\u6cd5 (\u5434\u98de) \u6210\u7ee9\u6784\u6210\uff1a - \u9879\u76ee\u7f16\u7a0b\u4f5c\u4e1a 35% - \u8003\u52e4 5% - \u671f\u672b\u95ed\u5377\u8003\u8bd5 60%
"},{"location":"CS/AI/Review/","title":"Review","text":"\u7ea6 152 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CS/AI/Review/#_1","title":"\u5f3a\u5316\u5b66\u4e60","text":"\u201c\u5c1d\u8bd5\u4e0e\u8bd5\u9519\u201d\u548c\u201c\u63a2\u7d22\u4e0e\u5229\u7528\u201d\u7b49\u673a\u5236\u5728\u6240\u5904\u72b6\u6001\u91c7\u53d6\u884c\u52a8\uff0c\u4e0d\u65ad\u4e0e\u73af\u5883\u4ea4\u4e92\uff0c\u76f4\u81f3\u8fdb\u5165\u7ec8\u6b62\u72b6\u6001\uff0c\u6839\u636e\u5728\u7ec8\u6b62\u72b6\u6001\u6240\u83b7\u5f97\u7684\u5956\u60e9\u6765\u6539\u8fdb\u884c\u52a8\u7b56\u7565\uff0c\u5e8f\u8d2f\u5b8c\u6210\u51b3\u7b56\u4efb\u52a1\u3002
\u5728\u5f3a\u5316\u5b66\u4e60\u4e2d\uff0c\u5b66\u4e60\u4fe1\u53f7\u4ee5\u5956\u52b1\u5f62\u5f0f\u51fa\u73b0\uff0c\u667a\u80fd\u4f53\u5728\u4e0e\u73af\u5883\u4ea4\u4e92\u4e2d\u53d6\u5f97\u6700\u5927\u5316\u6536\u76ca
\u9a6c\u5c14\u53ef\u592b\u6027\u8d28\u2014\u2014\u5373\u4e0b\u4e00\u4e2a\u72b6\u6001\u7684\u6982\u7387\u5206\u5e03\u4ec5\u4f9d\u8d56\u4e8e\u5f53\u524d\u72b6\u6001\u548c\u6240\u91c7\u53d6\u7684\u884c\u52a8\uff0c\u4e0e\u4e4b\u524d\u7684\u5386\u53f2\u72b6\u6001\u6216\u884c\u52a8\u65e0\u5173
"},{"location":"CS/AI/Review/#q-learning","title":"Q Learning","text":""},{"location":"CS/CO/","title":"\u8ba1\u7b97\u673a\u7ec4\u6210","text":"\u7ea6 17 \u4e2a\u5b57
\u4ecb\u7ecd
\u666e\u901aCS\u7684\u8ba1\u7ec4\u4e13\u4e1a\u8bfe
"},{"location":"CS/CO/1_Interface/","title":"Chapter 1 | Computer Abstraction","text":"\u7ea6 360 \u4e2a\u5b57 38 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
info
\u8fd9\u4e00\u7ae0\u662f\u603b\u89c8\u6027\u8d28\u7684\uff0c\u6ca1\u6709\u7279\u522b\u7684\u77e5\u8bc6\u70b9\uff0c\u5f88\u591a\u90fd\u662f\u6027\u8d28\u3001\u6982\u8ff0\u3002 \u8981\u6ce8\u610fTime\u7684\u8ba1\u7b97
"},{"location":"CS/CO/1_Interface/#_1","title":"\u7ec4\u6210","text":"Graph From https://xuan-insr.github.io/
- Instruction set architecture\uff08ISA,\u6307\u4ee4\u96c6\u7cfb\u7edf\u7ed3\u6784\uff09 ---- the interface between hardware and lowest-level software
graph LR\n1[Computer System]\n2[Software]\n3[Hardware]\n2.1[Application Software]\n\n2.2[System Software]\n\n2.2.1[Operation System]\n2.2.2[GCC]\n2.2.3[Firmware/Driver Software]\n\n1 --> 2\n1-->3\n2-->2.1\n2-->2.2\n2.2-->2.2.1\n2.2-->2.2.2\n2.2-->2.2.3\n\n3.1[CPU]\n3.2[Memory]\n3.3[I/O interface]\n3.1.1[Control unit]\n3.1.2[DataPath]\n3-->3.1\n3-->3.2\n3-->3.3\n3.1-->3.1.1\n3.1-->3.1.2\n3.3.1[Input: keyboard]\n3.3.2[Bidirectional: RS-232,USB]\n3.3.3[Output: VGA\uff0cLCD]\n3.3-->3.3.1\n3.3-->3.3.2\n3.3-->3.3.3
\u6ca1\u60f3\u5230\u671f\u4e2d\u8003\u8bd5\u7adf\u7136\u8003\u4e86Software\u90e8\u5206\u7684\u6846\u56fe
SoftWare
"},{"location":"CS/CO/1_Interface/#io-interface","title":"I/O Interface","text":""},{"location":"CS/CO/1_Interface/#memory","title":"Memory","text":""},{"location":"CS/CO/1_Interface/#_2","title":"\u8bed\u8a00\u8f6c\u6362","text":""},{"location":"CS/CO/1_Interface/#time","title":"* Time\u7684\u8ba1\u7b97","text":"graph\n\u9ad8\u7ea7\u7f16\u7a0b\u8bed\u8a00--Compiler-->\u6c47\u7f16--ASsembler-->3[Machine Code]
\u5904\u7406\u5668\u6267\u884c\u65f6\u95f4\u7531\u5904\u7406\u9891\u7387\uff0c \u7a0b\u5e8f\u6267\u884c\u7684\u6307\u4ee4\u6570\u76ee\u548c\u6bcf\u6761\u6307\u4ee4\u7684\u6027\u80fd\u51b3\u5b9a\uff1b \u800c\u6bcf\u6761\u6307\u4ee4\u7684\u6027\u80fd\uff0c\u7531\u6bcf\u6761\u6307\u4ee4\u6240\u9700\u65f6\u949f\u6570\u51b3\u5b9a
Response time/execution time \u54cd\u5e94\u65f6\u95f4/\u6267\u884c\u65f6\u95f4
- How long it takes to do a task
Throughput (bandwidth) \u541e\u5410\u7387
\u4e86\u89e3cost
- Total work done per unit time
- e.g., tasks/transactions/\u2026 per hour
Performance = 1/Execution Time
\u4e00\u4e2a\u6307\u4ee4\u5468\u671f\uff0c\u5305\u542b\u591a\u4e2a CPU \u5468\u671f\uff0c\u800c\u4e00\u4e2a CPU \u5468\u671f\u5305\u542b\u591a\u4e2a\u65f6\u949f\u5468\u671f\u3002
example
- CPI : \u6bcf\u6761\u6307\u4ee4\u7684\u5e73\u5747\u5468\u671f\u6570(Average cycles per instruction) \u2192 CPU \u5468\u671f
example
example
"},{"location":"CS/CO/1_Interface/#eight-great-ideas","title":"Eight Great Ideas","text":"
- MIPS: Millions of Instructions Per Second
"},{"location":"CS/CO/1_Interface/#_3","title":"\u8865\u5145","text":""},{"location":"CS/CO/1_Interface/#power-trend","title":"Power Trend","text":"
Design for Moore\u2019s Law \uff08\u8bbe\u8ba1\u7d27\u8ddf\u6469\u5c14\u5b9a\u5f8b\uff09
Use Abstraction to Simplify Design ( \u91c7\u7528\u62bd\u8c61\u7b80\u5316\u8bbe\u8ba1 )
Make the Common Case Fast ( \u52a0\u901f\u5927\u6982\u7387\u4e8b\u4ef6 )
Performance via Parallelism ( \u901a\u8fc7\u5e76\u884c\u63d0\u9ad8\u6027\u80fd )
Performance via Pipelining ( \u901a\u8fc7\u6d41\u6c34\u7ebf\u63d0\u9ad8\u6027\u80fd )
Performance via Prediction ( \u901a\u8fc7\u9884\u6d4b\u63d0\u9ad8\u6027\u80fd )
Hierarchy of Memories ( \u5b58\u50a8\u5668\u5c42\u6b21 )
Dependability via Redundancy ( \u901a\u8fc7\u5197\u4f59\u63d0\u9ad8\u53ef\u9760\u6027)
\u671f\u4e2d\u8003\u5230\u4e86, \u9898\u76ee\u5927\u610f\u8ddf\u4e0a\u56fe\u4e00\u81f4\uff0c\u8ba1\u7b97\\(\\frac{P_{new}}{P_{old}}\\)
"},{"location":"CS/CO/1_Interface/#_4","title":"\u9898\u76ee","text":""},{"location":"CS/CO/1_Interface/#eight-idea","title":"Eight Idea","text":""},{"location":"CS/CO/2_Instruction/","title":"Chapter 2 | Instruction","text":"\u7ea6 866 \u4e2a\u5b57 50 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
\u6982\u8ff0
- Introduction
- Operations of the computer hardware (\u8ba1\u7b97\u673a\u786c\u4ef6\u7684\u64cd\u4f5c)
- Operands of the computer hardware(\u8ba1\u7b97\u673a\u786c\u4ef6\u7684\u64cd\u4f5c\u6570)
- Signed and unsigned numbers (\u6709\u7b26\u53f7\u548c\u65e0\u7b26\u53f7\u6570)
- Representing instructions in the computer(\u8ba1\u7b97\u673a\u4e2d\u6307\u4ee4\u7684\u8868\u793a)
- Logical operations(\u903b\u8f91\u64cd\u4f5c)
- Instructions for making decision(\u51b3\u7b56\u6307\u4ee4)
- Supporting procedures in computer hardware(\u8ba1\u7b97\u673a\u5bf9\u8fc7\u7a0b\u7684\u652f\u6301)
- Instruction addressing (\u6307\u4ee4\u7684\u5bfb\u5740)
\u4fe1\u606f\u91cf Op > Func 3 > Func 6/7
"},{"location":"CS/CO/2_Instruction/#mention","title":"Mention","text":"\u91cd\u70b9\u7406\u89e3
- Branch\u6307\u4ee4\u8fdb\u884c\u5faa\u73af\u7b49\u64cd\u4f5c
- Procdure\u5c24\u5176\u662f\u6808\u7684\u5199\u6cd5
- \u9012\u5f52\uff0c\u6590\u6ce2\u90a3\u5951
- \u533a\u5206jal jalr
jal \u8df3\u8f6c\u662f\u57fa\u4e8ePC\u7684\u8df3\u8f6c UJ type
jalr \u76f8\u5f53\u4e8ejal\u7684\u5bc4\u5b58\u5668\u7248\u672c \u8df3\u8f6c\u8303\u56f4\u66f4\u52a0\u5e7f I type
PC + 4 \u90fd\u8981\u5b58\u56de\u53bb
"},{"location":"CS/CO/2_Instruction/#introduction","title":"Introduction","text":"
- \u7acb\u5373\u6570\u7684\u79cd\u7c7b
- \u8f6c\u6362code\u7684\u65f6\u5019\u6ce8\u610frs1\uff0crs2\u7684\u4f4d\u7f6e
\u5b58\u50a8\u7a0b\u5e8f\u6982\u5ff5\uff1a \u6307\u4ee4\u548c\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u4e0d\u52a0\u533a\u5206\u5730\u5b58\u50a8\u5728\u5b58\u50a8\u5668\u4e2d\u5e76\u56e0\u6b64\u6613\u4e8e\u66f4\u6539\uff0c\u56e0\u4e3a\u4ea7\u751f\u4e86\u5b58\u50a8\u7a0b\u5e8f\u8ba1\u7b97\u673a
"},{"location":"CS/CO/2_Instruction/#operation","title":"Operation","text":""},{"location":"CS/CO/2_Instruction/#operands","title":"Operands","text":"
- \u4e00\u6761\u6307\u4ee4\u4e00\u4e2a\u64cd\u4f5c
RISC - V 32 \u00d7 64-bit register file
word: 32 bits
double word : 64 bits
"},{"location":"CS/CO/2_Instruction/#register","title":"Register","text":"
- Arithmetic instructions use register operands \u5fc5\u987b\u5728\u5bc4\u5b58\u5668
- \u4ee564bits\u7684\u60f3\u6cd5\u7406\u89e3\u540e\u7eed\u7684\u6240\u6709\u64cd\u4f5c
C code: f = (g + h) - (i + j); f, \u2026, j in x19, x20, \u2026, x23 Compiled
RISC-V code: add x5, x20, x21 add x6, x22, x23 sub x19, x5, x6
"},{"location":"CS/CO/2_Instruction/#memory-operands","title":"Memory Operands","text":""},{"location":"CS/CO/2_Instruction/#byte-addressed","title":"byte addressed","text":""},{"location":"CS/CO/2_Instruction/#little-endian","title":"little endian","text":"
\u5927\u7aef\u5c0f\u7aef\u9488\u5bf9\u7684\u662f\u4e00\u4e2aword, \u5728\u5185\u5b58\u4e2d\u6709\u5f71\u54cd
Least-significant byte at least address of a word
c.f. Big Endian: most-significant byte at least address
0x 12345678 word index : 3210
32bits,4bytes
==> 78 is the lsb, \u8fd9\u4e2abyte\u4f4d\u4e8e3
"},{"location":"CS/CO/2_Instruction/#word-alignment","title":"word \u5bf9\u9f50 Alignment","text":"RISV - V\u4e0d\u5f3a\u5236\u8981\u6c42
word aligned
"},{"location":"CS/CO/2_Instruction/#example","title":"example","text":"struct {\n int a;\n char b;\n char c[2];\n char d[3]\n float e;\n}\n
"},{"location":"CS/CO/2_Instruction/#constant-or-immediate-operands","title":"Constant or immediate operands","text":"
- \u80fd\u8bbf\u95ee\u5bc4\u5b58\u5668\u7684\u53ea\u6709
load
store
- \u8fd9\u91cc\u5c55\u793a\u7684\u662f
\u5b57\u8282\u5bfb\u5740\uff088 bits\uff09
\u907f\u514d\u5e38\u6570\u64cd\u4f5c\u65f6load store \u6d6a\u8d39\u65f6\u95f4
"},{"location":"CS/CO/2_Instruction/#representing-instructions","title":"Representing Instructions","text":"Offer versions of the instruction \n addi x22, x22, 4 // x22= x22+ 4 \n\nConstant zero: a register x0\n
Mapping registers into numbers map registers x0 to x31 onto registers 0 to 31
RISC-V instructions
- Encoded as 32-bit instruction words \u6bcf\u6761\u6307\u4ee4\u4e00\u4e2aword
- Small number of formats encoding operation code (opcode), register numbers, \u2026Regularity
"},{"location":"CS/CO/2_Instruction/#r-format-instructions","title":"R-Format instructions","text":"
sd A,B
ld
opcode
: operation coderd
: destination register numberfunct3
: 3-bit function code (additional opcode) \u4f8b\u5982\u533a\u5206\u52a0\u51cf\u6cd5rs1
: the first source register numberrs2
: the second source register numberfunct7
: 7-bit function code (additional opcode)example
"},{"location":"CS/CO/2_Instruction/#i-format-instructions","title":"I-Format Instructions","text":"
load
addi
"},{"location":"CS/CO/2_Instruction/#s-format-instructions","title":"S-Format Instructions","text":"Example\uff1ald x9, 64(x22)\n22 (x22) is placed rs1;\n64 is placed immediate\n9 (x9) is placed rd\n
Example\uff1asd x9, 64(x22)\n 22 (x22) is placed rs1;\n 64 is placed immediate\n 9 (x9) is placed rs2\n
\u200b
"},{"location":"CS/CO/2_Instruction/#logical","title":"Logical","text":""},{"location":"CS/CO/2_Instruction/#instructions-for-making-decisions","title":"Instructions for making decisions","text":""},{"location":"CS/CO/2_Instruction/#branch","title":"Branch \u6307\u4ee4","text":"
slli\u3001ori...
\u4f7f\u7528\u7684\u4ecd\u7136\u662fI type Instruction
\uff0c\u53ea\u662fimm\u53ea\u7528\u4e86\u4f4e6\u4f4d"},{"location":"CS/CO/2_Instruction/#slt","title":"SLT","text":"
- \u901a\u8fc7
slli x10\uff0cx22\uff0c3
\u5c06 i \u5de6\u79fb3\u4f4d\u5f97\u5230\u5730\u5740\u504f\u79fb\u91cf
- \u6ce8\u610f\u8fd9\u91cc\u7684\u5927\u4e8e\u8868\u793a\u65b9\u6cd5,
bge>= beq== bne!=
A>B B>=A\u6709\u7b26\u53f7\u6570\u6bd4\u8f83
blt
: less thanbge
: greater equal\u65e0\u7b26\u53f7\u6570
"},{"location":"CS/CO/2_Instruction/#switchcase","title":"Switch/Case","text":"bltu
bgeu
jalr \uff1ajump and load register
JumpTable\u4e2d\u5b58\u50a8\u7684\u662f\u76ee\u6807\u7a0b\u5e8f\u7684\u5730\u5740\uff0c\u8fd9\u4e2aTable\u7684\u8d77\u59cb\u5730\u5740\u5047\u8bbe\u5728
X6
"},{"location":"CS/CO/2_Instruction/#basic-blocks","title":"Basic Blocks","text":""},{"location":"CS/CO/2_Instruction/#procedurefunction","title":"Procedure/function","text":"
- \u8fb9\u754c\u63a7\u5236
- \u8ba1\u7b97Table\u4e2d\u7684\u5730\u5740
- \u53d6\u51faTable\u4e2d\u7684\u503c\uff08\u4e00\u4e2a\u8df3\u8f6c\u7684\u5730\u5740\uff09
- \u8df3\u8f6c
jal
: jump and link
jal x1,100
\u8df3\u5230 PC + 100 \u7684\u4f4d\u7f6e
jarl x1,100(x5)
\u51e0\u4e4e\u76f8\u540c\uff0c\u53ea\u662f\u8df3\u8f6c\u7684\u57fa\u5740\u662freg\u4e2d\u7684\u503c\u57fa\u672c\u6d41\u7a0b\n // Caller !push to stack!\n Place Parameters in a place where the procedure can access them\n\n Transfer control to the procedure\uff1ajump to \n\n Acquire the storage resources needed for the procedure\n\n Perform the desired task\n\n Place the result value in a place where the calling program can access it \n // Callee jalr x0,0(x1) \n // !pull from stack and recover!\n // !\u6ce8\u610f\u51fd\u6570return\u7684\u503c\u8981\u7ed9\u67d0\u4e2a\u53e6\u5916\u7684\u5bc4\u5b58\u5668\uff0c\u800c\u4e0d\u662ftemporary\u5bc4\u5b58\u5668!\n Return control to the point of origin \n
Stack
- \u5f53\u53c2\u6570\u591a\u4e8e\u4e34\u65f6\u5bc4\u5b58\u5668\u7684\u4e2a\u6570 - \u6062\u590d\u539f\u6765\u7684\u53c2\u6570 \u9488\u5bf9
"},{"location":"CS/CO/2_Instruction/#communicating-with-people","title":"Communicating with People","text":"Saved value
- \u6ce8\u610f\u65b9\u5411\uff0c\u53ef\u4ee5\u770b\u5230\u4e0b\u9762\u662f\u4f4e\u4f4d\uff0c\u6240\u4ee5push\u8981sp - 8*bitsstrcpy: addi sp, sp, -8 # adjust stack for 1 doubleword\n sd x19, 0(sp) # save x19\n add x19, x0, x0 # i = 0 \n L1: \n add x5, x19, x11 # x5 = address of y[ i ]\n lbu x6, 0(x5) # x6 = y [ i ]\n add x7, x19, x10 # x7 = address of x[ i ] \n sb x6, 0(x7) # x[ i ] = y[ i ]\n beq x6, x0, L2 # if y[i] == 0 then exit\n addi x19, x19, 1 # i = i + 1\n jal x0, L1 # next iteration of loop\n L2: ld x19, 0(sp) # restore saved old s3\n addi sp, sp, 8 # pop 1 double word from stack\n jalr x0 0(x1) # return\n
\u6ce8\u610f\u8fd9\u91cc\u8ba1\u7b97
"},{"location":"CS/CO/2_Instruction/#32-bit-immediate-and-addresses","title":"32-Bit Immediate and Addresses","text":"address
\u7684\u65f6\u5019\u662fchar
\u7c7b\u578b\u7684lui
"},{"location":"CS/CO/2_Instruction/#_1","title":"\u5bfb\u5740","text":"
- PC\u76f8\u5bf9\u5bfb\u5740\u65b9\u5f0f
\u4e0b\u9762\u4e24\u79cdimm\u7684\u6700\u4f4e\u4e3a\u6052\u4e3a1
Branches
Jump
\u8fd9\u91cc\u7684jump\u6307\u7684\u662f
"},{"location":"CS/CO/2_Instruction/#synchronization-in-risc-v","title":"Synchronization in RISC-V | \u540c\u6b65","text":"jal
\u4e0d\u60f3\u5b66\u4e86
hobbitqia\u7684Notes
"},{"location":"CS/CO/2_Instruction/#a-c-sort-example-to-put-it-all-together","title":"A C Sort Example To Put it All Together","text":"\u4e3b\u8981\u8981\u7406\u89e3\u4e00\u4e0bloop
"},{"location":"CS/CO/2_Instruction/#_2","title":"\u9898\u76ee","text":""},{"location":"CS/CO/2_Instruction/#_3","title":"\u5927\u5c0f\u7aef\u5bf9\u9f50","text":"\u8fd9\u91cc\u4e00\u4e2abyte\u5b58\u50a8\u4e24\u4e2a16\u8fdb\u5236\u6570
answer"},{"location":"CS/CO/2_Instruction/#_4","title":"\u6c47\u7f16","text":""},{"location":"CS/CO/2_Instruction/#_5","title":"\u6590\u6ce2\u90a3\u5951\u6570","text":""},{"location":"CS/CO/2_Instruction/#_6","title":"\u5c3e\u9012\u5f52\u7684\u4f18\u5316\u3001","text":""},{"location":"CS/CO/3_Arithmetic/","title":"Chapter 3 | Arithmetic for Computer","text":"
0x11
0x88
\u7ea6 926 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
3.1 Introduction - \u6570\u503c\u8868\u8fbe -
3.2 Signed and Unsigned Numbers - Possible Representations
- \u6ea2\u51fa
3.3 Arithmetic--Addition & Subtraction and ALU
- CLA
- \u884c\u6ce2
3.4 Multiplication
3.5 Division
3.6 Floating point numbers
"},{"location":"CS/CO/3_Arithmetic/#introduction","title":"Introduction","text":""},{"location":"CS/CO/3_Arithmetic/#arithmetic","title":"Arithmetic","text":"
- \u4e00\u4e2a\u6570\u5b57\u53ea\u662f\u4e00\u4e2a\u6570\u5b57\uff0c\u672a\u6307\u660e\u542b\u4e49\u5b83\u5e76\u4e0d\u8868\u5f81\u4efb\u4f55\u610f\u4e49
overflow
\\(OverFlow = C_{n} \\oplus C_{n-1}\\)
Delay\u7684\u8ba1\u7b97
\u8fd9\u91cc\u8ddf\u6570\u5b57\u903b\u8f91\u7684\u57fa\u672c\u76f8\u540c
"},{"location":"CS/CO/3_Arithmetic/#cla","title":"CLA","text":""},{"location":"CS/CO/3_Arithmetic/#multiplication","title":"Multiplication","text":"Multiplicand=\u88ab\u4e58\u6570
Multiplier=\u4e58\u6570
"},{"location":"CS/CO/3_Arithmetic/#v1","title":"V1","text":"
- \u4e58\u6cd5\u4e0d\u80fd\u7528\u8865\u7801\u64cd\u4f5c
"},{"location":"CS/CO/3_Arithmetic/#v2","title":"V2","text":"
- \u4e0d\u65ad\u79fb\u52a8\u4f4d\u7f6e\uff08\u5de6\u79fb\u52a8\uff09\uff0c\u505a\u52a0\u6cd5
- \u79fb\u52a8\u88ab\u4e58\u6570
- \u5bf9\u4e58\u6570\u7684\u6700\u540e\u4e00\u4f4d\u5224\u65ad\uff0c\u662f1\uff0c\u7ed3\u679c\u52a0\u4e0a\u5f53\u524d\u7684\u88ab\u4e58\u6570
- \u4e0d\u79fb\u52a8\u88ab\u4e58\u6570\uff0c\u800c\u662f\u79fb\u52a8\u4e58\u79efproduct
- \u5bf9\u4e8e128bits\u7684product\uff0c\u9ad864bits\u8fdb\u884c\u7b97\u672f\u8fd0\u7b97\uff0c\u7136\u540e\u4e0d\u65ad\u53f3\u79fb
example
"},{"location":"CS/CO/3_Arithmetic/#v3","title":"V3","text":"
- \u4e4b\u524dV2\u91cc\u9762\u7684Product\u4f4e64bits\u6ca1\u6709\u4efb\u4f55\u7528\u5904\uff0c\u8fd9\u91cc\u7528\u6765\u88c5\u4e58\u6570\uff0c\u4f7f\u4e4b\u53f3\u79fb\u79fb\u9664\u7684bit\u8fdb\u884c\u5224\u65ad
"},{"location":"CS/CO/3_Arithmetic/#_1","title":"\u6709\u7b26\u53f7\u4e58\u6cd5","text":"
- 129bits\u662f\u4e3a\u4e86\u4fdd\u5b58\u8fdb\u4f4d\uff08\u4e2a\u4eba\u611f\u89c9\u7528\u4e0d\u5230\u554a
- \u8bb0\u5f55\u7b26\u53f7\uff0c\u8f6c\u4e3a\u7edd\u5bf9\u503c\u76f8\u4e58
Booth Algorithm
\u9002\u7528\u4e8e\u5f0f\u5b50\u4e2d1\u6bd4\u8f83\u591a\u7684\u60c5\u51b5\uff0c\u5c06\u591a\u7684\u52a0\u6cd5\u8f6c\u6362\u4e3ashift\uff08\u5de6\u5230\u53f3\u7684\u5e8f\u5217\uff09
\u6839\u636e\u76f8\u90bb\u7684\u4e24\u4e2abits\u5224\u65ad\u5bf9\u8fd9\u4e00\u4f4d\u8981\u505a\u4ec0\u4e48\u64cd\u4f5c\uff0c\u00b1\u88ab\u4e58\u6570
- \u4e0e\u4e0a\u9762\u7684\u601d\u60f3\u7c7b\u4f3c\uff0c\u5728\u4e00\u4e2a\u5bc4\u5b58\u5668\u5de6\u534a\u90e8\u5206\uff0c\u53f3\u534a\u90e8\u5206 \u5206\u522b \u653e\u7f6e Result\uff0c\u4e58\u6570\uff1b\u6bcf\u6b21\u6839\u636e\u4e58\u6570\u6700\u4f4e\u4f4d\u7684\u5e8f\u5217\u5bf9Result\u90e8\u5206\u8fdb\u884c\u64cd\u4f5c\uff0c\u6bd4\u5982 add \u88ab\u4e58\u6570\uff1b
- \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8ba1\u7b97\u8fd9\u4e2a\u5e8f\u5217\u662f\u4ece -1 \u4f4d\uff08\u9ed8\u8ba4\u4e3a0\uff09\u5f00\u59cb\u7684
- shift\u64cd\u4f5c\u6bcf\u6b21\u90fd\u8981\u8fdb\u884c 11\u300100 \u7684\u60c5\u51b5\u76f8\u5f53\u4e8eoperation\u73af\u8282\u662f\u7a7a\u7684
Example
"},{"location":"CS/CO/3_Arithmetic/#division","title":"Division","text":"Dividend=\u88ab\u9664\u6570\uff0c
Divisor=\u9664\u6570
Quotient \u5546
"},{"location":"CS/CO/3_Arithmetic/#v1_1","title":"V1","text":"
- \u9664\u6570\u6700\u5f00\u59cb\u5728Divisor\u5de664bits\uff0c\u88ab\u9664\u6570\u5728Remainder\u53f364bits\uff0c
Note
"},{"location":"CS/CO/3_Arithmetic/#v2_1","title":"V2","text":"\u6539\u8fdb
\u9664\u6570\u4e0d\u52a8\uff0c\u88ab\u9664\u6570\u5de6\u79fb\uff0c\u8fdb\u884c\u8ba1\u7b97\uff0c\u5c0f\u4e8e\u96f6\u5219\u56de\u9000\uff0c\u5de6\u79fbremainder\u7f6e0\uff1b\u5927\u4e8e\u96f6\u5de6\u79fbremainder\u7f6e1
shift right
\u9488\u5bf9\u7684\u662f\u6700\u540e\u4e00\u6b65\uff0c\u628a\u4f59\u6570\u90e8\u5206\u7684\u7ed3\u679c\u53f3\u79fb1bitexample
"},{"location":"CS/CO/3_Arithmetic/#_2","title":"\u6709\u7b26\u53f7\u9664\u6cd5","text":"
- \u6ce8\u610f\u6700\u540e\u4e00\u6b65
"},{"location":"CS/CO/3_Arithmetic/#floating-point-numbers","title":"Floating point Numbers","text":"
remainder
\u9ad8\u4f4d\uff0c\u7b26\u53f7\u7531\u88ab\u9664\u6570\u51b3\u5b9a- \u4f4e\u4f4d \u5546
- Overflow and division-by-zero don\u2019t produce errors
- Just return defined results
- Faster for the common case of no error
- \u5355\u7cbe\u5ea6 float 1 + 8 + 23
- \u53cc\u7cbe\u5ea6 double 1 + 11 + 52
\u4e3a\u4e86\u8282\u7701\u7b26\u53f7\u4f4d\u7684\u7a7a\u95f4\uff0c
\\[ \u4e8e\u662f\u53ef\u4ee5\u8868\u793a\uff1a \\ \\ (-1)^{sign}(1+significand)*2^{exponent - bias} \\] "},{"location":"CS/CO/3_Arithmetic/#range","title":"Range","text":"exponent
\u6211\u4eec\u90fd\u52a0\u4e0a\u4e86\u4e00\u4e2abiased
Exponents
"},{"location":"CS/CO/3_Arithmetic/#_3","title":"\u7cbe\u5ea6","text":"
- 00000000 and 11111111 reserved
\u8ba1\u7b97\u7cbe\u5ea6\u4e0e\u5c0f\u6570\u4f4d\u6570\u76f8\u5173
"},{"location":"CS/CO/3_Arithmetic/#_4","title":"\u52a0\u6cd5","text":""},{"location":"CS/CO/3_Arithmetic/#algorithm","title":"Algorithm","text":"
- Alignment \u5bf9\u9f50 \u4e00\u822c\u7531\u8f83\u5c0f\u7684\u6570\u5411\u5927\u7684\u53d8
- The proper digits have to be added
- Addition of significands
- Normalization of the result \u5f52\u4e00\u5316\u5904\u7406
- Rounding \u8fdb\u4f4d
example
"},{"location":"CS/CO/3_Arithmetic/#_5","title":"\u4e58\u6cd5","text":""},{"location":"CS/CO/3_Arithmetic/#ieee","title":"IEEE \u62d3\u5c55 \u7cbe\u786e\u7b97\u672f\u8fd0\u7b97","text":"
- \u8bb0\u5f97exponent\u90e8\u5206\u76f8\u52a0\u4e4b\u540e\u51cf\u53bb\u4e00\u4e2a
bias
- \\(y={exponent - bias},y_1+y_2=ex_1+ex_2-2*bias,ex_1+ex_2=y+2*bias\\)
\u6ce8\u610f\uff01
\u8fd9\u4e2aBlog\u5b9a\u4e49\u7684\u6982\u5ff5\u8ddf\u8bfe\u672c\u4e0a\u7684\u4e0d\u4e00\u81f4
"},{"location":"CS/CO/3_Arithmetic/#_6","title":"\u9898\u76ee","text":""},{"location":"CS/CO/3_Arithmetic/#_7","title":"\u6d6e\u70b9\u6570\u8ba1\u7b97","text":"Answer Answer
Blog
\u8fd9\u4e9bbits\u7684\u4f5c\u7528\u662f\u5728\u8fd0\u7b97\u8fc7\u7a0b\u4e2d\u4fdd\u7559\u7cbe\u5ea6\u4fbf\u4e8e\u4e4b\u540e\u8fdb\u4f4d\u635f\u5931\u7684\u7cbe\u5ea6\u4e0d\u8d85\u8fc70.5ulp
sticky bit
\u5728Round bit\u4e4b\u540e\u7684\u6240\u6709\u4f4d\u4e2d\u53ea\u8981\u67091\u5c31\u5b58\u4e3a1\uff0c\u8fd9\u4e2abit\u4e0d\u4e00\u5b9a\u8981\u7528\u5230\uff0c\u662f\u4e3a\u4e86\u68c0\u6d4b\u7c7b\u4f3c2.500000000\u4e0e2.500000001
\u7684\u533a\u522bGuard bit
\u8981\u4fdd\u7559\u7684\u6700\u4f4e\u4f4d\u4e4b\u540e\u7684\u7b2c\u4e00\u4f4dRound bit
- \u820d\u5165\u89c4\u5219:
- \u5982\u679cguard bit\u662f0\uff0c\u90a3\u4e48\u76f4\u63a5\u622a\u65ad\u3002
- \u5982\u679cguard bit\u662f1\u4e14round bit\u6216sticky bit\u81f3\u5c11\u4e00\u4e2a\u662f1\uff0c\u90a3\u4e48\u5411\u4e0a\u820d\u5165\uff08\u52a01\u81f3\u5c3e\u6570\u7684\u6700\u540e\u4e00\u4f4d\uff09\u3002
- \u5982\u679c\u4ec5\u4ec5guard bit\u662f1\uff0c\u90a3\u4e48\u6267\u884c\u5411\u5076\u6570\u820d\u5165\uff08\u5982\u679c\u5c3e\u6570\u7684\u6700\u540e\u4e00\u4f4d\u662f0\u5219\u4e0d\u53d8\uff0c\u5982\u679c\u6700\u540e\u4e00\u4f4d\u662f1\u5219\u52a01\uff09\u3002
\u5982\u679c\u5148\u8ba1\u7b97\u540e\u4e24\u4e2a\u6570\uff0c\u7ed3\u679c\u4f1a\u53d1\u751f\u53d8\u5316\uff0c\u56e0\u4e3a\u4e2d\u95f4\u8fc7\u7a0b\u7684GRTbit\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u5bfc\u81f4\u4fdd\u6301\u7684\u7cbe\u5ea6\u53d8\u5316
"},{"location":"CS/CO/4_Processor/","title":"Chapter 4 | Processor","text":"\u7ea6 1228 \u4e2a\u5b57 8 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 6 \u5206\u949f
"},{"location":"CS/CO/4_Processor/#part-1","title":"Part 1 \u5355\u5468\u671f","text":""},{"location":"CS/CO/4_Processor/#data-path","title":"Data Path","text":"\u7565
"},{"location":"CS/CO/4_Processor/#control","title":"Control","text":"
- \u4e03\u4e2a\u63a7\u5236\u4fe1\u53f7\u548c\u4e00\u4e2a\u56db\u4f4d\u7684
ALU operation
"},{"location":"CS/CO/4_Processor/#part-2","title":"Part 2 \u6d41\u6c34\u7ebf","text":"
- ALU \u4fe1\u53f7
\u5355\u5468\u671f\u7684\u5f0a\u7aef\uff1a \u5047\u8bbe\u53d6\u6307\u4ee4 200ps, \u5bc4\u5b58\u5668\u8bfb 100ps, ALU \u8ba1\u7b97 200ps, \u5185\u5b58\u8bbf\u95ee 200ps, \u5bc4\u5b58\u5668\u5199 100ps. \u90a3\u4e48
add
\u9700\u8981 600ps,ld
\u9700\u8981 800ps,sd
\u9700\u8981 700ps,beq
\u9700\u8981 500ps.
- a pipeline in which one instruction is in each stage
- CPI is decreased to 1, since one instruction will be issued (or finished) each cycle.
\u541e\u5410\u7387 | throughput
\u6d41\u6c34\u7ebf\u5b9e\u9645\u4e0a\u662f\u63d0\u9ad8\u4e86\u7cfb\u7edf\u7684\u541e\u5410\u7387\u3002\u4f46\u662fLatency (time for each instruction)\u4e0d\u4f1a\u51cf\u5c11
"},{"location":"CS/CO/4_Processor/#hazards","title":"\u7ade\u4e89 | Hazards","text":"\u5bfc\u81f4\u4e0b\u4e00\u6761\u6307\u4ee4\u65e0\u6cd5\u6b63\u5e38\u8fdb\u884c\u7684
"},{"location":"CS/CO/4_Processor/#structure","title":"\u7ed3\u6784\u7ade\u4e89 | Structure","text":"A required resource is busy \u5927\u591a\u6570\u662f\u786c\u4ef6\u95ee\u9898\u5bfc\u81f4
"},{"location":"CS/CO/4_Processor/#data","title":"\u6570\u636e\u7ade\u4e89 | Data","text":"
- In RISC-V pipeline with a single memory
- Load/store requires data access
Instruction fetch would have to stall for that cycle
- Would cause a pipeline \u201cbubble\u201d
\u628a\u6307\u4ee4\u548c\u6570\u636e\u5206\u5f00\u5b58\u50a8 \u5982\u679c\u53ea\u6709\u4e00\u5757\uff0c\u90a3\u4e48\u5f53IF\u9700\u8981\u83b7\u53d6\u6307\u4ee4\uff0cMem\u9700\u8981\u83b7\u53d6\u6570\u636e\u65f6\u5c31\u4f1a\u53d1\u751f\u7ed3\u6784\u5192\u9669
Need to wait for previous instruction to complete its data read/write
\u524d\u4e00\u4e2a\u7684\u7ed3\u679c\u662f\u540e\u4e00\u4e2a\u7684\u64cd\u4f5c\u6570
- WB\u5728\u4e0b\u964d\u6cbf\u89e6\u53d1
- ID\u5728\u4e0a\u5347\u6cbf\u89e6\u53d1
- \u63d2\u5165\"Bubble\"\u8fdb\u884c\"\u7f13\u51b2\"
Solution
- Forwarding (aka Bypassing)
ld
\u6307\u4ee4"},{"location":"CS/CO/4_Processor/#control_1","title":"\u63a7\u5236\u7ade\u4e89 | Control","text":"
- \u7f16\u8bd1\u5668\u65b9\u9762
Deciding on control action depends on previous instruction
\u5728ID\u9636\u6bb5\u52a0\u5165\u66f4\u591a\u7684\u786c\u4ef6\u53bb\u5224\u65ad
\u6216\u8005
\u4f7f\u7528Prediction\u6280\u672f
"},{"location":"CS/CO/4_Processor/#prediction","title":"Prediction","text":"
- \u4f8b\u5982\uff0c\u5bf9
beq
\uff0cIF
\u9700\u8981\u5f97\u77e5\u8981\u53bb\u7684\u5730\u5740\uff0c\u4f1a\u628a\u8ba1\u7b97\u63d0\u524d\u5230ID
\u6b65\u9aa4"},{"location":"CS/CO/4_Processor/#risc-v-pipelined-datapath","title":"RISC-V Pipelined Datapath","text":""},{"location":"CS/CO/4_Processor/#form","title":"Form","text":"
- Can predict branches not taken
- Fetch instruction after branch, with no delay
"},{"location":"CS/CO/4_Processor/#control_2","title":"Control \u6307\u4ee4","text":"
- \u6ce8\u610f\uff0c\u4e0a\u56fe\u4e2d\u7684Write Register\u662f\u9519\u8bef\u7684
"},{"location":"CS/CO/4_Processor/#data-hazards","title":"Data hazards","text":"
WB
\u6b65\u9aa4\u7684Write Register
\u4f20\u56de\u5bc4\u5b58\u5668\u5806Consider this sequence:
sub x2, x1,x3 and x12,x2,x5 or x13,x6,x2 add x14,x2,x2 sd x15,100(x2)
ID/EX
\u90a3\u91cc\u8981\u4f7f\u7528\u7684RS
\u662f\u5176\u4ed6\u6d41\u6c34\u7ebf\u7684RD
, \u5c31\u51fa\u73b0\u4e86\u6570\u636e\u7ade\u4e89\uff08\u8fd9\u91cc\u7684\u5b9a\u4e49\u6709\u4e9b\u7b3c\u7edf\uff0c\u66f4\u51c6\u786e\u5730\u8fd8\u8981\u52a0\u4e0a\u6761\u4ef6\uff1a\u9700\u8981\u7528\u5230RS
\uff09\\[ 1.\\ EX/MEM.RegisterRd=ID/EX.RegisterRs\\\\ 2.\\ EX/MEM.RegisterRd\\ !=0 \\\\ 3.\\ EX/MEM.RegWrite==1 \\\\ \u5bf9\u4e8eMEM/WB\u7ea7\u540c\u7406 \\\\ \\text{\u9700\u8981\u786e\u4fdd\u53d1\u751f\u6570\u636e\u7ade\u4e89\u7684\u4e0a\u4e00\u7ea7\u7684Rd\u662f\u8981\u5199\u56de\u7684\uff0c\u4e14\u5199\u56de\u7684\u5bc4\u5b58\u5668\u4e0d\u662f}X_0 \\] "},{"location":"CS/CO/4_Processor/#double-data-hazard","title":"Double Data Hazard","text":"
- \u6ce8\u610f\u5bc4\u5b58\u5668\u7684\u5199\u6cd5\uff0c
ID/EX.RegisterRd
\u8003\u8651\u4e24\u4e2a\u5730\u65b9\u90fd\u89e6\u53d1\u4e86\u6570\u636e\u7ade\u4e89\uff0c\u9009\u62e9\u6700\u8fd1\u7684\u90a3\u4e2a\u6570\u636e
add x1,x1,x2 add x1,x1,x3 add x1,x1,x4
\u9700\u8981\u5bf9
Mem/WB
\u5bc4\u5b58\u5668\u7684\u7279\u5224
EX/MEM
EX/MEM.RegWrite and (EX/MEM.RegisterRd!=0) and EX/MEM.RegisterRd = ID/EX.RegisterRs1
"},{"location":"CS/CO/4_Processor/#load-use-hazard-detection","title":"Load-Use Hazard Detection","text":"
MEM/WB
graph LR\n1[IF]\n2[ID]\n3[EX]\n4[Mem]\n5[WB]\n1-->2-->3-->4-->5\n
- Load\u7684\u65f6\u5019\uff0c\u5728
IF/ID
\u6b65\u9aa4\u9700\u8981\u5224\u65ad\uff0c\u56e0\u4e3a Load \u7684\u7ed3\u679c\u5fc5\u987b\u8981\u5230mem\u7ea7\u624d\u80fd\u83b7\u53d6\uff0c\u4e0d\u80fdID\u5230\u9519\u8bef\u7684\u6570\u636e
ld
\u7684\u7ed3\u679c\u5728EX/Mem
\u9636\u6bb5\u624d\u80fd\u5f97\u5230Bubble\uff1a\u7a7a\u6321
"},{"location":"CS/CO/4_Processor/#branch-hazard-control","title":"Branch hazard | Control","text":"
- Force control values in ID/EX register to 0 \u63d2\u96f6\u540e\u9762\u7684\uff0c\u628a\u5f53\u524d\u7684ID/EX\u53d8\u4e3aNOP
- EX, MEM and WB do
nop (no-operation)
- Prevent update of PC and IF/ID register \u505c\u6ede\u4e4b\u524d\u7684
- Using instruction is decoded again
"},{"location":"CS/CO/4_Processor/#_1","title":"\u7f29\u77ed\u5206\u652f\u5ef6\u8fdf","text":"
- \u9700\u8981\u6e05\u9664\u5206\u652f\u6307\u4ee4\u5230\u8fbeMem\u9636\u6bb5\u65f6\u5176\u4ed6\u524d\u9762\u51e0\u4e2a\u5bc4\u5b58\u5668
\u5c06\u5bf9\u5206\u652f\u7684\u68c0\u6d4b\u63d0\u524d\u5230ID\u9636\u6bb5
"},{"location":"CS/CO/4_Processor/#_2","title":"\u52a8\u6001\u9884\u6d4b","text":"
- \u9700\u8981\u65b0\u7684\u524d\u9012\u548cStall\u5355\u5143
- bypass
- Stall \uff1a\u6bd4\u5982\u8ba1\u7b97\u5206\u652f\u5730\u5740\u9700\u8981\u7684\u6570\u636e\u6765\u81ea\u4e8e\u4e0a\u4e00\u7ea7\u7684EX\u3001Mem
- \u4e0a\u4e00\u7ea7\u5b58\u5728ALU\u64cd\u4f5c\uff0c\u4e14\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u3002Stall one bubble
- \u4e0a\u4e00\u7ea7\u5b58\u5728ld\u64cd\u4f5c\uff0c\u4e14\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u3002Stall two bubbles
Branch prediction buffer (aka branch history table)
Indexed by recent branch instruction addresses \u6309\u7167\u5206\u652f\u6307\u4ee4\u7684\u4f4e\u4f4d\u5730\u5740\u5b9a\u4f4d\u7684\u5c0f\u5b58\u50a8
Stores outcome (taken/not taken)
- To execute a branch
- Check table, expect the same outcome
- Start fetching from fall-through or target
- If wrong, flush pipeline and flip prediction
\u5206\u652f\u9884\u6d4b\u5355\u5143\u53ef\u4ee5\u653e\u5728ID\u7ea7
\u5373\u4f7f\u5b58\u5728Prediction\uff0c\u8ba1\u7b97Branch Target\u7684\u4e00\u4e2a\u5468\u671f\u635f\u5931\u4e5f\u4e0d\u53ef\u907f\u514d
Branch target buffer | \u5206\u652f\u76ee\u6807\u7f13\u5b58
"},{"location":"CS/CO/4_Processor/#exceptions-and-interrupts","title":"Exceptions and Interrupts | \u5f02\u5e38\u4e0e\u4e2d\u65ad","text":"Interrupts
\u6539\u53d8CPU\u7684 work flow \u7684\u4e24\u79cd\u5f62\u5f0f
predictable \u6bd4\u5982beq\u3001bne\u7b49\u547d\u4ee4\u53d1\u751f\u8df3\u8f6c
unpredictable \u51fa\u73b0\u5f02\u5e38
\u5f88\u591a\u65f6\u5019\u4e8c\u8005\u4e0d\u52a0\u533a\u5206, \u5e7f\u4e49\u7684Exception\u5305\u62ecInterrupt
\u9047\u5230\u5f02\u5e38\u9700\u8981\u5904\u7406\u4e24\u4ef6\u4e8b\uff1a - \u5728\u54ea\u91cc\u5904\u7406\u5f02\u5e38\uff0c\u5982\u4f55\u8df3\u8fc7\u53bb - \u5982\u4f55\u56de\u53bb
1.\u4e2d\u65ad\u6765\u4e86\u600e\u4e48\u529e\u3002
2.\u5b58PC\u5230Supervisor Exception Program Counter (SEPC)\uff0c\u63a7\u5236\u6743\u4ea4\u7ed9\u64cd\u4f5c\u7cfb\u7edf\uff0c\u901a\u8fc7\u5f3a\u5236\u8df3\u8f6c\uff0c
3.\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u884c\u9884\u5148\u89c4\u5b9a\u7684\u64cd\u4f5c\uff0c\u4e5f\u53ef\u80fd\u662f\u6267\u884c\u95ee\u9898\u5206\u6790\uff0c\u4e5f\u53ef\u80fd\u662f\u91cd\u590d\u6267\u884c\u3002
4.\u5206\u6790\u539f\u56e0\u65f6\u4f7f\u7528\u4e24\u79cd\u65b9\u6cd5\u901a\u77e5\u7cfb\u7edf\uff0c
a. \u8bbe\u7f6eSCAUSE
b. \u5411\u91cf\u5f0f\u4e2d\u65ad | vectored interrupt
Privilege
- RISCV\u4e2d\uff0c\u7531\u786c\u4ef6\u90e8\u5206\u5b9e\u73b0\u5bf9\u591a\u4e2a\u5f02\u5e38\u7684\u4f18\u5148\u7ea7\u6392\u5e8f
\u4e86\u89e3 \u53ef\u4ee5\u770b\u9a6c\u5fb7\u8001\u5e08\u667a\u4e91
- \u6a21\u5f0f
- \u4e0e\u6a21\u5f0f\u76f8\u5173
- \u7528\u6237\u6a21\u5f0f(User Mode)
- \u673a\u5668\u6a21\u5f0f(Machine Mode)
- \u76d1\u7763\u6a21\u5f0f(Supervisor Mode)
- \u539f\u5b50\u64cd\u4f5c
- \u4e00\u51714096\u4e2aCSR\u5bc4\u5b58\u5668
Instruction
"},{"location":"CS/CO/4_Processor/#multiple","title":"Multiple","text":"
- \u5f02\u5e38\u63a7\u5236\u7a0b\u5e8f
"},{"location":"CS/CO/4_Processor/#pipline-itp","title":"Pipline | ITP","text":""},{"location":"CS/CO/4_Processor/#problem","title":"Problem","text":""},{"location":"CS/CO/4_Processor/#excution-diagram","title":"Excution Diagram\u7684\u753b\u6cd5","text":"Answer"},{"location":"CS/CO/5_/","title":"Speed and Size","text":"
precise
\u6309\u7167\u5f02\u5e38\u7684\u5148\u540e\u5b9e\u73b0imprecise
SEPC\u4fdd\u5b58\u7684\u5730\u5740\u4e0d\u4e00\u5b9a\u662f\u53d1\u751f\u4f8b\u5916/\u5f02\u5e38\u65f6\u7684\u5730\u5740
- Let the handler work out
- Simplifies hardware, but more complex handler software
- Not feasible for complex multiple-issue out-of-order pipelines \u5bf9\u4e8e\u65e0\u5e8f\u7684\u6d41\u6c34\u7ebf\u4e0d\u9002\u7528
\u7ea6 2625 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 13 \u5206\u949f
\u5904\u7406\u5668\u901f\u5ea6 <= \u9ad8\u5ea6\u76f8\u5173 => \u5bc4\u5b58\u5668\u901f\u5ea6
"},{"location":"CS/CO/5_/#memory-technology","title":"Memory Technology","text":""},{"location":"CS/CO/5_/#sram","title":"SRAM","text":""},{"location":"CS/CO/5_/#dram","title":"DRAM","text":"
- value is stored on a pair of inverting gates \u4e24\u4e2a\u53cd\u76f8\u5668
- very fast but takes up more space than DRAM
- Value is stored as a charge on capacitor \u7535\u5bb9\u5668
- Very small but slower than SRAM (factor of 5 to 10)
- Must periodically be refreshed \u5fc5\u987b\u5b9a\u671f\u5237\u65b0
- Read contents and write back (destructive read) \u7834\u574f\u6027\u8bfb\u53d6
Bits in a DRAM are organized as a rectangular array
DRAM accesses an entire row
Burst mode: supply successive words from a row with reduced latency (SDRAM)
\u4ece\u4e00\u884c\u4e2d\u8fde\u7eed\u8bfb\u53d6\u6bd4\u8f83\u5feb
\u6570\u5b57\u903b\u8f91
\u9ad8\u901f\u7684\u53e3\u4e00\u822c\u662f\u4e32\u884c\u7684\uff0c\u63a5\u53e3\u5f88\u5c11 <== \u4fdd\u8bc1\u591a\u6761\u7ebf\u540c\u65f6\u5230\u8fbe\u76ee\u6807
"},{"location":"CS/CO/5_/#flash","title":"Flash","text":"Nonvolatile semiconductor storage \u975e\u6613\u5931\u534a\u5bfc\u4f53
\u53ea\u80fd\u4ece1\u5199\u52300\uff0c\u64e6\u9664\u4ee3\u4ef7\u5927
"},{"location":"CS/CO/5_/#disk","title":"Disk","text":"
- NOR flash: bit cell like a NOR gate
- Random read/write access
- Used for instruction memory in embedded systems
- NAND flash: bit cell like a NAND gate
- Denser (bits/area), but block-at-a-time access
- Cheaper per GB
- Used for USB keys, media storage, \u2026
- Flash bits wears out after 1000\u2019s of accesses
- Not suitable for direct RAM or disk replacement
- Wear leveling: remap data to less used blocks
\u8bbf\u95ee\u65f6\u95f4\u7684\u8ba1\u7b97\uff1a
"},{"location":"CS/CO/5_/#memory-hierarchy-introduction","title":"Memory Hierarchy Introduction","text":"
- \u6bcf\u6b21\u8bfb\u53d6\u4e00\u4e2asector\u6247\u533a\u7684\u6570\u636e
locality
- Temporal locality \u65f6\u95f4\u5c40\u90e8\u6027
- Items accessed recently are likely to be accessed again soon
- e.g., instructions in a loop, induction variables
Spatial locality \u7a7a\u95f4\u5c40\u90e8\u6027
- Items near those accessed recently are likely to be accessed soon
- E.g., sequential instruction access, array data
Copy recently accessed (and nearby) items from disk to smaller DRAM memory Main memory \u4e3b\u5b58
Copy more recently accessed (and nearby) items from DRAM to smaller SRAM memory Cache memory attached to CPU \u7f13\u51b2
\u200b cache \u5728CPU\u5185\u90e8
\u6982\u5ff5
"},{"location":"CS/CO/5_/#the-basic-of-cache","title":"The basic of Cache","text":"
Block
: unit of copying \u642c\u8fd0\u7684\u6700\u5c0f\u5355\u4f4d \u53ef\u80fd\u662f\u4e00\u4e2aword\u6216\u8005\u591a\u4e2aword
Hit
: If accessed data is present in upper level \u4e24\u5c42\uff1a\u4ece\u786c\u76d8\u5230\u5185\u5b58\uff0c\u4ece\u5185\u5b58\u5230cache
Hit Time
: The time to access the upper level of the memory hierarchy, which includes the time needed to determine whether the access is a hit or a miss.
Hit ratio
: hits/accesses
Miss
: block copied from lower level
Miss ratio
: misses/accesses = 1 \u2013 hit ratioMiss penalty
: The time to replace a block in the upper level with the corresponding block from the lower level, plus the time to deliver this block to the processor. \u628a\u6570\u636e\u4ece\u5e95\u5c42\u62ff\u5230\u9ad8\u5c42\uff0c\u4e4b\u540e\u518d\u4f20\u7ed9processorSRAM and DRAM (main memory)
"},{"location":"CS/CO/5_/#direct-mapped","title":"Direct mapped","text":"(Block address) modulo (Number of blocks in the cache)
\u56fa\u5b9a\u7684\u4f4d\u7f6e $\\text{(Block address) \\% (Number of blocks in the cache)} $
Tag \u533a\u5206\u5b58\u653e\u7684\u54ea\u4e2a\u6570\u636e
- Store block address as well as the data
- Actually, only need the high-order bits
Valid Bits \u8fd9\u4e2aBlock\u662f\u5426\u4e3a\u7a7a
Valid bit: 1 = present, 0 = not present \u6700\u521d\u8bbe\u7f6e\u4e3a0
Cache Block Address
example\u7406\u89e3cache\u4e2d\u7684\u5404\u4e2a\u4f4d
\u4e0a\u9762\u7684\u90e8\u5206\u662f Memory address\uff08Tag + Index)\uff0c\u4e0b\u9762\u7684\u624d\u662fcache\u4e2d\u7684(\u8fd9\u91ccCache Address\u5c31\u662f\u5b83\u7684\u7d22\u5f15Index)\u3002\u8fd9\u91cc\u6bcf\u4e00\u4e2aBlock\u6709\u56db\u4e2aword\uff0c\u9700\u8981\u4e24\u4f4d\u6765\u5b9a\u4f4dword\uff0c\u6bcf\u4e2aword\u6709\u56db\u4e2a\u5b57\u8282\uff0c\u9700\u8981\u4e24\u4f4d\u6765\u5b9a\u4f4dbyte\uff0c\u6545\u800c
Byte offset = 4
index
\u5728cache\u4e2d\u5bfb\u627eblock\uff0c\u5176\u5927\u5c0f\u7531cache size\u51b3\u5b9a
Offset
\u7528\u4e8e\u53bb\u5728data\u4e2d\u5bfb\u5740\u3002\u6ce8\u610f\u5bfb\u5740\u65b9\u5f0f\uff0c\u4e00\u822c\u662f\u5b57\u8282\u5bfb\u5740\uff0c\u4f46\u662f\u5f88\u591a\u9898\u76ee\u4f1a\u662fword\u5bfb\u5740\uff0c\u540c\u65f6\u4e5f\u770b\u6e05\u695a\u7ed9\u7684\u5730\u5740\u662f\u4ee5\u5b57\u8282\u5740\u8fd8\u662fWord\u3002\u6bd4\u5982\uff0c\u4e00\u4e2a 4-word blocks\uff0c\u5c31\u9700\u8981 index \u5148\u53bb\u5bfb\u627eblock\uff0c\u518d\u7531offset\u5206\u522b\u786e\u5b9aword\u548cbyte\uff0c\u6545\u9700\u89814bit\u4e00\u4e2acache slot\u5b9e\u9645\u7684size\u662f data size of a block + Tag + Valid\uff0c\u4f46\u662f\u63d0\u53ca\u67d0\u4e2acache\u5927\u5c0f\u65f6\uff0c\u90fd\u662f\u53ea\u8ba1\u7b97Data\u90e8\u5206
Tag
\u7531 memory address \u51cf\u53bb Index\u3001Byte Offset\u8ba1\u7b97
Total cache size
: Block num(2^n) * (data size + tag size + valid bit)\u8ba1\u7b97
cache\u7684\u547d\u540d\u4e0d\u8003\u8651\u6807\u7b7e\u548c\u6709\u6548\u4f4d\u7684\u5927\u5c0f\uff0c\u53ea\u8003\u8651\u6570\u636e\u7684\u5927\u5c0f
example
Handling Cache reads hit and Misses
detail
Read
Read Miss \u6682\u505c\u5904\u7406\u5668\uff0c\u76f4\u5230\u4ece\u5185\u5b58\u4e2d\u8fd4\u56de\u6570\u636e
instruction cache miss
data cache miss
1. Send the original PC value (current PC-4) to the memory.
2. Instruct main memory to perform a read and wait for the memory to complete its access. (in multiple cycles)
3. Write the cache entry, putting the data from memory in the data portion of the entry, writing the upper bits of the address (from the ALU) into the tag field, and turning the valid bit on.
4. Restart the instruction execution at the first step, which will refetch the instruction again, this time finding it in the cache.
"},{"location":"CS/CO/5_/#deep-concept","title":"Deep Concept","text":"
Write hits
\u4e0d\u540c\u7684\u5199\u7b56\u7565 \u8be6\u7ec6\u5185\u5bb9\u89c1\u540e
write-back: Cause Inconsistent Wrote the data into only the data cache
write-through: Ensuring Consistent
Write Miss
\u5f15\u5165
1-word block
"},{"location":"CS/CO/5_/#block-placement","title":"Block Placement","text":""},{"location":"CS/CO/5_/#fully-associative","title":"Fully Associative","text":"Block can go anywhere in cache
"},{"location":"CS/CO/5_/#set-associative","title":"Set Associative","text":"Block can go in one of a set of places in the cache.
A set is a group of blocks in the cache.
Block address MOD Number of sets in the cache \u4e5f\u5c31\u662f\u9488\u5bf9\u4e0a\u9762\u7684index\u5728\u8fd9\u91cc\u4f1a\u662fset index
If sets have n blocks, the cache is said to be n-way set associative. \u00a0\u6ce8\u610f\u8fd9\u91cc\u662f\u4e00\u4e2a\u7ec4\u6709n\u4e2aBlock\u5219\u79f0\u4e4b\u4e3aN-way set\u800c\u975e n \u4e2aset
"},{"location":"CS/CO/5_/#block-identification","title":"Block identification","text":"\u57fa\u672c\u76f8\u540c
"},{"location":"CS/CO/5_/#block-replacement","title":"Block replacement","text":"
Random replacement
- randomly pick any block
Least-recently used (LRU)
- pick the block in the set which was least recently accessed
Assumed more recently accessed blocks more likely to be referenced again
This requires extra bits in the cache to keep track of accesses.
"},{"location":"CS/CO/5_/#write-strategy","title":"Write Strategy","text":"
First in,first out(FIFO)
- Choose a block from the set which was first came into the cache
write hit
- If the data are written to memory, the cache is called a write-through cache
- Can always discard cached data - most up-to-date data is in memory \u5728Disk\u4e2d\u603b\u662f\u6700\u65b0\u7684\u6570\u636e
- Cache control bit: only a valid bit
- memory (or other processors) always have latest data
- \u8bfb\u53d6miss\u4e0d\u4f1a\u5f71\u54cdwrite
- If the data are NOT written to memory, the cache is called a write-back cache
- dirty page \u5b58\u5728,\u4e0d\u80fd\u76f4\u63a5discard
- Cache control bits: both valid and dirty bits \u591a\u4e86Dirty bit
- much lower bandwidth, since data often overwritten multiple times
\u8fd9\u4e24\u79cd\u7b56\u7565\uff0c\u90fd\u4f1a\u4f7f\u7528Buffer\u3002 Write-Through \u4f7f\u7528Buffer\u662f\u4e3a\u4e86\u964d\u4f4e\u4e0d\u65ad\u5199\u56de\u4e0b\u4e00\u5c42\u7684cost\uff0c\u4f7f\u7528\u7684\u662f\u4e0b\u9762\u7684 Write Buffer\uff0c\u6570\u636e\u5199\u5165Cache\u7684\u540c\u65f6\uff0c\u4e5f\u5199\u5165buffer Write-Back \u4e5f\u6709\u5199\u7f13\u51b2\uff0cBuffer
Write stall
When the CPU must wait for writes to complete during write through
Write buffers
- A small cache that can hold a few values waiting to go to main memory.
- This buffer helps when writes are clustered.
- \u5982\u679c\u4e00\u6b21\u5199\u5165\u7684\u91cf\u5f88\u5927\uff0c\u5f88\u53ef\u80fd\u8d85\u8fc7buffer\u7684\u5bb9\u91cf
- \u589e\u52a0\u4e86\u6570\u636e\u8bbf\u95ee\u7684\u590d\u6742\u5ea6\uff0c\u9700\u8981\u68c0\u6d4b\u6570\u636e\u662f\u5426\u5728write buffer\u4e2d\uff0c\u5426\u5219\u5e76\u884c\u7684IC\u6570\u636e\u8bbf\u95ee\u8bfb\u53d6\u7684\u662f\u65e7\u6570\u636e
Write miss
\u770b\u662f\u5426\u5199\u56de\u5230cache\u4e2d\u53bb
- **Write allocate **
The block is loaded into the cache on a miss before anything else occurs.
"},{"location":"CS/CO/5_/#designing-the-memory-system-to-support-cache","title":"Designing the Memory system to Support Cache","text":"
**Write around (no write allocate) **
- The block is only written to main memory
- It is not stored in the cache.
In general, write-back caches use write-allocate , and write-through caches use write-around.
\u5bf9\u4e3b\u5b58\u7684\u52a0\u901f\u3002\u5355\u7eaf\u7684One-word-wide\u67b6\u6784\uff0c\u7531\u4e8e\u5bf9DRAM\u53d6\u6570\u636e\u5f88\u8017\u65f6\uff0c\u4f1a\u9020\u6210\u5f88\u591a\u65f6\u95f4\u6d6a\u8d39
\u6982\u5ff5
Bandwidth
\u5e26\u5bbd\uff0c\u662f\u4e00\u4e2a\u65f6\u949f\u5468\u671f\u80fd\u8bbf\u95ee\u7684Bytes\u6570\u76ee \\(Bandwidth = \\frac{Bytes}{CLK}\\)
miss penalty
\u79fb\u52a8\u4e00\u4e2aBlock\u7684\u4ee3\u4ef7example
\u589e\u5927 Memory \u4f4d\u5bbd
\u5982\u679c\u4f4d\u5bbd\u589e\u52a0\uff0c\u5355\u4f4d\u65f6\u95f4\u5185\u4f20\u8f93\u7684Block\u6570\u76ee\u589e\u52a0
\u589e\u52a0Memory\u6570\u91cf\uff08\u7c7b\u4f3c\u5e76\u884c
4 banks Interleaved Memory
\u4f46\u662fbus\u7684\u4f4d\u5bbd\u6ca1\u6709\u53d8\u5316\uff0c\u5bfc\u81f4\u901a\u8fc7bus\u4f20\u8f93\u6570\u636e\u9700\u8981\u7b49\u5f85
"},{"location":"CS/CO/5_/#measuring-and-improving-cache-performance","title":"Measuring and improving cache performance","text":"The main contents are the following:
\\[ \\text{Average Memory Assess Time (AMAT) = hit time + miss time}\\\\ \\text{= hit rate \u00d7 Cache time + miss rate \u00d7memory time} \\]"},{"location":"CS/CO/5_/#measuring","title":"Measuring","text":"
Measuring cache performance
Reducing cache misses by more flexible placement of blocks
Reducing the miss penalty using multilevel caches
\u6211\u4eec\u4f7f\u7528CPU Time\u6765\u8861\u91cf how good it works $$ {CPU Time} = \\text{CPI * I * CPU cycle time} \\ =\\text{CPU Excution Time} + \\text{CPU Memory-stall Time} $$
\\[ \\text{CPU Memory-Stall Time} = \\text{Read-stall+Write-stall}\\\\ = \\#of\\ instructions\\text{ * miss ratio * miss penalty} \\]For Read
\\(\\text{Read-stall} = \\frac{Read}{Program}*\\text{Read miss rate * Read miss penalty}\\)
For Write
\\(Write-stall = \\frac{Write}{Program}*\\text{Write miss rate * Write miss penalty} + Write Buffer\\)
If the write buffer stalls are small, we can safely ignore them .
If the cache block size is one word, the write miss penalty is 0.
- \u901a\u5e38\u60c5\u51b5\u4e0b\u90fd\u53ef\u4ee5\u5ffd\u7565 <== \u8bbe\u8ba1\u7684\u8f83\u597d\u7684CPU\u4e00\u822c\u4e0d\u4f1a\u6ee1
\u4e00\u5b9a\u8981\u6ce8\u610fWrite\u7684\u7c7b\u578b\uff0c\u9488\u5bf9write hit
Write-through Write-back
\u8fd8\u6709miss\u7684\u5e94\u5bf9
Write-allocate Write-around
\u8ba1\u7b97
"},{"location":"CS/CO/5_/#improving","title":"Improving","text":"
- Miss
- Instruction miss
- Data miss
"},{"location":"CS/CO/5_/#block-placement_1","title":"\u6620\u5c04 Block Placement","text":"
- \u63d0\u9ad8\u547d\u4e2d\u7387
- \u51cf\u5c11 miss \u4ee3\u4ef7
Tag\u8ba1\u7b97
- \u76f8\u8054\u5ea6\u548c\u5bb9\u91cf\u4e0d\u662f\u76f8\u4e92\u72ec\u7acb\u7684
\u4e3b\u5b58\u4e2d\u7684Block Address = Index + Tag
\u524d\u9762\u5df2\u7ecf\u5199\u7684\u6bd4\u8f83\u8be6\u7ec6\u4e86
"},{"location":"CS/CO/5_/#decreasing-miss-penalty-with-multilevel-caches","title":"Decreasing miss penalty with multilevel caches","text":"Add a second level cache:
often primary cache is on the same chip as the processor \u4e00\u7ea7\u7f13\u5b58\u5728\u5904\u7406\u5668\u7684\u82af\u7247\u4e0a
use SRAMs to add another cache above primary memory (DRAM)
miss penalty goes down if data is in 2nd level cache
\u4e00\u7ea7\u548c\u4e8c\u7ea7\u7684cache\u5173\u6ce8\u7684\u76ee\u6807\u4e0d\u540c\uff1a
- \u4e00\u7ea7 hit time\uff0c\u964d\u4f4e\u5931\u6548\u4ee3\u4ef7
- \u4e8c\u7ea7 miss rate \u76f8\u8054\u5ea6\u66f4\u9ad8
\u5982\u679c\u7b2c\u4e00\u7ea7\u7684cache\u5931\u6548\uff0c\u5c31\u4f1a\u8bbf\u95ee\u7b2c\u4e8c\u7ea7\u7684cache\uff0c\u5982\u679c\u6210\u529f\uff0c\u90a3\u4e48\u7b2c\u4e00\u7ea7\u7684penalty\u5c31\u662f\u7b2c\u4e8c\u7ea7\u7684\u8bbf\u95ee\u65f6\u95f4\uff1b... (\u8fd9\u91cc\u6709\u70b9\u7591\u95ee)
\u4f8b\u9898
- Main Memory \u7684\u5931\u6548\u4ee3\u4ef7\uff1a\u8bbf\u95eeMain Memory \u7684\u65f6\u95f4
- \u603bCPI = \u57fa\u51c6CPI + \u5404\u7ea7\u4ee3\u4ef7 \u6ce8\u610f\u8ba1\u7b97\u7684\u662f\u4ec0\u4e48\u5355\u4f4d
Local/Global miss rate
\u5b9e\u9645\u505a\u9898\u7684\u65f6\u5019,\u6709\u65f6\u5019\u7b97L2-cache\u5931\u6548\u7684CPI\u9700\u8981\u5728\u7b2c\u4e00\u7ea7\u5931\u6548\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u8ba1\u7b97,\u90a3\u65f6\u5019\u7b2c\u4e8c\u7ea7\u7684miss rate\u5b9e\u9645\u4e0a\u5c31\u662flocal miss rate
"},{"location":"CS/CO/5_/#virtual-memory","title":"Virtual Memory","text":"Main Memory act as a \u201cCache\u201d for the secondary storage.
Translation of a program\u2019s address space to physical address
Motivation:
Efficient and safe sharing of memory among multiple programs.\uff08\u591a\u4e2aVa\u6620\u5c04\u5230\u540c\u4e00\u4e2aPa\uff09
Remove the programming burdens of a small, limited amount of main memory.
Larger number of virtual pages than physical pages \u73b0\u5982\u4eca\u4e0d\u518d\u662f\u8fd9\u6837
"},{"location":"CS/CO/5_/#page-faults","title":"Page faults | \u7f3a\u9875","text":"
- \u4e2a\u4eba\u8bbe\u5907\u4e2d\uff0c\u901a\u5e38\u662fDRAM\u548c\u95ea\u5b58\u5145\u5f53\u4e24\u7ea7\u5b58\u50a8\u5c42\u6b21\u7ed3\u6784
- illusion of having more physical memory
- program relocation
- protection
The data is not in memory, retrieve it from disk
"},{"location":"CS/CO/5_/#page-table","title":"Page Table | \u9875\u8868","text":"
- huge miss penalty, thus pages should be fairly large (e.g., 4KB)
- reducing page faults is important (LRU is worth the price)
- can handle the faults in software instead of hardware \u901a\u8fc7\u8f6f\u4ef6\u89e3\u51b3\u7f3a\u9875\u95ee\u9898 Cache\u662f\u786c\u4ef6
- using write-through is too expensive so we use write back \u540c\u65f6\u5199\u5230\u786c\u76d8\u548c\u4e3b\u5b58\u4ee3\u4ef7\u592a\u5927
Page Table \u5305\u542b\u4e86\u6240\u6709\u7684\u5bf9\u5e94\u5173\u7cfb,\u4e0d\u9700\u8981Tag
- Page offset \u8ba1\u7b97\uff1a\u7531\u6574\u4e2aPage size\u51b3\u5b9a\uff0c = log(Page Size)
\u9875\u8868\u6307\u9488 Page Table Register
- \u5728Memory\u4e2d\u5b58\u50a8 indexed by the virtual page number
- Each Entry in the table contains the physical page number for that virtual pages if the page is current in memory, \u5373\u4f7f\u4e0d\u5728Main Memory\u4e2d,\u4e5f\u4f1a\u4fdd\u7559\u4e00\u4e2a\u7269\u7406\u5730\u5740(In Disk)
- Page table, Program counter and the page table register, specifies the state of the program. Each process has one page table. \u5982\u679c\u8f6c\u6362\u8fdb\u7a0b\uff0c\u8981\u4fdd\u5b58\u5f53\u524d\u8fdb\u7a0b\u7684\u72b6\u6001 \u5305\u62ec \u9875\u8868\u3001\u7a0b\u5e8f\u8ba1\u6570\u5668\u3001\u5bc4\u5b58\u5668
- \u64cd\u4f5c\u7cfb\u7edf\u53ea\u5206\u914d\u7269\u7406\u5185\u5b58\u5730\u5740\uff0c\u4e0d\u4fdd\u5b58\u9875\u8868\u3002
- Each program has its own page table \u6bcf\u4e00\u4e2a\u8fdb\u7a0b\u6709\u81ea\u5df1\u7684\u9875\u8868\u3002
Size
- Virtual Address - Page Offset = #bits(Virtual Page Number)
\u64cd\u4f5c\u7cfb\u7edf OS
- When the OS creates a process, it usually creates the space on disk for all the pages of a process.
- When a page fault occurs, the OS will be given control through exception mechanism.
- The OS will find the page in the disk by the page table.
- the OS will bring the requested page into main memory. If all the pages in main memory are in use, the OS will use LRU strategy to choose a page to replace
Virtual Address
virtual page number
Page offset
Write
"},{"location":"CS/CO/5_/#tlb","title":"TLB","text":"
use write-back strategy. To do so, the machines need add a dirty bit to the entry of page table.
The dirty bit is set when a page is first written. If the dirty bit of a page is set, the page must be written back to disk before being replaced.
\u76f8\u5f53\u4e8ePage Table\u7684\u4e00\u4e2acache
- Without a TLB, almost every memory access would require two accesses to RAM: An access to the page table, followed by an access to the requested data.
\u4f7f\u7528Page Table\u4e2d\u7684Valid\u6807\u8bb0\u662f\u5426\u5728\u4e3b\u5b58\u4e2d
TLB\u4e00\u822c\u91c7\u7528\u5168\u76f8\u8054
- \u786c\u4ef6/\u8f6f\u4ef6\u5904\u7406\u5931\u6548\uff0c\u5927\u591a\u6570MIPS\u4f7f\u7528\u8f6f\u4ef6
Combination of Miss
"},{"location":"CS/CO/5_/#_1","title":"\u4f8b\u9898","text":"Note
\u5927\u90e8\u5206\u5730\u5740\u90fd\u662f\u4ece00\u5f00\u59cb\u7684\uff0c\u522b\u5fd8\u4e860\u7684\u5730\u5740\u3002
"},{"location":"CS/CO/5_/#write-back-through","title":"Write back / through\u6982\u5ff5","text":"
- \u8ba1\u7b97
- cache
- cache\u7684size
- \u591a\u91cdcache\u7684performance measure
- Virtual Memory
- Page Table\u3001TLB \u662f\u5982\u4f55work\u7684\uff0c\u53ef\u80fd\u8981\u7ed9\u51fa\u6d41\u7a0b
- Page Table \u7684size
Answer
- If all blocks in the higher level cache are also present in the lower level cache, then the lower level cache is said to be inclusive of the higher level cache.
- If the lower level cache contains only blocks that are not present in the higher level cache, then the lower level cache is said to be exclusive of the higher level cache.
5.6.2 And the result written to L2, may update it in L2, and then tag it dirty. 5.6.3
"},{"location":"CS/CO/5_/#cache","title":"Cache \u8ba1\u7b97","text":""},{"location":"CS/CO/5_/#tlb_1","title":"TLB","text":"
instruction access, data access
\\(\\text{Total CPI = Base + Instruction miss + Data miss}\\)"},{"location":"CS/CO/5_/#_2","title":"\u66ff\u6362\u7b56\u7565","text":"
- TLB \u4e2d\u7684 Tag \u3001Index\uff08\u5f53\u7ec4\u76f8\u8054\uff09
two-way set associative cache with four one-word blocks
\u4e24\u7ec4
\u6bcf\u7ec4\u4e24\u4e2ablock
"},{"location":"CS/CO/5_/#408","title":"408","text":""},{"location":"CS/CO/6/","title":"IO","text":"
- Page size 4KB => Page Offset = 12
- Virtual Size 4GB = > virtual address 32 bits
- Virtual Page Number 20 bits
- \u6ce8\u610f\u8fdb\u5236
\u7ea6 163 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CS/CO/6/#introduction","title":"Introduction","text":"
- Behavior \u884c\u4e3a
Input (read once), output (write only, cannot read) ,or storage (can be reread and usually rewritten)
- Partner \u4ea4\u4e92\u5bf9\u8c61
Either a human or a machine is at the other end of the I/O device, either feeding data on input or reading data on output. \u4e00\u7aef\u4e00\u5b9a\u662fCPU <= \u6570\u636e\u5fc5\u987b\u4f20\u5230CPU\u5904\u7406
- Data rate
The peak rate at which data can be transferred between the I/O device and the main memory or processor.
"},{"location":"CS/CO/6/#performance","title":"Performance","text":""},{"location":"CS/CO/6/#amdahls-law","title":"Amdahl\u2019s (\u963f\u59c6\u8fbe\u5c14)law","text":""},{"location":"CS/CO/6/#disk-storage-and-dependability","title":"Disk Storage and Dependability","text":""},{"location":"CS/CO/6/#performance_1","title":"Performance","text":""},{"location":"CS/CO/6/#raid","title":"RAID","text":""},{"location":"CS/CO/6/#-survive","title":"- \u53ea\u6709\u6700\u540e\u4e00\u4e2a\u53ef\u4ee5\u5728\u4e24\u4e2a\u9519\u8bef\u53d1\u751f\u7684\u60c5\u51b5\u4e0bsurvive","text":""},{"location":"CS/CO/6/#buses-and-other-connections-between-processors-memory-and-io-devices","title":"Buses and Other Connections between Processors Memory, and I/O Devices","text":""},{"location":"CS/CO/6/#_1","title":"\u8ba1\u7b97","text":"
- Capacity penalty to store redundant info
- Bandwidth penalty to update redundant info
\u540c\u6b65\u5f02\u6b65\u7684BandWidth
"},{"location":"CS/DB/","title":"Index","text":"
- \u5730\u5740\u7ed9Memory
- \u8bfb\u53d6\u6570\u636e
- \u4f20\u8f93\u6570\u636e
\u7ea6 0 \u4e2a\u5b57
"},{"location":"CS/DB/Chapter_1/","title":"1. Interface","text":"\u7ea6 140 \u4e2a\u5b57 30 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
flowchart LR\n0{\u6982\u8ff0}\n0-->1\n1[View Of Data]-->2[Data Abstraction]\n\n\n1-->b[Data Models]\n\n0-->0.1[Schema and instances \u6a21\u5f0f\u4e0e\u5b9e\u4f8b]\n0.1-->\u533a\u5206\n0.1-->0.1.1[Physical Data Independence]\n0-->1.2[Language]\n1.2-->1.2.1[DDL:Data Difinition Language]\n1.2-->1.2.2[DML:Data Manipulation Language]\n1.2.2-->\u58f0\u660e\u5f0f:SQL\n1.2.2-->\u8fc7\u7a0b\u5f0f\n\n0-->4[Database Design]\n4-->4.1[E-R\u6a21\u578b \u5b9e\u4f53-\u8054\u7cfb\u6a21\u578b]\n4-->4.2[\u89c4\u8303\u5316]\n\n0-->3[Database Engine]\n3-->1.8\n3-->3.2[Storage Manager]\n3-->3.3[The Query Processor]\n3.3-->3.3.1[DDL interpreter]\n3.3-->3.3.2[DML compiler]\n3.3-->3.3.3[Query evaluation engine]\n1.8[\u4e8b\u52a1\u7ba1\u7406\u5668]-->1.8.1[\u5e76\u53d1\u63a7\u5236\u7ba1\u7406\u5668]\n1.8-->1.8.2[\u6062\u590d\u7ba1\u7406\u5668]
- Database Management System (DBMS)
A database system is a collection of interrelated data and a set of programs that allow users to access and modify these data.
Characteristics of Databases
\u200b data persistence (\u6570\u636e\u6301\u4e45\u6027)
\u200b convenience in accessing data (\u6570\u636e\u8bbf\u95ee\u4fbf\u5229\u6027)
\u200b data integrity (\u6570\u636e\u5b8c\u6574\u6027)
\u200b concurrency control for multiple user (\u591a\u7528\u6237\u5e76\u53d1\u63a7\u5236)
\u200b failure recovery (\u6545\u969c\u6062\u590d)
\u200b security control (\u5b89\u5168\u63a7\u5236)
file system\u7684\u95ee\u9898
"},{"location":"CS/DB/Chapter_1/#view-of-data","title":"View Of data","text":""},{"location":"CS/DB/Chapter_1/#language","title":"Language","text":""},{"location":"CS/DB/Chapter_1/#ddl","title":"DDL","text":"Data dictionary contains metadata
"},{"location":"CS/DB/Chapter_1/#dml","title":"DML","text":"
- \u6570\u636e\u6a21\u5f0f
- \u5b8c\u6574\u6027\u7ea6\u675f
- \u6388\u6743
SQL
A query takes as input several tables (possibly only one) and always returns a single table.
SQL does not support actions such as input from users, output to
displays, or communication over the network.
"},{"location":"CS/DB/Chapter_12/","title":"Physical Storage","text":"\u7ea6 212 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CS/DB/Chapter_12/#overview","title":"Overview","text":"- \u4e09\u7ea7\u5b58\u50a8 offline storage - optical disk \u5149\u5b66\u5b58\u50a8\u5668 CD - tape disk \u78c1\u5e26 \u8bbf\u95ee\u5fc5\u987b\u4ece\u5934\u5f00\u59cb\uff0c\u987a\u5e8f\u8bbf\u95ee
"},{"location":"CS/DB/Chapter_12/#flash-memory","title":"Flash Memory | \u95ea\u5b58","text":"NOR\u5feb\u95ea
\u53ef\u4ee5\u8bbf\u95ee\u5355\u4e2a\u5b57
\u901f\u5ea6\u53ef\u4ee5\u4e0e\u4e3b\u5b58\u5ab2\u7f8e
NAND\u5feb\u95ea SSD
Reading from NAND flash requires an entire page of data, which is very commonly 4096 bytes, to be fetched from NAND flash into main memory.
\u66f4\u7ecf\u5e38\u7528\u7684
\u95ea\u5b58\u7279\u70b9
"},{"location":"CS/DB/Chapter_12/#magnetic-disk","title":"Magnetic Disk","text":"
- \u5199\u64cd\u4f5c\u6bd4\u8f83\u590d\u6742\uff0c\u4e00\u65e6\u5b8c\u6210\u5199\u64cd\u4f5c\uff0c\u60f3\u8981\u590d\u5199\u5fc5\u987b\u64e6\u9664\u4e4b\u540e\u518d\u5199
- The erase operation must be performed on a group of pages, called an erase block
- \u5bb9\u6613\u635f\u574f Further, there is a limit to how many times a flash page can be erased, typically around 100,000 to 1,000,000 times. Once this limit is reached, errors in storing bits are likely to occur.
- \u901a\u8fc7\u673a\u68b0\u8fd0\u52a8\uff0c\u6bd4\u8f83\u6162
- \u6247\u533a\u662f\u6700\u5c0f\u7684\u8bfb\u5199\u5355\u5143
"},{"location":"CS/DB/Chapter_12/#performance","title":"Performance","text":""},{"location":"CS/DB/Chapter_12/#optimization","title":"Optimization","text":""},{"location":"CS/DB/Chapter_13/","title":"Data Storage Structures","text":"
- \u4e0a\u9762\u7684IOPS\u652f\u6301\u7684\u64cd\u4f5c\u662fRandom\u7684R/W
\u7ea6 932 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"CS/DB/Chapter_13/#file-organization","title":"File Organization","text":"Magnetic disks as well as SSDs are block structured devices, that is, data are read or written in units of a block(\u6570\u636e\u4f20\u8f93\u548c\u5b58\u50a8\u5206\u914d\u7684\u57fa\u672c\u5355\u5143\uff0c\u901a\u5e38\u662f4-8KB). In contrast, databases deal with records, which are usually much smaller than a block (although in some cases records may have attributes that are very large).
"},{"location":"CS/DB/Chapter_13/#fixed-length-records","title":"Fixed Length Records","text":"
- The database is stored as a collection of files.
- Each file is a sequence of records.
- A record is a sequence of fields.
- use freelist
"},{"location":"CS/DB/Chapter_13/#variable-length","title":"Variable Length","text":"\u8981\u89e3\u51b3\u7684\u95ee\u9898
- \u5982\u4f55\u8868\u793a\u4e00\u4e2a\u53d8\u957f\u7684\u5c5e\u6027\uff1f\u5e76\u4e14\u80fd\u591f\u8f7b\u6613\u5730\u83b7\u53d6\uff1f
- \u5982\u4f55\u5728Block\u4e2d\u5b58\u50a8\u53d8\u957f\u7684record\uff1f
- id name dept_name salary(fixed length) - \u5728\u90e8\u5206\u8868\u793a\u65b9\u6cd5\u4e2d\uff0cNull Bitmap\u653e\u5728\u6570\u636e\u5f00\u5934\uff0c\u5e76\u4e14\u53ea\u8981\u7f6e\u4e3a1\u5176\u6570\u636e\u90e8\u5206\u5c31\u4e3a\u7a7a
Slotted page \uff08\u5206\u69fd\u9875\uff09
"},{"location":"CS/DB/Chapter_13/#organization-of-records-in-files","title":"Organization of Records in Files","text":""},{"location":"CS/DB/Chapter_13/#heap","title":"Heap","text":"
- Records usually do not move once allocated
- Important to be able to efficiently find free space within file
Free-space map (\u81ea\u7531\u7a7a\u95f4\u56fe)
"},{"location":"CS/DB/Chapter_13/#sequential-file-organization","title":"Sequential File Organization","text":"
- Free space map written to disk periodically, OK to have wrong (old) values for some entries (will be detected and fixed
"},{"location":"CS/DB/Chapter_13/#multitable-clustering-file-organization","title":"Multitable Clustering File Organization","text":"
- Search key \u6392\u5e8f\u7684\u4f9d\u636e\u3002\u53ef\u4ee5\u662f\u67d0\u4e2a\u5c5e\u6027\u6216\u8005\u5c5e\u6027\u7684\u96c6\u5408\uff0c\u662f\u5426\u662f\u8d85\u7801\u3001\u5019\u8865\u7801\u4e0d\u5f71\u54cd
- Deletion Using the pointer
- Insertion locate the position where the record is to be inserted
- if there is free space insert there(\u8fd9\u91cc\u662ffree_list\uff0c\u4f18\u5148\u8003\u8651free_list\u4e2d\u7684\u5757\uff0c\u5982\u679c\u5176\u4e2d\u6ca1\u6709\u7a7a\u4f59\uff0c\u90a3\u4e48\u518d\u53bboverflow block\u63d2\u5165)
- if no free space, insert the record in an overflow block (\u6ea2\u51fa\u5757)
In either case, pointer chain must be updated
Reorganize \u4f7f\u4e4b\u91cd\u65b0\u7269\u7406\u6709\u5e8f\u5b58\u50a8. \u7531\u4e8e\u4e0a\u9762\u7684\u6ea2\u51fa\u5757\u6a21\u5f0f\uff0c\u5bfc\u81f4\u7269\u7406\u5b58\u50a8\u4e0d\u4e00\u5b9a\u6309\u7167\u6307\u9488\u987a\u5e8f\uff0c\u8fdb\u800c\u964d\u4f4e\u8bbf\u95ee\u6548\u7387
- \u5bf9\u76f8\u540c\u7684\u4fe1\u606f\u805a\u7c7b\uff1b\u628a\u4e0d\u540c\u7684\u5173\u7cfb\u653e\u5728\u540c\u4e00\u4e2a\u8868\u4e2d
- Results in variable size records
- Can add pointer chains to link records of a particular relation
"},{"location":"CS/DB/Chapter_13/#partitioning","title":"Partitioning","text":""},{"location":"CS/DB/Chapter_13/#data-dictionary-storage","title":"Data Dictionary Storage","text":"
- \u628a\u4e00\u4e2adepartment\u7684instructor\u805a\u96c6\u5728\u4e00\u8d77
"},{"location":"CS/DB/Chapter_13/#buffer","title":"Buffer","text":"
- \u6709\u52a9\u4e8e\u8bed\u4e49\u68c0\u67e5
- \u4f7f\u7528
metadata
\u7684\u60f3\u6cd5
- Blocks are units of both storage allocation and data transfer \u5185\u5b58\u7533\u8bf7\u3001\u6570\u636e\u4f20\u8f93
- Buffer (\u7f13\u51b2\u533a) \u2013 portion of main memory available to store copies of disk blocks\uff0c\u4f46\u662f\u5728\u78c1\u76d8\u4e0a\u7684\u62f7\u8d1d\u53ef\u80fd\u65e7\u4e8e\u7f13\u51b2\u533a\u7684
- Buffer manager (\u7f13\u51b2\u533a\u7ba1\u7406\u5668) \u2013 subsystem responsible for allocating buffer space in main memory.
\u6d41\u7a0b
- System Call
- in the buffer Return
- not in the buffer
- buffer is full
- The replaced block is updated -> write back to disk
- not , deleted the replaced page, and replaced
- buffer is not full
- Read The Page and return
pinned Block
memory block that is not allowed to be written back to disk - Pin done before reading/writing data from a block \u5728\u7533\u8bf7\u6570\u636e/\u5199\u6570\u636e\u4e4b\u524d\u201cPin\u201d - Unpin done when read /write is complete - Multiple concurrent pin/unpin operations possible - Keep a pin count, buffer block can be evicted only if pin count = 0
Shared and exclusive locks on buffer | \u5171\u4eab\u9501\u548c\u6392\u4ed6\u9501
Needed to prevent concurrent operations from reading page contents as they are moved/reorganized, and to ensure only one move/reorganize at a time
"},{"location":"CS/DB/Chapter_13/#_1","title":"\u7f13\u51b2\u533a\u66ff\u6362\u7b56\u7565","text":""},{"location":"CS/DB/Chapter_13/#lru","title":"LRU","text":"
- \u5171\u4eab\u9501\u548c\u6392\u4ed6\u9501\u4e0d\u80fd\u5e76\u884c
- \u540c\u4e00\u65f6\u95f4\u6700\u591a\u4e00\u4e2a\u8fdb\u7a0b\u5177\u6709\u6392\u4ed6\u9501
\u4ecebuffer\u4e2d\u53bb\u6389\u6700\u8fd1\u6700\u5c11\u7528\u5230\u7684
example
\u5bf9\u4e8e\u8981\u201c\u6254\u6389\u201d\u7684\u6570\u636e\uff0c\u8981\u5224\u65ad\u662f\u5426\u5df2\u7ecf\u4fee\u6539\u8fc7\uff08buffer\u4e2d\u7684\u6570\u636e\u53ef\u80fd\u662f\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u4fee\u6539\u540e\u7684\u6570\u636e\uff09\u3002
\u200b
Clock: An approximation of LRU\u4ecb\u7ecd
"},{"location":"CS/DB/Chapter_13/#others","title":"others","text":"Toss-immdiate \u7acb\u5373\u4e22\u5f03
Most recently used (MRU) strategy
\u64cd\u4f5c\u7cfb\u7edf/\u7f13\u5b58\u7ba1\u7406\u5668\u53ef\u80fd\u4f1a\u5bf9\u5199\u64cd\u4f5c\u8fdb\u884c\u91cd\u65b0\u6392\u5e8f
Operating system or buffer manager may reorder writes
"},{"location":"CS/DB/Chapter_13/#_2","title":"\u65e5\u5fd7","text":""},{"location":"CS/DB/Chapter_13/#column-oriented-storage","title":"Column-Oriented Storage","text":"
- Can lead to corruption of data structures on disk
- E.g., linked list of blocks with missing block on disk
- File systems perform consistency check to detect such situations \u6216\u8005\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u4ecb\u7ecd\u7684\u65e5\u5fd7
Store each attribute of a relation separately
- \u6700\u7b80\u5355\u7684\u60c5\u51b5\u662f\u6bcf\u4e00\u79cd\u5c5e\u6027\u5206\u6587\u4ef6\u5b58\u653e Further, each file is compressed, to reduce its size.
\u4f18\u70b9 Analysis Queries \u2014\u2014 \u53ef\u80fd\u8bbf\u95ee\u5f88\u591arows\uff0c\u4f46\u662f\u53ea\u53d6\u5176\u4e2d\u90e8\u5206\u5c5e\u6027
- \u63d0\u9ad8CPU\u6548\u7387
- \u51cf\u5c11I/O
- \u51cf\u5c11Disk\u8bbf\u95ee\u65f6\u95f4
- \u5411\u91cf\u8bbf\u95ee\u65b9\u4fbf
- \u5bf9\u4e8eDecision Support\u66f4\u52a0\u9ad8\u6548
\u7f3a\u70b9
Traditional row-oriented representation preferable for transaction processing
"},{"location":"CS/DB/Chapter_14/","title":"Indexing","text":"\u7ea6 1776 \u4e2a\u5b57 5 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 9 \u5206\u949f
"},{"location":"CS/DB/Chapter_14/#basic","title":"Basic","text":"Evaluation
"},{"location":"CS/DB/Chapter_14/#ordered-indices","title":"Ordered Indices","text":"
Access Type
- Point query: records with a specified value in the attribute
- Range query: records with an attribute value falling in a specified range of values.
Access time
- insertion time \u5305\u62ec\u627e\u5230\u63d2\u5165\u4f4d\u7f6e\u3001\u66f4\u65b0\u7d22\u5f15\u7ed3\u6784\u7684\u65f6\u95f4
- Deletion time \u5305\u62ec\u627e\u5230\u5220\u9664\u9879\u3001\u66f4\u65b0\u7d22\u5f15\u7ed3\u6784\u7684\u65f6\u95f4
- Space overhead \u7d22\u5f15\u7ed3\u6784\u6240\u5360\u636e\u7684\u989d\u5916\u7a7a\u95f4
"},{"location":"CS/DB/Chapter_14/#primary-index-clustering-index","title":"Primary Index | \u4e3b\u7d22\u5f15 || Clustering index | \u805a\u96c6\u7d22\u5f15","text":"
- \u5f53\u53d1\u751f\u63d2\u5165/\u5220\u9664
- \u6240\u6709\u53d7\u5230\u5f71\u54cd\u7684index\u90fd\u8981\u6539\u53d8
- update
- \u53d7\u5f71\u54cd\u5219\u53d8
"},{"location":"CS/DB/Chapter_14/#dense-index","title":"Dense Index | \u7a20\u5bc6\u7d22\u5f15","text":"
- In a sequentially ordered file, the index whose search key specifies the sequential order of the file.
\u53ef\u4ee5\u662f\u805a\u96c6\u6216\u8005\u975e\u805a\u96c6
"},{"location":"CS/DB/Chapter_14/#sparse-index","title":"Sparse Index | \u7a00\u758f\u7d22\u5f15","text":"
- \u5de6\u4fa7\u7684\u90e8\u5206\u90fd\u662f
index entry
\uff0c\u5305\u62ec\u4e00\u4e2a\u7d22\u5f15\u952e\u503c\u548c\u6307\u9488- \u5b83\u7684
pointer
\u6709\u4e09\u79cd\u60c5\u51b5\uff08\u7d22\u5f15\u662f\u5426\u662fkey
\uff09
- \u76f4\u63a5\u6307\u5411\u5bf9\u5e94search key\u7684\u8bb0\u5f55
- \u6307\u5411\u6240\u6709\u5177\u6709\u76f8\u540csearch key\u7684\u6307\u9488\uff0c\u76f8\u5f53\u4e8e\u662f\u4e0a\u56fe\u4e2d\u7684\u6307\u9488\u6307\u5411\u4e00\u4e2abucket\uff0c\u8fd9\u4e2abucket\u542b\u6709\u6240\u6709\u6307\u5411\u76f8\u5e94\u8bb0\u5f55\u7684\u6307\u9488
- \u6307\u5411\u6240\u6709\u5177\u6709\u76f8\u540csearch key\u7684\u7b2c\u4e00\u6761\u8bb0\u5f55\u7684\u6307\u9488\uff0c\u5982\u4e0a\u56fe
\u5fc5\u987b\u662f\u805a\u96c6\u7d22\u5f15\uff0c\u6309\u987a\u5e8f\u5b58\u653e
"},{"location":"CS/DB/Chapter_14/#secondary-index-non-clustering-index","title":"Secondary Index | Non clustering Index","text":"
- Contains index records for only some search-key values.
\u6587\u4ef6\u7684\u7d22\u5f15\u8ddf\u7269\u7406\u5b58\u50a8\u987a\u5e8f\u4e0d\u4e00\u81f4
"},{"location":"CS/DB/Chapter_14/#multi-level-index","title":"Multi Level index","text":"
index entry
Index record points to a bucket that contains pointers to all the actual records with that particular search-key value.- \u5fc5\u987b\u662f\u7a20\u5bc6\u7d22\u5f15\uff0c\u7269\u7406\u5b58\u50a8\u5fc5\u987b\u662f\u6709\u5e8f\u7684
- \u5bf9\u5176\u8fdb\u884c\u987a\u5e8fScan\u4ee3\u4ef7\u5f88\u9ad8
"},{"location":"CS/DB/Chapter_14/#others","title":"Others","text":"
- outer index \u2013 a sparse index of the basic index
- inner index \u2013 the basic index file
- Indices at all levels must be updated on insertion or deletion from the file
Composite search key
"},{"location":"CS/DB/Chapter_14/#operation","title":"Operation","text":""},{"location":"CS/DB/Chapter_14/#b-tree-index","title":"B+ Tree Index","text":"Paths: all leaf in same level
**Root: **
- non-Leaf. has at least 2 children.
- Leaf. If the root is a leaf (that is, there are no other nodes in the tree), it can have between 0 and (n\u20131) values.
Inner node: Each node that is not a root or a leaf has between \\(\\lceil n/2\\rceil\\) and n children.
Leaf: A leaf node has between \\(\\lceil (n\u20131)/2\\rceil\\)and n\u20131 values
\u603b\u4f53\u7ed3\u6784\u90fd\u662f\u4e0a\u9762\u7684
Leaf Node
\\(P_i\u6307\u5411\u8bb0\u5f55,P_n\u6307\u5411\u4e0b\u4e00\u4e2a\u53f6\u5b50\\)
Non Leaf Node
\\(P_i\u90fd\u6307\u5411\u5b83\u7684Children\\)
trick
Block_id entry Block_id + \u7edd\u5bf9\u504f\u79fb\u7684\u8868\u793a\u65b9\u6cd5\u5e76\u4e0d\u5229\u4e8e\u4f4d\u7f6e\u7684\u8bb0\u5f55
\u652f\u6301\u67e5\u8be2\u65b9\u5f0f Point Query \u548c Range Query \u548c Scanning
\u56e0\u4e3a\u53f6\u5b50\u8282\u70b9\u542b\u6709\u6307\u5411\u5144\u5f1f\u7684\u6307\u9488\uff1b\u53ef\u80fd\u542b\u6709\u4e00\u4e2aScanning pointer\uff0c\u6307\u5411\u7b2c\u4e00\u4e2aLeaf
"},{"location":"CS/DB/Chapter_14/#query","title":"Query","text":"\u6bcf\u4e00\u4e2a\u8282\u70b9\u90fd\u5bf9\u5e94\u4e00\u4e2a\u78c1\u76d8\u7684\u5757 block, \u628a\u8fd9\u4e00\u5757\u8bfb\u5165\u5185\u5b58\uff0c\u4e4b\u540e\u53ef\u4ee5\u83b7\u5f97\u8fd9\u4e2a\u8282\u70b9. A node is generally the same size as a disk block, typically 4 kilobytes
info
\u5728DB\u4e2d\u7684B+ Tree\u4e0b\uff0cinner node\u7684\u503c\u4e0d\u4e00\u5b9a\u5728leaf\u51fa\u73b0\uff0c\u4e2d\u95f4\u7ed3\u70b9\u7684\u503c\u53ea\u8d77\u5230\u7d22\u5f15\u7684\u4f5c\u7528\u3002\uff08\u8fd9\u79cd\u60c5\u51b5\u662f\u5728Deletion\u4e0b\u53d1\u751f\uff09
"},{"location":"CS/DB/Chapter_14/#insert-delete","title":"Insert / Delete","text":"Deletion
- Gold\u5220\u9664\u540e\u4ecd\u7136\u5728root\u7684\u7d22\u5f15\u4e2d
\u4f18\u5148\u8003\u8651\u5408\u5e76\u8282\u70b9\uff0c\u53ea\u6709\u5f53\u5408\u5e76\u540e\u7684\u5927\u4e8e\u80fd\u5bb9\u7eb3\u91cf\uff0c\u624d\u4f1a\u53bb\u8003\u8651\u91cd\u65b0\u5206\u914d\u6307\u9488
"},{"location":"CS/DB/Chapter_14/#_1","title":"\u8ba1\u7b97","text":"height & size \u4f30\u8ba1
height
$$ \\ \u6700\u5927\u9ad8\u5ea6\uff1a(\u4e0d\u8003\u8651\u6839\u7684\"\u4e8c\u53c9\"\uff0c\u53ea\u9700\u8981\u8003\u8651\u6bcf\u4e00\u5c42\u6700\u5c11\u6709\u591a\u5c11\u4e2avalue)\\ \\ Height\\leq \\lceil log_{\\lceil \\frac{n}{2}\\rceil}K \\rceil $$
Records per block \u6bcf\u4e00\u4e2anode\u662f\u4e00\u4e2a\u5757\uff0c\u4e00\u4e2a\u5757\u4e00\u822c\u662f4K\u5927\u5c0f(Block Size)\uff0cBlock Size / Data Size Blocks for storing Records size / Records per block
\u8981\u8ba1\u7b97
fan-out
\uff0c\u4e5f\u5c31\u662f\u8fd9\u4e2aB+ Tree\u7684\u5206\u652f\uff0c\u5bf9\u4e8e\u4e00\u4e2aM\u53c9\u7684B+ Tree\uff0c\u5b83\u6709 M+1 \u4e2a\u6307\u9488\uff0cM\u4e2a\u7d22\u5f15\u503c\u3002\uff08\u6bcf\u4e00\u4e2a\u8282\u70b9\u90fd\u662f\u4e00\u4e2aPage/Block\uff09 \u4e8e\u662f\uff0c\u8ba1\u7b97\u65b9\u5f0f\u5c31\u662f (\\(\\frac{Block Size - 4}{index\\ size+\\ pointer\\ size}\\) +1 )\u5c42\u6570
\u6839\u8282\u70b9\u7684level\u4e3a1
- Level 2 \uff1amin = 2 * leaf value , max = \u5168\u6ee1
- Level 3 \uff1amin = 2 * Inner value * leaf value
- Level K(K > 1) :
$$ min = 2 (Inner Pointer)_{min}^{K-2}(Leaf value){min}\\ max = (Inner Pointer) $$}^{K-1}*(Leaf value)_{max
size
"},{"location":"CS/DB/Chapter_14/#extension","title":"Extension","text":""},{"location":"CS/DB/Chapter_14/#_2","title":"\u6587\u4ef6\u7d22\u5f15","text":"
leaf\u7684\u90e8\u5206\uff0c\u8981\u5b58\u653e1000000\u4e2a(N)\u6570\u636e\uff0c\u90a3\u4e48\u9700\u8981N / leaf values\u4e2a\u53f6\u5b50\u8282\u70b9
\u6700\u5c11\u7684nodes leaf : 1000000 / 186
- \u6700\u591a\u7684nodes
"},{"location":"CS/DB/Chapter_14/#_3","title":"\u8f85\u52a9\u7d22\u5f15","text":"
- \u5b58\u653e\u7684\u662f\u8bb0\u5f55\u672c\u8eab\u800c\u4e0d\u662f\u6307\u5411\u8bb0\u5f55\u7684\u6307\u9488
\u5728\u6539\u53d8\u7d22\u5f15\u7684\u65f6\u5019\uff0c\u5373\u4f7f\u6ca1\u6709\u76f4\u63a5\u4f5c\u7528\u4e8e\u8fd9\u6761\u8bb0\u5f55\uff0c\u4f46\u4ed6\u7684\u7d22\u5f15\u4e5f\u53ef\u80fd\u53d1\u751f\u53d8\u5316\uff0c\u8fd9\u5bfc\u81f4\u7ef4\u62a4\u7684\u4ee3\u4ef7\u76f8\u5f53\u9ad8
Solution: use search key of B+-tree file organization instead of record pointer in secondary index
"},{"location":"CS/DB/Chapter_14/#_4","title":"\u5b57\u7b26\u4e32","text":"
- Add record-id if B+-tree file organization search key is non-unique
- Extra traversal of file organization to locate record
- Higher cost for queries, but node splits are cheap
\u4f7f\u7528 \u524d\u7f00\u538b\u7f29 | prefix encoding \u6765\u5bf9\u53d8\u957f\u7684\u6570\u636e\u8fdb\u884c\u7d22\u5f15
"},{"location":"CS/DB/Chapter_14/#bulk-loading-and-bottom-up-build","title":"\u6279\u91cf\u52a0\u8f7d\u4e0e\u6784\u5efa | Bulk Loading and Bottom-Up Build","text":"Algorithm 1
- sort entries first
- insert in sorted order
- much improved I/O performance, but most leaf nodes half full
Algorithm 2 | Bottom-up B+-tree construction
"},{"location":"CS/DB/Chapter_14/#hash","title":"Hash | \u6563\u5217","text":"
- sort entries
- create tree layer-by-layer, starting with leaf level
A bucket is a unit of storage containing one or more entries (a buckets typically a disk block).
- we obtain the bucket of an entry from its search-key value using a hash function
Hash function h is a function from the set of all search-key values K to the set of all bucket addresses B.
"},{"location":"CS/DB/Chapter_14/#static-hashing","title":"Static hashing","text":"Bucket Overflow
\u4f7f\u7528 overflow bucket \u5904\u7406\uff0c\u5f62\u6210\u6ea2\u51fa\u94fe
\u95ed\u6563\u5217
\u5f00\u6563\u5217
\u63d2\u5165\u5230\u5176\u4ed6bucket\u4e2d\uff0c\u6bd4\u5982\u4f7f\u7528\u7ebf\u6027\u63a2\u6d4b\u7b49\u65b9\u5f0f
"},{"location":"CS/DB/Chapter_14/#dynamic-hashing","title":"Dynamic Hashing","text":""},{"location":"CS/DB/Chapter_14/#multiple-key-access","title":"Multiple-key access","text":"
Periodic rehashing
Linear Hashing
- Extendable Hashing
Use multiple indices for certain types of queries
"},{"location":"CS/DB/Chapter_14/#definition-of-index","title":"Definition of Index","text":"select ID\nfrom instructor\nwhere dept_name = \u201cFinance\u201d and salary = 80000\n
create index takes_pk on takes (ID,course_ID, year, semester, section) \ndrop index takes_pk\n
"},{"location":"CS/DB/Chapter_14/#write-optimized-indices","title":"Write-Optimized Indices","text":"
- Indices on primary key created automatically by all databases
Performance of B+-trees can be poor for write-intensive workloads
- One I/O per leaf, assuming all internal nodes are in memory
With magnetic disks, < 100 inserts per second per disk
With flash memory, one page overwrite per insert
\u95ea\u5b58\u7684update\u4ee3\u4ef7\u6bd4\u8f83\u5927
"},{"location":"CS/DB/Chapter_14/#log-structured-merge-lsm-tree","title":"Log Structured Merge (LSM) Tree","text":"
- Size threshold for \\(\ud835\udc3f_{\ud835\udc56+1}\\) tree is \ud835\udc58 times size threshold for \\(\ud835\udc3f_\ud835\udc56\\) tree \u4e00\u4e2arecord\u5728\u4e00\u4e2a\u8282\u70b9\u6700\u591a\u5199K\u6b21
\u63d2\u5165 - Records inserted first into in-memory tree (\ud835\udc3f0 tree) - When in-memory tree is full, records moved to disk (\ud835\udc3f1 tree) B+-tree constructed using bottom-up build by merging existing \ud835\udc3f1 tree with records from \ud835\udc3f0 tree \u5185\u5b58\u91cc\u7684 B+ \u6811\u5982\u679c\u6ee1\u4e86\uff0c\u5c31\u9a6c\u4e0a\u5199\u5230\u78c1\u76d8\u91cc\u53bb\uff08\u53ef\u4ee5\u8fde\u7eed\u5199\uff09 - When \ud835\udc3f1 tree exceeds some threshold, merge into \\(L_2\\) tree And so on for more levels
\u8fd9\u6837\u6211\u4eec\u628a\u968f\u673a\u5199\u53d8\u4e3a\u4e86\u987a\u5e8f\u5199\u3002\u4f46\u6b64\u65f6\u67e5\u627e\u4e00\u4e2a\u7d22\u5f15\uff0c\u5c31\u8981\u904d\u5386\u6240\u6709 B + Tree
Stepped-merge index
\u5728\u6bcf\u4e00\u7ea7\u4f7f\u7528\u66f4\u591a\u7684B+ Tree \u800c\u4e0d\u662f\u50cf\u4e0a\u9762\u4e00\u6837\u6bcf\u6b21\u4e00\u68f5\u6811\u6ee1\u5c31\u53bbmerge\u5230\u4e0b\u4e00\u5c42
- Variant of LSM tree with multiple trees at each level
- Reduces write cost compared to LSM tree
- But queries are even more expensive
- Bloom filters to avoid lookups in most trees
- Bloom filters to avoid lookups in most trees
\u5220\u9664\u64cd\u4f5c
\u4e0d\u540c\u4e8e\u4e0a\u9762\u7684\u67e5\u627e\u548cinsert\uff0c\u5220\u9664\u901a\u8fc7
deletion entry
\u6765\u5b9e\u73b0Indicates which index entry is to be deleted. The process of inserting a deletion entry is identical to the process of insertinga normal index entry.
"},{"location":"CS/DB/Chapter_14/#buffer-tree","title":"Buffer Tree","text":"
- When trees are merged, if we find a delete entry matching an originalentry, both are dropped.
- When lookups, find both original entry and the delete entry, and mustreturn only those entries that do not have matching delete entry
\u5728\u6bcf\u4e2aInternal\u8282\u70b9\u52a0\u4e00\u4e2aBuffer\u7f13\u51b2
"},{"location":"CS/DB/Chapter_14/#bitmap-indices","title":"Bitmap Indices","text":"
Insert
- \u5148\u653e\u5728Root\u7684\u7f13\u51b2\u533a
- \u6ee1\u4e86\u5f80\u4e0b\u653e
- \u653e\u5728internal\u7f13\u51b2\u533a...
- \u4e00\u76f4\u5230\u53f6\u5b50\u8282\u70b9
Query
- \u5728\u67e5\u627e\u6240\u904d\u5386\u7684\u6bcf\u4e2a\u5185\u90e8\u8282\u70b9\u65f6\uff0c\u90fd\u5fc5\u987b\u68c0\u67e5\u8be5\u8282\u70b9\u7684\u7f13\u51b2\u533a\uff0c\u4ee5\u67e5\u770b\u662f\u5426\u6709\u4e0e\u67e5\u627e\u952e\u5339\u914d\u7684\u8bb0\u5f55\u3002\u662f\u5426\u6709\u4e0e\u67e5\u627e\u952e\u5339\u914d\u7684\u8bb0\u5f55\u3002\u8303\u56f4\u67e5\u627e\u4e0e\u666e\u901a B+-\u6811\u4e2d\u7684\u505a\u6cd5\u4e00\u6837\uff0c\u4f46\u5b83\u4eec\u8fd8\u5fc5\u987b\u68c0\u67e5\u88ab\u8bbf\u95ee\u7684\u53f6\u8282\u70b9\u4e0a\u9762\u7684\u6240\u6709\u5185\u90e8\u8282\u70b9\u7684\u7f13\u51b2\u533a\u3002
Bitmap indices are a special type of index designed for efficient querying on multiple keys not particularly useful for single attribute queries
- Applicable on attributes that take on a relatively small number of distinct values \u6bcf\u4e00\u5217\u4e0d\u540c\u7684\u5c5e\u6027\u503c\u4e0d\u8981\u592a\u591a
"},{"location":"CS/DB/Chapter_15/","title":"\u67e5\u8be2\u5904\u7406","text":"
- \u53ef\u4ee5\u8fdb\u884c\u4ea4\u5e76\u64cd\u4f5c
\u7ea6 1060 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"CS/DB/Chapter_15/#basic-step","title":"Basic Step","text":"
Parsing and Translation
- Translate the query into its internal form. This is then translated into relational algebra.
Parser checks syntax, verifies relations \u89e3\u6790\u5668
Optimization
- Amongst all equivalent evaluation plans choose the one with lowest cost.
Evaluation
- The query-execution engine takes a query-evaluation plan, executes that plan, and returns the answers to the query.
An evaluation plan defines exactly what algorithm is used for each operation, and how the execution of the operations is coordinated.
"},{"location":"CS/DB/Chapter_15/#measures-of-query-cost","title":"Measures of Query Cost","text":"
- Resource Consumption
"},{"location":"CS/DB/Chapter_15/#selection-operation-external-sort-merge","title":"Selection Operation | External Sort-Merge","text":"
- We often use worst case estimates, assuming only the minimum amount of memory needed for the operation is available
https://note.hobbitqia.cc/DB/db11/#selection-operation
"},{"location":"CS/DB/Chapter_15/#sorting","title":"Sorting","text":"\u6570\u636e\u5e93\u4e3b\u8981\u8003\u8651\u9700\u8981\u5916\u6392\u7684\u60c5\u51b5
We may build an index on the relation, and then use the index to read the relation in sorted order. May lead to one disk block access for each tuple.
"},{"location":"CS/DB/Chapter_15/#external-sort-merge","title":"External Sort-Merge","text":"
- Build Runs \u5f97\u5230 \\(\\lceil{\\frac{B_r}{M}}\\rceil\\) Runs \u9700\u8981\\(2B_r\\)\u6b21Transfer \uff0c\\(2\\lceil{\\frac{B_r}{M}}\\rceil\\)\u6b21Seek\uff08\u8fd9\u91cc\u5e94\u8be5\u662f\u7269\u7406\u5b58\u50a8\u4e34\u8fd1
- Merge Runs \u5f52\u5e76\u6b21\u6570 \\(\\lceil{\\log_{\\lfloor{\\frac{M}{B_b}-1}\\rfloor}{B_r/M}}\\rceil\\) \u9664\u4e86\u6700\u540e\u4e00\u6b21\u5f52\u5e76\uff0c\u5176\u4f59\u6bcf\u6b21\u90fd\u662f\\(2B_r\\)\u6b21Transfer Seek\uff1a\u6bcf\u4e00\u6b21\\(2\\lceil{\\frac{B_r}{B_b}}\\rceil\\)\u200b
- \\(B_b\\)\u628a\\(B_b\\)\u4e2a\u7f13\u51b2\u5757\u5206\u914d\u7ed9 \u6bcf\u4e2a \u5f52\u5e76\u6bb5
Cost of Transfer $$ 2 B_r \\lceil{\\log_{\\lfloor{\\frac{M}{B_b}-1}\\rfloor}{B_r/M}}\\rceil + 2B_r-B_r $$ Cost of Seek $$ 2\\lceil{\\frac{B_r}{B_b}}\\rceil\\lceil{\\log_{\\lfloor{\\frac{M}{B_b}-1}\\rfloor}{B_r/M}}\\rceil+2\\lceil{\\frac{B_r}{M}}\\rceil - \\lceil{\\frac{B_r}{B_b}}\\rceil\\ =\\lceil{\\frac{B_r}{B_b}}\\rceil(Merge-1)+build Seek $$
"},{"location":"CS/DB/Chapter_15/#join-operation","title":"Join Operation","text":""},{"location":"CS/DB/Chapter_15/#nested-loop-join","title":"Nested-loop join","text":"cost
\u8fd9\u91cc\u6709\u4e00\u4e2a\u9690\u542b\u7684\u5047\u8bbe\uff1a\u5185\u5c42\u7684\u6570\u636e\u53ef\u4ee5\u901a\u8fc7\u4e00\u6b21seek\u83b7\u53d6\u5168\u90e8
"},{"location":"CS/DB/Chapter_15/#block-nested-loop-join","title":"Block nested-loop join","text":"
- Transfer
- Seek \u5916\u5c42\u9700\u8981seek \\(b_r\\) times\uff0c\u5185\u5c42\u5176\u5b9e\u662f\\(n_r*b_s\\)
\u5c3d\u53ef\u80fd\u628a\u5c0f\u7684\u653e\u5728\u5916\u5c42
Improvement
\u5bf9\u5916\u5c42\u4f7f\u7528\u66f4\u591a\u7684\u7f13\u51b2\u5757
"},{"location":"CS/DB/Chapter_15/#indexed-nested-loop-join","title":"Indexed nested-loop join","text":"\u2022 Where c is the cost of traversing index and fetching all matching s tuples for one tuple of r
\u2022 c can be estimated as cost of a single selection on s using the join condition.
"},{"location":"CS/DB/Chapter_15/#merge-join","title":"Merge-Join","text":"
- Can be used only for equi-joins and natural joins
- \u76f4\u63a5\u5bf9\u8f85\u52a9\u7d22\u5f15\u7684\u503c\u6392\u5e8f\u4ee3\u4ef7\u592a\u5927\u4e86
- \u5148\u628a\u6709\u5e8f\u5173\u7cfb\u548cB+ Tree\u7684\u53f6\u5b50\u8fdb\u884cMerge
- \u6309\u7167\u7269\u7406\u5730\u5740\u5bf9\u4e0a\u8ff0\u7ed3\u679c\u6392\u5e8f\uff0c\u4f7f\u4e4b\u80fd\u591f\u66f4\u52a0\u65b9\u4fbf\u5730\u8fdb\u884c\u7269\u7406\u8bbf\u95ee
- \u8fdb\u884cMerge\uff0c\u7528\u771f\u5b9e\u7269\u7406\u5730\u5740\u66ff\u6362
"},{"location":"CS/DB/Chapter_15/#hash-join","title":"Hash-join","text":"
- \u6309\u7167\u5730\u5740\u6392\u5e8f\uff0c\u4f7f\u5f97\u5730\u5740\u8fde\u7eed\uff0c\u65b9\u4fbf\u4ece\u4e00\u4e2aBlock\u4e2d\u53d6\u51fa
- \u7528\u540c\u4e00\u4e2a\u54c8\u5e0c\u51fd\u6570\u8fdb\u884c\u5212\u5206 \u5206\u522b\u8fdb\u884c\u4e00\u6b21\u5b8c\u6574\u7684\u8bfb\u5165\u5199\u56de
- \u4e3a\u6bcf\u4e2a\\(S_i\\)\u200b\u6784\u9020\u4e00\u4e2a\u6563\u5217\u7d22\u5f15\uff08\u5185\u5b58\u4e2d\uff09\uff0c\u8fd9\u4e2a\u6563\u5217\u51fd\u6570\u5fc5\u987b\u4e0e\u4e4b\u524d\u7684\u4e0d\u540c
- \u5c0f\u7684\u8868\u8981\u80fd\u653e\u5728\u5185\u5b58\u4e2d
- \u7528\\(R_i\\)\u4e2d\u7684\u6bcf\u4e00\u4e2atuple\u53bb\u63a2\u67e5
"},{"location":"CS/DB/Chapter_15/#recursive-partitioning","title":"\u9012\u5f52\u5212\u5206 | recursive partitioning","text":"
- \u8fd9\u91cc\u4f7f\u7528\u7684\u6563\u5217\u51fd\u6570\u5fc5\u987b\u4e0e\u4e4b\u524d\u4f7f\u7528\u7684H\u4e0d\u540c
\u6ca1\u6709\u8db3\u591f\u7684\u7f13\u51b2\u5757\u652f\u6491\u4e00\u6b21\u5b8c\u6210\u6240\u6709\u7684partition
\u591a\u6b21\u4ea7\u751f\u66f4\u5c0f\u7684\u5212\u5206\u3002\u6bcf\u4e00\u8d9f\u7684\u6563\u5217\u51fd\u6570\u90fd\u4e0d\u540c\uff0c\u4e0d\u65ad\u91cd\u590d\u8f93\u5165\u7684\u5206\u88c2\u8fc7\u7a0b\u76f4\u5230\u6784\u9020\u7528\u8f93\u5165\u5173\u7cfb\u7684\u6bcf\u4e2a\u5212\u5206\u90fd\u80fd\u88ab\u5185\u5b58\u5bb9\u7eb3\u4e3a\u6b62 $$ M>b_s/M+1\\ \\text{\u7f13\u51b2\u533a\u5927\u5c0f\u5927\u4e8e\u6bcf\u4e2apartition\u7684\u5927\u5c0f + \u4e00\u4e2a\u8f93\u51fa\u5757}\\ M>\\sqrt {b_s} $$
"},{"location":"CS/DB/Chapter_15/#hash-table-overflow","title":"\u6ea2\u51fa\u5904\u7406 | hash-table overflow","text":"\u6563\u5217\u7d22\u5f15\u5927\u4e8e\u4e3b\u5b58
skewed \u5212\u5206\u4e0d\u5747\u5300 if some partitions have significantly more tuples than some others
fudge factor \u907f\u8ba9\u56e0\u5b50 \u4f7f\u5f97\u6bcf\u4e2a\u5212\u5206\u7684\u671f\u671b\u5927\u5c0f\u6bd4\u5185\u5b58\u5bb9\u91cf\u7565\u5c0f\uff0c\u589e\u52a0\u7684\u5212\u5206\u4e2a\u6570\u79f0\u4e4b\u4e3a\u907f\u8ba9\u94f6\u5b50
"},{"location":"CS/DB/Chapter_15/#cost","title":"cost","text":"
\u6ea2\u51fa\u5206\u89e3 | resolution \u6784\u9020\u9636\u6bb5\uff0c\\(s_i\\)\u200b\u592a\u5927\uff0c\u7528\u53e6\u4e00\u4e2ahash func\u8fdb\u884c\u8fdb\u4e00\u6b65\u5212\u5206\uff1b\u540c\u65f6\\(r_i\\)\u5fc5\u987b\u8fdb\u884c\u540c\u6837\u7684\u5212\u5206
\u6ea2\u51fa\u907f\u514d | avoidance \u5728\u6784\u9020\u9636\u6bb5\u8fdb\u884c\u8c28\u614e\u7684\u5212\u5206 partition build relation into many partitions, then combine them
example
"},{"location":"CS/DB/Chapter_15/#hybrid-hash-join","title":"\u6df7\u5408\u6563\u5217\u8fde\u63a5 | Hybrid hash-join","text":"\u628a\u4e00\u4e2a\\(S_0\\)\u5b58\u653e\u5728\u5185\u5b58\u4e2d\uff0c\u4e4b\u540e\u8bfb\u5165\\(R_i\\)\uff0c\u5bf9\u4e8e\\(R_0\\)\uff0c\u5c31\u53ea\u9700\u8981\u8bfb\u5165\u4e4b\u540e\u76f4\u63a5\u53bb\u548c\\(s_0\\)\u201c\u8fde\u63a5\u201d\uff0c\u4e4b\u540e\u4e0d\u9700\u8981\u5199\u56de\uff0c\u76f4\u63a5\u4e22\u5f03
"},{"location":"CS/DB/Chapter_15/#_2","title":"\u590d\u6742\u8fde\u63a5","text":"$ \\Pi_{T.branch_name} ( (\\Pi_{branch_name, assets}(\\rho_T(branch))) \\bowtie_{T.assets > S.assets} (\\Pi_{assets} (\\sigma_{branch_city = 'Brooklyn'}(\\rho_S(branch))))) $
\\(\\Pi_{}\\)
"},{"location":"CS/DB/Chapter_15/#other-operation","title":"other operation","text":""},{"location":"CS/DB/Chapter_15/#project","title":"Project","text":""},{"location":"CS/DB/Chapter_15/#_3","title":"15. Process","text":""},{"location":"CS/DB/Chapter_15/#evaluation-of-expressions","title":"Evaluation of Expressions","text":""},{"location":"CS/DB/Chapter_15/#materialized","title":"Materialized | \u7269\u5316","text":""},{"location":"CS/DB/Chapter_15/#pipeline","title":"pipeline | \u6d41\u6c34\u7ebf","text":"
- \u4ece\u6700\u5e95\u5c42\u5f00\u59cb
- \u9700\u8981\u5b58\u50a8\u4e34\u65f6\u7ed3\u679c
demand driven
- pull
- \u72b6\u6001\u7684\u7ef4\u62a4\u4f9d\u8d56\u4e8e\u7b97\u5b50 operator\uff0c
open() next() close()
producer driven
- push \u4ece\u5e95\u5c42\u5f80\u4e0apush
Blocking operations | \u963b\u585e\u64cd\u4f5c: cannot generate any output until all input is consumed
Pipeline stages:
- All operations in a stage run concurrently
- A stage can start only after preceding stages have completed execution
Double-pipeline
"},{"location":"CS/DB/Chapter_15/#memory","title":"\u52a0\u901fMemory\u4e2d\u7684\u67e5\u8be2\u8fc7\u7a0b","text":""},{"location":"CS/DB/Chapter_16/","title":"\u67e5\u8be2\u4f18\u5316","text":"\u7ea6 86 \u4e2a\u5b57
"},{"location":"CS/DB/Chapter_16/#intro","title":"Intro","text":""},{"location":"CS/DB/Chapter_16/#equivalent","title":"Equivalent","text":"
- An evaluation plan defines exactly what algorithm is used for each operation, and how the execution of the operations is coordinated.
"},{"location":"CS/DB/Chapter_16/#statistics-for-cost-estimation","title":"Statistics for Cost Estimation","text":"
- \u4e0a\u9762\u7684\u5f0f\u5b50\u5de6\u53f3\u53ef\u4ee5\u76f8\u4e92\u8f6c\u6362
- \u81ea\u7136\u8fde\u63a5\u53ef\u4ea4\u6362\u3001\u7ed3\u5408
Select\u5f80\u53f6\u5b50\u4e0apush
\\(\\theta _2\u4e0a\u9762\u6709\u7d22\u5f15\\)
Size Estimation
"},{"location":"CS/DB/Chapter_16/#choice-of-evaluation-plans","title":"Choice of Evaluation Plans","text":"\u5c40\u90e8\u6700\u4f18\u4e0d\u4e00\u5b9a\u5168\u5c40\u6700\u4f18
"},{"location":"CS/DB/Chapter_16/#additional-optimization-techniques","title":"Additional Optimization Techniques","text":""},{"location":"CS/DB/Chapter_17/","title":"\u4e8b\u52a1\u7ba1\u7406","text":"\u7ea6 100 \u4e2a\u5b57
"},{"location":"CS/DB/Chapter_17/#concepts","title":"Concepts","text":"ACID
"},{"location":"CS/DB/Chapter_17/#concurrent-executions","title":"Concurrent Executions","text":""},{"location":"CS/DB/Chapter_17/#serializability","title":"Serializability","text":""},{"location":"CS/DB/Chapter_17/#conflict-serializability","title":"Conflict Serializability | \u51b2\u7a81\u53ef\u4e32\u884c","text":"
- \u539f\u5b50\u6027
- \u4e00\u81f4\u6027
- \u9694\u79bb\u6027
- \u6301\u4e45\u6027
\u4ece\u51b2\u7a81\u7684\u89c6\u89d2\u770b\uff0c\u901a\u8fc7\u4ea4\u6362\u51b2\u7a81\u53ef\u4ee5\u8fbe\u6210serial
If a schedule S can be transformed into a schedule S\u2019 by a series of swaps of non-conflicting instructions, we say that S and S\u2019 are conflict equivalent
\u51b2\u7a81\u7b49\u4ef7\uff1a\u901a\u8fc7\u4ea4\u6362\u975e\u51b2\u7a81\u7684\u6307\u4ee4\uff0c
"},{"location":"CS/DB/Chapter_17/#view-serializability","title":"View Serializability | \u89c6\u56fe\u53ef\u4e32\u884c","text":""},{"location":"CS/DB/Chapter_17/#recoverable-schedules","title":"Recoverable Schedules","text":"\u5fc5\u987b\u5728
"},{"location":"CS/DB/Chapter_18/","title":"\u5e76\u53d1\u63a7\u5236","text":"\u7ea6 738 \u4e2a\u5b57 13 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 4 \u5206\u949f
"},{"location":"CS/DB/Chapter_18/#two-phase-locking-protocol","title":"Two-Phase Locking Protocol | \u4e24\u9636\u6bb5\u5c01\u9501\u534f\u8bae","text":"
- \u65e0\u6cd5\u4fdd\u8bc1\u53ef\u6062\u590d\u6027
=> \u662f\u51b2\u7a81\u53ef\u5e76\u884c\u7684\u5145\u5206\u6761\u4ef6\uff0c\u4f46\u4e0d\u662f\u5fc5\u8981\u6761\u4ef6\uff1b\u6ee1\u8db3\u4e24\u9636\u6bb5\u5c01\u9501\u534f\u8bae\uff0c\u4e00\u5b9a\u53ef\u51b2\u7a81\u4e32\u884c\u5316\uff0c\u4f46\u53ef\u51b2\u7a81\u4e32\u884c\u5316\uff0c\u4e0d\u4e00\u5b9a\u6ee1\u8db3\u4e24\u9636\u6bb5\u5c01\u9501\u534f\u8bae
strict | \u4e25\u683c\u7684
a transaction must hold all its exclusive locks till it commits/aborts.
- \u6392\u4ed6\u9501\u7ef4\u6301\u66f4\u957f\u7684\u65f6\u95f4
- Ensures recoverability and avoids cascading roll-backs
rigorous | \u5f3a
"},{"location":"CS/DB/Chapter_18/#lock-conversion","title":"Lock Conversion","text":"
- \u6240\u6709\u7684\u9501\u90fd\u5230\u6700\u540e\uff08commit/abort\uff09\u624d\u91ca\u653e
- Transactions can be serialized in the order in which they commit.
U Lock, \u5148\u8bfb\u540e\u9762\u53ef\u80fd\u4f1a\u5199
Growing
- upgrade
Shrinking
"},{"location":"CS/DB/Chapter_18/#automatic-acquisition-of-locks","title":"Automatic Acquisition of Locks","text":"
- downgrade
write
"},{"location":"CS/DB/Chapter_18/#dead-lock","title":"Dead Lock | \u6b7b\u9501","text":"The operation write(D) is processed as:\n if Ti has a lock-X on D\n then\n write(D)\n else begin\n if necessary wait until no other trans. has any lock on D,\n if Ti has a lock-S on D\n then\n upgrade lock on D to lock-X\n else\n grant Ti a lock-X on D\n write(D)\n end;\n
System is deadlocked if there is a set of transactions such that every transaction in the set is waiting for another transaction in the set. \u4e24\u4e2a\u4e8b\u52a1\u76f8\u4e92\u7b49\u5f85\u3002
- \u6b7b\u9501\u662f\u57fa\u4e8e\u9501\u534f\u8bae\u5171\u6709\u7684\u95ee\u9898
Deadlock Prevention
Timeout-Based Schemes
"},{"location":"CS/DB/Chapter_18/#detection","title":"Detection","text":"
a transaction waits for a lock only for a specified amount of time. After that, the wait times out and the transaction is rolled back.
thus deadlocks are not possible
simple to implement; but starvation is possible. Also difficult to determine good value of the timeout interval. \u4e00\u76f4\u65e0\u6cd5\u83b7\u5f97\u9501\uff0c\u4e00\u76f4\u5728\u7b49\u5f85
wait-for Graph
"},{"location":"CS/DB/Chapter_18/#recovery","title":"Recovery","text":"
- \\(T_i -> T_j\uff0c\u524d\u4e00\u4e2a\u7b49\u5f85\u540e\u9762\u7684\\)
"},{"location":"CS/DB/Chapter_18/#graph-based","title":"Graph-Based","text":"
- Some transaction will have to rolled back (made a victim) to break deadlock. \u9009\u62e9\u727a\u7272\u8005
- Select that transaction as victim that will incur minimum cost.
- Rollback -- determine how far to roll back transaction \u56de\u6eda
- Total rollback: Abort the transaction and then restart it.
- Partial rollback: Roll back victim transaction only as far as necessary to release locks that another transaction in cycle is waiting for.
\u5bf9\u6570\u636e\u7684\u8bbf\u95ee\u6709\u4e00\u5b9a\u201c\u9884\u77e5\u201d
"},{"location":"CS/DB/Chapter_18/#tree-protocol","title":"Tree Protocol","text":"
- \u53ea\u6709\u6392\u4ed6\u9501
- \u7b2c\u4e00\u4e2a\u9501\u53ef\u4ee5\u52a0\u5230\u4efb\u4f55\u5730\u65b9\uff0c\u4f46\u662f\u4e4b\u540e\u7684\u9501\u8981\u52a0\u7684\u6570\u636e \u7684\u7236\u8282\u70b9\u4e00\u5b9a\u8981\u6709\u9501
- \u9501\u7528\u8fc7\u4e4b\u540e\u5c31\u53ef\u4ee5\u968f\u65f6\u653e\u6389
- \u540c\u4e00\u4e2a\u8282\u70b9\u4e0d\u80fd\u91cd\u590d\u52a0\u9501\uff08lock - unlock - lock \u00d7\uff09
\u597d\u5904
- \u51b2\u7a81\u53ef\u4e32\u884c
- \u4e0d\u4f1a\u4ea7\u751f\u6b7b\u9501\uff0cdeadlock-free
- \u53ef\u4ee5\u65e9\u70b9\u653e\u9501\uff0c\u63d0\u9ad8\u4e86\u5e76\u53d1\u5ea6\u3001\u541e\u5410\u7387
\u7f3a\u70b9
"},{"location":"CS/DB/Chapter_18/#multiple-granularity","title":"Multiple Granularity | \u591a\u7c92\u5ea6","text":"
- \u4e0d\u4fdd\u8bc1\u53ef\u6062\u590d\u6027 recoverability. \u53ef\u80fd\u8bfb\u53d6\u810f\u6570\u636e
- \u53ef\u901a\u8fc7\u6dfb\u52a0\u201c\u63d0\u4ea4\u4f9d\u8d56\u201d\u6765\u4fdd\u8bc1\u8fd9\u4e00\u70b9
- \u53ef\u80fd\u9501\u4f4f\u66f4\u591a\u4e0d\u9700\u8981\u7684\u6570\u636e\uff0clock more data items \u2014\u2014 \u6bd4\u5982\u540c\u65f6\u8bbf\u95ee\u6839\u8282\u70b9\u548c\u67d0\u4e00\u4e2a\u53f6\u5b50\u8282\u70b9\uff0c\u5c31\u9700\u8981\u6309\u7167Tree\u7684\u4e00\u6761path\u9501\u5230\u53f6\u5b50\u8282\u70b9
Granularity of locking (level in tree where locking is done):
- Fine granularity (\u7ec6\u7c92\u5ea6) (lower in tree): high concurrency, high locking overhead
- Coarse granularity (\u7c97\u7c92\u5ea6) (higher in tree): low locking overhead, low concurrency
- \u53ef\u4ee5\u5728\u66f4\u5927\u7684\u7c92\u5ea6\u4e0a\u9762\u52a0\u9501
Intension Lock
\u5728\u4e00\u4e2a\u8282\u70b9\u663e\u5f0f\u52a0\u9501\u4e4b\u524d, \u5bf9\u4ed6\u7684\u7236\u8282\u70b9\u52a0\u610f\u5411\u9501
\u76f8\u5bb9\u8868
- \u5728\u7c97\u7c92\u5ea6\u4e0a\u9762\u52a0\u9501\uff0c\u53ef\u4ee5\u5148\u4e0d\u53bb\u7ba1\u4e0b\u9762\u7684\u7ec6\u7c92\u5ea6\u662f\u5426\u4f1a\u51b2\u7a81\uff1b\u610f\u5411
example
- \u52a0\u9501\u4ece\u4e0a\u9762 - Unlock\u4ece\u4e0b\u9762
"},{"location":"CS/DB/Chapter_18/#insert-and-delete-operations","title":"Insert and Delete Operations","text":""},{"location":"CS/DB/Chapter_18/#phantom-phenomenon","title":"Phantom Phenomenon | \u5e7b\u8bfb","text":""},{"location":"CS/DB/Chapter_18/#_2","title":"\u8c13\u8bcd\u9501","text":""},{"location":"CS/DB/Chapter_18/#index-locking-to-prevent-phantoms","title":"Index Locking To Prevent Phantoms | \u7d22\u5f15\u5c01\u9501","text":"
- Locking rules for insert/delete operations
- An exclusive lock must be obtained on an item before it is deleted \u81ea\u52a8\u52a0\u6392\u4ed6\u9501
- A transaction that inserts a new tuple into the database automatically gives an X-mode lock on the tuple
"},{"location":"CS/DB/Chapter_18/#next-key-locking-to-prevent-phantoms","title":"Next-Key Locking to Prevent Phantoms","text":"
- \u5728\u7d22\u5f15\u4e0a\u9762\u9501\u4f4f\u4e00\u6bb5
"},{"location":"CS/DB/Chapter_19/","title":"Recovery","text":"
- \u9501\u4f4f\u5355\u72ec\u7684\u6570\u636e
\u7ea6 393 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
"},{"location":"CS/DB/Chapter_19/#failure-classification","title":"Failure Classification","text":""},{"location":"CS/DB/Chapter_19/#_1","title":"\u4e8b\u52a1\u7684\u7269\u7406\u5b9e\u73b0","text":""},{"location":"CS/DB/Chapter_19/#_2","title":"\u65e5\u5fd7\u8bb0\u5f55","text":""},{"location":"CS/DB/Chapter_19/#_3","title":"\u4e8b\u52a1\u6062\u590d","text":"\u4e00\u4e2a\u4e8b\u52a1\u7684Commit\u6807\u5fd7\uff1a\u65e5\u5fd7\u5199\u5165\u7a33\u5b9a\u5b58\u50a8\u5668
A transaction is said to have committed when its commit log record is output to stable storage
- All previous log records of the transaction must have been output already
\u8fd9\u65f6\u7684\u4fee\u6539\u4e0d\u4e00\u5b9a\u5199\u5230\u4e86\u78c1\u76d8
\u7acb\u5373\u4fee\u6539
The immediate-modification scheme allows updates of an uncommitted transaction to be made to the buffer, or the disk itself, before the transaction commits
redo undo
- redo \u5386\u53f2\u91cd\u6f14
- undo \u9700\u8981\u8bb0\u5f55\u65e5\u5fd7 redo-only\uff0c\u5b8c\u6210\u540e\uff0c\u8bb0\u5f55
"},{"location":"CS/DB/Chapter_19/#check-point","title":"Check Point","text":"
- \u6b63\u5e38\u6267\u884c\u8fc7\u7a0b\u4e2d\u7684\u56de\u6eda
- \u7cfb\u7edf\u5d29\u6e83\u540e\u6062\u590d\u53d1\u73b0\u6ca1\u6709\u7ed3\u675f
fuzzy check point
"},{"location":"CS/DB/Chapter_19/#_4","title":"\u4e8b\u52a1\u56de\u6eda","text":"\u8865\u507f\u65e5\u5fd7\u8bb0\u5f55
"},{"location":"CS/DB/Chapter_19/#_5","title":"19. Recovery","text":""},{"location":"CS/DB/Chapter_19/#_6","title":"\u7f13\u51b2\u533a\u7ba1\u7406","text":"log force \u5c06\u7f13\u51b2\u7684\u65e5\u5fd7\u5f3a\u884c\u5199\u5230Disk
"},{"location":"CS/DB/Chapter_19/#logical-undo","title":"Logical Undo","text":"Redo\u662f\u6309\u7167\u7269\u7406\u6267\u884c
"},{"location":"CS/DB/Chapter_19/#aries","title":"ARIES","text":"
- \u6bcf\u4e2a\u8bb0\u5f55\u4e00\u4e2a\u65e5\u5fd7\u987a\u5e8f\u53f7 LSN
Typically an offset from beginning of log file to allow fast access
- \u5728\u6570\u636e\u9875\u4e2d\u8bb0\u5f55\u4e00\u4e2aLSN - Page LSN
- \u66f4\u65b0\u53d1\u751f\uff0c\u65e5\u5fd7\u7684LSN\u8bb0\u5f55\u8fdb\u53bb
- \u9632\u6b62 \u91cd\u590d\u7684 redo
- Log Record
Special redo-only log record called compensation log record (CLR) used to log actions taken during recovery that never need to be undone
- \u5728\u56de\u6eda\u65f6\uff0c\u6709\u52a9\u4e8e\u8df3\u8fc7\u5df2\u7ecf\u56de\u6eda\u7684\u65e5\u5fd7
Physiological redo
Dirty Page Table
- \u5728\u540e\u53f0\u5468\u671f\u6027\u5199\u56de\uff0c\u800c\u4e0d\u662f\u5728Check Point
\u8bb0\u5f55\u810f\u9875
- Fuzzy Check Point
only records information about dirty pages, and does not require dirty pages to be written out at checkpoint time
"},{"location":"CS/DB/Chapter_19/#_7","title":"\u6d41\u7a0b","text":"
\u5206\u6790
- \u5f97\u5230redo\u7684\u4f4d\u7f6eRedoLSN \u2014\u2014 \u81f3\u5c11\u5728Check Point \u4e4b\u524d\uff0c\u5bf9\u810f\u9875Table\u7684Rec\u53d6Min
- undo-list \u4eceCheck Point \u5f80\u4e0b\u626b\u63cf\uff0c\u5b8c\u5584undo list
- \u66f4\u65b0\u810f\u9875\u8868
Redo
- \u810f\u9875\u8868\uff0c\u6ce8\u610f\u662f\u8ddflog record\u4e2d\u7684LSN\u6bd4\u8f83
- \u78c1\u76d8\u9875
- Undo
"},{"location":"CS/DB/Chapter_2/","title":"Relation","text":"
\u7ea6 228 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
\u00a7 Structure of Relational Databases
\u00a7 Database Schema \u6570\u636e\u5e93\u6a21\u5f0f
- A relation instance r defined over schema R is denoted by r (R)
\u00a7 Keys
\u00a7 Schema Diagrams
\u00a7 Relational Query Languages
\u00a7 The Relational Algebra
"},{"location":"CS/DB/Chapter_2/#structure-of-relational-databases","title":"Structure of Relational Databases","text":""},{"location":"CS/DB/Chapter_2/#attributes","title":"Attributes","text":""},{"location":"CS/DB/Chapter_2/#database-schema","title":"Database Schema \u6570\u636e\u5e93\u6a21\u5f0f","text":"
\u539f\u5b50\u6027 \u2192 \u4e0d\u53ef\u62c6\u5206\uff08\u6570\u7ec4\u3001\u7ed3\u6784\u4f53\u4e4b\u7c7b\u4e0d\u53ef\uff09
The set of allowed values for each attribute is called the domain \uff08\u57df\uff09 of the attribute
The special value null \uff08\u7a7a\u503c\uff09 is a member of every domain. Indicated that the value is \u201cunknown\u201d
\u65e0\u5e8f\u6027\uff0c\u987a\u5e8f\u6ca1\u6709\u5f71\u54cd
schema \u5173\u7cfb\u6a21\u5f0f\uff0clogical structure
instance \u67d0\u4e00\u77ac\u95f4\u7684\u5feb\u7167
"},{"location":"CS/DB/Chapter_2/#keys","title":"Keys","text":""},{"location":"CS/DB/Chapter_2/#database","title":"Database","text":"
super key \u8d85\u7801 \u53ef\u4ee5\u552f\u4e00\u6807\u8bc6
candidate key \u6700\u5c0f\u5355\u5143\u7684\u8d85\u7801
primary key \u7684\u7ea6\u675f\u6761\u4ef6 \u4efb\u610f\u4e00\u4e2a\u5019\u9009\u7801\u90fd\u53ef\u4ee5\u4f5c\u4e3a\u4e3b\u952e\uff1b\u4e0d\u80fd\u662fnull
Foreign
- \\(R_1\\)\u4e2d\u7684\u4e00\u4e2a\u5c5e\u6027\uff0c\u662f\u53e6\u5916\u4e00\u4e2a\u53c2\u7167\\(R_2\\)\u7684 primary key
- \u7ea6\u675f\u6761\u4ef6\u6bd4\u8f83\u5f3a\uff0c\u5fc5\u987b\u662f A\u7684\u5c5e\u6027 B\u7684
primary key
referential integrity constraint \u53c2\u7167\u5b8c\u6574\u6027\u7ea6\u675f
- \u7ea6\u675f\u6761\u4ef6\u8f83\u5f31\uff0c
\u542b\u6709\u591a\u4e2arelation
"},{"location":"CS/DB/Chapter_2/#relation-algebra","title":"Relation Algebra","text":""},{"location":"CS/DB/Chapter_3_4_5/","title":"SQL","text":"\u7ea6 884 \u4e2a\u5b57 355 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 9 \u5206\u949f
"},{"location":"CS/DB/Chapter_3_4_5/#essential","title":"Essential","text":""},{"location":"CS/DB/Chapter_3_4_5/#ddl","title":"DDL","text":"
- A query returns a single table
Create
create table student\n(\n id int,\n name varchar(8) not null,\n ...\n <\u5b8c\u6574\u6027\u7ea6\u675f>\n primary key(id),\n foreign key(..) references department\n);\n
Select
SELECT * FROM Websites \nWHERE xx>15\nAND (country = 'US' or 'CN')\n;\n// \u53bb\u91cd\u590d\nSELECT DISTINCT country FROM Websites;\n// \u81ea\u7136\u8fde\u63a5 \u8003\u8651\u7684\u662f\u4e0d\u540c\u5173\u7cfb\u4e2d\u90fd\u51fa\u73b0\u7684\u5c5e\u6027\uff0c\u53d6\u8fd9\u4e9b\u76f8\u540c\u5c5e\u6027\u90fd\u76f8\u7b49\u7684tuple;\nselect A\nfrom r1 natural join R2 using <attributes>\n// \u6392\u5e8f\norder by salary desc, name asc\n
- The operands of the logical connectives can be expressions involving the comparison operators <, <=, >, >=, =, and <>.
order by (conlumns) ASC|DESC
Insert INTO
INSERT INTO table_name (column1,column2,column3,...)\nVALUES (value1,value2,value3,...);\n\nINSERT INTO table_name\nVALUES (value1,value2,value3,...);\n\ninsert into table1 select * from table1\n\ninsert into instructor\n select ID, name, dept_name, 18000\n from student \n where dept_name = 'Music' and total_cred > 144;\n
Update
where \u9650\u5236\u5f88\u91cd\u8981\uff01\uff01
"},{"location":"CS/DB/Chapter_3_4_5/#dml","title":"DML","text":"UPDATE Table\nSET name = \"666\",Country = 'CN'\nWHERE id = 4;\n
Delete
delete from Table \u5220\u9664\u6240\u6709\u5c5e\u6027\nwhere ...\n// \u5728\u6267\u884c\u4efb\u4f55\u5220\u9664\u4e4b\u524d\u5bf9\u6240\u6709\u5143\u7ec4\u5b8c\u6210\u5904\u7406\u5f88\u91cd\u8981\uff0c\u5426\u5219\u6267\u884c\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u5316\ndelete from instructor\nwhere salary < (select avg (salary) \n from instructor);\n
Drop
drop table r; \u5220\u9664\n
Alter
alter \u64cd\u4f5c\u9488\u5bf9\u7684\u662fattribute
https://www.runoob.com/mysql/mysql-alter.html
alter table r add att Domain\n\n\nalter table r drop att\n
"},{"location":"CS/DB/Chapter_3_4_5/#_1","title":"\u64cd\u4f5c","text":"alter table drop foreign key <\u7ea6\u675f\u540d>;\nalter table takes add constraint tb_id foreign key(id) references student(id);\n
Limit
"},{"location":"CS/DB/Chapter_3_4_5/#_2","title":"\u9644\u52a0\u7684\u64cd\u4f5c","text":""},{"location":"CS/DB/Chapter_3_4_5/#_3","title":"\u66f4\u540d","text":"\u9650\u5236\u9009\u4e2d\u7684\u6570\u76ee\nlimit number;\n
- \u7528\u4e8e\u533a\u5206\u540c\u4e00\u4e2a\u5173\u7cfb\u7684\u7b1b\u5361\u5c14\u79ef
"},{"location":"CS/DB/Chapter_3_4_5/#string","title":"string","text":"select distinct T.name\nfrom instructor as T, instructor as S\nwhere T.salary > S.salary and S.dept_name = \"\"\n
\u4f7f\u7528
LIKE
\u5b57\u7b26\u6765\u5b8c\u6210\u6a21\u5f0f\u5339\u914d
- % \u5339\u914d\u4efb\u610f\u5b57\u7b26\u4e32 \"%dar%\"
- _ \u5339\u914d\u4efb\u610f\u4e00\u4e2a\u5b57\u7b26 \" _ \" \u4e09\u4e2a\u5b57\u7b26
\u7528
escape
\u6765\u5b9a\u4e49\u8f6c\u4e49\u5b57\u7b26"},{"location":"CS/DB/Chapter_3_4_5/#set-operation","title":"\u96c6\u5408 | Set Operation","text":"where building like '%ab\\%cd%' escape '\\'\n// \u5305\u542bab%cd\n
"},{"location":"CS/DB/Chapter_3_4_5/#null","title":"null","text":"// \u81ea\u52a8\u53bb\u91cd\nA union B\nA union all B\n\nA intersect B\n\nA except B\n
- \u7b97\u672f\u8868\u8fbe \u7ed3\u679c\u4e3a\u7a7a
- \u6bd4\u8f83 unknown
"},{"location":"CS/DB/Chapter_3_4_5/#_4","title":"\u805a\u96c6\u51fd\u6570","text":"select count (distinct ID)\nfrom teaches\nwhere semester = 'Spring' and year = 2018;\n
avg min max sum count
group by
having
"},{"location":"CS/DB/Chapter_3_4_5/#nested","title":"Nested | \u5d4c\u5957\u5b50\u67e5\u8be2","text":"select dept_name, avg (salary) as avg_salary\nfrom instructor\ngroup by dept_name;\n\nselect count (*)\nfrom course;\n\nselect dept_name, avg (salary) as avg_salary\nfrom instructor\ngroup by dept_name\nhaving avg (salary) > 42000;\n
select distinct course_id\nfrom section\nwhere semester = 'Fall' and year= 2017 and \ncourse_id in (select course_id\n from section\n where semester = 'Spring' and year= 2018);\n
some
all
exists
select name\nfrom instructor\nwhere salary > some (select salary\n from instructor\n where dept name = 'Biology')\n\nselect distinct\n S.ID,\n S.name\nfrom\n student as S\nwhere\n not exists (\n (\n select\n course_id\n from\n course\n where\n dept_name = 'Biology'\n )\n except\n (\n select\n T.course_id\n from\n takes as T\n where\n S.ID = T.ID\n )\n );\n
unique
not unique
SQL \u4e2dunique\u7528\u4e8e\u7ea6\u675f
select T.course_id\nfrom course as T\nwhere unique ( select R.course_id\n from section as R\n where T.course_id= R.course_id\n and R.year = 2017); \n
select id,name,course_code,score,year\nfrom \n student natural join takes as C\nwhere (id,course_code) in\n(\n select distinct id, course_code\n from takes as T\n where C.id = T.id\n);\n
from
# Error : Every derived table must have its own alias\nselect id,name,course_code,score,year\nfrom \n(\n select id,name,course_code,score,year\n from student natural join takes\n where id = '0001'\n# ' as course ' here is bound to be added\n) as course\nwhere score >= 90;\n
with
with max_budget (value) as \n (select max(budget)\n from department)\n\nselect department.name\nfrom department, max_budget\nwhere department.budget = max_budget.value;\n
Scalar
Scalar \uff08\u6807\u91cf\uff09 subquery is one which is used where a single value is expected
\n
case
"},{"location":"CS/DB/Chapter_3_4_5/#intermediate","title":"Intermediate","text":""},{"location":"CS/DB/Chapter_3_4_5/#join","title":"Join","text":"case \n when pred then result\n when pred then result\n else result\nend\n\nupdate student S\nset score = case\n when ... t.hen\n else 0\nend\n
natural join
\u53ea\u4fdd\u7559\u4e00\u7ec4\u76f8\u540c\u7684\u5143\u7d20; \u4f7f\u7528 on condition \u7684join\u64cd\u4f5c\u5c06\u4f1a\u5b58\u5728\u4e24\u4e2a\u91cd\u590d\u7684condition\u5c5e\u6027"},{"location":"CS/DB/Chapter_3_4_5/#views","title":"Views","text":"natural left/right/full outer join\nusing (attribute)\non condition\n\u4f8b\u5982\nusing course_id\non takes.course_id = student.course_id\n
- \u4e00\u79cd\u865a\u5173\u7cfb
create view v as <query>\n\ncreate view departments_total_salary (dept_name, total_salary) as\n select dept_name , sum salary\n from instructor\n group by dept_name\n
"},{"location":"CS/DB/Chapter_3_4_5/#materialized-views","title":"Materialized Views | \u7269\u5316\u89c6\u56fe","text":"
- Recursive case \u7684expand?
"},{"location":"CS/DB/Chapter_3_4_5/#_5","title":"\u89c6\u56fe\u66f4\u65b0","text":"
- \u7269\u7406\u5b58\u50a8 \uff1a\u4e0d\u9700\u8981\u5728\u6bcf\u6b21\u8c03\u7528\u65f6\u91cd\u65b0\u8fdb\u884c\u67e5\u8be2\u64cd\u4f5c\uff08\u865a\u5173\u7cfb\u9700\u8981\uff09
- If relations used in the query are updated, the materialized view\uff08\u89c6\u56fe\u7ef4\u62a4\uff09 result becomes out of date
- Need to maintain the view, by updating the view whenever the underlying relations are updated.
- \u66f4\u65b0\u4e00\u4e2a\u89c6\u56fe\u5fc5\u987b\u8981\u7ed9\u51fa\u5bf9\u5b9e\u9645\u5173\u7cfb\u7684\u4fee\u6539
Most SQL implementations allow updates only on simple views
"},{"location":"CS/DB/Chapter_3_4_5/#transaction","title":"Transaction | \u4e8b\u52a1","text":"
- The from clause has only one database relation.
- The select clause contains only attribute names of the relation, and does not have any expressions, aggregates, or distinct specification.
- Any attribute not listed in the select clause can be set to null
- The query does not have a group by or having clause.
Atomic transaction
\u4e8b\u52a1\u662f\u7531\u67e5\u8be2\u548c\uff08\u6216\uff09\u66f4\u65b0\u8bed\u53e5\u7684\u5e8f\u5217\u7ec4\u6210\u3002SQL\u8bed\u53e5\u89c4\u5b9a\u5f53\u4e00\u6761\u8bed\u53e5\u5f00\u59cb\u65f6\uff0c\u4e00\u4e2a\u4e8b\u52a1\u5f00\u59cb\u6267\u884c\uff0c\u4e0b\u9762\u7684\u8bed\u53e5\u4f1a\u7ec8\u6b62\u4e00\u4e2a\u4e8b\u52a1
commit work
: \u63d0\u4ea4\u4e8b\u52a1rollback work
: \u56de\u6eda\u4e8b\u52a1\u5728SQL\u7684\u5b9e\u73b0\u4e2d\uff0c\u5f88\u591a\u60c5\u51b5\u4e0b\u90fd\u9ed8\u8ba4\u4e00\u6761\u8bed\u53e5\u81ea\u6210\u4e00\u4e2a\u4e8b\u52a1\uff0c\u4e00\u65e6\u6267\u884c\u5b8c\u6210\u5c31\u4f1a\u63d0\u4ea4
"},{"location":"CS/DB/Chapter_3_4_5/#integrity-constraints","title":"Integrity Constraints","text":"Constraints on a Single Relation
"},{"location":"CS/DB/Chapter_3_4_5/#check-assertion","title":"check & assertion","text":"
- not null
- primary key
- **unique ** ? a super key
- check (P), where P is a predicate
- \u8c13\u8bcd\u68c0\u6d4b
create table section \n(\n course_id varchar (8),\n sec_id varchar (8),\n semester varchar (6),\n year numeric (4,0),\n building varchar (15),\n room_number varchar (7),\n time slot id varchar (4), \n primary key (course_id, sec_id, semester, year),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer'))\n)\n
- assertion\u7684\u7ef4\u62a4\u4ee3\u4ef7\u6bd4\u8f83\u9ad8
"},{"location":"CS/DB/Chapter_3_4_5/#referential-intergrity","title":"referential intergrity | \u53c2\u7167\u5b8c\u6574\u6027","text":"create assertion <assertion-name> check <predicate>;\n\n// \u63d2\u5165\u4fee\u6539tuple\u65f6\u8981check\uff0ctime_slot\u6539\u53d8\u65f6\u4e5f\u8981check\ncheck (time_slot_id in (select time_slot_id from time_slot) )\n\n\n\ncreate assertion credits_earned_constraint check (\n not exists (\n select\n ID\n from\n student\n where\n tot cred <> (\n select\n coalesce(sum(credits), 0)\n from\n takes natural\n join course\n where\n student.ID = takes.ID\n and grade is not null\n and grade <> 'F'\n )\n )\n);\n
\u4e0d\u540c\u4e8e\u5916\u7801\u7ea6\u675f\uff0c\u53c2\u7167\u5b8c\u6574\u6027\u7ea6\u675f\u5e76\u4e0d\u8981\u6c42\u76ee\u6807\u5c5e\u6027\u662f\u67d0\u4e2a\u5173\u7cfb\u7684\u4e3b\u7801\u3002\u4f46\u662f\uff0cforeign key \u8981\u6c42\u81f3\u5c11\u662f\u5019\u8865\u7801
"},{"location":"CS/DB/Chapter_3_4_5/#_6","title":"\u589e\u52a0\u4e0e\u5220\u9664","text":"foreign key () references _\non delete set NULL\n// \u7ea7\u8054\non delete cascade\non update cascade\n
"},{"location":"CS/DB/Chapter_3_4_5/#data-type-schema","title":"Data Type & Schema","text":""},{"location":"CS/DB/Chapter_3_4_5/#data","title":"Data","text":"ALTER TABLE <\u6570\u636e\u8868\u540d> ADD CONSTRAINT <\u5916\u952e\u540d>\nFOREIGN KEY(<\u5217\u540d1>) REFERENCES <\u4e3b\u8868\u540d> (<\u5217\u540d2>);\n# \u6ce8\u610f\uff0c\u5916\u952e\u540d\u662f\u7528\u6237\u5b9a\u4e49\u7684\uff0c\n\nalter table takes add constraint tb_id foreign key(id) references student(id);\n
Time
\u9ed8\u8ba4\u503c
"},{"location":"CS/DB/Chapter_3_4_5/#index","title":"Index","text":"create table student\n(\n ID varchar(5),\n tot_cred numeric(3,0) default 0\n)\n
"},{"location":"CS/DB/Chapter_3_4_5/#large-object","title":"Large Object | \u5927\u5bf9\u8c61\u7c7b\u578b","text":"create index <name> on <relation name> (attribute);\n\ncreate table student(\n ID varchar (5),\n name varchar (20) not null,\n dept_name varchar (20),\n tot_cred numeric (3, 0),\n default 0,\n primary key (ID)\n);\ncreate index studentID_index on student(ID)\n// \u5220\u9664\u7d22\u5f15\ndrop index student_id on student;\n\nThe query:\nselect *\n from student\n where ID = '1001'\ncan be executed by using the index to find the required record, without\nlooking at all records of studen\n
bookreview clob (2KB)\nimage blob (10MB)\nmovie blob (2GB)\n
"},{"location":"CS/DB/Chapter_3_4_5/#user-defined-type","title":"User-defined Type","text":"
- When a query returns a large object, a pointer \uff08\u5b9a\u4f4d\u5668\uff09 is returned rather than the large object itself.
\u8fd9\u91cc\u4ecb\u7ecd\u7684\u662fdistinct Type
create type Dollars as numeric (12,2) final\n\ncreate domain DDollars as numeric (12,2) not null \nconstraint Dollars_test check ...;\n\ncreate table department\n (\n dept_name varchar (20)\n building varchar (15)\n budget Dollars\n );\n
cast \u6570\u503c\u8f6c\u6362
cast(department.budget to numeric(12,2))
\u5bf9\u4e8e\u5f3a\u7c7b\u578b\u68c0\u67e5\uff0c\u5fc5\u987b\u8fd9\u6837\u5904\u7406
"},{"location":"CS/DB/Chapter_3_4_5/#domain","title":"Domain","text":""},{"location":"CS/DB/Chapter_3_4_5/#authorization","title":"Authorization","text":"grant / revoke <privileges list>\non <\u5173\u7cfb/\u89c6\u56fe>\nto <user list>\n\ngrant update(dept)\non department\nto Alan\n
"},{"location":"CS/DB/Chapter_3_4_5/#role","title":"Role","text":"
- a
user id
public
, which allows all valid users the privilege granted- A
role
- \u521b\u5efa\u4e00\u4e2a role\uff0c\u8fd9\u4e2arole\u53ef\u4ee5\u6388\u4e88\u7ed9\u5176\u4ed6role/user\uff0c\u4e5f\u53ef\u4ee5\u63a5\u53d7\u6388\u6743(\u7ed9\u6211\u7684\u611f\u89c9\u50cf\u662f\u4e00\u4e2aTag)
"},{"location":"CS/DB/Chapter_3_4_5/#_7","title":"\u89c6\u56fe\u7684\u6388\u6743","text":"create role instructor\n\ngrant class to instructor\n
"},{"location":"CS/DB/Chapter_3_4_5/#_8","title":"\u6a21\u5f0f\u7684\u6388\u6743","text":""},{"location":"CS/DB/Chapter_3_4_5/#_9","title":"\u6743\u9650\u8f6c\u79fb","text":"
- \u89c6\u56fe\u7684\u521b\u5efa\u8005\u4e0d\u9700\u8981\u89c6\u56fe\u4e0a\u7684\u6240\u6709\u6743\u9650
with grant option
"},{"location":"CS/DB/Chapter_3_4_5/#_10","title":"\u6743\u9650\u6536\u56de","text":"grant select on depart to Aimit with grant option\n
- \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6743\u9650\u7684\u6536\u56de\u662f\u7ea7\u8054\u7684
"},{"location":"CS/DB/Chapter_3_4_5/#advanced","title":"Advanced","text":""},{"location":"CS/DB/Chapter_3_4_5/#_11","title":"\u7a0b\u5e8f\u8bed\u8a00","text":""},{"location":"CS/DB/Chapter_3_4_5/#odbc","title":"ODBC","text":""},{"location":"CS/DB/Chapter_3_4_5/#jdbc","title":"JDBC","text":"revoke select on department from Amit , Satoshi cascade\n\nrevoke select on department from Amit , Satoshi restrict\n
- try \u5c06\u5f02\u5e38\u629b\u51fa \u5230 catch
Prepared Statement
SQL Injection
Metadata Features
Transaction Control in JDBC
"},{"location":"CS/DB/Chapter_3_4_5/#sqlj","title":"SQLJ","text":""},{"location":"CS/DB/Chapter_3_4_5/#embedded","title":"Embedded","text":"# \u8fde\u63a5\u5230\u6570\u636e\u5e93\nEXEC SQL connect to server user user-name using password;\n# \u5bbf\u4e3b\u53d8\u91cf\u7528 : \u52a0\u4ee5\u533a\u5206\n# They are preceded by a colon (:) to distinguish from SQL variables (e.g., :credit_amount )\n# must be declared within DECLARE section,\nEXEC-SQL BEGIN DECLARE SECTION\nint credit-amount ;\nEXEC-SQL END DECLARE SECTION;\n
"},{"location":"CS/DB/Chapter_3_4_5/#function-and-procedures","title":"\u51fd\u6570\u548c\u8fc7\u7a0b | function and procedures","text":""},{"location":"CS/DB/Chapter_3_4_5/#trigger","title":"\u89e6\u53d1\u5668 | Trigger","text":"EXEC SQL\n# \u7528c\u4f5c\u4e3a\u6807\u8bc6\n declare c cursor for \n select ID, name\n from student\n where tot_cred > :credit_amount\nEND_EXEC\n\nEXEC SQL open c ;\n
- **Event : ** delete \u3001 insert \u3001update(
create trigger <trigger name> after <Event> of <relation> on <attribute>
)- before \u89e6\u53d1 \u7ef4\u62a4\u5b8c\u6574\u6027\u7ea6\u675f\uff1b\u6709\u52a9\u4e8e\u5916\u952e\u7684\u63d2\u5165
- after \u89e6\u53d1
TIPS\uff1a
IN MySQL, \u4e0b\u9762\u7684\u8bed\u53e5\u662f\u4e0d\u5b58\u5728\u7684\uff0c\u8981\u4f7f\u7528\u5173\u952e\u5b57
old
new
\u6765\u8868\u5f81referencing new row as nrow;\nreferencing old row as orow;\n
create trigger <trigger name> after <Event> on <relation>\n referencing new row as nrow;\n referencing old row as orow;\n# \u6307\u5b9a\u4e3a\u884c\u7ea7\u89e6\u53d1\uff0c\u5bf9\u4e8e\u6bcf\u4e00\u884c\u89e6\u53d1\u7684tuple\u90fd\u6267\u884c\u4e0b\u8ff0\u884c\u4e3a\nfor each row\nwhen ( condition )\n begin atmotic\n end;\n
"},{"location":"CS/DB/Chapter_3_4_5/#_12","title":"\u4f55\u65f6\u4e0d\u5e94\u4f7f\u7528\u89e6\u53d1\u5668","text":""},{"location":"CS/DB/Chapter_3_4_5/#function","title":"Function","text":"# \u5bf9\u5b66\u5206\u7684\u66f4\u65b0\ncreate trigger credits_earned\nafter\nupdate\n of takes on (grade) referencing new row as nrow referencing old row as orow for each row\n when nrow.grade <> 'F'\n and nrow.grade is not null\n and (\n orow.grade = 'F'\n or orow.grade is null\n ) begin atomic\nupdate\n student\nset\n tot_cred = tot_cred + (\n select\n credits\n from\n course\n where\n course.course_id = nrow.course_id\n )\nwhere\n student.id = nrow.id;\nend;\n
create function dept_count (dept_name varchar(20))\nreturns integer\n\nbegin\n declare d_count integer;\n select count (* ) into d_count\n from instructor\n where instructor.dept_name = dept_name\n return d_count;\nend\n\n# The function dept_count can be used to find the department names and budget of all departments with more that 12 instructors.\nselect dept_name, budget\n from department\n where dept_count (dept_name ) > 12\n
"},{"location":"CS/DB/Chapter_3_4_5/#procedure","title":"Procedure","text":""},{"location":"CS/DB/Chapter_3_4_5/#_13","title":"\u4f8b\u9898","text":""},{"location":"CS/DB/Chapter_3_4_5/#trigger_1","title":"Trigger","text":"
- \u6ce8\u610f\u4e0b\u9762\u7684 return \u548c returns
- \u63d2\u5165\u591a\u884c\u7684\u4e00\u79cd\u7528\u6cd5
insert into select from
"},{"location":"CS/DB/Chapter_6/","title":"Chapter 6 | ER Model","text":"create trigger insert_depositor\nafter insert on depositor \nreferencing new row as nrow\nfor each row \nbegin\ninsert into\n select branch_name, customer_name\n from depositor, account\n where nrow.account_number = account.account_number\nend;\n\ncreate trigger insert_customer\nafter insert on customer\nreferencing new row as nrow\nfor each row \nbegin\ninsert into\n select branch_name, customer_name\n from depositor, account\n where nrow.account_number = depositor.account_number\nend;\n
\u7ea6 86 \u4e2a\u5b57
"},{"location":"CS/DB/Chapter_6/#how-to-draw-a-er-graph","title":"How to draw a ER graph","text":""},{"location":"CS/DB/Chapter_6/#_1","title":"\u57fa\u6570\u8868\u793a","text":""},{"location":"CS/DB/Chapter_6/#weak-entity","title":"Weak Entity","text":""},{"location":"CS/DB/Chapter_6/#_2","title":"\u8f6c\u5316","text":"\u591a\u503c\u5c5e\u6027
\u591a\u5bf9\u4e00
"},{"location":"CS/DB/Chapter_6/#_3","title":"\u5176\u4ed6\u7279\u6027","text":""},{"location":"CS/DB/Chapter_6/#_4","title":"\u7279\u5316","text":"
- \u90e8\u5206\u53ef\u80fd\u4f1a\u51fa\u73b0null
"},{"location":"CS/DB/Chapter_6/#_5","title":"\u6cdb\u5316","text":""},{"location":"CS/DB/Chapter_6/#-partial-generalization-is-the-default","title":"- Partial generalization is the default.","text":""},{"location":"CS/DB/Chapter_7/","title":"Chapter 7 Relational Database Design","text":"
- \u91cd\u53e0\u7279\u5316 Overlapping \u4e00\u4e2a\u5b9e\u4f53\u96c6\u53ef\u80fd\u5c5e\u4e8e\u591a\u4e2a\u7279\u5316\u5b9e\u4f53\u96c6
- \u4e0d\u76f8\u4ea4\u7279\u5316 \u5fc5\u987b\u5c5e\u4e8e\u81f3\u591a\u4e00\u4e2a\u7279\u5316\u5b9e\u4f53\u96c6
\u7ea6 763 \u4e2a\u5b57 11 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 4 \u5206\u949f
"},{"location":"CS/DB/Chapter_7/#features-of-good-relational-design","title":"Features of Good Relational Design","text":"\u4e0d\u89c4\u8303\u7684\u5173\u7cfb\u6a21\u5f0f
\u540c\u65f6\u4e5f\u662f\u8981\u53bbdecompose\u4e00\u4e2a\u5173\u7cfb\u6a21\u5f0f\u7684\u539f\u56e0
\u51fd\u6570\u4f9d\u8d56 | functional dependency
graph\n 2[candidate key]\n 3[primary key]\n subgraph \"super key\"\n 2\n 2 -- one -->3\n end
\u65e0\u635f\u8fde\u63a5\u7684\u5b9a\u4e49 \u81ea\u7136\u8fde\u63a5\u4e4b\u540e\u7b49\u4e8e\u539f\u7ec4\u5408
\u65e0\u635f\u8fde\u63a5\u7684\u5206\u89e3
\u5206\u89e3 \u4e4b\u540e \u81f3\u5c11\u6709\u4e00\u4e2a\u516c\u5171\u5c5e\u6027\uff0c\u4e14\u662f\u5176\u4e2d\u4e00\u4e2a\u5173\u7cfb\u7684
key
(\u4e0d\u662fprimary
)\u8fd9\u91cc\u662f\u4e00\u4e2a\u5145\u5206\u6761\u4ef6\uff0c\u800c\u4e0d\u662f\u5fc5\u8981\u7684\uff1a
\\(\u8bc1\u660e\u7684\u601d\u8def\\\\ R_1\\cap R_2\\to R_1 \\\\or \\\\ R_1\\cap R_2\\to R_2\\)\u200b
- lossy decomposition
\u539f\u56e0\u5728\u4e8ename\u5c5e\u6027\u4e0d\u662f\u4e00\u4e2a\u5019\u8865\u952e\uff0c\u4e0d\u80fd\u51b3\u5b9a\u5176\u4ed6\u5c5e\u6027
"},{"location":"CS/DB/Chapter_7/#functional-dependency","title":"Functional Dependency","text":"
- \u53ef\u4ee5\u6839\u636e\u81ea\u7136\u8fde\u63a5\u540e\u80fd\u5426\u6062\u590d\u6765\u5224\u65ad\uff08\u6709\u53ef\u80fd\u4f1a\u53d8\u591a/\u5c11\uff09
\u5c31\u662f\u4e00\u79cd constraint
Trivial case
"},{"location":"CS/DB/Chapter_7/#closure","title":"Closure | \u95ed\u5305","text":""},{"location":"CS/DB/Chapter_7/#armstrongs-axioms","title":"\u516c\u7406 | Armstrong`s Axioms","text":"
- \u6ca1\u6709\u5b9e\u9645\u7684\u4fe1\u606f\u5b58\u5728
- \u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u9690\u542b\u8fd9\u6837\u7684\u5047\u8bbe\uff1a\u8fd9\u4e2a\u51fd\u6570\u4f9d\u8d56\u4e0d\u662fTrivial\u7684\uff08\u975e\u5e73\u51e1\u7684\uff09
- \u63a8\u8bba
$$ 1 \\alpha \\to \\beta,\\alpha\\to\\gamma \\Rightarrow \\alpha\\to\\alpha\\beta,\\alpha\\beta\\to\\beta\\gamma\\Rightarrow\\alpha\\to\\beta\\gamma \\ 2 apply tansitive law \\ 3 apply tansitive law \\ $$
- \u6d88\u53bb\u5f8b \u6d88\u53bb\u67d0\u4e00\u8fb9\u7684\u516c\u5171\u5c5e\u6027
Example
"},{"location":"CS/DB/Chapter_7/#_1","title":"\u5c5e\u6027\u7684\u95ed\u5305","text":"
- \u5c31\u662f\u67d0\u4e2a\u5c5e\u6027A\u53ef\u4ee5\u51b3\u5b9a\u5176\u4ed6\u54ea\u4e9b\u5c5e\u6027\uff0c\u8fd9\u4e9b\u5c5e\u6027\u5c31\u662fA\u7684\u95ed\u5305
graph LR\nA --> B\nB-->C\nB-->D
uses
- \u7528\u4e8e\u8ba1\u7b97\u51fd\u6570\u4f9d\u8d56 F \u7684\u95ed\u5305
"},{"location":"CS/DB/Chapter_7/#canonical-cover","title":"Canonical Cover | \u6b63\u5219\u8986\u76d6","text":"
- \u5316\u7b80\uff0c\u4f7f\u5f97\u4e0d\u5b58\u5728\u591a\u4f59\u7684\u5c5e\u6027\u548c\u51fd\u6570\u4f9d\u8d56
- Extraneous Attributes(\u65e0\u5173\u5c5e\u6027)
Example
\u7b2c\u4e00\u79cd\u65b9\u6cd5\u5f80\u5f80\u662f\u8ba1\u7b97\u7a0b\u5e8f\u4f7f\u7528\u7684\uff0c\u4eba\u5de5\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\u5e76\u4e0d\u9ad8\u6548
example "},{"location":"CS/DB/Chapter_7/#boyce-codd-normal-form-bcnf","title":"Boyce-Codd Normal Form | BCNF","text":"
- \u4efb\u4f55\u4e00\u6761\u51fd\u6570\u4f9d\u8d56\u8981\u4e48\u662f\u5e73\u51e1\u7684\uff0c\u8981\u4e48\u5de6\u8fb9\u662fkey == \u4efb\u4f55\u4e00\u6761\u975e\u5e73\u51e1\u7684\u5de6\u8fb9\u90fd\u662f
super key
Warning
\u4e0d\u662f\u6307\\(\\alpha\\to\\beta \u4e2d\u7684\\alpha\\)\u662fkey\u7684\u4e00\u90e8\u5206\uff0c\u800c\u662f\u5b83\u672c\u8eab\u5c31\u53ef\u4ee5\u51b3\u5b9a\u5176\u4ed6\u6240\u6709
example "},{"location":"CS/DB/Chapter_7/#how-good-is-bcnf","title":"How good is BCNF","text":"
- \u8f6c\u6362\u4e3aBCNF
- \u628a\u8fdd\u53cd\u5b9a\u4e49\u7684Func\u62ff\u51fa\u6765\uff0c\u4fdd\u6301\u65e0\u635f\u53bb\u5206\u89e3
"},{"location":"CS/DB/Chapter_7/#dependency-preservation","title":"Dependency Preservation","text":"
- \u662fBCNF\u4f46\u662f\u4ecd\u7136\u5b58\u5728\u95ee\u9898 <= \u5b58\u5728\u591a\u503c\u4f9d\u8d56\u4e14\u8fd8\u6709\u5176\u4ed6\u5c5e\u6027
- \u4f7f\u7528 4-NF\uff0c \u89c1 \u591a\u503c\u4f9d\u8d56
\u5b9a\u4e49
example
- \u4e0d\u9700\u8981\u5728\u5206\u89e3\u540e\u7684\\(R_i\\)\u4e4b\u95f4\u5efa\u7acb\u65b0\u7684\u5173\u8054\uff08\u901a\u8fc7\u81ea\u7136\u8fde\u63a5\u91cd\u65b0\u5efa\u7acb\u5c5e\u6027\u95f4\u7684\u8054\u7cfb\uff09\u5c31\u53ef\u4ee5\u5f97\u5230\u6240\u6709\u7684
DF\uff08Dependency Func\uff09
\\((F_1 \\cup F_2)^+ <>F^+\\)
execise- BCNF\u5206\u89e3\u7684\u65f6\u5019\u4e0d\u9700\u8981\u53bb\u7ba1\u51fd\u6570\u4f9d\u8d56\u7684\u95ee\u9898
"},{"location":"CS/DB/Chapter_7/#third-normal-form","title":"Third Normal Form","text":"\u5b9a\u4e49
\u7b97\u6cd5
\u751f\u6210\u6b63\u5219\u8986\u76d6
\u5bf9\u6240\u6709\u7684\u51fd\u6570\u4f9d\u8d56\u751f\u6210\u5173\u7cfb\u6a21\u5f0f
\u68c0\u6d4b\u662f\u5426\u6709\u5173\u7cfb\u6a21\u5f0f\u5305\u542b
candidate key
\uff0c\u4e00\u5b9a\u8981\u6ce8\u610f\u81ea\u59cb\u81f3\u7ec8\u6ca1\u6709\u5728\u51fd\u6570\u4f9d\u8d56\u4e2d\u51fa\u73b0\u7684\u5c5e\u6027\uff01example
\\[ schema(A,B,C,D,E,G) \\\\A\\to BCD \\\\BC\\to DE \\\\B\\to D \\\\D\\to A \\\\G\u8fd9\u4e2a\u5c5e\u6027\u6ca1\u6709\u5728\u4e0a\u8ff0\u51fd\u6570\u4f9d\u8d56\u4e2d\u51fa\u73b0 \\]Q1 : \u6c42BCNF
\u901a\u8fc7\u6c42A\u3001BC\u3001B\u3001D\u7684\u95ed\u5305\uff0c\u53ef\u4ee5\u53d1\u73b0\u4ed6\u4eec\u90fd\u76f8\u540c(ABCDE)\uff0c\u8fd9\u4e2a\u65f6\u5019\u4e00\u5b9a\u4e0d\u8981\u60f3\u5f53\u7136\u7684\u8ba4\u4e3a\u4ed6\u4eec\u6ee1\u8db3BCNF\u7684\u6761\u4ef6\uff0c\u9898\u4e2d\u7684FG\u662f\u5b64\u7acb\u7684\u5143\u7d20
\\(R_1=(A,B,C,D)\\ left = AEG\\) \u7531\u4e8e\\(A^+=ABCDE,\u6240\u6709\u8fd9\u91cc\u6709\u51fd\u6570\u4f9d\u8d56A\\to E\u6210\u7acb\\) \\(R_2=(A,E),R_3=(A,G)\\)
"},{"location":"CS/DB/Chapter_7/#multivalued-dependencies","title":"Multivalued Dependencies","text":"definition
\u51fd\u6570\u4f9d\u8d56\u662f\u591a\u503c\u4f9d\u8d56\u7684\u7279\u6b8a\u5f62\u5f0f
"},{"location":"CS/DB/Chapter_7/#4-nf","title":"4 NF","text":"
- \u5e73\u51e1\u7684\u591a\u503c\u4f9d\u8d56
- \u03b1\u662f
super key
ER graph
"},{"location":"CS/DB/Chapter_7/#process","title":"Process","text":"
- \u8bbe\u8ba1ER Graph\uff0c\u7531ER\u56fe\u8f6c\u4e3a\u5173\u7cfb\u6a21\u5f0f\uff0c\u4e0d\u9700\u8981\u518d\u53bbnormalize
- \u4e0d\u8bbe\u8ba1\uff0c\u4e4b\u540e\u518d\u53bbnormalize
\u5f15\u5165\u5197\u4f59\uff0c\u4fdd\u6301\u6027\u80fd
"},{"location":"CS/DIP/","title":"Index","text":"\u7ea6 185 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
\u6559\u5e08\uff1a\u5b8b\u660e\u9ece
\u8fd9\u4e2a\u8bfe\u53ea\u6709\u524d\u51e0\u8282\u8bfe\u548c\u6700\u540e\u4e00\u8282\u8bfe\u6765\u7684\u4eba\u591a\u4e00\u70b9\uff08\u56e0\u4e3a\u4f1a\u5212\u91cd\u70b9\uff09 \u4e0d\u5f97\u4e0d\u8bf4\u9ece\u53d4\u7684\u58f0\u97f3\u8fd8\u662f\u6709\u70b9\u50ac\u7720\u7684
\u6700\u540e\u8bb2\u7684\u5f88\u591a\u4e1c\u897f\u5f53\u65f6\u65e0\u6cd5\u7406\u89e3\uff0c\u5b66\u4e86\u4e00\u4e9bAI\u4e4b\u540e\u56de\u5934\u770b\u611f\u89c9\u5f53\u65f6\u8bb2\u7684\u8fd8\u633a\u591a\u7684\uff0c\u6709\u4e9b\u4e1c\u897f\u86ee\u6709\u7528\u7684
\u5173\u4e8e\u8003\u8bd5\uff1a
\u6700\u540e\u590d\u4e60\u8d77\u6765\u4e1c\u897f\u8fd8\u633a\u591a\uff0c\u53c8\u662f\u95ed\u5377\uff0c\u4e34\u65f6\u80cc\u5f88\u6709\u53ef\u80fd\u8bb0\u5fc6\u4e0d\u5b8c\u5168\uff0c\u5bfc\u81f4\u8003\u8bd5\u7684\u65f6\u5019\u6a21\u68f1\u4e24\u53ef\uff0c\u7b80\u7b54\u9898\u5199\u7684\u4e1c\u4e00\u5757\u3001\u897f\u4e00\u5757\uff08\u5c31\u662f\u5728\u8bf4\u6211\u81ea\u5df1\uff09
98\u4e0a\u9762\u6709\u633a\u591a\u5386\u5e74\u5377\uff0c\u53ef\u4ee5\u53bb\u62df\u5408\u4e00\u4e0b\uff1b\u5370\u8c61\u4e2d\u5f53\u65f6\u8003\u7684\u5f88\u591a\u90fd\u5728\u5386\u5e74\u5377\u4e2d\u51fa\u73b0\u8fc7
"},{"location":"CS/DIP/DIP_Review/","title":"\u671f\u672b\u590d\u4e60","text":""},{"location":"CS/DIP/DIP_Review/#introduction","title":"Introduction","text":""},{"location":"CS/DIP/DIP_Review/#ch1","title":"Ch1","text":"
- \u4e0d\u540c\u5f62\u5f0f\u7684\u6210\u50cf
\u7ea6 8764 \u4e2a\u5b57 23 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 44 \u5206\u949f
"},{"location":"CS/DIP/DIP_Review/#_1","title":"* \u6210\u50cf\u8fc7\u7a0b","text":""},{"location":"CS/DIP/DIP_Review/#_2","title":"\u5149\u5708\u5bf9\u4e8e\u6210\u50cf\u7684\u5f71\u54cd","text":"(1)\u5f53\u4f7f\u7528\u6570\u7801\u76f8\u673a\u62cd\u6444\u666f\u7269\u65f6\uff0c\u666f\u7269\u53cd\u5c04\u7684\u5149\u7ebf\u901a\u8fc7\u6570\u7801\u76f8\u673a\u7684\u955c\u5934\u900f\u5c04\u5230CCD\u4e0a\u3002\n(2)\u5f53CCD\u66dd\u5149\u540e\uff0c\u5149\u7535\u4e8c\u6781\u7ba1\u53d7\u5230\u5149\u7ebf\u7684\u6fc0\u53d1\u800c\u91ca\u653e\u51fa\u7535\u8377\uff0c\u751f\u6210\u611f\u5149\u5143\u4ef6\u7684\u7535\u4fe1\u53f7\u3002\n(3) CCD\u63a7\u5236\u82af\u7247\u5229\u7528\u611f\u5149\u5143\u4ef6\u4e2d\u7684\u63a7\u5236\u4fe1\u53f7\u7ebf\u8def\u5bf9\u53d1\u5149\u4e8c\u6781\u7ba1\u4ea7\u751f\u7684\u7535\u6d41\u8fdb\u884c\u63a7\u5236\uff0c\u7531\u7535\u6d41\u4f20\u8f93\u7535\u8def\u8f93\u51fa\uff0cCCD\u4f1a\u5c06\u4e00\u6b21\u6210\u50cf\u4ea7\u751f\u7684\u7535\u4fe1\u53f7\u6536\u96c6\u8d77\u6765\uff0c\u7edf\u4e00\u8f93\u51fa\u5230\u653e\u5927\u5668\u3002\n(4)\u7ecf\u8fc7 \u653e\u5927\u548c\u6ee4\u6ce2\u540e \u7684\u7535\u4fe1\u53f7\u88ab\u4f20\u9001\u5230ADC\uff0c\u7531ADC\u5c06\u7535\u4fe1\u53f7\uff08\u6a21\u62df\u4fe1\u53f7\uff09\u8f6c\u6362\u4e3a\u6570\u5b57\u4fe1\u53f7\uff0c\u6570\u503c\u7684\u5927\u5c0f\u548c\u7535\u4fe1\u53f7\u7684\u5f3a\u5ea6\u4e0e\u7535\u538b\u7684\u9ad8\u4f4e\u6210\u6b63\u6bd4\uff0c\u8fd9\u4e9b\u6570\u503c\u5176\u5b9e\u4e5f\u5c31\u662f\u56fe\u50cf\u7684\u6570\u636e\u3002\n(5)\u6b64\u65f6\u8fd9\u4e9b\u56fe\u50cf\u6570\u636e\u8fd8\u4e0d\u80fd\u76f4\u63a5\u751f\u6210\u56fe\u50cf\uff0c\u8fd8\u8981\u8f93\u51fa\u5230DSP\uff08\u6570\u5b57\u4fe1\u53f7\u5904\u7406\u5668\uff09\u4e2d\uff0c\u5728DSP\u4e2d\uff0c\u5c06\u4f1a\u5bf9\u8fd9\u4e9b\u56fe\u50cf\u6570\u636e\u8fdb\u884c\u8272\u5f69\u6821\u6b63\u3001\u767d\u5e73\u8861\u5904\u7406\uff0c\u5e76\u7f16\u7801\u4e3a\u6570\u7801\u76f8\u673a\u6240\u652f\u6301\u7684\u56fe\u50cf\u683c\u5f0f\u3001\u5206\u8fa8\u7387\uff0c\u7136\u540e\u624d\u4f1a\u88ab\u5b58\u50a8\u4e3a\u56fe\u50cf\u6587\u4ef6\u3002\n(6)\u5f53\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u56fe\u50cf\u6587\u4ef6\u5c31\u4f1a\u88ab\u4fdd\u5b58\u5230\u5b58\u50a8\u5668\u4e0a,\u6211\u4eec\u5c31\u53ef\u4ee5\u6b23\u8d4f\u4e86\u3002\n
\u5149\u5708\u5b54\u5f84\u2f24\u7684\u65f6\u5019\uff0c\u4f1a\u5bfc\u81f4\u6a21\u7cca\uff1b
\u5149\u5708\u5b54\u5f84\u8fc7\u2f29\u7684\u65f6\u5019\uff0c\u53ef\u901a\u8fc7\u7684\u5149\u7ebf\u5c31\u5f88\u5c11\uff0c\u5bfc\u81f4\u5149\u5f3a\u592a\u5f31\uff0c\u540c\u65f6\u5f53\u5b54\u5f84\u2f29\u5230\u2f00\u5b9a\u7a0b\u5ea6\u65f6\uff0c\u4f1a\u4ea7\u2f63\u884d\u5c04\u73b0\u8c61\u3002
"},{"location":"CS/DIP/DIP_Review/#_3","title":"\u5f25\u6563\u5706\u7684\u5b9a\u4e49","text":"\u901a\u8fc7\u4f7f\u2f64\u900f\u955c\u53ef\u4ee5\u4f1a\u805a\u66f4\u591a\u7684\u5149\u7ebf\u5230\u2f00\u4e2a\u6210\u50cf\u70b9\uff0c\u53ea\u662f\u53ea\u6709\u5728\u7279\u6b8a\u7684\u4f4d\u7f6e\u4e0a\u624d\u80fd\u8fbe\u5230\u8fd9\u4e2a\u2f6c\u6807\uff0c\u4f4d\u4e8e\u5408\u9002\u8ddd\u79bb\u7684\u7269\u4f53\u70b9\u53ef\u4ee5\u6210\u6e05\u6670\u50cf\uff0c\u5176\u4ed6\u7684\u70b9\u5219\u4f1a\u4ea7\u2f63\u5f25\u6563\u5706\u3002\u5f25\u6563\u5706\u662f\u6307\u5728\u7126\u70b9\u524d\u540e\uff0c\u5149\u7ebf\u5f00\u59cb\u805a\u96c6\u548c\u6269\u6563\uff0c\u70b9\u7684\u5f71\u50cf\u53d8\u6a21\u7cca\uff0c\u5f62\u6210\u2f00\u4e2a\u6269\u2f24\u7684\u5706\u3002
\u5982\u679c\u5f25\u6563\u5706\u7684\u76f4\u5f84\u2f29\u4e8e\u2f08\u773c\u7684\u9274\u522b\u80fd\u2f12\uff0c\u5728\u2f00\u5b9a\u8303\u56f4\u5185\u5b9e\u9645\u5f71\u50cf\u4ea7\u2f63\u7684\u6a21\u7cca\u662f\u4e0d\u80fd\u8fa8\u8ba4\u7684\u3002\u4e0d\u80fd\u8fa8\u8ba4\u7684\u76f4\u5f84\u53eb\u505a\u5bb9\u8bb8\u5f25\u6563\u5706\u3002
"},{"location":"CS/DIP/DIP_Review/#_4","title":"**\u5149\u5708\u5bf9\u4e8e\u666f\u6df1\u7684\u5f71\u54cd","text":"\u7126\u70b9\u524d\u540e\u5404\u6709\u2f00\u4e2a\u5bb9\u8bb8\u5f25\u6563\u5706\uff0c\u4ed6\u4eec\u4e4b\u95f4\u7684\u8ddd\u79bb\u53eb\u505a\u666f\u6df1\u3002\u666f\u6df1\u968f\u955c\u5934\u7684\u7126\u8ddd\u3001\u5149\u5708\u503c\u3001\u62cd\u6444\u8ddd\u79bb\u2f7d\u53d8\u5316
(1)\u3001\u955c\u5934\u5149\u5708 \u5149\u5708\u8d8a\u2f24\uff0c\u666f\u6df1\u8d8a\u2f29\uff1b\u5149\u5708\u8d8a\u2f29\uff0c\u666f\u6df1\u8d8a\u2f24\uff1b (2)\u3001\u955c\u5934\u7126\u8ddd \u955c\u5934\u7126\u8ddd\u8d8a\u2ed3\uff0c\u666f\u6df1\u8d8a\u2f29\uff1b\u7126\u8ddd\u8d8a\u77ed\uff0c\u666f\u6df1\u8d8a\u2f24\uff1b (3)\u3001\u62cd\u6444\u8ddd\u79bb \u8ddd\u79bb\u8d8a\u8fdc\uff0c\u666f\u6df1\u8d8a\u2f24\uff1b\u8ddd\u79bb\u8d8a\u8fd1\uff0c\u666f\u6df1\u8d8a\u2f29
"},{"location":"CS/DIP/DIP_Review/#_5","title":"\u5f69\u2f8a\u548c\u6d88\u2f8a\u7684\u5b9a\u4e49","text":"\u5f69\u2f8a\u662f\u6307\u7ea2\u3001\u2ee9\u3001\u84dd\u7b49\u5355\u2f8a\u4ee5\u53ca\u5b83\u4eec\u7684\u6df7\u5408\u2f8a\u3002\u5f69\u2f8a\u7269\u4f53\u5bf9\u5149\u8c31\u5404\u6ce2\u2ed3\u7684\u53cd\u5c04\u5177\u6709\u9009\u62e9\u6027\uff0c\u6240\u4ee5\u5b83\u4eec\u5728\u2f69\u5149\u7167\u5c04\u4e0b\u5448\u73b0\u51fa\u4e0d\u540c\u7684\u989c\u2f8a\u3002
\u6d88\u2f8a\uff0c\u4e5f\u5c31\u662f\u7070\u5ea6\uff0c\u662f\u6307\u2f69\u2f8a\uff0c\u2fca\u2f8a\u4ee5\u53ca\u5404\u79cd\u6df1\u6d45\u4e0d\u540c\u7684\u7070\u2f8a\u3002\u6d88\u2f8a\u7269\u4f53\u5bf9\u5149\u8c31\u5404\u6ce2\u2ed3\u7684\u53cd\u5c04\u6ca1\u6709\u9009\u62e9\u6027\uff0c\u5b83\u4eec\u662f\u4e2d\u6027\u2f8a\u3002
\u7ea2\u7eff\u84dd\u5149\u7684\u6ce2\u2ed3
\u7ea2 > \u7eff > \u84dd
"},{"location":"CS/DIP/DIP_Review/#_6","title":"\u89c6\u2f79\u819c\u7684\u4e24\u79cd\u7ec6\u80de","text":"\u89c6\u2f79\u819c\u4e0a\u5206\u5e03\u7740\u4e24\u79cd\u89c6\u89c9\u7ec6\u80de\uff0c\u2f00\u79cd\u4e3a\u6746\u72b6\u4f53\uff0c\u53e6\u2f00\u79cd\u4e3a\u9525\u72b6\u4f53\u3002\u6746\u72b6\u4f53\u7ec6\u80de\u2f50\u8f83\u591a\uff0c\u2f24\u7ea6\u6709\u4e0a\u4ebf\u4e2a\uff0c\u5b83\u5bf9\u5149\u6781\u4e3a\u7075\u654f\uff0c\u4f46\u6ca1\u6709\u533a\u5206\u2f8a\u5f69\u7684\u80fd\u2f12\u3002\u9525\u72b6\u4f53\u7ec6\u80de\u5219\u53ea\u6709\u516d\u3001\u4e03\u767e\u4e07\u4e2a\uff0c\u5b83\u8981\u5728\u8f83\u5f3a\u7684\u7167\u5ea6\u4e0b\u624d\u80fd\u6fc0\u53d1\uff0c\u5b83\u7684\u5b58\u5728\u4f7f\u6211\u4eec\u80fd\u591f\u8fa8\u522b\u5404\u79cd\u4e0d\u540c\u7684\u989c\u2f8a\u3002
\u6746\u72b6\uff1a\u591a\uff0c\u5bf9\u5149\u7075\u654f\uff0c\u4f46\u662f\u4e0d\u80fd\u533a\u5206\u2f8a\u5f69 \u9525\u72b6\uff1a\u5c11\uff0c\u5f3a\u5149\u624d\u80fd\u6fc0\u53d1\uff0c\u2f64\u6765\u533a\u5206\u2f8a\u5f69
"},{"location":"CS/DIP/DIP_Review/#_7","title":"\u4e09\u539f\u2f8a\u5f62\u6210\u7684\u539f\u7406","text":"\u5728\u89c6\u2f79\u819c\u4e0a\u5b58\u5728\u7740\u4e09\u79cd\u5206\u522b\u5bf9\u7ea2\u3001\u7eff\u548c\u84dd\u5149\u7ebf\u7684\u6ce2\u2ed3\u7279\u522b\u654f\u611f\u7684\u89c6\u9525\u7ec6\u80de\u6216\u76f8\u5e94\u7684\u611f\u5149\u2f8a\u7d20\uff0c\u5f53\u4e0d\u540c\u6ce2\u2ed3\u7684\u5149\u7ebf\u8fdb\u2f0a\u2f08\u773c\u65f6\uff0c\u4e0e\u4e4b\u76f8\u7b26\u6216\u76f8\u8fd1\u7684\u89c6\u9525\u7ec6\u80de\u53d1\u2f63\u4e0d\u540c\u7a0b\u5ea6\u7684\u5174\u594b\uff0c\u4e8e\u662f\u5728\u2f24\u8111\u4ea7\u2f63\u76f8\u5e94\u7684\u2f8a\u89c9\uff1b\u4e09\u79cd\u89c6\u9525\u7ec6\u80de\u82e5\u53d7\u5230\u540c\u7b49\u7a0b\u5ea6\u7684\u523a\u6fc0\uff0c\u5219\u4ea7\u2f63\u6d88\u2f8a\u3002
"},{"location":"CS/DIP/DIP_Review/#_8","title":"\u611f\u77e5\u7684\u4f18\u5148\u7a0b\u5ea6\u548c\u654f\u611f\u5ea6","text":"\u4f18\u5148\u7a0b\u5ea6\uff1a\u540c\u7b49\u6761\u4ef6\u4e0b\uff0c\u2f08\u4eec\u5f80\u5f80\u4f1a\u6ce8\u610f\u5230\u2f8a\u8c03\uff08Hue, H\uff09\u7684\u53d8\u5316\uff0c\u7136\u540e\u662f\u9971\u548c\u5ea6\uff08Saturation, S\uff09\uff0c\u7136\u540e\u662f\u4eae\u5ea6\uff08Value, V\uff09\u3002\u8c03\u4fdd\u4eae HSV
\u654f\u611f\u5ea6\uff1a\u2f08\u773c\u5bf9\u4e8e\u4eae\u5ea6\u7684\u53d8\u5316\u6700\u4e3a\u654f\u611f\uff0c\u5206\u8fa8\u80fd\u2f12\u6700\u5f3a\u3002\u6070\u597d\u4e0e\u2f08\u773c\u7684\u2fbc\u52a8\u6001\u80fd\u2f12\u76f8\u5339\u914d\u3002
"},{"location":"CS/DIP/DIP_Review/#_9","title":"* \u4e0e\u8bbe\u5907\u76f8\u5173\u548c\u2f46\u5173\u7684\u989c\u2f8a\u6a21\u578b","text":"
\u4e0e\u8bbe\u5907\u76f8\u5173\u7684\u989c\u2f8a\u6a21\u578b\uff1aRGB, CMY, HSV
\u4e0e\u8bbe\u5907\u2f46\u5173\u7684\u989c\u2f8a\u6a21\u578b\uff1aCIE XYZ, CIE L*a*b\u548c CIE YUV
HSV\u66f4\u63a5\u8fd1\u2f08\u7684\u611f\u77e5
"},{"location":"CS/DIP/DIP_Review/#rgb","title":"RGB","text":"RBG \u989c\u8272\u6a21\u578b\u662f\u4e09\u7ef4\u76f4\u89d2\u5750\u6807\u989c\u8272\u7cfb\u7edf\u4e2d\u7684\u4e00\u4e2a\u5355\u4f4d\u6b63\u65b9\u4f53\u5728\u6b63\u65b9\u4f53\u7684\u4e3b\u5bf9\u89d2\u7ebf\u4e0a\uff0c\u5404\u539f\u8272\u7684\u91cf\u76f8\u7b49\uff0c\u4ea7\u751f\u7531\u6697\u5230\u4eae\u7684\u767d\u8272\uff0c\u5373\u7070\u5ea6\u3002\uff080\uff0c0\uff0c0\uff09\u4e3a\u9ed1\uff0c\uff081\uff0c1\uff0c1\uff09\u4e3a\u767d\uff0c\u6b63\u65b9\u4f53\u7684\u5176\u4ed66\u4e2a\u89d2\u70b9\u5206\u522b\u4e3a\u7ea2\u3001\u9ec4\u3001\u7eff\u3001\u9752\u3001\u84dd\u548c\u54c1\u7ea2\u3002RGB\u989c\u8272\u6a21\u578b\u6784\u6210\u7684\u989c\u8272\u7a7a\u95f4\u662fCIE\u539f\u8272\u7a7a\u95f4\u7684\u4e00\u4e2a\u771f\u5b50\u96c6\u3002RGB\u989c\u8272\u6a21\u578b\u901a\u5e38\u7528\u4e8e\u5f69\u8272\u9634\u6781\u5c04\u7ebf\u7ba1\u548c\u5f69\u8272\u5149\u6805\u56fe\u5f62\u663e\u793a\u5668\uff08\u8ba1\u7b97\u673a\u548c\u7535\u89c6\u673a\u91c7\u7528\uff09\u3002
"},{"location":"CS/DIP/DIP_Review/#hsv","title":"HSV","text":"HSV\u989c\u8272\u7a7a\u95f4\u662f\u4ece\u4eba\u7684\u89c6\u89c9\u7cfb\u7edf\u51fa\u53d1\uff0c\u7528\u8272\u8c03\uff08Hue)\u3001\u8272\u9971\u548c\u5ea6\uff08Saturation\uff09\u548c\u4eae\u5ea6\uff08Intensity\uff0c\u6216\u8005Value\uff09\u6765\u5706\u9525\u7684\u9876\u9762\u5bf9\u5e94\u4e8eV=1\uff0c\u5b83\u5305\u542bRGB\u6a21\u578b\u4e2d\u7684R=1\uff0cG=1\uff0cB=1\u4e09\u4e2a\u9762\uff0c\u6545\u6240\u4ee3\u8868\u7684\u989c\u8272\u8f83\u4eae\u3002\u8272\u5ea6H\u7531\u7ed5V\u8f74\u7684\u65cb\u8f6c\u89d2\u7ed9\u5b9a\u3002\u7ea2\u8272\u5bf9\u5e94\u4e8e\u89d2\u5ea60o\uff0c\u7eff\u8272\u5bf9\u5e94\u4e8e\u89d2\u5ea6120o\uff0c\u84dd\u8272\u5bf9\u5e94\u4e8e\u89d2\u5ea6240o\u3002\u63cf\u8ff0\u989c\u8272\u3002\u5728\u5706\u9525\u7684\u9876\u70b9\u5904\uff0cV=0\uff0cH\u548cS\u65e0\u5b9a\u4e49\uff0c\u4ee3\u8868\u9ed1\u8272\u3002
"},{"location":"CS/DIP/DIP_Review/#_10","title":"\u52a0\u8272 \u51cf\u8272(\u52a0\u8272\u7684\u8865\u8272)","text":"RGB CMY \u5f69\u8272\u5370\u5237\u6216\u8005\u5f69\u8272\u6253\u5370\u7684\u7eb8\u5f20\u4e0d\u80fd\u53d1\u5c04\u5149\u7ebf\uff0c\u56e0\u800c\u5370\u5237\u673a\u6216\u6253\u5370\u673a\u5c31\u53ea\u80fd\u4f7f\u7528\u4e00\u4e9b\u80fd\u591f\u5438\u6536\u7279\u5b9a\u5149\u6ce2\u800c\u53cd\u5c04\u5176\u4ed6\u5149\u6ce2\u7684\u6cb9\u58a8\u6216\u8005\u989c\u8272\u3002\u6cb9\u58a8\u6216\u989c\u6599\u76843\u79cd\u57fa\u8272\u662f\u4ee5\u7ea2\u3001\u7eff\u3001\u84dd\u4e09\u8272\u7684\u8865\u8272\u9752\uff08Cyan\uff09\u3001\u54c1\u7ea2\uff08Magenta\uff09\u3001\u9ec4\uff08Yellow\uff09\u4e3a\u57fa\u8272\u3002\u7528CMY\u6a21\u578b\u4ea7\u751f\u7684\u989c\u8272\u79f0\u4e3a\u76f8\u51cf\u8272\uff0c\u662f\u56e0\u4e3a\u5b83\u51cf\u6389\u4e86\u4e3a\u89c6\u89c9\u7cfb\u7edf\u8bc6\u522b\u989c\u8272\u6240\u9700\u8981\u7684\u53cd\u5c04\u5149
"},{"location":"CS/DIP/DIP_Review/#jpeg","title":"JPEG\u7684\u538b\u7f29\u7684\u57fa\u672c\u7b56\u7565\u4ee5\u53ca\u4f18\u70b9","text":"\u538b\u7f29\u7b56\u7565:\u6839\u636e\u538b\u7f29\u2f50\u8981\u6c42\uff0c\u4ece\u2fbc\u9891\u5230\u4f4e\u9891\u9010\u6b65\u524a\u51cf\u4fe1\u606f
\u597d\u5904\uff1a
"},{"location":"CS/DIP/DIP_Review/#_11","title":"\u56fe\u50cf\u683c\u5f0f","text":"
- \u2fbc\u9891\u4fe1\u606f\u5360\u2f64\u5b58\u50a8\u7a7a\u95f4\u2f24\uff0c\u51cf\u5c11\u2fbc\u9891\u4fe1\u606f\u66f4\u5bb9\u6613\u83b7\u5f97\u2fbc\u538b\u7f29\u2f50\uff1b
- \u4f4e\u9891\u4fe1\u606f\u53ef\u4ee5\u4fdd\u7559\u7269\u4f53\u7684\u57fa\u672c\u8f6e\u5ed3\u548c\u2f8a\u5f69\u5206\u5e03\uff0c\u6700\u2f24\u9650\u5ea6\u7ef4\u6301\u56fe\u50cf\u8d28\u91cf\u3002
- \u9002\u5408\u2f64\u4e8e\u4e92\u8054\u2f79
\u76ee\u7684\uff1a\u5b58\u50a8\u56fe\u50cf\u4fe1\u606f \u56fe\u50cf\u7279\u70b9\uff1a\u4ee5\u50cf\u7d20\u4e3a\u5355\u4f4d\u3001\u77e9\u5f62\u533a\u57df\u3001\u4fe1\u606f\u91cf\u2f24
\u6709\u4e9b\u2f42\u4ef6\u683c\u5f0f\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u6709\u5173\uff1awindows\u3001unix\u3001mac \u7f16\u7801\u2f45\u5f0f\uff1a\u2f46\u538b\u7f29\uff08BMP\uff09\u3001\u2f46\u635f\u538b\u7f29(PNG,GIF)\u3001\u6709\u635f\u538b\u7f29(JPEG)
\u5e38\u2f64\u7684\u56fe\u50cf\u2f42\u4ef6\u683c\u5f0f\uff1aBMP\u3001JPEG\u3001TIFF\u3001GIF\u3001PNG\u2026\u2026
"},{"location":"CS/DIP/DIP_Review/#bmp","title":"BMP","text":"Windows\u64cd\u4f5c\u7cfb\u7edf\u7684\u6807\u51c6\u6587\u4ef6\u683c\u5f0f\u4e4b\u4e00\uff0c\u6709\u65f6\u5019\u4e5f\u5b58\u4e3a.dib\u6587\u4ef6\u5927\u90e8\u5206BMP\u6587\u4ef6\u662f\u4e0d\u538b\u7f29\u7684\u5f62\u5f0f\u4f46\u5b83\u672c\u8eab\u8fd8\u662f\u652f\u6301\u56fe\u50cf\u538b\u7f29\u7684\uff0c\u5982rle\u683c\u5f0f\uff08\u884c\u7a0b\u957f\u5ea6\u7f16\u7801\uff0crunlength encoding\uff09\u538b\u7f29\u683c\u5f0f\u7b49
"},{"location":"CS/DIP/DIP_Review/#image-file-header","title":"Image file header | \u6587\u4ef6\u5934","text":"
bfType
\u8bf4\u660e\u6587\u4ef6\u7684\u7c7b\u578b\uff0c\u8be5\u503c\u5fc5\u9700\u662f0x4D42\uff0c\u4e5f\u5c31\u662f\u5b57\u7b26'BM'\u3002
bfSize
\u8bf4\u660e\u8be5\u4f4d\u56fe\u6587\u4ef6\u7684\u5927\u5c0f\uff0c\u7528\u5b57\u8282\u4e3a\u5355\u4f4d
bfReserved1
\u4fdd\u7559\uff0c\u5fc5\u987b\u8bbe\u7f6e\u4e3a0
bfReserved2
\u4fdd\u7559\uff0c\u5fc5\u987b\u8bbe\u7f6e\u4e3a0"},{"location":"CS/DIP/DIP_Review/#image-information-header","title":"Image information header | \u4fe1\u606f\u5934","text":"
bfOffBits
\u8bf4\u660e\u4ece\u6587\u4ef6\u5934\u5f00\u59cb\u5230\u5b9e\u9645\u7684\u56fe\u8c61\u6570\u636e\u4e4b\u95f4\u7684\u5b57\u8282\u7684\u504f\u79fb\u91cf\u3002\u8fd9\u4e2a\u53c2\u6570\u662f\u975e\u5e38\u6709\u7528\u7684\uff0c\u56e0\u4e3a\u4f4d\u56fe\u4fe1\u606f\u5934\u548c\u8c03\u8272\u677f\u7684\u957f\u5ea6\u4f1a\u6839\u636e\u4e0d\u540c\u60c5\u51b5\u800c\u53d8\u5316\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u7528\u8fd9\u4e2a\u504f\u79fb\u503c\u8fc5\u901f\u7684\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u5230\u4f4d\u6570\u636e\u3002typedef struct tagBITMAPINFOHEADER{\n// \u957f\u5ea6\u56fa\u5b9a 40\nDWORD biSize;\nLONG biWidth;\nLONG biHeight;\nWORD biPlanes;\nWORD biBitCount\nDWORD biCompression;\nDWORD biSizeImage;\nLONG biXPelsPerMeter;\nLONG biYPelsPerMeter;\nDWORD biClrUsed;\nDWORD biClrImportant;\n} BITMAPINFOHEADER;\n
biSize
How many bytes are needed to define \u8bf4\u660e\u4e0a\u8ff0\u7ed3\u6784\u6240\u9700\u8981\u7684\u5b57\u6570\u3002
biWidth
\u8bf4\u660e\u56fe\u8c61\u7684\u5bbd\u5ea6\uff0c\u4ee5\u8c61\u7d20\u4e3a\u5355\u4f4d\u3002
biHeight
\u8bf4\u660e\u56fe\u8c61\u7684\u9ad8\u5ea6\uff0c\u4ee5\u8c61\u7d20\u4e3a\u5355\u4f4d\u3002\u5982\u679c\u8be5\u503c\u662f\u4e00\u4e2a\u6b63\u6570\uff0c\u8bf4\u660e\u56fe\u50cf\u662f\u5012\u5411\u7684\uff0c\u5982\u679c\u8be5\u503c\u662f\u4e00\u4e2a\u8d1f\u6570\uff0c\u5219\u8bf4\u660e\u56fe\u50cf\u662f\u6b63\u5411\u7684\u3002\u5927\u591a\u6570\u7684BMP\u6587\u4ef6\u90fd\u662f\u5012\u5411\u7684\u4f4d\u56fe\uff0c\u4e5f\u5c31\u662f\u65f6\uff0c\u9ad8\u5ea6\u503c\u662f\u4e00\u4e2a\u6b63\u6570\u3002
biPlanes
\u4e3a\u76ee\u6807\u8bbe\u5907\u8bf4\u660e\u4f4d\u9762\u6570\uff0c\u5176\u503c\u5c06\u603b\u662f\u88ab\u8bbe\u4e3a1\u3002
biBitCount
\u8bf4\u660e\u6bd4\u7279\u6570/\u8c61\u7d20\uff0c\u5176\u503c\u4e3a1\u30014\u30018\u300116\u300124\u3001\u621632\u3002\u4f46\u662f\u7531\u4e8e\u6211\u4eec\u5e73\u65f6\u7528\u5230\u7684\u56fe\u50cf\u7edd\u5927\u90e8\u5206\u662f24\u4f4d\u548c32\u4f4d\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u8ba8\u8bba\u8fd9\u4e24\u7c7b\u56fe\u50cf\u3002
biCompression
\u8bf4\u660e\u56fe\u8c61\u6570\u636e\u538b\u7f29\u7684\u7c7b\u578b\uff0c\u6211\u4eec\u53ea\u8ba8\u8bba\u6ca1\u6709\u538b\u7f29\u7684\u7c7b\u578b\uff1aBI_RGB\u3002
biSizeImage
\u8bf4\u660e\u56fe\u8c61\u7684\u5927\u5c0f\uff0c\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u3002\u5f53\u7528BI_RGB\u683c\u5f0f\u65f6\uff0c\u53ef\u8bbe\u7f6e\u4e3a0\u3002biSizeImage=biWidth\u2019 \u00d7 biHeight biWidth` \u5fc5\u987b\u662f 4 \u7684\u500d\u6570
biXPelsPerMeter
\u8bf4\u660e\u6c34\u5e73\u5206\u8fa8\u7387\uff0c\u7528\u8c61\u7d20/\u7c73\u8868\u793a\u3002
biYPelsPerMeter
\u8bf4\u660e\u5782\u76f4\u5206\u8fa8\u7387\uff0c\u7528\u8c61\u7d20/\u7c73\u8868\u793a\u3002
biClrUsed
\u8bf4\u660e\u4f4d\u56fe\u5b9e\u9645\u4f7f\u7528\u7684\u5f69\u8272\u8868\u4e2d\u7684\u989c\u8272\u7d22\u5f15\u6570\uff08\u8bbe\u4e3a0\u7684\u8bdd\uff0c\u5219\u8bf4\u660e\u4f7f\u7528\u6240\u6709\u8c03\u8272\u677f\u9879\uff09\u3002"},{"location":"CS/DIP/DIP_Review/#palette","title":"Palette | \u8c03\u8272\u677f","text":"| \u542b\u4e49 |
biClrImportant
\u8bf4\u660e\u5bf9\u56fe\u8c61\u663e\u793a\u6709\u91cd\u8981\u5f71\u54cd\u7684\u989c\u8272\u7d22\u5f15\u7684\u6570\u76ee\uff0c\u5982\u679c\u662f0\uff0c\u8868\u793a\u90fd\u91cd\u8981\u3002\u6709\u4e00\u4e2a\u957f\u5bbd\u5404\u4e3a200\u4e2a\u8c61\u7d20\uff0c\u989c\u8272\u6570\u4e3a16\u8272\u7684\u5f69\u8272\u56fe\uff0c\u6bcf\u4e00\u4e2a\u8c61\u7d20\u90fd\u7528R\u3001G\u3001B\u4e09\u4e2a\u5206\u91cf\u8868\u793a\u3002\u56e0\u4e3a\u6bcf\u4e2a\u5206\u91cf\u6709256\u4e2a\u7ea7\u522b\uff0c\u8981\u75288\u4f4d(bit)\uff0c\u5373\u4e00\u4e2a\u5b57\u8282(byte)\u6765\u8868\u793a\uff0c\u6240\u4ee5\u6bcf\u4e2a\u8c61\u7d20\u9700\u8981\u75283\u4e2a\u5b57\u8282\u3002\u6574\u4e2a\u56fe\u8c61\u8981\u7528200\u00d7200\u00d73\uff0c\u7ea6120k\u5b57\u8282\uff0c\u53ef\u4e0d\u662f\u4e00\u4e2a\u5c0f\u6570\u76ee\u5440\uff01
\u5982\u679c\u6211\u4eec\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\uff0c\u5c31\u80fd\u7701\u7684\u591a\u3002\u56e0\u4e3a\u662f\u4e00\u4e2a16\u8272\u56fe\uff0c\u4e5f\u5c31\u662f\u8bf4\u8fd9\u5e45\u56fe\u4e2d\u6700\u591a\u53ea\u670916\u79cd\u989c\u8272\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u4e2a\u8868\uff1a\u8868\u4e2d\u7684\u6bcf\u4e00\u884c\u8bb0\u5f55\u4e00\u79cd\u989c\u8272\u7684R\u3001G\u3001B\u503c\u3002\u8fd9\u6837\u5f53\u6211\u4eec\u8868\u793a\u4e00\u4e2a\u8c61\u7d20\u7684\u989c\u8272\u65f6\uff0c\u53ea\u9700\u8981\u6307\u51fa\u8be5\u989c\u8272\u662f\u5728\u7b2c\u51e0\u884c\uff0c\u5373\u8be5\u989c\u8272\u5728\u8868\u4e2d\u7684\u7d22\u5f15\u503c\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5982\u679c\u8868\u7684\u7b2c0\u884c\u4e3a255\uff0c0\uff0c0(\u7ea2\u8272)\uff0c\u90a3\u4e48\u5f53\u67d0\u4e2a\u8c61\u7d20\u4e3a\u7ea2\u8272\u65f6\uff0c\u53ea\u9700\u8981\u6807\u660e0\u5373\u53ef\u3002\u8fd9\u5f20R\u3001G\u3001B\u7684\u8868\uff0c\u5c31\u662f\u6211\u4eec\u5e38\u8bf4\u7684\u8c03\u8272\u677f(Palette)\uff0c\u53e6\u4e00\u79cd\u53eb\u6cd5\u662f\u989c\u8272\u67e5\u627e\u8868LUT(Look Up Table)\uff0c\u4f3c\u4e4e\u66f4\u786e\u5207\u4e00\u4e9b\u3002Windows\u4f4d\u56fe\u4e2d\u4fbf\u7528\u5230\u4e86\u8c03\u8272\u677f\u6280\u672f\u3002\u5176\u5b9e\u4e0d\u5149\u662fWindows\u4f4d\u56fe\uff0c\u8bb8\u591a\u56fe\u8c61\u6587\u4ef6\u683c\u5f0f\u5982pcx\u3001tif\u3001gif\u7b49\u90fd\u7528\u5230\u4e86\u3002\u6240\u4ee5\u5f88\u597d\u5730\u638c\u63e1\u8c03\u8272\u677f\u7684\u6982\u5ff5\u662f\u5341\u5206\u6709\u7528\u7684\u3002
"},{"location":"CS/DIP/DIP_Review/#image-data","title":"Image data | \u56fe\u50cf\u6570\u636e","text":"
Palette
N * 4 bytes. \u6bcf\u4e00\u4e2a\u5143\u7d20\u90fd\u6709\u56db\u4e2a\u6bd4\u7279\uff0c\u5206\u522b\u5b58\u50a8\u84dd\u7eff\u7ea2\u7684 RGB \u503c\u548c\u4e00\u4e2a reserved byte.(1) \u6bcf\u4e00\u884c\u7684\u5b57\u8282\u6570\u5fc5\u987b\u662f4\u7684\u6574\u500d\u6570\uff0c\u5982\u679c\u4e0d\u662f\uff0c\u5219\u9700\u8981\u8865\u9f50\u3002\u8fd9\u5728\u524d\u9762\u4ecb\u7ecdbiSizeImage\u65f6\u5df2\u7ecf\u63d0\u5230\u4e86\u3002
(2) \u4e00\u822c\u6765\u8bf4\uff0c.bMP\u6587\u4ef6\u7684\u6570\u636e\u4ece\u4e0b\u5230\u4e0a\uff0c\u4ece\u5de6\u5230\u53f3\u7684\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4ece\u6587\u4ef6\u4e2d\u6700\u5148\u8bfb\u5230\u7684\u662f\u56fe\u8c61\u6700\u4e0b\u9762\u4e00\u884c\u7684\u5de6\u8fb9\u7b2c\u4e00\u4e2a\u8c61\u7d20\uff0c\u7136\u540e\u662f\u5de6\u8fb9\u7b2c\u4e8c\u4e2a\u8c61\u7d20\u2026\u2026\u63a5\u4e0b\u6765\u662f\u5012\u6570\u7b2c\u4e8c\u884c\u5de6\u8fb9\u7b2c\u4e00\u4e2a\u8c61\u7d20\uff0c\u5de6\u8fb9\u7b2c\u4e8c\u4e2a\u8c61\u7d20\u2026\u2026\u4f9d\u6b21\u7c7b\u63a8 \uff0c\u6700\u540e\u5f97\u5230\u7684\u662f\u6700\u4e0a\u9762\u4e00\u884c\u7684\u6700\u53f3\u4e00\u4e2a\u8c61\u7d20\u3002
"},{"location":"CS/DIP/DIP_Review/#rle","title":"RLE \u4e8c\u503c\u56fe\u50cf\u7f16\u7801","text":""},{"location":"CS/DIP/DIP_Review/#ch2","title":"Ch2","text":""},{"location":"CS/DIP/DIP_Review/#_12","title":"\u2f06\u503c\u56fe\u50cf\u7684\u4f18\u7f3a\u70b9","text":"
- \u6bcf\u4e00\u884c\u90fd\u7528subterm\u8868\u793a\uff0c\u7b2c\u4e00\u4e2a\u4e3a\u884c\u53f7\uff0c
\u4f18\u70b9\uff1a
- \u66f4\u2f29\u7684\u5185\u5b58\u9700\u6c42
- \u8fd0\u2f8f\u901f\u5ea6\u66f4\u5feb
- \u4e3a\u2f06\u503c\u56fe\u50cf\u5f00\u53d1\u7684\u7b97\u6cd5\u5f80\u5f80\u53ef\u4ee5\u2f64\u4e8e\u7070\u5ea6\u7ea7\u56fe\u50cf
- \u66f4\u4fbf\u5b9c
\u7f3a\u70b9\uff1a
"},{"location":"CS/DIP/DIP_Review/#_13","title":"\u56fe\u50cf\u7684\u2f06\u503c\u5316","text":"
- \u5e94\u2f64\u8303\u56f4\u6bd5\u7adf\u6709\u9650\uff1b
- \u66f4\u2f46\u6cd5\u63a8\u2f34\u5230\u4e09\u7ef4\u7a7a\u95f4\u4e2d
- \u8868\u73b0\u2f12\u2f4b\u7f3a\uff0c\u4e0d\u80fd\u8868\u73b0\u7269\u4f53\u5185\u90e8\u7ec6\u8282
- \u2f46\u6cd5\u63a7\u5236\u5bf9\u2f50\u5ea6
"},{"location":"CS/DIP/DIP_Review/#_14","title":"\u9009\u53d6\u5408\u9002\u7684\u9608\u503c\u7684\u57fa\u672c\u601d\u60f3","text":"
- \u8bbe\u7f6e\u2f00\u4e2a\u9608\u503c
\u5c06\u2f06\u503c\u5316\u5f97\u5230\u7684\u2f06\u503c\u56fe\u50cf\u89c6\u4e3a\u4e24\u90e8\u5206\uff0c\u2f00\u90e8\u5206\u5bf9\u5e94\u524d\u666f\uff08Foreground\uff09\uff0c\u53e6\u2f00\u90e8\u5206\u5bf9\u5e94\u80cc\u666f\uff08Background\uff09\u3002\u5c1d\u8bd5\u627e\u5230\u2f00\u4e2a\u5408\u9002\u7684threshold\u4f7f\u5f97\u5230\u7684\u524d\u666f\u548c\u80cc\u666f\u7684\u5185\u90e8\u534f\u2f45\u5dee\u6700\u2f29\uff0c\u2f7d\u5b83\u4eec\u4e4b\u95f4\u7684\u5916\u90e8\u534f\u2f45\u5dee\u6700\u2f24\u3002
"},{"location":"CS/DIP/DIP_Review/#_15","title":"\u2f24\u6d25\u7b97\u6cd5","text":"Step 1: \u786e\u5b9a\u539f\u59cb\u56fe\u50cf\u4e2d\u50cf\u7d20\u7684\u6700\u2f24\u503c\u548c\u6700\u2f29\u503c\uff1b
Step 2: \u6700\u2f29\u503c\u52a01\u4f5c\u4e3athreshold\u5bf9\u539f\u59cb\u56fe\u50cf\u8fdb\u2f8f\u2f06\u503c\u5316\u64cd\u4f5c\uff1b
Step 3: \u6839\u636e\u5bf9\u5e94\u5173\u7cfb\u786e\u5b9a\u524d\u666f\u548c\u80cc\u666f\uff0c\u5206\u522b\u8ba1\u7b97\u5f53\u524dthreshold\u4e0b\u7684\u5185\u90e8\u534f\u2f45\u5dee\u548c\u5916\u90e8\u534f\u2f45\u5dee\uff1b
Step 4: \u56de\u5230Step 2\u76f4\u5230\u8fbe\u5230\u50cf\u7d20\u6700\u2f24\u503c\uff1b
Step 5\uff1a\u627e\u5230\u6700\u2f24\u5916\u90e8\u548c\u6700\u2f29\u5185\u90e8\u534f\u2f45\u5dee\u5bf9\u5e94\u7684threshold.
"},{"location":"CS/DIP/DIP_Review/#_16","title":"\u5c40\u90e8\u2f83\u9002\u5e94\u64cd\u4f5c","text":"\u8bbe\u5b9a\u2f00\u4e2a\u5c40\u90e8\u7a97\u2f1d\uff0c\u5728\u6574\u4e2a\u56fe\u50cf\u4e0a\u6ed1\u52a8\u8be5\u7a97\u2f1d\uff1b\u5bf9\u4e8e\u6bcf\u2f00\u7a97\u2f1d\u4f4d\u7f6e\uff0c\u786e\u5b9a\u9488\u5bf9\u8be5\u7a97\u2f1d\u7684threshold\u3002
"},{"location":"CS/DIP/DIP_Review/#dilation","title":"\u81a8\u80c0(Dilation)","text":"\u7269\u7406\u610f\u4e49\uff1a\u4f7f\u8fb9\u754c\u5411\u5916\u90e8\u6269\u5f20\u7684\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u2f64\u6765\u586b\u8865\u7269\u4f53\u4e2d\u7684\u7a7a\u6d1e\u3002
"},{"location":"CS/DIP/DIP_Review/#erosion","title":"\u8150\u8680\uff08Erosion\uff09","text":"\u7269\u7406\u610f\u4e49\uff1a\u6d88\u9664\u8fb9\u754c\u70b9\uff0c\u4f7f\u8fb9\u754c\u5411\u5185\u90e8\u6536\u7f29\u7684\u8fc7\u7a0b\u3002\u53ef\u4ee5\u2f64\u6765\u6d88\u9664\u2f29\u4e14\u2f46\u610f\u4e49\u7684\u7269\u4f53
"},{"location":"CS/DIP/DIP_Review/#application","title":"Application","text":""},{"location":"CS/DIP/DIP_Review/#_17","title":"*** \u8150\u8680\u548c\u81a8\u80c0\u5177\u6709\u5bf9\u5076\u6027","text":""},{"location":"CS/DIP/DIP_Review/#opening-e-d","title":"\u5f00\u8fd0\u7b97(Opening = E + D)","text":"\u5148\u8150\u8680\uff0c\u540e\u81a8\u80c0\u3002
\u7269\u7406\u610f\u4e49\uff1a\u2f64\u6765\u6d88\u9664\u2f29\u7269\u4f53\u3001\u5728\u7ea4\u7ec6\u70b9\u5904\u5206\u79bb\u7269\u4f53\u3001\u5e73\u6ed1\u8f83\u2f24\u7269\u4f53\u7684\u8fb9\u754c\u7684\u540c\u65f6\u5e76\u4e0d\u660e\u663e\u6539\u53d8\u5176\u79ef\u3002
"},{"location":"CS/DIP/DIP_Review/#closing-d-e","title":"\u95ed\u8fd0\u7b97(Closing = D + E)","text":"\u5148\u81a8\u80c0\u540e\u8150\u8680
\u7269\u7406\u610f\u4e49\uff1a\u2f64\u6765\u586b\u5145\u7269\u4f53\u5185\u7ec6\u2f29\u7a7a\u6d1e\u3001\u8fde\u63a5\u90bb\u8fd1\u7269\u4f53\u3001\u5e73\u6ed1\u5176\u8fb9\u754c\u7684\u540c\u65f6\u5e76\u4e0d\u660e\u663e\u6539\u53d8\u5176\u2faf\u79ef\u3002
"},{"location":"CS/DIP/DIP_Review/#_18","title":"\u6307\u7eb9\u7684\u9884\u5904\u7406\u8fc7\u7a0b","text":""},{"location":"CS/DIP/DIP_Review/#ch3","title":"Ch3","text":"
- Opening \u6d88\u9664\u5916\u90e8\u566a\u70b9
- \u8150\u8680
- \u81a8\u80c0
- Closing \u6d88\u9664\u5185\u90e8\u566a\u70b9
\u8ba1\u7b97\u7070\u5ea6\u611f\u77e5
\u6839\u636e\u2ed9\u4f2f\u5b9a\u7406
"},{"location":"CS/DIP/DIP_Review/#log","title":"** Log \u53ef\u89c6\u5316\u589e\u5f3a","text":"Ld\u662f\u663e\u793a\u4eae\u5ea6\uff0cLw\u662f\u771f\u5b9e\u4eae\u5ea6,Lmax\u662f\u56fe\u50cf\u4e2d\u7684\u6700\u2f24\u4eae\u5ea6\u3002
\u8fd9\u4e2a\u6620\u5c04\u80fd\u591f\u786e\u4fdd\u4e0d\u7ba1\u573a\u666f\u7684\u52a8\u6001\u8303\u56f4\u662f\u600e\u4e48\u6837\u7684\uff0c\u5176\u6700\u2f24\u503c\u90fd\u80fd\u6620\u5c04\u52301\uff08\u2f69\uff09\uff0c\u5176\u4ed6\u7684\u503c\u80fd\u591f\u2f50\u8f83\u5e73\u6ed1\u5730\u53d8\u5316\u3002
"},{"location":"CS/DIP/DIP_Review/#_19","title":"** \u56fe\u50cf\u76f4\u65b9\u56fe\u5747\u8861\u5316","text":"\u76f4\u65b9\u56fe\u5747\u8861\u5316\u5b9e\u8d28\u4e0a\u662f\u51cf\u5c11\u56fe\u50cf\u7684\u7070\u5ea6\u7ea7\u4ee5\u6362\u53d6\u5bf9\u6bd4\u5ea6\u7684\u52a0\u5927\u3002\u5728\u5747\u8861\u8fc7\u7a0b\u4e2d\uff0c\u539f\u6765\u7684\u76f4\u65b9\u56fe\u4e0a\u51fa\u73b0\u6982\u7387\u8f83\u5c0f\u7684\u7070\u5ea6\u7ea7\u88ab\u5f52\u5165\u5f88\u5c11\u51e0\u4e2a\u751a\u81f3\u4e00\u4e2a\u7070\u5ea6\u7ea7\u4e2d\uff0c\u6545\u5f97\u4e0d\u5230\u589e\u5f3a\u3002\u82e5\u8fd9\u4e9b\u7070\u5ea6\u7ea7\u6240\u6784\u6210\u7684\u56fe\u8c61\u7ec6\u8282\u6bd4\u8f83\u91cd\u8981\uff0c\u5219\u9700\u91c7\u7528\u5c40\u90e8\u533a\u57df\u76f4\u65b9\u56fe\u5747\u8861\u5316\u5904\u7406\u3002
\u5047\u8bbe\uff1a
\u4ee4r\u548cs\u5206\u522b\u4ee3\u8868\u53d8\u5316\u524d\u540e\u56fe\u50cf\u7684\u7070\u5ea6\u7ea7\uff0c\u5e76\u4e14 0\u2264r,s \u22641 \u3002
P(r)\u548cP(s) \u5206\u522b\u4e3a\u53d8\u5316\u524d\u540e\u5404\u7ea7\u7070\u5ea6\u7684\u6982\u7387\u5bc6\u5ea6\u51fd\u6570\uff08r\u548cs\u503c\u5df2\u5f52\u2f00\u5316\uff0c\u6700\u2f24\u7070\u5ea6\u503c\u4e3a1\uff09\u3002
\u89c4\u5b9a\uff1a
\u57280\u2264r \u22641\u4e2d\uff0cT(r)\u662f\u5355\u8c03\u9012\u589e\u51fd\u6570\uff0c\u5e76\u4e140\u2264T(r)\u22641\u3002
\u53cd\u53d8\u6362r = T-1(s)\u4e5f\u4e3a\u5355\u8c03\u9012\u589e\u51fd\u6570\u3002
\u7070\u5ea6\u76f4\u2f45\u56fe\u5747\u8861\u5316
\u8bbe\u56fe\u50cf\u670964*64=4096\u4e2a\u50cf\u7d20\uff0c\u67098\u4e2a\u7070\u5ea6\u7ea7\uff0c\u7070\u5ea6\u5206\u5e03\uff1a
\u5982\u679c\u57281/7\u548c2/7\u4e4b\u95f4\uff0c\u90a3\u4e48\u548c\u54ea\u4e2a\u66f4\u8fd1\u5c31\u7ea6\u7b97\u5230\u54ea\u4e2a
\u76f4\u2f45\u56fe\u5747\u8861\u5316\u7684\u95ee\u9898
\u6309\u7167\u5747\u8861\u5316\u7684\u8981\u6c42\uff0c\u5728\u5747\u8861\u5316\u540e\u7684\u7ed3\u679c\u76f4\u2f45\u56fe\u4e2d\uff0c\u5404\u7070\u5ea6\u7ea7\u53d1\u2f63\u7684\u6982\u7387\u5e94\u8be5\u662f\u76f8\u540c\u7684\uff0c\u5982\u53f3\u4e0a\u56fe\u6240\u793a\u8fde\u7eed\u7070\u5ea6\u7ea7\u5747\u8861\u5316\u7ed3\u679c\u90a3\u6837\u3002\u4f46\u662f\uff0c\u53f3\u4e0b\u56fe\u4e2d\u79bb\u6563\u7070\u5ea6\u7ea7\u5747\u8861\u5316\u540e\uff0c\u5404\u7070\u5ea6\u7ea7\u51fa\u73b0\u7684\u6982\u7387\u5e76\u4e0d\u5b8c\u5168\u2f00\u6837\uff0c\u4e3a\u4ec0\u4e48\uff1f
\u6b65\u9aa42\u4e2d\uff0c\u6240\u5f97\u7684sk\u4e0d\u53ef\u80fd\u6b63\u597d\u7b49\u4e8e8\u7ea7\u7070\u5ea6\u503c\u4e2d\u7684\u67d0\u2f00\u7ea7\uff0c\u56e0\u6b64\u9700\u8981\u5c31\u8fd1\u5f52\u2f0a\u67d0\u2f00\u4e2a\u7070\u5ea6\u7ea7\u4e2d\u3002
\u8fd9\u6837\uff0c\u76f8\u90bb\u7684\u591a\u4e2ask\u5c31\u53ef\u80fd\u843d\u2f0a\u540c\u2f00\u4e2a\u7070\u5ea6\u7ea7\uff0c\u9700\u8981\u5728\u6b65\u9aa43\u65f6\u5c06\u5904\u4e8e\u540c\u2f00\u4e2a\u7070\u5ea6\u7ea7\u7684\u50cf\u7d20\u4e2a\u6570\u7d2f\u52a0\u3002\u56e0\u6b64\uff0c\u79bb\u6563\u7070\u5ea6\u76f4\u2f45\u56fe\u5747\u8861\u5316\u64cd\u4f5c\u4ee5\u540e\uff0c\u6bcf\u4e2a\u7070\u5ea6\u7ea7\u5904\u7684\u6982\u7387\u5bc6\u5ea6\uff08\u6216\u50cf\u7d20\u4e2a\u6570\uff09\u5e76\u4e0d\u5b8c\u5168\u2f00\u6837\u3002
"},{"location":"CS/DIP/DIP_Review/#histogram-fitting","title":"\u76f4\u2f45\u56fe\u7684\u5339\u914d(Histogram fitting)","text":"
- \u6240\u8c13\u76f4\u65b9\u56fe\u5339\u914d\uff0c\u5c31\u662f\u4fee\u6539\u4e00\u5e45\u56fe\u50cf\u7684\u76f4\u65b9\u56fe\uff0c\u4f7f\u5f97\u5b83\u4e0e\u53e6\u4e00\u5e45\u56fe\u50cf\u7684\u76f4\u65b9\u56fe\u5339\u914d\u6216\u5177\u6709\u4e00\u79cd\u9884\u5148\u89c4\u5b9a\u7684\u51fd\u6570\u5f62\u72b6\u3002
\u76f4\u65b9\u56fe\u5339\u914d\u7684\u76ee\u6807\uff0c\u662f\u7a81\u51fa\u6211\u4eec\u611f\u5174\u8da3\u7684\u7070\u5ea6\u8303\u56f4\uff0c\u4f7f\u56fe\u50cf\u8d28\u91cf\u6539\u5584
\u5229\u7528\u76f4\u65b9\u56fe\u5747\u8861\u5316\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5b9e\u73b0\u76f4\u65b9\u56fe\u5339\u914d\u8fc7\u7a0b\u3002
\u2f6c\u7684\uff0c\u628a\u76f4\u2f45\u56feA\u8f6c\u6362\u5230B
\u7b2c\u2f00\u6b65\uff0c\u901a\u8fc7\u76f4\u2f45\u56fe \u5747\u8861\u5316\u628ar\u6620\u5c04\u5230s
\u7b2c\u2f06\u6b65\uff0c\u540c\u7406\u628a\u7070\u5ea6\u7ea7z\u6620\u5c04\u5230v
\u7b2c\u4e09\u6b65,\u7531v = G(z)\u5f97\u5230z =G-1(v)\u3002\u7531\u4e8es\u548cv\u6709\u76f8\u540c\u7684\u5206\u5e03\uff0c\u9010\u2f00\u53d6v = s\uff0c\u6c42\u51fa\u4e0er\u5bf9\u5e94\u7684z =G- 1(s)\u3002
\u7b80\u8ff0\u7248\u672c\uff1a
\u5728\u6b65\u9aa41\u548c2\u4e2d\uff0c\u5206\u522b\u8ba1\u7b97\u83b7\u5f97\u4e24\u5f20\u8868\uff08\u53c2\u2ec5\u76f4\u2f45\u56fe\u5747\u8861\u5316\u4e2d\u7684\u7b97\u4f8b\uff09\uff0c\u4ece\u4e2d\u9009\u53d6\u2f00\u5bf9vk\u3001 sj\uff0c\u4f7fvk = sj\uff0c\u5e76\u4ece\u4e24\u5f20\u8868\u4e2d\u67e5\u51fa\u5bf9\u5e94\u7684zk\u3001rj\u3002\u8fd9\u6837\uff0c\u539f\u59cb\u56fe\u50cf\u4e2d\u7070\u5ea6\u7ea7\u4e3arj\u7684\u6240\u6709\u50cf\u7d20\u90fd\u6620\u5c04\u6210\u7070\u5ea6\u7ea7zk\uff0c\u6700\u7ec8\u5f97\u5230\u6240\u671f\u671b\u7684\u56fe\u50cf\u3002
"},{"location":"CS/DIP/DIP_Review/#ch4","title":"Ch4","text":""},{"location":"CS/DIP/DIP_Review/#_20","title":"** \u5404\u79cd\u53d8\u6362\u7684\u5750\u6807\u516c\u5f0f\u8981\u638c\u63e1","text":"\u65cb\u8f6c\u4ee5\u540e\u4ea7\u2f63\u7a7a\u6d1e\u7684\u63d2\u503c\u2f3f\u6cd5
\u2f8f\u63d2\u503c\u2014\u2014\u6309\u987a\u5e8f\u5bfb\u627e\u6bcf\u2f00\u2f8f\u4e2d\u7684\u7a7a\u6d1e\u50cf\u7d20\uff0c\u8bbe\u7f6e\u5176\u50cf\u7d20\u503c\u4e0e\u540c\u2f00\u2f8f\u4e2d\u524d\u2f00\u4e2a\u50cf\u7d20\u7684\u50cf\u7d20\u503c\u76f8\u540c\u3002
\u6700\u8fd1\u90bb\u63d2\u503c---\u4e3a\u4e86\u8ba1\u7b97\u2f0f\u4f55\u53d8\u6362\u540e\u65b0\u56fe\u50cf\u4e2d\u67d0\u2f00\u70b9P\u2019\u5904\u7684\u50cf\u7d20\u503c\uff0c\u53ef\u4ee5\u2fb8\u5148\u8ba1\u7b97\u8be5\u2f0f\u4f55\u53d8\u6362\u7684\u9006\u53d8\u6362\uff0c\u8ba1\u7b97\u51faP\u2019\u6240\u5bf9\u5e94\u7684\u539f\u56fe\u50cf\u4e2d\u7684\u4f4d\u7f6eP\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cP\u7684\u4f4d\u7f6e\u4e0d\u53ef\u80fd\u6b63\u597d\u5904\u5728\u539f\u56fe\u50cf\u7684\u67d0\u2f00\u4e2a\u50cf\u7d20\u4f4d\u7f6e\u4e0a\uff08\u5373P\u70b9\u7684\u5750\u6807\u901a\u5e38\u90fd\u4e0d\u4f1a\u6b63\u597d\u662f\u6574\u6570\uff09\u3002\u5bfb\u627e\u4e0eP\u70b9\u6700\u63a5\u8fd1\u7684\u50cf\u7d20Q\uff0c\u628aQ\u70b9\u7684\u50cf\u7d20\u503c\u4f5c\u4e3a\u65b0\u56fe\u50cf\u4e2dP\u2019\u70b9\u7684\u50cf\u7d20\u503c\u3002
\u5f53\u56fe\u50cf\u4e2d\u5305\u542b\u660e\u663e\u7684\u51e0\u4f55\u7ed3\u6784\u65f6\uff0c\u7ed3\u679c\u5c06\u4e0d\u592a\u5149\u6ed1\u8fde\u7eed\uff0c\u4ece\u800c\u5728\u56fe\u50cf\u4e2d\u4ea7\u751f\u4eba\u4e3a\u7684\u75d5\u8ff9\u3002
- \u2f00\u7ef4\u7ebf\u6027\u63d2\u503c
- \u53cc\u7ebf\u6027\u63d2\u503c
\u5df2\u77e5\u56fe\u50cf\u7684\u6b63\u2f45\u5f62\u2f79\u683c\u4e0a\u56db\u4e2a\u70b9A\u3001B\u3001C\u3001D\u7684\u7070\u5ea6\uff0c\u6c42P\u70b9\u7684\u7070\u5ea6\u3002
"},{"location":"CS/DIP/DIP_Review/#morph","title":"Morph\u56fe\u50cf\u7684\u53d8\u5f62","text":"\u5b9a\u4e49\u53cc\u7ebf\u6027\u65b9\u7a0bg(x,y)=ax+by+cxy+d \u3002\n\u5206\u522b\u5c06A\u3001B\u3001C\u3001D\u56db\u70b9\u7684\u4f4d\u7f6e\u548c\u7070\u5ea6\u4ee3\u5165\u65b9\u7a0b\uff0c\u5f97\u5230\u65b9\u7a0b\u7ec4\u3002\n\u89e3\u65b9\u7a0b\u7ec4\uff0c\u89e3\u51faa\u3001b\u3001c\u3001d\u56db\u4e2a\u7cfb\u6570\u3002\n\u5c06P\u70b9\u7684\u4f4d\u7f6e\u4ee3\u5165\u65b9\u7a0b\uff0c\u5f97\u5230P\u70b9\u7684\u7070\u5ea6\u3002\n
\u8fd9\u91cc\u8ba8\u8bba\u7684Morph\u53d8\u5f62\u4e0d\u540c\u4e8e\u4e00\u822c\u7684\u51e0\u4f55\u53d8\u6362(Warp)\u3002 Morph\u53d8\u5f62\u6307\u666f\u7269\u7684\u5f62\u4f53\u53d8\u5316\uff0c\u5b83\u662f\u4f7f\u4e00\u5e45\u56fe\u50cf\u9010\u6b65\u53d8\u5316\u5230\u53e6\u4e00\u5e45\u56fe\u50cf\u7684\u5904\u7406\u65b9\u6cd5\u3002 \u8fd9\u662f\u4e00\u79cd\u8f83\u590d\u6742\u7684\u4e8c\u7ef4\u56fe\u50cf\u5904\u7406\uff0c\u9700\u8981\u5bf9\u5404\u50cf\u7d20\u70b9\u7684\u989c\u8272\u3001\u4f4d\u7f6e\u4f5c\u53d8\u6362\u3002 \u53d8\u5f62\u7684\u8d77\u59cb\u56fe\u50cf\u548c\u7ed3\u675f\u56fe\u50cf\u5206\u522b\u4e3a\u4e24\u5e45\u5173\u952e\u5e27\uff0c\u4ece\u8d77\u59cb\u5f62\u72b6\u53d8\u5316\u5230\u7ed3\u675f\u5f62\u72b6\u7684\u5173\u952e\u5728\u4e8e\u81ea\u52a8\u5730\u751f\u6210\u4e2d\u95f4\u5f62\u72b6\uff0c\u4e5f\u5373\u81ea\u52a8\u751f\u6210\u4e2d\u95f4\u5e27\u3002
Change A to B
\u2f24\u2f29\u76f8\u540c\u7684\u4e24\u5e45\u56fe\u7684\u8f6c\u6362\u4f5c\u9759\u6001\u53d8\u6362\u3002\u4ece\u2f00\u5e45\u56fea\u9010\u6e10\u53d8\u5316\u6210\u7b2c\u2f06\u5e45\u56feb\u3002\u539f\u7406\uff1a\u8ba9\u56fea\u4e2d\u6bcf\u4e2a\u50cf\u7d20\u7684\u989c\u2f8a\uff0c\u9010\u6e10\u53d8\u6210\u56feb\u76f8\u540c\u4f4d\u7f6e\u50cf\u7d20\u7684\u989c\u2f8a\u3002
\u2f45\u6cd5\uff1a\u6839\u636e\u53d8\u6362\u7684\u5feb\u6162\uff0c\u8bbe\u7f6e\u76f8\u5e94\u7684\u6b65\u2ed3\uff0c\u5c06\u56fea\u6bcf\u2f00\u70b9\u7684RGB\u9010\u6e10\u53d8\u6210\u56feb\u76f8\u540c\u4f4d\u7f6e\u8c61\u7d20\u7684 RGB\u3002\u53ef\u4ee5\u9009\u62e9\u7b49\u2f50\u6216\u7b49\u5dee\u7684\u2f45\u5f0f\uff0c\u6216\u5176\u5b83\u2f45\u5f0f\u8ba9\uff1ara-->rb\u3002
\u5bf9\u4e8e\u7070\u5ea6\u56fe\u50cf\uff0c\u53ef\u4ee5\u76f4\u63a5\u2f64\u7b49\u2f50\u6216\u7b49\u5dee\u7ea7\u6570\u5b9a\u4e49\u6b65\u2ed3\uff0c\u4f7f\u989c\u2f8a\u4ece\u539f\u56fe\u53d8\u5230\u2f6c\u6807\u56fe\u3002
"},{"location":"CS/DIP/DIP_Review/#morph_1","title":"* \u5e94\u7528 Morph \u8868\u60c5\u5339\u914d","text":"Assumption: Human faces have approximately the same normals
"},{"location":"CS/DIP/DIP_Review/#ch5","title":"Ch5","text":""},{"location":"CS/DIP/DIP_Review/#_21","title":"\u2f00\u7ef4\u5377\u79ef","text":"\u5377\u79ef\u672c\u8d28\u4e0a\u7b49\u540c\u4e8e\u8ba1\u7b97\u56fe\u50cf\u50cf\u7d20\u7684\u52a0\u6743\u548c\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\u8981\u638c\u63e1
- \u5b83\u8868\u793a\u4e24\u4e2a\u51fd\u6570\u7684\u5377\u79ef\u53ef\u4ee5\u8f6c\u5316\u6210\u4e58\u79ef\u7684\u79ef\u5206\u6765\u8ba1\u7b97\u3002\u901a\u5e38\u5c06f(x)\u79f0\u4e3a\u8f93\u5165\u51fd\u6570\uff0c\u5c06h(x)\u79f0\u4e3a\u5377\u79ef\u51fd\u6570\u3002
\u8fd9\u2fa5\u8981\u6ce8\u610f\u7684\u662f\u5f97\u5230\u7684g(x)\u7684\u5b9a\u4e49\u57df\u4e3a[0,799]
\u6b65\u9aa41\uff1a \u5c06\u5377\u79ef\u51fd\u6570h(t)\u5173\u4e8e\u539f\u70b9\u8fdb\u884c\u955c\u50cf\u6620\u5c04\uff08\u5012\u8f6c\uff09\uff0c\u5f97\u5230h(-t)\u3002
\u6b65\u9aa42\uff1a \u5c06\u5012\u8f6c\u8fc7\u7684\u51fd\u6570h(-t)\u6ed1\u8fc7f(t)\uff0c\u8fd9\u8981\u589e\u52a0\u4e00\u4e2a\u5e38\u6570\u4f4d\u79fbx\u5230h(-t)\uff0c\u5373\u53d8\u6210h(x-t)\u3002
\u6b65\u9aa43\uff1a \u5bf9\u6bcf\u4e00\u4e2a\u6837\u672c\u70b9t \uff08t = 0, 1, 2, 3, \u2026, 399\uff09\u90fd\u8ba1\u7b97\u4e58\u79eff(t)h(x-t)\uff0c\u7136\u540e\u5c06\u8fd9\u4e9b\u4e58\u79ef\u76f8\u52a0\u540e\u9664\u4ee5\u5e38\u6570M\uff08=400\uff09\uff0c\u5c31\u5f97\u5230\u5728\u4f4d\u79fbx\u4e0b\u7684\u5377\u79ef\u3002
\u6b65\u9aa44\uff1a \u5bf9\u6709\u6548\u8303\u56f4\u5185\u7684\u6240\u6709\u4f4d\u79fbx\u5747\u8ba1\u7b97\u4e00\u4e2a\u5377\u79ef\uff0c\u8fd9\u6837\uff0c\u6240\u6709\u8fd9\u4e9b\u503c\u5c31\u5f62\u6210\u4e86\u4e00\u6761\u66f2\u7ebf\u3002
"},{"location":"CS/DIP/DIP_Review/#sharping-filter","title":"Sharping filter \u62c9\u666e\u62c9\u65af","text":"\u5fae\u5206\u7b97\u5b50\u662f\u5b9e\u73b0\u9510\u5316\u7684\u5de5\u5177\uff0c\u5176\u54cd\u5e94\u7a0b\u5ea6\u4e0e\u56fe\u50cf\u5728\u8be5\u70b9\u5904\u7684\u7a81\u53d8\u7a0b\u5ea6\u6709\u5173\u3002\u5fae\u5206\u7b97\u5b50\u589e\u5f3a\u4e86\u8fb9\u7f18\u548c\u5176\u4ed6\u7a81\u53d8\uff08\u5982\u566a\u58f0\uff09\u5e76\u524a\u5f31\u4e86\u7070\u5ea6\u53d8\u5316\u7f13\u6162\u7684\u533a\u57df\u3002
- \u57fa\u4e8e\u4e00\u9636\u5fae\u5206\u7684\u56fe\u50cf\u589e\u5f3a\u2014\u2014\u68af\u5ea6\u6cd5
- \u57fa\u4e8e\u4e8c\u9636\u5fae\u5206\u7684\u56fe\u50cf\u589e\u5f3a\u2014\u2014\u62c9\u666e\u62c9\u65af\u7b97\u5b50
\u5de6\u4fa7\u4e3a\u6b63\u5e38\u7684\u7b97\u5b50\uff0c\u53f3\u4fa7\u4e3aextending one
\u5f53\u62c9\u666e\u62c9\u65af\u6ee4\u6ce2\u540e\u7684\u56fe\u50cf\u4e0e\u5176\u5b83\u56fe\u50cf\u5408\u5e76\u65f6\uff08\u76f8\u52a0\u6216\u76f8\u51cf\uff09\uff0c\u5219\u5fc5\u987b\u8003\u8651\u7b26\u53f7\u4e0a\u7684\u5dee\u522b \u5c06\u539f\u59cb\u56fe\u50cf\u548c\u62c9\u666e\u62c9\u65af\u56fe\u50cf\u53e0\u52a0\u5728\u4e00\u8d77\u7684\u7b80\u5355\u65b9\u6cd5\u53ef\u4ee5\u4fdd\u62a4\u62c9\u666e\u62c9\u65af\u9510\u5316\u5904\u7406\u7684\u6548\u679c\uff0c\u540c\u65f6\u53c8\u80fd\u590d\u539f\u80cc\u666f\u4fe1\u606f\u3002
"},{"location":"CS/DIP/DIP_Review/#_22","title":"\u5e73\u6ed1\u7a7a\u95f4\u6ee4\u6ce2 | \u4f4e\u901a\u6ee4\u6ce2","text":"\u7a7a\u95f4\u6ee4\u6ce2
\u641e\u6e05\u695a\uff0c\u5747\u503c\u6ee4\u6ce2\u548c\u4e2d\u503c\u6ee4\u6ce2\u4e0d\u662f\u2f00\u56de\u4e8b\uff0c\u5747\u503c\u6ee4\u6ce2\u662f\u2fbc\u65af\u6ee4\u6ce2\u7684\u2f00\u79cd\u7279\u4f8b\uff0c\u2fbc\u65af\u6ee4\u6ce2\u662f\u2f00\u79cd\u4f4e\u901a\u6ee4\u6ce2\u3002
\u5f53\u53d1\u73b0\u56fe\u50cf\u4e2d\u6709\u592a\u591a\u7684\u4f2a\u5f71\u6216\u566a\u58f0\u65f6\uff0c\u53ef\u4ee5\u5bf9\u56fe\u50cf\u8fdb\u2f8f\u5e73\u6ed1\u5904\u7406\uff0c\u6291\u5236\u566a\u58f0\uff0c\u51cf\u5c11\u4f2a\u5f71\u3002 \u7136\u2f7d\uff0c\u5e73\u6ed1\u64cd\u4f5c\u4f1a\u4f7f\u56fe\u50cf\u53d8\u5f97\u6a21\u7cca\u3002
Linear smoothing filter
- \u7ebf\u6027
Statistical sorting filter
"},{"location":"CS/DIP/DIP_Review/#general-idea","title":"\u53cc\u8fb9\u6ee4\u6ce2\u7684general idea","text":"
- \u975e\u7ebf\u6027
- \u5e38\u7528n\u00d7n\u7684\u4e2d\u503c\u6ee4\u6ce2\u5668\u53bb\u9664\u90a3\u4e9b\u76f8\u5bf9\u4e8e\u5176\u90bb\u57df\u50cf\u7d20\u66f4\u4eae\u6216\u66f4\u6697\uff0c\u5e76\u4e14\u5176\u533a\u57df\u5c0f\u4e8en2/2\uff08\u6ee4\u6ce2\u5668\u533a\u57df\u7684\u4e00\u534a\uff09\u7684\u5b64\u7acb\u50cf\u7d20\u96c6\u3002
\u2f00\u5e45\u56fe\u50cf\u6709\u4e24\u4e2a\u4e3b\u8981\u7279\u5f81
\u7a7a\u95f4\u57dfS\uff0c\u5b83\u662f\u2f00\u5e45\u56fe\u50cf\u4e2d\u53ef\u80fd\u4f4d\u7f6e\u7684\u96c6\u5408\u3002 \u8fd9\u4e0e\u5206\u8fa8\u7387\u6709\u5173\uff0c\u4e5f\u5c31\u662f\u56fe\u50cf\u4e2d\u7684\u2f8f\u6570\u548c\u5217\u6570\u3002
\u5f3a\u5ea6\u57dfR\uff0c\u662f\u53ef\u80fd\u50cf\u7d20\u503c\u7684\u96c6\u5408\u3002 \u2f64\u6765\u8868\u793a\u50cf\u7d20\u503c\u7684\u4f4d\u6570\u53ef\u80fd\u4f1a\u53d8\u5316\u3002 \u5e38\u2ec5\u7684\u50cf\u7d20\u8868\u793a\u5f62\u5f0f\u662f\u2f46\u7b26\u53f7\u5b57\u8282(0\u5230255)\u548c\u6d6e\u70b9\u6570\u3002
\u2fbc\u65af\u6ee4\u6ce2\u53ea\u8003\u8651\u4e86\u524d\u2f00\u4e2a\u57df\u3002\uff08\u628a\\(r\\)\u62c9\u5230\u6b63\u65e0\u7a77\uff0c\u90a3\u4e48\u5c06\u53d8\u6210\u9ad8\u65af\u6a21\u7cca\uff09
\u53cc\u8fb9\u6ee4\u6ce2\u516c\u5f0f\u6bcf\u4e2a\u7684\u542b\u4e49
From GPT \u53cc\u8fb9\u6ee4\u6ce2\uff08Bilateral Filter\uff09\u662f\u4e00\u79cd\u5e38\u7528\u7684\u56fe\u50cf\u5904\u7406\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u5728\u4fdd\u6301\u8fb9\u7f18\u6e05\u6670\u7684\u540c\u65f6\u5bf9\u56fe\u50cf\u8fdb\u884c\u5e73\u6ed1\u5904\u7406\u3002\u53cc\u8fb9\u6ee4\u6ce2\u5668\u7684\u4e24\u4e2a\u53c2\u6570\u5206\u522b\u662f\u7a7a\u95f4\u57df\u6807\u51c6\u5dee\uff08\\(\\sigma_s\\)\uff09\u548c\u7070\u5ea6\u503c\u57df\u6807\u51c6\u5dee\uff08\\(\\sigma_r\\)\uff09\u3002
- \\(\\sigma_s\\)\uff1a\u63a7\u5236\u4e86\u5728\u7a7a\u95f4\u4e0a\u8fdb\u884c\u5e73\u6ed1\u7684\u8303\u56f4\u3002\u8f83\u5927\u7684 \\(\\sigma_s\\) \u503c\u610f\u5473\u7740\u66f4\u5e7f\u6cdb\u7684\u7a7a\u95f4\u8303\u56f4\u5185\u7684\u50cf\u7d20\u5c06\u88ab\u8003\u8651\uff0c\u4ece\u800c\u4ea7\u751f\u66f4\u5927\u8303\u56f4\u7684\u5e73\u6ed1\u6548\u679c\u3002
- \\(\\sigma_r\\)\uff1a\u63a7\u5236\u4e86\u5bf9\u7070\u5ea6\u503c\u8fdb\u884c\u5e73\u6ed1\u7684\u8303\u56f4\u3002\u8f83\u5927\u7684 \\(\\sigma_r\\) \u503c\u610f\u5473\u7740\u5bf9\u4e8e\u7070\u5ea6\u503c\u5dee\u5f02\u8f83\u5927\u7684\u50cf\u7d20\uff0c\u5176\u6743\u91cd\u4f1a\u66f4\u5927\uff0c\u8fd9\u53ef\u4ee5\u5e2e\u52a9\u4fdd\u6301\u56fe\u50cf\u7684\u8fb9\u7f18\u4fe1\u606f\u3002
- \u589e\u5927 \\(\\sigma_s\\) \u4f1a\u5bfc\u81f4\u66f4\u5927\u8303\u56f4\u7684\u50cf\u7d20\u88ab\u8003\u8651\u5728\u5185\uff0c\u56e0\u6b64\u4ea7\u751f\u66f4\u5927\u8303\u56f4\u7684\u5e73\u6ed1\u6548\u679c\uff0c\u4f46\u4e5f\u53ef\u80fd\u5bfc\u81f4\u56fe\u50cf\u5931\u771f\u3002\u800c\u589e\u5927 \\(\\sigma_r\\) \u4f1a\u4f7f\u5f97\u5bf9\u7070\u5ea6\u503c\u5dee\u5f02\u8f83\u5927\u7684\u50cf\u7d20\u6709\u66f4\u5927\u7684\u6743\u91cd\uff0c\u56e0\u6b64\u53ef\u4ee5\u66f4\u597d\u5730\u4fdd\u7559\u56fe\u50cf\u7684\u8fb9\u7f18\u4fe1\u606f\uff0c\u4f46\u4e5f\u53ef\u80fd\u5bfc\u81f4\u8fb9\u7f18\u7ec6\u8282\u4e0d\u591f\u5e73\u6ed1\u3002 \u56e0\u6b64\uff0c\u5408\u7406\u9009\u62e9 \\(\\sigma_s\\) \u548c \\(\\sigma_r\\) \u7684\u503c\u5bf9\u4e8e\u83b7\u5f97\u6ee1\u610f\u7684\u53cc\u8fb9\u6ee4\u6ce2\u6548\u679c\u975e\u5e38\u91cd\u8981\u3002
How to set \uff08From PPT\uff09
- \\(\\sigma_s\\) : \u4e0e\u7a97\u53e3\u5927\u5c0f\u6709\u5173
- \\(\\sigma_r\\) : \u4e0e\u8fb9\u7f18\u632f\u5e45\u6210\u6b63\u6bd4
- \u4e0e\u5206\u8fa8\u7387\u548c\u66dd\u5149\u65e0\u5173
\u53cc\u8fb9\u6ee4\u6ce2\u56e0\u4e3a\u5f15\u2f0a\u4e86\u5feb\u901f\u5085\u2fa5\u53f6\u53d8\u5316\u624d\u5b9e\u73b0\u52a0\u901f
"},{"location":"CS/DIP/DIP_Review/#_23","title":"\u6d88\u9664\u566a\u97f3","text":""},{"location":"CS/DIP/DIP_Review/#guided-filterguided-filter","title":"Guided filter\u4e3a\u4ec0\u4e48\u2f50\u53cc\u8fb9\u6ee4\u6ce2\u597d\uff0c\u4ee5\u53caGuided filter\u7684\u4f18\u70b9","text":"Regularization \u8d8a\u5927\uff0c\u4fdd\u8fb9\u80fd\u529b\u8d8a\u5f3a
\u56e0\u4e3aGuided filter\u8003\u8651\u4e86\u4fdd\u68af\u5ea6\uff0c\u4e0d\u4f1a\u9020\u6210\u68af\u5ea6\u7684\u9006\u8f6c\uff0c\u4f46\u662f\u53cc\u8fb9\u6ee4\u6ce2\u4f1a\u4ea7\u2f63\u68af\u5ea6\u7684\u9006\u8f6c\uff0c\u56e0\u4e3a\u53cc\u8fb9\u4fdd\u7684\u662fdifference\u7684\u7edd\u5bf9\u503c\uff0c\u2f7d\u4e0d\u662f\u2f45\u5411\u3002
\u79fb\u9664\u4e0d\u9700\u8981\u7684\u9891\u7387
"},{"location":"CS/DIP/DIP_Review/#snf","title":"SNF \u7a00\u758f\u8303\u6570\u6ee4\u6ce2","text":"
- p>1\u4e0d\u80fd\u9632\u6b62\u68af\u5ea6\u9006\u8f6c\uff0cp<1\u624d\u53ef
\u8bc1\u660e\uff1ap = 1\uff0c\u4e2d\u503c\u6ee4\u6ce2\uff1bp=2\uff0c\u9ad8\u65af\u6ee4\u6ce2\uff08\u5747\u503c\uff09
\u56e0\u4e3a SNF \u7684\u5fae\u5206\u662f\u975e\u5c40\u90e8\u7684\uff0c\u4ed6\u4e0d\u90a3\u4e48\u53ef\u80fd\u9677\u5165\u68af\u5ea6\u4e0b\u964d\u7684\u60c5\u51b5
"},{"location":"CS/DIP/DIP_Review/#ch6","title":"Ch6","text":""},{"location":"CS/DIP/DIP_Review/#ft","title":"FT \u5085\u91cc\u53f6\u53d8\u6362","text":"
- \u4e0b\u9762\u4e3aFT\u7684\u53bb\u566a
"},{"location":"CS/DIP/DIP_Review/#dft","title":"DFT","text":"1. \u8fdb\u884c\u5085\u91cc\u53f6\u53d8\u6362\n2. \u5728\u53d8\u6362\u540e\u7684X\uff08t\uff09\u4e2d\u8fdb\u884c\u6ee4\u6ce2\n3. \u8fdb\u884c\u9006\u5085\u91cc\u53f6\u53d8\u6362\n
"},{"location":"CS/DIP/DIP_Review/#fft","title":"FFT \u5feb\u901f\u5085\u91cc\u53f6\u53d8\u6362","text":"
- \u76f8\u4f4d\u53ef\u4ee5\u7528\u6765\u4f20\u9012\u7ed3\u6784\u4fe1\u606f\uff0c\u5e45\u503c\u4e0d\u884c
- \u5c06\u539f\u59cb\u7684 N \u70b9\u5e8f\u5217\u4f9d\u6b21\u5206\u89e3\u4e3a\u4e00\u7cfb\u5217\u77ed\u5e8f\u5217\uff1b
- \u6c42\u51fa\u8fd9\u4e9b\u77ed\u5e8f\u5217\u7684\u79bb\u6563\u5085\u7acb\u53f6\u53d8\u6362\uff1b
- \u7ec4\u5408\u51fa\u6240\u9700\u7684\u53d8\u6362\u503c\uff1b
- \u8ba1\u7b97\u91cf\uff08\u4e58\u9664\u6cd5\uff09\uff1a
FFT\u7684\u63a8\u5bfc
"},{"location":"CS/DIP/DIP_Review/#ch7","title":"Ch7","text":""},{"location":"CS/DIP/DIP_Review/#_24","title":"\u89d2\u70b9\u7279\u5f81\u68c0\u6d4b","text":"\u6211\u4eec\u8003\u8651\u4e00\u4e2a\u5c0f\u7a97\u53e3\u7684\u50cf\u7d20
- flat: \u5728\u4efb\u4f55\u65b9\u5411\u90fd\u4e0d\u4f1a\u6709\u50cf\u7d20\u7684\u6539\u53d8
- egde: \u6cbf\u7740\u8fb9\u7684\u65b9\u5411\u4e0d\u4f1a\u6709\u50cf\u7d20\u7684\u6539\u53d8
- corner: \u5728\u4efb\u4f55\u65b9\u5411\u90fd\u4f1a\u6709\u660e\u663e\u7684\u6539\u53d8
\u7279\u5f81
- \u65cb\u8f6c\u4e0d\u53d8\u6027
- \u7f29\u653e\u4f1a\u5177\u6709\u5f71\u54cd
Detect the Error \u4f7f\u7528SSD suming up the Square Differen'vce
\u6211\u4eec\u53ef\u4ee5\u5728\u84dd\u8272\u7684\u5706\u5708\u5185\u79fb\u52a8window\uff0c\u6700\u5927\u548c\u6700\u5c0f\u7684E\u7684\u4f4d\u7f6e\u5982\u4f55\u53d6\u5f97\u4f9d\u8d56\u4e8eH\u7684\u7279\u5f81\u5411\u91cf
"},{"location":"CS/DIP/DIP_Review/#_25","title":"\u4e0d\u53d8\u6027","text":""},{"location":"CS/DIP/DIP_Review/#harris-laplacian","title":"Harris Laplacian","text":"\u4e0d\u540c\u7ef4\u5ea6\u8ba1\u7b97\u65b9\u6cd5\u4e0d\u4e00\u6837
- \u521d\u59cb\u5316\uff1a\u591a\u5c3a\u5ea6\u7684 Harris corner detection(\u6539\u53d8\u6e05\u6670\u5ea6\u540e\uff0c\u5355\u72ec\u627e\u89d2\u70b9) \u53ea\u6709\u5728\u4efb\u4f55\u5c3a\u5ea6\u4e0a\u90fd\u662f\u89d2\u70b9\u7684\u70b9\uff0c\u624d\u80fd\u88ab\u4fdd\u7559
- \u57fa\u4e8e\u62c9\u666e\u62c9\u65af\u7b97\u5b50\uff0c\u8fdb\u884c\u5c3a\u5ea6\u9009\u62e9\u3002\u5bf9\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u54ea\u4e00\u4e2a\u5c3a\u5ea6\u4e0a\u62c9\u666e\u62c9\u65af\u503c\u6700\u5927\uff0c\u5c06\u8fd9\u4e2a\u4f4d\u7f6e\u548c\u5c3a\u5ea6\u4f5c\u4e3a\u89d2\u70b9\u3002\uff08\u552f\u4e00\u6027\uff0c\u5728\u8fd9\u4e2a\u5c3a\u5ea6\u4e0a\u662f\u6781\u5927\u503c\uff0c\u90a3\u4e48\u5728\u53e6\u4e00\u4e2a\u5c3a\u5ea6\u4e0a\u4e5f\u662f\u6781\u5927\u503c\uff0c\u53ea\u662f\u6781\u5927\u503c\u7684\u6570\u503c\u53ef\u80fd\u4e0d\u540c\uff09
Laplacian-of-Gaussian = \"blob\" detector
\u5728\u56fe\u50cf\u4e2d\u7ed9\u5b9a\u7684\u4e00\u4e2a\u70b9\uff0c\u6211\u4eec\u5b9a\u4e49\u62c9\u666e\u62c9\u65af\u54cd\u5e94\u503c\u8fbe\u5230\u5cf0\u503c\u7684\u5c3a\u5ea6\u4e3a\u7279\u5f81\u5c3a\u5ea6(characteristic scale)
"},{"location":"CS/DIP/DIP_Review/#sift","title":"SIFT","text":"
- \u5728\u68c0\u6d4b\u5230\u7684\u7279\u5f81\u89d2\u70b9\u5468\u56f4\u9009\u53d6 16\u00d716 \u7684\u65b9\u5f62\u7a97\u53e3
- \u8ba1\u7b97\u6bcf\u4e2a\u50cf\u7d20\u7684\u8fb9\u7684\u671d\u5411(\u68af\u5ea6\u7684\u89d2\u5ea6- 90\u00b0)
- \u5254\u9664\u5f31\u8fb9\u7f18(\u5c0f\u4e8e\u9608\u503c\u68af\u5ea6\u5e45\u5ea6)
- \u521b\u5efa\u5269\u4e0b\u8fb9\u7684\u65b9\u5411\u7684\u76f4\u65b9\u56fe
\u5b8c\u6574\u7248\uff1a
"},{"location":"CS/DIP/DIP_Review/#sift_1","title":"SIFT\u4e3a\u4ec0\u4e48\u80fd\u505a\u5230\u65cb\u8f6c\u4e0d\u53d8\u6027","text":"
- \u5c06 16\u00d716 \u7684\u7a97\u53e3 \u5212\u5206\u4e3a 4\u00d74 \u7684\u7f51\u683c
- \u5bf9\u6bcf\u4e2a\u7f51\u683c\u8ba1\u7b97\u5176\u65b9\u5411\u76f4\u65b9\u56fe
- 16 cells * 8 orientations = 128 dimensional descriptor(128 \u7ef4\u5411\u91cf)
SIFT \u7279\u5f81\uff1a\u65cb\u8f6c\u4e0d\u53d8\u6027 \u6839\u636e\u5176\u4e3b\u8981\u68af\u5ea6\u65b9\u5411(dominant gradient orientation)\u65cb\u8f6c patch, \u8fd9\u6837\u53ef\u4ee5\u4f7f\u4ed6\u5904\u4e8e\u89c4\u8303\u65b9\u5411
"},{"location":"CS/DIP/DIP_Review/#sift_2","title":"SIFT\u4e3a\u4ec0\u4e48\u80fd\u505a\u5230\u5c3a\u5ea6\u4e0d\u53d8\u6027","text":"
\u5728\u68c0\u6d4b\u7279\u5f81\u9644\u8fd1\u521b\u5efa\u2f00\u4e2a16*16\u7684\u6b63\u2f45\u5f62\u7a97\u2f1d
\u5bf9\u4e8e\u6bcf\u4e2a\u50cf\u7d20\u8ba1\u7b97\u5176\u8fb9\u7f18\u2f45\u5411
\u9664\u53bb\u5f31\u7684\u8fb9
\u5bf9\u5269\u4e0b\u7684\u8fb9\u521b\u5efa\u2f00\u4e2a\u76f4\u2f45\u56fe
SIFT\u7684128\u7ef4\u7684\u7279\u5f81\u662f\u54ea\u6765\u7684
16*16\u7684\u7a97\u2f1d\u5206\u4e3a16\u4e2a4*4\u7684\u2f29\u5757\uff0c\u6bcf\u4e2a\u2f29\u5757\u6709\u2f0b\u4e2a\u2f45\u5411\uff0c\u6240\u4ee5\u6709128\u7ef4\u7684\u7279\u5f81
"},{"location":"CS/DIP/DIP_Review/#sift_3","title":"SIFT\u7684\u5e94\u2f64","text":"\u56fe\u50cf\u7684\u8bc6\u522b\u4e0e\u62fc\u63a5
"},{"location":"CS/DIP/DIP_Review/#sift_4","title":"SIFT\u7684\u4f18\u7f3a\u70b9","text":"\u4f18\u70b9\uff1a
\u5177\u6709\u5c3a\u5ea6\u3001 \u65cb\u8f6c\u3001 \u4eae\u5ea6\u4e0d\u53d8\u6027
\u5728\u5c40\u90e8\u5757\u4e0a\u6709\u2fbc\u5ea6\u72ec\u7279\u548c\u63cf\u8ff0\u6027
\u5728\u521a\u6027\u5bf9\u8c61\u8868\u793a\u4e2d\u7279\u522b\u6709\u6548
\u7f3a\u70b9\uff1a\u00a0
"},{"location":"CS/DIP/DIP_Review/#surf","title":"SURF","text":""},{"location":"CS/DIP/DIP_Review/#ransac","title":"RANSAC\u7684\u6d41\u7a0b","text":"
\u63d0\u53d6\u65f6\u95f4\u8fc7\u2ed3
\u5bf9\u4e8e\u2fae\u521a\u6027\u5bf9\u8c61\u7684\u8868\u73b0\u8f83\u5dee
\u2f46\u6cd5\u5728\u4e25\u91cd\u4eff\u5c04\u5931\u771f\u4e2d\u2f2f\u4f5c
\u62df\u5408\u6570\u5b66\u6a21\u578b\u5e76\u8bc6\u522b\u6570\u636e\u4e2d\u7684\u79bb\u7fa4\u503c\u7684\u8fed\u4ee3\u65b9\u6cd5\u3002\u5b83\u7684\u4e3b\u8981\u5e94\u7528\u662f\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u548c\u56fe\u50cf\u5904\u7406\u9886\u57df\uff0c\u7528\u4e8e\u4f30\u8ba1\u6a21\u578b\u53c2\u6570\uff0c\u4f8b\u5982\u62df\u5408\u7ebf\u3001\u5e73\u9762\u6216\u5176\u4ed6\u51e0\u4f55\u5f62\u72b6\uff0c\u5e76\u6392\u9664\u5f02\u5e38\u503c\u7684\u5f71\u54cd\u3002
\u968f\u673a\u62bd\u6837\uff1a\u9996\u5148\u4ece\u6570\u636e\u96c6\u4e2d\u968f\u673a\u9009\u62e9\u4e00\u5b9a\u6570\u91cf\u7684\u6570\u636e\u70b9\u6765\u6784\u5efa\u5019\u9009\u6a21\u578b\u3002
\u6a21\u578b\u62df\u5408\uff1a\u4f7f\u7528\u9009\u5b9a\u7684\u6570\u636e\u70b9\u6765\u62df\u5408\u6a21\u578b\uff08\u4f8b\u5982\uff0c\u62df\u5408\u4e00\u6761\u76f4\u7ebf\u4ee5\u9002\u5e94\u9009\u5b9a\u7684\u4e24\u4e2a\u70b9\uff09\u3002
- \u5185\u70b9\u7b5b\u9009\uff1a\u5bf9\u4e8e\u5269\u4f59\u7684\u6570\u636e\u70b9\uff0c\u68c0\u67e5\u5b83\u4eec\u662f\u5426\u4e0e\u5f53\u524d\u62df\u5408\u7684\u6a21\u578b\u4e00\u81f4\u3002\u5982\u679c\u4e00\u4e2a\u6570\u636e\u70b9\u4e0e\u5f53\u524d\u6a21\u578b\u4e00\u81f4\uff08\u4f8b\u5982\uff0c\u8ddd\u79bb\u5728\u4e00\u5b9a\u9608\u503c\u5185\uff09\uff0c\u5219\u5c06\u5176\u6807\u8bb0\u4e3a\u201c\u5185\u70b9\u201d\uff0c\u5426\u5219\u6807\u8bb0\u4e3a\u201c\u5916\u70b9\u201d\u3002
- \u8bc4\u4f30\u6a21\u578b\uff1a\u8ba1\u7b97\u6a21\u578b\u9002\u5e94\u6570\u636e\u7684\u5ea6\u91cf\uff0c\u4f8b\u5982\u7b26\u5408\u5185\u70b9\u7684\u6570\u91cf\u3002
- \u91cd\u590d\u8fed\u4ee3\uff1a\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa4\u591a\u6b21\uff08\u901a\u5e38\u662f\u51e0\u5341\u751a\u81f3\u51e0\u767e\u6b21\uff09\uff0c\u9009\u62e9\u4ea7\u751f\u6700\u5927\u5185\u70b9\u6570\u7684\u6a21\u578b\u3002
\u6a21\u578b\u9a8c\u8bc1\uff1a\u6700\u7ec8\u6a21\u578b\u9700\u8981\u7ecf\u8fc7\u9a8c\u8bc1\uff0c\u4ee5\u786e\u4fdd\u5176\u5728\u6574\u4e2a\u6570\u636e\u96c6\u4e0a\u7684\u6027\u80fd\u3002
\u968f\u673a\u9009\u62e9\u79cd\u5b50\u70b9\u4f5c\u4e3a\u8f6c\u6362\u4f30\u8ba1\u7684\u57fa\u7840
- \u8ba1\u7b97\u79cd\u5b50\u70b9\u4e4b\u95f4\u7684\u53d8\u6362
- \u627e\u5230\u8fd9\u6b21\u53d8\u6362\u7684 inliers
- \u5982\u679c inliners \u7684\u6570\u76ee\u8db3\u591f\u591a\uff0c\u90a3\u4e48\u91cd\u65b0\u8ba1\u7b97\u6240\u6709 inliners \u4e0a\u7684\u6700\u5c0f\u4e8c\u4e58\u6cd5\u4f30\u8ba1
- \u56de\u5f52\u4e4b\u540e\u518d\u8ba1\u7b97 inliners \u5982\u6b64\u5f80\u590d\uff0c\u7ee7\u7eed\u8c03\u6574\u3002\u5982\u679c\u6ca1\u6709\u8c03\u6574\u90a3\u6211\u4eec\u53ef\u4ee5\u505c\u6b62\u5faa\u73af\u3002\u6700\u7ec8\u4f7f\u5f97\u56de\u5f52\u51fa\u7684\u7ebf\u8fbe\u5230\u6700\u591a\u7684 inliners.
w=0.8, \u6a21\u578b\u53d6\u70b9\u6570\u4e3a3\uff0c\u95ee\u6700\u5c11\u8981\u53d6\u51e0\u4e2a\u70b9\u624d\u80fd\u4fdd\u8bc1\u6982\u7387>95%RANSEC\u6536\u655b
"},{"location":"CS/DIP/DIP_Review/#_26","title":"\u56fe\u50cf\u62fc\u63a5\u7684\u4e3b\u8981\u6d41\u7a0b","text":""},{"location":"CS/DIP/DIP_Review/#_27","title":"\u62c9\u666e\u62c9\u65af\u91d1\u5b57\u5854","text":""},{"location":"CS/DIP/DIP_Review/#ch8","title":"Ch8","text":""},{"location":"CS/DIP/DIP_Review/#_28","title":"\u795e\u7ecf\u5143","text":""},{"location":"CS/DIP/DIP_Review/#bp","title":"BP\u7b97\u6cd5","text":"\u62c9\u666e\u62c9\u65af\u91d1\u5b57\u5854\u662f\u901a\u8fc7\u9ad8\u65af\u91d1\u5b57\u5854\u8ba1\u7b97\u5f97\u5230\u7684\u3002\u4e0b\u9762\u662f\u83b7\u5f97\u62c9\u666e\u62c9\u65af\u91d1\u5b57\u5854\u7684\u6b65\u9aa4\uff1a\n\n1. \u9996\u5148\uff0c\u901a\u8fc7\u5bf9\u539f\u59cb\u56fe\u50cf\u8fdb\u884c\u91cd\u590d\u91c7\u6837\u548c\u9ad8\u65af\u6a21\u7cca\u64cd\u4f5c\uff0c\u5f97\u5230\u9ad8\u65af\u91d1\u5b57\u5854\u3002\u9ad8\u65af\u91d1\u5b57\u5854\u662f\u7531\u4e00\u7cfb\u5217\u5206\u8fa8\u7387\u9010\u6e10\u51cf\u5c0f\u7684\u56fe\u50cf\u7ec4\u6210\u7684\uff0c\u6bcf\u4e00\u5c42\u56fe\u50cf\u90fd\u662f\u901a\u8fc7\u5bf9\u4e0a\u4e00\u5c42\u56fe\u50cf\u8fdb\u884c\u964d\u91c7\u6837\u548c\u9ad8\u65af\u6a21\u7cca\u5f97\u5230\u7684\u3002\n\n2. \u63a5\u4e0b\u6765\uff0c\u901a\u8fc7\u5bf9\u9ad8\u65af\u91d1\u5b57\u5854\u8fdb\u884c\u4e0a\u91c7\u6837\uff0c\u5f97\u5230\u4e00\u4e2a\u6bd4\u539f\u59cb\u56fe\u50cf\u5927\u4e00\u500d\u7684\u56fe\u50cf\u3002\u7136\u540e\uff0c\u5c06\u4e0a\u4e00\u5c42\u9ad8\u65af\u91d1\u5b57\u5854\u7684\u56fe\u50cf\u51cf\u53bb\u4e0a\u91c7\u6837\u5f97\u5230\u7684\u56fe\u50cf\uff0c\u5f97\u5230\u5f53\u524d\u5c42\u7684\u62c9\u666e\u62c9\u65af\u56fe\u50cf\u3002\n\n3. \u91cd\u590d\u8fdb\u884c\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u76f4\u5230\u8fbe\u5230\u91d1\u5b57\u5854\u7684\u9876\u5c42\u3002\n\n\u901a\u8fc7\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u62c9\u666e\u62c9\u65af\u91d1\u5b57\u5854\uff0c\u5b83\u662f\u7531\u4e00\u7cfb\u5217\u56fe\u50cf\u7ec4\u6210\u7684\uff0c\u6bcf\u4e2a\u56fe\u50cf\u90fd\u4ee3\u8868\u4e86\u539f\u59cb\u56fe\u50cf\u5728\u4e0d\u540c\u7a7a\u95f4\u5c3a\u5ea6\u4e0a\u7684\u7ec6\u8282\u4fe1\u606f\u3002\n
- BP\u7b97\u6cd5\u89e3\u51b3\u7684\u662f\u591a\u91cd\u795e\u7ecf\u7f51\u7edc\u7684\u6c42\u89e3\u8fc7\u7a0b\uff08\u5e2e\u52a9\u7406\u89e3\uff09
\u200b \u4e0d\u65ad\u91cd\u590d\uff0c\u76f4\u5230E\u5c0f\u4e8e\u4e00\u4e2a\u9608\u503c
"},{"location":"CS/DIP/DIP_Review/#_29","title":"\u4e3a\u4ec0\u4e48\u52a0\u5165\u5377\u79ef\u6838\uff0c\u597d\u5904","text":"\u52a0\u5165\u5377\u79ef\u6838\u6709\u52a9\u4e8e\u51cf\u5c11\u8ba1\u7b97\u91cf\uff0c\u8fd9\u4e3b\u8981\u4f53\u73b0\u5728\u4e24\u4e2a\u65b9\u9762\uff1a
"},{"location":"CS/DIP/DIP_Review/#_30","title":"\u8ba1\u7b97","text":"
- \u53c2\u6570\u5171\u4eab\uff1a - \u5377\u79ef\u6838\u7684\u53c2\u6570\u662f\u5171\u4eab\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5728\u6574\u4e2a\u8f93\u5165\u6570\u636e\u4e0a\u4f7f\u7528\u76f8\u540c\u7684\u5377\u79ef\u6838\u8fdb\u884c\u7279\u5f81\u63d0\u53d6\u3002 \u56e0\u6b64\uff0c\u65e0\u8bba\u8f93\u5165\u6570\u636e\u7684\u5927\u5c0f\u5982\u4f55\uff0c\u5377\u79ef\u6838\u7684\u53c2\u6570\u6570\u91cf\u90fd\u4fdd\u6301\u4e0d\u53d8\u3002\u8fd9\u79cd\u53c2\u6570\u5171\u4eab\u51cf\u5c11\u4e86\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u6570\u91cf\uff0c\u4ece\u800c\u964d\u4f4e\u4e86\u6a21\u578b\u7684\u590d\u6742\u6027\u3002
- \u4e3e\u4f8b\u6765\u8bf4\uff0c\u5047\u8bbe\u8f93\u5165\u6570\u636e\u662f\u4e00\u4e2a\u56fe\u50cf\uff0c\u5982\u679c\u6211\u4eec\u4f7f\u7528\u5927\u5c0f\u4e3a3x3\u7684\u5377\u79ef\u6838\u8fdb\u884c\u7279\u5f81\u63d0\u53d6\uff0c\u65e0\u8bba\u56fe\u50cf\u7684\u5c3a\u5bf8\u5982\u4f55\uff0c\u5377\u79ef\u6838\u7684\u53c2\u6570\u6570\u91cf\u90fd\u662f\u56fa\u5b9a\u7684\uff0c\u56e0\u4e3a\u5377\u79ef\u6838\u5728\u6574\u4e2a\u56fe\u50cf\u4e0a\u5171\u4eab\u53c2\u6570\u3002\u8fd9\u79cd\u53c2\u6570\u5171\u4eab\u5927\u5927\u51cf\u5c11\u4e86\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u6570\u91cf\uff0c\u964d\u4f4e\u4e86\u8ba1\u7b97\u6210\u672c\u3002
- \u7a00\u758f\u4ea4\u4e92\uff1a - \u5377\u79ef\u64cd\u4f5c\u662f\u5c40\u90e8\u8fde\u63a5\u7684\uff0c\u6bcf\u4e2a\u8f93\u51fa\u5143\u7d20\u4ec5\u4e0e\u8f93\u5165\u7684\u5c40\u90e8\u533a\u57df\u6709\u5173\u3002\u8fd9\u79cd\u7a00\u758f\u4ea4\u4e92\u4f7f\u5f97\u6a21\u578b\u66f4\u5177\u6709\u6548\u6027\uff0c\u56e0\u4e3a\u5728\u5377\u79ef\u64cd\u4f5c\u4e2d\uff0c\u53ea\u6709\u5377\u79ef\u6838\u8986\u76d6\u5230\u7684\u533a\u57df\u624d\u4f1a\u53c2\u4e0e\u8ba1\u7b97\uff0c\u800c\u5176\u4ed6\u533a\u57df\u5219\u4e0d\u4f1a\u5f71\u54cd\u8f93\u51fa\u7ed3\u679c\u3002
- \u4e3e\u4f8b\u6765\u8bf4\uff0c\u5047\u8bbe\u8f93\u5165\u6570\u636e\u662f\u4e00\u4e2a\u5927\u5c3a\u5bf8\u7684\u56fe\u50cf\uff0c\u800c\u5377\u79ef\u6838\u7684\u5927\u5c0f\u76f8\u5bf9\u8f83\u5c0f\uff0c\u90a3\u4e48\u5728\u5377\u79ef\u64cd\u4f5c\u4e2d\uff0c\u6bcf\u4e2a\u5377\u79ef\u6838\u53ea\u9700\u8981\u4e0e\u8f93\u5165\u6570\u636e\u7684\u4e00\u4e2a\u5c0f\u533a\u57df\u8fdb\u884c\u4ea4\u4e92\uff0c\u800c\u4e0d\u9700\u8981\u8003\u8651\u6574\u4e2a\u56fe\u50cf\u3002\u8fd9\u79cd\u7a00\u758f\u4ea4\u4e92\u51cf\u5c11\u4e86\u9700\u8981\u5904\u7406\u7684\u6570\u636e\u91cf\uff0c\u4ece\u800c\u964d\u4f4e\u4e86\u8ba1\u7b97\u6210\u672c\u3002 \u56e0\u6b64\uff0c\u901a\u8fc7\u53c2\u6570\u5171\u4eab\u548c\u7a00\u758f\u4ea4\u4e92\uff0c\u52a0\u5165\u5377\u79ef\u6838\u6709\u52a9\u4e8e\u51cf\u5c11\u8ba1\u7b97\u91cf\uff0c\u964d\u4f4e\u6a21\u578b\u7684\u590d\u6742\u6027\uff0c\u5e76\u63d0\u9ad8\u6a21\u578b\u7684\u8ba1\u7b97\u6548\u7387\u3002
From GPT \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u8ba1\u7b97\u6bcf\u4e2a\u5377\u79ef\u5c42\u8f93\u51fa\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\u3002
\u5047\u8bbe\u8f93\u5165\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\u4e3a \\(W_{\\text{in}}\\times H_{\\text{in}}\\times D_{\\text{in}}\\)\uff0c\u5377\u79ef\u6838\u7684\u5c3a\u5bf8\u4e3a \\(F\\times F\\times D_{\\text{in}}\\times D_{\\text{out}}\\)\uff0c\u6b65\u957f\u4e3a \\(S\\)\uff0c\u586b\u5145\u4e3a \\(P\\)\u3002
\u5bf9\u4e8e\u6ca1\u6709\u586b\u5145\u7684\u60c5\u51b5\uff0c\u8f93\u51fa\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u516c\u5f0f\u8ba1\u7b97\uff1a $$ W_{\\text{out}} = \\frac{W_{\\text{in}} - F}{S} + 1 $$ $$ H_{\\text{out}} = \\frac{H_{\\text{in}} - F}{S} + 1 $$ $$ D_{\\text{out}} = \\text{\u5377\u79ef\u6838\u7684\u6570\u91cf} $$
\u5bf9\u4e8e\u6c60\u5316\u5c42\uff0c\u8f93\u51fa\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\u8ba1\u7b97\u65b9\u5f0f\u7c7b\u4f3c\uff0c\u4f46\u662f\u662f\u4f7f\u7528\u6c60\u5316\u6838\u7684\u5c3a\u5bf8\u548c\u6b65\u957f\u8fdb\u884c\u8ba1\u7b97\u3002 \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0a\u8ff0\u516c\u5f0f\u8ba1\u7b97\u6bcf\u4e2a\u5377\u79ef\u5c42\u7684\u8f93\u51fa\u7279\u5f81\u56fe\u5c3a\u5bf8\u3002
"},{"location":"CS/DIP/DIP_Review/#_31","title":"\u56fe\u50cf\u5206\u7c7b\u7684\u533a\u522b","text":""},{"location":"CS/DIP/DIP_Review/#_32","title":"\u4ea4\u53c9\u71b5","text":"
\u4f20\u7edf\u7684\u56fe\u50cf\u5206\u7c7b\uff1a
\u4f20\u7edf\u7684\u56fe\u50cf\u5206\u7c7b\u65b9\u6cd5\u901a\u5e38\u57fa\u4e8e\u624b\u5de5\u8bbe\u8ba1\u7684\u7279\u5f81\u63d0\u53d6\u5668\uff0c\u4f8b\u5982SIFT\uff08\u5c3a\u5ea6\u4e0d\u53d8\u7279\u5f81\u53d8\u6362\uff09\u548cHOG\uff08\u65b9\u5411\u68af\u5ea6\u76f4\u65b9\u56fe\uff09\u3002\u8fd9\u4e9b\u7279\u5f81\u63d0\u53d6\u65b9\u6cd5\u4f9d\u8d56\u4e8e\u9886\u57df\u4e13\u5bb6\u5bf9\u56fe\u50cf\u7279\u5f81\u7684\u7406\u89e3\uff0c\u7136\u540e\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff08\u5982\u652f\u6301\u5411\u91cf\u673a\u3001\u968f\u673a\u68ee\u6797\u7b49\uff09\u5bf9\u63d0\u53d6\u7684\u7279\u5f81\u8fdb\u884c\u5206\u7c7b\u3002
\u4f20\u7edf\u65b9\u6cd5\u7684\u5c40\u9650\u5728\u4e8e\u7279\u5f81\u63d0\u53d6\u9700\u8981\u4f9d\u8d56\u9886\u57df\u4e13\u5bb6\u7684\u77e5\u8bc6\uff0c\u5e76\u4e14\u5728\u590d\u6742\u6570\u636e\u96c6\u4e0a\u7684\u6cdb\u5316\u80fd\u529b\u6709\u9650\u3002
\u6df1\u5ea6\u5b66\u4e60\u7684\u56fe\u50cf\u5206\u7c7b\uff1a
\u6df1\u5ea6\u5b66\u4e60\u65b9\u6cd5\uff0c\u7279\u522b\u662f\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\uff0c\u80fd\u591f\u7aef\u5230\u7aef\u5730\u5b66\u4e60\u56fe\u50cf\u7684\u7279\u5f81\u8868\u793a\u548c\u5206\u7c7b\u5668\uff0c\u65e0\u9700\u624b\u52a8\u8bbe\u8ba1\u7279\u5f81\u63d0\u53d6\u5668\u3002\u6df1\u5ea6\u5b66\u4e60\u65b9\u6cd5\u901a\u8fc7\u5b66\u4e60\u4ece\u539f\u59cb\u6570\u636e\u5230\u76ee\u6807\u6807\u7b7e\u7684\u6620\u5c04\u5173\u7cfb\uff0c\u53ef\u4ee5\u81ea\u52a8\u5730\u53d1\u73b0\u548c\u63d0\u53d6\u7279\u5f81\uff0c\u4ece\u800c\u5728\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\u4e0a\u53d6\u5f97\u4e86\u663e\u8457\u7684\u6027\u80fd\u63d0\u5347\u3002
- \u6df1\u5ea6\u5b66\u4e60\u65b9\u6cd5\u7684\u4f18\u52bf\u5728\u4e8e\u5b83\u4eec\u80fd\u591f\u4ece\u5927\u89c4\u6a21\u6570\u636e\u4e2d\u5b66\u4e60\u7279\u5f81\u8868\u793a\uff0c\u65e0\u9700\u4f9d\u8d56\u9886\u57df\u4e13\u5bb6\u7684\u5148\u9a8c\u77e5\u8bc6\uff0c\u540c\u65f6\u5728\u5904\u7406\u590d\u6742\u6570\u636e\u96c6\u65f6\u5177\u6709\u66f4\u597d\u7684\u6cdb\u5316\u80fd\u529b\u3002
"},{"location":"CS/DIP/DIP_Review/#cnn","title":"CNN","text":"
- \u4ee3\u8868\u542b\u4e49\uff1a - \u4ea4\u53c9\u71b5\u662f\u4e00\u79cd\u8861\u91cf\u4e24\u4e2a\u6982\u7387\u5206\u5e03\u4e4b\u95f4\u5dee\u5f02\u7684\u5ea6\u91cf\u65b9\u5f0f\u3002\u5728\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u4ea4\u53c9\u71b5\u5e38\u88ab\u7528\u4f5c\u635f\u5931\u51fd\u6570\uff0c\u7279\u522b\u662f\u5728\u5206\u7c7b\u95ee\u9898\u4e2d\u3002
- \u635f\u5931\\(L\\)\uff1a
- \u5bf9\u4e8e\u4e8c\u5206\u7c7b\u95ee\u9898\uff0c\u7ed9\u5b9a\u771f\u5b9e\u6807\u7b7e\\(y\\)\u548c\u6a21\u578b\u9884\u6d4b\u7684\u6982\u7387\u5206\u5e03\\(\\hat{y}\\)\uff0c\u4ea4\u53c9\u71b5\u635f\u5931\\(L\\)\u53ef\u4ee5\u8868\u793a\u4e3a\uff1a\\(L(y, \\hat{y}) = -\\left(y \\log(\\hat{y}) + (1 - y) \\log(1 - \\hat{y})\\right)\\)\u3002
- \u5bf9\u4e8e\u591a\u5206\u7c7b\u95ee\u9898\uff0c\u7ed9\u5b9a\u771f\u5b9e\u6807\u7b7e\\(y\\)\u548c\u6a21\u578b\u9884\u6d4b\u7684\u6982\u7387\u5206\u5e03\\(\\hat{y}\\)\uff0c\u4ea4\u53c9\u71b5\u635f\u5931\\(L\\)\u53ef\u4ee5\u8868\u793a\u4e3a\uff1a\\(L(y, \\hat{y}) = -\\sum_{i} y_i \\log(\\hat{y}_i)\\)\uff0c\u5176\u4e2d\\(y_i\\)\u8868\u793a\u771f\u5b9e\u6807\u7b7e\u7684\u6982\u7387\u5206\u5e03\uff0c\\(\\hat{y}_i\\)\u8868\u793a\u6a21\u578b\u9884\u6d4b\u7684\u6982\u7387\u5206\u5e03\u3002 \u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570\u5728\u8bad\u7ec3\u795e\u7ecf\u7f51\u7edc\u65f6\u7ecf\u5e38\u88ab\u7528\u4f5c\u76ee\u6807\u51fd\u6570\uff0c\u56e0\u4e3a\u5b83\u80fd\u591f\u6709\u6548\u5730\u8861\u91cf\u6a21\u578b\u8f93\u51fa\u4e0e\u771f\u5b9e\u6807\u7b7e\u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u5e76\u4e14\u80fd\u591f\u4fc3\u4f7f\u6a21\u578b\u4ea7\u751f\u66f4\u4e3a\u51c6\u786e\u7684\u6982\u7387\u5206\u5e03\u8f93\u51fa\u3002
"},{"location":"CS/DIP/DIP_Review/#cnn_1","title":"\u4e3a\u4ec0\u4e48\u5f15\u2f0aCNN\u53ef\u4ee5\u2f24\u89c4\u6a21\u51cf\u5c11\u6743\u6570\u53c2\u6570\u8bad\u7ec3\u91cf","text":"
- CNN \u662f\u5c11\u6709\u7684\u53ef\u4ee5\u76d1\u7763\u8bad\u7ec3\u7684\u6df1\u5ea6\u6a21\u578b\uff0c\u800c\u4e14\u5bb9\u6613\u7406\u89e3\u3001\u5b9e\u73b0\u3002
\u56e0\u4e3aCNN\u901a\u8fc7
1\uff09 \u5c40\u90e8\u8fde\u63a5\uff08Local Connectivity\uff09 \u5377\u79ef\u64cd\u4f5c\u662f\u5c40\u90e8\u8fde\u63a5\u7684\uff0c\u8fd9\u610f\u5473\u7740\u6bcf\u4e2a\u795e\u7ecf\u5143\u4ec5\u4e0e\u8f93\u5165\u7684\u5c40\u90e8\u533a\u57df\u76f8\u8fde\uff0c\u800c\u4e0d\u662f\u4e0e\u6574\u4e2a\u8f93\u5165\u76f8\u8fde\u3002\u8fd9\u79cd\u5c40\u90e8\u8fde\u63a5\u7684\u65b9\u5f0f\u4e5f\u51cf\u5c11\u4e86\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u6570\u91cf\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u795e\u7ecf\u5143\u53ea\u9700\u8981\u5b66\u4e60\u4e0e\u5c40\u90e8\u4fe1\u606f\u76f8\u5173\u7684\u6743\u91cd\u3002
2\uff09 \u6743\u503c\u5171\u4eab\uff08Shared Weights\uff09 \u5728CNN\u4e2d\uff0c\u5377\u79ef\u5c42\u4f7f\u7528\u6ee4\u6ce2\u5668\uff08\u6216\u5377\u79ef\u6838\uff09\u5bf9\u8f93\u5165\u8fdb\u884c\u5377\u79ef\u64cd\u4f5c\u3002\u8fd9\u4e9b\u6ee4\u6ce2\u5668\u5728\u56fe\u50cf\u7684\u4e0d\u540c\u4f4d\u7f6e\u90fd\u4f7f\u7528\u76f8\u540c\u7684\u53c2\u6570\u8fdb\u884c\u7279\u5f81\u63d0\u53d6\u3002\u8fd9\u79cd\u53c2\u6570\u5171\u4eab\u673a\u5236\u53ef\u4ee5\u5927\u5927\u51cf\u5c11\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u6570\u91cf\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u6ee4\u6ce2\u5668\u7684\u53c2\u6570\u90fd\u88ab\u91cd\u590d\u4f7f\u7528\u5728\u8f93\u5165\u7684\u4e0d\u540c\u4f4d\u7f6e\u4e0a
3\uff09 \u6c60\u5316\uff08Pooling\uff09 \u6c60\u5316\u5c42\u901a\u8fc7\u5bf9\u8f93\u5165\u6570\u636e\u8fdb\u884c\u4e0b\u91c7\u6837\uff0c\u51cf\u5c11\u4e86\u6bcf\u4e2a\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\uff0c\u4ece\u800c\u51cf\u5c11\u4e86\u540e\u7eed\u5c42\u7684\u8ba1\u7b97\u91cf\u3002\u8fd9\u6709\u52a9\u4e8e\u964d\u4f4e\u6a21\u578b\u7684\u590d\u6742\u5ea6\u548c\u8ba1\u7b97\u6210\u672c\u3002
\u6765\u964d\u4f4e\u53c2\u6570\u91cf
"},{"location":"CS/DIP/DIP_Review/#cnn_2","title":"CNN\u6c60\u5316\u7684\u610f\u4e49","text":"\u200b CNN\u6c60\u5316\u53ef\u4ee5\u901a\u8fc7\u6c60\u5316\u5c42\u6765\u964d\u4f4e\u5377\u79ef\u5c42\u8f93\u51fa\u7684\u7279\u5f81\u7ef4\u5ea6\uff0c\u5728\u6709\u6548\u51cf\u5c11\u2f79\u7edc\u53c2\u6570\u7684\u540c\u65f6\u8fd8\u53ef\u4ee5\u9632\u2f4c\u8fc7\u62df\u5408\u73b0\u8c61\u3002
\u66f4\u5927\u7684\u63a5\u53d7\u57df
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/","title":"Index","text":"\u7ea6 351 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
\u8bfe\u7a0b\u4fe1\u606f
- \u7b14\u8bb0\u5185\u5bb9\u4e3b\u8981\u6765\u81ea\u4e8e\u8bfe\u672c\u548c\u4e0a\u8bfe\u7528\u7684PPT
- \u7406\u8bba\u90e8\u5206: \u8fd9\u95e8\u8bfe\u7684\u7406\u8bba\u90e8\u5206\u96be\u5ea6\u8fd8\u597d\uff0c\u4e3b\u8981\u662f\u8981\u7406\u89e3\u4e00\u4e0b\u65f6\u5e8f\u7535\u8def\u8fd8\u6709\u540e\u9762\u7684\u5b58\u50a8\u5668\u90e8\u5206\uff0c\u8fd9\u4e00\u90e8\u5206\u7684\u65f6\u5e8f\u5ef6\u8fdf\u5206\u6790\u3001\u7535\u8def\u8bbe\u8ba1\u90fd\u6bd4\u8f83\u91cd\u8981\u3002
- \u5b9e\u9a8c\u90e8\u5206: \u786c\u4ef6\u8bfe\u7684\u5b9e\u9a8c\u6bd4\u8f83\u8ba9\u4eba\u5934\u5927\u3002\u524d\u4e09\u6b21\u5b9e\u9a8c\u662f\u7c7b\u4f3c\u4e8e\u7269\u7406\u5b9e\u9a8c\u7684\uff0c\u793a\u6ce2\u5668\u7684\u4f7f\u7528\u3001\u7535\u8def\u7684\u642d\u5efa\u7b49\u7b49\uff1b\u4e4b\u540e\u76844-7\u6b21\u5b9e\u9a8c\u4e3b\u8981\u5b66\u4e60ISE\u7684\u642d\u5efa\u4e0e\u57fa\u672c\u4f7f\u7528\uff08\u6211\u4eec\u8fd9\u4e00\u5c4a\u90e8\u5206\u73ed\u7ea7\u7528\u7684vivado\uff0c\u4e4b\u540e\u4e5f\u53ef\u80fd\u7edf\u4e00\u7528vivado\uff09\uff1b\u518d\u4e4b\u540e\u7684\u5b9e\u9a8c\u4f1a\u8981\u6c42\u5199\u4e00\u4e9bVerilog\u4ee3\u7801\uff08\u524d\u9762\u7684\u4e5f\u8981\u5199\uff0c\u4f46\u4e00\u822c\u90fd\u4f1a\u76f4\u63a5\u7ed9\u51fa\uff09\u3002 \u5c31\u6211\u4e2a\u4eba\u7684\u4f53\u9a8c\u6765\u8bf4\uff0c\u524d\u9762\u7684\u5b9e\u9a8c\u96be\u5ea6\u8fd8\u597d\uff0c\u4f46\u6700\u597d\u5728\u8fd9\u6bb5\u65f6\u95f4\u8d81\u7740\u6709\u6307\u5bfc\u628a\u4e00\u4e9b\u4e1c\u897f\u5f04\u660e\u767d\uff0c\u4e0d\u7136\u5230\u540e\u9762\u505a\u8d77\u6765\u4f1a\u5f88\u6162\u3002\u5927\u7a0b\u7684\u8bdd\uff0c\u8fd8\u662f\u5efa\u8bae\u65e9\u4e00\u70b9\u5f00\u59cb\uff0c\u6211\u4eec\u7ec4\u5f00\u59cb\u7684\u6bd4\u8f83\u65e9\uff0c\u5927\u6982\u641e\u4e86\u4e24\u4e09\u5468\u5728\u671f\u672b\u5468\u4e4b\u524d\u641e\u5b8c\u4e86\u3002\u5982\u679c\u5f00\u59cb\u665a\u7684\u8bdd\u5f88\u53ef\u80fd\u5f71\u54cd\u671f\u672b\u7684\u590d\u4e60\u3002
- \u8bfe\u7a0b\u5206\u6570
- Theory: 70%
- Quizzes 40% * 70% = 28%
- Projects: 20% *70 = 14%
- The final Examination: 40%*70% = 28% \u2022 Necessary condition: the score \u226550
- Experiments: 30%
\u8d44\u6e90
\u5f3a\u63a8\uff01\u4fee\u4f6c\u7684\u7b14\u8bb0\uff1aIsshiki\u4fee's Notebook
\u5386\u5e74\u5377\u548c\u8bfe\u672c\u7b54\u6848\uff1a \u6c42\u662f\u6f6e
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/","title":"Labs","text":"\u671f\u672b\u590d\u4e60\u7528
https://guahao31.github.io/2023_DD/lab5/decoder/
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#lab-05-decoder","title":"Lab 05 Decoder","text":"
- 74LS138
- G1,G2 G
- MC14495
\u7ea6 977 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
\u4f4e\u7535\u5e73\u6709\u6548(Low-Level Active)\uff0c\u6216\u79f0\u4f4e\u7535\u5e73\u89e6\u53d1\uff0c\u6307\u7684\u662f\u5728\u6570\u5b57\u7535\u8def\u4e2d\uff0c\u903b\u8f91\u95e8\u6216\u89e6\u53d1\u5668\u7684\u8f93\u5165\u6216\u63a7\u5236\u4fe1\u53f7\u5728\u4f4e\u7535\u5e73\uff08\u8f83\u4f4e\u7684\u7535\u538b\u503c\uff09\u65f6\u88ab\u89c6\u4e3a\u6709\u6548\u6216\u89e6\u53d1\u52a8\u4f5c\u3002\u9ad8\u7535\u5e73\u6709\u6548\u5219\u4e0e\u4e4b\u76f8\u5bf9\u3002 \u5728\u8fdb\u884c\u8bbe\u8ba1\u65f6\uff0c\u4e24\u8005\u90fd\u662f\u53ef\u884c\u7684\u9009\u9879\u3002
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#74ls138","title":"74LS138","text":"74LS138 \u82af\u7247\u662f\u4e00\u79cd 3-8 \u8bd1\u7801\u5668\u82af\u7247\uff0c\u7528\u4e8e\u5c06 3 \u4f4d\u4e8c\u8fdb\u5236\u5730\u5740\u8f93\u5165\u4fe1\u53f7\u8f6c\u6362\u4e3a 8 \u4e2a\u8f93\u51fa\u4fe1\u53f7\u4e4b\u4e00\u3002\u4e3b\u8981\u7aef\u53e3\u4e3a\u4f7f\u80fd\u8f93\u5165\u7ba1\u811a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#_1","title":"\u4f7f\u80fd\u4fe1\u53f7","text":"G, G2A, G2B
\uff0c\u5730\u5740\u8f93\u5165\u7ba1\u811aA, B, C
\uff08\u5176\u4e2dA
\u4e3a\u4f4e\u5730\u5740\uff09\uff0c\u8f93\u51fa\u7ba1\u811aY0~Y7
\u300274LS138 \u6709\u4e09\u4e2a\u4f7f\u80fd\u4fe1\u53f7
G, G2A, G2B
\uff0c\u5176\u4e2dG
\u4fe1\u53f7\u4e3a\u9ad8\u7535\u5e73\u6709\u6548\u7684\u4e3b\u8981\u4f7f\u80fd\u4fe1\u53f7\uff0c\u5f53\u5b83\u5904\u4e8e\u4f4e\u7535\u4f4d\u65f6\uff0c\u6240\u6709\u7684\u8f93\u51fa\u4fe1\u53f7\u5747\u5904\u4e8e\u65e0\u6548\u7535\u4f4d\uff08\u9ad8\u7535\u4f4d\uff09\u3002
G2A, G2B
\u662f\u770b\u8d77\u6765\u6709\u4e9b\u5197\u4f59\u7684\u4f7f\u80fd\u4fe1\u53f7\uff0c\u4ece\u771f\u503c\u8868\u53ef\u4ee5\u770b\u51fa\uff0c\u5b83\u4eec\u4e3a\u4f4e\u7535\u5e73\u6709\u6548\uff0c\u5f53\u4e24\u4e2a\u4fe1\u53f7\u90fd\u4e3a\u4f4e\u7535\u5e73\u4e14G
\u4e3a\u9ad8\u7535\u5e73\u65f6\uff0c3-8 \u8bd1\u7801\u5668\u80fd\u6b63\u5e38\u5de5\u4f5c\uff1b\u5f53G2A
\u4e0eG2B
\u4e2d\u6709\u4e00\u4e2a\u4e3a\u9ad8\u7535\u5e73\u65f6\uff0c\u8f93\u51fa\u5747\u5904\u4e8e\u65e0\u6548\u7535\u5e73\u3002\u8fd9\u4e24\u4e2a\u201c\u5197\u4f59\u201d\u7684\u4f7f\u80fd\u4fe1\u53f7\u53ef\u4ee5\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u53d1\u6325\u4f5c\u7528\uff0c\u6bd4\u5982\u5c06 74LS138 \u7528\u4f5c\u6570\u636e\u5206\u914d\u5668\uff08\u6216\u79f0\u591a\u8def\u5206\u914d\u5668\uff09\u65f6\uff0c\u53ef\u4ee5\u5c06
G2B
\u7f6e\u4e8e\u4f4e\u7535\u5e73\uff0c\u8fd9\u65f6\u5730\u5740\u4fe1\u53f7\u5bf9\u5e94\u7684\u90a3\u4e2a\u8f93\u51fa\u7aef\u53e3\u8f93\u51fa\u7684\u7535\u5e73\u5c06\u4e0eG2A
\u7684\u7535\u5e73\u76f8\u540c\u3002\u540c\u6837\u7684\uff0c\u5f53\u6211\u4eec\u5e0c\u671b\u4f7f\u7528\u4e24\u4e2a 74LS138 \u82af\u7247\u7ec4\u6210\u4e00\u4e2a 4-16 \u8bd1\u7801\u5668\u65f6\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e24\u4e2a\u4fe1\u53f7\u4e2d\u7684\u4e00\u4e2a\u7528\u4e8e\u5206\u914d\u9ad8\u4e00\u534a\u5730\u5740\u4e0e\u7b2c\u4e00\u534a\u5730\u5740\uff0c\u800c\u4fdd\u7559
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#_2","title":"\u5730\u5740\u4fe1\u53f7","text":"G
\u4e3b\u4f7f\u80fd\u4fe1\u53f7\u7684\u4f5c\u7528\uff08\u5982\u679c\u4ec5\u6709\u4e00\u4e2aG
\u4f7f\u80fd\u4fe1\u53f7\uff0c\u5b83\u5c06\u88ab\u7528\u4e8e\u533a\u5206\u9ad8\u4f4e\u5730\u5740\uff0c\u800c\u4f7f\u5f97\u5230\u7684\u7535\u8def\u9700\u8981\u6dfb\u52a0\u989d\u5916\u7684\u903b\u8f91\u6765\u5b9e\u73b0\u4e3b\u4f7f\u80fd\u4fe1\u53f7\u7684\u4f5c\u7528\uff09\u3002\u6211\u4eec\u7ea6\u5b9a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#lab-06","title":"Lab 06 \u4e03\u6bb5\u6570\u7801\u7ba1","text":"A
\u4fe1\u53f7\u4e3a\u6700\u4f4e\u4f4d\u7684\u5730\u5740\u4fe1\u53f7\uff0cC
\u4e3a\u6700\u9ad8\u4f4d\u7684\u5730\u5740\u4fe1\u53f7\uff0c\u6bd4\u5982A, B, C
\u4fe1\u53f7\u503c\u5206\u522b\u4e3a0, 1, 1
\u65f6\uff0c\u6211\u4eec\u8868\u8fbe\u7684\u5730\u5740\u4e3ab110
\uff0c\u5373\u5bf9\u5e94\u9009\u62e9Y6
\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u4e9b LED \u5171\u9633\u6781\uff0c\u6211\u4eec\u7ed9\u51fa
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#mc14495","title":"MC14495","text":"0
\u624d\u80fd\u70b9\u4eae\uff08\u4f4e\u7535\u5e73\u6709\u6548\uff09\u3002\u6bd4\u5982\uff0c\u6211\u4eec\u5e0c\u671b\u4e03\u6bb5\u6570\u7801\u7ba1\u663e\u793a\u4e3a\u4e0a\u56fe\u4e2d\u201c0\u201d\u7684\u6837\u5b50\uff0c\u9700\u8981\u5c06g
\u4ee5\u5916\u7684\u4fe1\u53f7\u8bbe\u7f6e\u4e3a0
\u8868\u793a\u70b9\u4eae\u5e76\u5c06g
\u8bbe\u7f6e\u4e3a1
\u3002\u6211\u4eec\u8981\u5b9e\u73b0\u7684\u7ec4\u5408\u90e8\u4ef6
MyMC14495
\u7aef\u53e3\u5982\u4e0b\uff1a
D3~D0
\uff1a\u8f93\u5165\u7684 4 \u4f4d\u4e8c\u8fdb\u5236\u6570\u5b57LE
\uff1a\u4f7f\u80fd\u4fe1\u53f7\uff0c\u4f4e\u7535\u5e73\u6709\u6548point
\uff1a\u7528\u6765\u8868\u793a\u5c0f\u6570\u70b9\u662f\u5426\u70b9\u4eae\uff0c\u9ad8\u7535\u5e73\u6709\u6548- \u8f93\u51fa\u4fe1\u53f7
a~g, p
\uff1a\u5747\u4e3a\u4f4e\u7535\u5e73\u6709\u6548\u5728\u8fdb\u884c\u5b9e\u73b0\u65f6\uff0c\u8bf7\u6ce8\u610f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#lab-07-multiplexer","title":"Lab 07 Multiplexer","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#_3","title":"\u8ba1\u6570\u5668\u548c\u8ba1\u65f6\u5668","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#74ls161","title":"74LS161","text":"LE
\u4e3a\u4f4e\u7535\u5e73\u6709\u6548\uff0c\u5373\u503c\u4e3a1
\u65f6\u6240\u6709\u7684\u8f93\u51fa\u5747\u4e3a\u65e0\u6548\u76841
\uff1bpoint
\u4e3a\u9ad8\u7535\u5e73\u6709\u6548\uff0c\u5373\u503c\u4e3a1
\u65f6\u70b9\u4eae\u5c0f\u6570\u70b9p
\u8f93\u51fa\u4e3a0
\u300274LS161 \u82af\u7247\u5177\u6709\u540c\u6b65\u56db\u4f4d\u4e8c\u8fdb\u5236\u8ba1\u6570\u5668\u529f\u80fd\uff0c\u5176\u5f15\u811a\u5982\u4e0b\uff1a
CP
\uff1a\u63a5\u5165\u65f6\u949f\u4fe1\u53f7\uff0c\u4e0a\u5347\u6cbf\u89e6\u53d1CRn
\uff1a\u6e05\u96f6\u7aef\uff0c\u4f4e\u7535\u5e73\u6709\u6548\uff0c\u4e14\u4e3a\u5f02\u6b65\u6e05\u96f6LDn
\uff1a\u7f6e\u6570\u63a7\u5236\u7aef\uff0c\u4f4e\u7535\u5e73\u6709\u6548D3~D0
\uff1a\u7f6e\u6570\u6570\u636e\u7aef\uff0c\u5f53LDn
\u6709\u6548\u65f6\u5c06\u6570\u636e\u5199\u5165CTT, CTP
\uff1a\u4f7f\u80fd\u7aef\uff0c\u4e24\u811a\u5747\u4e3a\u9ad8\u7535\u5e73\u65f6\u542f\u7528\u8ba1\u6570\u529f\u80fd\uff0c\u4efb\u610f\u4e00\u811a\u4e3a\u4f4e\u7535\u5e73\u65f6\u8ba1\u6570\u5668\u4fdd\u6301\u539f\u72b6\u6001Q3~Q0
\uff1a\u6570\u636e\u8f93\u51fa\u7aefCO
\uff1a\u8fdb\u4f4d\u8f93\u51fa\u7aef\uff0c\u5f53\u8f93\u51fa\u4f4d\u5747\u4e3a 1 \u65f6\u7f6e 1\u8bf7\u7279\u522b\u5173\u6ce8\u8f93\u51fa\u6539\u53d8\u65f6\u673a\uff1a\u5f02\u6b65\u6e05\u96f6\u610f\u5473\u7740\u4e0d\u8bba\u65f6\u949f\u4fe1\u53f7\u4e3a\u4f55\u5f53\u6e05\u96f6\u7aef\u6709\u6548\u65f6\u7acb\u5373\u6539\u53d8\u8f93\u51fa\u4e3a 0\uff1b\u6e05\u96f6\u5916\u7684\u6240\u6709\u8f93\u51fa\u6539\u53d8\u90fd\u53d1\u751f\u5728\u65f6\u949f\u4e0a\u5347\u6cbf\uff08\u5305\u62ec\u7f6e\u6570\u4e0e\u8ba1\u6570\uff09\u3002\u5176\u529f\u80fd\u8868\u5982\u4e0b\uff1a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/","title":"P1","text":"\u7ea6 175 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#_2","title":"\u4fe1\u606f\u8868\u8fbe","text":"
For digital systems, the variables take on discrete values.
\u7535\u4f4d\u8868\u793a
\u6a21\u62df\u4fe1\u53f7\u3001\u6570\u5b57\u4fe1\u53f7
\u533a\u5206\u7f16\u7801\u548c\u6570\u5236\u8f6c\u6362
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#_3","title":"\u6570\u5236\u8f6c\u6362","text":"10 - 2
\u5206\u5f00\u8ba1\u7b97\u6574\u6570\u90e8\u5206\u548c\u5c0f\u6570\u90e8\u5206
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#encoding","title":"\u7f16\u7801 | Encoding","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#numeric","title":"Numeric","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#_4","title":"\u72ec\u70ed\u7801/\u72ec\u51b7\u7801","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#bcd","title":"BCD \u7801","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#excess-3","title":"\u4f59\u4e09\u7801\uff08Excess 3\uff09","text":"\u5b9e\u8d28\u662f\u4e00\u79cd\u6620\u5c04\u5173\u7cfb\u3002\u628a\u5341\u8fdb\u4f4d\u5236\u7684\u8fdb\u4f4d\u6620\u5c04\u5230 \u5341\u516d\u8fdb\u4f4d\u5236
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#gray-code","title":"\u683c\u96f7\u7801\uff08Gray Code\uff09","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#non-numeric","title":"Non-Numeric","text":"ASCII \u7801 UNICODE
\u5947\u5076\u68c0\u9a8c\uff08parity\uff09
\uff01 \u662f\u4fdd\u8bc1\u6574\u4e2aSequence\u5177\u6709\u5947\u6570\u6216\u8005\u5076\u6570\u4e2a1\uff0c\u800c\u4e0d\u662f\u7528\u6765\u5224\u65ad\u524d\u9762\u6709\u591a\u5c11\u4e2a1
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#number-system","title":"\u6570\u5236\u8f6c\u6362 | Number System","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#_5","title":"\u9898\u76ee","text":"\u4e4b\u524d\u6ca1\u6ce8\u610f\u8fc7\u8fd9\u4e2a\u77e5\u8bc6\u70b9
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/","title":"P2","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#part-1","title":"Part 1","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#logic-gate","title":"Logic Gate | \u903b\u8f91\u95e8","text":"
- \u5c0f\u6570\u7684\u8865\u7801\uff0c\u5bf9\u6574\u6570\u90e8\u5206\u3001\u5c0f\u6570\u90e8\u5206\u5206\u522b\u505a
\u7ea6 612 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
NOT OR EXCLUCIVE OR NOT AND EXCLUCIVE NOR
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#gate-delay","title":"Gate Delay | \u95e8\u5ef6\u8fdf","text":"
- Identity
\u8f83\u8be6\u7ec6 \u4f20\u64ad\u5ef6\u65f6
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#boolean-algebra","title":"Boolean Algebra | \u5e03\u5c14\u4ee3\u6570","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#_1","title":"\u8868\u793a","text":"Truth Table Logic Graph Equation
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#duality","title":"Duality","text":"
- \u4e0d\u6539\u53d8\u4e8b\u4ef6\u672c\u8eab
- self - dual
AB + AC + BC
- \u53cd\u51fd\u6570 | Complementing
\u6539\u53d8\u4e8b\u4ef6 \u5176\u4ed6\u6027\u8d28\u540c dual
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#some-principles","title":"* some principles","text":"
- \u9700\u8981\u66f4\u591a\u6ce8\u610f\u90a3\u4e9b\u4f7f\u7528 OR \u5206\u914d\u5f8b\u6216\u7ed3\u5408\u5f8b\u7684\uff0c\u8fd9\u4e00\u4e8b\u5b9e\u672c\u8eab\u8fdd\u53cd\u4e4b\u524d\u7684\u6570\u5b66\u903b\u8f91
\u601d\u8def\uff1a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#canonical-forms","title":"Canonical Forms | \u89c4\u8303\u578b","text":"
**AND**
**\u64cd\u4f5c\u7b26\u591a\u7684\uff1a\u6c42\u5bf9\u5076 dual **
- \u65b9\u6cd5
- \u8f6c\u6362 dual
- \u5316\u5f52
- Minterm
- \u6bcf\u4e2a\u53d8\u91cf\u90fd\u51fa\u73b0
index
the decimal equivalent of the binary combination corresponding to the Minterm
- Maxterm
- SOM | sum of minterms
- POM | product of maxterms
- \u6240\u6709\u4ee4 f \u503c\u4e3a 0 \u7684\u7ec4\u5408 \u53ea\u8981\u6709\u4efb\u610f\u4e00\u4e2a\u4e0d\u4e3a 0 \u5219\u4e3a 1
:::info Tips:
- \u6700\u5927\u9879\u548c\u6700\u5c0f\u9879\u53ef\u4ee5\u76f8\u4e92\u8f6c\u5316
:::
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#standard-form","title":"Standard Form | \u6807\u51c6\u578b","text":"\u7c7b\u4f3c\u79bb\u6563\u6570\u5b66\u4e2d\u7684 DNF CNF \u4e0e Full DNF \u7684\u533a\u522b \u53ef\u4ee5\u5c11\u9879
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#part-2","title":"Part 2 \u4f18\u5316","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#cost-function","title":"cost function","text":"
- sum of product
- product of sum
\u4e09\u4e2a\u7ef4\u5ea6
literal
Complement \u5305\u62ec\u672c\u8eab\u90fd\u8ba1\u7b97\u5728\u5185\uff0c\u91cd\u590d\u4e5f\u8ba1\u7b97G
GN
- \u6ce8\u610f comlemented single literals \u53ea\u8ba1\u5165\u4e00\u6b21
\u5229\u7528\u56fe\u793a\u6570 \u67e5\u8fde\u7ebf\u6570
\u6570\u7684\u65f6\u5019\u53ef\u4ee5\u4e00\u5c42\u5c42\u62c6\u89e3\u4e0b\u53bb
\u6bd4\u5982\u4e0a\u56fe\u4e2d\u7684 2 \u5b8f\u89c2\u4e0a \u4e3a X + Y \u4e4b\u540e\u518d\u53bb \u5206\u522b\u770b XY \u662f\u5426\u8ba1\u5165\u4e00\u6b21 \u62c6\u89e3 XY \u4e0d\u65ad\u91cd\u590d
**\u4f8b\u5b50**
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#k-map","title":"K-map | \u5361\u8bfa\u56fe","text":"
- \u4ee5\u7b2c\u4e09\u4e2a\u4e3a\u4f8b\u5b50
- literal cost 8
- \u9996\u5148\uff0c + \u4e24\u8fb9\u7684\u4e24\u4e2a\u5927\u9879 2` , \u6bcf\u4e2a\u5927\u9879\u5185\u90e8\uff0cA \uff0cC single\uff1bB + D 1
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#system-simplification","title":"System Simplification","text":"
- \u53ef\u4ee5\u770b\u4f5c\u771f\u503c\u8868\u7684\u53e6\u4e00\u79cd\u8868\u8fbe
- \u6ce8\u610f\u76f8\u9694\u7684 squre \u53ea\u6709\u4e00\u4f4d\u4e0d\u540c\uff0cGray Code
- \u8574\u542b\u9879 | implicant
\u542b\u6709 2n \u4e2a 1 \u7684\u77e9\u5f62
- \u4e3b\u8574\u542b\u9879 | prime implicant
\u6781\u5927\u8574\u542b\u9879
- \u57fa\u672c\u4e3b\u8574\u542b\u9879 | essential prime implicant
\u65e0\u53ef\u66ff\u4ee3 TIP : \u4e3b\u8574\u542b\u9879\u4e00\u5b9a\u5b58\u5728\u4f46\u57fa\u672c\u4e3b\u8574\u542b\u9879\u4e0d\u4e00\u5b9a \u57fa\u672c\u4e3b\u8574\u542b\u9879\u4e00\u5b9a\u5b58\u5728\u5728\u5316\u7b80\u7ed3\u679c\u4e2d
\u548c\u4e4b\u79efSOP\u7684\u4f18\u5316\u65b9\u6cd5\uff1a \u6cd5\u4e00: \u5148\u53d6\u53cd\u518d\u64cd\u4f5c \u6cd5\u4e8c\uff1a\u76f4\u63a5\u5bf9 0 \u64cd\u4f5c
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#dont-cares","title":"Don`t Cares","text":"x
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#part-3","title":"Part 3","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#gate-types","title":"Gate Types","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#primitive-gates","title":"Primitive Gates","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#buffer","title":"Buffer | \u7f13\u51b2\u5668","text":"\u63d0\u9ad8\u7535\u8def\u7535\u538b\u6c34\u5e73\u548c\u589e\u52a0\u7535\u8def\u8fd0\u884c\u901f\u5ea6\u3002
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#three-state-buffer","title":"Three-state Buffer | \u4e09\u6001\u7f13\u51b2\u5668","text":"\u7ed9\u51fa\u4e09\u79cd\u72b6\u6001\uff1a0\uff0c1\uff0cHi-Z
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#complex-gates","title":"Complex Gates","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#_2","title":"P2","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#_3","title":"\u8865\u5145","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#odd-function","title":"Odd Function | \u5947\u51fd\u6570","text":"*IN
\uff1a\u6570\u636e\u7aef**EN**
\uff1a\u63a7\u5236\u7aefHI-Z
:** \u65e2\u4e0d\u662f\u9ad8\u7535\u5e73\u4e5f\u4e0d\u662f\u4f4e\u7535\u5e73\uff0c\u5b83\u7684\u8868\u73b0\u4e0e\u901a\u8def\u7c7b\u4f3c\uff0c\u5982\u679c\u8f93\u5165\u5230\u4e0b\u4e00\u7aef\u53e3\u5c06\u4e0d\u9020\u6210\u5f71\u54cd\u3002\u53e6\u5916\uff0c\u5982\u679c\u7528\u4e07\u7528\u8868\u6d4b\u91cf\u7535\u5e73\uff0c\u5176\u9ad8\u4f4e\u53d6\u51b3\u4e8e\u5b83\u540e\u9762\u7684\u4e1c\u897f\u901a\u8fc7
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/","title":"P3","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#elements-for-design","title":"Elements for Design | \u8bbe\u8ba1\u8981\u7d20","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#fan-in","title":"fan-in","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#fan-out","title":"fan-out","text":"exclusive or
\u642d\u5efafan-out \u4f1a\u5f71\u54cdPropogation Delay
\u53ef\u4ee5\u88ab\u6807\u51c6\u8d1f\u8f7d\uff08stadard load\uff09\u5b9a\u4e49
\u6807\u51c6\u8d1f\u8f7d\uff1a \u5927\u5c0f\u4e0a\u7b49\u540c\u4e8e\u4e00\u4e2a\u53cd\u76f8\u5668\u7684\u8f93\u5165
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#transition-time","title":"Transition Time | \u8f6c\u6362\u65f6\u95f4","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#_1","title":"\u4f20\u64ad\u6a21\u578b","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#gate-transport-delay","title":"Gate Transport Delay | \u4f20\u64ad\u5ef6\u8fdf","text":"
- \u5bf9\u4e8e\u8f93\u51fa\u7684\u53d8\u5316\u800c\u8a00
tHL
VCC \u7684 10% \u5347\u9ad8\u5230 90% \u6240\u9700\u8981\u7684\u65f6\u95f4tLH
VCC \u7684 90% \u964d\u4f4e\u5230 10% \u6240\u9700\u8981\u7684\u65f6\u95f4- \u65e0\u9700\u6bd4\u8f83\u53d8\u5316
- \u6700\u5927\u8d1f\u8f7d\uff1a\u4e0d\u8d85\u8fc7\u89c4\u5b9a\u7684\u6700\u5927\u8f6c\u6362\u65f6\u95f4\u7684\u8d1f\u8f7d
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#inertial-delay","title":"Inertial delay | \u60ef\u6027\u5ef6\u8fdf","text":"
tPHL
High to low\u8ba1\u7b97\u65b9\u6cd5
\u662f\u53d8\u5316\u524d\u540e\u7684\u4e2d\u70b9\u65f6\u95f4\u5dee- td = max( tPHL,tPLH )
\u7c7b\u4f3c\u4e8e\u4f20\u8f93\u5ef6\u8fdf
Difinition
\uff1a \u5982\u679c\u8f93\u5165\u53d8\u5316\u4f7f\u5f97\u8f93\u51fa\u5728\u4e00\u4e2a\u5c0f\u4e8e\u62d2\u7edd\u65f6\u95f4\u7684\u95f4\u9694\u5185\u53d1\u751f\u4e24\u6b21\u53d8\u5316\uff0c\u90a3\u4e48\u7b2c\u4e00\u4e2a\u53d8\u5316\u5c06\u4e0d\u4f1a\u53d1\u751f \u4ee5\u4e0b\u56fe\u4e3a\u4f8b \u84dd\u8272\u7684\u6761\u5e26\u4ee3\u8868\u4f20\u64ad\u5ef6\u8fdf\uff0c\u5176\u4e2d\u7684\u9ed1\u8272\u6761\u4ee3\u8868\u60ef\u6027\u5ef6\u8fdf"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#circuit-delay","title":"Circuit Delay | \u7535\u8def\u5ef6\u8fdf","text":"
- a\u3001b\uff1ab \u53d1\u751f\u5728\u62d2\u7edd\u65f6\u95f4 [rejection time]\uff0c\u6545 a \u6ca1\u6709\u51fa\u73b0\u5728\u60ef\u6027\u5ef6\u8fdf\u4e2d
- c\u3001d\u3001e\uff1ad \u6070\u597d\u5728\u62d2\u7edd\u65f6\u95f4\uff0c\u6545\u800c c \u53d1\u751f\uff0c\u53c8 e \u5728\u62d2\u7edd\u65f6\u95f4\u5185\uff0c\u6545\u800c d \u4e0d\u53d1\u751f
\u7ea6 1043 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#design-procedure","title":"Design Procedure | \u8bbe\u8ba1\u8fc7\u7a0b","text":"
- Specialfication
- Formulation
Optimization
Technology mapping | \u5de5\u827a\u6620\u5c04
\u4e00\u822c\u4f7f\u7528\u4e0e\u975e\u95e8+\u975e\u95e8 \u6216\u8005 \u6216\u975e\u95e8 + \u975e\u95e8
\u5148\u5c06\u5176\u4ed6\u95e8\u66ff\u6362\u4e3a\u6307\u5b9a lib \u4e2d\u7684\u5668\u4ef6\uff0c\u7136\u540e\u6d88\u53bb doubly invertor
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#part-2","title":"Part 2","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#_2","title":"\u7ec4\u5408\u903b\u8f91","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#function-and-function-blocks","title":"Function and function Blocks | \u57fa\u672c\u51fd\u6570","text":"
- Verification | \u9a8c\u8bc1
- Manaul Logic Analysis \u5229\u7528\u771f\u503c\u8868\u3001\u5e03\u5c14\u4ee3\u6570\u7b49\u65b9\u5f0f\u8fdb\u884c\u9a8c\u8bc1
- Simulation \u8fdb\u884c\u4eff\u771f
Single varible
- \u5e38\u503c (fixing - value) | \u8f93\u51fa\u5b9a\u503c
- \u4f20\u8f93\uff08transforming\uff09| \u4fdd\u6301\u4e0d\u53d8
- \u9006\u53d8\uff08inverting\uff09| \u76f8\u53cd
Multiple Rugimentary Functions
Enabling Function
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#docoding","title":"Docoding | \u89e3\u7801","text":"
- \u5141\u8bb8
input
\u662f\u5426\u8f93\u5165- \u5f53\u4e2d\u65ad\u65f6\uff0c\u8f93\u51fa\u503c\u53ef\u80fd\u4e3aHi-Z\uff0c0\uff0c1
- \u6ce8\u610f
AND
\u548cOR
\u4e2d\u5177\u6709\u4e0d\u540c\u7684\u8868\u73b0\u5f62\u5f0f(\u539f\u7406\u4e00\u6837)
Definition
input
n
bits outputn<=m<=2^n
\u4ea7\u751f
minterm
\u4e8e\u662f\u884d\u751f\u53e6\u4e00\u4e2a \u8bdd\u9898Decoder and OR Gates
n-to-m line decoder
A general Rule
\u5982\u679c\u4e00\u76f4\u4f7f\u7528
minterm
\u8fdb\u884c\u89e3\u7801\uff0cCost\u5c06\u5927\u5e45\u5ea6\u4e0a\u5347\uff08\u4f7f\u7528\u66f4\u591a\u8f93\u5165\u7684\u4e0e\u95e8\uff09\u3002\u6211\u4eec\u9700\u8981\u4e00\u79cd\u5229\u7528\u5206\u5c42\u548c\u4e00\u7ec4\u4e0e\u95e8\u5b9e\u73b0\u7f16\u7801
\u5173\u4e8e\u8ba1\u7b97\u4e0e\u95e8\u8f93\u5165\u6210\u672c
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#decoder-with-enable","title":"Decoder with Enable","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#decoder-and-or-gates","title":"Decoder and OR gates","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#adder","title":"ADDer \u7684\u5b9e\u73b0","text":"
- 6/2 = 3\uff0c\u8fde\u63a5 64 \u4e2a\u4e8c\u8f93\u5165\u4e0e\u95e8\u7684\u662f\u4e24\u4e2a
3-8\u8bd1\u7801\u5668
- COST : 6 + 2*\uff084*2\uff09+2*(8*2)+64*2
\u5b9e\u73b0 1 bit \u7684\u52a0\u51cf\uff0c\u9700\u8981\u4e24\u4e2a\u76f8\u52a0\u4f4d\uff0c\u4e0a\u4e00\u4f4d\u7684\u8fdb\u4f4d\uff0c\u5b58\u50a8\u672c\u4f4d\u7ed3\u679c\u548c\u4e0b\u4e00\u4f4d\u8fdb\u4f4d\u3002\u5373 X+Y+Z=(CS)2
\u5bf9\u4e8e\u662f\u5426\u5229\u7528minterm\u8868\u793a\uff0c\u6211\u4eec\u9700\u8981\u81ea\u5df1\u505a\u51fa\u6743\u8861\uff1b
It`s a business of budgt.
EXAMPLE
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#encoding","title":"Encoding | \u7f16\u7801","text":"
one-hot
\u7684\u5f62\u5f0f\uff0c\u4e00\u822c\u800c\u8a00\u53ea\u6709\u4e00\u4f4d\u4e3a1Encoder
\u5b9e\u73b0\u7535\u8def\u793a\u4f8b\uff1aDecimal-to-BCD
input : 0-9 \u517110\u4e2a\u6570\u5b57
output : 4-bits BCD\u7801
function : if Di == 1, then the output (A1-A4) is just the BCD code for i
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u6837\u4e00\u79cd\u65b9\u5f0f\u7684\u5c40\u9650\u6027\u5f88\u5927\uff0c\u4e3b\u8981\u5728\u4e8e\u6211\u4eec\u5f88\u96be\u786e\u4fdd
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#priority-encoder","title":"Priority Encoder | \u4f18\u5148\u9009\u62e9","text":"one-hot
\u7684\u5f62\u5f0f\uff0c\u4e8e\u662f\u6211\u4eec\u9700\u8981\u4e00\u79cd\u80fd\u591f\u4fdd\u8bc1\u63a5\u53d7\u6240\u6709\u8f93\u5165\u7684\u65b9\u6cd5\u3002
- \u4f18\u5148\u7f16\u7801\u5668\u80fd\u591f\u5b9e\u73b0\u4f18\u5148\u7ea7\u51fd\u6570\uff0c\u5b83\u4e0d\u8981\u6c42\u8f93\u5165\u662f one-hot \u7684\uff0c\u800c\u662f\u603b\u662f\u5173\u6ce8\u6709\u6548\u8f93\u5165\u4e2d\u4f18\u5148\u7ea7\u6700\u9ad8\u7684\u90a3\u4e00\u4e2a\u3002\u5373\u6bd4\u5982\u5f53\u4f18\u5148\u7ea7\u6700\u9ad8\u7684\u90a3\u4e00\u4f4d\u662f
1
\u65f6\uff0c\u5176\u5b83\u6240\u6709\u4f18\u5148\u7ea7\u4e0d\u5982\u5b83\u7684\u4f4d\u7f6e\u7684\u503c\u90fd\u662f\u6211\u4eec\u4e0d\u5173\u5fc3\u7684\u5185\u5bb9\u4e86\u3002\u793a\u4f8b\uff1a
\u200b \u8fd9\u91cc\u7684A2A1A0\u8868\u793a\u4e0b\u6807
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#selecting","title":"Selecting | \u9009\u62e9\u5668","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#multiplexer","title":"Multiplexer | \u591a\u8def\u590d\u7528\u5668","text":"
- \u7b80\u5199\u4e3a
MUX
\uff0c\u53c8\u88ab\u79f0\u4e3adata selecter
- \u57fa\u672c\u6784\u6210 2n-to-1-Line Multiplexer`
- n-to-2n-line decoder
- 2n\u00d7 2 AND-OR
- \u5f62\u6210\u4e00\u79cd\u89c2\u5ff5\u2014\u2014\u9009\u62e9\u662f\u76f8\u4e92\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0cINPUT\u548cEnable\u4e0d\u662f\u7edd\u5bf9\u7684\u6982\u5ff5\uff08\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u662f\u524d\u6587\u5e26\u4f7f\u80fd\u76841-2Decoder\uff0c\u4f46\u662f\u4e66\u4e0a\u79f0\u4ed6\u4e3a\u591a\u8def\u5206\u914d\u5668|demultiplexer\uff0c\u4e2a\u4eba\u611f\u89c9\u6ca1\u6709\u533a\u522b\uff09
- Example
2-to-1-Line Multiplexer
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#_3","title":"\u4f7f\u7528\u4e09\u6001\u95e8","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#implementation","title":"Implementation","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#approach-1","title":"Approach 1","text":"\u5229\u7528\u591a\u91cd\u7684\u591a\u8def\u590d\u7528\u5668\u8fdb\u884c\u64cd\u4f5c\uff0c\u8ba1\u7b97SOM\uff1b
Y = minOR
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#approach-2","title":"Approach 2","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#part-3-arithmetic-function","title":"Part 3 Arithmetic Function","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#adder_1","title":"Adder | \u52a0\u6cd5\u5668","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#half-adder","title":"Half Adder","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#full-adder","title":"Full Adder","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#ripple-curry-adder","title":"Ripple Curry Adder | \u884c\u6ce2\u52a0\u6cd5\u5668","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#curry-look-ahead","title":"Curry Look Ahead | \u8d85\u524d\u8fdb\u4f4d\u52a0\u6cd5\u5668","text":"
- \u91cd\u70b9\u5728\u4e8e\u627e\u5230\u5bf9\u5e94\u7684Function\u8fdb\u884c\u5316\u7b80
\u8ba1\u7b97Delay
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#_4","title":"\u4e8c\u8fdb\u5236\u52a0\u6cd5","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#unsigned-integer","title":"Unsigned Integer","text":"
- 1`s Complement \u53cd\u7801
- 2`s Complement \u8865\u7801
- \u51cf\u6cd5Substraction\u53ef\u4ee5 \u7531 A + B\u7684\u8865\u7801 \u5b9e\u73b0
- \u8fdb\u4f4d\u4e3a0\uff0c\u5bf9\u7ed3\u679c\u4fee\u6b63
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#signed-integer","title":"Signed Integer","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#overflow","title":"OverFlow","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#other-arithmetic-function","title":"Other Arithmetic Function","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#incrementing-decrementing","title":"Incrementing & Decrementing","text":"
- \u8fdb\u4f4d\u4e3a1\uff0c\u4e0d\u9700\u8981\u4fee\u6b63
+1
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/","title":"P4","text":"\u200b This chapter begins with an introduction to sequential circuits, describing the difference between synchronous sequential circuits(\u540c\u6b65\u53d8\u5316), which have a clock signal to synchronize changes in the state of the circuit at discrete points in time, and asynchronous sequential circuits\uff08\u5f02\u6b65\uff09, which can change state at any time in response to changes in inputs.
\u8981\u5b9e\u73b0\u4fe1\u606f\u7684\u5b58\u50a8\uff0c\u6211\u4eec\u5c31\u9700\u8981\u4e00\u79cd\u65b0\u7684\u7535\u8def\uff1a\u65f6\u5e8f\u7535\u8def
Combinational Logic
Inputs -
Output function (Mealy) Outputs = g(Inputs, State)
Output function (Moore) Outputs = h(State)
Next state function Next State = f(Inputs, State)
Storage Elements
\u4e0b\u9762\u662f\u4e00\u79cd\u6700\u57fa\u672c\u7684
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#part-1-storage-elements-and-analysis","title":"Part 1 Storage Elements and Analysis","text":"Buffer
\uff08\u7f13\u51b2\u5668\uff09\uff0c\u53ef\u4ee5\u4fdd\u6301\u4e00\u4e2a\u503c\u5728\u4e00\u5b9a\u65f6\u95f4\u5185\u4e0d\u53d8 \u5c06\u53cd\u76f8\u5668\u6539\u4e3a\u5176\u4ed6\u539f\u4ef6\uff0c\u5373\u5f97\u5230\u6700\u57fa\u672c\u7684\u9501\u5b58\u5668\u7ea6 1070 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#type","title":"Type","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#synchronous","title":"Synchronous | \u540c\u6b65\u53d8\u5316","text":"\u5728\u6700\u7b80\u5355\u7684\u949f\u63a7\u65f6\u5e8f\u7535\u8def\u4e2d\u4f7f\u7528\u7684\u5b58\u50a8\u5355\u5143\u79f0\u4e4b\u4e3a\u89e6\u53d1\u5668\u3002
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u89e6\u53d1\u5668\u662f\u7531\u9501\u5b58\u5668\u6784\u6210\u7684\u3002
\u949f\u63a7\u65f6\u5e8f\u7535\u8def
Clocked sequential circuit
\u901a\u8fc7\u65f6\u949f\u4ea7\u751f\u5668
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#asynchronous","title":"Asynchronous | \u5f02\u6b65\u53d8\u5316","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#latch","title":"\u9501\u5b58\u5668 | Latch","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#basic-nand-bars-barr-latch","title":"Basic (NAND) \\(\\bar{S}-\\bar{R}\\) Latch","text":"Clock Generator
\u4ea7\u751f\u5468\u671f\u6027\u7684\u65f6\u949f\u8109\u51b2clock pulse
\u6765\u5b9e\u73b0\u3002\u8109\u51b2\u7cfb\u7edf\u5206\u5e03\u4e8e\u6574\u4e2a\u7cfb\u7edf\uff0c\u540c\u6b65\u5b58\u50a8\u5143\u4ef6\u4e4b\u5728\u6bcf\u4e00\u4e2a\u8109\u51b2\u7279\u5b9a\u7684\u65f6\u523b\u53d7\u5230\u5f71\u54cd\u4e00\u822c\u6765\u8bf4\uff0cset\u4e3a\u7f6e1\u7aef\u53e3\uff0creset\u4e3a\u7f6e0\u7aef\u53e3 \u4f46\u662f\uff0c\u8fd9\u91cc\u7684\\(\\bar{R}-\\bar{S}\\)\u4f7f\u7528\u7684\u662f \\(\\bar{S\\R}\\) \u6765\u8868\u793a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#basic-nor-s-r-latch","title":"Basic (NOR) S \u2013 R Latch","text":"S \u7f6e 1 \u7aef\u53e3 R \u7f6e 0 \u7aef\u53e3
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#clocked-s-r-latch","title":"Clocked S - R Latch","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#d-latch","title":"D- Latch","text":"
- \u5b9e\u9645\u4e0a\uff0c\u5b83\u5c06NAND\u7684\u884c\u4e3a\u8f6c\u4e3a\u4e86\u4e0eNOR\u76f8\u540c\u7684\u5bc4\u5b58\u5668
- \u6ca1\u6709\u6a21\u7cca\u503c (
indeterminate value
)\u4f46\u662f\uff0c\u5728\u4e00\u4e2a\u65f6\u949f\u5468\u671f\u5185\uff0c\u53ea\u8981C = 1\u4e0d\u53d8\uff0c\u8f93\u51fa\u53ef\u4ee5\u53d1\u751f\u591a\u6b21\u53d8\u5316\uff1b\u7b2c\u4e00\u6b21\u53d8\u5316\u662f\u6211\u4eec\u9884\u671f\u4e2d\u7684\uff0c\u4e4b\u540e\u7684\u88ab\u79f0\u4e4b\u4e3a\u201d\u7a7a\u7ffb\u201c
\u4e5f\u5c31\u662f\u8bf4\uff0c it is transparent.
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#flip-flops","title":"\u89e6\u53d1\u5668 | Flip-Flops","text":"\u8fb9\u6cbf\u89e6\u53d1\u5f0f D \u89e6\u53d1\u5668\u662f\u76ee\u524d\u4f7f\u7528\u6700\u5e7f\u6cdb\u7684\u89e6\u53d1\u5668\u3002
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#s-r-master-slave-flip-flop","title":"\u4e3b\u4ece\u89e6\u53d1|S-R master-slave flip-flop","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#edge-triggered-flip-flop","title":"\u8fb9\u7f18\u68c0\u6d4b|edge-triggered flip-flop","text":"
- \u5b83\u5b58\u5728\u7684\u95ee\u9898\u4e0eR-S Latch\u7c7b\u4f3c\uff0c\u90fd\u5b58\u5728\u4e0d\u786e\u5b9a\u7684\u72b6\u6001\uff0c\u5bfc\u81f4\u53ef\u80fd\u53d1\u751f\u9519\u8bef
- 1`s catching Problem
- \u4e0a\u56fe\u8d1f\u8fb9\u7f18\u53d8\u5316
\u6b63\u8fb9\u7f18\u53d8\u5316
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#standard-symbols","title":"\u6807\u51c6\u56fe\u5f62\u7b26\u53f7 | Standard Symbols","text":"
- \u76f4\u89d2 \u7b26\u53f7\u8868\u793a \u5ef6\u65f6\u8f93\u51fa\u6307\u793a\u5668 \u8868\u793a\u8f93\u51fa\u4fe1\u53f7\u5728\u8109\u51b2\u7684\u7ed3\u5c3e\u53d1\u751f\u6539\u53d8
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_1","title":"\u65f6\u5e8f\u7535\u8def\u5206\u6790","text":"
- C\u524d\u9762\u7684\u7bad\u5934\u8868\u793a\u52a8\u6001\u8f93\u5165\uff0c\u8868\u793a\u89e6\u53d1\u5668\u76f8\u5e94\u8f93\u5165\u65f6\u949f\u8109\u51b2\u7684\u8fb9\u6cbf\u8df3\u53d8
Example
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#state-graph","title":"State Graph","text":"
- \u5f53\u524d\u72b6\u6001 \u4e0b\u4e00\u72b6\u6001 \u8f93\u5165 \u8f93\u51fa
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#state-diagram","title":"State Diagram","text":"
- Mealy\u548cMoore\u7684\u72b6\u6001\u8868\u4e0d\u540c
- \u5982\u679c\u8f93\u51fa\u65e2\u4f9d\u8d56\u4e8e\u5f53\u524d\u72b6\u6001\uff0c\u4e5f\u4f9d\u8d56\u4e8e\u8f93\u5165\u7684\u65f6\u5e8f\u7535\u8def\uff0c\u5219\u79f0\u4e3a \u7c73\u52d2\u578b\u7535\u8def(Mealy model circuit)\uff1b\u800c\u5982\u679c\u8f93\u51fa\u53ea\u4f9d\u8d56\u4e8e\u5f53\u524d\u72b6\u6001\uff0c\u5219\u79f0\u4e3a \u6469\u5c14\u578b\u7535\u8def(Moore model circuit)\u3002
Mealy\u6a21\u578b
- Node \u6307\u793a\u72b6\u6001\uff1b\u7bad\u5934\u8868\u793a\u8f93\u5165\u8f93\u51fa
Moore\u6a21\u578b \uff08\u53ea\u4f9d\u8d56\u4e8eState\uff09
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_2","title":"\u7b49\u4ef7","text":"
- Def: \u5982\u679c\u4e24\u4e2a\u72b6\u6001\u5bf9\u6bcf\u4e00\u4e2a\u8f93\u5165\u7b26\u53f7\u4ea7\u751f\u7684\u8f93\u51fa\u76f8\u540c\uff0c\u800c\u4e14\u4e0b\u4e00\u4e2a\u72b6\u6001\u76f8\u540c\u6216\u8005\u7b49\u4ef7\uff0c\u90a3\u4e48\u6211\u4eec\u79f0\u4ed6\u4eec\u7b49\u4ef7
Example
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#timing-parameter","title":"Timing Parameter","text":"
- Setup Time \\(t_s\\)\uff1a\u91c7\u6837\u8fb9\u7f18\u524d\u8f93\u5165\u4fe1\u53f7\u9700\u8981\u4fdd\u6301\u7a33\u5b9a\u7684\u65f6\u95f4\uff0c\u5426\u5219\u4f1a\u53d1\u751f
- Hold Time \\(t_h\\)\uff1a\u91c7\u6837\u8fb9\u7f18\u540e\u8f93\u5165\u4fe1\u53f7\u9700\u8981\u4fdd\u6301\u7a33\u5b9a\u7684\u65f6\u95f4\uff1b
- Propagation Time \\(t_p\\)\uff1a\u89e6\u53d1\u5668\u7684\u91c7\u6837\u8fb9\u7f18\u5230\u8f93\u51fa\u7a33\u5b9a\u7684\u65f6\u95f4\uff08\u4f20\u64ad\u65f6\u95f4\uff09\uff1b
- Slack Time\uff1a\u677e\u5f1b\u65f6\u95f4 \\(t_{slack}>=0\uff0c\u4e00\u822c\u63a5\u8fd10\\)
\u200b \u5bf9\u4e8e \\(t_h<t_{pd}\\)
\\(t_p=t_{pd}+t_{slack}+t_s = t_{pd,FF}+t_{pd,Com}+t_s+t_{slack}\\)
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#part-2-design-procedure","title":"Part 2 Design Procedure","text":"Specification
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#preparation","title":"Preparation","text":"
\u786e\u8ba4\u7cfb\u7edf\u7684\u884c\u4e3a\uff1a\u9700\u8981\u8bf4\u660e\u89c4\u683c\uff0c\u4ee5\u786e\u5b9a\u6570\u76ee\uff1b\u786e\u8ba4\u521d\u59cb\u72b6\u6001 | Spcification
Formulation - Obtain a state diagram or state table
State Assignment - Assign binary codes to the states
Flip-Flop Input Equation Determination - Select flip-flop types and derive flip-flop equations from next state entries in the table
- Output Equation Determination - Derive output equations from output entries in the table
- Optimization - Optimize the equations
- Technology Mapping - Find circuit from equations and map to flip-flops and gate technology
- Verification - Verify correctness of final design
Reset\u8bbe\u7f6e
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#formulation","title":"Formulation","text":"Example 1 : Sequence Check
\u76ee\u7684\uff1a\u5728\u4e00\u6bb5\u8fde\u7eed\u7684\u5e8f\u5217\u4e2d\u68c0\u6d4b\u8981\u6c42\u7684\u5e8f\u5217\uff0c\u5047\u8bbe\u4e3a\u201c1101\u201d \u72b6\u6001\u56fe\uff1a
- A\u4e3a\u521d\u59cb\u72b6\u6001\uff0c\"Reset\"\u4f4d
\u5173\u4e8ereset
\u540c\u6b65
\u5f02\u6b65
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_3","title":"\u72b6\u6001\u56fe\u7684\u4f18\u5316\u4e0e\u786e\u5b9a\u7b56\u7565","text":"A state is an abstraction of the history of the past applied inputs to the circuit (including power-up reset or system reset).
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_4","title":"\u4f18\u5316","text":"\u5bf9\u7b49\u6548\u72b6\u6001\u7684\u7406\u89e3
\u9690\u542b\u8868\u5316\u7b80
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_5","title":"\u72b6\u6001\u5206\u914d","text":"\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7b2c\u4e00\u6761\u539f\u5219\u8f83\u4e3a\u91cd\u8981\uff0c\u9700\u4f18\u5148\u8003\u8651\uff0c\u5176\u6b21\u8981\u8003\u8651\u7531\u524d\u4e09\u6761\u539f\u5219\u5f97\u5230\u7684\u5e94\u5206\u914d\u76f8\u90bb\u4ee3\u7801\u7684\u72b6\u6001\u5bf9\u51fa\u73b0\u7684\u6b21\u6570\uff0c\u6b21\u6570\u591a\u7684\u72b6\u6001\u5bf9\u5e94\u4f18\u5148\u5206\u914d\u76f8\u90bb\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_6","title":"\u4f8b\u9898","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_7","title":"\u65f6\u5e8f\u8ba1\u7b97","text":"\u6ce8\u610f\u7ed3\u5408\u65f6\u5e8f\u56fe\u8fdb\u884c\u5206\u6790
- \u8fb9\u6cbf\u89e6\u53d1\u7684\uff0c\\(t_s\\)\u5728\u8fb9\u6cbf\u89e6\u53d1\u4e4b\u524d\u8fdb\u884c
- \u6545\u800c\u5e38\u8bf4\u7684\uff0c\"to the positive clock edge\"\u9700\u8981\u8ba1\u7b97 \\(t_s\\)
- \u4e00\u822c\u5728\u8fd9\u79cdclock stew\u95ee\u9898\u4e2d\u624d\u8003\u8651\\(t_h\\),\u5728\u89e6\u53d1\u540e
- \u8ba1\u7b97\u65f6\u95f4\u5ef6\u65f6Max\u7684\u65f6\u5019\uff0c\u4ece\u4e00\u4e2aFF\u7684\u8f93\u51fa\u5230\u53e6\u5916\u4e00\u4e2a\u7684\u8f93\u5165
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/","title":"P5","text":"
- X -> S \u5ba1\u9898\uff0c\u662f\u4eceexternal input
- \u8fb9\u6cbf\u89e6\u53d1
\u7ea6 42 \u4e2a\u5b57
Technology
\u7279\u6027
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/#rom","title":"ROM","text":"Read-only
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/#pal","title":"PAL","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/#pla","title":"PLA","text":"\u5229\u7528K-map\u5bfb\u627e\u76f8\u540c\u9879 XOR\u95e8\u53ef\u4ee5\u589e\u52a0\u4e00\u7ec4\u503c\uff0c\u6709\u5229\u4e8e\u4f18\u5316\uff08\u4f7f\u5f97\u4e00\u79cd\u8f93\u51fa\u6210\u4e3a\u53ef\u80fd\uff09 NOT
Example\uff1a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/#fpga","title":"FPGA","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/","title":"P6","text":"In a digital system, a datapath and a control unit are frequently present at the upper levels of the design hierarchy.
A datapath consists of processing logic and a collection of registers that performs data processing. A control unit is made up of logic that determines the sequence of data-processing operations performed by the datapath. Register transfer notation describes elementary data-processing actions referred to as microoperations.
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#register","title":"Register | \u5bc4\u5b58\u5668","text":"Register transfers
move information between registers, between registers and memory, and through processing logic. Dedicated transfer hardware using multiplexers and shared transfer hardware called buses implement these movements of data. The design of the control unit for controlling register transfers is also covered in this chapter.
- \u5bc4\u5b58\u5668\u5176\u5b9e\u5c31\u662f\u5b58\u50a8\u6570\u636e\u7528\u7684\u89e6\u53d1\u5668\u90e8\u5206\u548c\u63a7\u5236\u4e0d\u540c\u72b6\u6001\u8f6c\u6362\u7684\u7ec4\u5408\u7535\u8def\u90e8\u5206\u7ec4\u6210
Notation
K1 : R1 <- R2 \u76f8\u5f53\u4e8e\u6761\u4ef6\u7ea6\u675f
\u5982\u679c\u5728\u5de6\u8fb9\u6761\u4ef6\u4e2d\u51fa\u73b0
A + B
\u8868\u793a\u903b\u8f91\u8fd0\u7b97\uff0c\u53f3\u8fb9\u8868\u793a\u7b97\u672f\u8fd0\u7b97 \u5982\uff1aA + B : R1 + R2
Example
\u4e00\u4e2a\u7b80\u5355\u7684\u52a0\u51cf\u6cd5\u5b9e\u73b0
\u4e00\u4e9b\u53ef\u80fd\u7528\u4e0d\u5230\u7684\u7ec6\u8282\uff1a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#load-enable","title":"Load Enable","text":"
- \u5927\u5199\u5b57\u6bcd\u8868\u793a\u529f\u80fd\uff0c
AR
\u5730\u5740\u5bc4\u5b58\u5668\uff1a\u4fdd\u7559\u5b58\u50a8\u5355\u5143\u5730\u5740\uff1bPC
\u7a0b\u5e8f\u8ba1\u6570\u5668\uff1bIR
\u6307\u4ee4\u5bc4\u5b58\u5668\uff1bR2
\u5bc4\u5b58\u56682\uff1b- \u6700\u4f4e\u4f4d 0 \u4f4d\u53f3\u7aef \u5c0f\u7aef\u683c\u5f0f\uff1b\u5de6\u7aef \u5927\u7aef\u683c\u5f0f
\u6211\u4eec\u671f\u671b\u4e2d\u7684\u5bc4\u5b58\u5668\u9700\u8981\u6709\u4e00\u4e2a\u4fe1\u53f7\u6765\u63a7\u5236\u4ed6\u7684\u201cLoad\u201d\u6216\u8005\u201cStore\u201d\uff0c\u800c\u5355\u7eaf\u7684\u89e6\u53d1\u5668\u5728\u6bcf\u4e2a\u65f6\u949f\u5468\u671f\u90fd\u4f1a\u91cd\u65b0\u8bfb\u5165
\u4e24\u79cd\u601d\u8def\uff08\u8fd8\u6709\u4e00\u79cd\u662f\u4f7f\u7528JK\u89e6\u53d1\u5668\uff0c\u572800\u72b6\u6001\u8fdb\u884c\u9501\u5b58\uff09
- Clock Gating | \u95e8\u63a7\u65f6\u949f :
Clock
\u8fdb\u884c\u7ea6\u675f\uff0c\u7c7b\u4f3c\u4e8e\u4e4b\u524d\u7684Reset
\u64cd\u4f5c\u4e00\u79cd\u95e8\u63a7\u7684\u601d\u8def\uff0c\u4f46\u662f\u8981\u6ce8\u610f\u8fd9\u4e4b\u4e2d\u5b58\u5728\u7740
\u65f6\u949f\u504f\u79fb\u3010clock skew\u3011
,\u5c06\u5bfc\u81f4\u5230\u8fbe\u89e6\u53d1\u5668\u7684\u65f6\u949f\u4fe1\u53f7\u5e76\u4e0d\u540c\u6b65"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#transfer","title":"Transfer | \u4f20\u8f93","text":"
\u5bf9
Input
\u8fdb\u884c\u7ea6\u675f\u601d\u8def\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u5229\u7528\u4e00\u4e2a\u4e8c\u9009\u4e00\u7684\u591a\u8def\u590d\u7528\u5668\u5bf9input\u5904\u7406\uff0c\u4e8e\u662f\u4fbf\u5f62\u6210\u4e86 b \u4e2d\u7684\u5e26\u6709EN\u7aef\u7684D\u89e6\u53d1\u5668
\u7ea6 984 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#multiplexer","title":"\u57fa\u4e8e Multiplexer","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#_1","title":"\u57fa\u4e8e\u591a\u8def\u590d\u7528\u548c\u603b\u7ebf","text":"Dedicated
- \u4e3a\u6bcf\u4e00\u4e2a\u5bc4\u5b58\u5668\u90fd\u63d0\u4f9b\u4e00\u4e2a\u4e13\u5c5e\u7684\u9009\u62e9\u5668
- \u597d\u5904\u4e0e\u7f3a\u70b9\u540c\u6837\u660e\u663e\uff1a\u80fd\u591f\u540c\u65f6\u63d0\u4f9b\u4e0d\u540c\u7684\u4f20\u8f93\u503c\uff08R0<-R1,R1<-R2\uff09\uff0c\u4f46\u8017\u8d39\u66f4\u591a\u7684cost
Shared
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#microoperations","title":"Microoperations","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#shift-register","title":"Shift Register | \u79fb\u4f4d\u5bc4\u5b58\u5668","text":"
- \u4e09\u6001\u95e8\u5b9e\u73b0
- ' 0 Filled'
\u4e32\u884c | Serial
- \u5e38\u5e38\u7528\u4e8e\u4e32\u884c\u3001\u5e76\u884c\u7684\u8f6c\u6362
- \u6709\u65f6\u949f\u504f\u79fb\u7684\u98ce\u9669
- \u5f53\u6570\u636e\u521a\u8fdb\u5165\u7684\u65f6\u5019\uff0c\u540e\u51e0\u4e2a\u5bc4\u5b58\u5668\u5185\u7684\u503c\u662f\u65e0\u6cd5\u786e\u5b9a\u7684\u72b6\u6001
\u5e76\u884c\u52a0\u8f7d\u7684\u79fb\u4f4d\u5bc4\u5b58\u5668 | Parallel Load Shift Registers
- \u6bcf\u4e2a\u5bc4\u5b58\u5668\u524d\u4e09\u4e2aAND
- \u7528\u4e8eShift
- \u7528\u4e8e\u5e76\u884c\u52a0\u8f7d
- \u7528\u4e8e\u4fdd\u6301\u539f\u6765\u7684\u503c
\u53cc\u5411\u79fb\u4f4d\u5bc4\u5b58\u5668
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#part-2counters-register-cells-buses-serial-operations","title":"Part 2:Counters, register cells, buses, & serial operations","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#counter","title":"Counter","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#ripple-counter","title":"ripple Counter | \u884c\u6ce2\u8ba1\u6570\u5668","text":"
- \u6ce8\u610f\uff0c\u4e0b\u56fe\u662f\u5728\u4e0a\u9762\u76846-10\u57fa\u7840\u4e0a\u5b8c\u6210\u7684\u2014\u2014\u5b83\u5728\u6bcf\u4e00\u4e2a\u5bc4\u5b58\u5668\u524d\u591a\u52a0\u4e86\u4e00\u4e2aMUX\uff08\u6bcf\u4e2a\u5bc4\u5b58\u5668\u524d\u90fd\u6709\u4e00\u4e2aMUX\uff09
\u5de5\u4f5c\u539f\u7406
- \u5728\u6bcf\u4e2a\u65f6\u949f\u5468\u671f\u53cd\u8f6c\uff08\u9ed8\u8ba4\u662f\u5728\u65f6\u949f\u4fe1\u53f7\u7684\u4e0a\u5347\u6cbf\u89e6\u53d1\uff09
- \u4f46\u662f\uff0c\u7b2c\u4e00\u4e2a\u89e6\u53d1\u5668\u4e4b\u5916\u7684\u89e6\u53d1\u5668\u6240\u4f7f\u7528\u7684\u65f6\u949f\u4fe1\u53f7\u90fd\u662f\u4e0a\u4e00\u4e2a\u89e6\u53d1\u5668\u7684\u8f93\u51fa
\u95ee\u9898
Timing Delay
\u8fd9\u4e2a\u65f6\u5e8f\u56fe\u8981\u6ce8\u610f"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#synchronous-counters","title":"Synchronous Counters | \u540c\u6b65\u4e8c\u8fdb\u5236\u8ba1\u6570\u5668","text":"
- \u597d\u5904\u662f\u529f\u8017\u4f4e
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#other-counters","title":"Other Counters","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#with-parallel-load","title":"With Parallel Load","text":"Load Count Action 0 0 Hold 0 1 Count 1 X Load
\\(Q_n\u7ffb\u8f6c\u7684\u6761\u4ef6\uff1aQ_1 - Q_{n-1}\u5747\u7b49\u4e8e1\\)
serial counter
\u53ef\u4ee5\u770b\u51fa\u6765\uff0c\u5f53Load == 1\u65f6\uff0cCount\u662f\u88ab\u6291\u5236\u4e86\u7684\uff1b\u8fd9\u6837\u8bbe\u8ba1\u6709\u4e00\u4e2a\u597d\u5904\uff0c\u5c31\u662f\u8f93\u5165\u4e3a 1 1 \u7684\u72b6\u6001\u4e0d\u4f1a\u53d1\u751f\u51b2\u7a81
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#bcd-code-counter","title":"BCD code Counter","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#module-n-counter","title":"module N Counter","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#serial-transfers-and-microoperations","title":"Serial Transfers and Microoperations | \u4e32\u884c","text":"
LOAD
\u662f\u5e76\u884c\u8fdb\u884c\u7684\u30026 - 0110 ReLOAD- \u4e00\u79cd\u4e0d\u53ef\u884c\u7684\u65b9\u6cd5\u662f\u5728 7-0111 \u65f6\u8fdb\u884c
Clear
- Clear \u64cd\u4f5c\u4e0d\u662f\u540c\u6b65\u7684\uff0c\u53ef\u80fd\u5c06D0 Reset \u52301\u65f6\uff0cclear\u4fe1\u53f7\u5df2\u7ecf\u53d1\u751f\u53d8\u5316\uff0c\u4f46clear\u8fc7\u7a0b\u5e76\u672a\u5b8c\u6210
- SRG4 \u4e3a\u56db\u4f4d\u4e32\u884c\u884c\u6ce2\u8ba1\u6570\u5668
\u4e32\u884c\u52a0\u6cd5
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#register-cell","title":"Register Cell | \u5bc4\u5b58\u5668\u5355\u5143\u8bbe\u8ba1","text":"
- \u597d\u5904\u5728\u4e8e\u7528\u7684\u7a7a\u95f4\u66f4\u5c11
- A \u4fdd\u5b58\u8fd0\u7b97\u7ed3\u679c\uff1bB \u7528\u4e8e\u52a0\u8f7d\u52a0\u6570\uff1b
- Shift \u4e3a 1\uff0cClock\u8109\u51b2\u6052\u4e3a1\uff0c\u4e00\u76f4\u79fb\u4f4d\uff1bShift 0\uff0cClock\u8109\u51b2\u6b63\u5e38\uff0c\u6839\u636e\u8109\u51b2\u8fdb\u884c\u8fd0\u7b97
# Part 3 \u2013 Control of Register Transfers | \u5bc4\u5b58\u5668\u4f20\u8f93\u63a7\u5236
\u8bbe\u8ba1\u63a7\u5236\u5355\u5143 \u5bc4\u5b58\u5668\u7ea7\u522b\u8fdb\u884c\u8bbe\u8ba1\u4e5f\u5c31\u662f RTL
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#design-procedure","title":"Design Procedure","text":"\u4e66\u4e0a\u7684\u4e24\u4e2a\u4f8b\u5b50
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/","title":"P7","text":"Definition
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#rom","title":"ROM","text":"\u7ea6 210 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#ram","title":"RAM","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#sram","title":"SRAM","text":"\u9759\u6001\u7684RAM
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#coincident-selection","title":"Coincident Selection","text":"
- SR Latch
- Select input for control 1
- Dual Rail Data Inputs \\(B\\) and \\(\\bar{B}\\)
- Dual Rail Data Outputs $C and \\bar{C} $
\u5982\u679c\u53ea\u662f\u4f7f\u7528\u4e00\u79cdDecoder\uff0c\u95e8\u7684\u6d88\u8017\u5f88\u5927\u5f88\u5927\uff0c\u5b9e\u73b0\u8fd9\u79cd\u9635\u5217\u9009\u62e9\u66f4\u597d
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#array-of-ram","title":"Array Of RAM","text":"
- Simplified Symbol Of RAM
- The capacity OF RAM
- The number Of Word --- the address
- The length of each word --- data Input and Output
Example 1 : \u5c06\u56db\u4e2a64K*8\u7684\u8f6c\u5316\u4e3a\u4e00\u4e2a256K*8
Example 2:
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#dram","title":"DRAM","text":"\u52a8\u6001\u7684RAM\uff0c\u5229\u7528
\u6210\u672c\u4f4e\uff08\u7528\u6676\u4f53\u7ba1\u6570\u76ee\u66f4\u5c11\uff0c\u7ed3\u6784\u66f4\u7b80\u5355\uff09\uff0c\u5bb9\u91cf\u5927 SRAM Cell \u4f7f\u7528\u4e00\u4e2a\u9501\u5b58\u5668\u6765\u5b58\u50a8\u6570\u636e\uff0c\u800c DRAM Cell \u4f7f\u7528\u4e00\u4e2a\u7535\u5bb9\u548c\u4e00\u4e2a\u6676\u4f53\u7ba1\u6765\u5b58\u50a8\u6570\u636e\u3002
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#slice","title":"Slice","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#timing","title":"Timing","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#_1","title":"\u4f8b\u9898","text":"
- D\u9501\u5b58\u5668
- \u4e00\u4e2aSelect
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#dram_1","title":"DRAM","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#_2","title":"\u5185\u5b58\u8ba1\u7b97","text":"
address line
data line
address pins
"},{"location":"CodingLanguage/","title":"Index","text":"
- \u4e2a\u4eba\u8ba4\u4e3a\uff0c\u4ed6\u5e76\u6ca1\u6709\u63d0\u53ca\u4e4b\u540e\u7684\u8f93\u51fa\u60c5\u51b5\uff0c\u6240\u4ee5\u6309\u71672 byte\u8ba1\u7b97
\u7ea6 0 \u4e2a\u5b57
!!!
"},{"location":"CodingLanguage/C/","title":"Index","text":"\u7ea6 80 \u4e2a\u5b57
\u6982\u8ff0
\u8fd9\u91cc\u7684\u6587\u6863\u662f\u6211\u4e4b\u524d\u5b66\u4e60C\u5c0fC\u5927\u65f6\u5199\u7684\uff0c\u5f53\u65f6\u7528\u7684\u7b14\u8bb0\u5e73\u53f0\u6bd4\u8f83\u6742\u4e71\uff0c\u6240\u4ee5\u5f88\u591a\u4e1c\u897f\u5df2\u7ecf\u4e22\u5931\u3002\u8fd9\u4efd\u7b14\u8bb0\u603b\u4f53\u5e76\u4e0d\u662f\u5f88\u5168\u9762\uff0c\u66f4\u591a\u7684\u662f\u6211\u5f53\u65f6\u4e0d\u592a\u7406\u89e3\u7684\u90e8\u5206\u3002
\u7b80\u5355\u6765\u8bf4\uff0c\u662f\u62ff\u6765\u5145\u6570\u7684\uff08\u96fe
"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/","title":"\u5b58\u50a8\u7c7b\u522b\u3001\u94fe\u63a5\u548c\u5185\u5b58\u7ba1\u7406","text":"\u7ea6 472 \u4e2a\u5b57 21 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_2","title":"\u5b58\u50a8\u7c7b\u522b","text":"\u4e00\u4e2a
\u5bf9\u8c61
\u5177\u6709\u5b58\u50a8\u671f \u4e00\u4e2a\u6807\u8bc6\u7b26
\u5177\u6709 \u94fe\u63a5\u548c\u4f5c\u7528\u57df \u63cf\u8ff0\u5176\u53ef\u89c1\u6027"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_3","title":"\u57fa\u672c\u6982\u5ff5","text":""},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_4","title":"\u4f5c\u7528\u57df","text":"
**\u81ea\u52a8\u53d8\u91cf**
auto
\u5173\u952e\u5b57- \u4e0d\u4f1a\u81ea\u52a8\u521d\u59cb\u5316
**\u5bc4\u5b58\u5668\u53d8\u91cf**
register
\u5173\u952e\u5b57- \u65e0\u6cd5\u83b7\u53d6\u5730\u5740\uff0c\u56e0\u4e3a\u5b58\u50a8\u5728\u5bc4\u5b58\u5668\u800c\u975e\u5185\u5b58
- \u64cd\u4f5c\u901f\u5ea6\u66f4\u5feb
- \u53ef\u58f0\u660e\u7c7b\u578b\u6709\u9650\uff0cCPU \u4e2d\u7684\u5bc4\u5b58\u5668\u53ef\u80fd\u6ca1\u6709\u8db3\u591f\u7684\u5b58\u50a8\u7a7a\u95f4
**\u5757\u4f5c\u7528\u57df\u7684\u9759\u6001\u53d8\u91cf**
\uff08\u5c40\u90e8\u9759\u6001\u53d8\u91cf\uff09static
\u5173\u952e\u5b57\u5177\u6709\u5757\u4f5c\u7528\u57df\uff0c\u4f46\u662f\u9759\u6001\u5b58\u50a8\u671f
int f(double m)\n{\n int m; # \u6bcf\u6b21\u8fd0\u884c\u65f6\u90fd\u4f1a\u6267\u884c\n static int without = 1; # \u8fd0\u884c\u65f6\u5e76\u4e0d\u6267\u884c\n}\n
**\u5916\u90e8\u94fe\u63a5\u7684\u9759\u6001\u53d8\u91cf**
\uff08\u5916\u90e8\u53d8\u91cf\uff09extern
\u5173\u952e\u5b57\u3002\u7528\u4e8e\u5f15\u7528\u5df2\u6709\u7684\u5916\u90e8\u53d8\u91cf- \u5916\u90e8\u53d8\u91cf\u53ea\u80fd\u521d\u59cb\u5316\u4e00\u6b21\uff0c\u800c\u4e14\u5fc5\u987b\u5728\u5b9a\u4e49\u65f6\u8fdb\u884c
**\u5185\u90e8\u94fe\u63a5\u7684\u9759\u6001\u53d8\u91cf**
- \u7528\u4e8e\u672c\u6587\u4ef6
Tip : \u7ffb\u8bd1\u5355\u5143\uff1a\u7f16\u8bd1\u5668\u628a\u6e90\u4ee3\u7801\u6587\u4ef6\u548c\u5176\u4e2d\u6240\u6709\u7684\u5934\u6587\u4ef6\u770b\u6210\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u5305\u542b\u4fe1\u606f\u7684\u6587\u4ef6 \u5168\u5c40\u53d8\u91cf\uff08\u6587\u4ef6\u4f5c\u7528\u57df\u53d8\u91cf\uff09\u7684\u4f5c\u7528\u8303\u56f4\u662f\u4e00\u4e2a\u7ffb\u8bd1\u5355\u5143
"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_5","title":"\u94fe\u63a5","text":"
\u5916\u90e8\u94fe\u63a5
\u591a\u6587\u4ef6\u7a0b\u5e8f\u5185\u90e8\u94fe\u63a5
\u4e00\u4e2a\u7ffb\u8bd1\u5355\u5143\u5185\u65e0\u94fe\u63a5
\u51fd\u6570\u539f\u578b\u3001 \u6587\u4ef6\u4f5c\u7528\u57df \u53ef\u4ee5\u662f\u5185\u90e8/\u5916\u90e8\u94fe\u63a5"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_6","title":"\u5b58\u50a8\u671f","text":"int giants = 5; # \u5916\u90e8\u94fe\u63a5\nstatic int dodgers = 3; # \u5185\u90e8\u94fe\u63a5\nint main()\n{\n\n}\n
- \u5206\u7c7b
"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_7","title":"\u5185\u5b58\u5206\u914d","text":""},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_8","title":"\u52a8\u6001\u5185\u5b58\u5206\u914d","text":"
\u9759\u6001\u5b58\u50a8\u671f
\u7a0b\u5e8f\u6267\u884c\u671f\u95f4\u4e00\u76f4\u5b58\u5728 \u6ce8\u610f\uff0cstatic \u5e76\u4e0d\u5f71\u54cd\u53d8\u91cf\u5b58\u50a8\u671f\uff0c\u800c\u662f\u5f71\u54cd\u5176\u94fe\u63a5\u5c5e\u6027\u3002\u6240\u6709\u6587\u4ef6\u4f5c\u7528\u57df\u53d8\u91cf\u90fd\u5177\u6709\u9759\u6001\u5b58\u50a8\u671f\u7ebf\u7a0b\u5b58\u50a8\u671f
\u4ece\u88ab\u58f0\u660e\u5230\u7ebf\u7a0b\u7ed3\u675f\u81ea\u52a8\u5b58\u50a8\u671f
\u5757\u4f5c\u7528\u57df\u7684\u53d8\u91cf\uff08\u5c40\u90e8\u53d8\u91cf\u00b7\u00b7 \u8fdb\u5165\u5757\u65f6\u4e3a\u53d8\u91cf\u5206\u914d\u5185\u5b58\uff0c\u5b58\u50a8\u671f\u4ece\u5757\u5f00\u59cb\u5230\u5757\u7ed3\u675f \u4f46\u53d8\u957f\u6570\u7ec4\u7684\u5b58\u50a8\u671f\u662f\u4ece\u5b9a\u4e49\u5230\u5757\u7ed3\u675f\u52a8\u6001\u5206\u914d\u5b58\u50a8\u671f
stdlib.h
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/","title":"\u6307\u9488\u4e0e\u94fe\u8868","text":"
malloc
\u51fd\u6570free
\u51fd\u6570double * positon;\nint n;\nposition = (double *) malloc(n * sizeof(double));\n\nif(position == NULL)\n{\n exit(0);\n}\n\nfree(position);\n
\u7ea6 393 \u4e2a\u5b57 77 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#error","title":"Error","text":""},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#point","title":"POINT","text":""},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_2","title":"\u666e\u901a\u6307\u9488","text":"char a[]=\"axd123\";\nchar **s;\ns=&a; //\u6b64\u5904a[]\u4e3a\u5b57\u7b26\u4e32\u5e38\u91cf \u4e0d\u80fd\u53d6\u5730\u5740 a\u672c\u8eab\u8868\u793a\u8be5\u5b57\u7b26\u4e32\u7684\u5730\u5740\nchar *p;\np=a;\n// \u6b64\u65f6 \u53ef\u4ee5\u4ee4 s=&p\n
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_3","title":"\u7b97\u672f\u8fd0\u7b97\u4e0e\u5173\u7cfb\u8fd0\u7b97","text":"
- \u53d8\u91cf\u63d0\u4f9b\u8bbf\u95ee\u5730\u5740\u7684\u5feb\u6377\u65b9\u5f0f\uff0c\u4f46\u662f\u786c\u4ef6\u4ecd\u7136\u901a\u8fc7\u5730\u5740\u8bbf\u95ee\u5185\u5b58\u4f4d\u7f6e\uff0c\u540d\u5b57\u4e0e\u5185\u5b58\u4f4d\u7f6e\u7684\u5173\u8054\u7531\u7f16\u8bd1\u5668\u5b9e\u73b0\u3002
*
\u95f4\u63a5\u8bbf\u95ee\u5730\u5740\u7b26\uff0c\u53ea\u80fd\u7528\u4e8e\u6307\u9488\u7c7b\u578b\u8868\u8fbe\u5f0f\uff0c\u5bf9\u4e8e\u6307\u9488\u5e38\u91cf\u4e0d\u9002\u7528,\u5fc5\u987b\u5f3a\u5236\u8f6c\u6362 \u5176\u8bbf\u95ee\u4e00\u4e2a\u7279\u5b9a\u7684\u4f4d\u7f6e e.g. \u00a0(int )100 = 25; \u00a0 \u5373\u5728\u5df2\u77e5\u5730\u5740 100 \u7684\u4f4d\u7f6e\u5b58\u50a8\u503c 25**NULL**
\u00a0 \u5bf9\u6307\u9488\u53d8\u91cf\u8fdb\u884c\u663e\u5f0f\u7684\u521d\u59cb\u5316\uff0c\u5728\u6307\u9488\u89e3\u5f15\u7528\u4e4b\u524d\u8fdb\u884c\u68c0\u67e5\uff0c\u907f\u514d\u975e\u6cd5\u6307\u9488\u5728\u540c\u4e00\u4e2a\u6570\u7ec4\u5185 \u8fdb\u884c\u5173\u7cfb\u8fd0\u7b97\u6ce8\u610f\u4e0b\u6807
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_4","title":"\u4e8c\u7ea7\u6307\u9488","text":""},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_5","title":"\u6307\u9488\u6570\u7ec4","text":"char * color[] = {\"red\", \"blue\", \"yellow\", \"green\", \"black\"};\n int i, flag = 0; char ch;\n char **pc;\n pc = color;\n printf(\"Input a character:\");\n ch = getchar();\n for( i =0; i<5; i++ ) {\n if( **(pc+i)==ch ) {\n flag = 1;\n puts(*(pc+i));\n }\n }\n if( flag==0 )\n printf(\"Not Found\");\n
int * a[]={\"asd\",\"dwq\"}; a[]\u4e2d\u5b58\u50a8\u7684\u662f\u6307\u9488
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_6","title":"\u6570\u7ec4\u6307\u9488","text":"int a[10]; &a \u6570\u7ec4\u6307\u9488( \u00a0int (p)[10] \u00a0) \u00a0 \u6307\u5411\u6570\u7ec4 a a == &a[0] a + 1 == &a[1] a[k] \u00a0==(a+k)
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_7","title":"\u51fd\u6570\u6307\u9488","text":"\u5b9a\u4e49 \u8fd4\u56de\u503c\u7c7b\u578b\uff08*\u53d8\u91cf\u540d\uff09\uff08\u53c2\u6570\u7c7b\u578b\u8868\uff09
double \u00a0(*op) (double);
int _ (_f)();
\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u6307\u9488\uff0c\u8be5\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u6574\u578b\u7684\u6307\u9488
int _(_g[])(int,float);
g[ ]\u4e3a\u4e00\u4e2a\u6570\u7ec4\uff0c\u5176\u4e2d\u5143\u7d20\u4e3a\u51fd\u6570\u6307\u9488\uff1b\u8fd4\u56de\u6574\u578b\u6307\u9488
\u51fd\u6570\u540d\u4e5f\u662f\u4e00\u4e2a\u6307\u9488 \u7c7b\u578b\uff1a\u5374\u51b3\u4e8e\u8fd4\u56de\u503c\u7684\u7c7b\u578b\u548c\u53c2\u6570\u5217\u8868\u7684\u7c7b\u578b\u4ee5\u53ca\u4e2a\u6570
here is an error, the second line of main function, there must be ptr = f1 ;
\u65b9\u4fbf\u540c\u4e00\u4e2a\u51fd\u6570\u5185\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8c03\u7528\u4e0d\u540c\u7684\u5b50\u51fd\u6570
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#typedef","title":"typedef \u51fd\u6570\u6307\u9488\u7c7b\u578b","text":"\u6709\u5229\u4e8e\u7b80\u5316\u51fd\u6570\u6307\u9488\u7684\u4f7f\u7528
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_8","title":"\u6307\u9488\u4e0e\u6570\u7ec4","text":""},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_9","title":"\u94fe\u8868","text":""},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_10","title":"\u5355\u94fe\u8868","text":"#include <stdio.h>\n#include <math.h>\n//typedef \u5c06\u53d8\u91cf\u540dTFunc\u66ff\u6362\u4e3a\u51fd\u6570\u6307\u9488\u7c7b\u578b\u540d\ntypedef double (*TFunc)(double);\ndouble calc(TFunc f, double a, double b);\ndouble f1(double);\ndouble f2(double);\nint main(void)\n{\n TFunc ptr = f1;\n printf(\"f1: %.4f\\n\", calc(ptr,0,1));\n printf(\"f2: %.4f\\n\", calc(f2,1,2));\n return 0;\n}\n\ndouble calc(TFunc f, double a, double b)\n{\n return (f(a)+f(b))*(b-a)/2;\n}\ndouble f1(double x)\n{\n return x*x;\n}\ndouble f2(double x)\n{\n return sin(x)/x;\n}\n
\u63d2\u5165\u4e00\u4e2a\u503c
"},{"location":"CodingLanguage/CPP/","title":"Index","text":"#include <stdio.h>\n#include <string.h>\ntypedef struct NODE{\n int value;\n struct Node *next;\n}Node;\nint value; //supposed that we have get a new value into the link\nNode *head,*pre,*p,*new;\npre=NULL;\n\n//\u5f15\u7528\u4e4b\u524d\u786e\u4fddp\u4e0d\u662fnull\nwhile(p!=NULL&&p->value<value){\n pre=p;\n p=p->next;\n}\n\n//\nnew=(Node *)malloc(sizeof(Node));\nif(new==NULL) return ;\nnew->value=value;\nnew->next=p;\n\n//\nif(pre==NULL){\n head=new;\n}else{\n pre->next=new;\n}\n\u4f20\u5165 **Node [&head] \u4fee\u6539\u5934\u6307\u9488 *head=new;\n
\u7ea6 29 \u4e2a\u5b57
\u8d44\u6599
- \u4e66
- \u300aC++ primer\u300b
- \u535a\u5ba2 \u7f51\u7ad9
- C++\u90a3\u4e9b\u4e8b
- cpp referrence
- effective C++
- \u7ec3\u4e60
\u5bfc\u822a\u680f
"},{"location":"CodingLanguage/CPP/Static%26Extern/","title":"Static & Extern","text":"
- cake
- Static&Extern
- const
- memory
\u7ea6 236 \u4e2a\u5b57 26 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
.h
"},{"location":"CodingLanguage/CPP/Static%26Extern/#static","title":"Static","text":"code
- \u5168\u5c40\u53d8\u91cf \u9650\u5236\u5728\u6b64\u6587\u4ef6\u5185\u90e8
\u51fd\u6570\u4fee\u9970 \u540c\u4e0a
\u7c7b\u4e2d\u53d8\u91cf \u6240\u6709\u7c7b\u5171\u4eab\u53d8\u91cf(\u6ce8\u610f\u9700\u8981\u5728\u7c7b\u7684\u5916\u90e8\u5bf9\u8fd9\u4e2a\u53d8\u91cf\u8fdb\u884c\u5b9a\u4e49\uff0c\u4e5f\u662f\u5bf9\u4ed6\u8fdb\u884c\u521d\u59cb\u5316\u7684\u5730\u65b9) \u4e0d\u80fd\u5728\u521d\u59cb\u5316\u5217\u8868\u4e2d\u521d\u59cb\u5316\u9759\u6001\u53d8\u91cf
\u7c7b\u4e2d\u51fd\u6570\u4fee\u9970 \u53ea\u80fd\u4f7f\u7528
static
\u53d8\u91cf\uff0c\u6bd4\u5982\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\u5982\u679c\u5728foo\u51fd\u6570\u4e2d\u8c03\u7528value\u5c31\u4f1a\u62a5\u9519 \u8fd9\u4e2a\u51fd\u6570\u662f\u72ec\u7acb\u4e8e\u5bf9\u8c61\u4e4b\u5916\u7684\uff0c\u6ca1\u6709\u9690\u542b\u7684this
\u6307\u9488
- \u6ca1\u6709
this
\u6307\u9488- \u53ea\u80fd\u4f7f\u7528\u9759\u6001\u6570\u636e
- \u4e0d\u80fd\u88abdynamically Overridden
\u6ce8\u610f12\uff0c18\u884c\u7684\u5199\u6cd5
"},{"location":"CodingLanguage/CPP/Static%26Extern/#extern","title":"Extern","text":"#include <iostream>\nusing namespace std;\n\nclass A\n{\npublic:\n A() : value(0) { cout << \"A() \" << endl; };\n ~A() { cout << \"~A\" << endl; };\n static int count;\n static void foo()\n {\n cout << \"foo() \" << count << endl;\n }\n\nprivate:\n int value;\n};\nint A::count;\nint main()\n{\n A a;\n a.foo();\n A::foo();\n cout << a.count << endl;\n cout << A::count << endl;\n}\n
extern is a declaration says there will be such a variable somewhere in the whole program
\u5982\u679c\u9700\u8981\u91cd\u590d\u4f7f\u7528\u540c\u4e00\u4e2a\u53d8\u91cf\uff0c\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a
1.\u4f7f\u7528\u5934\u6587\u4ef6\uff0c\u7136\u540e\u58f0\u660e\u5b83\u4eec\uff0c\u7136\u540e\u5176\u4ed6\u6587\u4ef6\u53bb\u5305\u542b\u5934\u6587\u4ef6\u3002
2.\u5728\u5176\u4ed6\u6587\u4ef6\u4e2d\u76f4\u63a5extern
Backlinks:
"},{"location":"CodingLanguage/CPP/TypeCast/","title":"Type Cast","text":"\u7ea6 139 \u4e2a\u5b57 3 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
Info
"},{"location":"CodingLanguage/CPP/TypeCast/#_1","title":"\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362","text":"
- \u9690\u5f0f\u7c7b\u578b\u8f6c\u6362
- \u663e\u5f0f\u7c7b\u578b\u8f6c\u6362
- \u6574\u578b\u63d0\u5347
- \u65e0\u7b26\u53f7\u7c7b\u578b\u8f6c\u6362
"},{"location":"CodingLanguage/CPP/TypeCast/#static_cast","title":"static_cast","text":"
cast-name<type>(expression)
\u53ea\u8981\u4e0d\u5305\u542b\u5e95\u5c42\u7684const\u5c31\u53ef\u4ee5\u4f7f\u7528
static_cast
\u5728\u76f8\u5173\u7684\u7c7b\u578b\u4e4b\u95f4\u8f6c\u6362\uff0c\u6bd4\u5982
- \u4e00\u4e2a\u7236\u7c7b\u548c\u6d3e\u751f\u7c7b\u4e4b\u95f4\u7684\u8f6c\u6362
void *
\u5230\u5176\u4ed6\u6307\u9488\u7c7b\u578b\u4e4b\u95f4\u7684\u8f6c\u6362int
float
\u7b49\u7c7b\u578b\u4e4b\u95f4\u7684\u8f6c\u6362- \u5b83\u7684\u5b89\u5168\u6027\u6bd4\u8f83\u9ad8\uff0c
"},{"location":"CodingLanguage/CPP/TypeCast/#const_cast","title":"const_cast","text":"double m;\nvoid *p = &m;\ndouble *dp = static_cast<double *>(p);\n
\u53ea\u80fd\u6539\u53d8\u5e95\u5c42const
"},{"location":"CodingLanguage/CPP/TypeCast/#reinterpret_cast","title":"reinterpret_cast","text":"\u4e3a\u8f6c\u6362\u5bf9\u8c61\u7684\u4f4d\u6a21\u5f0f\u63d0\u4f9b\u66f4\u4f4e\u5c42\u6b21\u7684\u91cd\u65b0\u89e3\u91ca
"},{"location":"CodingLanguage/CPP/argv/","title":"Argv","text":"\u7ea6 0 \u4e2a\u5b57
"},{"location":"CodingLanguage/CPP/const/","title":"const","text":"\u7ea6 4 \u4e2a\u5b57
Backlinks:
"},{"location":"CodingLanguage/CPP/memory/","title":"\u5185\u5b58\u6a21\u578b","text":"\u7ea6 44 \u4e2a\u5b57 19 \u884c\u4ee3\u7801
INFO
"},{"location":"CodingLanguage/CPP/memory/#_2","title":"memory","text":"
- stack \u5411\u4e0b\u589e\u957f local vars
- heap \u5411\u4e0a\u589e\u957f dynamically allocated vars.
- code/data global vars static global vars static local vars
example
"},{"location":"CodingLanguage/CPP/memory/#static","title":"static","text":"const char * s1 = \"\" // \u6307\u5411\u9759\u6001\u53d8\u91cf\u7684\u6307\u9488 \nchar s2 [] = \"\" // copy \u4e00\u4efd \u5b58\u50a8\u5728\u6808\u533a\n\n\nconst char *s1 = \"Hello\"; // \u6307\u5411\u9759\u6001\u53d8\u91cf\u7684\u6307\u9488\nchar *s3 = \"Hello\";\nchar s2[] = \"Hello\";\n\ncout << (void *)main << endl;\ncout << (void *)s1 << endl;\ncout << (void *)s2 << endl;\ncout << (void *)s3 << endl;\n/*\n0x40158f\n0x404008\n0x61fe0a\n0x404008\n*/\n
\u5728\u7c7b\u4e2d\u4f7f\u7528
Backlinks:
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/","title":"\u57fa\u7840\u90e8\u5206","text":"\u7ea6 1711 \u4e2a\u5b57 392 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 13 \u5206\u949f
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_2","title":"\u57fa\u7840","text":"\u4e00\u4e9b\u6ce8\u610f\u7684\u5730\u65b9
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_3","title":"\u5f15\u7528","text":"
- \u8d4b\u503c\u4e0e\u521d\u59cb\u5316\u5176\u5b9e\u5e76\u4e0d\u5b8c\u5168\u76f8\u540c\uff0c\u521d\u59cb\u5316\u662f\u521b\u5efa\u53d8\u91cf\u65f6\u8d4b\u4e88\u4e00\u4e2a\u521d\u59cb\u503c\uff0c\u8d4b\u503c\u662f\u64e6\u9664\u5f53\u524d\u503c\u3002
- \u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e00\u70b9\u5e76\u6ca1\u6709\u4efb\u4f55\u5f71\u54cd
\u5f15\u7528
\u8fd9\u662fC++\u4e2d\u4e00\u79cd\u65b0\u7684\u7279\u6027\u3002\u6211\u4eec\u5e38\u8bf4\u7684\u5f15\u7528\u6307\u7684\u662f\u5de6\u503c\u5f15\u7528\uff0c\u8fd8\u6709\u4e00\u79cd\u5f15\u7528\u662f\u6307\u53f3\u503c\u5f15\u7528
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_4","title":"\u5de6\u503c\u5f15\u7528","text":"\u5b9a\u4e49\u5de6\u503c\u5f15\u7528\u7684\u4f7f\u7528\uff0c\u4e00\u5b9a\u8981\u8d4b\u521d\u59cb\u503c
warning
- \u4e0d\u5141\u8bb8\u4f7f\u7528\u5f15\u7528\u7684\u6570\u7ec4C/C++(251)
- \u4e0d\u5141\u8bb8\u4f7f\u7528\u5f15\u7528\u7684\u5f15\u7528
int value;\nint &refVal = value;\nint *PtrValue = &value;\n// \u6307\u5411\u6307\u9488\u7684\u5f15\u7528\nint *&refPointer = PtrValue; \n// \u6570\u7ec4\u5f15\u7528\nint &arr[10]; // \u5143\u7d20\u4e3a\u5f15\u7528\u7c7b\u578b \uff1f \u4e0d\u5141\u8bb8\u4f7f\u7528\u5f15\u7528\u7684\u6570\u7ec4C/C++(251)\n\nint (&arr)[10]; // \u6574\u578b\u6570\u7ec4\u7684\u5f15\u7528\n
\u5bf9\u4e00\u4e2a\u5e38\u91cf\u7684\u5f15\u7528\u53ef\u80fd\u662f\u4e00\u4e2a\u975e\u5e38\u91cf,
const int &
\u53ea\u662f\u5bf9\u5f15\u7528\u7684\u64cd\u4f5c\u6709\u4e86\u9650\u5236int i = 10086;\nconst int m = i;\nint &ref_i = i;\nconst int &Ref_i = i;\nref_i -= 1;\nstd::cout << \"i:\" << i << std::endl;\nstd::cout << \"m:\" << m << std::endl; // 10086\nstd::cout << \"i:\" << ref_i << std::endl; // 10085\nstd::cout << \"I:\" << Ref_i << std::endl;\n
const \u5f15\u7528
double a = 1.12;\nconst double &ref_a = a;\nconst int &Ref_a = a;\na = a - 100;\nstd::cout << \"a:\" << ref_a << std::endl;\nstd::cout << \"A:\" << Ref_a << std::endl;\n\n>> a:-98.88\n>> A:1\n
Warning
\u5f15\u7528\u672c\u8eab\u5e76\u4e0d\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5b83
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_5","title":"\u6307\u9488","text":"\u7ed1\u5b9a
\u5230\u4e00\u4e2a\u5bf9\u8c61\u4e0a\u9762\u53bb\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u5e76\u4e0d\u662f\u590d\u5236
\u4e0d\u80fd\u591f\u5f62\u6210\u4e00\u4e2a\u5f15\u7528\u7684\u5f15\u7528Warning
\u5728CPP\u4e2d\uff0c\u6307\u9488\u7684\u521d\u59cb\u5316\u6700\u597d\u4f7f\u7528
nullptr
,\u76f8\u5f53\u4e8evoid *\uff0c\u800cNULL\u5728cstdlib
\u4e2d\u5b9a\u4e49\uff0c"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#const","title":"const","text":"int * a = nullptr;\n
const \u5206\u4e3a\u9876\u5c42\u7684\u548c\u5e95\u5c42\u7684\u3002 \u9876\u5c42\u7684 Top \u8868\u793a\u672c\u8eab\u4e0d\u53ef\u53d8\uff0c\u6307\u5411\u7684\u503c\u4e0d\u4e00\u5b9a \u5e95\u5c42\u7684 \u8868\u793a\u672c\u8eab\u53ef\u53d8\uff0c\u6307\u5411\u4e00\u4e2a\u4e0d\u53ef\u53d8\u7684\u503c \u800c\u6307\u9488\u65e2\u53ef\u4ee5\u662fTop-level\uff0c\u4e5f\u53ef\u4ee5\u662fLow-level
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#const_1","title":"const\u4e0e\u6307\u9488","text":"Example
\u5176\u5b9e\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0cint * const a = &i; // \u6307\u9488\u662f\u5e38\u91cf a\u9876\u5c42\u7684\uff0c\u4e0d\u80fd\u6539\u53d8 \nconst int * b = &j; // \u6307\u5411\u5e38\u91cf\u7684\u6307\u9488\n
a
\u662f\u4e00\u4e2a\u6307\u9488\u5e38\u91cf\uff0cb
\u662f\u4e00\u4e2a\u5e38\u91cf\u6307\u9488\uff1b\u8fd9\u6837\u4fa7\u91cd\u540e\u9762\u7684\u4e00\u4e2a\uff0c\u53ef\u80fd\u5bb9\u6613\u7406\u89e3\u4e00\u70b9 \u8ddd\u79bb\u53d8\u91cf\u6700\u8fd1\u7684\u662f*
\u6216\u8005const
\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5224\u65ad\u53d8\u91cf\u7684\u7c7b\u578b"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#constexpr","title":"constexpr\u548c\u5b57\u9762\u503c\u7c7b\u578b","text":"const char * a; //\u6307\u5411const\u5bf9\u8c61\u7684\u6307\u9488\u6216\u8005\u8bf4\u6307\u5411\u5e38\u91cf\u7684\u6307\u9488\u3002\nchar const * a; //\u540c\u4e0a\nchar * const a; //\u6307\u5411\u7c7b\u578b\u5bf9\u8c61\u7684const\u6307\u9488\u3002\u6216\u8005\u8bf4\u5e38\u6307\u9488\u3001const\u6307\u9488\u3002 a\u662f\u4e0d\u53ef\u4fee\u6539\u7684\u5de6\u503c\nconst char * const a; //\u6307\u5411const\u5bf9\u8c61\u7684const\u6307\u9488\u3002\n
constexpr
\u662f\u4e00\u79cd\u5e38\u91cf\u8868\u8fbe\u5f0f\uff0cC11\u52a0\u5165\u4f5c\u4e3a\u4e00\u79cd\u7c7b\u578b constexpr\u51fd\u6570\u8fd4\u56de\u503c\u4e0d\u4e00\u5b9a\u662f\u5e38\u91cf\u8868\u8fbe\u5f0f
constexpr\u51fd\u6570
\u5b9a\u4e49\u4e00\u4e2aconstexpr\u51fd\u6570\uff0c1. \u8fd4\u56de\u503c\u548c\u5f62\u53c2\u90fd\u5fc5\u987b\u662f\u5b57\u9762\u503c\u7c7b\u578b 2. \u51fd\u6570\u4f53\u5185\u53ea\u80fd\u5b58\u5728\u4e00\u53e5return
constexpr int new_sz() { return 11; }
constexpr size_t scale(size_t cnt){return new_sz()*cnt}
\uff0c\u5728\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\u65f6\uff0c\u5fc5\u987b\u5173\u6ce8\u5b9e\u53c2\u7684\u7c7b\u578b\u3002\u5982\u679c\u4e0d\u4e3a\u5b57\u9762\u503c\u7c7b\u578b\uff0c\u8c03\u7528\u5931\u8d25\u5b57\u9762\u503c\u5e38\u91cf literal
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_6","title":"\u5904\u7406\u7c7b\u578b","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_7","title":"\u7c7b\u578b\u522b\u540d","text":"
- \u6574\u578b \u6d6e\u70b9\u578b
- \u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff0c\u5b57\u7b26\u5b57\u9762\u503c '' \"\"
- \u6307\u9488\u5b57\u9762\u503c nullptr
typedef double wage;\nusing wage = double; \n
typedef
\u4f7f\u7528typedef\u65f6\uff0c\u4ee5\u4e0b\u4e24\u79cd\u7528\u6cd5\u53ef\u80fd\u5e26\u6765\u4e0d\u540c\u7684\u5f71\u54cd
typedef char *prtChar;\nconst char*A = &ch;\nconst prtChar B = &ch;\n// \u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cB\u662f\u4e00\u4e2a\u6307\u9488\uff1bA\u662f\u4e00\u4e2a\u5e38\u91cf\n\ntypedef char (*prtChar);\nconst char *A = &ch;\nconst prtChar B = &const_ch;\n// \u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cA\u3001B\u76f8\u540c\uff0c\u90fd\u662f\u4e00\u4e2a\u6307\u9488\u7c7b\u578b\u7684\u5e38\u91cf\n
\u4e3a\u4ec0\u4e48\u662f\u8fd9\u6837\u5b9a\u4e49\u7684
Todo Typedef\u7684\u5b9e\u9645\u4f5c\u7528 \u662f\u5982\u4f55\u53d1\u751f\u7684
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#auto","title":"auto","text":"C11
auto\u7684\u81ea\u52a8\u63a8\u65ad\uff0c\u4f1a\u4f7f\u5f97\u9876\u5c42\u7684const\u5931\u6548\uff0c\u4fdd\u7559\u5e95\u5c42\u7684const
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#decltype","title":"decltype","text":"int i = 0;\nconst int ci = i,&cr = ci;\nauto b = ci; // b is int\nauto c = cr;\n
C11
\u6709\u65f6\u5019\uff0c\u6211\u4eec\u53ea\u5e0c\u671b\u83b7\u5f97\u4e00\u4e2a
Function
\u7684\u6700\u7ec8\u8fd0\u7b97\u7c7b\u578b\uff0c\u800c\u4e0d\u5e0c\u671b\u7531\u5b83\u6765\u8d4b\u4e88\u521d\u59cb\u503cint i;\ndecltype(f()) sum;\nconst int ci = 0, &cj = ci;\ndecltype(ci) a = 0; // const int \ndecltype(cj) b = a; // const int &\n\ndecltype((i)) c; //Error!! \u5f15\u7528\u5fc5\u987b\u8d4b\u4e88\u521d\u59cb\u503c\n
Note
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_8","title":"\u5b57\u7b26\u4e32","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_9","title":"\u57fa\u672c\u64cd\u4f5c","text":"
decltype(())
\u7684\u7ed3\u679c\u6c38\u8fdc\u662f\u5f15\u7528decltype()
\u5219\u4e0d\u7136// Initailize\nstring s;\nstring _10c(10,'c');\nstring _hi(\"hi\");\nstring s = \"value\";\n// Input\ngetline(input,receive);\n// Method\ns.size(); // unsigned int \ns.empty();\n// \nstring str1 = \"World\";\nstring str2 = \"Hello\";\nstring str3 = str2 + \", \" + str1;\nstring str4 = \"Hello\" + \" , \" + str1; //false\n
Warning
C++\u4e2d\u7684\u5b57\u7b26\u4e32\u7684\u5b57\u9762\u503c\u7c7b\u578b\u5e76\u4e0d\u662f\u6807\u51c6\u5e93string\u7684\u5bf9\u8c61\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b57\u7b26\u4e32\u7684\u5b57\u9762\u503c\u7c7b\u578b\u548cstring\u4e0d\u662f\u540c\u4e00\u7c7b\u578b\u3002
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#cctype","title":"cctype","text":"for range"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#vector","title":"Vector","text":"for (auto c : str)\n cout << c << endl;\n\nfor (auto &c : str)\n c = toupper(c);\n
Warning
\u5c3d\u91cf\u51cf\u5c11\u4f7f\u7528\u6570\u7ec4\u548c\u6307\u9488\uff0c\u5c3d\u91cf\u4f7f\u7528 Vector \u548c iterator\u6216\u8005const_iterator \u5c3d\u91cf\u4f7f\u7528String\u800c\u4e0d\u662fC\u98ce\u683c\u7684\u57fa\u4e8e\u6570\u7ec4\u7684\u5b57\u7b26\u4e32
string str = \"ab\"; char str[] = {'a','b','\\0'}
// Initailize \nvector<int> v1(n, val);\nvector<vector<int>> v2;\nvector<string> v3;\nstring word;\n# \u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u6765\u521d\u59cb\u5316Vector\nint int_array[] = {0,1,2,3,4,5,6};\nvector<int> vec(begin(int_array),end(int_array));\n// Method\nwhile (cin >> word)\n v3.push_back(word);\nv3.pop_back();\n// \u8fd4\u56de\u7684\u662f \u5f15\u7528\u7c7b\u578b\nv3.back(); v3.front();\n// \u8fd4\u56de\u8fed\u4ee3\u5668\nv3.begin(); v3.end();\nv3.empty();\nv3.size();\n# \u5fc5\u987b\u8981\u6307\u5b9a\u6e05\u695atype\nvector<int>::size_type;\n# \u5728\u51fd\u6570\u4e2d\u8fd4\u56de\u4e00\u4e2aVector\nvector<string> process()\n{\n if(...)\n return {};\n else\n return {\"Yes\",\"No\",\"CPP\"};\n}\n
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_10","title":"\u8fed\u4ee3\u5668","text":"// \u904d\u5386 \n vector<string> a;\n a.push_back(\"begin\");\n a.push_back(\"NO.1\");\n *a.begin() = \"change\";\n for (auto ch : a[0])\n cout << ch;\n cout << endl;\n cout << \"2 : \" << a[1];\n// Insert\n position = vector.begin(); // \u662f\u4e00\u4e2aiterator\u7c7b\u578b\n vector.insert(position,number,val);\n// Erase\n vector.erase(position);\n vector.erase(position_begin,position_end);\n
Note
begin end \u8fd4\u56de\u503c\u7c7b\u578b\u53ef\u80fd\u662f iterator\u6216\u8005const_iterator
cbegin cend \u4e00\u5b9a\u662fconst_iterator
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_11","title":"\u6570\u7ec4","text":"
\u8fed\u4ee3\u5668\u7c7b\u578b
\u8fed\u4ee3\u5668\u8fd0\u7b97 string vector\u652f\u6301 \u83b7\u53d6\u4efb\u610f\u4f4d\u7f6e\u7684iterator
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#enum","title":"enum","text":"size_t cnt = 0;\nconstexpr size_t rowCnt = 3, colCnt = 4;\nint Arr[rowCnt][colCnt];\nfor(auto &Row : Arr) // note!\n for(auto Col : Row)\n {\n\n }\n
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_12","title":"\u8868\u8fbe\u5f0f","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_13","title":"\u7c7b\u578b\u8f6c\u6362","text":"
\u6cbf\u7528C\u4e2d\u7684\u8868\u8fbe
enum Color{red,green,blue};
\u4f7f\u7528C++\u7684\u7c7b
enum class Color{red,green,blue};
Info
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_14","title":"\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362","text":"
- \u9690\u5f0f\u7c7b\u578b\u8f6c\u6362
- \u663e\u5f0f\u7c7b\u578b\u8f6c\u6362
- \u6574\u578b\u63d0\u5347
- \u65e0\u7b26\u53f7\u7c7b\u578b\u8f6c\u6362
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#static_cast","title":"static_cast","text":"
cast-name<type>(expression)
\u53ea\u8981\u4e0d\u5305\u542b\u5e95\u5c42\u7684const\u5c31\u53ef\u4ee5\u4f7f\u7528
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#const_cast","title":"const_cast","text":"double m;\nvoid *p = &m;\ndouble *dp = static_cast<double *>(p);\n
\u53ea\u80fd\u6539\u53d8\u5e95\u5c42const
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#reinterpret_cast","title":"reinterpret_cast","text":"\u4e3a\u8f6c\u6362\u5bf9\u8c61\u7684\u4f4d\u6a21\u5f0f\u63d0\u4f9b\u66f4\u4f4e\u5c42\u6b21\u7684\u91cd\u65b0\u89e3\u91ca
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_15","title":"\u8fd0\u7b97\u7b26","text":"\u6982\u5ff5
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_16","title":"\u4f18\u5148\u7ea7\u7684\u95ee\u9898","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_17","title":"\u5f02\u5e38\u5904\u7406","text":"
- \u91cd\u8f7d\u8fd0\u7b97\u7b26
- \u5de6\u503c\u548c\u53f3\u503c
Info
- \u5f02\u5e38\u68c0\u6d4b
throw \u8868\u8fbe\u5f0f
- \u5f02\u5e38\u5904\u7406
try block
\u5f02\u5e38\u7c7b
// throw\n if(ISBN1 != ISBN2)\n throw runtime_error(\"Data ...\");\n// try\n try {\n // if throw one exception \n // then, go for the related catch to deal with it \n } catch(runtime_error err){\n cout << err.what();\n } catch(){\n\n }\n
list bubu
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_18","title":"\u51fd\u6570","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_19","title":"\u53ef\u53d8\u53c2\u6570\u4f20\u9012","text":"initializer_list\u81ea\u5b9a\u4e49\u53ef\u53d8\u6a21\u677f\u7701\u7565\u7b26\u53f7\u5f62\u53c2\u5f62\u53c2\u6570\u91cf\u672a\u77e5\uff0c\u4f46\u7c7b\u578b\u76f8\u540c
initializer_list<int> lst{1, 2, 3};\nlst.size();\nlst.begin();\nlst.end();\n\nvoid error_msg(int type, initializer_list<string> il)\n{\n for (auto j : il)\n cout << j;\n cout << endl;\n}\nstring a = \"NO\";\nerror_msg(0, {\"Yes\", \" or \", a});\n
\u4fbf\u4e8eC++\u8bbf\u95ee\u90e8\u5206\u7279\u6b8a\u7684C\u4ee3\u7801\u8bbe\u7f6e\u7684\u3002\u7279\u522b\u7684\u662f\uff0c\u5927\u591a\u6570\u7c7b\u7c7b\u578b\u7684\u5bf9\u8c61\u5728\u4f20\u9012\u7ed9\u7701\u7565\u7b26\u5f62\u53c2\u65f6\u90fd\u65e0\u6cd5\u6b63\u5e38\u62f7\u8d1d\u3002
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_20","title":"\u8fd4\u56de\u503c","text":"void func(int a,...);\nvoid func(...);\n
\u5c3e\u7f6e\u8fd4\u56de\u7c7b\u578b
auto func(int i) -> int (*)[10]
a
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_21","title":"\u51fd\u6570\u91cd\u8f7d","text":"\u4e0d\u5141\u8bb8
- \u4e24\u4e2a\u9664\u4e86\u8fd4\u56de\u7c7b\u578b\u4e4b\u5916\u5b8c\u5168\u76f8\u540c\u7684\u51fd\u6570
- \u53c2\u6570\u4e2d,\u9876\u5c42const\u65e0\u6cd5\u533a\u5206\uff0c\u5e95\u5c42\u53ef\u4ee5(\u6bd4\u5982\u533a\u5206\u6307\u9488\u6216\u8005\u5f15\u7528\u6307\u5411\u7684\u662f\u5e38\u91cf\u5bf9\u8c61\u6216\u8005\u975e\u5e38\u91cf\u5bf9\u8c61)
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_22","title":"\u9ed8\u8ba4\u5b9e\u53c2","text":"// \u65e0\u6cd5\u533a\u5206\nint lookup(int);\nint lookup(const int);\n// \u53ef\u4ee5\u533a\u5206\nint lookup(int *);\nint lookup(const int *);\nint lookup(int &);\nint lookup(const int &);\n
Tips
\u6ce8\u610f\uff0c\u5bf9\u540c\u4e00\u51fd\u6570\u7684\u58f0\u660e\u53ef\u4ee5\u591a\u6b21\u8fdb\u884c\u3002
\u4f46\u662f\uff0c\u5728\u7ed9\u5b9a\u7684\u4f5c\u7528\u57df\u5185\uff0c\u4e00\u4e2a\u5f62\u53c2\u53ea\u80fd\u6709\u4e00\u4e2a\u9ed8\u8ba4\u53c2\u6570\uff1b\u540e\u7eed\u7684\u58f0\u660e\u53ea\u80fd\u7ed9\u4e4b\u524d\u6ca1\u6709\u9ed8\u8ba4\u5b9e\u53c2\u7684\u53c2\u6570\u6dfb\u52a0\u9ed8\u8ba4\u5b9e\u53c2\uff0c\u800c\u4e14\u8be5\u5b9e\u53c2\u53f3\u4fa7\u7684\u5f62\u53c2\u5fc5\u987b\u5177\u6709\u9ed8\u8ba4\u5b9e\u53c2\u3002
Exampletypedef string::size_type sz;\nstring sreen(sz ht,sz wid,char = '');\nstring sreen(sz = 100,sz = 80,char );\n
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_23","title":"\u51fd\u6570\u5339\u914d","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_24","title":"\u51fd\u6570\u6307\u9488","text":"void testFunc(int a = 10086)\n{\n cout << a << endl;\n return;\n}\nint m = 0;\nint main()\n{\n testFunc();\n // \u7528\u4e8e\u521d\u59cb\u5316\u9ed8\u8ba4\u5b9e\u53c2\u7684\u5982\u679c\u662f\u53d8\u91cf\uff0c\u4e0d\u80fd\u662f\u5c40\u90e8\u53d8\u91cf\n void testFunc(int = m);\n testFunc();\n return 0;\n}\n
using PF = int(*)(int *, int );\nusing F = int(int *, int );\nPF m;\n// \u58f0\u660e\u6307\u5411\u51fd\u6570\u7684\u6307\u9488\n// f1 \u8fd4\u56de\nPF f1(int);\nP * f2(int);\n // \u7531\u5185\u5411\u5916\u8bfb f3\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u8fd4\u56de\u503c\u4e3a\u6307\u9488\uff0c\u8fd9\u4e2a\u6307\u9488\u662f\u4e00\u4e2a\u51fd\u6570\u6307\u9488\nint (* f3(int))(int * , int);\nauto f4(int) -> int (*)(int * ,int);\n
\u51fd\u6570\u6307\u9488
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_25","title":"\u7c7b","text":"int ReturnNum(int *array, int index)\n{\n return array[index];\n}\nauto f4(int) -> int (*)(int *, int)\n{\n return ReturnNum;\n};\nint main()\n{\n int array[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};\n cout << f4(4)(array, 5);\n return 0;\n}\n
\u6982\u8ff0
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_26","title":"\u4ecb\u7ecd","text":"
- \u57fa\u672c\u4ecb\u7ecd
- \u6784\u9020\u51fd\u6570
- friend private public mutable
- \u9759\u6001\u6210\u5458
this
\u76f8\u5f53\u4e8e\u4e00\u4e2a\u5e38\u91cf\u6307\u9488\uff0c\u5b83\u662f\u9690\u5f0f\u5b9a\u4e49\u7684 !!! question \"Question\" \u5982\u4e0b\u56fe\uff0cthis\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e0d\u662f\u4e00\u4e2a\u6307\u9488\u5e38\u91cf\u5417\uff1f\u611f\u89c9\u524d\u540e\u8bf4\u6cd5\u6709\u4e9b\u77db\u76fe- ``
e.g.
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_27","title":"\u6784\u9020\u51fd\u6570","text":"// \u5e38\u91cf\u6210\u5458\u51fd\u6570\uff0c\u5173\u952e\u5728\u7406\u89e3const\nstd::string isbn() const{return bookNo;}\n// \u5728\u7c7b\u5916\u90e8\u5b9a\u4e49\uff0c\u5fc5\u987b\u52a0\u4e0a\u6240\u5c5e\u7684\u7c7b\u540d\ndouble Sales_data::avg_price() const{\n if(units_sold)\n return revenue;\n}\n//\nstd::string bookNo;\n
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_28","title":"\u8bbf\u95ee\u63a7\u5236\u4e0e\u5c01\u88c5","text":"// \u7c7b\u7684\u5185\u90e8\nSales_data( ) = default;\nSales_data(const std::string &s) : bookNo(s) { }\n// \u7c7b\u7684\u5916\u90e8\nSales_data::Sales_data(std::istream &is)\n{\n // read will read a transaction from is into this object\n read(is, *this);\n}\n
abstract
example Sales_data.cppSales_data.h
- \u6211\u4eec\u4f7f\u7528private\u3001public\u3001protected\u8bbf\u95ee\u8bf4\u660e\u7b26\u52a0\u5f3a\u7c7b\u7684\u5c01\u88c5
- class \u548c struct\u7684\u552f\u4e00\u533a\u522b\u5728\u4e8e\u9ed8\u8ba4\u7684\u8bbf\u95ee\u6743\u9650: \u7c7b\u53ef\u4ee5\u5728\u7b2c\u4e00\u4e2a\u8bbf\u95ee\u8bf4\u660e\u7b26\u4e4b\u524d\u5b9a\u4e49\u6210\u5458\uff0cstruct\u5219\u9ed8\u8ba4\u4e3apublic\uff0cclass\u9ed8\u8ba4\u4e3aprivate
- friend \u5141\u8bb8\u5176\u4ed6\u7c7b\u6216\u8005\u51fd\u6570\u8bbf\u95ee private \u6210\u5458\uff08\u5728\u7c7b\u5916\u5b9a\u4e49\u4e00\u4e9b\u63a5\u53e3\uff09
#include <iostream>\nusing std::istream;\nusing std::ostream;\n\n#include \"Sales_data.h\"\nSales_data::Sales_data(std::istream &is)\n{\n // read will read a transaction from is into this object\n read(is, *this);\n}\n\ndouble\nSales_data::avg_price() const\n{\n if (units_sold)\n return revenue / units_sold;\n else\n return 0;\n}\n\n// add the value of the given Sales_data into this object\nSales_data &\nSales_data::combine(const Sales_data &rhs)\n{\n units_sold += rhs.units_sold; // add the members of rhs into\n revenue += rhs.revenue; // the members of ``this'' object\n return *this; // return the object on which the function was called\n}\n\nSales_data\nadd(const Sales_data &lhs, const Sales_data &rhs)\n{\n Sales_data sum = lhs; // copy data members from lhs into sum\n sum.combine(rhs); // add data members from rhs into sum\n return sum;\n}\n\n// transactions contain ISBN, number of copies sold, and sales price\nistream &\nread(istream &is, Sales_data &item)\n{\n double price = 0;\n is >> item.bookNo >> item.units_sold >> price;\n item.revenue = price * item.units_sold;\n return is;\n}\n\nostream &\nprint(ostream &os, const Sales_data &item)\n{\n os << item.isbn() << \" \" << item.units_sold << \" \"\n << item.revenue << \" \" << item.avg_price();\n return os;\n}\n
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_29","title":"\u5176\u4ed6\u7279\u6027","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_30","title":"\u53ef\u53d8\u6570\u636e\u6210\u5458","text":"#ifndef SALES_DATA_H\n#define SALES_DATA_H\n\n#include \"Version_test.h\"\n\n#include <string>\n#include <iostream>\n\nclass Sales_data {\nfriend Sales_data add(const Sales_data&, const Sales_data&);\nfriend std::ostream &print(std::ostream&, const Sales_data&);\nfriend std::istream &read(std::istream&, Sales_data&);\npublic:\n // constructors\n// using the synthesized version is safe only\n// if we can also use in-class initializers\n#if defined(IN_CLASS_INITS) && defined(DEFAULT_FCNS)\n Sales_data() = default;\n#else\n Sales_data(): units_sold(0), revenue(0.0) { }\n#endif\n#ifdef IN_CLASS_INITS\n Sales_data(const std::string &s): bookNo(s) { }\n#else\n Sales_data(const std::string &s): \n bookNo(s), units_sold(0), revenue(0.0) { }\n#endif\n Sales_data(const std::string &s, unsigned n, double p):\n bookNo(s), units_sold(n), revenue(p*n) { }\n Sales_data(std::istream &);\n\n // operations on Sales_data objects\n std::string isbn() const { return bookNo; }\n Sales_data& combine(const Sales_data&);\n double avg_price() const;\nprivate:\n std::string bookNo;\n#ifdef IN_CLASS_INITS // using the synthesized version is safe only\n unsigned units_sold = 0;\n double revenue = 0.0;\n#else\n unsigned units_sold;\n double revenue;\n#endif\n};\n\n// nonmember Sales_data interface functions\nSales_data add(const Sales_data&, const Sales_data&);\nstd::ostream &print(std::ostream&, const Sales_data&);\nstd::istream &read(std::istream&, Sales_data&);\n\n// used in future chapters\ninline \nbool compareIsbn(const Sales_data &lhs, const Sales_data &rhs)\n{\n return lhs.isbn() < rhs.isbn();\n}\n#endif\n
mutable
\u4f7f\u5f97const func\u4e5f\u80fd\u591f\u6539\u53d8\u5176\u503c Mutable\u7c7b\u5185\u521d\u59cb\u503cpublic:\n //\nprivate:\n mutable size_t count;\n
\u8fd4\u56de *thisclass Window_mgr{\n private:\n std::vector<Screen> sreens{Screen(24,80,'')};\n};\n
// \u5982\u679c\u51fd\u6570\u4e3aconst\u7c7b\u578b\uff0c\u8fd4\u56de\u7684\u5f15\u7528\u4e3aconst type &; \ninline Screen &Screen::Display const(){}\ninline Screen &Screen::set(char c)\n{\n contents[cursor] = c;\n return *this;\n}\n
Friend
- \u53ef\u4ee5\u5c06\u53e6\u5916\u4e00\u4e2a\u7c7b\u6307\u5b9a\u4e3a\u672c\u7c7b\u7684friend \u53cb\u5143\u5173\u7cfb\u4e0d\u5b58\u5728\u4f20\u9012\u6027
\u6211\u7684\u5974\u96b6\u7684\u5974\u96b6\u4e0d\u662f\u6211\u7684\u5974\u96b6
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_31","title":"\u9690\u5f0f\u8f6c\u6362","text":"
- \u4ee4\u6210\u5458\u51fd\u6570\u4e3afriend\uff0c\u800c\u4e0d\u662f\u4ee4\u53e6\u5916\u4e00\u6574\u4e2a\u7c7b\u53d8\u6210\u53cb\u5143
class Screen{\n friend void Window_mgr::clear(ScreenIndex);\n}\n
\u901a\u8fc7\u4e00\u4e2a\u5b9e\u53c2\u8c03\u7528\u7684\u6784\u9020\u51fd\u6570\u5b9a\u4e49\u4e00\u6761\u4ece\u6784\u9020\u51fd\u6570\u7684\u53c2\u6570\u7c7b\u578b\u5411\u7c7b\u7c7b\u578b\u8f6c\u6362\u7684\u89c4\u5219
\u9650\u5236
\u9690\u5f0f\u8f6c\u6362\u53ea\u5141\u8bb8\u6700\u591a\u4e00\u6b65
\u53ef\u4ee5\u4f7f\u7528
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_32","title":"\u9759\u6001\u6210\u5458","text":"explicit
\uff08\u53ea\u5141\u8bb8\u5728\u7c7b\u5185\u51fa\u73b0explicit Sales_data(std::istream &)
\uff09\u6765\u9650\u5236\u9690\u5f0f\u8f6c\u6362\uff08\u4f46\u662f\u4ecd\u7136\u53ef\u4ee5\u8fdb\u884c\u663e\u5f0f\u7684\u8f6c\u6362\uff09\u4e0e\u7c7b\u76f8\u5173\uff0c\u800c\u4e0d\u662f\u4e0e\u7c7b\u7684\u6210\u5458\u76f8\u5173\uff1b\u4e00\u65e6\u53d1\u751f\u6539\u53d8\uff0c\u6240\u6709\u7684\u6210\u5458\u5bf9\u8c61\u90fd\u80fd\u4f7f\u7528\u6539\u53d8\u540e\u7684\u503c
note
- \u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u9759\u6001\u6210\u5458\u5728\u7c7b\u7684\u5916\u90e8\u8fdb\u884c\u521d\u59cb\u5316\uff1b\u4f46\u5e38\u91cf\u8868\u8fbe\u5f0f\u60c5\u51b5\u662f\u4e00\u4e2a\u4f8b\u5916\uff0c
static constexpr int period = 30; double daily[period];
,\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u5728\u7c7b\u7684\u5916\u90e8\u5bf9\u5e38\u91cf\u9759\u6001\u6570\u636e\u6210\u5458\u8fdb\u884c\u5b9a\u4e49\uff0cconstexpr int Account::period;
- \u4e0e\u975e\u9759\u6001\u6210\u5458\u7684\u533a\u522b
class Bar{\npublic:\n1. \u53ef\u4ee5\u4f5c\u4e3a\u9ed8\u8ba4\u5b9e\u53c2\nScreen &clear(char = bkground)\nprivate:\n2. \u53ef\u4ee5\u4f7f\u7528\u4e0d\u5b8c\u5168\u7c7b\u578b\u5b9a\u4e49\nstatic Bar mem1;\nBar Wrong; // \u00d7\nstatic const char bkground;\n}\n
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/","title":"Algorithm","text":"// \u58f0\u660e\nclass Account {\npublic:\n static double rate() {return interestRate;}\n static void rate(double);\nprivate:\n std::string owner; \n double amount;\n static double interestRate; \n static double initRate() { return .0225; }\n static const std::string accountType;\n}\n// \u4f7f\u7528\ndouble r = Account::rate();\nAccount ac1;\nAccount &ac2;\nac1.rate(); \nac2->rate();\n\n// \u5b9a\u4e49\nvoid Account::rate(double newRate) # (1)\n{\n interestRate = newRate;\n}\n
\u7ea6 316 \u4e2a\u5b57 13 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
Abstract
\u6807\u51c6\u5e93\u63d0\u4f9b\u4e86\u4e00\u7ec4\u7b97\u6cd5\uff0c\u5927\u591a\u6570\u90fd\u72ec\u7acb\u4e8e\u5bb9\u5668\u5b58\u5728\u3002 referrence
Short Video
\u591a\u6570\u7b97\u6cd5\u5728
algorithm
\u6587\u4ef6\u4e2d\u63d0\u4f9b:
- find
\u8fd8\u6709\u4e00\u90e8\u5206\u5728
numeric
\u4e2d:\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7b97\u6cd5\u5e93\u4e2d\u7684\u7b97\u6cd5\u64cd\u4f5c\u7684\u5bf9\u8c61\u90fd\u662f\u8fed\u4ee3\u5668\u800c\u975e\u5bb9\u5668\u672c\u8eab\u3002
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#-accumulate","title":"- accumulate","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#_1","title":"\u7f57\u5217","text":"\u6ce8\u610f
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#find","title":"find","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#accumulate","title":"accumulate","text":"
- \u5bf9\u4e8e\u63a5\u53d7\u5355\u4e00\u8fed\u4ee3\u5668\u8868\u793a\u7b2c\u4e8c\u4e2a\u5bb9\u5668\u7684\u7b97\u6cd5\uff0c\u9ed8\u8ba4\u540e\u4e00\u4e2a\u5bb9\u5668\u957f\u5ea6\u5927\u4e8e\u7b49\u4e8e\u7b2c\u4e00\u4e2a
- \u4e0b\u9762\u7684\u53c2\u6570\u4e3a\u8fed\u4ee3\u5668\u5373\u53ef\uff0c\u4e0d\u4e00\u5b9a\u662fbegin(),end()
numeric
accumulate(vec.begin(),vec.end(),element);
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#equal","title":"equal","text":"
- \u7b2c\u4e09\u4e2a\u53c2\u6570\u51b3\u5b9a\u4e86\u4f7f\u7528\u7684\u52a0\u6cd5\u8fd0\u7b97\u7b26\u548c\u8fd4\u56de\u503c\u7684\u7c7b\u578b\uff0c\u540c\u65f6\u52a0\u6cd5\u4e5f\u662f\u5728 element \u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u64cd\u4f5c
- \u8981\u6ce8\u610f\u662f\u5426\u53ef\u52a0
equal(vec.begin(),vec.end(),vec2.begin());
\u8981\u786e\u4fdd\u7b2c\u4e8c\u4e2a\u5e8f\u5217\u7684\u957f\u5ea6>=\u7b2c\u4e00\u4e2a
\u4e14\u6240\u6709\u7b2c\u4e8c\u4e2a\u5bb9\u5668\u53ea\u7528\u4e00\u4e2a\u8fed\u4ee3\u5668\u8868\u793a\u7684\u7b97\u6cd5\u90fd\u9ed8\u8ba4\u8fd9\u4e00\u6761\u89c4\u5219
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#fill","title":"fill","text":"\u5199\u64cd\u4f5c
warning
writing\u64cd\u4f5c\u9ed8\u8ba4\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u5bb9\u7eb3\u5199\u7684\u5143\u7d20
\u4e00\u4e2a\u5f88\u5178\u578b\u7684\u9519\u8bef\u662f\u5411\u7a7a\u5bb9\u5668\u5199\u5165\u503c
\u4e3a\u4e86\u4fdd\u8bc1\u5728\u5199\u5165\u5143\u7d20\u65f6\u5b58\u5728\u8db3\u591f\u7684\u7a7a\u95f4\uff0c\u53ef\u4ee5\u4f7f\u7528
back_inserter
vector<int> a;\n fill_n(back_inserter(a), 10, 0);\n
fill(begin,end,element);
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#copy","title":"copy","text":"
fill_n(iter,n,element)
copy
auto b = copy(a.begin(), a.begin() + 5, back_inserter(c));\ncopy(a.begin(), a.begin() + 1, b);\n
copy_if
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#_2","title":"\u91cd\u6392","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#unique","title":"unique","text":"std::copy_if(from_vector.begin(), from_vector.end(),\n std::back_inserter(to_vector),\n [](int x) { return x % 3 == 0; });\n
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#sort","title":"sort","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#_3","title":"\u5b9a\u5236\u64cd\u4f5c","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/IO/","title":"IO\u5e93","text":"auto b = unique(a.begin(), a.end());\nPrint(a);\n// unique \u7b97\u6cd5\u64cd\u4f5c\u7684\u662f\u8fed\u4ee3\u5668\uff0c\u4e3a\u4e86\u5220\u9664\u5143\u7d20\uff0c\u53ea\u80fd\u4f7f\u7528\u5bb9\u5668\u64cd\u4f5c\na.erase(b, a.end());\nPrint(a);\n
\u7ea6 148 \u4e2a\u5b57 138 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#io","title":"IO\u7c7b","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#_1","title":"\u6761\u4ef6\u72b6\u6001","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#_2","title":"\u6d41\u7684\u72b6\u6001","text":"
- IO\u5bf9\u8c61\u65e0\u8d4b\u503c\u65e0\u62f7\u8d1d
iostate
\u7c7b\u578b
- \u53ef\u4ee5\u5229\u7528
good() fail()
\u5224\u65ad\u6574\u4f53\u6d41\u7684\u72b6\u6001State Of I/O
"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#_3","title":"\u7ba1\u7406\u7f13\u51b2","text":"// cin\u4f1a\u8fd4\u56de\u4e00\u4e2acin\uff0c\u5e76\u53bb\u68c0\u6d4bstream\u662f\u5426\u505a\u597d\u4e86\u51c6\u5907(Test)\nvector<int> read_ints(istream& is)\n{\nvector<int> res;\nint i;\nwhile (is>>i)\nres.push_back(i);\nreturn res;\n}\n\n//\nwhile (cin)\n{\n for (int i; cin >> i;)\n {\n // ... use the integer ...\n }\n if (cin.eof())\n {\n // .. all is well we reached the end-of-file ...\n }\n else if (cin.fail())\n { // a potentially recoverable error\n cin.clear(); // reset the state to good()\n char ch;\n if (cin >> ch)\n { // look for nesting represented by { ... }\n switch (ch)\n {\n case '{':\n // ... start nested structure ...\n break;\n case '}':\n // ... end nested structure ...\n break;\n default:\n cin.setstate(ios_base::failbit); // add fail() to cin\u2019s state\n }\n }\n }\n // ...\n}\n
\u5237\u65b0\u7f13\u51b2\u7684\u539f\u56e0
\u64cd\u7eb5\u7b26
cout << unitbuf; // \u6240\u6709cout\u64cd\u4f5c\u4e4b\u540e\u90fd\u5237\u65b0buffer\ncout << nounitbuf;\n
\u6d41\u7684\u5173\u8054\u64cd\u4f5c
"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#file","title":"File","text":"cin.tie(&cout);\n// old_tie\u6307\u5411\u7684\u662fcin\u7684\u5173\u8054\u6d41\uff1b\u8f6c\u5316\u540e\uff0ccin\u4e0d\u518d\u5173\u8054\nostream *old_tie = cin.tie(nullptr);\ncin.tie(&cerr);\ncin.tie(old_tie);\n
"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#_4","title":"\u6587\u4ef6\u6a21\u5f0f","text":"ifstream in; // read a file\nofstream out; // writing a file\nstring filename(\"CppLearning\");\nin.open(filename + \".md\");\nif (in)\n{ //...\n}\nin.close();\n
\"../Stadard_Library/\u5173\u8054\u5bb9\u5668.md\"
\u6ce8\u610f
\u4ee5
out
\u65b9\u5f0f\u6253\u5f00\u6587\u4ef6\uff0c\u9ed8\u8ba4\u4f1a\u8986\u76d6"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#string","title":"String","text":"ofstream out(\"filename\",mode);\nofstream out(\"filename\",ofstream::app | ofstream::out);\n
Example
\u4f7f\u7528
istringstream
\u8bfb\u53d6\uff0costringstream\u8f93\u5165 \u4f7f\u7528ostringstream
\u53ef\u4ee5\u5728\u9002\u5f53\u7684\u65f6\u673a\u8f93\u51fa\u6240\u6709\u503c istringstreamstring str, line;\nvector<PersonInfo> People;\nwhile (getline(cin, line))\n{\n PersonInfo Person;\n string name, numbers;\n istringstream iStr(line);\n iStr >> name;\n Person.name = name;\n while (iStr >> numbers)\n {\n Person.Phones.push_back(numbers);\n }\n People.push_back(Person);\n}\n// print\nfor (auto person : People)\n{\n cout << \"name:\" << person.name << endl;\n cout << \"phones:\" << endl;\n for (auto phone : person.Phones)\n cout << phone << endl;\n}\n
"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#user-defined","title":"User-defined","text":"
getline
\u4f8b\u7a0b
is.get(c)
\u51fd\u6570\u4e0d\u4f1a\u8df3\u8fc7 Space"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#formatting","title":"Formatting","text":"#include <iostream>\n#include <vector>\n#include <string>\n\nusing namespace std;\n\nstruct Entry\n{\n string name;\n int number;\n};\n\nostream &operator<<(ostream &os, const Entry &e)\n{\n return os << \"{\\\"\" << e.name << \"\\\", \" << e.number << \"}\";\n}\nistream &operator>>(istream &is, Entry &e)\n// read { \"name\" , number } pair. Note: for matted with { \" \" , and }\n{\n char c, c2;\n if (is >> c && c == '{' && is >> c2 && c2 == '\"')\n { // star t with a { \"\n string name; // the default value of a string is the empty string: \"\"\n while (is.get(c) && c != '\"') // anything before a \" is part of the name\n name += c;\n if (is >> c && c == ',')\n {\n int number = 0;\n if (is >> number >> c && c == '}')\n { // read the number and a }\n e = {name, number}; // assign to the entry\n return is;\n }\n }\n }\n return is;\n}\n\nint main()\n{\n Entry test;\n cin >> test;\n cout << test;\n}\n
, ,, and
\u7cbe\u5ea6\u63a7\u5236
constexpr double d = 123.456;\ncout << d << \"; \" // use the default for mat for d\n<< scientific << d << \"; \" // use 1.123e2 style for mat for d\n<< hexfloat << d << \"; \" // use hexadecimal notation for d\n<< fixed << d << \"; \" // use 123.456 style for mat for f\n<< defaultfloat << d << '\\n'; // use the default for mat for d\n\ncout.percision(8);\ncout << 1234.56789 << ' ' << 1234.56789 << ' ' << 123456 << '\\n';\n\n>>> 1234.5679 1234.5679 123456\n
\u5bbd\u5ea6\u63a7\u5236
"},{"location":"CodingLanguage/CPP/Stadard_Library/string/","title":"String","text":"\u7ea6 11 \u4e2a\u5b57 13 \u884c\u4ee3\u7801
INFO
"},{"location":"CodingLanguage/CPP/Stadard_Library/string/#_1","title":"\u5b57\u7b26\u4e32\u5206\u5272","text":"
- \u603b\u7ed3Blog
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/","title":"\u52a8\u6001\u5185\u5b58","text":"/*\ns = \"2024-1-2\"\n*/\nDate AnalyDate(string s)\n{\n stringstream ss(s);\n string line;\n vector<string> lines;\n while (getline(ss, line, '-'))\n lines.push_back(line);\n Date date;\n date.SetDate(stoi(lines[0]), stoi(lines[1]), stoi(lines[2]));\n}\n
\u7ea6 435 \u4e2a\u5b57 21 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
INFO
\u9664\u4e86\u9759\u6001\u5185\u5b58\u548c\u6808\u5185\u5b58\uff0c\u6bcf\u4e2a\u7a0b\u5e8f\u8fd8\u4f1a\u6709\u4e00\u4e2a\u5185\u5b58\u6c60\uff0c\u7528\u6765\u5b58\u50a8\u5728\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u521b\u5efa\u7684\u53d8\u91cf
- \u4e3a\u4ec0\u4e48\u4f7f\u7528\u52a8\u6001\u5185\u5b58\uff1f
- \u8981\u4f7f\u7528\u7684\u5927\u5c0f\u672a\u77e5
- \u8981\u4f7f\u7528\u7684\u7c7b\u578b\u672a\u77e5
- \u9700\u8981\u5728\u591a\u4e2a\u7a0b\u5e8f\u95f4\u5171\u4eab\u53d8\u91cf
- \u5728\u67d0\u4e2a\u4f5c\u7528\u57df\u4e0b\u5b9a\u4e49\u4e00\u4e2a\u52a8\u6001\u6307\u9488\uff0c\u4e4b\u540e\u8fd9\u4e2a\u6307\u9488\u88ab\u9500\u6bc1\uff0c\u4f46\u7533\u8bf7\u7684\u5185\u5b58\u8fd8\u5728
The diffence between malloc and new
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/#delete","title":"delete","text":"
delete
\u548cfree
\u51e0\u4e4e\u540c\u7406 - \u5728\u5185\u5b58\u4e2d\uff0cnew\u548cdelete\u7533\u8bf7\u7684 Space \u533a\u57df\u4e5f\u4e0d\u5b8c\u5168\u76f8\u540c. new \u4f4d\u4e8e free store \u533a\uff08\u4e5f\u6709\u8bf4\u6cd5\u662f\u5dee\u522b\u4e0d\u5927\uff09warning
\u4f7f\u7528\u52a8\u6001\u5185\u5b58\u7684\u65f6\u5019\uff0c\u4e00\u5b9a\u8981\u6ce8\u610f\u5185\u5b58\u7ba1\u7406\uff1b\u4f7f\u7528delete\u7684\u65f6\u5019\uff0c\u4e00\u5b9a\u8981\u6ce8\u610f\u91ca\u653e\u7684\u662fsingle var\u8fd8\u662f\u6570\u7ec4
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/#_2","title":"\u667a\u80fd\u6307\u9488","text":"delete single;\ndelete[] Array;\n
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/#make_shared","title":"make_shared","text":"
shared_ptr
shared_ptr p = make_shared<typename>()
unique_ptr
weak_ptr
TIPS
- \u4e0d\u4f7f\u7528\u591a\u4e2a\u667a\u80fd\u6307\u9488\u6307\u5411\u540c\u4e00\u4e2a\"\u5e95\u5c42\u7684\"(\u521d\u59cb\u7684)\u6307\u9488
- \u6bd4\u5982 p.get()\u8fd4\u56de\u7684\u6307\u9488\u5c31\u662f\u4e00\u4e2a\"\u5e95\u5c42\u7684\"
- \u6216\u8005reset
- \u5982\u679c\u4f7f\u7528\u667a\u80fd\u6307\u9488\u7ba1\u7406\u7684\u5185\u5b58\u4e0d\u662fnew\u6765\u7684\uff0c\u8981\u7ed9\u5b83\u4e00\u4e2a\u5220\u9664\u5668
make_shared \u51fd\u6570
\u53ef\u9009\u7684 \u5220\u9664\u51fd\u6570\u53c2\u6570auto a = make_shared<int>();\nauto a = make_shared<int>(5);\n
delete\u7684\u65f6\u5019\u8c03\u7528\u6790\u6784\u51fd\u6570\uff0c\u53ef\u4ee5\u7531user\u6307\u5b9a
shared_ptr<> a(val,func)
shared_ptr
shared_ptr\u53ef\u4ee5\u901a\u8fc7\u67d0\u79cd\u529e\u6cd5\u8bb0\u5f55\u5171\u4eab\u5bf9\u8c61\u7684\u6307\u9488\uff08\u4e00\u4e2a\u8ba1\u6570\u5668\uff09\uff0c\u5728count==0\u65f6\uff0c\u5c31\u4f1a\u81ea\u52a8\u91ca\u653e\u5185\u5b58
\u6240\u4ee5
shared_ptr
\u652f\u6301p.unique(),p.ues_count()
\u51fd\u6570"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/#unique_ptr","title":"unique_ptr","text":"p.reset(q) // \u5c06p\u91cd\u65b0\u7ed1\u5b9a\u5230q\n\n// \u6539\u53d8\u5e95\u5c42\u5bf9\u8c61\u4e4b\u524d\uff0c\u68c0\u6d4b\u81ea\u5df1\u662f\u5426\u662f\u552f\u4e00\u7684\nif(!p.unique())\n p.reset(new string(*p));\np.val = newVal;\n
NOTES
\u4e00\u822c\u60c5\u51b5\u4e0b\uff0cunique_ptr\u4e0d\u5141\u8bb8\u62f7\u8d1d\u3002
\u4f46\u662f\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u2014\u2014\u7f16\u8bd1\u5668\u77e5\u9053\u8fd9\u91cc\u7684unique_ptr\u5c06\u8981\u88ab\u9500\u6bc1\u3002
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/#weak_ptr","title":"weak_ptr","text":"unique_ptr<int> clone(int p)\n{\n return unique_ptr<int>(new int(p));\n}\nunique_ptr<int> clone(int p)\n{\n rst = unique_ptr<int>(new int(p));\n return rst;\n}\n
\u6307\u5411 shared_ptr \uff0c\u4f46\u5e76\u4e0d\u589e\u52a0\u5176\u8ba1\u6570\uff1b\u9500\u6bc1\u65f6\u540c\u65f6\u9500\u6bc1
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/","title":"\u5bb9\u5668","text":"weak_ptr<T> a;\n
\u7ea6 382 \u4e2a\u5b57 100 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
Abstract
\u4e00\u4e2a\u5bb9\u5668\u662f\u4e00\u4e9b\u7279\u5b9a\u7c7b\u578b\u5bf9\u8c61\u7684\u96c6\u5408\u3002 \u6240\u6709\u5bb9\u5668\u7c7b\u90fd\u5171\u4eab\u516c\u5171\u7684\u63a5\u53e3\uff0c\u4e0d\u5bb9\u7684\u5bb9\u5668\u6309\u7167\u4e0d\u540c\u7684\u65b9\u5f0f\u8fdb\u884c\u62d3\u5c55\u3002 \u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u8303\u56f4 range(a,b) \u6307\u7684\u662f[a,b)
- \u5bb9\u5668\u64cd\u4f5c
- \u987a\u5e8f\u5bb9\u5668
- vector
- deque \u53cc\u5411
- list \u53cc\u5411\u94fe\u8868
- forward_list
- array (static)
- \u5173\u8054\u5bb9\u5668
- set
- multiset
- map
- multimap
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#_1","title":"\u57fa\u672c\u64cd\u4f5c","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#_2","title":"\u5b9a\u4e49 \u521d\u59cb\u5316","text":"
- \u7c7b\u578b
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#swap","title":"\u8d4b\u503c\u4e0eswap","text":"// \u8fd4\u56de\u53cd\u5411\u5bb9\u5668\nreverse_iterator\nconst_reverse_iterator\nc.rbegin() c.rend()\n\n// \u6784\u9020\u8d4b\u503c\nType c;\nType c1 = c2;\nType c(n,val);\nType c1(c2);\n
c1 = c2;\nc = {a,b,c};\nswap(c1,c2);\nc1.swap(c2);\nseq.assign(b,e); // b,e\u6307\u5411\u7684\u4e0d\u80fd\u662fseq\u4e2d\u7684\nseq.assign(initialList);\nseq.assign(n,val);\n
\u9664\u4e86\u6570\u7ec4\u4e4b\u5916\uff0cSwap\u64cd\u4f5c\u4e0d\u5bf9\u6570\u636e\u8fdb\u884c\u62f7\u8d1d\u3001\u5220\u9664\u3001\u63d2\u5165\uff0c\u53ef\u4ee5\u5728\u5e38\u6570\u65f6\u95f4\u5185\u5b8c\u6210
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#_3","title":"\u987a\u5e8f\u5bb9\u5668","text":"\u987a\u5e8f\u5bb9\u5668\u4e2d\u7684\u5143\u7d20\u6309\u7167\u4e25\u683c\u7684\u7ebf\u6027\u987a\u5e8f\u6392\u5e8f\u3002\u53ef\u4ee5\u901a\u8fc7\u5143\u7d20\u5728\u5e8f\u5217\u4e2d\u7684\u4f4d\u7f6e\u8bbf\u95ee\u5bf9\u5e94\u7684\u5143\u7d20\u3002
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#_4","title":"\u64cd\u4f5c","text":"**\u4ee5\u4e0b\u7684\u64cd\u4f5c\u4e0d\u4e00\u5b9a\u5bf9\u6240\u6709\u7684\u987a\u5e8f\u5bb9\u5668\u751f\u6548**\n// \u6dfb\u52a0\u5143\u7d20\nc.push_back(t);\nc.push_front(t);\nc.emplace_front(args);\nc.emplace_back(args);\n //\u8fd4\u56de\u7b2c\u4e00\u4e2a\u65b0\u52a0\u5165\u5143\u7d20\u7684\u8fed\u4ee3\u5668\nc.insert(position,n,val); // position \u4e3a \u8fed\u4ee3\u5668\nc.insert(position,begin,end);\nc.insert(position,initialList);\n\n// \u4f4d\u7f6e\nc.at(n);\n// \u5220\u9664\nc.pop_back();\nc.pop_front();\nc.erase(position);\nc.erase(b,e);\n// \u6539\u53d8\u5927\u5c0f\nc.resize(n,optional::val);\n// \u5bb9\u91cf\u5927\u5c0f\nc.capacity();\nc.size();\nc.shrink_to_fit();\nc.reserve(n);\n
\u6dfb\u52a0\u5143\u7d20
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#forward_list","title":"forward_list","text":"
- emplace\u4e0epush\u3001insert\u7684\u4e0d\u540c\u5728\u4e8e\uff0cemplace\u662f\u901a\u8fc7\u5143\u7d20\u7684\u6784\u9020\u51fd\u6570\u76f4\u63a5\u6784\u9020\u4e00\u4e2a\u65b0\u7684\u5143\u7d20\uff1b\u800c\u53e6\u5916\u4e24\u8005\u662f\u62f7\u8d1d\u7684\u65b9\u5f0f
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#string","title":"String","text":"flits.before_begin();\nflits.insert_after(...);\nemplace_after(iter_position,args);\nflits.erase_after(position);\nflits.erase_after(b,e);\n
// \u6784\u9020\u51fd\u6570\nstring s1(cp,n); // cp[n]\u4e4b\u524d\nstring s2(str,pos); // str[pos]\u4e4b\u540e\nstring s3(str,pos,len);\n// \ns.substr(pos,n); // position n\u4e2a\n\n// \u63d2\u5165 char / string\ns.insert(nth,\"\");\ns.append(\"\");\ns.replace();\n
\u641c\u7d22\u64cd\u4f5c
\u6ce8\u610f\uff0cfind()\u51fd\u6570\u7684\u8fd4\u56de\u503c\u662f
unsigned
\u7c7b\u578b\uff0cstring::size_type npos = -1;
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#adaptor","title":"\u9002\u914d\u5668 | adaptor","text":"// \u5168\u5339\u914d\ns.find();\ns.rfind(); // \u6700\u540e\u4e00\u6b21\u51fa\u73b0\n// \u90e8\u5206\u5339\u914d\ns.find_first_of();\ns.find_first_not_of();\ns.find_last_of();\ns.find_last_not_of();\n// example\ncout << a.find(); // Not Found: 18446744073709551615\nstring str = \"he is not here\";\ncout << str.find(\"he\") << endl;\ncout << str.substr(str.find(\"he\"), sizeof(\"he\"));\n// example \u9009\u62e9\u5339\u914d\nstring str = \"11h23e55 i4456s88 n77o97t here!\";\nstring numbers(\"0123456789\");\nstring result(\"\");\nstring::size_type pos = 0;\nwhile ((pos = str.find_first_not_of(numbers, pos)) != string::npos)\n{\n result.push_back(str[pos]);\n pos++;\n}\ncout << result;\n
\u9002\u914d\u5668\u53ef\u4ee5\u5c06\u4e00\u4e2a\u7c7b\u7684\u63a5\u53e3\u8f6c\u5316\u4e3a\u53e6\u5916\u4e00\u4e2a\u7c7b\u7684\u63a5\u53e3\u3002 \u901a\u8fc7\u5305\u88c5\u4e00\u4e2a\u5e95\u5c42\u7684\u7c7b\uff0c\u5bf9\u5176\u63a5\u53e3\u8fdb\u884c\u4e8c\u6b21\u5904\u7406\uff0c\u5448\u73b0\u51fa\u4e00\u79cd\u65b0\u7684\u5f62\u5f0f \u4e00\u822c\u60c5\u51b5\u4e0b\uff0c
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#_5","title":"\u5173\u8054\u5bb9\u5668","text":"stack
queue
\u57fa\u4e8edequeue
\u5b9e\u73b0\uff0cpriority_queue
\u57fa\u4e8evector\u5b9e\u73b0\uff08\u4e5f\u53ef\u4ee5\u901a\u8fc7\u91cd\u8f7d\u6539\u53d8\uff0c\u4f46\u9700\u8981\u6ee1\u8db3\u9002\u914d\u5668\u7684\u7279\u6027\uff09 \u5982stack<string, vector<string>> str_stk;
\u6ce8\u610f
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#map","title":"map","text":"
- \u4f7f\u7528\u5173\u8054\u5bb9\u5668\u7684
find
\u6bd4\u6cdb\u578b\u7b97\u6cd5\u7684find
\u66f4\u52a0\u9ad8\u6548"},{"location":"CodingLanguage/CPP/cake/assert/","title":"Assert","text":"map< <type>,<type> >\n\nmap<string,int> M {{},{}};\n// map \u4e2d\u7684\u5143\u7d20\u662f pair \u7c7b\u578b\nmap.first();\nmap.second();\n// \u5bf9\u4e8e\u5355\u4e00\u7684 insert \u64cd\u4f5c\uff0c\u8fd4\u56de\u4e00\u4e2apair\u7c7b\u578b\uff0c\u7b2c\u4e00\u4e2a\u503c\u662f\u8fed\u4ee3\u5668\uff0c\u7b2c\u4e8c\u4e2a\u503c\u662fbool\u8868\u5f81\u6210\u529f\u4e0e\u5426\nM.insert({word, 1});\nM.insert(make_pair(word, 1));\nM.insert(pair<string, int>(word, 1));\nM.insert(map<string, int>());\n// \u5bf9map\u7684\u8bbf\u95ee\nM[]; // \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u76f4\u63a5\u4e0b\u6807\u8bbf\u95ee\u5982\u679c\u672a\u67e5\u8be2\u5230\u5c06\u4f1ainsert\uff0c\u800cat()\u8bbf\u95ee\u8fd4\u56de\u5c3e\u540e\u6307\u9488\nM.at();\n// new feature\nM.try_emplace()\nM.merge()\n
\u7ea6 60 \u4e2a\u5b57 15 \u884c\u4ee3\u7801
Ref
Geeks
Assert \u66f4\u7ecf\u5e38\u7528\u4e8e\u4e00\u4e9b\u5e95\u5c42\u7684\u68c0\u67e5\u3001Debug\u8fc7\u7a0b\u4e2d\uff0c\u800c\u5f02\u5e38\u68c0\u6d4b\u5e38\u5e38\u662f\u5728\u4e00\u4e9b\u63a5\u53e3\u8c03\u7528\u65f6\u7531\u4e0a\u5c42\u5224\u65ad
assert\u53ef\u4ee5\u5173\u95ed
"},{"location":"CodingLanguage/CPP/cake/assert/#_1","title":"\u5355\u5143\u6d4b\u8bd5","text":"// The below program runs fine because NDEBUG is defined\n# define NDEBUG\n# include <assert.h>\n\nint main()\n{\n int x = 7;\n assert (x==5);\n return 0;\n}\n
\u4e0b\u9762\u8fd9\u4e00\u6bb5\u4ee5gtest\u4e3a\u4f8b
"},{"location":"CodingLanguage/CPP/classes/","title":"Index","text":"#include \"gtest/gtest.h\"\nvoid CheckTxnLockSize(Txn &txn, size_t shared_expected, size_t exclusive_expected) {\n ASSERT_EQ(shared_expected, txn.GetSharedLockSet().size());\n ASSERT_EQ(exclusive_expected, txn.GetExclusiveLockSet().size());\n}\n
\u7ea6 0 \u4e2a\u5b57
"},{"location":"CodingLanguage/CPP/classes/Copy/","title":"Copy Control","text":"\u7ea6 256 \u4e2a\u5b57 77 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
Copy
- \u51fd\u6570\u4f20\u53c2\u6570
"},{"location":"CodingLanguage/CPP/classes/Copy/#_1","title":"\u62f7\u8d1d\u6784\u9020\u51fd\u6570","text":"class A\n{\npublic:\n A(int i) : mi(i) {}\n A(const A &rhs) : mi(rhs.mi)\n {\n cout << \"A::A(&)\" << endl;\n }\n virtual void f()\n {\n cout << \"A::f(), \" << mi << endl;\n }\nprotected:\n int mi;\n};\n
- \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u7f16\u8bd1\u5668\u4f1a\u6709\u4e00\u4e2a
- \u539f\u751f\u7c7b\u578b\u503c\u62f7\u8d1d
- class\u8c03\u7528\u5176\u62f7\u8d1d\u51fd\u6570
- \u4f46\u662f\u5bf9\u4e8e\u6307\u9488\u800c\u8a00\uff0c\u5b83\u4e5f\u662f\u503c\u62f7\u8d1d\uff0c\u5bfc\u81f4\u6709\u4e24\u4e2a\u6307\u9488\u6307\u5411\u540c\u4e00\u4e2a\u5143\u7d20\u3002\u8fd9\u5bfc\u81f4\u5b83\u7684\u7ba1\u7406\u4e0d\u660e\u786e\uff0c\u53ef\u80fd\u5bf9\u540c\u4e00\u5757\u5730\u5740\u8fdb\u884c\u4e24\u6b21\u751a\u81f3\u591a\u6b21
delete
.\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8981\u5bf9\u6790\u6784\u51fd\u6570\u3001\u62f7\u8d1d\u6784\u9020\u51fd\u6570\u8fdb\u884c\u5b9a\u4e49Why const and why &
- const: \u4e0d\u80fd\u6539\u53d8
- \u5f15\u7528: \u4e0d\u7136\u4f20\u53c2\u6570\u7684\u65f6\u5019\u53d1\u751f\u503c\u4f20\u9012\uff0c\u53c8\u8981\u8c03\u7528\u62f7\u8d1d\u51fd\u6570\uff0c\u9677\u5165\u6b7b\u5faa\u73af
\u5b9a\u4e49\u90e8\u5206A(const A &rhs) : mi(rhs.mi)\n{\n\n}\n
\u7f16\u8bd1\u5668\u4f18\u5316\u95ee\u9898#include <iostream>\nusing namespace std;\nclass A\n{\npublic:\n A() : value(0) { cout << \"A() \" << endl; };\n A(int a) : value(a) { cout << \"A(int a)\" << endl; };\n A(const A &other)\n {\n this->value = other.value;\n cout << \"A(&)\" << other.value << endl;\n };\n\n ~A() { cout << \"~A\" << endl; };\n\nprivate:\n int value;\n};\nA f(int a)\n{\n cout << \"f()\" << endl;\n return A(a);\n}\nA bar(A a)\n{\n cout << \"bar\" << endl;\n return a;\n}\n
"},{"location":"CodingLanguage/CPP/classes/Copy/#_2","title":"\u62f7\u8d1d\u8d4b\u503c\u8fd0\u7b97","text":"int main()\n{\n // \u7f16\u8bd1\u5668\u4f18\u5316\n // \u62f7\u8d1d\u6784\u9020\u88ab\u4f18\u5316 \u76f8\u5f53\u4e8e xa = A(5)\n A xa = f(5);\n /*\n f()\n A(int a)\n */\n\n // \u8fdb\u884c\u62f7\u8d1d\u6784\u9020\n A xb = bar(xa);\n /*\n A(&)5 \u53c2\u6570\u4f20\u5165\u4e00\u6b21\u62f7\u8d1d\u6784\u9020\n bar bar \u8c03\u7528\n A(&)5 \u62f7\u8d1d\u6784\u9020 xb = \u4f20\u56de\u53c2\u6570\n ~A \u5e94\u8be5\u662f\u90a3\u4e2a\u53c2\u6570\u88ab\u9500\u6bc1\u4e86\n */\n A xc = A(11);\n}\n
\u62f7\u8d1d
"},{"location":"CodingLanguage/CPP/classes/Copy/#vector","title":"\u6548\u7387\u95ee\u9898 Vector","text":"
- \u901a\u5e38\u8fd4\u56de\u5de6\u503c\u7684\u5f15\u7528
\u7531\u4e8evector\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u4f1a\u53d1\u751f\u6269\u5bb9\uff0c\u6240\u4ee5\u62f7\u8d1d\u6784\u9020\u4f1a\u591a\u6b21\u8fdb\u884c
\u4f18\u5316\u62f7\u8d1d
\u5c06
alist.push_back(A(0));
\u6539\u4e3aalist.emplace_back(0);
\uff0c\u53ef\u4ee5\u4e0d\u6267\u884c\u62f7\u8d1d\u6784\u9020\u800c\u662f\u76f4\u63a5\u6784\u9020C11 \u7981\u7528copy\uff0c
Person(const Person &rhs) = delete;
"},{"location":"CodingLanguage/CPP/classes/Inherit/","title":"\u7ec4\u5408\u4e0e\u7ee7\u627f","text":"vector<A> alist;\n// push_back\nalist.push_back(A(0));\nalist.push_back(A(1));\nalist.push_back(A(2));\n\nalist.emplace_back(0);\nalist.emplace_back(1);\nalist.emplace_back(2);\n
\u7ea6 78 \u4e2a\u5b57 54 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CodingLanguage/CPP/classes/Inherit/#_2","title":"\u7ec4\u5408","text":""},{"location":"CodingLanguage/CPP/classes/Inherit/#_3","title":"\u7ee7\u627f","text":"\u8986\u76d6\u5173\u7cfb
\u540c\u540d\u51fd\u6570\u7684\u7ee7\u627f\u95ee\u9898 \u4e00\u4e2a\u6d3e\u751f\u7c7b\u4e2doverride\uff0c\u5176\u4ed6\u57fa\u7c7b\u540c\u540d\u51fd\u6570\u4e5f\u88ab\u8986\u76d6\u6389
\u8bb0\u5f97override\u6240\u6709\u7684\u76f8\u5173\u51fd\u6570
#include <iostream>\nusing namespace std;\n\nclass A\n{\npublic:\n A(int i) : mi(i) {}\n A(const A &rhs) : mi(rhs.mi)\n {\n cout << \"A::A(&)\" << endl;\n }\n A &operator=(const A &rhs)\n {\n mi = rhs.mi;\n cout << \"A::operator=()\" << endl;\n return *this;\n }\n virtual void f()\n {\n cout << \"A::f(), \" << mi << endl;\n }\n\nprotected:\n int mi;\n};\n\nclass B : public A\n{\npublic:\n B(int i, int j) : A(i), mj(j) {}\n void f() override\n {\n cout << \"B::f(), \" << mi << \", \" << mj << endl;\n }\n\nprivate:\n int mj;\n};\n\nint main()\n{\n A a1(1);\n B b(3, 4);\n\n A &ra = b;\n ra.f();\n ra = a1;\n ra.f();\n\n A a2 = b;\n a2.f();\n}\n
- copy \u6d3e\u751f\u7c7b
=
\u8d4b\u503c\u7ed9\u57fa\u7c7b\uff0cvirtual\u7684\u8868\u4e0d\u4f1a\u62f7\u8d1d\u8fc7\u53bb
base = derived\n
- upcasting
\u7528
void* *
\u8f6c\u6362\n
Relaxation
"},{"location":"CodingLanguage/CPP/classes/OverloadOperator/","title":"Overload","text":"\u7ea6 3 \u4e2a\u5b57
info
"},{"location":"CodingLanguage/CPP/classes/OverloadOperator/#_1","title":"OverloadOperator","text":""},{"location":"CodingLanguage/CPP/classes/class/","title":"CLASSES","text":"\u7ea6 562 \u4e2a\u5b57 49 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
"},{"location":"CodingLanguage/CPP/classes/class/#_1","title":"\u6784\u9020\u4e0e\u6790\u6784","text":""},{"location":"CodingLanguage/CPP/classes/class/#_2","title":"\u5c01\u88c5","text":""},{"location":"CodingLanguage/CPP/classes/class/#_3","title":"\u8bbf\u95ee\u63a7\u5236","text":""},{"location":"CodingLanguage/CPP/classes/class/#protected","title":"protected","text":"\u5f53\u6210\u5458\u88ab\u58f0\u660e\u4e3a protected \u65f6\uff0c\u5b83\u4eec\u5bf9\u4e8e\u6d3e\u751f\u7c7b\u662f\u53ef\u8bbf\u95ee\u7684\uff0c\u4f46\u5bf9\u4e8e\u7c7b\u5916\u90e8\u662f\u4e0d\u53ef\u8bbf\u95ee\u7684\u3002
"},{"location":"CodingLanguage/CPP/classes/class/#private","title":"private","text":"
- \u6d3e\u751f\u7c7b\u7684\u8bbf\u95ee\uff1a\u6d3e\u751f\u7c7b\u53ef\u4ee5\u8bbf\u95ee\u5176\u57fa\u7c7b\u4e2d\u58f0\u660e\u4e3a protected \u7684\u6210\u5458\u3002
- \u7c7b\u5916\u90e8\u7684\u8bbf\u95ee\uff1a\u7c7b\u5916\u90e8\u4e0d\u80fd\u76f4\u63a5\u8bbf\u95ee\u57fa\u7c7b\u4e2d\u58f0\u660e\u4e3a protected \u7684\u6210\u5458\uff0c\u5305\u62ec\u6d3e\u751f\u7c7b\u7684\u5bf9\u8c61\u4e5f\u4e0d\u80fd\u76f4\u63a5\u8bbf\u95ee\u3002
- \u6d3e\u751f\u7c7b\u7684\u6210\u5458\u51fd\u6570\u7684\u8bbf\u95ee\uff1a\u6d3e\u751f\u7c7b\u7684\u6210\u5458\u51fd\u6570\u53ef\u4ee5\u8bbf\u95ee\u5176\u57fa\u7c7b\u4e2d\u58f0\u660e\u4e3a protected \u7684\u6210\u5458\u3002
- \u53cb\u5143\u7c7b\u548c\u53cb\u5143\u51fd\u6570\u7684\u8bbf\u95ee\uff1a\u53cb\u5143\u7c7b\u548c\u53cb\u5143\u51fd\u6570\u53ef\u4ee5\u8bbf\u95ee\u57fa\u7c7b\u4e2d\u58f0\u660e\u4e3a protected \u7684\u6210\u5458\u3002
"},{"location":"CodingLanguage/CPP/classes/class/#friend","title":"friend","text":"
- \u9488\u5bf9\u7c7b\u800c\u8a00\u7684\u6982\u5ff5\uff0c\u800c\u4e0d\u662f\u9488\u5bf9\u67d0\u4e2a\u5b9e\u4f8b. \u9488\u5bf9\u4e0b\u9762\u7684\u5b9e\u4f8b\uff0c
class A\n{\n public:\n void Foo(Base * B){cout << B.val << endl;}\n private:\n int val;\n}\n
friend
- \u4e00\u822c\u6765\u8bf4\uff0c\u6700\u597d\u628a\u53cb\u5143\u58f0\u660e\u96c6\u4e2d\u653e\u5230\u7c7b\u7684\u5f00\u59cb\u90e8\u5206
- \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u53cb\u5143\u58f0\u660e\u672c\u8eab\u5e76\u4e0d\u662f\u4e00\u4e2a\u6b63\u5f0f\u7684\u58f0\u660e\uff0c\u6211\u4eec\u8981\u5728\u7c7b\u4e4b\u5916\u518d\u6b21\u6b63\u5f0f\u58f0\u660e\u51fd\u6570
- \u53cb\u5143\u5173\u7cfb\u662f\u5355\u5411\u7684\uff0c\u4e0d\u5177\u6709\u4f20\u9012\u6027\u3002
- \u53cb\u5143\u5173\u7cfb\u4e0d\u53d7\u8bbf\u95ee\u63a7\u5236\u7b26\u5f71\u54cd\uff0c\u5373\u53cb\u5143\u51fd\u6570\u6216\u53cb\u5143\u7c7b\u53ef\u4ee5\u8bbf\u95ee\u7c7b\u7684\u79c1\u6709\u3001\u4fdd\u62a4\u548c\u516c\u6709\u6210\u5458\u3002
\u5c3d\u91cf\u5c11\u4f7f\u7528\u53cb\u5143\uff0c\u56e0\u4e3a\u5b83\u7834\u574f\u4e86\u5c01\u88c5\u6027\uff0c\u4f7f\u4ee3\u7801\u66f4\u96be\u7406\u89e3\u548c\u7ef4\u62a4\u3002\u53ea\u5728\u786e\u5b9e\u9700\u8981\u8bbf\u95ee\u79c1\u6709\u6210\u5458\u4f46\u65e0\u6cd5\u901a\u8fc7\u6210\u5458\u51fd\u6570\u6216\u63a5\u53e3\u5b9e\u73b0\u65f6\u624d\u4f7f\u7528\u53cb\u5143\u3002 \u53cb\u5143\u51fd\u6570\u6216\u53cb\u5143\u7c7b\u7684\u58f0\u660e\u901a\u5e38\u653e\u5728\u7c7b\u7684\u5185\u90e8\uff0c\u4f46\u5b9a\u4e49\u53ef\u4ee5\u5728\u7c7b\u5185\u6216\u5916\u3002
"},{"location":"CodingLanguage/CPP/classes/class/#_4","title":"\u6784\u9020\u4e0e\u6790\u6784","text":""},{"location":"CodingLanguage/CPP/classes/class/#const","title":"const","text":"
- \u5728\u591a\u6001\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u8c03\u7528\u6d3e\u751f\u7c7b\\\u591a\u6001\u7c7b\u7684\u7684\u6790\u6784\u51fd\u6570\u65f6\uff0c\u8981\u8bb0\u5f97\u628a\u6790\u6784\u51fd\u6570\u5b9a\u4e49\u4e3a
vitual
- \u4e3a\u51fd\u6570\u6dfb\u52a0const\u4fee\u9970\uff0c
assignment & Initialization
const
\u5bf9\u8c61\u7684\u521d\u59cb\u5316\n
"},{"location":"CodingLanguage/CPP/classes/class/#_5","title":"\u5185\u5b58\u5e03\u5c40","text":"class S\n{\n static int count; // \u7531\u5b9e\u4f8b\u5171\u4eab\n static const int size = 100;\n const int selfRank;\n // int A[selfRank]; // Error\n // int A[count]; // Error\n int A[size];\n\npublic:\n void f()\n {\n cout << \"SizeOF S\" << sizeof(S) << endl;\n }\n void f() const\n {\n cout << \"f() const\" << endl;\n }\n\n static void g() // \u53ef\u4e0d\u7531\u5b9e\u4f8b\u4f7f\u7528\n {\n cout << \"Recall g()\" << endl;\n }\n S() : selfRank(0) {}\n S(int rank) : selfRank(rank)\n {\n }\n};\n\nint S::count = 100;\n\nint main()\n{\n const S s;\n S s2;\n S::g();\n s.f();\n s.g();\n s2.f();\n};\n
"},{"location":"CodingLanguage/CPP/classes/class/#_6","title":"class","text":""},{"location":"CodingLanguage/CPP/classes/class/#_7","title":"\u591a\u6001","text":"
- \u6210\u5458\u51fd\u6570\u5b58\u653e\u5728\u4ee3\u7801\u533a
static
\u4e0d\u5728class\u533a\u57df\u7684\u5185\u5b58\u5b9a\u4e49vitual
"},{"location":"CodingLanguage/CPP/classes/class/#abstract-class","title":"Abstract Class","text":""},{"location":"CodingLanguage/CPP/classes/class/#interface","title":"Interface","text":""},{"location":"CodingLanguage/CPP/classes/class/#_8","title":"class","text":""},{"location":"CodingLanguage/CPP/classes/template/","title":"\u6a21\u677f\u548c\u6cdb\u578b\u7f16\u7a0b","text":"
- vitual \u901a\u8fc7\u4e00\u4e2a\u51fd\u6570\u6307\u9488\u5b9e\u73b0
8 bytes
- \u6307\u9488\u6307\u5411\u4e00\u4e2a\u8868\uff0c\u5305\u542b\u6240\u6709\u865a\u51fd\u6570\u7684code
- \u8fd9\u4e2a\u51fd\u6570\u6307\u9488\u653e\u5728\u524d\u516b\u4e2a\u5b57\u8282\u4e2d\uff0c\u6240\u4ee5\u865a\u51fd\u6570\u5b9e\u9645\u8c03\u7528\u7684\u65f6\u5019\u5c31\u662f\u901a\u8fc7\u8fd9\u524d\u516b\u4e2a\u5b57\u8282\u8fdb\u884c\u7d22\u5f15
\u7ea6 38 \u4e2a\u5b57 12 \u884c\u4ee3\u7801
INFO
template
"},{"location":"CodingLanguage/CPP/classes/template/#_2","title":"\u6a21\u677f","text":""},{"location":"CodingLanguage/CPP/classes/template/#_3","title":"\u51fd\u6570\u6a21\u677f","text":""},{"location":"CodingLanguage/CPP/classes/template/#_4","title":"\u6a21\u677f\u5b9a\u4e49","text":"template <typename T>\nT info(T &a, T &b)\n{\n}\n
\u975e\u7c7b\u578b\u53c2\u6570
inlinetemplate <typename T,unsigned m,unsigned n>\nT info(const char (&p1)[m],const char (&p1)[n])\n{\n}\n
"},{"location":"CodingLanguage/CPP/classes/template/#_5","title":"\u7c7b\u6a21\u677f","text":"
template <> inline
template <typename T>\nclass S\n{\n}\n
\u663e\u5f0f\u6a21\u677f\u5b9e\u53c2 vector"},{"location":"CodingLanguage/Python/","title":"Index","text":"
\u7ea6 0 \u4e2a\u5b57
"},{"location":"CodingLanguage/Python/CS61A/","title":"CS61A","text":"\u7ea6 1947 \u4e2a\u5b57 553 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 17 \u5206\u949f
\u6982\u8ff0
\u8fd9\u4e2a\u6587\u6863\u8bb0\u5f55\u4e86\u4e4b\u524d\u5b66\u4e60CS61A\u7684\u4e00\u90e8\u5206\u7b14\u8bb0\uff0c\u5f53\u65f6\u5e76\u6ca1\u6709\u542c\u5b8c\u6240\u6709\u8bfe\uff0c\u8fd9\u4efd\u7b14\u8bb0\u4e0d\u7b97\u7279\u522b\u5b8c\u5584\u3002\uff08\u5f53\u7136\u6709\u4e00\u90e8\u5206\u662f\u89c9\u5f97\u6ca1\u4ec0\u4e48\u8bb0\u7684\u5fc5\u8981\uff09
\u4e0d\u5f97\u4e0d\u8bf4\uff0c\u8fd9\u4e2a\u8bfe\u4f5c\u4e3a\u6211\u4e0a\u8fc7\u7684\u7b2c\u4e00\u95e8\u56fd\u5916\u7f51\u8bfe\uff0c\u5b83\u7684\u8bfe\u7a0b\u7f51\u7ad9\u3001\u4f5c\u4e1aOJ\u3001\u5305\u62ec\u6307\u5bfc\u6559\u7a0b\u90fd\u4ee4\u6211\u5370\u8c61\u633a\u6df1\u7684\u3002
\u8d44\u6e90
FALL 2020
CS 61A Fall 2020
ANSEWR
GitHub - HobbitQia/CS61A-Fall-2020: My solutions for CS61A Fall 2020.
Python Tutor
Online Python Tutor - Composing Programs - Python 3
TextBook
Composing Programs
"},{"location":"CodingLanguage/Python/CS61A/#chapter-1-building-abstractions-with-function","title":"Chapter 1: Building Abstractions with Function","text":""},{"location":"CodingLanguage/Python/CS61A/#_1","title":"\u57fa\u672c\u7279\u5f81","text":""},{"location":"CodingLanguage/Python/CS61A/#features","title":"Features","text":"
- turediv / \u6d6e\u70b9\u6570
- floordiv // \u6574\u9664
- \u53ef\u4ee5\u6709\u591a\u4e2a\u8fd4\u56de\u503c
def divide_exact(n,d) return n//d, n%d
"},{"location":"CodingLanguage/Python/CS61A/#_2","title":"\u5b57\u7b26\u4e32","text":"
- py \u6ca1\u6709\u5355\u72ec\u7684\u5b57\u7b26\u7c7b\u578b\uff0c\u4e00\u4e2a\u5b57\u7b26\u5c31\u662f\u957f\u5ea6\u4e3a 1 \u7684\u5b57\u7b26\u4e32
- Python \u4e2d\u7684\u5b57\u7b26\u4e32\u4e0d\u80fd\u6539\u53d8
- \u53cd\u659c\u6760\u53ef\u4ee5\u7528\u6765\u8f6c\u4e49\uff0c\u4f7f\u7528 r \u53ef\u4ee5\u8ba9\u53cd\u659c\u6760\u4e0d\u53d1\u751f\u8f6c\u4e49\u3002 \u5982 r\"this is a line with \\n\" \u5219 \\n \u4f1a\u663e\u793a\uff0c\u5e76\u4e0d\u662f\u6362\u884c\u3002\uff08raw string\uff09
- \u5b57\u7b26\u4e32\u7684\u622a\u53d6\u7684\u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\uff1a\u53d8\u91cf[\u5934\u4e0b\u6807:\u5c3e\u4e0b\u6807:\u6b65\u957f]
str = '123456789'\nprint(str[0:-1])# \u8f93\u51fa\u7b2c\u4e00\u4e2a\u5230\u5012\u6570\u7b2c\u4e8c\u4e2a\u7684\u6240\u6709\u5b57\u7b26\n>>> 12345678\nprint(str[0])# \u8f93\u51fa\u5b57\u7b26\u4e32\u7b2c\u4e00\u4e2a\u5b57\u7b26\n>>> 1\nprint(str[2:5])# \u8f93\u51fa\u4ece\u7b2c\u4e09\u4e2a\u5f00\u59cb\u5230\u7b2c\u516d\u4e2a\u7684\u5b57\u7b26\uff08\u4e0d\u5305\u542b\uff09print(str[2:])# \u8f93\u51fa\u4ece\u7b2c\u4e09\u4e2a\u5f00\u59cb\u540e\u7684\u6240\u6709\u5b57\u7b26\n>>> 345\nprint(str[1:5:2])# \u8f93\u51fa\u4ece\u7b2c\u4e8c\u4e2a\u5f00\u59cb\u5230\u7b2c\u4e94\u4e2a\u4e14\u6bcf\u9694\u4e00\u4e2a\u7684\u5b57\u7b26\uff08\u6b65\u957f\u4e3a2\uff09\n>>> 24\n
- \u5b57\u7b26\u4e32\u53ef\u4ee5\u7528 + \u8fd0\u7b97\u7b26\u8fde\u63a5\u5728\u4e00\u8d77\uff0c\u7528 * \u8fd0\u7b97\u7b26\u91cd\u590d
"},{"location":"CodingLanguage/Python/CS61A/#_3","title":"\u4ea4\u4e92","text":"print(ptr * 2)\n
- Print \u548c return
print\u8f93\u51fa\u7684\u662f \u2018\u2019\u5f15\u53f7\u5185\u7684
return \u6240\u6709
"},{"location":"CodingLanguage/Python/CS61A/#environment","title":"environment","text":""},{"location":"CodingLanguage/Python/CS61A/#_4","title":"\ud83d\udca1CS61A","text":""},{"location":"CodingLanguage/Python/CS61A/#environment_1","title":"\u9ad8\u9636\u51fd\u6570\u7684 Environment","text":""},{"location":"CodingLanguage/Python/CS61A/#nested-higher","title":"Nested / Higher","text":"
- environment is combined with many frames.
- global frame and others(local frame)
- And at one time, there`s only one frame( the program can`t be in two distinct frames )
- \u5b9a\u4e49\u5e76\u4e0d\u4f1a\u521b\u5efaframe \u53ea\u6709\u5f53\u8fd0\u884c\u5230\u51fd\u6570\u65f6\u624d\u4f1a\u521b\u5efa
# \u4e00\u4e2a\u5d4c\u5957\u51fd\u6570\n# make_adder(5) \u5c06\u8fd4\u56de\u4e00\u4e2a\u51fd\u6570\uff08+5\u7684adder\uff09\ndef compose(f,g):\n def h(x):\n return f(g(x))\n return h\ndef make_adder(x):\n def adder(y):\n return y + x\n return adder\n>>> compose(f,make_adder(5))(4) ```\u5b8c\u6210\u8c03\u7528\n
"},{"location":"CodingLanguage/Python/CS61A/#_5","title":"\u5982\u4f55\u7ed8\u5236","text":""},{"location":"CodingLanguage/Python/CS61A/#funciton","title":"funciton","text":"def print_sums(n):\n \"\"\"Print all sums of arguments of repeated calls.\n n \u4e3a\u603b\u548c k \u4e3a\u4e0b\u4e00\u4e2a\u52a0\u548c\u6570\u5b57\n >>> f = print_sums(1)(2)(3)(4)(5)\n 1\n 3\n 6\n 10\n 15\n \"\"\"\n print(n)\n def next_sum(k):\n return print_sums(n+k)\n return next_sum\n
- from operator import add,mul //\u5f15\u5165\u51fd\u6570\uff08build-in\uff09
- docstring `````` ( HELP ) comments # \u6ce8\u91ca
Print and None
- Print \u8fd4\u56de\u503c\u4e3aNone None\u5728py \u4e2d\u4e0d\u662f\u4e00\u4e2a\u6570\u503c\u8868\u8fbe ==> NoneType \u548c int \u4e0d\u80fd\u8fdb\u884c\u8ba1\u7b97\uff08type Error\uff09
Control
bool \uff1a \u5bf9\u4e8e and \u548c or \u4ed6\u4eec\u603b\u662f\u8fd4\u56de\u6700\u540e\u4e00\u4e2aevaluate\u7684\u5bf9\u8c61\uff0c\u5982\u679c\u5224\u65ad\u5bf9\u8c61\u4e0d\u662fbooleans\uff0c\u5c06\u8fd4\u56de\u6570\u5b57\uff1bTure and 13 will return 13 but not True
iteration \u8fed\u4ee3\uff1a
Test \uff1a Assertions\u5728False\u65f6 \u8f93\u51fa\u540e\u9762\u7684\u5b57\u7b26\u4e32 \u2018 \u2019\u6216\u8005\u201c \u201d
Doctest
- \u5168\u5c40
from doctest import testmod
- \u5355\u4e2a\u51fd\u6570
from doctest import run_docstring_examples
- \u6587\u4ef6
python3 -m doctest \u8fd0\u884c\u6240\u6709 doctests
\u9ad8\u9636\u51fd\u6570
- Currying \u53ea\u542b\u6709\u4e00\u4e2a \u53c2\u6570
\u4f8b\u5982\uff0cg (x) (y) \u7b49\u6548\u4e8e f (x , y) , \u8fd9\u4e2a\u8f6c\u6362\u7684\u8fc7\u7a0b\u5c31\u88ab\u79f0\u4e3acurrying
from operator import add, mul\ndef curry2(f):\n def g(x):\n def h(y):\n return f(x, y)\n return h\n return g\nm = curry2(add)\nadd_three = m(3)\nadd_three(4)\nm(2)(1)\n
- Lambda Expressions
\u5b9a\u4e49\u6b64\u7c7b\u51fd\u6570\u65f6\u6ca1\u6709 intrinsic name
b = lambda x: lambda: x # Lambdas can return other lambdas!\nc = b(88)\n>>> c\nFunction\n>>> c()\n88\n
- Decorators \u4fee\u9970\u7b26
\u7528\u4e8e\u66f4\u597d\u5730\u4f7f\u7528\u9ad8\u9636\u51fd\u6570 triple \u7ed1\u5b9a\u7684\u662f trace \u5728\u8c03\u7528triple\u4e4b\u540e\u7ed1\u5b9a\u7684\u8fd4\u56de\u503c :::
"},{"location":"CodingLanguage/Python/CS61A/#_6","title":"\u542b\u6709\u4efb\u610f\u53c2\u6570\u7684\u51fd\u6570","text":"def print_sum(n):\n //\u6253\u5370n\u4e2a\u6570\u7684\u603b\u548c\n print(n)\n def f(k):\n return print_sum(n+k)\n return f\n\n>>> print_sum(3)(5)(7)\nn k print_sum(3) f(5)\n3 5 print_sum(8) f(7)\n8 7 print_sum(15) f\n
"},{"location":"CodingLanguage/Python/CS61A/#_7","title":"\u4fee\u9970","text":""},{"location":"CodingLanguage/Python/CS61A/#recursive-function","title":"Recursive Function","text":""},{"location":"CodingLanguage/Python/CS61A/#_8","title":"\u57fa\u672c\u6784\u6210","text":"def average(*args):\n k,sum = 0,0\n while k < trials_count:\n sum += original_function(*args) \n k += 1\n return sum / trials_count\n return average\n
- basic case
- recursive case
\u4f8b\u5982\uff0c\\(f_{n+1} = f_n + f (n-1)\\)
"},{"location":"CodingLanguage/Python/CS61A/#lambda","title":"** Lambda\u8868\u793a","text":""},{"location":"CodingLanguage/Python/CS61A/#_9","title":"\u57fa\u7840\u4f7f\u7528","text":""},{"location":"CodingLanguage/Python/CS61A/#y","title":"Y\u7b97\u5b50/\u4e0d\u52a8\u70b9","text":""},{"location":"CodingLanguage/Python/CS61A/#chapter-2-bulilding-abstractions-with-data","title":"Chapter 2 : Bulilding Abstractions with Data","text":""},{"location":"CodingLanguage/Python/CS61A/#sequences","title":"\u00b7 Sequences","text":""},{"location":"CodingLanguage/Python/CS61A/#lists","title":"Lists","text":"
- \u501f\u52a9 helper \u51fd\u6570 \u64cd\u7eb5\u66f4\u591a\u53c2\u6570
"},{"location":"CodingLanguage/Python/CS61A/#sequence-iteration","title":"Sequence Iteration","text":"# \u57fa\u672c\u8fd0\u7b97\n>>> digits = [1, 8, 2, 8]\n>>> len(digits)\n4\n>>> digits[3]\n8\n\n>>> [2, 7] + digits * 2 // mul \u548c add \u5bf9 list\n[2, 7, 1, 8, 2, 8, 1, 8, 2, 8]\n\n>>> pairs = [10, 20], [30, 40](10, 20], [30, 40.md){#9e0fbd15a3b78d4010362d10a44e1fa2}// \u5305\u542blist\u7684list \n>>> pairs[1]\n[30, 40]\n>>> pairs[1][0]\n30\n# unpack pair = [10,20]\n1. pair[0]\n2. x,y = pair\n3. >>> from operator import getitem\n >>> getitem(pair, 0)\n 10\n
for <name> in <expression>:\n <suite>\n
unpacking iteration
# \u5c06list\u4e2d\u7684\u591a\u4e2a\u503c\u8d4b\u7ed9\u53d8\u91cf\n>>> pairs = [1, 2], [2, 2], [2, 3], [4, 4](1, 2], [2, 2], [2, 3], [4, 4.md){#1e41902c4c4bd8a100fe6a2f77932c1c}// list\u542b\u6709\u76f8\u540c\u6570\u76ee\u5143\u7d20\n>>> for x, y in pairs:\n if x == y:\n same_count = same_count + 1\n>>> same_count\n2\n
range
"},{"location":"CodingLanguage/Python/CS61A/#sequence-processing","title":"Sequence Processing","text":">>> range(5,8) //\u5305\u62ec 5 excluding 8 \n>>> list(range(3)) // range() \n[0,1,2]\n>>> for _ in range(3): // _ \u8868\u793a\u4e0d\u518dsuit\u4e2d\u4f7f\u7528\u7684\u53d8\u91cf \u81ea\u52a8\u4ece 0 \u5f00\u59cb\n print('Go Bears!')\n
:::info List Comprehensions :::
[<map expression> for <name> in <sequence expression> if <filter expression>]\n# \u6ce8\u610f\u662f\u5728\u3010\u3011\u4e2d\u8fdb\u884c\uff0c\u751f\u6210\u65b0\u7684 List \n>>> odds = [1, 3, 5, 7, 9]\n>>> [x+1 for x in odds if ...]\n[2, 4, 6, 8, 10]\n# Aggregation\nsum max min , etc\n
:::info Higher-Order Function :::
# reduce \u91cd\u590d\u8ba1\u7b97\nfrom functools import reduce\nreduce(fn_reduce,iterable,initial)\n# map \nr = map(fn_map,iterable)\nlist(r)\n# \n
:::info Conventional Names :::
>>> apply_to_all = lambda map_fn, s: list(map(map_fn, s))\n>>> keep_if = lambda filter_fn, s: list(filter(filter_fn, s))\n
:::info Sequence Abstraction :::
"},{"location":"CodingLanguage/Python/CS61A/#trees","title":"Trees","text":"lists = [0,1,2,3,4,5,6,7]\n# Membership\nx in lists / not in\n# Slicing\nlist[0:]\n# Processing\n1. sum(iterative[,start])\n2. max(iterative[,key = function])\n3. all(iterative) -> bool()\n
- Trees. \u6709\u4e00\u4e2a rootlabel \u548c branches \u5b83\u672c\u8eab\u662f\u4e00\u79cd\u7528\u9012\u5f52\u5b9a\u4e49\u7684\u6570\u636e\u7ed3\u6784
- \u5f62\u5f0f\uff1a[label , branches = [] ] [1,[ [2 , [3]] , [4,[5]] , [6,[7]] ]]
\u5c24\u5176\u6ce8\u610fbranches\u7684\u683c\u5f0f\u95ee\u9898 \u4e5f\u53ef\u4ee5\u4f7f\u7528\u5b57\u5178\u5f62\u5f0f\u8868\u793atree\u8fd9\u79cd\u6570\u636e\u7ed3\u6784
- \u5bf9 tree \u7684\u904d\u5386\u7ecf\u5e38\u7528\u5230
for b in branches(t):\n
\u82e5\u5df2\u77e5\u4e3a\u4e8c\u53c9\u6811\uff0c\u4e5f\u53ef\u4ee5\u4e0d\u65ad\u5206\u4e3a left right \u4e24\u4e2a\u8282\u70b9
"},{"location":"CodingLanguage/Python/CS61A/#data-abstraction-of-trees","title":"Data abstraction of trees","text":"
h = **[**helper(branch,height + 1) for branch in branches(tree)**]**
\u8fd9\u6837\u7684\u8bed\u53e5\u4f1a\u5bfc\u81f4\u4e4b\u540e\u6240\u6709\u7684\u8fd4\u56de\u503c\u5f62\u6210\u5f88\u6df1\u5c42\u6b21\u7684\u5d4c\u5957**[2], 1, [[[[5]]]](2], 1, [[[[5]]].md)**
\u6700\u597d\u5728\u6bcf\u4e00\u5c42\u7ea7\u90fd\u201c\u89e3\u538b\u201d**max(t)**
\u8fd9\u6837\u4e4b\u540e\u8fd4\u56de\u7684\u624d\u662f\u6570\u503c
- \u6b64\u5904\u7684\u7ec4\u4ef6\u5e76\u4e0d\u901a\u8fc7\u9012\u5f52\u5f62\u6210\u4e00\u4e2atree\uff0c\u53ea\u662f\u5355\u7eaftree\u7684component
- \u6ce8\u610f branches \u7684\u5199\u6cd5
## the first level for abstraction\n# constructor\n>>> def tree(root_label, branches=[]):\n for branch in branches:\n assert is_tree(branch), 'branches must be trees'\n return [root_label] + list(branches)\n# selector\n>>> def label(tree):\n return tree[0]\n>>> def branches(tree):\n return tree[1:]\n\n## the second\n>>> def is_tree(tree):\n if type(tree) != list or len(tree) < 1:\n return False\n for branch in branches(tree):\n if not is_tree(branch):\n return False\n return True\n>>> def is_leaf(tree):\n return not branches(tree)\n
- partition\u7684tree\u505a\u6cd5
"},{"location":"CodingLanguage/Python/CS61A/#excises-and-application","title":"Excises and Application","text":"def partition_tree(n, m):\n \"\"\"Return a partition tree of n using parts of up to m.\"\"\"\n if n == 0:\n return tree(True)\n elif n < 0 or m == 0:\n return tree(False)\n else:\n left = partition_tree(n-m, m)\n right = partition_tree(n, m-1)\n return tree(m, [left, right])\n# recursion tree in prefix order\ndef print_parts(tree, partition=[]):\n if is_leaf(tree):\n if label(tree):\n print(' + '.join(partition))\n else:\n left, right = branches(tree)\n m = str(label(tree))\n print_parts(left, partition + [m])\n print_parts(right, partition)\n
- Add Tree
- \u8003\u8651\u9012\u5f52\u7684
Basic case
\u548cRecursive case
- Hard : \u786e\u8ba4\u5bf9\u5e94\u4f4d\u7f6e
- Tip : using the
zip
functionzip(iterable1,iterable2,...):\n Returns a zip object, which is an iterator of tuples\n \u5982\u679c\u53c2\u6570\u957f\u5ea6\u4e0d\u4e00\uff0c\u53d6\u6700\u77ed\u7684\n>>> t2\n[1, [5, [6]], [9], [4, [8], [1]]], [99](1]]], [99.md){#618df381853bde2dd02159e20c7c676c}\n>>> t1 \n[1, [5, [6]], [8], [9]]\n>>> list(zip(t1,t2))\n[(1, 1), ([5, [6]], [5, [6]]), ([8], [9]), ([9], [4, [8], [1]](1].md))]\n
- \u5f62\u6210\u65b0\u7684Tree
- \u4ecd\u7136\u662f\u5bf9 rucursive \u7ed3\u6784\u8003\u8651\u4e0d\u662f\u5f88\u6e05\u695a.
tree : [1, [5], [6, [7]]]
,branches
\u4e2d\uff0c\u6bcf\u4e00\u4e2a\u5143\u7d20\u90fd\u4ee3\u8868\u4e00\u6574\u4e2a\u5206\u652fdef add_tree(t1,t2):\n '''Return the addition tree of the two trees t1 and t2.\n Adding up the corresponding value, and making a tree.\n IF one branch is onlt in one tree, then it will be in the new tree\n >>> numbers = tree(1,\n ... [tree(2,\n ... [tree(3),\n ... tree(4)]),\n ... tree(5,\n ... [tree(6,\n ... [tree(7)]),\n ... tree(8)])])\n >>> print_tree(add_trees(numbers, numbers))\n 2\n 4\n 6\n 8\n 10\n 12\n 14\n 16\n >>> print_tree(add_trees(tree(2), tree(3, [tree(4), tree(5)])))\n 5\n 4\n 5\n >>> print_tree(add_trees(tree(2, [tree(3)]), tree(2, [tree(3), tree(4)])))\n 4\n 6\n 4\n >>> print_tree(add_trees(tree(2, [tree(3, [tree(4), tree(5)])]), \\\n tree(2, [tree(3, [tree(4)]), tree(5)])))\n 4\n 6\n 8\n 5\n 5\n '''\n if is_leaf(t1) and is_leaf(t2): \n return tree(label(t1) + label(t2)) \n elif is_leaf(t1): \n return tree(label(t1) + label(t2), branches(t2)) \n elif is_leaf(t2): \n return tree(label(t1) + label(t2), branches(t1)) \n else: \n new_label = label(t1) + label(t2) \n new_branches = [add_trees(b1, b2) for b1, b2 in zip(branches(t1), branches(t2))] \n if len(branches(t1)) > len(branches(t2)): \n new_branches += branches(t1)[len(branches(t2)):] \n elif len(branches(t1)) < len(branches(t2)): \n new_branches += branches(t2)[len(branches(t1)):] \n return tree(new_label, new_branches)\n
-
"},{"location":"CodingLanguage/Python/CS61A/#linked-lists","title":"Linked Lists","text":"
- \u5b9a\u4e49\uff1a\u4e0e tree\u7c7b\u4f3c\uff0c[ element , new_linked]
[ 2, [3, [4, 'empty']]]
-
"},{"location":"CodingLanguage/Python/CS61A/#data-abstraction","title":"\u00b7 Data abstraction","text":""},{"location":"CodingLanguage/Python/CS61A/#abstraction-barrier","title":"Abstraction barrier","text":"four = [1,[2,[3,[4,'empty']]]]\n\n# constructor\nempty = 'empty'\n\ndef link(label , rest):\n if is_link(rest):\n return [label,rest]\n\ndef first(s):\n assert is_link(s), \"first only applies to linked lists.\"\n assert s != empty, \"empty linked list has no first element.\"\n return s[0]\n\ndef rest(s):\n assert is_link(s), \"first only applies to linked lists.\"\n assert s != empty, \"empty linked list has no rest.\"\n return s[1]\n\n# convenience\ndef is_link(s):\n return s == empty or (len(s) == 2 and is_link(s[1]))\n\ndef getitem_link(s,i):\n if i == 0:\n return first(s)\n else:\n return getitem_link( rest(s) ,i - 1)\n\ndef len_link(s):\n length = 0\n while s != empty:\n length += 1\n s = rest(s)\n return length\n\n## \n\n## application\n
"},{"location":"CodingLanguage/Python/CS61A/#dictionary","title":"Dictionary","text":"
- \u5bf9\u529f\u80fd\u8fdb\u884c\u4e0d\u540c\u7684\u5206\u5c42\uff0c\u5176\u5c42\u7ea7\u4e4b\u95f4\u5f62\u6210abstraction barrier
- \u8c03\u7528\u90e8\u5206\u529f\u80fd\u65f6\u4e0d\u8981\u4f7f\u7528\u8fc7\u4f4e\u5c42\u7ea7\uff0ceg\uff1aadd_rational( ) \u4e2d\uff0c\u4f7f\u7528 rational \u3001numer\u3001denom\u51fd\u6570\u4f5c\u4e3acomponent\u6784\u5efa\u76f8\u5173\u51fd\u6570
- \u5176\u76ee\u7684\u662f\u4e3a\u4e86\u5c3d\u53ef\u80fd\u51cf\u5c11\u4fee\u6539\u4ee3\u7801\u65f6\u7684\u5de5\u4f5c\u91cf\uff0c\u5373\u6240\u8c13 isolution
:::info Basic operation :::
**\u521b\u5efa\u65b9\u6cd5**
**dict**(_**kwargs_)
******dict**(mapping,_**kwargs_)
**dict**(iterable,_**kwargs_)
\u952e\u503c\u5bf9 {a:1,b:2}
\u63a8\u5bfc\u5f0f {x: x ** 2 for x in range(10)}
\u7c7b\u578b\u6784\u9020\u5668 dict([(a,1),(b,2)])
**methods**
**\u5b57\u5178\u89c6\u56fe\u5bf9\u8c61**
\u52a8\u6001\u53d8\u5316\uff0c\u4e0d\u662f iterator \u4f46\u53ef\u4ee5\u901a\u8fc7\u51fd\u6570\u4ea7\u751fiter(dictview)
**keys()**
**items()**
**values()**
**popitem**()
**pop()**
\u8fed\u4ee3\u65b9\u6cd5\uff1a
- \u5229\u7528
dic.items
\u4ea7\u751f\u4e00\u4e2a\u952e\u503c\u5bf9\u7684 listfor i,j in dic.items()
2.key -> value\ndic = {'I':1,'A'\uff1a2,5:a} # \u6b64\u5904\u7684a\u4e3a\u5df2\u8d4b\u503c\u7684\u53d8\u91cf\uff0c\u6216\u8005'a'\u4ee3\u8868\u53d8\u91cf\n>>> dic['I'] == 1\n>>> dic.values()\n>>> dic.key()\n>>> items = dic.items()\n>>> dict(items)\n>>> dic.get('X',0) # get \u6253\u5370value ornot print 0\n
:::info Dictionary comprehension and limitation :::
"},{"location":"CodingLanguage/Python/CS61A/#mutable-data","title":"\u00b7 Mutable Data","text":">>> {x:x*x for x in range(10}\n\u00b7 key \u4e0d\u80fd\u91cd\u590d\n\u00b7 key \u4e0d\u80fd\u662f\u53ef\u53d8\u5316\u7684\u503c/list/sequence\n
- Mutable Data \u7528\u4e8e\u8868\u793a\u52a8\u6001\u53d8\u5316\u7684\u503c
- py\u5185\u7f6e\u7684numbers\u3001string\u3001tuple\u4e0d\u80fd\u53d8\u5316\uff0csequence\u53ef\u4ee5
- default argument value is part of a function value
"},{"location":"CodingLanguage/Python/CS61A/#object","title":"Object","text":"def f(s = []):\n s.append(5)\n return len(s)\n>>> f()\n1\n>>> f()\n2\n
- Objects are both information and processes (bundling information and behavior together)
- Objects have attributes,we use dot to represent
.\u8fd9\u91cc\u7684name\u76f8\u5f53\u4e8e object \u7684\u4e00\u79cd\u5c5e\u6027\uff0c\u53ea\u5728 . \u540e\u6709\u7528
"},{"location":"CodingLanguage/Python/CS61A/#sequence-object","title":"Sequence Object","text":"
- method \u76f8\u5f53\u4e8efunction-valued attribute
- In python, all values are objects
# operation on data \n# share and identity\n''' = \u5e76\u6ca1\u6709\u521b\u5efa\u65b0\u7684object \u6545\u800c suits \u4e0e chinese \u6307\u5411\u76f8\u540c\u7684object'''\nchinese = ['coin', 'string', 'myriad'] # A list literal\nsuits = chinese # Two names refer to the same list\n\n## \u79fb\u9664\nsuits.pop() # Remove and return the final element\nsuits.remove('string') # Remove the first element that equals the argument\n\n## \u589e\u6dfb\nsuits.append('cup') # Add an element to the end\nsuits.extend(['sword', 'club']) # Add all elements of a sequence to the end\n\n## \u66f4\u6539 mutable\nsuits[2] = 'spade' # Replace an element\nsuits[0:2] = ['heart', 'diamond'] # Replace a slice\n\n### slicing \u5207\u7247\u65f6\u4e0d\u662fmutable\u7684\na = suits[0:2]\n\n## \u590d\u5236 \n'\u4f7f\u7528constructor\uff1alist\u521b\u5efa\u4e00\u4e2a\u526f\u672c\u5373\u4e00\u4e2a\u65b0\u53d8\u91cf'\nnested = list(suits)\nnested[0] = suits # \u6307\u5411suits\u5217\u8868\n\n## check\n'identity is much stronger than equality'\n'\u4f7f\u7528 is \u6216\u8005 is not \u5224\u65ad\u6307\u5411\u7684\u662f\u5426\u4e3a\u540c\u4e00\u5bf9\u8c61'\n>>> suits is nested[0]\nTrue\n
# comprehension\n\n'\u521b\u5efa\u65b0\u7684list'\n## slicing\nsuits[1:]\n\n## complicated examples\n'\u5f15\u7528\u81ea\u8eab\u7684list'\n>>> t = [1,2,3]\n>>> t[1:3] = [t]\n[1,[...]]\n'\u8fd9\u91cc\u7684[...]\u5c31\u662f\u8fd9\u4e2a list \u672c\u8eab '\n>>>t.extend(t)\n[1,[...],1,[...]]\n>>> t[1]\n[1,[...],1,[...]]\n\n>>> t = [1,2],[3,4](1,2],[3,4.md){#b62caabac6f0b056c943105b6c99d2aa}\n>>> t[0].append(t[1:2]) # t[1:2] -> [3,4](3,4.md){#3217f0200a9316574561e220f77a82c2}\n[1,2,[[3,4]],[3,4](1,2,[[3,4]],[3,4.md){#cfc817a5247d573d544970abfc9d61ff}\n
\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff1a\u4ee5 list \u4f5c\u4e3a\u5143\u7d20\u65f6\uff0c\u662f\u4ee5\u5360\u4f4d\u7b26\u5f62\u5f0f\u5c55\u73b0\u7684
"},{"location":"CodingLanguage/Python/CS61A/#tuples","title":"Tuples","text":"a = [0,1,2,3,4,[5,6]]\nb = a\nc = b[:]\n\nprint(c is b)\nprint(c[5] is b[5])\n
- \u5143\u7ec4 \u5177\u6709\u7c7b\u4f3clist\u7684\u64cd\u4f5c\uff0c\u4f46\u662f\u5143\u7ec4\u672c\u8eab\u4e0d\u53ef\u4ee5\u76f4\u63a5\u6539\u53d8\uff08unmutable\uff09
- \u53ef\u4ee5\u5305\u62ec\u4efb\u4f55\u7c7b\u578b\u7684\u5bf9\u8c61
- \u53ef\u4ee5\u5bf9\u5bf9\u8c61\u8fdb\u884c\u6539\u53d8\uff08mutable data\uff09
- \u521b\u5efa\uff0c\u4f7f\u7528 \uff0c \uff08 \uff09
"},{"location":"CodingLanguage/Python/CS61A/#dictionary-object","title":"Dictionary Object","text":">>> 1, 2 + 3\n(1, 5)\n>>> (\"the\", 1, (\"and\", \"only\"))\n('the', 1, ('and', 'only'))\n>>> type( (10, 20) )\n<class 'tuple'>\n\n>>> () # 0 elements\n()\n>>> (10,) # 1 element\n(10,)\n
Dictionaries do have some restrictions:
- A key of a dictionary cannot be or contain a mutable value.
- There can be at most one value for a given key.
"},{"location":"CodingLanguage/Python/CS61A/#string","title":"String","text":"# \n##\n'\u666e\u901a\u7684\u6539\u53d8\u6216\u8005\u589e\u52a0\u53ef\u4ee5\u901a\u8fc7\u8d4b\u503c\u8bed\u53e5\u5b9e\u73b0'\n\n## methods\uff1akeys, values, and items all return iterable values.\n>>> sum(dic.values())\n\n'\u901a\u8fc7\u952e\u503c\u5bf9\u521b\u5efadict'\n>>> dict([(3, 9), (4, 16), (5, 25)])\n{3: 9, 4: 16, 5: 25}\n\n## methods\n'get: \u5982\u679c\u6ca1\u6709\u8be5\u952e\u503c\u5bf9\uff0c\u8fd4\u56de 0 '\n>>> numerals.get('V', 0)\n5\n
- Unicode,ASCII,UTF-8\u7684\u533a\u522b-\u817e\u8baf\u4e91\u5f00\u53d1\u8005\u793e\u533a-\u817e\u8baf\u4e91 :::info ASCII : \u4e00\u4e2a\u5b57\u8282 \u82f1\u6587\u7f16\u7801 Unicode :\u4e24\u4e2a\u5b57\u8282 \u6240\u6709\u7f16\u7801\u7edf\u4e00 UTF - 8 :\u81ea\u52a8\u51b3\u5b9a\u5b57\u8282\u6570
TIP :
"},{"location":"CodingLanguage/Python/CS61A/#local-state","title":"Local State","text":"
- \u5185\u5b58\u7edf\u4e00\u4f7f\u7528 unicode \u7f16\u7801 :::
- nonlocal statement \u5fc5\u987b\u4f7f\u7528\u5728\u5df2\u7ecf\u8d4b\u503c\u540e\u7684\u53d8\u91cf\u524d[ in nonlocal frame ]
no binging for nonlocal '' found
- \u4e00\u4e2a\u53d8\u91cf\u4e0d\u80fd\u5148\u8bbf\u95ee
non-local frame
\u4e4b\u540e\u518d\u5728local frame
\u4e2d\u8d4b\u503c
name '' is parameter and nonlocal
- \u7ed1\u5b9a\u7684\u662f\u7b2c\u4e00\u4e2a
non-local frame
\u4e2d\u7684name \u3010enclosing scope\u3011- \u3010referential transparency\u3011expression -> \u7528\u8868\u8fbe\u5f0f\u7684\u503c\u66ff\u6362\u8868\u8fbe\u5f0f\u4e4b\u540e\u4e0d\u5f71\u54cd\u6574\u4e2a program
\u3010violate ...\u3011mutable operation
- Instances\uff1a
"},{"location":"CodingLanguage/Python/CS61A/#implementing-on-list","title":"Implementing on List","text":"def make_withdraw(balance):\n def withdraw(amount):\n nonlocal balance\n if amount > balance:\n return 'Insufficient funds'\n balance = balance - amount\n return balance\n return withdraw\n
This part is going to introduce one way to creat mutable data structure by mutable function
"},{"location":"CodingLanguage/Python/CS61A/#-dispatch-function-the-message-determines-the-behavior-of-the-function","title":"- Dispatch Function : the message determines the behavior of the function","text":""},{"location":"CodingLanguage/Python/CS61A/#object-oriented-programming","title":"\u00b7 Object-Oriented Programming","text":""},{"location":"CodingLanguage/Python/CS61A/#implementing-classes-and-objects","title":"\u00b7 Implementing Classes and Objects","text":""},{"location":"CodingLanguage/Python/CS61A/#object-abstraction","title":"\u00b7 Object Abstraction","text":""},{"location":"CodingLanguage/Python/CS61A/#objects-and-classes","title":"Objects And Classes","text":""},{"location":"CodingLanguage/Python/CS61A/#creating-a-class","title":"Creating a class","text":"
instance attribute
/fileds
/instance variables
/properties
methods
: functions that operate on the object or perform object-specific computations are called methodsattribute
/class variables
/static variables
\uff1adifined without the range of methods. It is shared by all the class and among all instances definedinstance attribute
specific attributes for one instance**\u533a\u5206**
\u5bf9\u4e8e instance \uff0cobject
\u8bbf\u95ee\u5bf9\u8c61\u65f6\u4f18\u5148\u8bbf\u95eeinstance attr
\uff0c\u672a\u5bfb\u627e\u5230\u624d\u8bbf\u95eeclass attribute
\u4e5f\u5c31\u662f\u8bf4\uff0c\u53ef\u4ee5\u5b58\u5728\u4e00\u4e2aattr
\u53ea\u5b58\u5728\u4e8e\u67d0\u4e2a\u7279\u5b9a\u5b9e\u4f8b\u800c\u4e0d\u5b58\u5728\u4e8eclass
class Account:\n# definitiate a new method\n def __init__(self, account_holder):\n# self is bound to the newly defined class\n self.balance = 0\n self.holder = account_holder\n def deposit(self, amount):\n self.balance = self.balance + amount\n return self.balance\n def withdraw(self, amount):\n if amount > self.balance:\n return 'Insufficient funds'\n self.balance = self.balance - amount\n return self.balance\n\na = Account('Kirk')\n# \u4e24\u79cd\u4e0d\u540c\u8c03\u7528 function \u548c method \u7684\u65b9\u6cd5\n'\u6839\u636eclass \u548c instance \u7684\u4e0d\u540c\uff0c\u8fd4\u56de\u503c\u4e5f\u4e0d\u540c'\n>>> Account.deposit(spock_account, 1001) # The deposit function takes 2 arguments\n1011\n>>> spock_account.deposit(1000) # The deposit method takes 1 argument\n2011\n
getattr(instance,attr)\n'Return the value of calling it which is identical to the dot expression'\n# the attr must be a string\ngetattr(a,'balance')\n\nhasattr(instance,attr)\n'''return True or False'''\n
"},{"location":"CodingLanguage/Python/CS61A/#inheritance","title":"Inheritance","text":"
- As an attribute of a class, a method is just a function, but as an attribute of an instance, it is a bound method. \u533a\u522b\uff1a\u5f53
method
\u88ab\u8c03\u7528\u65f6\uff0cself \u5c06\u81ea\u52a8\u7ed1\u5b9a\u8fd9\u4e2aobject
- Python's convention\uff1a dictates that if an attribute name starts with an underscore, it should only be accessed within methods of the class itself, rather than by users of the class.
is-a
\u7c7b\u7ee7\u627fhas-a
\u805a\u5408- \u4ece\u7236\u7c7b\u7ee7\u627f\u6240\u6709attr\uff0c\u4f46\u662f\u53ef\u4ee5override
"},{"location":"CodingLanguage/Python/CS61A/#multiple-inheritance","title":"Multiple Inheritance","text":">>> class CheckingAccount(Account):\n \"\"\"A bank account that charges for withdrawals.\"\"\"\n withdraw_charge = 1\n interest = 0.01\n def withdraw(self, amount):\n return Account.withdraw(self, amount + self.withdraw_charge)\n
- For non-ambigious case, it works nuturally.
- For ambigious case, for example, both the two have one same name, then the order matters
"},{"location":"CodingLanguage/Python/CS61A/#efficiency","title":"\u00b7 Efficiency","text":""},{"location":"CodingLanguage/Python/CS61A/#recursive-objects","title":"\u00b7 Recursive Objects","text":""},{"location":"CodingLanguage/Python/CS61A/#chapter-4-data-processing","title":"Chapter 4 : Data Processing","text":""},{"location":"CodingLanguage/Python/CS61A/#implicit-sequence","title":"Implicit Sequence","text":""},{"location":"CodingLanguage/Python/CS61A/#iterator","title":"Iterator","text":"class SavingsAccount(Account):\n deposit_charge = 2\n def deposit(self, amount):\n return Account.deposit(self, amount - self.deposit_charge)\nclass AsSeenOnTVAccount(CheckingAccount, SavingsAccount):\n def __init__(self, account_holder):\n self.holder = account_holder\n self.balance = 1 # A free dollar!\n\n# one way to find out the order of inheritance\n>>> [c.__name__ for c in AsSeenOnTVAccount.mro()]\n['AsSeenOnTVAccount', 'CheckingAccount', 'SavingsAccount', 'Account', 'object']\n
- components
- a mechanism for retrieving the next element in the sequence being processed and
- a mechanism for signaling that the endof the sequence has been reached no further elements remain
- Calling
**iter**
on an iterator will return that iterator, not a copy"},{"location":"CodingLanguage/Python/CS61A/#build-in-iterator","title":"Build-in Iterator","text":">>> next(iterator)\n7\n>>> next(iterator)\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nStopIteration\n>>> try:\n next(iterator)\n except StopIteration:\n print('No more values')\nNo more values\n
- Taking an iterator and return an iterator
lazy processing
\u8c03\u7528iterator function \u4e0d\u4f1a\u76f4\u63a5\u8ba1\u7b97\u7ed3\u679c\uff0c\u8fd4\u56de\u4e00\u4e2aiterator\uff0c\u53ea\u6709\u5f53\u4f7f\u7528\u67d0\u4e2a\u6570\u503c\u65f6\u624d\u4f1a\u53d1\u751f\u8ba1\u7b97. \u5982\uff1a\u4e0b\u4f8b\u4e2d\uff0c\u82e5\u4e4b\u540e\u518d\u6b21\u8c03\u7528doubled
\u76f8\u5173\uff0c\u5c06\u4f1a\u51fa\u9519\uff0c\u56e0\u4e3a\u8fd9\u4e2aiterator
\u5df2\u7ecf\u5230\u8fbe\u5c3d\u5934>>> def double_and_print(x):\n print('***', x, '=>', 2*x, '***')\n return 2*x\n>>> s = range(3, 7)\n>>> doubled = map(double_and_print, s) # double_and_print not yet called\n>>> next(doubled) # double_and_print called once\n*** 3 => 6 ***\n6\n>>> next(doubled) # double_and_print called again\n*** 4 => 8 ***\n8\n>>> list(doubled) # double_and_print called twice more\n*** 5 => 10 ***\n*** 6 => 12 ***\n[10, 12]\n
"},{"location":"CodingLanguage/Python/CS61A/#iterables","title":"Iterables","text":"
zip
map
reversed
"},{"location":"CodingLanguage/Python/CS61A/#generator","title":"Generator","text":"
- Any value that can produce iterators is called an
_**iterable**_** value**
.- \u5bf9\u4e8e\u4e00\u4e9b\u672c\u8eab\u65e0\u5e8f\u7684\u7ed3\u6784\uff0c\u5982\u5b57\u5178\u548c\u96c6\u5408\uff0cPython \u5c06\u4f1a\u5185\u7f6e\u4e00\u4e2a\u987a\u5e8f\uff0c\u4f7f\u5f97
iter``next
\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c- \u4f46\u5982\u679c\u6539\u52a8\u6216\u5220\u9664\u4e86
key
\uff0c\u5c06\u4f1a\u51fa\u73b0\u65b0\u987a\u5e8f\uff0c\u4e4b\u524d\u4ea7\u751f\u7684iter
\u5931\u6548- \u5728\u9ad8\u7248\u672cpy\u4e2d\u5b57\u5178\u5df2\u7ecf\u6709\u4e86\u987a\u5e8f
- is one type of special iterator
- returned by a special class of function called a generator function.
- \u6bcf\u6b21\u8c03\u7528\u76f4\u5230\u5230\u8fbe
yield
\u65f6return
\u4e00\u4e2agenerator
\uff0c\u5e76\u8bb0\u5f55\u6b64\u6b21\u8fd0\u884c\u7684 name \u548c value\uff0c\u4e0b\u4e00\u6b21\u4ece\u6b64\u6b21\u7ed3\u675f\u5904\u91cd\u590d\u64cd\u4f5c>>> def letters_generator():\n current = 'a'\n while current <= 'd':\n yield current\n current = chr(ord(current)+1)\n>>> for letter in letters_generator():\n print(letter)\na\nb\nc\nd\n
- \u4ea7\u751f\u53ef\u91cd\u590d\u4f7f\u7528\u7684 iterable \uff08Creating Iterables with Yield\uff09
"},{"location":"CodingLanguage/Python/CS61A/#library","title":"Library","text":""},{"location":"CodingLanguage/Python/CS61A/#standard-library","title":"Standard Library","text":""},{"location":"CodingLanguage/Python/CS61A/#q-a","title":"Q & A","text":""},{"location":"CodingLanguage/Python/CS61A/#_10","title":"\u6d6e\u70b9\u6570\u95ee\u9898","text":"class LettersWithYield:\n def __init__(self, start='a', end='e'):\n self.start = start\n self.end = end\n def __iter__(self):\n next_letter = self.start\n while next_letter < self.end:\n yield next_letter\n next_letter = chr(ord(next_letter)+1)\n\n\nclass LetterIter:\n \"\"\"An iterator over letters of the alphabet in ASCII order.\"\"\"\n def __init__(self, start='a', end='e'):\n self.next_letter = start\n self.end = end\n def __next__(self):\n if self.next_letter == self.end:\n raise StopIteration\n letter = self.next_letter\n self.next_letter = chr(ord(letter)+1)\n return letter\n
- \u4fdd\u7559\u4f4d\u6570
\u4f7f\u7528 round \u51fd\u6570 \u56db\u820d\u4e94\u5165\u7c7b\u578b\u7684\u51fd\u6570 \u5982\u679c\u6709 0 \u5b58\u5728\u81ea\u52a8\u820d\u53bb\u591a\u4f59\u76840
>>> round( 4.000 , 2 )\n4.0\n>>> round(4,2)\n4\n>>> round(float(4),2)\n4.0\n
-
"},{"location":"CodingLanguage/Python/CS61A/#_11","title":"\u5176\u4ed6\u5e38\u7528\u51fd\u6570\u7684\u7ec6\u8282","text":"
- max & min
# \u539f\u578b\nmax(iterable, *, default, key=None)\n''' \u8fd4\u56de\u7b2c\u4e00\u4e2a\u627e\u5230\u7684max\u503c\n iterable\u4e3a\u7a7a\u65f6\u8fd4\u56dedefault\n key\u4e3a\u6307\u5b9a\u7684 \u5b9e\u9645\u4f20\u5165list.sort()\u7684\u53c2\u6570\n'''\n\n# \u5e94\u7528 \n '''\u6309\u5b57\u5178\u987a\u5e8f\u6bd4\u8f83'''\n ## \u6bd4\u8f83\u5b57\u7b26\u4e32 \n>>> max('1', '9', '10', '100') # \u8fd4\u56de\u591a\u4e2a\u5b57\u7b26\u4e32\u4e2d\u6700\u5927\u7684\u5b57\u7b26\u4e32\n'9'\n>>> max('asdxyz')\n'z'\n ## \u6bd4\u8f83\u5217\u8868\n>>> min(['8',4],['8',4,'2']) # \u8fd4\u56de\u591a\u4e2a\u5217\u8868\u4e2d\u6700\u5c0f\u7684\u5217\u8868\n['8', 4]\n>>> min(('8',4, '3'),('8',4,'2')) # \u8fd4\u56de\u591a\u4e2a\u5143\u7ec4\u4e2d\u6700\u5c0f\u7684\u5143\u7ec4\n('8', 4, '2')\n ## \u6bd4\u8f83\u5b57\u5178 \u6ce8\u610f \u8fd4\u56de\u503c\u4e3a \u952e\n>>> d = {'x':5, 'y':7, 'z':3}\n>>> min(d) # \u8fd4\u56de\u5b57\u5178\u5143\u7d20\u4e2d\u7684\u6700\u5c0f\u503c\uff0c\u7ed3\u679c\u662f\u6700\u5c0f\u7684\u952e\n'x'\n>>> min(d , key = lambda x:d[x])\n'z'\n
"},{"location":"CodingLanguage/Python/CS61A/#_12","title":"\u4e00\u4e9b\u601d\u8003\u65b9\u5f0f","text":"
- print\u51fd\u6570
"},{"location":"CodingLanguage/Python/basic/","title":"Basic and Warning","text":"
- \u5206cases\u8003\u8651\u9012\u5f52\u95ee\u9898 tree\u7684\u60f3\u6cd5
\u7ea6 479 \u4e2a\u5b57 89 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 4 \u5206\u949f
info
\u8fd9\u91cc\u4e00\u65b9\u9762\u653e\u4e00\u4e9b\u81ea\u5df1\u91cd\u65b0\u770bpy\u8bed\u6cd5\u65f6\u4e00\u4e9b\u57fa\u7840\u7684\u77e5\u8bc6\uff0c\u53e6\u4e00\u65b9\u9762\u653e\u4e00\u4e9b\u5b9e\u8df5\u8fc7\u7a0b\u4e2d\u9047\u5230\u7684\u5751\u6216\u8005\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9
"},{"location":"CodingLanguage/Python/basic/#some","title":"Some","text":""},{"location":"CodingLanguage/Python/basic/#string","title":"\u5173\u4e8estring","text":"
- \u4ee5\u4e0b\u5212\u7ebf\u5f00\u5934\u7684\u6807\u8bc6\u7b26\u662f\u6709\u7279\u6b8a\u610f\u4e49\u7684\u3002\u4ee5\u5355\u4e0b\u5212\u7ebf\u5f00\u5934 _foo \u7684\u4ee3\u8868\u4e0d\u80fd\u76f4\u63a5\u8bbf\u95ee\u7684\u7c7b\u5c5e\u6027\uff0c\u9700\u901a\u8fc7\u7c7b\u63d0\u4f9b\u7684\u63a5\u53e3\u8fdb\u884c\u8bbf\u95ee\uff0c\u4e0d\u80fd\u7528 from xxx import * \u800c\u5bfc\u5165\u3002
- \u4ee5\u53cc\u4e0b\u5212\u7ebf\u5f00\u5934\u7684 foo \u4ee3\u8868\u7c7b\u7684\u79c1\u6709\u6210\u5458\uff0c\u4ee5\u53cc\u4e0b\u5212\u7ebf\u5f00\u5934\u548c\u7ed3\u5c3e\u7684 __foo \u4ee3\u8868 Python \u91cc\u7279\u6b8a\u65b9\u6cd5\u4e13\u7528\u7684\u6807\u8bc6\uff0c\u5982 init() \u4ee3\u8868\u7c7b\u7684\u6784\u9020\u51fd\u6570\u3002
"},{"location":"CodingLanguage/Python/basic/#_1","title":"\u5305\u4e0e\u6a21\u5757","text":""},{"location":"CodingLanguage/Python/basic/#_2","title":"\u6a21\u5757\u8c03\u7528","text":"s = '\u5b66\u4e60Python'\n# \u5207\u7247\ns[0], s[-1], s[3:], s[::-1] # '\u4f18', 'n', 'ython', 'nohtyP\u7684\u4e60\u5b66'\n# \u66ff\u6362\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u66ff\u6362\ns.replace('Python', 'Java') # '\u5b66\u4e60Java'\n# \u67e5\u627e\uff0cfind()\u3001index()\u3001rfind()\u3001rindex()\ns.find('P') # 3, \u8fd4\u56de\u7b2c\u4e00\u6b21\u51fa\u73b0\u7684\u5b50\u4e32\u7684\u4e0b\u6807\ns.find('h', 2) # 6, \u8bbe\u5b9a\u4e0b\u68072\u5f00\u59cb\u67e5\u627e\ns.find('23333') # -1, \u67e5\u627e\u4e0d\u5230\u8fd4\u56de-1\ns.index('y') # 4, \u8fd4\u56de\u7b2c\u4e00\u6b21\u51fa\u73b0\u7684\u5b50\u4e32\u7684\u4e0b\u6807\ns.index('P') # \u4e0d\u540c\u4e0efind(), \u67e5\u627e\u4e0d\u5230\u4f1a\u629b\u51fa\u5f02\u5e38\n# \u8f6c\u5927\u5c0f\u5199, upper()\u3001lower()\u3001swapcase()\u3001capitalize()\u3001istitle()\u3001isupper()\u3001islower()\ns.upper() # '\u5b66\u4e60PYTHON'\ns.swapcase() # '\u5b66\u4e60pYTHON', \u5927\u5c0f\u5199\u4e92\u6362\ns.istitle() # True\ns.islower() # False\n# \u53bb\u7a7a\u683c,strip()\u3001lstrip()\u3001rstrip()\n# \u683c\u5f0f\u5316\ns1 = '%s %s' % ('Windrivder', 21) # 'Windrivder 21'\ns2 = '{}, {}'.format(21, 'Windridver') # \u63a8\u8350\u4f7f\u7528format\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\ns3 = '{0}, {1}, {0}'.format('Windrivder', 21)\ns4 = '{name}: {age}'.format(age=21, name='Windrivder')\n# \u8fde\u63a5\u4e0e\u5206\u5272\uff0c\u4f7f\u7528 + \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u6bcf\u6b21\u64cd\u4f5c\u4f1a\u91cd\u65b0\u8ba1\u7b97\u3001\u5f00\u8f9f\u3001\u91ca\u653e\u5185\u5b58\uff0c\u6548\u7387\u5f88\u4f4e\uff0c\u6240\u4ee5\u63a8\u8350\u4f7f\u7528join\nl = ['2017', '03', '29', '22:00']\ns5 = '-'.join(l) # '2017-03-29-22:00'\ns6 = s5.split('-') # ['2017', '03', '29', '22:00']\n
import
\u4fdd\u5b58\u539f\u6709\u7684module\u547d\u540d\u7a7a\u95f4"},{"location":"CodingLanguage/Python/basic/#_3","title":"\u5305","text":"
from module import func
\u628afunnc
\u5bfc\u5165\u5230\u5f53\u524d\u7684\u547d\u540d\u7a7a\u95f4\u5e38\u89c1\u7684\u5305\u7ed3\u6784\u5982\u4e0b\uff1a
pakageName\n-------__init__.py\n-------moduleName1.py\n-------moduleName2.py\n------- ...\n
\u5305\u8def\u5f84\u4e0b\u5fc5\u987b\u5b58\u5728
__init__.py
\u6587\u4ef6\u3002\u5173\u4e8e import
from blog
init .py\u6587\u4ef6 \u7528\u4e8e\u7ec4\u7ec7\u5305\uff08package\uff09\uff0c\u65b9\u4fbf\u7ba1\u7406\u5404\u4e2a\u6a21\u5757\u4e4b\u95f4\u7684\u5f15\u7528\u3001\u63a7\u5236\u7740\u5305\u7684\u5bfc\u5165\u884c\u4e3a\u3002 \u8be5\u6587\u4ef6\u53ef\u4ee5\u4ec0\u4e48\u5185\u5bb9\u90fd\u4e0d\u5199\uff0c\u5373\u4e3a\u7a7a\u6587\u4ef6\uff08\u4e3a\u7a7a\u65f6\uff0c\u4ec5\u4ec5\u7528import [\u8be5\u5305]\u5f62\u5f0f \u662f\u4ec0\u4e48\u4e5f\u505a\u4e0d\u4e86\u7684\uff09\uff0c\u5b58\u5728\u5373\u53ef\uff0c\u76f8\u5f53\u4e8e\u4e00\u4e2a\u6807\u8bb0\u3002
\u5f53\u6211\u4eec\u5728\u5bfc\u5165\u4e00\u4e2a\u5305\uff08package\uff09\u65f6\uff08\u4f1a\u5148\u52a0\u8f7d init .py\u5b9a\u4e49\u7684\u5f15\u5165\u6a21\u5757\uff0c\u7136\u540e\u518d\u8fd0\u884c\u5176\u4ed6\u4ee3\u7801\uff09\uff0c\u5b9e\u9645\u4e0a\u662f\u5bfc\u5165\u7684\u5b83\u7684 init .py\u6587\u4ef6\uff08\u5bfc\u5165\u65f6\uff0c\u8be5\u6587\u4ef6\u81ea\u52a8\u8fd0\u884c\uff0c\u52a9\u6211\u4eec\u4e00\u4e0b\u5bfc\u5165\u8be5\u5305\u4e2d\u7684\u591a\u4e2a\u6a21\u5757\uff09\u3002\u6211\u4eec\u53ef\u4ee5\u5728 init .py\u4e2d\u518d\u5bfc\u5165\u5176\u4ed6\u7684\u5305\uff08package\uff09\u6216\u6a21\u5757 \u6216\u81ea\u5b9a\u4e49\u7c7b\u3002
"},{"location":"CodingLanguage/Python/basic/#_4","title":"\u5143\u7d20\u7c7b\u578b","text":""},{"location":"CodingLanguage/Python/basic/#list","title":"list","text":"
append
extend
# \u5b9a\u4e49\u4e00\u4e2alist\nname = list('Pyther')\n\n# \u6539\u53d8 list \u4e2d\u7684\u6700\u540e\u4e24\u4e2a\u503c\nname[4:]='on'\nname\n['P', 'y', 't', 'h', 'o', 'n']\n
\u6784\u9020\u4e00\u4e2alist
"},{"location":"CodingLanguage/Python/basic/#tuple","title":"tuple","text":"even_squares = [x**2 for x in range(1, 11) if x % 2 == 0]\n
"},{"location":"CodingLanguage/Python/basic/#dict","title":"dict","text":"a = (1,2,3)\n
"},{"location":"CodingLanguage/Python/basic/#set","title":"set","text":"a = {1:a,}\n\n# method\ndict.get(val,default = None)\n# \u67e5\u627e\nif key in dict\ndict.setdefault() # \u672a\u627e\u5230\u5219\u63d2\u5165\n\ndict.items( ) \n
\u57fa\u672c\u7528\u6cd5
"},{"location":"CodingLanguage/Python/basic/#function","title":"function","text":""},{"location":"CodingLanguage/Python/basic/#_5","title":"\u9ed8\u8ba4\u53c2\u6570","text":"a = {'a','b','c'}\n# \u7a7a\u5b57\u5178\na = {}\n# \u7a7aset\na = set()\n#\na.update(iterable) # dict \u6dfb\u52a0\u7684\u662f\u952e\u503c\n>>> a\n>>> {1, 2, 3, 4, 6, 45, 23, 56}\n>>> a.update({1:2,'a':5})\n>>> a\n>>> {1, 2, 3, 4, 6, 45, 23, 56, 'a'}\na.add()\n#\na.remove()\na.discard() # nonexsitence won`t throw error\n# \u4ea4\u96c6\nset.intersection(set1, set2 ... etc)\n\n**\u53c2\u6570\uff1a**\nset1 -- \u5fc5\u9700\uff0c\u8981\u67e5\u627e\u76f8\u540c\u5143\u7d20\u7684\u96c6\u5408\nset2 -- \u53ef\u9009\uff0c\u5176\u4ed6\u8981\u67e5\u627e\u76f8\u540c\u5143\u7d20\u7684\u96c6\u5408\uff0c\u53ef\u4ee5\u591a\u4e2a\uff0c\u591a\u4e2a\u4f7f\u7528\u9017\u53f7 , \u9694\u5f00\n
Warning!
\u9ed8\u8ba4\u503c\u53ea\u8ba1\u7b97\u4e00\u6b21\u3002\u9ed8\u8ba4\u503c\u4e3a\u5217\u8868\u3001\u5b57\u5178\u6216\u7c7b\u5b9e\u4f8b\u7b49\u53ef\u53d8\u5bf9\u8c61\u65f6\uff0c\u4f1a\u4ea7\u751f\u4e0e\u4e0d\u540c\u7684\u7ed3\u679c\u3002
"},{"location":"CodingLanguage/Python/basic/#lambda","title":"lambda","text":"def f(a, L=[]):\n L.append(a)\n return L\ndef f(a, L=None):\n if L is None:\n L = []\n L.append(a)\n return L\n\nprint(f(1))\nprint(f(2))\nprint(f(3))\n
"},{"location":"CodingLanguage/Python/basic/#class","title":"class","text":""},{"location":"CodingLanguage/Python/basic/#method","title":"method","text":""},{"location":"CodingLanguage/Python/basic/#method_1","title":"\u5b9e\u4f8bmethod","text":""},{"location":"CodingLanguage/Python/basic/#method_2","title":"\u9759\u6001method","text":""},{"location":"CodingLanguage/Python/basic/#method_3","title":"\u7c7bmethod","text":""},{"location":"CodingLanguage/Python/%E7%88%AC%E8%99%AB/","title":"\u722c\u866b","text":"pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]\npairs.sort(key=lambda pair: pair[1])\npairs\n[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]\n
\u7ea6 2 \u4e2a\u5b57
abstract
"},{"location":"CodingLanguage/Python/library/numpy/","title":"numpy","text":"\u7ea6 5 \u4e2a\u5b57 14 \u884c\u4ee3\u7801
"},{"location":"CodingLanguage/Python/library/numpy/#array","title":"array","text":"\u521d\u59cb\u5316
"},{"location":"Tools/","title":"Index","text":"import numpy as np\n\n# \u521b\u5efa\u4e00\u4e2a\u5305\u542b\u7279\u5b9a\u6570\u76ee\u5143\u7d20\u7684\u6570\u7ec4\narr = np.array([1, 2, 3, 4, 5])\nprint(arr)\n\n# \u521b\u5efa\u4e00\u4e2a\u6307\u5b9a\u6570\u76ee\u7684\u6570\u7ec4\uff0c\u6240\u6709\u5143\u7d20\u521d\u59cb\u5316\u4e3a0\narr_zeros = np.array([0] * 5)\nprint(arr_zeros)\n\n# \u521b\u5efa\u4e00\u4e2a\u6307\u5b9a\u6570\u76ee\u7684\u6570\u7ec4\uff0c\u6240\u6709\u5143\u7d20\u521d\u59cb\u5316\u4e3a1\narr_ones = np.array([1] * 5)\nprint(arr_ones)\n
\u7ea6 82 \u4e2a\u5b57
\u6982\u8ff0
\u8fd9\u91cc\u653e\u4e00\u4e9b\u81ea\u5df1\u5728CS\u5b66\u4e60\u8fc7\u7a0b\u4e2d\u7528\u5230\u7684\u4e00\u4e9b\u5de5\u5177\u4ee5\u53ca\u5b66\u4e60\u8fd9\u4e9b\u5de5\u5177\u7684\u8d44\u6e90\u7d22\u5f15\u3002
\u540d\u79f0 \u8d44\u6e90 cmake \u5b98\u65b9\u6559\u7a0b GNU MAKE \u8d44\u6599: makefile \u4ecb\u7ecd \u2014 \u8ddf\u6211\u4e00\u8d77\u5199 Makefile 1.0 \u6587\u6863 \u89c6\u9891: \u4e00\u4e2a\u8f83\u7b80\u5355\u7684\u5165\u95e8 Git \u5ed6\u96ea\u5cf0Git\u5165\u95e8 shell
- MissingSemester
Note
"},{"location":"Tools/CMake/","title":"tools","text":""},{"location":"Tools/CMake/#cmake","title":"CMake","text":"\u7ea6 10 \u4e2a\u5b57
\u8d44\u6e90
\u5b98\u65b9\u6559\u7a0b : https://cmake.org/cmake/help/latest/guide/tutorial/index.html
"},{"location":"Tools/Collection/","title":"\u6536\u96c6","text":"\u7ea6 71 \u4e2a\u5b57
"},{"location":"Tools/Collection/#_2","title":"\u7535\u8111\u4e0a\u7684\u5c0f\u5de5\u5177","text":""},{"location":"Tools/Collection/#_3","title":"\u56fe\u50cf","text":""},{"location":"Tools/Collection/#-draw-io-vsc","title":"- \u6d41\u7a0b\u56fe draw io \u4e3b\u8981\u662f\u53ef\u4ee5\u96c6\u6210\u5230VSC\u4e2d","text":""},{"location":"Tools/Conda/","title":"Conda","text":"
- everything \u597d\u7528\u7684\u67e5\u627e\u5de5\u5177
- Snipaste \u6bd4\u8f83\u597d\u7528\u7684\u622a\u56fe\u5de5\u5177
- chorme\u62d3\u5c55 : \u6c99\u62c9\u67e5\u8bcd \u6253\u5f00chorme\u670d\u52a1\u4e4b\u540e\u4efb\u4f55\u60c5\u51b5\u4e0b\u67e5\u8bcd\u90fd\u4f1a\u6bd4\u8f83\u65b9\u4fbf
\u7ea6 1 \u4e2a\u5b57
"},{"location":"Tools/GNUMake/","title":"GNU Make","text":"\u7ea6 1026 \u4e2a\u5b57 87 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 6 \u5206\u949f
\u8d44\u6599:
makefile \u4ecb\u7ecd \u2014 \u8ddf\u6211\u4e00\u8d77\u5199 Makefile 1.0 \u6587\u6863
\u89c6\u9891:
\u4e00\u4e2a\u8f83\u7b80\u5355\u7684\u5165\u95e8 https://www.youtube.com/watch?v=E1_uuFWibuM&t=1152s
TIPS
- cc \u662f C \u7f16\u8bd1\u5668\u7684\u547d\u4ee4\u3002\u5728\u4e00\u822c\u7684\u7cfb\u7edf\u4e0a\uff08Unix/Linux\uff09\uff0c\u901a\u5e38\u662f\u4e00\u4e2a\u6307\u5411 \u5b9e\u9645 C \u7f16\u8bd1\u5668\uff08gcc\uff09\u7684\u7b26\u53f7\u94fe\u63a5\u6216\u522b\u540d
windows \u4e0b\u53ef\u4ee5\u4f7f\u7528 gcc .c -o .o
"},{"location":"Tools/GNUMake/#_1","title":"\u4f7f\u7528\u8fc7\u7a0b","text":"// \u6307\u5b9a\u6587\u4ef6\ngcc your_source_file.c -o ../your_executable\n// \u94fe\u63a5c++\u6807\u51c6\u5e93\ngcc source/pdShow.cpp pd.cpp -o source/pdShow -lstdc++\n
\u200b
"},{"location":"Tools/GNUMake/#_2","title":"\u57fa\u672c\u4ecb\u7ecd","text":"target ... : prerequisites ...\n recipe\n ...\n ...\n// \u5b9a\u4e49\u4f9d\u8d56\u5173\u7cfb\n
target \u53ef\u4ee5\u662f\u4e00\u4e2a object file\uff08\u76ee\u6807\u6587\u4ef6\uff09\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u8fd8\u53ef\u4ee5\u662f\u4e00\u4e2a\u6807\u7b7e\uff08label\uff09\u3002 prerequisites \u751f\u6210\u8be5 target \u6240\u4f9d\u8d56\u7684\u6587\u4ef6\u548c/\u6216 target\u3002 recipe \u8be5 target \u8981\u6267\u884c\u7684\u547d\u4ee4\uff08\u4efb\u610f\u7684 shell \u547d\u4ee4\uff09\u3002
"},{"location":"Tools/GNUMake/#_3","title":"\u53d8\u91cf","text":"
- \u7b2c\u4e00\u4e2a\u76ee\u6807\u4f1a\u4f5c\u4e3a\u9ed8\u8ba4\u76ee\u6807
- makefile \u4e2d\u7684\u53d8\u91cf\u76f8\u5f53\u4e8e C \u4e2d\u7684\u5b8f\u5b9a\u4e49
"},{"location":"Tools/GNUMake/#makefile","title":"Makefile \u5982\u4f55\u5de5\u4f5c","text":"
def
:objects = main.o
usage
:edit : $(objects)
"},{"location":"Tools/GNUMake/#windows","title":"windows","text":""},{"location":"Tools/GNUMake/#_4","title":"\u4e66\u5199\u89c4\u5219","text":"
- make \u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u627e\u540d\u5b57\u53eb\u201cMakefile\u201d\u6216\u201cmakefile\u201d\u7684\u6587\u4ef6\u3002
- \u5982\u679c\u627e\u5230\uff0c\u5b83\u4f1a\u627e\u6587\u4ef6\u4e2d\u7684\u7b2c\u4e00\u4e2a\u76ee\u6807\u6587\u4ef6\uff08target\uff09\uff0c\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u4ed6\u4f1a\u627e\u5230\u201cedit\u201d\u8fd9\u4e2a\u6587\u4ef6\uff0c\u5e76\u628a\u8fd9\u4e2a\u6587\u4ef6\u4f5c\u4e3a\u6700\u7ec8\u7684\u76ee\u6807\u6587\u4ef6\u3002
- \u5982\u679c edit \u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u6216\u662f edit \u6240\u4f9d\u8d56\u7684\u540e\u9762\u7684 .o \u6587\u4ef6\u7684\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u8981\u6bd4 edit \u8fd9\u4e2a\u6587\u4ef6\u65b0\uff0c\u90a3\u4e48\uff0c\u4ed6\u5c31\u4f1a\u6267\u884c\u540e\u9762\u6240\u5b9a\u4e49\u7684\u547d\u4ee4\u6765\u751f\u6210 edit \u8fd9\u4e2a\u6587\u4ef6\u3002
- \u5982\u679c edit \u6240\u4f9d\u8d56\u7684 .o \u6587\u4ef6\u4e5f\u4e0d\u5b58\u5728\uff0c\u90a3\u4e48 make \u4f1a\u5728\u5f53\u524d\u6587\u4ef6\u4e2d\u627e\u76ee\u6807\u4e3a .o \u6587\u4ef6\u7684\u4f9d\u8d56\u6027\uff0c\u5982\u679c\u627e\u5230\u5219\u518d\u6839\u636e\u90a3\u4e00\u4e2a\u89c4\u5219\u751f\u6210 .o \u6587\u4ef6\u3002\uff08\u8fd9\u6709\u70b9\u50cf\u4e00\u4e2a\u5806\u6808\u7684\u8fc7\u7a0b\uff09
- \u5f53\u7136\uff0c\u4f60\u7684 C \u6587\u4ef6\u548c\u5934\u6587\u4ef6\u662f\u5b58\u5728\u7684\u5566\uff0c\u4e8e\u662f make \u4f1a\u751f\u6210 .o \u6587\u4ef6\uff0c\u7136\u540e\u518d\u7528 .o \u6587\u4ef6\u751f\u6210 make \u7684\u7ec8\u6781\u4efb\u52a1\uff0c\u4e5f\u5c31\u662f\u53ef\u6267\u884c\u6587\u4ef6 edit \u4e86\u3002
"},{"location":"Tools/GNUMake/#_5","title":"\u901a\u914d\u7b26","text":"
- \u547d\u4ee4\u4e00\u5b9a\u8981\u4ee5
tab
\u5f00\u5934"},{"location":"Tools/GNUMake/#_6","title":"\u6587\u4ef6\u641c\u5bfb","text":"
*
.o .c?
~
\u5728\u6587\u4ef6\u540d\u4e2d\u6709\u7528\u9014 \u3002 \u6bd4\u5982\uff0c~/test
\u8868\u793a\u5f53\u524d\u7528\u6237\u7684 $HOME \u76ee\u5f55\u4e0b\u7684 test \u76ee\u5f55\u3002
VPATH \u53d8\u91cf
VPATH = src:../headers
\u6b64\u5904\uff0c\u7528 : \u5206\u9694\u4e0d\u540c\u8def\u5f84vpath \u5173\u952e\u5b57
**vpath <pattern> <directories>**
\u4e3a\u7b26\u5408\u6a21\u5f0f\u7684\u6587\u4ef6\u6307\u5b9a\u641c\u7d22\u76ee\u5f55\u3002**vpath <pattern>**
\u6e05\u9664\u7b26\u5408\u6a21\u5f0f\u7684\u6587\u4ef6\u7684\u641c\u7d22\u76ee\u5f55\u3002**vpath**
\u6e05\u9664\u6240\u6709\u5df2\u88ab\u8bbe\u7f6e\u597d\u4e86\u7684\u6587\u4ef6\u641c\u7d22\u76ee\u5f55\u3002"},{"location":"Tools/GNUMake/#_7","title":"\u4f2a\u76ee\u6807","text":"
.PHONY : clean
\u58f0\u660e\u8fd9\u4e2a\u76ee\u6807\u662f\u4f2a\u76ee\u6807\uff0c\u907f\u514d\u4e0e\u6587\u4ef6\u540d\u91cd\u590d.PHONY : clean\nclean :\n rm *.o temp\n
\u5229\u7528\u4f2a\u76ee\u6807\u5b9e\u73b0\u4e00\u4e2a makefile \u7f16\u8bd1\u591a\u4e2a\u6587\u4ef6\uff0c\u751f\u6210\u591a\u4e2a exe
all : prog1 prog2 prog3\n# \u6b64\u5904\u7684\u4f9d\u8d56\u4e5f\u662f\u76ee\u6807\n.PHONY : all\n\nprog1 : prog1.o utils.o\n cc -o prog1 prog1.o utils.o\n\nprog2 : prog2.o\n cc -o prog2 prog2.o\n\nprog3 : prog3.o sort.o utils.o\n cc -o prog3 prog3.o sort.o utils.o\n
\u4f2a\u76ee\u6807\u4f5c\u4e3a\u4f9d\u8d56
"},{"location":"Tools/GNUMake/#_8","title":"\u591a\u76ee\u6807","text":".PHONY : cleanall cleanobj cleandiff\n\ncleanall : cleanobj cleandiff\n rm program\n\ncleanobj :\n rm *.o\n\ncleandiff :\n rm *.diff\n
- \u4f7f\u7528\u4e00\u4e2a\u81ea\u52a8\u5316\u53d8\u91cf
$@
\uff0c\u8fd9\u4e2a\u53d8\u91cf\u8868\u793a\u7740\u76ee\u524d\u89c4\u5219\u4e2d\u6240\u6709\u7684\u76ee\u6807\u7684\u96c6\u5408"},{"location":"Tools/GNUMake/#_9","title":"\u9759\u6001\u6a21\u5f0f","text":"bigoutput littleoutput : text.g\n generate text.g -$(subst output,,$@) > $@\n\n#\u4e0a\u8ff0\u89c4\u5219\u7b49\u4ef7\u4e8e\uff1a\n\nbigoutput : text.g\n generate text.g -big > bigoutput\nlittleoutput : text.g\n generate text.g -little > littleoutput\n
\u66f4\u5bb9\u6613\u5b9a\u4e49\u591a\u76ee\u6807\u7684\u89c4\u5219
<targets ...> : <target-pattern> : <prereq-patterns ...>\n <commands>\n ...\n# Example\nobjects = foo.o bar.o\n\nall: $(objects)\n# $< \u8868\u793a\u7b2c\u4e00\u4e2a\u4f9d\u8d56\u6587\u4ef6\n# $@ \u8868\u793a\u76ee\u6807\u96c6\uff08\u4e5f\u5c31\u662f\u201cfoo.o bar.o\u201d\uff09\n$(objects): %.o: %.c\n $(CC) -c $(CFLAGS) $< -o $@\n
targets
\u5b9a\u4e49\u4e86\u4e00\u7cfb\u5217\u7684\u76ee\u6807\u6587\u4ef6\uff0c\u53ef\u4ee5\u6709\u901a\u914d\u7b26\u3002\u662f\u76ee\u6807\u7684\u4e00\u4e2a\u96c6\u5408\u3002
target-pattern
\u6307\u660e\u4e86 targets \u7684\u6a21\u5f0f\uff0c\u4e5f\u5c31\u662f\u7684\u76ee\u6807\u96c6\u6a21\u5f0f\u3002
prereq-patterns
\u662f\u76ee\u6807\u7684\u4f9d\u8d56\u6a21\u5f0f\uff0c\u5b83\u5bf9 target-pattern \u5f62\u6210\u7684\u6a21\u5f0f\u518d\u8fdb\u884c\u4e00\u6b21\u4f9d\u8d56\u76ee\u6807\u7684\u5b9a\u4e49\u3002
"},{"location":"Tools/GNUMake/#_10","title":"* \u81ea\u52a8","text":"GNU \u7ec4\u7ec7\u5efa\u8bae\u628a\u7f16\u8bd1\u5668\u4e3a\u6bcf\u4e00\u4e2a\u6e90\u6587\u4ef6\u7684\u81ea\u52a8\u751f\u6210\u7684\u4f9d\u8d56\u5173\u7cfb\u653e\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u4e3a\u6bcf\u4e00\u4e2a
name.c
\u7684\u6587\u4ef6\u90fd\u751f\u6210\u4e00\u4e2aname.d
\u7684 Makefile \u6587\u4ef6\uff0c.d
\u6587\u4ef6\u4e2d\u5c31\u5b58\u653e\u5bf9\u5e94.c
\u6587\u4ef6\u7684\u4f9d\u8d56\u5173\u7cfb\u3002 \u901a\u8fc7gcc
\u547d\u4ee4\u81ea\u52a8\u751f\u6210\u4f9d\u8d56\u6587\u4ef6>>> gcc -MM main.c\nmain.o: main.c variable.h\n
\u5728\u7f16\u8bd1\u5668\u751f\u6210\u7684\u4f9d\u8d56\u5173\u7cfb\u4e2d\u52a0\u5165
.d
\u6587\u4ef6\u7684\u4f9d\u8d56"},{"location":"Tools/GNUMake/#_11","title":"\u4e66\u5199\u547d\u4ee4","text":""},{"location":"Tools/GNUMake/#_12","title":"\u547d\u4ee4\u663e\u793a","text":"%.d: %.c\n @set -e; rm -f $@; \\\n $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \\\n sed 's,\\($*\\)\\.o[ :]*,\\1.o $@ : ,g' < $@.$$$$ > $@; \\\n rm -f $@.$$$$\n
- \u901a\u5e38\uff0cmake \u4f1a\u628a\u5176\u8981\u6267\u884c\u7684\u547d\u4ee4\u884c\u5728\u547d\u4ee4\u6267\u884c\u524d\u8f93\u51fa\u5230\u5c4f\u5e55\u4e0a\u3002\u5f53\u6211\u4eec\u7528 @ \u5b57\u7b26\u5728\u547d\u4ee4\u884c\u524d\uff0c\u90a3\u4e48\uff0c\u8fd9\u4e2a\u547d\u4ee4\u5c06\u4e0d\u88ab make \u663e\u793a\u51fa\u6765\uff0c\u6700\u5177\u4ee3\u8868\u6027\u7684\u4f8b\u5b50\u662f\uff0c\u6211\u4eec\u7528\u8fd9\u4e2a\u529f\u80fd\u6765\u5411\u5c4f\u5e55\u663e\u793a\u4e00\u4e9b\u4fe1\u606f\u3002
@echo \u6b63\u5728\u7f16\u8bd1\n>>>\u6b63\u5728\u7f16\u8bd1\necho \u6b63\u5728\u7f16\u8bd1\n>>>echo \u6b63\u5728\u7f16\u8bd1\n>>>\u6b63\u5728\u7f16\u8bd1\n
- make \u53c2\u6570
"},{"location":"Tools/GNUMake/#_13","title":"\u547d\u4ee4\u6267\u884c","text":"
-n
\u6216--just-print
\uff0c\u90a3\u4e48\u5176\u53ea\u662f\u663e\u793a\u547d\u4ee4\uff0c\u4f46\u4e0d\u4f1a\u6267\u884c\u547d\u4ee4\uff0c\u8fd9\u4e2a\u529f\u80fd\u5f88\u6709\u5229\u4e8e\u6211\u4eec\u8c03\u8bd5\u6211\u4eec\u7684 Makefile\uff0c\u770b\u770b\u6211\u4eec\u4e66\u5199\u7684\u547d\u4ee4\u662f\u6267\u884c\u8d77\u6765\u662f\u4ec0\u4e48\u6837\u5b50\u7684\u6216\u662f\u4ec0\u4e48\u987a\u5e8f\u7684\u3002 make \u53c2\u6570-s
\u6216--silent
\u6216--quiet
\u5219\u662f\u5168\u9762\u7981\u6b62\u547d\u4ee4\u7684\u663e\u793a\u3002"},{"location":"Tools/GNUMake/#_14","title":"\u5d4c\u5957\u6267\u884c","text":""},{"location":"Tools/GNUMake/#-","title":"- \u4f18\u70b9\uff1a\u6a21\u5757\u5316","text":""},{"location":"Tools/GNUMake/#_15","title":"\u793a\u4f8b","text":"
exec: cd /home/hchen; pwd
\u4e0d\u80fd\u5199\u5728\u4e24\u884c\u4e0a \u4f7f\u5f97pwd
\u547d\u4ee4\u5728cd
\u547d\u4ee4\u57fa\u7840\u4e0a\u8fdb\u884c"},{"location":"Tools/Git/","title":"Git","text":"objects = main.o kbd.o command.o display.o \\\n insert.o search.o files.o utils.o\n\nedit : $(objects)\n cc -o edit $(objects)\n\nmain.o : defs.h\nkbd.o : defs.h command.h\ncommand.o : defs.h command.h\ndisplay.o : defs.h buffer.h\ninsert.o : defs.h buffer.h\nsearch.o : defs.h buffer.h\nfiles.o : defs.h buffer.h command.h\nutils.o : defs.h\n\n# \u8868\u793a clean \u662f\u4e2a\u4f2a\u76ee\u6807\u6587\u4ef6\n.PHONY : clean\nclean :\n rm edit $(objects)\n
\u7ea6 353 \u4e2a\u5b57 61 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
Docs
"},{"location":"Tools/Git/#git_1","title":"Git \u914d\u7f6e","text":"
- Command \u6c47\u603b
- Learn Branch \uff1a\u4e00\u4e2a\u5206\u652f\u7684\u7ec3\u4e60\\\u5b66\u4e60\u7f51\u7ad9
- \u63a8\u8350\u9605\u8bfb\uff1aProGit
"},{"location":"Tools/Git/#gitignore","title":"gitignore\u7684\u5199\u6cd5","text":"
- \u67e5\u770b\u914d\u7f6e\u6587\u4ef6
git config --list --show-origin
- \u67e5\u770b\u914d\u7f6e\u4fe1\u606f
git config --list
- \u914d\u7f6e\u7528\u6237\u4fe1\u606f
$ git config --global user.name \"ZZIcarus\"\n$ git config --global user.email 2450606426@qq.com\n
\u901a\u914d\u7b26
"},{"location":"Tools/Git/#usage","title":"Usage","text":"# \u5ffd\u7565\u6240\u6709\u7684 .a \u6587\u4ef6\n*.a\n\n# \u4f46\u8ddf\u8e2a\u6240\u6709\u7684 lib.a\uff0c\u5373\u4fbf\u4f60\u5728\u524d\u9762\u5ffd\u7565\u4e86 .a \u6587\u4ef6\n!lib.a\n\n# \u53ea\u5ffd\u7565\u5f53\u524d\u76ee\u5f55\u4e0b\u7684 TODO \u6587\u4ef6\uff0c\u800c\u4e0d\u5ffd\u7565 subdir/TODO\n/TODO\n\n# \u5ffd\u7565\u4efb\u4f55\u76ee\u5f55\u4e0b\u540d\u4e3a build \u7684\u6587\u4ef6\u5939\nbuild/\n\n# \u5ffd\u7565 doc/notes.txt\uff0c\u4f46\u4e0d\u5ffd\u7565 doc/server/arch.txt\ndoc/*.txt\n\n# \u5ffd\u7565 doc/ \u76ee\u5f55\u53ca\u5176\u6240\u6709\u5b50\u76ee\u5f55\u4e0b\u7684 .pdf \u6587\u4ef6\ndoc/**/*.pdf\n
\u82f1\u6587\u72b6\u6001\u4e0b\u6309
q
\u53ef\u4ee5\u9000\u51fagit log
\u7b49\u8f93\u51fa\u4fe1\u606f\u7684\u547d\u4ee4git log
"},{"location":"Tools/Git/#_1","title":"\u7248\u672c\u56de\u9000","text":"git init \n\ngit add\n\ngit commit -m \"message\"\n\ngit status\n\ngit diff\n\ngit push origin main\n\ngit pull origin main\n
HEAD\u8868\u793a\u6700\u65b0\u7248\u672c\uff0cHEAD,HEAD^,HEAD~100\u8868\u793a\u524d\u4e00\u4e2a\u3001\u524d\u4e24\u4e2a\u3001\u524d100\u4e2a\u7248\u672c
d16f1504a39840ea6962aa3e464a51bd8f72f298
\u662f\u7248\u672c\u53f7\uff0c\u53ef\u4ee5\u5728git log
\u547d\u4ee4\u4e2d\u67e5\u770b\u5982\u679c\u5728\u4e00\u6b21\u56de\u9000\u4e4b\u540e\u60f3\u8981\u56de\u5230\u201c\u672a\u6765\u201d\uff0c\u4f7f\u7528
git relog
, \u53ef\u4ee5\u67e5\u770b\u4e4b\u524d\u7684\u547d\u4ee4"},{"location":"Tools/Git/#_2","title":"\u8fdc\u7a0b\u8fde\u63a5","text":"git reset --hard HEAD\ngit reset --hard d16f1504a39840ea6962aa3e464a51bd8f72f298\n
SSH
\u5173\u8054\u8fdc\u7a0b\u5e93 - origin \u662f\u5f53\u524d\u7684\u4ed3\u5e93\u540d
"},{"location":"Tools/Git/#_3","title":"\u5206\u652f\u7ba1\u7406","text":"git remote add origin ...
\u5206\u79bbHead
\u5206\u79bb\u7684 HEAD \u5c31\u662f\u8ba9\u5176\u6307\u5411\u4e86\u67d0\u4e2a\u5177\u4f53\u7684\u63d0\u4ea4\u8bb0\u5f55\u800c\u4e0d\u662f\u5206\u652f\u540d\u3002
git checkout HEAD
"},{"location":"Tools/Git/#_4","title":"\u5206\u652f\u5408\u5e76","text":"git checkout -b dev // \u521b\u5efa\u5e76\u8df3\u8f6c\n# \u521b\u5efa \u79fb\u52a8\u5206\u652f\ngit branch dev\ngit checkout dev\n# \u79fb\u52a8\u6307\u5b9a\u5206\u652f\u5230\u6307\u5b9a\u4f4d\u7f6e\ngit branch -f main HEAD~3\n\ngit branch // \u67e5\u770b\u5f53\u524d\u5206\u652f\n\n# \u5206\u652f\u5408\u5e76\ngit checkout main\ngit merge dev\n\n# \u5220\u9664\u5206\u652f\ngit branch -d dev\n
\u4e24\u79cd\u65b9\u5f0f
"},{"location":"Tools/Git/#tag","title":"Tag","text":""},{"location":"Tools/Git/#errors","title":"Errors","text":""},{"location":"Tools/Git/#_5","title":"\u51b2\u7a81","text":"git merge
git rebase
stockOverflow
"},{"location":"Tools/Git/#_6","title":"\u5206\u652f","text":"! [rejected] main -> main (non-fast-forward)\nerror: failed to push some refs to 'github.com:zzicarus/zzicarus.github.io.git' \nhint: Updates were rejected because the tip of your current branch is behind \nhint: its remote counterpart. Integrate the remote changes (e.g.\nhint: 'git pull ...') before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details. \n
\u5207\u6362\u5230\u65b0\u5efa\u7684\u5206\u652f\u540e\uff0c\u8fdb\u884cpush\u62a5\u9519
\u9700\u8981\u5c06\u672c\u5730\u65b0\u5efa\u7684\u5206\u652f\u4e0e\u8fdc\u7a0b\u7684\u5206\u652f\u5efa\u7acb\u8fde\u63a5
\u65b9\u6cd51\uff1a
git push --set-upstream origin dev
\u8fd9\u91cc\u7684dev\u662f\u65b0\u7684\u5206\u652f\u65b9\u6cd52\uff1a
"},{"location":"Tools/Git/#_7","title":"\u4ee3\u7406\u95ee\u9898","text":"fatal: The current branch dev has no upstream branch.\nTo push the current branch and set the remote as upstream, use\n\n git push --set-upstream origin dev\n\nTo have this happen automatically for branches without a tracking\nupstream, see 'push.autoSetupRemote' in 'git help config'.\n
\u95ee\u9898
\u7531\u4e8e\u8bbe\u7f6e\u7684\u4ee3\u7406\u4e0e\u5f53\u524d\u7684\u4ee3\u7406\u4e0d\u540c\u3002\u4e00\u822c\u662f\u7ffb\u5899\u4e4b\u540e\uff0c\u7f51\u7edc\u4ee3\u7406\u53d1\u751f\u53d8\u5316\u3002Connection reset by 20.205.243.160 port 443\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n
Solution
\u5173\u4e8e\u4ee3\u7406"},{"location":"Tools/Shell/","title":"tools","text":""},{"location":"Tools/Shell/#shell","title":"Shell","text":"git config --global http.proxy http://127.0.0.1:7890 \ngit config --global https.proxy http://127.0.0.1:7890\n\n# \u53d6\u6d88\u4ee3\u7406\ngit config --global --unset http.proxy\ngit config --global --unset https.proxy\n
\u7ea6 850 \u4e2a\u5b57 42 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
\u73af\u5883\u53d8\u91cf
echo $path
$ which echo\n$ pwd\n$ cd . current\n$ cd .. parent\n
ls -l
drwxr-xr-x
\u662f\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u8868\u793a\u65b9\u5f0f\u4e2d\u7684\u4e00\u90e8\u5206\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cdrwxr-xr-x
\u8868\u793a\u4e00\u4e2a\u76ee\u5f55\u7684\u6743\u9650\u3002
- \u7b2c\u4e00\u4e2a\u5b57\u7b26
d
\u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u76ee\u5f55\u3002\u5982\u679c\u662f\u6587\u4ef6\uff0c\u8be5\u5b57\u7b26\u4f1a\u662f-
\u3002- \u63a5\u4e0b\u6765\u7684\u4e09\u4e2a\u5b57\u7b26
rwx
\u8868\u793a\u6240\u6709\u8005\uff08owner\uff09\u5bf9\u8be5\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0crwx
\u8868\u793a\u6240\u6709\u8005\u5177\u6709\u8bfb\uff08read\uff09\u3001\u5199\uff08write\uff09\u548c\u6267\u884c\uff08execute\uff09\u7684\u6743\u9650\u3002- \u63a5\u4e0b\u6765\u7684\u4e09\u4e2a\u5b57\u7b26
r-x
\u8868\u793a\u7ec4\uff08group\uff09\u5bf9\u8be5\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cr-x
\u8868\u793a\u7ec4\u5177\u6709\u8bfb\u548c\u6267\u884c\u7684\u6743\u9650\uff0c\u4f46\u6ca1\u6709\u5199\u7684\u6743\u9650\u3002- \u6700\u540e\u7684\u4e09\u4e2a\u5b57\u7b26
r-x
\u8868\u793a\u5176\u4ed6\u7528\u6237\u5bf9\u8be5\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cr-x
\u8868\u793a\u5176\u4ed6\u7528\u6237\u5177\u6709\u8bfb\u548c\u6267\u884c\u7684\u6743\u9650\uff0c\u4f46\u6ca1\u6709\u5199\u7684\u6743\u9650\u3002\u56e0\u6b64\uff0c
drwxr-xr-x
\u8868\u793a\u8fd9\u4e2a\u76ee\u5f55\u7684\u6240\u6709\u8005\u5177\u6709\u8bfb\u3001\u5199\u548c\u6267\u884c\u7684\u6743\u9650\uff0c\u7ec4\u548c\u5176\u4ed6\u7528\u6237\u5177\u6709\u8bfb\u548c\u6267\u884c\u7684\u6743\u9650\uff0c\u4f46\u6ca1\u6709\u5199\u7684\u6743\u9650\u3002"},{"location":"Tools/Shell/#streams","title":"streams","text":"
rmdir
mkdir
man
ctrl + L
\u6e05\u9664cat
\u91cd\u5b9a\u5411
missing:~$ echo hello > hello.txt\nmissing:~$ cat hello.txt\nhello\nmissing:~$ cat < hello.txt\nhello\nmissing:~$ cat < hello.txt > hello2.txt\nmissing:~$ cat hello2.txt\nhello\n
\u8ffd\u52a0
>>
pipe |
sudo : super user
"},{"location":"Tools/Shell/#unixroot","title":"\u5173\u4e8eUnix\u4e2d\u7684root\u7528\u6237","text":"\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 ls -l \u6765\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f\n\u4f7f\u7528 chmod \u6765\u4fee\u6539\n
\u5728UNIX\u6216\u7c7bUNIX\u7cfb\u7edf\u4e2d\uff0c\u6bcf\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u90fd\u6709\u4e00\u4e2a\u6240\u6709\u8005\uff08owner\uff09\uff0c\u4e00\u4e2a\u7ec4\uff08group\uff09\u548c\u5176\u4ed6\u7528\u6237\uff08others\uff09\u3002
- \u6240\u6709\u8005\uff08owner\uff09\u662f\u521b\u5efa\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u7528\u6237\u3002\u6240\u6709\u8005\u5bf9\u6587\u4ef6\u6216\u76ee\u5f55\u5177\u6709\u6700\u9ad8\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u8bfb\u53d6\u3001\u5199\u5165\u548c\u6267\u884c\u3002
- \u7ec4\uff08group\uff09\u662f\u4e00\u7ec4\u7528\u6237\uff0c\u53ef\u4ee5\u5171\u4eab\u5bf9\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u8bbf\u95ee\u6743\u9650\u3002\u7ec4\u6210\u5458\u5177\u6709\u4e0e\u7ec4\u76f8\u5173\u8054\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u662f\u8bfb\u53d6\u3001\u5199\u5165\u548c\u6267\u884c\u3002
- \u5176\u4ed6\u7528\u6237\uff08others\uff09\u662f\u9664\u4e86\u6240\u6709\u8005\u548c\u7ec4\u4e4b\u5916\u7684\u6240\u6709\u7528\u6237\u3002\u5176\u4ed6\u7528\u6237\u5177\u6709\u72ec\u7acb\u4e8e\u6240\u6709\u8005\u548c\u7ec4\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u662f\u8bfb\u53d6\u3001\u5199\u5165\u548c\u6267\u884c\u3002
\u4f7f\u7528
chmod
\u547d\u4ee4\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u7f29\u5199\u6765\u6307\u5b9a\u4e0d\u540c\u7528\u6237\u7c7b\u522b\u7684\u6743\u9650\uff1a
u
\u4ee3\u8868\u6240\u6709\u8005\uff08user\uff09\u3002g
\u4ee3\u8868\u7ec4\uff08group\uff09\u3002o
\u4ee3\u8868\u5176\u4ed6\u7528\u6237\uff08others\uff09\u3002\u4f8b\u5982\uff0c
chmod u+rwx,g+rw,o+x file.txt
\u5c06\u4e3a\u6587\u4ef6file.txt
\u5206\u914d\u5982\u4e0b\u6743\u9650\uff1a
- \u6240\u6709\u8005\u5177\u6709\u8bfb\u53d6\u3001\u5199\u5165\u548c\u6267\u884c\u6743\u9650\u3002
- \u7ec4\u5177\u6709\u8bfb\u53d6\u548c\u5199\u5165\u6743\u9650\u3002
- \u5176\u4ed6\u7528\u6237\u5177\u6709\u6267\u884c\u6743\u9650\u3002
\u8fd9\u6837\u7684\u6743\u9650\u8bbe\u7f6e\u5c06\u786e\u4fdd\u4e0d\u540c\u7528\u6237\u7c7b\u522b\u5177\u6709\u9002\u5f53\u7684\u6743\u9650\uff0c\u4ee5\u63a7\u5236\u5bf9\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u8bbf\u95ee\u3002
"},{"location":"Tools/Shell/#bash","title":"Bash \u7f16\u7a0b","text":"
- shell\u4e2d\u7684\u7a7a\u683c\u5341\u5206\u91cd\u8981
foo=bar
foo = bar
\u524d\u8005\u6b63\u5e38\u5de5\u4f5c\uff0c\u540e\u8005\u627e\u4e0d\u5230foo\u547d\u4ee4- \u7f16\u5199shell\u51fd\u6570\u65f6
$0
- \u811a\u672c\u540d$1
\u5230$9
- \u811a\u672c\u7684\u53c2\u6570\u3002$1
\u662f\u7b2c\u4e00\u4e2a\u53c2\u6570\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002$@
- \u6240\u6709\u53c2\u6570$#
- \u53c2\u6570\u4e2a\u6570$?
- \u524d\u4e00\u4e2a\u547d\u4ee4\u7684\u8fd4\u56de\u503c$$
- \u5f53\u524d\u811a\u672c\u7684\u8fdb\u7a0b\u8bc6\u522b\u7801!!
- \u5b8c\u6574\u7684\u4e0a\u4e00\u6761\u547d\u4ee4\uff0c\u5305\u62ec\u53c2\u6570\u3002\u5e38\u89c1\u5e94\u7528\uff1a\u5f53\u4f60\u56e0\u4e3a\u6743\u9650\u4e0d\u8db3\u6267\u884c\u547d\u4ee4\u5931\u8d25\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528sudo !!
\u518d\u5c1d\u8bd5\u4e00\u6b21\u3002$_
- \u4e0a\u4e00\u6761\u547d\u4ee4\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u3002\u5982\u679c\u4f60\u6b63\u5728\u4f7f\u7528\u7684\u662f\u4ea4\u4e92\u5f0f shell\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u6309\u4e0bEsc
\u4e4b\u540e\u952e\u5165 . \u6765\u83b7\u53d6\u8fd9\u4e2a\u503c\u3002\u8fdb\u7a0b\u66ff\u6362
<(CMD)
\u5c06\u4f1a\u6267\u884cCMD\u5e76\u5c06\u7ed3\u679c\u8f93\u51fa\u5230\u4e00\u4e2a\u4e34\u65f6\u6587\u4ef6\u4e2d\uff0c\u5e76\u5c06<(CMD)
\u66ff\u6362\u4e3a\u4e34\u65f6\u6587\u4ef6\u540d\u3002\u6ce8\u610f\uff0c\u8fd4\u56de\u503c\u901a\u8fc7\u6587\u4ef6\u800c\u4e0d\u662fSTDOUT#!/bin/bash\n\necho \"Starting program at $(date)\" # date\u4f1a\u88ab\u66ff\u6362\u6210\u65e5\u671f\u548c\u65f6\u95f4\n\necho \"Running program $0 with $# arguments with pid $$\"\n\nfor file in \"$@\"; do\n grep foobar \"$file\" > /dev/null 2> /dev/null\n # \u5982\u679c\u6a21\u5f0f\u6ca1\u6709\u627e\u5230\uff0c\u5219grep\u9000\u51fa\u72b6\u6001\u4e3a 1\n # \u6211\u4eec\u5c06\u6807\u51c6\u8f93\u51fa\u6d41\u548c\u6807\u51c6\u9519\u8bef\u6d41\u91cd\u5b9a\u5411\u5230Null\uff0c\u56e0\u4e3a\u6211\u4eec\u5e76\u4e0d\u5173\u5fc3\u8fd9\u4e9b\u4fe1\u606f\n if [ \"\"$?\" -ne 0 ]( \"\"$?\" -ne 0 .md){#d2c9477a5ae1eaf7dda2777e66b04317}; then\n echo \"File $file does not have any foobar, adding one\"\n echo \"# foobar\" >> \"$file\"\n fi\ndone\n
There`s a
test
to check\u901a\u914d\u7b26
"},{"location":"Tools/Shell/#prompt","title":"prompt","text":"ls *.py\nls project?\n{}\n
xargs
"},{"location":"Tools/Shell/#instance","title":"Instance","text":"#!/bin/bash\n# Test run in Git bash\n\ndate1=\"2021 02 03\"\ncontent=\"today\\nI get a little bit happy\\n\"\n\necho \"hello\"\necho \"--- Running to Get the Exe ---\"\n# gcc source/pdRemove.cpp source/pd.cpp -o pdRemove -lstdc++\n# gcc source/pdAdd.cpp source/pd.cpp -o pdAdd -lstdc++\n# gcc source/pdList.cpp source/pd.cpp -o pdList -lstdc++\n# gcc source/pdShow.cpp source/pd.cpp -o pdShow -lstdc++\necho \"--- Complete ---\"\n\n# \u5c06\u811a\u672c\u4e2d\u7684\u5185\u5bb9\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9pdAdd\u547d\u4ee4\necho -e \"$date1\\n$content\" | xargs ./pdAdd\n
\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528echo -e\u6765\u6253\u5370\u5b57\u7b26\u4e32\uff0c\u5e76\u4f7f\u7528\u7ba1\u9053\u7b26\uff08|\uff09\u5c06\u5176\u91cd\u5b9a\u5411\u5230xargs\u547d\u4ee4\u7684stdin\u3002\u7136\u540e\uff0cxargs\u547d\u4ee4\u5c06\u8fd9\u4e9b\u8f93\u5165\u6570\u636e\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9pdAdd\u547d\u4ee4
"},{"location":"Tools/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/","title":"\u6b63\u5219\u8868\u8fbe\u5f0f","text":"\u7ea6 6 \u4e2a\u5b57
"},{"location":"Tools/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/#_2","title":"\u6b63\u5219\u8868\u8fbe\u5f0f","text":""},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/","title":"\u535a\u5ba2\u642d\u5efa","text":"\u7ea6 566 \u4e2a\u5b57 108 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 4 \u5206\u949f
Abstract
\u8bb0\u5f55\u642d\u5efa MkDocs \u7684\u8fc7\u7a0b
\u53c2\u8003\u6587\u6863\uff1a
Material for mkdocs
\u77e5\u4e4e
Task
- \u521d\u6b65\u642d\u5efa\u5e73\u53f0
- \u642d\u5efa\u7b14\u8bb0\u6846\u67b6
- \u4e0a\u4f20\u7b14\u8bb0
- \u5bf9\u9875\u9762\u7f8e\u5316\uff0c\u98ce\u683c\u5316
- \u9875\u9762\u7f8e\u5316
- \u5b57\u6570\u7edf\u8ba1
- Comment\u7cfb\u7edf
Question
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_2","title":"\u9884\u4e0b\u8f7d","text":"
- \u591a\u4e2a H1 \u7684\u60c5\u51b5\uff0c\u6e32\u67d3\u4f1a\u51fa\u9519\uff1a\u4e3b\u8981\u662f\u53f3\u4fa7\u5bfc\u822a\u680f\u7684\u6e32\u67d3
\u4e3a\u4e86\u6210\u529f\u642d\u5efa\uff0c\u4f60\u9700\u8981\u5982\u4e0b\u9884\u5907\uff1a
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#material","title":"Material","text":"
- python \u73af\u5883\uff0c\u5e76\u4e14\u5b89\u88c5\u597d\u4e86 pip
- \u4e86\u89e3\u57fa\u672c\u7684 git \u8bed\u6cd5\uff08online \u90e8\u7f72\uff09
- \u4e86\u89e3\u57fa\u672c\u7684 md \u8bed\u6cd5
\u7531\u4e8e
MkDocs
\u7684\u539f\u7248\u4e3b\u9898\u786e\u5b9e\u4e0d\u592a\u597d\u770b\uff0c\u6240\u4ee5\u8fd9\u91cc\u4f7f\u7528\u4e86Material For MkDocs
\u8fdb\u884c\u4f18\u5316"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#github-page","title":"Github Page \u7684\u90e8\u7f72","text":"mkdocs new // \u65b0\u5efa\u4e00\u4e2aMkDocs\n\nmkdocs serve // \u5efa\u7acb\u4e00\u4e2a\u9884\u89c8\n\nmkdocs build // \u5efa\u7acb\u4e00\u4e2a\u9759\u6001\u7f51\u9875\n
- \u81ea\u52a8\u90e8\u7f72\u9700\u8981\u5728
.github\\workflows
\u4e2d\u52a0\u5165ci.yml
\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_3","title":"\u529f\u80fd","text":"name: ci\non:\n push:\n branches:\n - master\n - main\npermissions:\n contents: write\njobs:\n deploy:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n - name: Configure Git Credentials\n run: |\n git config user.name github-actions[bot]\n git config user.email 41898282+github-actions[bot]@users.noreply.github.com\n - uses: actions/setup-python@v4\n with:\n python-version: 3.x\n - run: echo \"cache_id=$(date --utc '+%V')\" >> $GITHUB_ENV\n - uses: actions/cache@v3\n with:\n key: mkdocs-material-${{ env.cache_id }}\n path: .cache\n restore-keys: |\n mkdocs-material-\n - run: pip install mkdocs-material\n - run: mkdocs gh-deploy --force\n
\u4ecb\u7ecd
\u8fd9\u91cc\u6211\u9009\u4e86\u51e0\u4e2a\u81ea\u5df1\u4e4b\u540e\u5e94\u8be5\u5e38\u7528\u7684\uff0c\u8bb0\u4e00\u4e0b\u7528\u6cd5
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_4","title":"\u9009\u9879\u5361","text":""},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_5","title":"\u5206\u7ec4\u4ee3\u7801\u5757","text":"CC++=== \"C\"\n\n ``` c\n #include <stdio.h>\n\n int main(void) {\n printf(\"Hello world!\\n\");\n return 0;\n }\n ```\n\n=== \"C++\"\n\n ``` c++\n #include <iostream>\n\n int main(void) {\n std::cout << \"Hello world!\" << std::endl;\n return 0;\n }\n ```\n
#include <stdio.h>\n\nint main(void) {\n printf(\"Hello world!\\n\");\n return 0;\n}\n
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_6","title":"\u5d4c\u5165\u683c\u5f0f","text":"#include <iostream>\n\nint main(void) {\n std::cout << \"Hello world!\" << std::endl;\n return 0;\n}\n
\u5d4c\u5165
Unordered ListOrdered List* Sed sagittis eleifend rutrum\n* Donec vitae suscipit est\n* Nulla tempor lobortis orci\n
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#box","title":"box","text":"1. Sed sagittis eleifend rutrum\n2. Donec vitae suscipit est\n3. Nulla tempor lobortis orci\n
From
\u8fd9\u4e00\u90e8\u5206\u662f\u4ecexyjj \u7684 Page\u770b\u5230\u7684
<span class=\"box box-blue\">blue</span>\n<span class=\"box box-green\">green</span>\n<span class=\"box box-red\">red</span>\n<span class=\"box box-yellow\">yellow</span>\n<span class=\"box box-gray\">gray</span>\n
blue green red yellow gray
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_7","title":"\u5b57\u6570\u7edf\u8ba1","text":"\u76f4\u63a5\u4f7f\u7528\u4e86\u4e00\u4f4d\u5b66\u957f\u7684\u63d2\u4ef6
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#vsc","title":"\u4f18\u5316 vsc \u4e2d\u7684\u5de5\u4f5c\u6d41\u7a0b","text":"
- \u5feb\u6377\u952e Markdown ShortCuts \u63d2\u4ef6
- \u81ea\u5b9a\u4e49 Snippet
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_8","title":"\u4e00\u4e9b\u7528\u6cd5 | \u6d4b\u8bd5\u683c\u5f0f","text":""},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#code-block","title":"Code Block","text":"\"Color Box\": {\n \"prefix\": \"box\",\n \"body\": [\n \"<span class=\\\"box box-${1|blue,red,green,yellow|}\\\">$2</span>\",\n \"$3\",\n ],\n \"description\": \"Inserts a colored box span\"\n },\n \"Prompt\": {\n \"prefix\": \"annotation\",\n \"body\": [\n \"!!! ${1|note,info,abstract,tip,success,quote,question,warning,bug,example,failure|} \\\"$2\\\"\",\n \"\\t$3\",\n ],\n \"description\": \"Inserts an annotation\"\n },\n
- \u7a81\u51fa\u663e\u793a\u7279\u5b9a\u884c
def bubble_sort(items):\n for i in range(len(items)):\n for j in range(len(items) - 1 - i):\n if items[j] > items[j + 1]:\n items[j], items[j + 1] = items[j + 1], items[j]\n
```py hl_lines=\"2 3\"\ndef bubble_sort(items):\n for i in range(len(items)):\n for j in range(len(items) - 1 - i):\n if items[j] > items[j + 1]:\n items[j], items[j + 1] = items[j + 1], items[j]\n```\n
- \u9ad8\u4eae\u5185\u90e8\u4ee3\u7801
The `#!python range()` function is used to generate a sequence of numbers.\n
The
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#md","title":"md \u683c\u5f0f\u7684\u8c03\u6574","text":"range()
function is used to generate a sequence of numbers.\u4ee3\u7801\u89c1 CSS \u90e8\u5206
- \u6709\u5e8f\u5217\u8868
- \u6709\u5e8f\u5217\u8868
- \u65e0\u5e8f\u5217\u8868
\u659c\u4f53
\u52a0\u7c97
\u5f15\u7528
\u94fe\u63a5
\u4e0b\u9762\u7684\u662f\u4e00\u4e9b\u62d3\u5c55\u7684\uff0c\u5728 markdown - extension \u4e2d\u53ef\u4ee5\u9009\u62e9\u52a0\u5165\uff08\u5efa\u8bae\u8bfb\u5b98\u65b9\u6587\u6863\uff09
:bread:\n~~\u5220\u9664~~\n==\u7a81\u51fa\u663e\u793a==\n^^\u63d2\u5165^^\n
\u5220\u9664
\u7a81\u51fa\u663e\u793a
\u63d2\u5165
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#todo-mermaid","title":":Todo: Mermaid \u5e8f\u5217\u56fe","text":"\u8fd9\u91cc\u53d1\u73b0\u683c\u5f0f\u5e76\u4e0d\u662f\u5f88\u597d\uff0c\u4e4b\u540e\u6709\u65f6\u95f4\u4e86\u518d\u4fee\u6539 Mermaid \u7684\u914d\u7f6e\u5427\u3002\u800c\u4e14 Mermaid \u7684\u6e32\u67d3\u6709\u70b9\u6162\uff1f\uff08
https://mermaid.js.org/syntax/flowchart.html
note
flowchart LR\nsubgraph subgraph1\ndirection TB\ntop1[top] --> bottom1[bottom]\nend\nsubgraph subgraph2\ndirection TB\ntop2[top] --> bottom2[bottom]\nend\n Link *to* subgraph1: subgraph1 direction is maintained\n outside --> subgraph1\n subgraph2 inherits the direction of the top-level graph (LR)\n outside ---> top2\n ```\n\n### annotation\n\n```md\n!!! \u6216\u8005 ???\n???+ \u6298\u53e0\uff0c\u9ed8\u8ba4\u5c55\u5f00\u72b6\u6001
Note
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
info
info
abstract
abstract
tip
octicons/squirrel-16
successsuccess
quotequote
questionquestion
warningwarning
bugbug
example
example
failure
failure
"},{"location":"_templates/_README/","title":"None","text":"\u7ea6 0 \u4e2a\u5b57
"},{"location":"_templates/_changelog/","title":"changelog","text":"\u7ea6 20 \u4e2a\u5b57
"},{"location":"_templates/_changelog/#general","title":"General","text":""},{"location":"_templates/_changelog/#blog","title":"Blog","text":""},{"location":"_templates/_changelog/#meta","title":"Meta","text":""},{"location":"_templates/_changelog/#obsidian","title":"Obsidian","text":""},{"location":"_templates/_changelog/#social","title":"Social","text":""},{"location":"_templates/_changelog/#minifier","title":"Minifier","text":""},{"location":"_templates/_changelog/#debugger","title":"Debugger","text":"Legend
\u274e - added \u2705 - fixed \u267b\ufe0f - changed \ud83d\udeab - removed
"},{"location":"_templates/_page/","title":"None","text":"\u7ea6 0 \u4e2a\u5b57
"},{"location":"_templates/_post/","title":"None","text":"\u7ea6 21 \u4e2a\u5b57
"},{"location":"_templates/_post/#changelog","title":"Changelog","text":""},{"location":"_templates/_post/#general","title":"General","text":""},{"location":"_templates/_post/#blog","title":"Blog","text":""},{"location":"_templates/_post/#meta","title":"Meta","text":""},{"location":"_templates/_post/#obsidian","title":"Obsidian","text":""},{"location":"_templates/_post/#social","title":"Social","text":""},{"location":"_templates/_post/#minifier","title":"Minifier","text":""},{"location":"_templates/_post/#debugger","title":"Debugger","text":"Legend
\u274e - added \u2705 - fixed \u267b\ufe0f - changed \ud83d\udeab - removed
"},{"location":"others/","title":"Index","text":"\u7ea6 12 \u4e2a\u5b57
Abstract
\u8fd9\u91cc\u653e\u4e00\u4e9bCS\u4e4b\u5916\u7684\u4e1c\u897f
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/","title":"\u5927\u5b66\u7269\u7406\u5b9e\u9a8c","text":"\u7ea6 484 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
\u4ecb\u7ecd
\u603b\u4f53
\u8fd9\u95e8\u8bfe\u600e\u4e48\u8bf4\u5462\uff0c\u611f\u89c9\u4ef7\u503c\u4e0d\u5927\u3002 \u4ee4\u4eba\u8bdf\u75c5\u7684\u624b\u6284\u62a5\u544a\u3001\u4e0e\u7406\u8bba\u5b8c\u5168\u4e0d\u5339\u914d\u7684\u8fdb\u5ea6\uff0c\u5bf9\u4e8e\u5f88\u591a\u4e0a\u8fd9\u95e8\u8bfe\u7a0b\u7684\u540c\u5b66\u6765\u8bf4\uff0c\u5f88\u53ef\u80fd\u4e4b\u540e\u4e0d\u5927\u4f1a\u7528\u5f97\u5230\u7269\u7406\uff08
\u6210\u7ee9\u6784\u6210
- 60% \u5e73\u65f6\u5b9e\u9a8c\u7684\u5e73\u5747
- 40% \u671f\u672b\u8003\u8bd5
\u8bfe\u7a0b\u8d44\u6599
\u7535\u5b50\u8bfe\u672c \u5927\u5b66\u7269\u7406\u5b9e\u9a8c (\u674e\u6d77\u6d0b) (Z-Library) (1).pdf
\u5f80\u5c4a\u7684\u90e8\u5206\u53c2\u8003 xyjj\u7684Page
\u671f\u672b\u590d\u4e60
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_2","title":"\u7eea\u8bba","text":""},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_3","title":"\u5b9e\u9a8c\u6d4b\u91cf\u4e0e\u8bef\u5dee","text":""},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_4","title":"\u6d4b\u91cf","text":"
- \u6700\u7ec8\u7ed3\u679c\u7684\u8868\u8ff0
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_5","title":"\u4e0d\u540c\u4eea\u5668\u4f7f\u7528","text":"
\u6d4b\u91cf
\u88ab\u6d4b\u5bf9\u8c61\u3001\u6d4b\u91cf\u7a0b\u5e8f\u3001\u6d4b\u91cf\u51c6\u786e\u5ea6\u548c\u8ba1\u91cf\u5355\u4f4d\u6709\u6548\u4f4d\u6570
\u6709\u6548\u6570\u5b57\u7684\u4f4d\u6570\u6709\u6548\u6570\u5b57
=\u53ef\u9760\u6570\u5b57\uff08\u76f4\u63a5\u8bfb\uff09
+\u4e00\u4f4d\u5b58\u7591\u6570\u5b57\uff08\u4f30\u8bfb\uff09
\u6e38\u6807\u5361\u5c3a
\u87ba\u65cb\u6d4b\u5fae\u5668 \u5206\u5ea6\u5c3a
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_6","title":"\u8bef\u5dee","text":"
- \u6ce8\u610f\u5916\u90e8\u523b\u5ea6\u548c\u5185\u90e8\u523b\u5ea6
\u8868\u793a
\u7edd\u5bf9\u8bef\u5dee = \u6d4b\u91cf - \u771f\u503c\uff08\u4e00\u822c\u4f1a\u662f\u7ea6\u5b9a\u4fd7\u6210\u7684\u503c\uff09
- \u76f8\u5bf9\u8bef\u5dee \uff08\u767e\u5206\u8bef\u5dee\uff09
E = | \u6d4b\u91cf - \u771f\u503c | / \u771f\u503c * 100 %
- \u6807\u51c6\u8bef\u5dee
\u5206\u7c7b
\u7cfb\u7edf\u8bef\u5dee
- \u5df2\u5b9a\u7cfb\u7edf\u8bef\u5dee\uff08\u4eea\u5668\u672c\u8eab\uff09
- \u672a\u5b9a\u7cfb\u7edf\u8bef\u5dee\uff08\u793a\u503c\u8bef\u5dee\uff09
- \u968f\u673a\u8bef\u5dee - \u4e0d\u53ef\u4fee\u6b63
- \u7c97\u5927\u8bef\u5dee
- ** \u8bef\u5dee\u5206\u5e03
\u6b63\u6001\u5206\u5e03
- \u6807\u51c6\u5dee
- \u6570\u5b66\u671f\u671b\u503c - \u8fd1\u4f3c\u771f\u503c
- \u6807\u51c6\u504f\u5dee\uff08\u5355\u6b21\u6d4b\u91cf\u503c\uff09
- \u5e73\u5747\u503c\u7684\u6807\u51c6\u504f\u5dee
- \u5355\u5cf0 \u5bf9\u79f0 \u6709\u754c \u62b5\u507f
\u5747\u5300\u5206\u5e03
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_7","title":"\u8bef\u5dee\u4e0e\u4e0d\u786e\u5b9a\u5ea6","text":"
- \u7cbe\u5bc6\u5ea6\u4e0e\u51c6\u786e\u5ea6
\u603b\u4e0d\u786e\u5b9a\u5ea6
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_8","title":"\u6807\u51c6\u4e0d\u786e\u5b9a\u5ea6","text":"A\u7c7b\uff1a\u7528\u7edf\u8ba1\u65b9\u6cd5\u8bc4\u5b9a B\u7c7b\uff1a\u7528\u5176\u4ed6\u65b9\u6cd5\u8bc4\u5b9a
- \u76f4\u63a5\u6d4b\u91cf
- A \u7c7b
6 \u2264 n \u226410\uff0c\u7f6e\u4fe1\u6982\u7387\u4e3a68.3%
- B \u7c7b
\u5b9e\u4f8b
- \u95f4\u63a5\u6d4b\u91cf\uff08\u5408\u6210\u6807\u51c6\u4e0d\u786e\u5b9a\u5ea6\uff09
- \u548c\u5dee\u5f62\u5f0f
- \u79ef\u5546\u5f62\u5f0f
\u5b9e\u4f8b
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_9","title":"\u6709\u6548\u6570\u5b57","text":""},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_10","title":"\u4fee\u7ea6","text":"
- \u53d6\u5076\u6cd5\u5219 \u5728\u6709\u591a\u4e2a\u6700\u63a5\u8fd1\u7684\u503c\u65f6\uff0c\u4e00\u822c\u53d6\u4fee\u7ea6\u533a\u95f4\u7684\u5076\u6570\u500d
\u4e0d\u5141\u8bb8\u8fde\u7eed\u4fee\u7ea6 \u4f8b\u5b502.2500 -> 2.2 \u6709\u6548\u6570\u5b57\u7684\u8868\u793a\u6cd5
\u53d6\u5076\u6cd5\u5219 \u5728\u6709\u591a\u4e2a\u6700\u63a5\u8fd1\u7684\u503c\u65f6\uff0c\u4e00\u822c\u53d6\u4fee\u7ea6\u533a\u95f4\u7684\u5076\u6570\u500d
- \u6709\u6548\u6570\u5b57\u7684\u4f4d\u6570\u591a\u5c11\u76f4\u63a5\u53cd\u6620\u6d4b\u91cf\u7684\u51c6\u786e\u5ea6\u3002\u6709\u6548\u4f4d\u6570 \u8d8a\u591a\uff0c\u8868\u660e\u6d4b\u91cf\u7684\u51c6\u786e\u5ea6\u8d8a\u9ad8\u3002
- \u6709\u6548\u6570\u503c\u4e66\u5199\u65f6\u5e94\u6ce8\u610f\uff1a\u6709\u6548\u6570\u503c\u7684\u4f4d\u6570\u4e0e\u5c0f\u6570\u70b9\u4f4d\u7f6e \u65e0\u5173\u3002\u4e0d\u56e0\u4f7f\u7528\u7684\u5355\u4f4d\u4e0d\u540c\u800c\u6539\u53d8\u3002
- \u5728
\u8fd0\u7b97\u8fc7\u7a0b
\u4e2d\u7684\u6709\u6548\u6570\u5b57\u53d6\u820d\uff0c \u4e00\u822c\u9075\u5faa\uff1a \u52a0\u51cf\u8fd0\u7b97\u7684\u7ed3\u679c\u4ee5\u53c2\u4e0e\u8fd0\u7b97\u7684\u672b\u4f4d\u6700\u9ad8\u7684\u6570\u4e3a\u51c6\uff1a\u4e58\u9664\u5219\u4ee5_\u6709\u6548\u6570\u5b57\u6700\u5c11_\u7684\u6570\u4e3a\u51c6\u3002\u4e0d\u786e\u5b9a\u5ea6\u4fee\u7ea6\u6cd5\u5219
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_11","title":"\u6570\u503c\u4e66\u5199","text":"
- \u60f3\u8981\u4fdd\u7559\u7684\u6700\u4f4e\u4e3a\u4e4b\u540e\u7684\u4e00\u4f4d\u6570\u4e0d\u662f 0 \u5c31\u8fdb\u4f4d\u5426\u5219\u820d\u53bb
- \u4f4d\u6570\u7531\u5408\u6210\u4e0d\u786e\u5b9a\u5ea6\u51b3\u5b9a\u3002
- \u5408\u6210\u4e0d\u786e\u5b9a\u5ea6\uff1a\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u9996\u4f4d\u5927\u4e8e\u7b49\u4e8e 3 \u53ea\u53d6\u4e00\u4f4d\uff0c\u5426\u5219\u53d6 2 \u4f4d
\u540c\u65f6\uff0c\u6d4b\u91cf\u503c\u7684\u6700\u540e\u4e00\u4f4d\u5e94\u8be5\u548c\u4e0d\u786e\u5b9a\u5ea6\u7684\u6700\u540e\u4e00\u4f4d\u5bf9\u9f50 \u8ba1\u7b97\u4e0d\u786e\u5b9a\u5ea6 -> \u4e0d\u786e\u5b9a\u5ea6\u4fee\u7ea6\uff08\u00bd\uff09 ->
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/","title":"\u5fae\u89c2\u7ecf\u6d4e\u5b66","text":"\u7ea6 474 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
\u672c\u7b14\u8bb0\u7c97\u5236\u6ee5\u9020\uff0c\u5199\u7684\u4e0d\u662f\u5f88\u8be6\u7ec6\uff0c\u66f4\u591a\u662f\u5f53\u65f6\u4e3a\u4e86\u5e2e\u52a9\u81ea\u5df1\u68b3\u7406\u3002\u8bf7\u5ba1\u614e\u89c2\u770b
Abstract
\u6388\u8bfe\u6559\u5e08: \u8d56\u666e\u6e05
\u2665 \u975e\u5e38\u597d\u7b14\u8bb0\uff0c\u7231\u6765\u81ea\u6d59\u5927 \u2665
\u4e00\u4efd\u524d\u8f88\u7684\u7b14\u8bb0
\u5fae\u89c2\u7ecf\u6d4e\u5b66\uff08\u4e0a\uff09
\u5fae\u89c2\u7ecf\u6d4e\u5b66\uff08\u4e0b\uff09
\u4e00\u4e9b\u8bfe\u7a0b\u8d44\u6e90\uff1a
\u7eff\u76ae\u4e66\uff08\u5f3a\u70c8\u63a8\u8350\uff01\uff09 \u5fae\u89c2\u7ecf\u6d4e\u5b66\u6559\u7a0b (\u6d59\u6c5f\u5927\u5b66\u73b0\u4ee3\u7ecf\u6d4e\u5b66\u4e1b\u4e66) (\u674e\u5efa\u7434) (Z-Library).pdf
\u7b54\u6848 \u5fd8\u8bb0\u5b58\u5728\u54ea\u91cc\u4e86\uff0c98\u7248\u641c\u5427(
\u3010ljq \u667a\u4e91\u5750\u6807\u3011 \u667a\u4e91\u8bfe\u5802
\u8bfe\u7a0b\u6210\u7ee9\u76f8\u5173
\u5e73\u65f6 40%
\u4f5c\u4e1a\uff08\u5b66\u5728\u6d59\u5927\uff09
\u51fa\u52e4\uff08\u7ebf\u4e0b\uff09
\u671f\u672b 60% - \u95ed\u5377\uff08\u96be\u5ea6\u8fd1\u4f5c\u4e1a\uff09
\u8865\u5145\uff1a\u8fd9\u91cc\u7684\u96be\u5ea6\u662f\u6307\u8ba1\u7b97\u9898\uff0c\u6bd5\u7adf\u5e73\u65f6\u7684\u4f5c\u4e1a\u4e5f\u6ca1\u6709\u9009\u62e9\u9898\uff0c\u7b80\u7b54\u4e5f\u5c31\u5076\u5c14\u4e00\u9053\uff1b\u4e2a\u4eba\u611f\u89c9\u671f\u672b\u7684\u9009\u62e9\u9898\u8003\u7684\u8fd8\u633a\u7ec6\uff0c\u5f88\u591a\u6982\u5ff5\u90fd\u6a21\u68f1\u4e24\u53ef\u7684\uff08\n
\u9009\u62e9\u9898(\u7ea620%)\u3001\u8ba1\u7b97\u9898(\u7ea630% )\u3001\u7b80\u7b54\u9898(\u7ea630%)\u3001\u7efc\u5408\u5206\u6790\u9898(\u7ea620% )
Tips
\u8fd9\u95e8\u8bfe\u7684\u5e73\u65f6\u5b66\u4e60\u7684\u8d1f\u62c5\u5e76\u4e0d\u662f\u5f88\u5927\uff0c\u4e00\u4e2a\u5b66\u671f\u603b\u7684\u4f5c\u4e1a\u6b21\u6570\u4e5f\u5e76\u4e0d\u591a\u3002(\u8fd9\u4e5f\u95f4\u63a5\u5bfc\u81f4\u6211\u6bcf\u6b21\u53ea\u628a\u4f5c\u4e1a\u4e0a\u7684\u8ba1\u7b97\u9898\u641e\u5b8c\u5c31\u5b8c\u4e8b\u513f\u4e86)\u7b14\u8005\u540e\u671f\u4e0a\u8bfe\u8d8a\u6765\u8d8a\u6446\u70c2\uff0c\u4e0a\u8bfe\u4e0d\u542c\uff0c\u4e0b\u8bfe\u8865\u8bfe\u4e5f\u4e0d\u662f\u5f88\u53ca\u65f6\uff0c\u6700\u540e\u8865\u5929\u8fd8\u662f\u633a\u75db\u82e6\u7684 QAQ\u3002
\u5982\u679c\u60f3\u8981\u6210\u7ee9\u9ad8\u4e00\u70b9\u7684\u8bdd\uff0c\u5efa\u8bae\u8981\u4e48\u4e0a\u8bfe\u8ddf\u7740\u8001\u5e08\u597d\u597d\u542c\uff08\u627e\u4e00\u4e2a\u8bb2\u5f97\u597d\u4e00\u70b9\u7684\u8001\u5e08\uff09\uff0c\u8981\u4e48\u8ba4\u771f\u770b\u4e00\u770b\u7eff\u76ae\u4e66
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/","title":"\u4ef7\u683c\u673a\u5236","text":"\u7ea6 426 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_2","title":"\u533a\u5206\u6982\u5ff5","text":"
- \u9700\u6c42\u548c\u6b32\u671b \u9700\u6c42\u4e0e\u6b32\u671b\uff08Wants\uff09\u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u6982\u5ff5\u3002\u6b32\u671b\u6216\u8d2d\u4e70\u6b32\u671b\u662f\u6307\u4eba\u4eec\u5bf9\u67d0\u79cd\u7269\u54c1\u611f\u5230\u7f3a\u4e4f\uff0c\u5e0c\u671b\u5f97\u5230\u7684\u4e00\u79cd\u5fc3\u7406\u73b0\u8c61\uff0c\u800c\u9700\u6c42\u5219\u662f\u5177\u6709\u8d2d\u4e70\u80fd\u529b\u7684\u6709\u6548\u9700\u6c42\u3002 \u4e5f\u5c31\u662f
\u9700\u6c42 = \u6b32\u671b + \u8d2d\u4e70\u80fd\u529b
- \u9700\u6c42\u548c\u9700\u6c42\u91cf \u9700\u6c42\u91cf\u5fc5\u987b\u8981\u6709\u4e00\u5b9a\u7684\u65f6\u95f4\u9650\u5236 \u800c\u4e14\u9700\u6c42\u662f\u6240\u6709\u4ef7\u683c\u6c34\u5e73\uff1b\u9700\u6c42\u91cf\u662f\u9488\u5bf9\u67d0\u4e00\u7279\u5b9a\u4ef7\u683c\u6c34\u5e73 \u9700\u6c42\u7684\u53d8\u5316 \u4ef7\u683c\u4e4b\u5916\u7684\u56e0\u7d20\uff1b\u66f2\u7ebf\u6574\u4f53 \u9700\u6c42\u91cf\u7684\u53d8\u5316 \u4ef7\u683c\u7684\u53d8\u5316\u5f15\u8d77\uff1b\u5355\u4e2a\u70b9
- \u66ff\u4ee3\u4ea7\u54c1\u548c\u4e92\u8865\u4ea7\u54c1
\u66ff\u4ee3\u4ea7\u54c1\uff1a\u4ea4\u66ff\u4f7f\u7528\u80fd\u591f\u6ee1\u8db3\u4eba\u4eec\u540c\u4e00\u9700\u6c42\u6216\u76f8\u4f3c\u9700\u6c42\u7684\u5546\u54c1\u3002 \u4e92\u8865\u4ea7\u54c1\uff1a\u914d\u5408\u4f7f\u7528
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_3","title":"\u9700\u6c42","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_4","title":"\u523b\u753b\u9700\u6c42","text":"
- \u6b63\u5e38\u5546\u54c1\u548c\u4f4e\u6863\u5546\u54c1 \u6d88\u8d39\u8005\u6536\u2f0a\u2f54\u5e73\u7684\u53d8\u5316\u4f1a\u5f15\u8d77\u5176\u5bf9\u67d0\u79cd\u5546\u54c1\u7684\u9700\u6c42\u53d1\u2f63\u540c\u2f45\u5411\u6216\u53cd\u2f45\u5411\u53d8\u5316\u3002\u5982\u679c\u6d88\u8d39\u8005\u6536\u2f0a\u2f54\u5e73\u7684\u53d8\u5316\u5f15\u8d77\u5bf9\u67d0\u79cd\u5546\u54c1\u7684\u9700\u6c42\u53d1\u2f63\u540c\u2f45\u5411\u53d8\u5316\uff0c\u5219\u8be5\u5546\u54c1\u662f\u6b63\u5e38\u5546\u54c1\uff08Normal Goods\uff09\uff1b\u5982\u679c\u6d88\u8d39\u8005\u6536\u2f0a\u2f54\u5e73\u7684\u53d8\u5316\u5f15\u8d77\u5bf9\u67d0\u79cd\u5546\u54c1\u7684\u9700\u6c42\u53d1\u2f63\u53cd\u2f45\u5411\u53d8\u5316\uff0c\u5219\u8be5\u5546\u54c1\u662f\u4f4e\u6863\u5546\u54c1\uff08Inferior Goods\uff09\u3002
image.png
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_5","title":"\u4e2a\u522b\u9700\u6c42\u548c\u5e02\u573a\u9700\u6c42","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_6","title":"\u4f9b\u7ed9","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_7","title":"\u523b\u753b","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_8","title":"\u5747\u8861\u4ef7\u683c","text":"
**\u4e2a\u522b\u9700\u6c42**
\u662f\u6307\u5355\u4e2a\u6d88\u8d39\u8005\u5728\u2f00\u5b9a\u65f6\u95f4\u5185\u5728\u6bcf\u2f00\u4e2a\u4ef7\u683c\u2f54\u5e73 \u4e0a\u5bf9\u67d0\u79cd\u5546\u54c1\u7684\u9700\u6c42\u91cf\u3002**\u5e02\u573a\u9700\u6c42**
\u5728\u2f00\u4e2a\u7279\u5b9a\u7684\u5e02\u573a\u4e2d\uff0c\u6240\u6709\u6d88\u8d39\u8005\u5728\u2f00\u5b9a\u65f6\u95f4\u5185\u5bf9\u67d0\u79cd\u5546\u54c1\u7684\u9700 \u6c42\u7684\u603b\u548c\uff0c\u79f0\u4e4b\u4e3a\u5e02\u573a\u9700\u6c42\uff08Market Demand\uff09\u3002"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/","title":"Chapter 2 \u6d88\u8d39\u8005\u7406\u8bba","text":"
- \u4e00\u4e2a\u5c0f\u65b9\u6cd5\uff1a\u76f4\u63a5\u8003\u8651\u6781\u9650\u7684\u60c5\u51b5
\u7ea6 1616 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 8 \u5206\u949f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_1","title":"\u57fa\u6570\u6548\u7528\uff1a\u8fb9\u9645\u6548\u7528\u5206\u6790","text":"\u6548\u7528\uff08utility\uff09\uff1a\u6d88\u8d39\u8005\u6d88\u8d39\u67d0\u79cd\u5546\u54c1\u6216\u52b3\u52a1\u800c\u5f97\u5230\u7684\u6ee1\u8db3\u3002\u5546\u54c1\u672c\u8eab\u7684\u6709\u7528\u6027\u6216\u4f7f\u7528\u4ef7\u503c\uff0c\u66f4\u662f\u6d88\u8d39\u8005\u5bf9\u6240\u6d88\u8d39\u5546\u54c1\u6216\u52b3\u52a1\u6ee1\u8db3\u81ea\u8eab\u6b32\u671b\u80fd\u529b\u7684\u4e00\u79cd\u4e3b\u89c2\u5fc3\u7406\u611f\u53d7\u6216\u8bc4\u4ef7 \u57fa\u6570\u6548\u7528\uff08Cardinal Utility\uff09\u7406\u8bba\u8ba4\u4e3a\uff0c\u4e00\u79cd\u5546\u54c1\u5bf9\u6d88\u8d39\u8005\u7684\u6548\u7528\u662f\u53ef\u4ee5\u7528\u57fa\u65701\uff0c2\uff0c3\uff0c4\u2026\u2026\u52a0\u4ee5\u6d4b\u91cf\uff0c\u5e76\u8ba1\u603b\u6c42\u548c\u7684\u3002 \u603b\u6548\u7528\uff08Total Utility, TU\uff09\u662f\u6307\u6d88\u8d39\u8005\u5728\u4e00\u5b9a\u65f6\u671f\u5185\u6d88\u8d39\u4e00\u5b9a\u91cf\u67d0\u5546\u54c1\u800c\u5f97\u5230\u7684\u6548\u7528\u603b\u548c\u6216\u603b\u7684\u6ee1\u8db3\u7a0b\u5ea6\uff1b \u8fb9\u9645\u6548\u7528\uff08Marginal Utility, MU\uff09\u662f\u6307\u4ece\u989d\u5916\u4e00\u5355\u4f4d\uff08\u6700\u540e\u4e00\u5355\u4f4d\uff09\u67d0\u79cd\u5546\u54c1\u7684\u6d88\u8d39\u4e2d\u6240\u83b7\u5f97\u7684\u989d\u5916\u7684\u6548\u7528\uff08\u6216\u6ee1\u8db3\u611f\uff09\u3002 \u4f8b\u5982\uff0c\u6d88\u8d393\u676f\u53ef\u4e50\u7684\u603b\u6548\u7528\u4e3a9\u6548\u7528\u5355\u4f4d\uff1b\u6d88\u8d394\u676f\u53ef\u4e50\u7684\u603b\u6548\u7528\u4e3a10\u6548\u7528\u5355\u4f4d\uff0c\u5219\u53ef\u4ee5\u77e5\u9053\u7b2c4\u676f\u53ef\u4e50\u7684\u8fb9\u9645\u6548\u7528\u4e3a1\u5355\u4f4d\uff0810\uff0d9\uff1d1\uff09\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_2","title":"\u8fb9\u9645\u6548\u7528","text":"\u8fb9\u9645\u6548\u7528\u9012\u51cf\u89c4\u5f8b : \u5176\u4ed6\u6761\u4ef6\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\uff0c\u6d88\u8d39\u8005\u8fde\u7eed\u6d88\u8d39\u67d0\u79cd\u5546\u54c1\u7684\u8fb9\u9645\u6548\u7528\uff0c\u5c06\u968f\u5176\u6d88\u8d39\u91cf\u7684\u589e\u52a0\u800c\u4e0d\u65ad\u51cf\u5c0f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_3","title":"\u5e8f\u6570\u6548\u7528\uff1a\u65e0\u5dee\u5f02\u66f2\u7ebf","text":"
- \u8fb9\u9645\u6548\u7528\u662f\u7279\u5b9a\u65f6\u95f4\u5185\u7684\u6548\u7528\uff0c\u4e5f\u5177\u6709\u65f6\u95f4\u6027\u3002
- \u5728\u5b9e\u9645\u4e2d\uff0c\u8fb9\u9645\u6548\u7528\u4e0d\u4f1a\u4e3a\u96f6\u6216\u8d1f\u503c\u3002\u56e0\u4e3a\u5fae\u89c2\u7ecf\u6d4e\u5b66\u5047\u8bbe\u6d88\u8d39\u8005\u662f\u7406\u6027\u7684\uff0c\u8ffd\u6c42\u603b\u6548\u7528\u6700\u5927\u5316\uff0c\u56e0\u6b64\uff0c\u5f53\u67d0\u4e00\u5546\u54c1\u7684\u8fb9\u9645\u6548\u7528\u63a5\u8fd1\u4e8e\u96f6\u65f6\uff0c\u6d88\u8d39\u8005\u5c06\u4e0d\u518d\u589e\u52a0\u6d88\u8d39\u91cf\u3002
\u4ee5\u4eba\u4eec\u7684\u6b32\u671b\u5f3a\u5ea6\u9012\u51cf\u548c\u6b32\u671b\u5f3a\u5ea6\u9971\u548c\u4e3a\u57fa\u7840\u7684
\u5e8f\u6570\u6548\u7528\uff08Ordinal Utility\uff09\u7406\u8bba\u8ba4\u4e3a\u4e00\u79cd\u5546\u54c1\u5bf9\u6d88\u8d39\u8005\u7684\u6548\u7528\uff0c\u6ca1\u6709\u4e00\u4e2a\u5ba2\u89c2\u7684\u8861\u91cf\u6807\u51c6\uff0c\u800c\u4e14\u53d7\u5230\u540c\u65f6\u6d88\u8d39\u7684\u6709\u5173\u5546\u54c1\u7684\u5f71\u54cd\u3002 \u4f46\u8be5\u7406\u8bba\u8ba4\u4e3a\uff0c\u4e00\u4e2a\u6d88\u8d39\u8005\u867d\u7136\u8bf4\u4e0d\u51fa\u5404\u79cd\u5546\u54c1\u7684\u6548\u7528\u5927\u5c0f\uff0c\u5374\u80fd\u591f\u660e\u786e\u6392\u51fa\u81ea\u5df1\u5bf9\u8fd9\u4e9b\u5546\u54c1\u7684\u504f\u597d\u6b21\u5e8f\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_4","title":"\u504f\u597d\u5047\u8bbe","text":"\u504f\u597d\u7684\u5b8c\u5907\u6027\uff1a\u6d88\u8d39\u8005\u9762\u4e34\u4e0d\u540c\u7684\u5546\u54c1\u7ec4\u5408\u65f6\uff0c\u5b8c\u5168\u80fd\u591f\u6309\u7167\u81ea\u8eab\u7684\u504f\u597d\u6392\u5217\u4e00\u4e2a\u987a\u5e8f\u3002 \u504f\u597d\u7684\u4f20\u9012\u6027\uff1a\u6d88\u8d39\u8005\u7684\u504f\u597d\u5177\u6709\u53ef\u4f20\u9012\u7684\u7279\u6027\uff0c\u5373\u504f\u597d\u5728\u903b\u8f91\u4e0a\u7684\u4e00\u81f4\u6027\u3002 \u504f\u597d\u7684\u975e\u9971\u548c\u6027(\u8d8a\u591a\u8d8a\u597d)\uff1a\u5bf9\u4e8e\u6d88\u8d39\u4e0d\u540c\u7ec4\u5408\u7684\u76f8\u540c\u5546\u54c1\uff0c\u6d88\u8d39\u8005\u603b\u662f\u504f\u597d\u6570\u91cf\u8f83\u591a\u7684\u4e00\u7ec4\u5546\u54c1\u3002- \u5047\u8bbe\u8fb9\u9645\u6548\u7528>0
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_5","title":"\u65e0\u5dee\u5f02\u66f2\u7ebf","text":"\u65e0\u5dee\u5f02\u66f2\u7ebf\uff08Indifference Curve\uff0cIC\uff09\u662f\u6307\u5728\u504f\u597d\u65e2\u5b9a\u7684\u6761\u4ef6\u4e0b\uff0c\u80fd\u591f\u7ed9\u6d88\u8d39\u8005\u5e26\u6765\u76f8\u540c\u603b\u6548\u7528\u7684\u6240\u6709\u4e24\u79cd\u5546\u54c1\u4e0d\u540c\u7ec4\u5408\u7684\u8fde\u7ebf\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_6","title":"\u8fb9\u9645\u66ff\u4ee3\u7387","text":"
- \u65e0\u5dee\u5f02\u66f2\u7ebf\u5411\u53f3\u4e0b\u65b9\u503e\u659c\uff0c\u5373\u659c\u7387\u4e3a\u8d1f\u3002
- \u4efb\u4f55\u4e24\u6761\u65e0\u5dee\u5f02\u66f2\u7ebf\u4e0d\u53ef\u80fd\u76f8\u4ea4\u3002
- \u79bb\u539f\u70b9\u8d8a\u8fdc\u7684\u65e0\u5dee\u5f02\u66f2\u7ebf\u4ee3\u8868\u7684\u6548\u7528\u6c34\u5e73\u8d8a\u9ad8\u3002
- \u51f8\u5411\u539f\u70b9\u7684\u7ebf\uff0c\u5373\u65e0\u5dee\u5f02\u66f2\u7ebf\u7684\u659c\u7387\u7684\u7edd\u5bf9\u503c\u662f\u9012\u51cf\u7684\u3002
\u5728\u4fdd\u6301\u603b\u6548\u7528\u6c34\u5e73\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\uff0c\u6d88\u8d39\u8005\u4e3a\u589e\u52a0\u4e00\u4e2a\u5355\u4f4d\u67d0\u2014\u5546\u54c1\u7684\u6d88\u8d39\u800c\u5fc5\u987b\u51cf\u5c11\u7684\u53e6\u4e00\u79cd\u5546\u54c1\u7684\u6d88\u8d39\u6570\u91cf\uff0c\u5c31\u662f\u5546\u54c1\u7684\u8fb9\u9645\u66ff\u4ee3\u7387\uff08Marginal Rate of Substitution\uff09\uff0c\u901a\u5e38\u7528MRS\u6765\u8868\u793a\u3002
MRS = \u659c\u7387\u7684\u7edd\u5bf9\u503c
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_7","title":"\u7279\u6b8a\u7c7b\u578b","text":"
- \u8fb9\u9645\u66ff\u4ee3\u7387\u4e5f\u53ef\u5199\u4f5c\u8fb9\u9645\u6548\u7528\u4e4b\u6bd4
- \u5b8c\u5168\u66ff\u4ee3\u54c1
\u5b8c\u5168\u66ff\u4ee3\u54c1\uff08Perfect Substitutes\uff09\u662f\u6307\u66ff\u4ee3\u6bd4\u4f8b\u56fa\u5b9a\u4e0d\u53d8\u7684\u4e24\u79cd\u5546\u54c1\u3002\u56e0\u6b64\uff0c\u5728\u5b8c\u5168\u66ff\u4ee3\u7684\u60c5\u51b5\u4e0b\uff0c\u4e24\u79cd\u5546\u54c1\u4e4b\u95f4\u7684\u8fb9\u9645\u66ff\u4ee3\u7387MRSXY\u5c31\u662f\u4e00\u4e2a\u5e38\u6570\uff0c\u76f8\u5e94\u7684\u65e0\u5dee\u5f02\u66f2\u7ebf\u662f\u4e00\u6761\u659c\u7387\u4e0d\u53d8\u7684\u76f4\u7ebf\u3002
- \u5b8c\u5168\u4e92\u8865\u54c1
\u5b8c\u5168\u4e92\u8865\u54c1\u3002\u5b8c\u5168\u4e92\u8865\u54c1\uff08Perfect Complements\uff09\u610f\u5473\u7740\u5fc5\u987b\u6309\u56fa\u5b9a\u4e0d\u53d8\u7684\u6bd4\u4f8b\u540c\u65f6\u4f7f\u7528\u7684\u4e24\u79cd\u5546\u54c1\u3002\u76f8\u5e94\u7684\u65e0\u5dee\u5f02\u66f2\u7ebf\u76f4\u89d2\u5f62\u72b6\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_8","title":"\u6d88\u8d39\u9884\u7b97\u7ebf","text":"\u6d88\u8d39\u8005\u5728\u8d2d\u4e70\u65f6\u603b\u8981\u53d7\u5230\u5236\u7ea6\uff0c\u5373\u4ed6\u4e0d\u5f97\u4e0d\u5728\u5546\u54c1\u4ef7\u683c\u65e2\u5b9a\u548c\u8d27\u5e01\u6536\u5165\u6709\u9650\u7684\u6761\u4ef6\u4e0b\u51b3\u5b9a\u81ea\u5df1\u7684\u6d88\u8d39\u884c\u4e3a\u3002
\u6d88\u8d39\u9884\u7b97\u7ebf\uff08Budget Line\uff09\u662f\u6307\u5728\u6d88\u8d39\u8005\u6536\u5165\u548c\u6240\u8d2d\u4e70\u5546\u54c1\u4ef7\u683c\u65e2\u5b9a\u7684\u6761\u4ef6\u4e0b\uff0c\u6d88\u8d39\u8005\u7528\u5168\u90e8\u6536\u5165\u6240\u80fd\u4e70\u5230\u7684\u4e24\u79cd\u5546\u54c1\u7684\u6700\u5927\u6570\u91cf\u7ec4\u5408\u7684\u8fde\u7ebf\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_9","title":"\u53d8\u5316","text":"\u91cd\u70b9\u5728\u4e8e\u641e\u6e05\u695a\u6d88\u8d39\u9884\u7b97\u7ebf\u662f\u5982\u4f55\u6765\u7684\uff0c\u8fd9\u6837\u5404\u79cd\u60c5\u51b5\u90fd\u5341\u5206\u6e05\u6670\u660e\u4e86
\u6536\u5165\u6c34\u5e73 \u548c \u5546\u54c1\u4ef7\u683c
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_10","title":"\u6d88\u8d39\u8005\u5747\u8861","text":"
- \u6536\u5165\u6c34\u5e73\u53d8\u5316\uff0c\u5f15\u8d77\u9884\u7b97\u7ebf\u4e0a\u4e0b\u79fb\u52a8
- \u5546\u54c1\u4ef7\u683c\u53d8\u5316\uff0c\u4e0e\u5750\u6807\u8f74\u4ea4\u70b9\u53d8\u5316
- \u540c\u65f6\u53d8\u5316\uff0c\u5177\u4f53\u5206\u6790\uff0c\u6ca1\u5fc5\u8981\u8bb0
\u6d88\u8d39\u8005\u884c\u4e3a\u7406\u8bba\u5047\u5b9a\uff0c\u6d88\u8d39\u8005\u4ee5\u603b\u6548\u7528\u6700\u5927\u5316\u4e3a\u76ee\u6807\u3002 \u6d88\u8d39\u8005\u5747\u8861\uff08Consumer Equilibrium\uff09\u662f\u6307\u6d88\u8d39\u8005\u5728\u6536\u5165\u548c\u5546\u54c1\u4ef7\u683c\u65e2\u5b9a\u7684\u6761\u4ef6\u4e0b\uff0c\u9009\u62e9\u8d2d\u4e70\u4e00\u5b9a\u6570\u91cf\u7684\u5546\u54c1\u7ec4\u5408\uff0c\u4ece\u800c\u83b7\u5f97\u6700\u5927\u6ee1\u8db3\u7684\u72b6\u6001\uff0c\u5373\u603b\u6548\u7528\u6700\u5927\u5316\u7684\u72b6\u6001\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_11","title":"\u9700\u6c42\u66f2\u7ebf\u7684\u63a8\u5bfc","text":"\u867d\u7136\u57fa\u6570\u6548\u7528\u8bba\u4e0e\u5e8f\u6570\u6548\u7528\u8bba\u6240\u63a8\u5bfc\u51fa\u6765\u7684\u9700\u6c42\u66f2\u7ebf\u7279\u5f81\u76f8\u540c\uff0c\u4f46\u4e24\u8005\u7684\u63a8\u5bfc\u65b9\u6cd5\u4e0d\u540c\u3002 \u524d\u8005\u5728\u6548\u7528\u53ef\u4ee5\u8861\u91cf\u548c\u8fb9\u9645\u6548\u7528\u9012\u51cf\u89c4\u5f8b\u7684\u5047\u5b9a\u6761\u4ef6\u4e0b\u63a8\u5bfc\u51fa\u9700\u6c42\u66f2\u7ebf\uff1b \u540e\u8005\u5219\u8ba4\u4e3a\u8fd9\u4e24\u4e2a\u5fc3\u7406\u5047\u8bbe\u65e0\u6cd5\u5f97\u5230\u5b9e\u8bc1\uff0c\u4ece\u800c\u8f6c\u5411\u7528\u6d88\u8d39\u8005\u504f\u597d\u6240\u51b3\u5b9a\u7684\u6548\u7528\u6c34\u5e73\u6216\u6ee1\u8db3\u987a\u5e8f\u6765\u4ee3\u66ff\u6548\u7528\u7684\u5177\u4f53\u8861\u91cf\uff0c\u7528\u5546\u54c1\u7684\u8fb9\u9645\u66ff\u4ee3\u7387\u9012\u51cf\u89c4\u5f8b\u6765\u53d6\u4ee3\u5546\u54c1\u7684\u8fb9\u9645\u6548\u7528\u9012\u51cf\u89c4\u5f8b\uff0c\u540c\u6837\u63a8\u5bfc\u51fa\u4e86\u5411\u53f3\u4e0b\u65b9\u503e\u659c\u7684\u9700\u6c42\u66f2\u7ebf\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_12","title":"\u6bd4\u8f83\u9759\u6001\u5206\u6790","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_13","title":"\u6536\u5165\u3001\u66ff\u4ee3\u4e0e\u4ef7\u683c\u6548\u5e94","text":"\u5b9e\u9645\u6536\u5165\u6c34\u5e73\u6216\u8d27\u5e01\u8d2d\u4e70\u529b\uff1a\u7528\u540c\u6837\u7684\u8d27\u5e01\u80fd\u591f\u8d2d\u5165\u7684\u5546\u54c1\u6570\u91cf\u8861\u91cf \u6536\u5165\u6548\u5e94\uff08Income Effect\uff09\u6d88\u8d39\u8005\u7684\u5b9e\u9645\u6536\u5165\u6c34\u5e73\u53d8\u5316\u6240\u5f15\u8d77\u7684\u5546\u54c1\u9700\u6c42\u91cf\u7684\u53d8\u5316\u3002\u5b9e\u9645\u6536\u5165\u6c34\u5e73\u53d7\u5546\u54c1\u4ef7\u683c\u548c\u6536\u5165\u7684\u5f71\u54cd \u66ff\u4ee3\u6548\u5e94\uff08Substitution Effect\uff09\u5b9e\u9645\u6536\u5165\u6c34\u5e73\u4e0d\u53d8\u7684\u6761\u4ef6\u4e0b\uff0c\u7531\u4e8e\u4e00\u79cd\u5546\u54c1\u7684\u4ef7\u683c\u53d8\u5316\u6216\u4e24\u79cd\u5546\u54c1\u4ef7\u683c\u7684\u53cd\u65b9\u5411\u53d8\u5316\uff0c\u4f7f\u5f97\u76f8\u5bf9\u4ef7\u683c\u53d1\u751f\u53d8\u5316\uff0c\u5bfc\u81f4\u6d88\u8d39\u8005\u589e\u52a0\u4ef7\u683c\u4e0b\u964d\u7684\u5546\u54c1\u7684\u9700\u6c42\u91cf\u4ee5\u66ff\u4ee3\u4ef7\u683c\u4e0a\u6da8\u7684\u5546\u54c1\uff0c\u8fd9\u4e00\u73b0\u8c61\u88ab\u79f0\u4e3a\u66ff\u4ee3\u6548\u5e94
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/","title":"Chapter 3 \u751f\u4ea7\u8005\u7406\u8bba","text":"\u7ea6 1264 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 6 \u5206\u949f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_1","title":"\u751f\u4ea7\u8005","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_2","title":"\u4f01\u4e1a","text":"
- \u72ec\u8d44\u4f01\u4e1a
\u200b \u72ec\u8d44\u4f01\u4e1a\u662f\u6307\u7531\u4e2a\u4eba\u51fa\u8d44\u548c\u4e2a\u4eba\u6240\u6709\u7684\u4f01\u4e1a\uff0c\u6240\u4ee5\u53c8\u79f0\u5355\u4e00\u4e1a\u4e3b\u5236\uff08Individual Proprietorship\uff09
- \u5408\u4f19\u4f01\u4e1a
- \u6709\u9650\u516c\u53f8 \u8d23\u4efb\u6709\u9650 \u80a1\u4efd\u6709\u9650
\u5171\u540c\u7279\u70b9
\uff081\uff09\u8d23\u4efb\u6709\u9650\uff0c\u6240\u6709\u6295\u8d44\u8005\uff08\u80a1\u4e1c\uff09\u7684\u8d23\u4efb\u4ec5\u9650\u4e8e\u6240\u6295\u5165\u7684\u8d44\u672c\uff1b
\uff082\uff09\u516c\u53f8\u5177\u6709\u8fde\u7eed\u6027\uff0c\u80a1\u4efd\u6301\u6709\u8005\u7684\u79bb\u53bb\u4e5f\u4e0d\u5f71\u54cd\u4f01\u4e1a\u6cd5\u4eba\u7684\u5b58\u5728\uff0c\u5373\u516c\u53f8\u662f\u72ec\u7acb\u4e8e\u80a1\u4efd\u6301\u6709\u8005\u7684\u6cd5\u4eba\uff1b
\uff083\uff09\u7531\u6295\u8d44\u8005\u9009\u51fa\u7684\u8463\u4e8b\u4f1a\u638c\u63e1\u516c\u53f8\u7684\u7ecf\u8425\u7ba1\u7406\u6743\uff0c\u5176\u4ed6\u4eba\u65e0\u6743\u884c\u4f7f\u516c\u53f8\u7ba1\u7406\u6743\u3002
\u4e3b\u8981\u533a\u522b
\uff081\uff09\u5728\u7ec4\u6210\u4f01\u4e1a\u7684\u6210\u5458\u6570\u76ee\u4e0a\uff0c\u6709\u9650\u8d23\u4efb\u516c\u53f8\u89c4\u5b9a\u662f2\u4eba\u4ee5\u4e0a\uff0c50\u4eba\u4ee5\u4e0b\uff0c\u800c\u80a1\u4efd\u6709\u9650\u516c\u53f8\u53ea\u89c4\u5b9a2\u4eba\u4ee5\u4e0a\uff0c\u4e0d\u89c4\u5b9a\u4f01\u4e1a\u6210\u5458\u6570\u76ee\u7684\u4e0a\u9650
\uff082\uff09\u5728\u6240\u6709\u6743\u8f6c\u8ba9\u65b9\u9762\uff0c\u6709\u9650\u8d23\u4efb\u516c\u53f8\u4e2d\u67d0\u4e2a\uff08\u4e9b\uff09\u80a1\u4efd\u6301\u6709\u8005\u987b\u5f81\u5f97\u5176\u4ed6\u80a1\u4efd\u6301\u6709\u8005\u7684\u540c\u610f\u624d\u80fd\u8f6c\u8ba9\u80a1\u4efd\uff0c\u800c\u80a1\u4efd\u6709\u9650\u516c\u53f8\u7684\u80a1\u4efd\u53ef\u7531\u6301\u80a1\u4eba\u81ea\u7531\u8f6c\u8ba9\u3002
\u4f01\u4e1a\u5b58\u5728\u7684\u4e00\u4e2a\u4e3b\u8981\u7406\u7531\u5c31\u662f\u901a\u8fc7\u4f01\u4e1a\u7684\u5185\u90e8\u534f\u8c03\u6765\u6d88\u9664\u5e02\u573a\u7684\u4ea4\u6613\u6210\u672c\uff0c\u4f01\u4e1a\u5c31\u662f\u4e3a\u4e86\u51cf\u5c11\u5e02\u573a\u4ea4\u6613\u6210\u672c\u800c\u4ea7\u751f\u7684\u66ff\u4ee3\u5e02\u573a\u7684\u4e00\u79cd\u7ec4\u7ec7\u5f62\u5f0f\u3002
\u5e02\u573a\u4ea4\u6613\u6210\u672c\u548c\u4f01\u4e1a\u7ec4\u7ec7\u534f\u8c03\u6210\u672c\u7684\u6982\u5ff5\u63d0\u51fa\u540e\uff0c\u751f\u4ea7\u8fc7\u7a0b\u4e2d\u7684\u67d0\u4e00\u73af\u8282\u3001\u67d0\u4e00\u9053\u5de5\u5e8f\u3001\u67d0\u4e00\u90e8\u4ef6\u3001\u67d0\u4e00\u4e2a\u96f6\u4ef6\u662f\u7531\u5e02\u573a\u4ea4\u6613\u6765\u534f\u8c03\uff0c\u8fd8\u662f\u7531\u4f01\u4e1a\u7684\u5185\u90e8\u7ec4\u7ec7\u7ba1\u7406\u6765\u534f\u8c03\uff0c\u5c31\u53d6\u51b3\u4e8e\u5e02\u573a\u4ea4\u6613\u6210\u672c\u5927\uff0c\u8fd8\u662f\u4f01\u4e1a\u7684\u7ec4\u7ec7\u534f\u8c03\u6210\u672c\u5927\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_3","title":"\u751f\u4ea7\u5206\u6790","text":"
\u751f\u4ea7\u8981\u7d20
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_4","title":"\u751f\u4ea7\u51fd\u6570","text":"
- \u8d44\u672c
- \u52b3\u52a8
- \u571f\u5730
- \u4f01\u4e1a\u5bb6\u624d\u80fd
\u4e00\u822c\u800c\u8a00\uff0c\u6211\u4eec\u53ea\u8003\u8651\u8d44\u672c\u548c\u52b3\u52a8\u7684\u6295\u5165\uff0c\u800c\u5ffd\u7565\u5176\u4ed6\u7684\u751f\u4ea7\u8981\u7d20
- \u56fa\u5b9a\u6bd4\u4f8b\u751f\u4ea7\u51fd\u6570\u548c\u53ef\u53d8\u6bd4\u4f8b\u751f\u4ea7\u51fd\u6570
\u7531\u8d44\u672c\u548c\u52b3\u52a8\u7684\u7ec4\u5408\u6bd4\u4f8b\u51b3\u5b9a \u52b3\u52a8 / \u8d44\u672c\u5bc6\u96c6\u578b\u751f\u4ea7\u65b9\u5f0f
- C-D\u51fd\u6570\uff08\u67ef\u5e03-\u9053\u683c\u62c9\u65af\uff09
\u200b Q = C L\u03b1 K\u03b2 \u90e8\u5206\u60c5\u51b5\u4e0b\u6ee1\u8db3 \u03b1 + \u03b2 = 1
- \u957f\u671f\u548c\u77ed\u671f\u751f\u4ea7\u51fd\u6570
\u77ed\u671f \u957f\u671f
\u5e76\u4e0d\u53ea\u662f\u4f9d\u636e\u65f6\u95f4\u957f\u77ed\uff0c\u5176\u533a\u5206\u4f9d\u8d56\u7684\u662f \u662f\u5426\u6240\u6709\u751f\u4ea7\u8981\u7d20\u90fd\u53d1\u751f\u53d8\u5316
\u53ef\u53d8\u751f\u4ea7\u8981\u7d20 \u56fa\u5b9a\u751f\u4ea7\u8981\u7d20
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_5","title":"\u77ed\u671f\u751f\u4ea7\u51fd\u6570","text":"\u603b\u4ea7\u91cf TP \u5e73\u5747\u4ea7\u91cf AP \u8fb9\u9645\u4ea7\u91cf MP
Q = f(K) or f(L)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_6","title":"\u8fb9\u9645\u62a5\u916c\u9012\u51cf","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_7","title":"\u957f\u671f\u751f\u4ea7\u51fd\u6570","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_8","title":"\u7b49\u4ea7\u91cf\u66f2\u7ebf","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_9","title":"\u8fb9\u9645\u6280\u672f\u66ff\u4ee3\u7387","text":"\u8fb9\u9645\u6280\u672f\u66ff\u4ee3\u7387 Marginal Rate of Technological Substitution
\\(MRTS_{LK} = - \\Delta K/\\Delta L = \\frac{MP_L}{MP_K} = \\frac{w}{k}\\)
\u6b64\u5904 w \u4e3a\u52b3\u52a8\u7684\u4ef7\u683c\uff0ck \u4e3a\u8d44\u672c\u7684\u4ef7\u683c \u7531\u4e8e K\u51cf\u5c11\u5e26\u6765\u7684\u4ea7\u91cf\u51cf\u5c11 \u5fc5\u7136\u7b49\u4e8e L\u589e\u52a0\u5e26\u6765\u7684\u4ea7\u91cf\u589e\u52a0 \\(-\\Delta K*MP_K = \\Delta L*MP_L\\) L\u5bf9K\u7684\u8fb9\u9645\u66ff\u4ee3\u7387 \u2014\u2014 \u589e\u52a0 1 \u5355\u4f4d L \u53ef\u4ee5\u5e26\u6765 K\u7684\u53d8\u5316
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_10","title":"\u6700\u4f18\u5316","text":"
- \u603b\u4ea7\u91cf\u4e00\u5b9a\uff0c\u6210\u672c\u6700\u4f4e
- \u6210\u672c\u4e00\u5b9a\uff0c\u603b\u4ea7\u91cf\u6700\u5927
Example
\\(\u5229\u7528\u504f\u5bfc \u6c42\u51faMP_L \u548cMP_K\u8981\u6ce8\u610f\u4ed6\u4eec\u90fd\u662f\u5173\u4e8eQ\u7684\u51fd\u6570\uff0c\u5373Q=f(K,L)\\) \\(\u4e4b\u540e\u5229\u7528 MRTS_{LK} = \\frac{w}{k}\\)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_11","title":"\u7b49\u6210\u672c\u65b9\u7a0b","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_12","title":"\u6210\u672c\u5206\u6790","text":"\u4f1a\u8ba1\u6210\u672c\u4e0d\u8ba1\u7b97\u9690\u6027\u6210\u672c
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_13","title":"\u77ed\u671f\u6210\u672c","text":"\u8fd9\u91cc\u63cf\u8ff0\u7684\u662f\u6210\u672c\u548c\u4ea7\u91cf\u7684\u5173\u7cfb C = f\uff08Q\uff09
\u77ed\u671f\u603b\u6210\u672c TC \u603b\u56fa\u5b9a\u6210\u672c FC \u603b\u53ef\u53d8\u6210\u672c VC \u77ed\u671f\u5e73\u5747\u6210\u672c AC \u5e73\u5747\u56fa\u5b9a\u6210\u672c AFC \u5e73\u5747\u53ef\u53d8\u6210\u672c AVC \u77ed\u671f\u8fb9\u9645\u6210\u672c MC
TC = FC + VC
\\(MC = \\frac{\\Delta TC}{\\Delta Q}=\\frac{\\Delta VC}{\\Delta Q}\\)
- \u968f\u7740\u4ea7\u91cf\u7684\u589e\u52a0\uff0cSMC\u66f2\u7ebf\u4e0eAVC\u66f2\u7ebf\u548cSAC\u66f2\u7ebf\u5148\u540e\u76f8\u4ea4\u4e8eAVC\u66f2\u7ebf\u548cSAC\u66f2\u7ebf\u7684\u6700\u4f4e\u70b9E\u70b9\u548cF\u70b9\u3002
SMC
\u5148\u4e0b\u964d\u540e\u4e0a\u5347Q : \u603b\u53ef\u53d8\u6210\u672c\u4e3a\u4ec0\u4e48\u5148\u4ee5\u9012\u51cf\u7684\u901f\u5ea6\u589e\u52a0\u540e\u53c8\u4ee5\u9012\u589e\u7684\u901f\u5ea6\u589e\u52a0?
A : \u4ece\u751f\u4ea7\u51fd\u6570\u8fdb\u884c\u5206\u6790\uff0c\u6210\u672c\u51fd\u6570\u5c31\u662f\u751f\u4ea7\u51fd\u6570\u7684\u201c\u53cd\u8f6c\u201d
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_14","title":"\u957f\u671f\u6210\u672c\u51fd\u6570","text":"\u957f\u671f\u603b\u6210\u672c \uff1a LTC \u957f\u671f\u5e73\u5747\u6210\u672c\uff1a LAC \u957f\u671f\u8fb9\u9645\u6210\u672c\uff1aLMC
\u957f\u671f\u662f\u7531\u65e0\u6570\u4e2a\u77ed\u671f\u7ec4\u6210\u7684\uff0c\u56e0\u6b64\uff0c\u6240\u6709\u7684\u957f\u671f\u6210\u672c\u6216\u957f\u671f\u6210\u672c \u66f2\u7ebf\u90fd\u53ef\u4ee5\u4ece\u77ed\u671f\u6210\u672c\u6216\u77ed\u671f\u6210\u672c\u66f2\u7ebf\u4e2d\u63a8\u5bfc\u51fa\u6765\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_15","title":"\u89c4\u6a21\u7ecf\u6d4e","text":"
- \u7531\u77ed\u671f\u5e73\u5747\u6210\u672c\u66f2\u7ebf\u63a8\u5bfc
\u5982\u679c\u91c7\u7528Q = aL\u03b1K\u03b2\u7684\u9053\u683c\u62c9\u65af\u51fd\u6570\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\uff1a \u751f\u4ea7\u89c4\u6a21\u6269\u5927x\u500d\u540e\uff0cQ = a X\u03b1+\u03b2L\u03b1K\u03b2
\u4e5f\u5c31\u662f\u8bf4\uff0c\u03b1+\u03b2 = \u4e0a\u56fe\u4e2d\u7684 n
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_16","title":"\u89c4\u6a21\u7ecf\u6d4e","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_17","title":"\u8ba1\u7b97","text":"Q = aL\u03b1K\u03b2 C = aL + bK \u6c42C(Q) ,\u4e5f\u5c31\u662f\u6c42\u6210\u672c\u51fd\u6570\uff0c\u5c31\u662f\u5728Q\u7684\u6761\u4ef6\u7ea6\u675f\u4e0b\uff0c\u6c42\u51faC\u7684\u6700\u5c0f\u503c
- \u62c9\u683c\u6717\u65e5\u51fd\u6570
- \u76f4\u63a5\u4f7f\u7528\u6700\u4f18\u89e3\u7684\u6761\u4ef6\uff0c\u4e5f\u5c31\u662f\u8fb9\u9645\u4e4b\u6bd4 = K L\u4ef7\u683c\u4e4b\u6bd4
\u5047\u8bbe\u67d0\u4f01\u4e1a\u751f\u4ea7\u51fd\u6570Q=KL\uff0c\u5176\u4e2dK\u3001L\u5206\u522b\u4e3a\u8d44\u672c\u3001\u52b3\u52a8\u6295\u5165\u91cf\uff0c\u5176\u4ef7\u683c\u5206\u522br\u3001w\uff0c\u8bd5\u6c42\u8be5\u4f01\u4e1a\u7684\u6210\u672c\u51fd\u6570\u548c\u8fb9\u9645\u6210\u672c\u51fd\u6570\u3002
MC = C`(Q)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/","title":"Chapter 4 \u5f39\u6027\u7406\u8bba","text":"\u7ea6 307 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_1","title":"\u6982\u5ff5\u533a\u5206","text":"
- \u9700\u6c42\u5f39\u6027 \u9700\u6c42\u4ef7\u683c\u5f39\u6027
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_2","title":"\u9700\u6c42\u7684\u4ef7\u683c\u5f39\u6027","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_3","title":"\u8ba1\u7b97","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_4","title":"\u4e0e\u603b\u6536\u76ca\u7684\u5173\u7cfb","text":"
\u9700\u6c42\u5f39\u6027
\uff1a\u7528\u6765\u8861\u91cf\u6d88\u8d39\u8005\u5bf9\u5546\u54c1\u4ef7\u683c\u3001\u66ff\u4ee3\u54c1\u4ef7\u683c\u3001\u6536\u5165\u7b49\u53d8\u91cf\u53d8\u52a8\u7684\u53cd\u5e94\u7a0b\u5ea6\u9700\u6c42\u4ef7\u683c\u5f39\u6027
\uff08Price Elasticity of Demand\uff09\uff1a\u8861\u91cf\u9700\u6c42\u91cf\u5bf9\u4ef7\u683c\u53d8\u52a8\u7684\u53cd\u5e94\u7a0b\u5ea6\uff0c\u5373\u67d0\u79cd\u5546\u54c1\u9700\u6c42\u91cf\u53d8\u52a8\u7684\u767e\u5206\u6bd4\u4e0e\u5176\u4ef7\u683c\u53d8\u52a8\u7684\u767e\u5206\u6bd4\u4e4b\u6bd4"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_5","title":"\u5f71\u54cd\u56e0\u7d20","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_6","title":"\u4ea4\u53c9","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_7","title":"\u9700\u6c42\u7684\u6536\u5165\u5f39\u6027","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/","title":"Chapter 5 \u5b8c\u5168\u7ade\u4e89\u5e02\u573a","text":"
TR = P * Qd
\u82e5\u9500\u552e\u8fd9\u79cd\u5546\u54c1\u7684\u603b\u6536\u76ca\u4e0e\u5176\u4ef7\u683c\u6210\u53cd\u5411\u53d8\u52a8\uff0c\u5373\u4ef7\u683c\u4e0b\u964d\u603b\u6536\u76ca\u589e\u52a0\uff0c\u4ef7\u683c\u4e0a\u6da8\u603b\u6536\u76ca\u51cf\u5c11\uff0c\u5219\u8be5\u5546\u54c1\u5c5e\u4e8e\u9700\u6c42\u5bcc\u6709\u5f39\u6027\u7684\u5546\u54c1\uff1b\u82e5\u9500\u552e\u8fd9\u79cd\u5546\u54c1\u7684\u603b\u6536\u76ca\u4e0e\u5176\u4ef7\u683c\u53d8\u52a8\u2f46\u5173\uff0c\u8bf4\u660e\u2f46\u8bba\u4ef7\u683c\u4e0a\u6da8\u6216\u4e0b\u964d\uff0c\u603b\u6536\u76ca\u90fd\u4e0d\u53d8\uff0c\u5219\u8be5\u5546\u54c1\u7684\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u4e3a\u5355\u4f4d\u5f39\u6027\uff1b\u82e5\u9500\u552e\u8fd9\u79cd\u5546\u54c1\u7684\u603b\u6536\u76ca\u4e0e\u5176\u4ef7\u683c\u6210\u540c\u2f45\u5411\u53d8\u52a8\uff0c\u5373\u4ef7\u683c\u4e0b\u964d\u603b\u6536\u76ca\u4e0b\u964d\uff0c\u4ef7\u683c\u4e0a\u6da8\u603b\u6536\u76ca\u4e5f\u589e\u52a0\uff0c\u5219\u8be5\u5546\u54c1\u5c5e\u4e8e\u9700\u6c42\u7f3a\u4e4f\u5f39\u6027\u7684\u5546\u54c1\u3002 \u7b56\u7565\uff1a\u65e0\u5f39\u6027 \u63d0\u4ef7 \u6709\u5f39\u6027 \u964d\u4ef7\u7ea6 966 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_1","title":"\u57fa\u672c\u7279\u5f81","text":"\u5224\u65ad\u4e0d\u540c\u5e02\u573a\u7684\u6807\u51c6 \uff081\uff09\u4ea4\u6613\u8005\u7684\u6570\u91cf\uff1b \uff082\uff09\u4ea4\u6613\u5546\u54c1\u7684\u6027\u8d28\uff1b \uff083\uff09\u8fdb\u5165\u5e02\u573a\u6709\u65e0\u969c\u788d\uff1b \uff084\uff09\u4ea4\u6613\u8005\u6240\u5f97\u5230\u7684\u4fe1\u606f\u662f\u5426\u5b8c\u5168\u3002
\u4f01\u4e1a\u9762\u4e34\u4e24\u79cd\u7ea6\u675f\uff1a
- \u6280\u672f\u7ea6\u675f\uff1a\u7528\u751f\u4ea7\u51fd\u6570\u6216\u6210\u672c\u51fd\u6570\u52a0\u4ee5\u6982\u62ec
- \u5e02\u573a\u7ea6\u675f\uff1a\u7528\u5e02\u573a\u7ed3\u6784\u6216\u9700\u6c42\u66f2\u7ebf\u52a0\u4ee5\u6982\u62ec
\u5206\u7c7b
\u5b8c\u5168\u7ade\u4e89\u7684\u7279\u5f81
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_2","title":"\u5382\u5546\u6536\u76ca\u66f2\u7ebf","text":"
- \u5b58\u5728\u7740\u5927\u91cf\u7684\u5356\u8005\u548c\u4e70\u8005\uff08Price taker\uff09 \u8fd9\u610f\u5473\u7740\uff0c\u5356\u5bb6\u548c\u4e70\u5bb6\u90fd\u65e0\u6cd5\u5355\u72ec\u5730\u51b3\u5b9a\u5546\u54c1\u7684\u5b9a\u4ef7\uff0c\u4ed6\u4eec\u90fd\u662f\u5e02\u573a\u4ef7\u683c\u7684\u88ab\u52a8\u63a5\u53d7\u8005
- \u9500\u552e\u7684\u4ea7\u54c1\u662f\u540c\u8d28\u7684 \u4e0d\u6b62\u7269\u7406\u7279\u6027\u76f8\u540c\uff0c\u5176\u4ed6\u5c5e\u6027\u4e5f\u5e94\u8be5\u662f\u76f8\u540c\u7684
- \u8d44\u6e90\u7684\u6d41\u52a8\u4e0d\u53d7\u9650\u5236\uff08\u8fdb\u51fa\u5e02\u573a\u4e0d\u53d7\u9650\u5236\uff09
- \u4fe1\u606f\u5b8c\u5168 \u6240\u6709\u51b3\u7b56\u8005\u90fd\u62e5\u6709\u5b8c\u5168\u7684\u5bf9\u8fc7\u53bb\u3001\u73b0\u5728\u3001\u672a\u6765\u7684\u4fe1\u606f
\u6536\u76ca\u90e8\u5206 \\(R = PQ = P(Q) * Q\\) \\(AR = \\frac{R}{Q} = P(Q)\\) \\(MR= \\frac{dR}{dQ}=\\frac{dP(Q)}{dQ}*Q+P(Q)\\)
\u5229\u6da6\u51fd\u6570 \\(\\pi(Q)=R(Q)-C(Q)\\) \u6700\u5927\u5316\u6761\u4ef6 \\(MR(Q)=MC(Q)\\)
\u5bf9\u5b8c\u5168\u7ade\u4e89\u800c\u8a00 \\(P(Q)=P_0 \\ \u59cb\u7ec8\u4e0d\u53d8\\)\uff08\u4ed6\u4eec\u90fd\u662f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_3","title":"\u77ed\u671f\u4f9b\u7ed9\u4e0e\u5747\u8861","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_4","title":"\u5382\u5546","text":"Price Taker
\uff09 \u4e8e\u662f\u53ef\u4ee5\u63a8\u51fa \\(MC = MR = P_0\\)\u4e00\uff1a\u603b\u91cf\u5206\u6790 \u7565 \u4e8c\uff1a\u8fb9\u9645\u5206\u6790 \u5206\u4e3a\u4e09\u79cd\u60c5\u51b5\uff1a
- \\(P > min(AC)\\)
- \\(P = min(AC)\\) \\(E_2\\) \u76c8\u4e8f\u5e73\u8861\u70b9
- \\(P < min(AC)\\) \u4e8f\u635f\u51b3\u7b56 \uff08\u5173\u952e\u5728\u4e8e\u80fd\u5426cover\u5168\u90e8\u7684AVC\u53ef\u53d8\u751f\u4ea7\u6210\u672c\uff09
- \\(q_3:AC>P>AVC\\) \u7ee7\u7eed\u8425\u4e1a\uff0c
- \\(q_4:AC>P=AVC\\) \u505c\u4e1a\u8425\u4e1a\u70b9
\\(q_5:P<AVC\\) \u505c\u6b62\u8425\u4e1a
\u5229\u6da6\u6700\u5927\u5316\u4e0e\u5b9e\u9645\u5229\u6da6\u591a\u5c11\u65e0\u5173\uff0c\u5b9e\u9645\u5229\u6da6\u9700\u8981\u8003\u8651
AC
\u4e0e\u4e4b\u7684\u5927\u5c0f\u5173\u7cfb\u77ed\u671f\u4f9b\u7ed9\u66f2\u7ebf
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_5","title":"\u5382\u5546\u5230\u5e02\u573a","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_6","title":"\u5269\u4f59\u4ef7\u503c","text":"
- \u505c\u6b62\u8425\u4e1a\u70b9\u4e4b\u4e0a\u7684\u90e8\u5206
- \u751f\u4ea7\u8005\u5269\u4f59\uff1a\u4efb\u610f\u4e00\u4e2a\u751f\u4ea7\u8005\u5728\u751f\u4ea7\u548c\u51fa\u552e\u5546\u54c1\u65f6\u5f97\u5230\u7684\u5b9e\u9645\u6536\u76ca\u548c\u610f\u613f\u6536\u76ca\uff08\u5373\u4ed6\u613f\u610f\u63a5\u53d7\u7684\u6700\u5c0f\u6536\u76ca\uff09\u4e4b\u95f4\u5e38\u5e38\u4e5f\u5b58\u5728\u4e00\u5b9a\u7684\u5dee\u989d\u3002
- \u6d88\u8d39\u8005\u5269\u4f59\uff1a\u4efb\u610f\u4e00\u4e2a\u6d88\u8d39\u8005\u5728\u8d2d\u4e70\u5546\u54c1\u65f6\u7684\u610f\u613f\u652f\u4ed8\uff08\u5373\u4ed6\u613f\u610f\u652f\u4ed8\u7684\u6700\u9ad8\u4ee3\u4ef7\uff09\u4e0e\u5b9e\u9645\u652f\u4ed8\u4e4b\u95f4\u5e38\u5e38\u5b58\u5728\u4e00\u5b9a\u7684\u5dee\u989d\u3002
- \u5e02\u573a\u603b\u5269\u4f59\uff1a\u4e8c\u8005\u603b\u548c
\u751f\u4ea7\u8005\u5269\u4f59\u4e0e\u5229\u6da6\u76f8\u5173\uff0c\u4f46\u5e76\u4e0d\u76f8\u540c
\\(\u751f\u4ea7\u8005\u5269\u4f59 = TR - TVC\\) \\(\u5229\u6da6\\pi=TR-TC=TR-TVC-TFC\\)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_7","title":"\u957f\u671f\u5747\u8861","text":"\u6240\u6709\u751f\u4ea7\u8981\u7d20\u7684\u8c03\u6574\u53ef\u4ee5\u8868\u73b0\u5728\u4e24\u4e2a\u65b9\u9762\uff1a
\u4e00\u662f\u5382\u5546\u81ea\u7531\u5730\u8fdb\u5165\u6216\u9000\u51fa\u67d0\u4e00\u884c\u4e1a\uff0c\u5373\u884c\u4e1a\u5185\u5382\u5546\u6570\u76ee\u7684\u8c03\u6574\uff1b \u4e8c\u662f\u5382\u5546\u5bf9\u81ea\u8eab\u751f\u4ea7\u89c4\u6a21\u7684\u8c03\u6574\u3002
\u5b8c\u5168\u7ade\u4e89\u5382\u5546\u7684\u957f\u671f\u5747\u8861\u5c31\u662f\u901a\u8fc7\u8fd9\u4e24\u65b9\u9762\u7684\u8c03\u6574\u800c\u5b9e\u73b0\u7684\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_8","title":"\u5382\u5546","text":"\u6570\u76ee\u53d8\u5316
- \u5047\u8bbe\uff0c\u6700\u521d\\(P_0,Q_0\\)\u4e3a\u5747\u8861\u503c\uff0c\u7531\u4e8e\\(P_0>AC\\)\uff0c\u5728\u5de8\u989d\u5229\u6da6\u5f71\u54cd\u4e0b\u65b0\u5382\u5546\u8fdb\u5165
- \u4f9b\u5e94\u79fb\u52a8\u81f3\\(S_2\\)\u66f2\u7ebf\uff0c\u5e73\u8861\u53d8\u5316
- \u6700\u7ec8\u5e73\u8861\u4f4d\u7f6e\u5728E\u70b9
\u89c4\u6a21\u8c03\u6574
- \u957f\u671f\u7684\u89c4\u6a21\u8c03\u6574\uff0c\u6216\u957f\u671f\u7684\u5229\u6da6\u6700\u5927\u5316\uff0c\u5c31\u662f\u5728\u6240\u6709\u7684\u77ed\u671f\u5747\u8861\u4e2d\u9009\u62e9\u4e00\u4e2a\u201c\u6700\u4f18\u201d\u7684\u77ed\u671f\u5747\u8861\u3002
\u5747\u8861\u6761\u4ef6
\\(P\uff1dLMC\uff1dLAC\uff1dSMC\uff1dSAC\\)
\u8fb9\u9645\u6210\u672c = \u5e02\u573a\u4ef7\u683c = \u5e73\u5747\u6210\u672c ==> \u6548\u7387\u9ad8
\u6b64\u65f6\uff0c\\(LMC =0,LAC\u53d6\u6700\u5c0f\u503c\\)
\u957f\u671f\u5747\u8861\u610f\u5473\u7740\u5382\u5546\u7684\u603b\u5229\u6da6\u4e3a0\uff0c\u5426\u5219\u5176\u4ed6\u5382\u5546\u4f1a\u76f8\u5e94\u4f5c\u51fa\u53cd\u5e94\uff0c\u5bfc\u81f4\u5747\u8861\u53d8\u5316
\u6bd4\u5982\uff0c\u5229\u6da6 > 0, \u65b0\u5382\u5546\u8fdb\u5165\uff0c\u4ef7\u683c\u964d\u4f4e\uff0c\u5229\u6da6\u4e0b\u964d \u5229\u6da6<0\uff0c\u539f\u5382\u5546\u9000\u51fa\uff0c\u4ef7\u683c\u4e0a\u5347\uff0c\u5355\u4e2a\u5382\u5546\u4e8f\u635f\u51cf\u5c11\uff0c\u76f4\u81f3\u4e8f\u635f\u4e3a0\uff0c\u4e0d\u518d\u9000\u51fa
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_9","title":"\u884c\u4e1a","text":"\u5728\u957f\u671f\u4e2d\uff0c\u5b8c\u5168\u7ade\u4e89\u884c\u4e1a\u7684\u6210\u672c\u53ef\u80fd\u662f\u4e0d\u53d8\u7684\uff0c\u9012\u589e\u7684\uff0c\u9012\u51cf\u7684
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_10","title":"\u6210\u672c\u4e0d\u53d8","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_11","title":"\u4f8b\u9898","text":"
- \\(S_0,D_0\\)\u4e3a\u6700\u521d\u7684\u5e73\u8861
- \u5047\u8bbe\u9700\u6c42\u589e\u52a0\u4e3a\\(D_1\\)\uff0c\u77ed\u671f\u5185\u4f9b\u7ed9\u4e0d\u53d8\uff0c
- \u7531\u4e8e\u5de8\u989d\u5229\u6da6\uff0c\u5382\u5546\u8fdb\u5165\uff0c\u4f9b\u7ed9\u53d8\u4e3a\\(S_1\\)
(1) MC = P , \u03a0 = q * P - STC (2) min(SAC) = min(SVC / q) \u6ce8\u610f\u533a\u5206SVC\u548cFC \u6bd4\u5982\u8fd9\u91cc\u7684STC = SFC + SVC, SFC\u5373\u4e3a\u5e38\u6570 (3) MC with limitation(P > P0)
( 1 ) LAC \u53d6min\u65f6\uff0c\u6c42\u51fa\u4ea7\u91cfq \u5747\u8861\u65f6 P = LAC \u5047\u8bbe\u6210\u672c\u4e0d\u53d8\uff0c\u53ef\u5f97\u957f\u671f\u4f9b\u7ed9\u51fd\u6570\u4e3a\u4e00\u6761\u76f4\u7ebf D = (LAC)min
(2) n\u4e3a\u5382\u5546\u6570\u76ee,q\u4e3aLAC\u53d6min\u65f6\u7684\u4ea7\u91cf QD==QS==q*n
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/","title":"Chapter 6 \u4e0d\u5b8c\u5168\u7ade\u4e89\u5e02\u573a","text":"\u7ea6 2834 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 14 \u5206\u949f
\u4e0d\u5b8c\u5168\u7ade\u4e89\uff1a\u5b8c\u5168\u5784\u65ad\u3001\u5be1\u5934\u5784\u65ad\u3001\u5784\u65ad\u7ade\u4e89\u5e02\u573a
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_1","title":"\u5b8c\u5168\u5784\u65ad\u5e02\u573a","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_2","title":"\u7279\u5f81\u4e0e\u6210\u56e0","text":"\u7279\u5f81 \u5b8c\u5168\u5784\u65ad\u901a\u5e38\u7b80\u79f0\u5784\u65ad\u3002\u5728\u5356\u65b9\u5e02\u573a\u4e0a\uff0c\u5b8c\u5168\u5784\u65ad\uff08Monopoly\uff09\u662f\u6307\u4e00\u4e2a\u884c\u4e1a\u53ea\u6709\u552f\u4e00\u4e00\u5bb6\u5382\u5546\u7684\u5e02\u573a\u7ed3\u6784\u3002
- \u4e00\u4e2a\u884c\u4e1a\u4e2d\u53ea\u6709\u4e00\u5bb6\u5382\u5546\u751f\u4ea7\u548c\u9500\u552e\u5168\u90e8\u4ea7\u54c1\uff0c\u800c\u6d88\u8d39\u8005\u7684\u6570\u76ee\u4f17\u591a\u3002
- \u5382\u5546\u751f\u4ea7\u548c\u9500\u552e\u7684\u4ea7\u54c1\u4e0d\u5b58\u5728\u4efb\u4f55\u63a5\u8fd1\u7684\u66ff\u4ee3\u54c1\u3002\u5982\u679c\u5b58\u5728\u66ff\u4ee3\u54c1\u7684\u8bdd\uff0c\u8be5\u5382\u5546\u5c31\u4e0d\u5f97\u4e0d\u9762\u4e34\u5176\u4ed6\u5382\u5546\u7684\u7ade\u4e89\u800c\u6ca1\u6709\u5b8c\u5168\u63a7\u5236\u5e02\u573a\u7684\u80fd\u529b\u3002
- \u884c\u4e1a\u4e2d\u5b58\u5728\u7740\u4e25\u683c\u7684\u8fdb\u5165\u58c1\u5792\uff0c\u5176\u4ed6\u5382\u5546\u8981\u8fdb\u5165\u8be5\u884c\u4e1a\u6781\u5176\u56f0\u96be\uff0c\u751a\u81f3\u662f\u4e0d\u53ef\u80fd\u7684
\u5206\u7c7b
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_3","title":"\u6536\u76ca\u66f2\u7ebf","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_4","title":"\u5747\u8861","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_5","title":"\u77ed\u671f\u5747\u8861","text":"
- \u8d44\u6e90\u5784\u65ad \uff1a\u4e3b\u8981\u6307\u539f\u6599\u7684\u63a7\u5236
- \u7279\u8bb8\u5784\u65ad
- \u4e13\u5229\u5784\u65ad
- \u81ea\u7136\u5784\u65ad\uff1a\u4e00\u5bb6\u5382\u5546\u80fd\u4ee5\u6700\u4f4e\u6210\u672c\u6ee1\u8db3\u6574\u4e2a\u5e02\u573a\u5bf9\u67d0\u4e00\u4ea7\u54c1\u7684\u9700\u6c42\uff0c\u8be5\u5382\u5546\u5c31\u80fd\u53d6\u5f97\u5e02\u573a\u7684\u5784\u65ad\u5730\u4f4d\u3002\u7531\u4e8e\u89c4\u6a21\u7ecf\u6d4e\u5bfc\u81f4\u7684\u5784\u65ad
- \u6ee1\u8db3\u5747\u8861\u7684\u6761\u4ef6\uff1a\\(SMC=MR\\)
- \u77ed\u671f\u5185\uff0c\u751f\u4ea7\u89c4\u6a21\u4e0d\u53d1\u751f\u53d8\u5316\uff0c\u4e5f\u5c31\u662fSMC\u548cSAC\u4e0d\u53d8\uff1b\u901a\u8fc7\u6539\u53d8\u4ef7\u683c\u548c\u4ea7\u91cf\u8fdb\u884c\u5747\u8861\u8c03\u6574
- \u4e8f\u635f\u662f\u5426\u7ee7\u7eed\u751f\u4ea7\uff1f
- \u540c\u5b8c\u5168\u7ade\u4e89\u6761\u4ef6\u4e0b\uff1a\u4e0eAVC\u6bd4\u8f83
\u4f9b\u7ed9\u7684\u95ee\u9898
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_6","title":"\u957f\u671f\u5747\u8861","text":"\u957f\u671f\u5747\u8861\u5c31\u662f\u5bfb\u627e\u6700\u4f18\u77ed\u671f\u5747\u8861\u7684\u8fc7\u7a0b
\u5747\u8861\u6761\u4ef6 \uff1a \\(LMC = MR=SMC\\)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_7","title":"\u4ef7\u683c\u6b67\u89c6","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_8","title":"\u5f62\u6210","text":"\u5b9e\u884c\u4ef7\u683c\u6b67\u89c6\u9700\u8981\u4e09\u4e2a\u57fa\u672c\u6761\u4ef6\uff1a
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_9","title":"\u7279\u5f81","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_10","title":"\u4e00\u7ea7\u4ef7\u683c\u6b67\u89c6","text":"
\u7b2c\u4e00\uff0c\u5382\u5546\u5fc5\u987b\u62e5\u6709\u4e00\u5b9a\u7684\u5e02\u573a\u529b\u91cf\uff0c\u5373\u80fd\u591f\u5c06\u4ef7\u683c\u5b9a\u4e8e\u8fb9\u9645\u6210\u672c\u4e4b\u4e0a\uff0c\u5426\u5219\u7ade\u4e89\u8005\u80fd\u591f\u4ee5\u7ade\u4e89\u4ef7\u683c\u7834\u574f\u4ef7\u683c\u6b67\u89c6\uff1b
\u7b2c\u4e8c\uff0c\u5546\u54c1\u80fd\u591f\u5728\u4e24\u4e2a\u6216\u4e24\u4e2a\u4ee5\u4e0a\u88ab\u5206\u5272\u7684\u5e02\u573a\u4e0a\u51fa\u552e\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u6d88\u8d39\u8005\u4e0d\u53ef\u80fd\u8f7b\u800c\u6613\u4e3e\u5730\u5c06\u5546\u54c1\u5728\u4e0d\u540c\u7684\u5e02\u573a\u4e4b\u95f4\u8fdb\u884c\u5012\u5356\u3002\u5426\u5219\uff0c\u4e0d\u540c\u5e02\u573a\u7684\u4ef7\u683c\u4f1a\u56e0\u4e3a\u5546\u54c1\u5012\u5356\u800c\u8d8b\u4e8e\u76f8\u7b49\uff1b
\u7b2c\u4e09\uff0c\u4e0d\u540c\u5e02\u573a\u7684\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u4e0d\u540c\u3002\u5bf9\u4e8e\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u8f83\u5927\u7684\u5e02\u573a\uff0c\u4ef7\u683c\u5b9a\u5f97\u8f83\u4f4e\uff1b\u800c\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u8f83\u5c0f\u7684\u5e02\u573a\uff0c\u4ef7\u683c\u5b9a\u5f97\u8f83\u9ad8\u3002\u5982\u679c\u4e0d\u540c\u5e02\u573a\u7684\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u76f8\u540c\uff0c\u90a3\u4e48\u5229\u6da6\u6700\u5927\u5316\u7684\u4e0d\u540c\u5e02\u573a\u7684\u4ef7\u683c\u4e5f\u4f1a\u4e00\u6837\u3002
\u6240\u8c13\u4e00\u7ea7\u4ef7\u683c\u6b67\u89c6\uff08First-degree Price Discriminations\uff09\u662f\u6307\u5784\u65ad\u5382\u5546\u5411\u8d2d\u4e70\u5546\u54c1\u7684\u6bcf\u4e00\u4e2a\u6d88\u8d39\u8005\u7d22\u53d6\u4ed6\u613f\u610f\u652f\u4ed8\u7684\u6700\u9ad8\u4ef7\u683c\uff0c\u6216\u8005\u662f\u5784\u65ad\u5382\u5546\u5411\u5355\u4e2a\u6d88\u8d39\u8005\u8d2d\u4e70\u7684\u6bcf\u4e00\u5355\u4f4d\u5546\u54c1\u7d22\u53d6\u4ed6\u613f\u610f\u652f\u4ed8\u7684\u6700\u9ad8\u4ef7\u683c\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_11","title":"\u4e8c\u7ea7\u4ef7\u683c\u6b67\u89c6","text":"
- \u5382\u5546\u83b7\u53d6\u6240\u6709\u7684\u751f\u4ea7\u8005\u5269\u4f59
- \u5982\u679c\u5784\u65ad\u5382\u5546\u4e0d\u5b9e\u884c\u4ef7\u683c\u6b67\u89c6\uff0c\u4ee5\u4e0d\u53d8\u4ef7\u683cP0\u51fa\u552eQ0\u5355\u4f4d\u5546\u54c1\uff0c\u5219\u5784\u65ad\u5382\u5546\u7684\u603b\u6536\u76ca\u4e3aP0Q0 ;\u6b64\u65f6\u6d88\u8d39\u8005\u603b\u5269\u4f59\u4e3a\u4e09\u89d2\u5f62AP0B\u7684\u9762\u79ef
\u5784\u65ad\u5382\u5546\u5bf9\u540c\u4e00\u6d88\u8d39\u8005\u8d2d\u4e70\u4e0d\u540c\u6570\u91cf\u7684\u540c\u4e00\u5546\u54c1\u7d22\u53d6\u4e0d\u540c\u7684\u4ef7\u683c\uff0c\u4ece\u800c\u5360\u6709\u6bcf\u4e2a\u6d88\u8d39\u8005\u4ee5\u4e0d\u53d8\u7684\u5e02\u573a\u4ef7\u683c\u8d2d\u4e70\u5546\u54c1\u65f6\u5e94\u8be5\u5f97\u5230\u7684\u6d88\u8d39\u8005\u5269\u4f59\u3002
\u5982\u679c\u5784\u65ad\u5382\u5546\u5b9e\u884c\u4e8c\u7ea7\u4ef7\u683c\u6b67\u89c6\uff0c\u5728\u6d88\u8d39\u8005\u8d2d\u4e70\u91cfQ\u2264Q1\u65f6\uff0c\u5b9a\u4ef7\u4e3aP1\uff1b\u5728\u6d88\u8d39\u8005\u8d2d\u4e70\u91cfQ1\uff1cQ\u2264Q2\u65f6\uff0c\u5b9a\u4ef7\u4e3aP2\uff1b\u5728\u6d88\u8d39\u8005\u8d2d\u4e70\u91cfQ2\uff1cQ\u2264Q3\u65f6\uff0c\u5b9a\u4ef7\u4e3aP3\u3002
\u90a3\u4e48\uff0c\u5382\u5546\u5c06\u83b7\u53d6\u90e8\u5206\u7684\u751f\u4ea7\u8005\u5269\u4f59\uff0c\u5229\u6da6\u589e\u52a0
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_12","title":"\u4e09\u7ea7\u4ef7\u683c\u6b67\u89c6","text":"\u4ee5\u4e0d\u540c\u7684\u4ef7\u683c\u5411\u4e0d\u540c\u7c7b\u578b\u7684\u6d88\u8d39\u8005\u6216\u5728\u4e0d\u540c\u7684\u5e02\u573a\u4e0a\u51fa\u552e\u540c\u4e00\u5546\u54c1\u3002
OR
\u4e09\u7ea7\u4ef7\u683c\u6b67\u89c6\u9488\u5bf9\u7684\u662f\u5177\u6709\u4e0d\u540c\u7684\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u7684\u6d88\u8d39\u7fa4\u4f53\uff0c\u5e76\u6839\u636e\u8fd9\u4e9b\u4e0d\u540c\u7684\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u5bf9\u8fd9\u4e9b\u6d88\u8d39\u7fa4\u4f53\u6536\u53d6\u4e0d\u540c\u7684\u4ef7\u683c\u3002
\u63a8\u65ad\uff1a
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_13","title":"\u5784\u65ad\u7ade\u4e89\u5e02\u573a","text":"
- \u9996\u5148\uff0c\u5728\u4e24\u4e2a\u4e0d\u540c\u7684\u5e02\u573a\uff0c\u5206\u522b\u5177\u6709\u9700\u6c42\u51fd\u6570\\(D_1 \\ \\ D_2\\)
- \u5229\u6da6\\(\\pi=TR(Q_1)+TR(Q_2)-TC(Q_0)=TR(Q_1)+TR(Q_2)-TC(Q_1+Q_2)\\)
- \u6839\u636e\u62c9\u683c\u6717\u65e5\u6761\u4ef6
- \\(MR(Q_1)-MC(Q)=0\\)
- \\(MR(Q_2)-MC(Q)=0\\)
- \u6545\u800c\uff0c\\(MR(Q_1)=MR(Q_2)=MC(Q)\\)
\u5784\u65ad\u7ade\u4e89\uff08Monopolistic Competition\uff09\u5e02\u573a\u662f\u4e00\u79cd\u65e2\u6709\u5784\u65ad\u53c8\u6709\u7ade\u4e89\u7684\u5e02\u573a\u3002\u5728\u8fd9\u4e2a\u5e02\u573a\u4e0a\u5b58\u5728\u7740\u8bb8\u591a\u751f\u4ea7\u548c\u9500\u552e\u6709\u5dee\u522b\u7684\u540c\u79cd\u4ea7\u54c1\u7684\u5382\u5546.
\u901a\u5e38\uff0c\u5728\u77ed\u671f\u4e2d\uff0c\u5382\u5546\u80fd\u591f\u51ed\u501f\u4ea7\u54c1\u7684\u5dee\u522b\u83b7\u5f97\u76f8\u5bf9\u5784\u65ad\u5730\u4f4d\uff1b\u800c\u5728\u957f\u671f\u4e2d\uff0c\u7531\u4e8e\u4fe1\u606f\u57fa\u672c\u5b8c\u5907\uff0c\u8fdb\u51fa\u884c\u4e1a\u8f83\u81ea\u7531\uff0c\u5176\u4ed6\u5382\u5546\u80fd\u591f\u901a\u8fc7\u521b\u65b0\u3001\u6a21\u4eff\u7b49\u624b\u6bb5\u751f\u4ea7\u6709\u5dee\u522b\u7684\u4ea7\u54c1\uff0c\u4e0e\u539f\u6709\u7684\u5382\u5546\u8fdb\u884c\u7ade\u4e89\u3002
\u7279\u5f81
- \u5e02\u573a\u4e0a\u6709\u8bb8\u591a\u7684\u5382\u5546\u548c\u6d88\u8d39\u8005\u3002\u7531\u4e8e\u5382\u5546\u7684\u6570\u76ee\u5f88\u591a\uff0c\u6bcf\u4e00\u5bb6\u5382\u5546\u5bf9\u4ea7\u54c1\u7684\u4ef7\u683c\u867d\u7136\u6709\u5f71\u54cd\uff0c\u4f46\u53ea\u662f\u5f88\u5c0f\u7684\u5f71\u54cd\u3002
- **\u5e02\u573a\u4e0a\u7684\u8bb8\u591a\u5382\u5546\u751f\u4ea7\u7684\u662f\u6709\u5dee\u522b\u7684\u540c\u79cd\u4ea7\u54c1\uff0c\u56e0\u800c\uff0c\u4e00\u65b9\u9762\u8fd9\u4e9b\u4ea7\u54c1\u80fd\u591f\u6ee1\u8db3\u6d88\u8d39\u8005\u7684\u5404\u79cd\u4e0d\u540c \u504f\u597d\uff0c\u53e6\u4e00\u65b9\u9762\u8fd9\u4e9b\u4ea7\u54c1\u4e4b\u95f4\u53c8\u5177\u6709\u5f88\u5f3a\u7684\u66ff\u4ee3\u6027\u3002
\u8fd9\u79cd\u5dee\u522b\u6709\u5b9e\u8d28\u4e0a\u7684\uff0c\u6bd4\u5982\u8d28\u91cf\uff1b\u53c8\u6709\u975e\u5b9e\u8d28\u7684\uff0c\u6bd4\u5982\u5ba3\u4f20\u3001\u5e7f\u544a \u8fd9\u4e00\u70b9\u6b63\u662f\u5bfc\u81f4\u8fd9\u79cd\u5e02\u573a\u5f62\u6210\u7684\u4e3b\u8981\u539f\u56e0
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_14","title":"\u9700\u6c42\u66f2\u7ebf","text":"
\u4ece\u957f\u671f\u6765\u770b\uff0c\u5382\u5546\u53ef\u4ee5\u6bd4\u8f83\u81ea\u7531\u5730\u8fdb\u5165\u6216\u9000\u51fa\u4e00\u4e2a\u884c\u4e1a\u3002\u7531\u4e8e\u5382\u5546\u6570\u76ee\u5f88\u591a\uff0c\u6bcf\u4e2a\u5382\u5546\u7684\u89c4\u6a21\u4e5f\u4e0d\u662f\u592a\u5927\uff0c\u6240\u9700\u8981\u7684\u8d44\u672c\u4e0d\u662f\u5f88\u591a\uff0c\u56e0\u800c\u8981\u8fdb\u51fa\u884c\u4e1a\u6ca1\u6709\u591a\u5927\u7684\u969c\u788d\u3002
\u5e02\u573a\u4fe1\u606f\u57fa\u672c\u5b8c\u5907\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_15","title":"\u77ed\u671f\u5747\u8861","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_16","title":"\u5be1\u5934\u5784\u65ad\u5e02\u573a","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_17","title":"\u7279\u5f81\u4e0e\u6210\u56e0","text":"
- \u5784\u65ad\u7ade\u4e89\u5382\u5546\u6240\u9762\u4e34\u7684\u9700\u6c42\u66f2\u7ebf\u6709\u4e24\u6761\uff1a\u4e00\u6761\u79f0\u4e3a\u4e3b\u89c2\u9700\u6c42\u66f2\u7ebfd0\uff0c\u8868\u793a\u5784\u65ad\u7ade\u4e89\u884c\u4e1a\u4e2d\u7684\u5355\u4e2a\u5382\u5546\u6539\u53d8\u4ea7\u54c1\u4ef7\u683c\uff0c\u800c\u5176\u4ed6\u5382\u5546\u7684\u4ea7\u54c1\u4ef7\u683c\u90fd\u4fdd\u6301\u4e0d\u53d8\u65f6\uff0c\u8be5\u5382\u5546\u7684\u4ea7\u54c1\u4ef7\u683c\u4e0e\u4ea7\u9500\u91cf\u4e4b\u95f4\u7684\u5173\u7cfb\uff1b\u53e6\u4e00\u6761\u79f0\u4e3a\u5b9e\u9645\u9700\u6c42\u66f2\u7ebfD\uff0c\u8868\u793a\u5784\u65ad\u7ade\u4e89\u884c\u4e1a\u4e2d\u7684\u5355\u4e2a\u5382\u5546\u6539\u53d8\u4ea7\u54c1\u4ef7\u683c\uff0c\u5176\u4ed6\u5382\u5546\u7684\u4ea7\u54c1\u4ef7\u683c\u540c\u65f6\u53d8\u5316\u65f6
\u5be1\u5934\u662f\u5bf9\u5be1\u5934\u5784\u65ad\u5e02\u573a\u4e0a\u5382\u5546\u7684\u522b\u79f0\uff0c\u5be1\u5934\u5784\u65ad\uff08Oligopoly\uff09\u5e02\u573a\u662f\u6307\u5c11\u6570\u5382\u5546\u63a7\u5236\u67d0\u4e00\u4ea7\u54c1\u6781\u5927\u90e8\u5206\u751f\u4ea7\u548c\u9500\u552e\u7684\u5e02\u573a\u7ed3\u6784\u3002
\u7279\u5f81
\u7b2c\u4e00\uff0c\u6709\u8bb8\u591a\u4e70\u8005\uff0c\u4f46\u53ea\u6709\u5c11\u6570\u5356\u8005\u3002\u5356\u8005\u7684\u6570\u76ee\u81f3\u5c11\u7b49\u4e8e2\uff0c\u5426\u5219\u5c31\u53d8\u6210\u4e86\u5b8c\u5168\u5784\u65ad\u3002\u5f53\u4e00\u4e2a\u884c\u4e1a\u4e2d\u4ec5\u6709\u4e24\u5bb6\u5382\u5546\u65f6\uff0c\u79f0\u4e4b\u4e3a\u53cc\u5be1\u5934\u3002\u4e00\u822c\u5356\u8005\u7684\u6570\u76ee\u53ef\u4ee5\u591a\u81f3\u51e0\u5bb6\u3001\u5341\u51e0\u5bb6\u4e43\u81f3\u51e0\u5341\u5bb6\u3002\u6bcf\u4e00\u5bb6\u5382\u5546\u5728\u5e02\u573a\u4e0a\u90fd\u6709\u4e3e\u8db3\u8f7b\u91cd\u7684\u5730\u4f4d\uff0c\u5bf9\u5176\u4ea7\u54c1\u7684\u4ef7\u683c\u90fd\u6709\u76f8\u5f53\u7684\u5f71\u54cd\u529b\uff0c\u56e0\u6b64\uff0c\u4ed6\u4eec\u5728\u5e02\u573a\u4e0a\u76f8\u4e92\u4f9d\u5b58\uff0c\u5176\u51b3\u7b56\u8981\u6bd4\u5176\u4ed6\u5e02\u573a\u5382\u5546\u7684\u51b3\u7b56\u590d\u6742\u5f97\u591a\u3002\u4e00\u822c\u53ef\u4ee5\u6839\u636e\u4ed6\u4eec\u4e4b\u95f4\u7684\u4f9d\u5b58\u5173\u7cfb\uff0c\u5c06\u4ed6\u4eec\u7684\u884c\u52a8\u65b9\u5f0f\u5206\u4e3a\u72ec\u7acb\u884c\u52a8\u548c\u76f8\u4e92\u52fe\u7ed3\u4e24\u79cd\u7c7b\u578b\u3002
\u7b2c\u4e8c\uff0c\u5404\u5bb6\u5382\u5546\u6240\u751f\u4ea7\u6216\u9500\u552e\u7684\u4ea7\u54c1\u53ef\u4ee5\u662f\u540c\u8d28\u7684\uff0c\u4e5f\u53ef\u4ee5\u662f\u5f02\u8d28\u7684\u3002\u5bf9\u4e8e\u751f\u4ea7\u6216\u9500\u552e\u540c\u8d28\u4ea7\u54c1\u7684\u5382\u5546\uff0c\u79f0\u5176\u4e3a\u7eaf\u7cb9\u5be1\u5934\uff0c\u800c\u5bf9\u4e8e\u751f\u4ea7\u6216\u9500\u552e\u5f02\u8d28\u4ea7\u54c1\u5382\u5546\uff0c\u5219\u79f0\u5176\u4e3a\u5dee\u522b\u5be1\u5934\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u94a2\u94c1\u3001\u70bc\u94dd\u3001\u77f3\u6cb9\u3001\u6c34\u6ce5\u7b49\u884c\u4e1a\u5c5e\u4e8e\u7eaf\u7cb9\u5be1\u5934\uff0c\u5404\u5382\u5546\u7684\u4ea7\u54c1\u51e0\u4e4e\u6ca1\u6709\u5dee\u522b\uff0c\u5f7c\u6b64\u95f4\u7684\u66ff\u4ee3\u7a0b\u5ea6\u5f88\u9ad8\uff1b\u800c\u673a\u68b0\u3001\u77f3\u6cb9\u4ea7\u54c1\u3001\u6c7d\u8f66\u3001\u5bb6\u7535\u7b49\u884c\u4e1a\u5c5e\u4e8e\u5dee\u522b\u5be1\u5934\uff0c\u5404\u5382\u5546\u7684\u4ea7\u54c1\u6709\u5dee\u522b\uff0c\u5f7c\u6b64\u95f4\u7684\u66ff\u4ee3\u7a0b\u5ea6\u76f8\u5bf9\u8f83\u4f4e\u3002
\u7b2c\u4e09\uff0c\u5382\u5546\u8fdb\u51fa\u884c\u4e1a\u53d7\u5230\u9650\u5236\u3002\u5bf9\u4e8e\u5728\u4f4d\u5382\u5546\u6765\u8bf4\uff0c\u7531\u4e8e\u89c4\u6a21\u8f83\u5927\uff0c\u5e76\u4e14\u62e5\u6709\u65e2\u5f97\u5229\u76ca\uff0c\u4e00\u822c\u4e0d\u4f1a\u8f7b\u6613\u9000\u51fa\u6240\u5728\u884c\u4e1a\uff1b\u800c\u5bf9\u4e8e\u65b0\u5382\u5546\u6765\u8bf4\uff0c\u7531\u4e8e\u89c4\u6a21\u7ecf\u6d4e\u7b49\u81ea\u7136\u969c\u788d\u548c\u5728\u4f4d\u5382\u5546\u7684\u4eba\u4e3a\u8bbe\u969c\uff0c\u901a\u5e38\u5f88\u96be\u8fdb\u5165\u5be1\u5934\u5784\u65ad\u884c\u4e1a\u3002
\u7b2c\u56db\uff0c\u4fe1\u606f\u4e0d\u5b8c\u5168\u3002\u5be1\u5934\u5784\u65ad\u5e02\u573a\u4e0a\uff0c\u7531\u4e8e\u5be1\u5934\u4e4b\u95f4\u7684\u4f9d\u5b58\u5173\u7cfb\uff0c\u4ea4\u6613\u7684\u4fe1\u606f\u662f\u4e0d\u5b8c\u5168\u7684\uff0c\u800c\u4e14\u60c5\u51b5\u975e\u5e38\u590d\u6742\u3002
\u6210\u56e0
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_18","title":"\u7ade\u4e89\u6a21\u578b","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_19","title":"\u53e4\u800c\u8bfa\u6a21\u578b","text":"
- \u89c4\u6a21\u7ecf\u6d4e\u3002
- \u5bf9\u6295\u5165\u7684\u63a7\u5236\u3002\u5982\u679c\u884c\u4e1a\u4e2d\u7684\u8001\u5382\u5546\u80fd\u5bf9\u4ea7\u54c1\u7684\u5173\u952e\u6295\u5165\u8fdb\u884c\u63a7\u5236\uff0c\u90a3\u4e48\u5c31\u80fd\u6709\u6548\u5730\u9650\u5236\u65b0\u5382\u5546\u7684\u8fdb\u5165
- \u5927\u91cf\u7684\u8d44\u672c\u3002\u5728\u8bb8\u591a\u884c\u4e1a\u4e2d\uff0c\u5382\u5546\u9700\u8981\u5927\u91cf\u7684\u8d44\u672c\u624d\u80fd\u4f7f\u5176\u7ecf\u8425\u5904\u5728\u6709\u6548\u7387\u7684\u6c34\u5e73\u4e0a\u3002
- \u6280\u672f\u9886\u5148
- \u6c89\u6ca1\u6210\u672c
- \u653f\u5e9c\u4fdd\u62a4
\u5047\u8bbe\u5982\u4e0b\uff1a
\uff081\uff09\u53ea\u6709\u4e24\u4e2a\u5382\u5546(\u5be1\u5934\u7532\u548c\u5be1\u5934\u4e59)\uff1b \uff082\uff09\u751f\u4ea7\u540c\u8d28\u4ea7\u54c1\uff08\u77ff\u6cc9\u6c34\uff09\uff1b \uff083\uff09\u751f\u4ea7\u6210\u672c\u4e3a\u96f6\uff1b \uff084\uff09\u5382\u5546\u90fd\u51c6\u786e\u4e86\u89e3\u5e02\u573a\u9700\u6c42\u66f2\u7ebf\uff1b \uff085\uff09\u5382\u5546\u65e0\u5408\u8c0b\uff1b \uff086\uff09\u5382\u5546\u901a\u8fc7\u8c03\u6574\u4ea7\u91cf\u5b9e\u73b0\u5229\u6da6\u6700\u5927\u5316
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_20","title":"\u63a8\u5bfc","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_21","title":"\u4e00 \uff1a\u56fe\u63a8\u5bfc\uff08\u9012\u5f52\uff09","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_22","title":"\u4e8c \uff1a\u516c\u5f0f\u63a8\u5bfc","text":"\u53cd\u9700\u6c42\u51fd\u6570\\(P=H-aQ\\) \\(Q=Q_A+Q_B\\) \\(CQ_A=CQ_B=0\\) \\(\\pi _A=P_AQ_A-TC_A=HQ_A-aQ_A^2-aQ_AQ_B\\) \\(\\pi _B=P_BQ_B-TC_B=HQ_B-aQ_B^2-aQ_AQ_B\\) \\(\\frac{d\\pi}{dQ_A}=H-2aQ_A-aQ_B=0\\)
\\(\\frac{d\\pi}{dQ_B}=H-2aQ_B+aQ_A=0\\)
==>\\(Q_A=\\frac{H}{2a}-\\frac{Q_B}{2}\\) \\(Q_B=\\frac{H}{2a}-\\frac{Q_A}{2}\\) \\(Q_A=Q_B=\\frac{H}{3a}\\) ==> \\(P=\\frac{H}{3}\\)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_23","title":"\u7f3a\u9677","text":"\u8be5\u6a21\u578b\u5047\u5b9a\u5382\u5546\u7684\u6700\u4f18\u884c\u4e3a\u662f\u4ee5\u5176\u7ade\u4e89\u5bf9\u624b\u7684\u4ea7\u91cf\u4e0d\u53d8\u4e3a\u6761\u4ef6\u7684\uff0c\u8fd9\u663e\u7136\u4e0d\u7b26\u5408\u73b0\u5b9e\u4e2d\u5be1\u5934\u7684\u884c\u4e3a\u3002\u6b63\u56e0\u4e3a\u5982\u6b64\uff0c\u53e4\u5c14\u8bfa\u6a21\u578b\u4e0d\u662f\u5be1\u5934\u884c\u4e3a\u7684\u4e00\u822c\u5206\u6790\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_24","title":"\u65af\u5a01\u9f50\u6a21\u578b","text":"\u5f53\u5382\u5546A\u964d\u4ef7\u65f6\uff0c\u5176\u4ed6\u5382\u5546\u4e3a\u9632\u6b62\u5931\u53bb\u987e\u5ba2\u4e5f\u76f8\u5e94\u5730\u964d\u4ef7\uff1b\u800c\u5f53\u5382\u5546A\u63d0\u4ef7\u65f6\uff0c\u5176\u4ed6\u5382\u5546\u4e3a\u5438\u5f15\u987e\u5ba2\u5374\u4e0d\u63d0\u4ef7\u3002\u8fd9\u6837\u5382\u5546A\u7684\u9700\u6c42\u66f2\u7ebf\u5c31\u6210\u4e3adED\u90a3\u6837\u7684\u5f2f\u6298\u66f2\u7ebf\uff0c\u5373\u5f53\u4ef7\u683c\u9ad8\u4e8eP0\u65f6\uff0c\u5382\u5546A\u7684\u9700\u6c42\u66f2\u7ebf\u7531\u7ebf\u6bb5dE\u6784\u6210\uff0c\u800c\u5f53\u4ef7\u683c\u4f4e\u4e8eP0\u65f6\uff0c\u5382\u5546A\u7684\u9700\u6c42\u66f2\u7ebf\u7531\u7ebf\u6bb5ED\u6784\u6210
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_25","title":"\u4f8b\u9898","text":"\u4f8b\u98986.1\u3000\u5047\u5b9a\u5784\u65ad\u8005\u9762\u4e34\u7684\u9700\u6c42\u66f2\u7ebf\u4e3aP\uff1d100\uff0d4Q\uff0c\u603b\u6210\u672c\u51fd\u6570\u4e3aTC\uff1d50\uff0b20Q\uff0c\u6c42\uff1a\uff081\uff09\u5784\u65ad\u8005\u5229\u6da6\u6781\u5927\u5316\u65f6\u7684\u4ea7\u91cf\u3001\u4ef7\u683c\u53ca\u5229\u6da6\uff1b\uff082\uff09\u5047\u8bbe\u5784\u65ad\u8005\u9075\u4ece\u5b8c\u5168\u7ade\u4e89\u6cd5\u5219\uff0c\u90a3\u4e48\u5382\u5546\u7684\u4ea7\u91cf\u3001\u4ef7\u683c\u53ca\u5229\u6da6\u5982\u4f55\uff1f\u5e76\u4e0e\uff081\uff09\u8fdb\u884c\u6bd4\u8f83\u3002
(1) \u5229\u7528\u5784\u65ad\u7684\u5747\u8861\u6761\u4ef6\uff1aMC = MR
(2) \u5229\u7528\u5b8c\u5168\u7ade\u4e89\u7684\u5747\u8861\u6761\u4ef6\uff1aMC \uff08= MR\uff09 = P
\u4f8b\u98986.2\u3000\u5047\u5982\u67d0\u5784\u65ad\u5382\u5546\u751f\u4ea7\u7684\u4ea7\u54c1\u80fd\u591f\u5728\u4e24\u4e2a\u4e0d\u540c\u7684\u5e02\u573a\u4e0a\u5b9e\u884c\u5dee\u522b\u5b9a\u4ef7\uff0c\u5176\u751f\u4ea7\u7684\u603b\u6210\u672c\u51fd\u6570\u4e3aTC\uff1dQ2\uff0b10Q\uff0c\u4e24\u4e2a\u5e02\u573a\u7684\u9700\u6c42\u51fd\u6570\u5206\u522b\u4e3aQ1\uff1d32\uff0d0.4P1\uff0cQ2\uff1d18\uff0d0.1P2\uff0c\u6c42\uff1a\uff081\uff09\u5784\u65ad\u5382\u5546\u5229\u6da6\u6781\u5927\u65f6\u4e24\u4e2a\u5e02\u573a\u7684\u9500\u552e\u91cf\u3001\u9500\u552e\u4ef7\u683c\u53ca\u5382\u5546\u7684\u603b\u5229\u6da6\uff1b\uff082\uff09\u5047\u5982\u4e24\u4e2a\u5e02\u573a\u53ea\u80fd\u7d22\u53d6\u76f8\u540c\u7684\u4ef7\u683c\uff0c\u6c42\u89e3\u5229\u6da6\u6781\u5927\u65f6\u7684\u9500\u552e\u91cf\u3001\u9500\u552e\u4ef7\u683c\u548c\u5229\u6da6\u3002
\u4f8b\u9898 6.3
\uff081\uff09\u6839\u636e\u516c\u5f0f\uff0c\u6216\u8005\u91cd\u65b0\u63a8\u5bfc\u62c9\u683c\u6717\u65e5\u6761\u4ef6\u6c42R\u6700\u5927\u503c\uff1b\u6ce8\u610f\u4ed6\u7ed9\u7684\u5f62\u5f0f\u4e3a\u9700\u6c42\u51fd\u6570\uff0c\u8981\u6362\u4e3a\u53cd\u9700\u6c42\u51fd\u6570 \uff082\uff09\\(p_1=p_2\\)\u5c06\u51fd\u6570\u53e0\u52a0\u4e3a\u603b\u53cd\u9700\u6c42\u51fd\u6570\u5373\u53ef\uff0c\u4e4b\u540e\u6839\u636eMR=MC\u8ba1\u7b97
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%207%20%E5%8D%9A%E5%BC%88%E8%AE%BA/","title":"Chapter 7 \u535a\u5f08\u8bba","text":"\u7ea6 0 \u4e2a\u5b57
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/","title":"Chapter 8 \u8981\u7d20\u5e02\u573a","text":"\u7ea6 482 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
\u672c\u7ae0\u4ece\u4ea7\u54c1\u5e02\u573a\u8f6c\u5411\u2f63\u4ea7\u8981\u7d20\u5e02\u573a\uff0c\u7740\u91cd\u5206\u6790\u8981\u7d20\u4ef7\u683c\u7684\u51b3\u5b9a\u95ee\u9898\u3002 \u2fb8\u5148\uff0c\u8003\u5bdf\u2f63\u4ea7\u8981\u7d20\u7684\u9700\u6c42\u3001\u4f9b\u7ed9\u53ca\u5176\u4ef7\u683c\u7684\u51b3\u5b9a\uff1b \u5176\u6b21\u5206\u6790\u52b3\u52a8\u3001\u8d44\u672c\u3001\u2f1f\u5730\u3001\u4f01\u4e1a\u5bb6\u624d\u80fd\u7b49\u5404\u79cd\u2f63\u4ea7\u8981\u7d20\u5e02\u573a\u4e0a\u7684\u4f9b\u6c42\u53ca\u5176\u4ef7\u683c\u7684\u51b3\u5b9a\u3002 \u7531\u4e8e\u8981\u7d20\u4ef7\u683c\u548c\u6570\u91cf\u662f\u51b3\u5b9a\u6d88\u8d39\u8005\u6536\u2f0a\u2f54\u5e73\u7684\u91cd\u8981\u56e0\u7d20\uff0c\u51b3\u5b9a\u4e86\u8981\u7d20\u4ef7\u683c\u548c\u6570\u91cf\uff0c\u5728\u5f88\u2f24\u7a0b\u5ea6\u4e0a\u51b3\u5b9a\u4e86\u8981\u7d20\u6240\u6709\u8005\u7684\u6536\u2f0a\u5206\u914d\uff0c\u6240\u4ee5\u8981\u7d20\u5e02\u573a\u7406\u8bba\u5728\u7ecf\u6d4e\u5b66\u4e2d\u4e5f\u88ab\u79f0\u4f5c\u201c\u5206\u914d\u7406\u8bba\u201d\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_1","title":"\u8981\u7d20\u7684\u9700\u6c42","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_2","title":"\u8fb9\u9645\u6536\u76ca","text":"\\(MR_F\\)\u8981\u7d20\u7684\u8fb9\u9645\u6536\u76ca \\(MC_F\\)\u8981\u7d20\u7684\u8fb9\u9645\u6210\u672c
\u8fb9\u9645\u4ea7\u54c1\u4ef7\u503c\uff08Value of Marginal Product, VMP\uff09 \u8fb9\u9645\u4ea7\u91cf\uff08MP\uff09 \\(VMP=MP*P\\)
\u8fb9\u9645\u4ea7\u54c1\u6536\u76ca\uff08Revenue of Marginal Product,MRP\uff09 \\(MRP=MP*MR\\)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_3","title":"\u8fb9\u9645\u6210\u672c","text":"\u603b\u6210\u672c\\(TC=wL+rK,L\u52b3\u52a8\uff0cK\u8d44\u672c\\) \u5b8c\u5168\u7ade\u4e89 P=MR
\u200b \u5bf9\u4e8e\u5e02\u573a\u800c\u8a00\uff0c\u5e02\u573a\u5bf9\u8981\u7d20\u7684\u9700\u6c42\u66f2\u7ebf != \u8fb9\u9645\u4ea7\u54c1\u4ef7\u503c\u66f2\u7ebf\uff08VMP\uff09 \u200b \u5de5\u8d44w\u4e0b\u964d\uff0c\u6240\u6709\u5382\u5546\u5bf9\u52b3\u52a8\u529b\u7684\u9700\u6c42\u589e\u52a0\uff0c\u66f2\u7ebf\u6574\u4f53\u53f3\u79fb \u200b \u5f53\u2f2f\u8d44\uff08w\uff09\u4e0b\u964d\u65f6\uff0c\u7531\u4e8e\u6240\u6709\u2f1a\u5546\u90fd\u4f1a\u589e\u52a0\u5bf9\u52b3\u52a8\u7684\u9700\u6c42\u91cf\uff0c\u2f63\u4ea7\u51fa\u66f4\u591a\u7684\u4ea7\u54c1\u3002\u8fd9\u6837\uff0c\u5728\u4ea7\u54c1\u7684\u5e02\u573a\u9700\u6c42\u4e0d\u53d8\u65f6\uff0c\u4ea7\u54c1\u5e02\u573a\u4f9b\u7ed9\u7684\u589e\u52a0\u4f1a\u5f15\u8d77\u4ea7\u54c1\u5e02\u573a\u4ef7\u683c\u7684\u4e0b\u964d\uff0c\u2f7d\u4ea7\u54c1\u7684\u5e02\u573a\u4ef7\u683c\u7684\u4e0b\u964d\u4f7f\u5f97\u5404\u4e2a\u2f1a\u5546\u7684\u52b3\u52a8\u7684\u9700\u6c42\u66f2\u7ebf\u90fd\u4ecedL\u5411\u5de6\u79fb\u2f84dL \u2032\u3002
\u975e\u5b8c\u5168\u7ade\u4e89 \u6c42\u504f\u5bfc\uff0c\u5f97\u5230L\u6216\u8005K\u7684\u8fb9\u9645\u6210\u672c
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_4","title":"\u5382\u5546\u4f7f\u7528\u8981\u7d20\u7684\u539f\u5219","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_5","title":"\u8981\u7d20\u7684\u4f9b\u7ed9","text":"\u6d88\u8d39\u8005\uff1a
\u4ece\u8981\u7d20\u7684\u4f9b\u7ed9\u6765\u8bb2\uff0c\u7531\u4e8e\u8981\u7d20\u4f9b\u7ed9\u672c\u2f9d\u5bf9\u6d88\u8d39\u8005\u5e76\u4e0d\u76f4\u63a5\u4ea7\u2f63\u6548\u2f64\uff0c\u53ea\u6709\u5f53\u6d88\u8d39\u8005\u4f9b\u7ed9\u8981\u7d20\u5f97\u5230\u6536\u2f0a\u5e76\u2f64\u4e8e\u6d88\u8d39\u65f6\u624d\u4ea7\u2f63\u6548\u2f64.
\u200b \u8981\u7d20\u4f9b\u7ed9 \u4e00\u822c\u4ea7\u751f\u95f4\u63a5\u6548\u7528
\u200b \u4fdd\u7559\u81ea\u7528 \u4e00\u822c\u4ea7\u751f\u76f4\u63a5\u6548\u7528
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_6","title":"\u52b3\u52a8\u4e0e\u5de5\u8d44","text":""},{"location":"%E6%9D%82%E8%B0%88/","title":"Index","text":"\u7ea6 15 \u4e2a\u5b57
Abstrct
\u5728\u8fd9\u91cc\u653e\u4e00\u70b9\u4e0d\u592a\u597d\u5206\u7c7b\u7684\u4e1c\u897f
"},{"location":"%E6%9D%82%E8%B0%88/Compile/","title":"What happened when Compiling?","text":"\u7ea6 4 \u4e2a\u5b57
"}]} \ No newline at end of file +{"config":{"lang":["zh","en"],"separator":"[\\s\\-\\.]+","pipeline":["stemmer"]},"docs":[{"location":"","title":"\u6b22\u8fce\\(@^0^@)/","text":"\u7ea6 23 \u4e2a\u5b57
\u7ad9\u70b9\u7edf\u8ba1
\u672c\u7ad9\u5171\u6709 {{ pages }} \u4e2a\u9875\u9762 {{ words }} \u4e2a\u5b57 {{ codes }} \u884c\u4ee3\u7801
","tags":["homepage"]},{"location":"CS/","title":"\u8bfe\u5185","text":"\u7ea6 17 \u4e2a\u5b57
\u6982\u8ff0
\u8fd9\u91cc\u653e\u4e00\u4e9bZJU CS\u8bfe\u5185\u7684\u4e1c\u897f
"},{"location":"CS/OOP/","title":"OOP","text":"\u7ea6 4283 \u4e2a\u5b57 651 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 30 \u5206\u949f
INFO
\u4e2a\u4eba\u5728\u8bb0\u8fd9\u90e8\u5206\u7b14\u8bb0\u7684\u65f6\u5019\u4f1a\u6709\u4e00\u90e8\u5206\u62d3\u5c55\u5185\u5bb9\uff0c\u53ef\u80fd\u8003\u8bd5\u5e76\u4e0d\u8981\u6c42\u638c\u63e1;\u4e5f\u6709\u4e00\u90e8\u5206\u5185\u5bb9\u7531\u4e8e\u65f6\u95f4\u539f\u56e0\u6216\u8005\u81ea\u5df1\u89c9\u5f97\u6ca1\u5fc5\u8981\u5199\u4e8e\u662f\u6ca1\u6709\u7740\u58a8\u3002BTW\uff0c\u4e5f\u53ef\u80fd\u4f1a\u6709\u4e00\u4e9b\u9519\u8bef/\u7eb0\u6f0f\uff0c\u6b22\u8fce\u53cd\u9988\uff01
\u672c\u6765\u662f\u60f3\u8981\u628aC++\u7684\u7b14\u8bb0\u4f5c\u4e3a\u6bcf\u4e2a\u70b9\u4e00\u4e2aPage\uff0c\u540e\u6765\u53d1\u73b0\u8fd9\u6837\u4ece\u590d\u4e60OOP\u7684\u89d2\u5ea6\u975e\u5e38\u4e0d\u5229\u3002
\u5185\u5bb9\u6765\u6e90\uff1a\u9648\u7fd4\u8001\u5e08\u4e0a\u8bfe\u5185\u5bb9\u53caPPT\uff0cljj\u8001\u5e08PPT\uff0c\u53ca\u90e8\u5206\u7f51\u7edc\u8d44\u6e90\uff08ljj 21\u5e74\u7684PPT\u4e2d\u5185\u5bb9\u6709\u4e00\u5b9a\u7eb0\u6f0f\uff0c\u770b\u7684\u65f6\u5019\u4e0d\u8981\u76f2\u4ece\uff0c\u6709\u4e00\u90e8\u5206\u89c4\u8303\u5df2\u7ecf\u88ab\u8f83\u65b0\u7684\u89c4\u8303\u53d6\u4ee3;\u4f46\u603b\u4f53\u4e0a\u8fd8\u662f\u633a\u5b9e\u7528\u7684\uff09
- \u4e00\u4e9b\u9898\u76ee\u6536\u96c6\u7684BLOG
- OOP Midterm Review
- \u5386\u5e74\u5377
- 98\u6c47\u603b
- \u65b0\u768498\u6c47\u603b **\u8fd9\u4e2a\u5df2\u7ecf\u5f88\u5168\u9762\u4e86\uff0c\u5efa\u8bae\u770b\u8fd9\u4e2a
- \u7f51\u7ad9\u63a8\u8350
- cpp reference
- modern CPP Programing \u8fd9\u4e2a\u91cc\u9762\u8bb2\u5f97\u5f88\u591a\u4e1c\u897f\u5f88\u5b9e\u7528
- \u9648\u7fd4\u8001\u5e08\u63a8\u8350\u7684\u4e86\u89e3\u7b97\u6cd5\u5e93\u7684\u89c6\u9891
- this pointer \u770b\u8fc7\u4e00\u4e9b\u5173\u4e8eMemory\u7ba1\u7406\u7684\u5185\u5bb9
- \u4e00\u4e9b\u5de5\u5177\u7684\u5b66\u4e60
- CMAKE \u7a0d\u5fae\u770b\u70b9\u4f8b\u5b50\uff0c\u80fd\u660e\u767d\u57fa\u7840\u7528\u6cd5\uff1b\u66f4\u9ad8\u7684\u5c31\u6839\u636e\u4e2a\u4eba\u9700\u8981
\u8bfe\u7a0b\u8bc4\u4ef7/\u603b\u7ed3
\u6388\u8bfe\u6559\u5e08\uff1a\u9648\u7fd4
\u9648\u7fd4\u8001\u5e08\u662fOOP\u8fd9\u95e8\u8bfe\u516c\u8ba4\u7684\u201c\u795e\u201d\uff0c\u5728\u8bfe\u5802\u4e0a\u7528Vim\u6f14\u793a\u4ee3\u7801\u8bb2\u89e3C++\u7279\u6027\uff0c\u5f88\u7b26\u5408\u6211\u5bf9\u7a0b\u5e8f\u5458\u7684\u523b\u677f\u5370\u8c61
\u5173\u4e8e\u8003\u8bd5\uff1a\u8fd9\u95e8\u8bfe\u7684\u8003\u8bd5\u8fd9\u51e0\u5e74\u4e0d\u662f\u5f88\u96be\uff0c\u8003\u524d\u4e00\u5b9a\u5237\u51e0\u5957\u5386\u5e74\u5377\uff0c\u867d\u7136\u98ce\u683c\u5dee\u5f02\u4f1a\u6bd4\u8f83\u5927\uff0c\u4f46\u5bf9\u4e8e\u96be\u70b9\u7684\u8003\u5bdf\u5927\u5dee\u4e0d\u5dee\u3002
\u5206\u6570\u6784\u6210
\u5206\u6570\u6784\u6210\u591a\u4e2a\u6559\u5b66\u73ed\u76f8\u5dee\u4e0d\u5927\u3002\u636e\u6211\u4e2a\u4eba\u4e86\u89e3\uff0c\u7fc1\u607a\u8001\u5e08\u73ed\u4f1a\u6709\u671f\u4e2d\u8003\u8bd5\u3001\u8bfe\u524d\u5c0f\u6d4b\u3001\u7b7e\u5230\uff0c\u5e73\u65f6\u4f5c\u4e1a\u4e5f\u4f1a\u7a0d\u5fae\u591a\u4e00\u70b9\u3002cx\u8001\u5e08\u73ed\u5e73\u65f6\u5206\u57fa\u672c\u7ed9\u6ee1
"},{"location":"CS/OOP/#_1","title":"\u96f6\u788e\u77e5\u8bc6","text":"
- Attendance
- Assignment \u9648\u7fd4\u8001\u5e08\u73ed\u7ea7\u4f5c\u4e1a\u5355\u5468\u4e00\u4e2aLab\uff0c\u53cc\u5468\u662f\u7b80\u5355\u7684\u7a0b\u5e8f\u586b\u7a7a\u3001\u9009\u62e9
- Lab
- \u5e73\u65f6Lab
- Final Lab \u505a\u5e8f\u5217\u5316\u7684\u5904\u7406
- Exam
- Fill in Blank (text) -------- 30 points, 8 problems
- write the output of the given code
- Fill in blank (program) --- 30 points, 2 problems
- single line code completion
- Subjective (function) ----- 20 points, 1 problem \u4f7f\u7528\u4ee3\u7801markdown\u4ee3\u7801\u5757\u5d4c\u8fdb\u53bb\uff0c\u5426\u5219\u53ef\u80fd\u51fa\u73b0\u90e8\u5206\u6d88\u5931
- class design
- function implementation
- Multiple Choice (SA) ----- 20 points, 1 problem \u5355\u9009
- miscellaneous \u6982\u5ff5\u6027\uff0c\u8bed\u8a00\u4e0a\u7684; \u4f8b\u5982\uff0cC++\u8bed\u8a00\u7684\u7279\u6027
mention
\u8fd9\u91cc\u7684\u4e00\u90e8\u5206\u5185\u5bb9\uff08union\uff09\u6211\u53ea\u5728ljj\u768421\u5e74PPT\u4e0a\u770b\u5230\u8fc7\uff0c\u4e0d\u77e5\u9053\u5728\u4e0d\u5728\u8003\u8bd5\u8303\u56f4\u5185
"},{"location":"CS/OOP/#const","title":"const","text":"
const int
int const
\u7b49\u4ef7
int * const p
\u8fd9\u4e2a\u6307\u9488\u662f\u4e00\u4e2a\u5e38\u91cf\uff0c\u5fc5\u987b\u5728\u5b9a\u4e49\u7684\u65f6\u5019\u8d4b\u503c\uff0c\u6307\u5411\u4e00\u4e2aint
\u7c7b\u578b\u7684\u53d8\u91cf
int const *p
\u8fd9\u4e2a\u6307\u9488\u672c\u8eab\u4e0d\u662fconst\uff0c\u6307\u5411\u7684\u5bf9\u8c61\u662fconst\u5bf9\u8c61
int const * const p
\"\u7f1d\u5408\u602a\"\uff08\u7c7b\u7684const\u5bf9\u8c61
"},{"location":"CS/OOP/#inline","title":"inline","text":"
- \u4e0d\u80fd\u8c03\u7528non-const\u51fd\u6570
"},{"location":"CS/OOP/#_2","title":"\u5f15\u7528","text":"
- \u9012\u5f52\u51fd\u6570\u4e0d\u80fd\u58f0\u660e\u4e3ainline\u51fd\u6570
- \u7c7b\u4e2d\u542b\u6709\u51fd\u6570\u4f53\u9ed8\u8ba4\u4e3ainline\u51fd\u6570
\u50cf\u662f\u4e00\u4e2a\u6307\u9488\u5e38\u91cf,\u53ea\u6709\u5728\u521d\u59cb\u5316\u7684\u65f6\u5019\u624d\u4f1a\u8d4b\u503c,\u4e4b\u540e\u5b83\u7684\u503c\u4e0d\u53d8,\u4f46\u662f\u6307\u5411\u7684\u53ef\u80fd\u4f1a\u53d8.
const int &
\u7684\u9650\u5236\u662f\u4e0d\u80fd\u901a\u8fc7\u8fd9\u4e2a\u5f15\u7528\u53d8\u91cf\u5bf9\u503c\u8fdb\u884c\u6539\u53d8."},{"location":"CS/OOP/#static-extern","title":"static & extern","text":"
- \u4e0d\u80fd\u58f0\u660e\u5f15\u7528\u7684\u5f15\u7528\uff0c\u4e5f\u4e0d\u80fd\u5b9a\u4e49\u5f15\u7528\u7684\u6307\u9488\u3002\u5982\uff1a \u4e0b\u4f8b\u4e2d\u7684\u64cd\u4f5c\u662f\u8fbe\u4e0d\u5230\u7684\uff1a
int a;\nint & & ra=a;\nint &*p=&ra; //\u9519\u8bef\n
- \u4e0d\u80fd\u5efa\u7acb\u6570\u7ec4\u7684\u5f15\u7528\uff0c\u56e0\u4e3a\u6570\u7ec4\u662f\u4e00\u4e2a\u7531\u82e5\u5e72\u4e2a\u5143\u7d20\u6240\u7ec4\u6210\u7684\u96c6\u5408\uff0c\u6240\u4ee5\u5c31\u65e0\u6cd5\u5efa\u7acb\u4e00\u4e2a\u6570\u7ec4\u7684\u522b\u540d\u3002
- \u4e0d\u80fd\u5efa\u7acb\u7a7a\u6307\u9488\u7684\u5f15\u7528\uff0c\u5982\uff1a\u4e0d\u80fd\u5efa\u7acb
int &rp=NULL
- \u4e5f\u4e0d\u80fd\u5efa\u7acb\u7a7a\u7c7b\u578bvoid\u7684\u5f15\u7528\uff0c\u5982\u4e0d\u80fd\u5efa\u7acb\uff1a
void &ra=3
- \u5bf9\u4e8e\u4e00\u4e2a\u63a5\u53d7
non-const
\u53d8\u91cf\u7684\u51fd\u6570\u6765\u8bf4,\u4f20\u5165\u7684\u53c2\u6570\u4e00\u5b9a\u8981\u662f\u4e00\u4e2a\u5de6\u503cvoid func (int &);\nfunc (i * 3); // Warning or Error!\n
NOTES
"},{"location":"CS/OOP/#inline-function","title":"inline Function","text":""},{"location":"CS/OOP/#defalut-value","title":"Defalut Value","text":"inline int add(int a,int b){...}\n
"},{"location":"CS/OOP/#_3","title":"\u4f5c\u7528\u57df\u6807\u8bc6\u7b26","text":"
- Defalut value\u5fc5\u987b\u5728\u51fd\u6570\u6700\u53f3\u4fa7
- \u7b2c\u4e00\u4e2a\u7f3a\u7701\u503c\u51fa\u73b0\u4e4b\u540e\uff0c\u540e\u9762\u7684\u6240\u6709\u7f3a\u7701\u503c\u90fd\u9ed8\u8ba4\u4e3a\u7f3a\u7701\u503c
int fun(int I,int j=5,int k); //\u9519\u8bef\nint fun(int I,int k = 1,int j=5); //\u6b63\u786e\nfun(0,0) // Right\nfun(0) // Right\nfun(0,,0) // Wrong\n
::
\u5728\u5c40\u90e8\u533a\u57df\u4f7f\u7528\u5168\u5c40\u7684\u503c"},{"location":"CS/OOP/#union","title":"union","text":"int A = 500;\nint main()\n{\n int A = 40;\n cout << A << \" \" << ::A << endl;\n return 0;\n}\n
The size of the union is equal to the size of the largest data type.
\u6682\u65f6\u611f\u53d7\u4e0d\u5230\u4ed6\u6709\u4ec0\u4e48\u7528
"},{"location":"CS/OOP/#named-casts","title":"Named Casts","text":""},{"location":"CS/OOP/#static_cast","title":"static_cast","text":"
- \u5168\u5c40\u533f\u540dunion\u5fc5\u987b\u662fstatic
\u6839\u636e\u7f16\u8bd1\u65f6\u72b6\u6001\u8fdb\u884ccast\u8f6c\u6362
example
- \u53ea\u80fd\u8f6c\u6362\u76f8\u5173\u7684\u5173\u7cfb
\u4e0d\u80fd\u79fb\u9664const
\u57fa\u7840\u6570\u636e\u7c7b\u578b\u7684\u8f6c\u6362
- \u6d3e\u751f\u7684\u6307\u9488/\u5f15\u7528\u5411\u57fa\u7c7b
- \u57fa\u7c7b\u5411\u6d3e\u751f\u7c7b
\u8f93\u51fa\uff1aclass Base\n{\npublic:\n int val;\n Base(int x) : val(x) { cout << \"Base()\" << endl; }\n};\nclass Derived : public Base\n{\npublic:\n Derived(int x) : Base(x) { cout << \"Derived()\" << endl; }\n};\nclass Another\n{\n};\nint main()\n{\n double b = 1.01;\n int a = static_cast<int>(b);\n Base base(1), *bp;\n Derived d(2), *dp;\n bp = &base;\n // Derived d = static_cast<Derived>(base); \u9519\u8bef\uff01\u53ea\u80fd\u6307\u9488/\u5f15\u7528\n dp = static_cast<Derived *>(bp);\n cout << dp->val << endl;\n dp = &d;\n bp = static_cast<Base *>(dp);\n cout << bp->val << endl;\n return 0;\n}\n
"},{"location":"CS/OOP/#dynamic_cast","title":"dynamic_cast","text":"Base()\nBase()\nDerived()\n1\n2\n
\u83b7\u5f97\u8fd0\u884c\u65f6\u7684\u72b6\u6001
- \u5fc5\u987b\u8981\u662f\u591a\u6001\uff0c\u9700\u8981\u5b58\u5728Virtual Function\u6765\u83b7\u53d6\u8fd0\u884c\u65f6\u4fe1\u606f
- \u53ea\u9700\u8981\u8f6c\u6362\u7684\u57fa\u7c7b\u662f\u591a\u6001\u7c7b\u5c31\u53ef\u4ee5\u8fd0\u884c\uff0c\u4f46\u662f\u53ef\u80fd\u4ea7\u751fnullptr
"},{"location":"CS/OOP/#reinterpret_cast","title":"reinterpret_cast","text":"A *pa = new B;\nC *pc = static_cast<C *>(pa); // OK: but *pa is B!\ncout << pa << endl; // 0xe22580\ncout << pc << endl; // 0xe22580\nB *pb = dynamic_cast<B *>(pa); // OK:\nC *pcDy = dynamic_cast<C *>(pa); // Not OK:\ncout << pb << endl; // 0xe22580\ncout << pcDy << endl; // 0 nullptr\n
\u5e95\u5c42\u8868\u793a\u4e0d\u53d8\uff0c\u4f46\u662f\u7406\u89e3\u4e3a\u53e6\u5916\u4e00\u79cd
"},{"location":"CS/OOP/#const_cast","title":"const_cast","text":"const
const\u4e4b\u95f4\u6709\u533a\u522b\uff1a\u7f16\u8bd1\u65f6\u548c\u7f16\u8bd1\u540e\u83b7\u5f97\u5e38\u91cf\u5728\u7a0b\u5e8f\u4e2d\u8868\u73b0\u4e0d\u540c
"},{"location":"CS/OOP/#namespace","title":"NameSpace","text":"int x = 7;\nconst int a = 7; // if a = x\nint *p;\np = const_cast<int *>(&a);\ncout << a << endl;\ncout << *p << endl;\n*p = 155;\ncout << a << endl;\ncout << *p << endl;\n\n> 7\n> 7\n> 7 // a = 155\n> 155\n
GeeksForGeeks
C++ Reference
"},{"location":"CS/OOP/#mi","title":"\u591a\u91cd\u7ee7\u627f MI","text":"
- \u547d\u540d\u7a7a\u95f4\u53ef\u4ee5\u5b9a\u4e49\u53d8\u91cf\u3001\u51fd\u6570\u3001\u7c7b\u578b
- \u547d\u540d\u7a7a\u95f4\u53ef\u4ee5\u5d4c\u5957
- \u649e\u547d\u540d\u7a7a\u95f4 -> Ambiguities
- \u522b\u540d
namespace short_ns = supercalifragilistic;
- \u5408\u6210
namespace mine { \n using orig::Cat; // use Cat class from orig \n void x(); \n void y();\n}\n
- \u4e0d\u4e00\u5b9a\u5728\u540c\u4e00\u4e2amodule\u4e2d \u53ef\u4ee5\u8de8\u591a\u6587\u4ef6\u5b58\u5728
Protocol / Interface classes
"},{"location":"CS/OOP/#memory","title":"Memory","text":""},{"location":"CS/OOP/#_4","title":"\u5185\u5b58\u57fa\u7840\u77e5\u8bc6","text":""},{"location":"CS/OOP/#_5","title":"\u52a8\u6001\u5185\u5b58\u5206\u914d","text":"\u53e6\u4e00\u5757\u7b14\u8bb0
"},{"location":"CS/OOP/#class","title":"Class","text":"NOTE
\u8003\u8bd5\u7684\u65f6\u5019\u5b9a\u4e49\u7c7b\u7684\u7ed3\u675f\u8981\u8bb0\u5f97\u52a0
;
TODO: \u5de6\u503c\u548c\u53f3\u503c\u5f15\u7528
::Error:: \u975e\u5e38\u91cf\u5f15\u7528\u7684\u521d\u59cb\u503c\u5fc5\u987b\u4e3a\u5de6\u503cC/C++(461)
"},{"location":"CS/OOP/#construct-destruct","title":"construct / destruct","text":"void fun(A &a)\n{\n cout << \"A a\" << a.get();\n}\nint main()\n{\n fun(A());\n return 0;\n}\n
Construct
- \u6ce8\u610f,\u4e00\u4e2a\u7c7b\u7684\u6784\u9020\u51fd\u6570\u4e2d\u542b\u6709\u4e00\u4e2a\u9759\u6001\u53d8\u91cf,\u8fd9\u4e2a\u9759\u6001\u53d8\u91cf\u53ea\u6709\u7b2c\u4e00\u6b21\u8c03\u7528\u624d\u4f1a\u521d\u59cb\u5316
"},{"location":"CS/OOP/#this","title":"this\u6307\u9488","text":"Date::Date(int y, int m, int d) // \u5b9a\u4e49\u6784\u9020\u51fd\u6570\n{\n year = y;\n month = m;\n day = d;\n Time time(11, 11, 11);\n // \u5728\u7c7bDate\u5b9a\u4e49\u7684\u6784\u9020\u51fd\u6570\u4e2d\u5b9a\u4e49\u7c7bTime\u7684\u5bf9\u8c61\uff08\u5c40\u90e8\uff09\n // \u8fd9\u91cc\u4e5f\u53ea\u5b9a\u4e49\u4e00\u6b21\n static Time time1(12, 12, 12);\n // \u5728\u7c7bDate\u5b9a\u4e49\u7684\u6784\u9020\u51fd\u6570\u4e2d\u5b9a\u4e49\u7c7bTime\u7684\u9759\u6001\u5bf9\u8c61\uff08\u5c40\u90e8\uff09\n cout << \"Date Constructor\" << year << \":\" << month << \":\" << day << endl;\n}\n
this
this\u6307\u9488\u662f\u4e00\u4e2a\u9690\u542b\u4e8e\u6bcf\u4e00\u4e2a\u6210\u5458\u51fd\u6570\u4e2d\u7684\u7279\u6b8a\u6307\u9488\u3002\u5b83\u6307\u5411\u6b63\u64cd\u4f5c\u8be5\u6210\u5458\u51fd\u6570\u7684\u5bf9\u8c61\u3002
\u5f53\u5bf9\u4e00\u4e2a\u5bf9\u8c61\u8c03\u7528\u6210\u5458\u51fd\u6570\u65f6\uff0c\u7f16\u8bd1\u7a0b\u5e8f\u5148\u5c06\u5bf9\u8c61\u7684\u5730\u5740\u8d4b\u7ed9this\u6307\u9488\uff0c\u7136\u540e\u8c03\u7528\u6210\u5458\u51fd\u6570\u3002
\u6bcf\u6b21\u6210\u5458\u51fd\u6570\u5b58\u53d6\u6570\u636e\u6210\u5458\u65f6\uff0cC++\u7f16\u8bd1\u5668\u5c06\u6839\u636ethis\u6307\u9488\u6240\u6307\u5411\u7684\u5bf9\u8c61\u6765\u786e\u5b9a\u5e94\u8be5\u5f15\u7528\u54ea\u4e00\u4e2a\u5bf9\u8c61\u7684\u6570\u636e\u6210\u5458\u3002
\u901a\u5e38this\u6307\u9488\u5728\u7cfb\u7edf\u4e2d\u662f\u9690\u542b\u5b58\u5728\u7684\uff0c\u4e5f\u53ef\u4ee5\u628a\u5b83\u663e\u5f0f\u8868\u793a\u51fa\u6765\u3002
"},{"location":"CS/OOP/#copy-control","title":"Copy Control","text":"
- this\u6307\u9488\u662f\u4e00\u4e2aconst\u6307\u9488\uff0c\u4e0d\u80fd\u5728\u7a0b\u5e8f\u4e2d\u4fee\u6539\u5b83\u6216\u7ed9\u5b83\u8d4b\u503c\u3002
- this\u6307\u9488\u662f\u4e00\u4e2a\u5c40\u90e8\u6570\u636e\uff0c\u5b83\u7684\u4f5c\u7528\u57df\u4ec5\u5728\u4e00\u4e2a\u5bf9\u8c61\u7684\u5185\u90e8,\u901a\u8fc7 this \u53ef\u4ee5\u8bbf\u95ee\u7c7b\u7684\u6240\u6709\u6210\u5458\uff0c\u5305\u62ec private\u3001protected\u3001public \u5c5e\u6027\u7684\u3002
- \u6709\u5728\u5bf9\u8c61\u88ab\u521b\u5efa\u4ee5\u540e\u624d\u4f1a\u7ed9 this \u8d4b\u503c\uff0c\u5e76\u4e14\u8fd9\u4e2a\u8d4b\u503c\u7684\u8fc7\u7a0b\u662f\u7f16\u8bd1\u5668\u81ea\u52a8\u5b8c\u6210\u7684\uff0c\u4e0d\u9700\u8981\u7528\u6237\u5e72\u9884\uff0c\u7528\u6237\u4e5f\u4e0d\u80fd\u663e\u5f0f\u5730\u7ed9 this \u8d4b\u503c\u3002
"},{"location":"CS/OOP/#_6","title":"\u62f7\u8d1d\u6784\u9020\u51fd\u6570","text":"class A\n{\npublic:\n A(int i) : mi(i) {}\n A(const A &rhs) : mi(rhs.mi)\n {\n cout << \"A::A(&)\" << endl;\n }\n virtual void f()\n {\n cout << \"A::f(), \" << mi << endl;\n }\nprotected:\n int mi;\n};\n
Copy
\u8c03\u7528\u62f7\u8d1d\u6784\u9020\u51fd\u6570\u7684\u60c5\u51b5\u6709\u4e09\u79cd\uff1a \uff081\uff09\u660e\u786e\u8868\u793a\u7531\u4e00\u4e2a\u5bf9\u8c61\u521d\u59cb\u5316\u53e6\u4e00\u4e2a\u5bf9\u8c61\u3002 \uff082\uff09\u5f53\u5bf9\u8c61\u4f5c\u4e3a\u51fd\u6570\u5b9e\u53c2\u4f20\u9012\u7ed9\u51fd\u6570\u5f62\u53c2\u65f6\u3002 \uff083\uff09\u5f53\u5bf9\u8c61\u4f5c\u4e3a\u51fd\u6570\u7684\u8fd4\u56de\u503c\uff0c\u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u5bf9\u8c61\u3002
- \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u7f16\u8bd1\u5668\u4f1a\u6709\u4e00\u4e2a
- \u539f\u751f\u7c7b\u578b\u503c\u62f7\u8d1d
- class\u8c03\u7528\u5176\u62f7\u8d1d\u51fd\u6570
- \u4f46\u662f\u5bf9\u4e8e\u6307\u9488\u800c\u8a00\uff0c\u5b83\u4e5f\u662f\u503c\u62f7\u8d1d\uff0c\u5bfc\u81f4\u6709\u4e24\u4e2a\u6307\u9488\u6307\u5411\u540c\u4e00\u4e2a\u5143\u7d20\u3002\u8fd9\u5bfc\u81f4\u5b83\u7684\u7ba1\u7406\u4e0d\u660e\u786e\uff0c\u53ef\u80fd\u5bf9\u540c\u4e00\u5757\u5730\u5740\u8fdb\u884c\u4e24\u6b21\u751a\u81f3\u591a\u6b21
delete
. \u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8981\u5bf9\u6790\u6784\u51fd\u6570\u3001\u62f7\u8d1d\u6784\u9020\u51fd\u6570\u8fdb\u884c\u5b9a\u4e49- \u9ed8\u8ba4\u7684\u62f7\u8d1d\u6784\u9020\u51fd\u6570,\u4f1a\u9012\u5f52\u5730\u5bf9\u6240\u6709\u6210\u5458objects\u8c03\u7528copy
Person(const Person &rhs) = delete;
// \u8fd9\u91cc\u9700\u8981\u5bf9\u7c7b\u4e2d\u7684\u5185\u5b58\u8fdb\u884c\u624b\u52a8\u7684\u7ba1\u7406,\u4e0d\u7136\u4e4b\u540edelete\u4f1a\u91cd\u590d\u5220\u9664\u540c\u4e00\u5757\u5185\u5b58\nPerson::Person( const Person& w ) { \n name = new char[::strlen(w.name) + 1]; \n ::strcpy(name, w.name); \n}\n
Why const and why &
- const: \u4e0d\u80fd\u6539\u53d8
- \u5f15\u7528: \u4e0d\u7136\u4f20\u53c2\u6570\u7684\u65f6\u5019\u53d1\u751f\u503c\u4f20\u9012\uff0c\u53c8\u8981\u8c03\u7528\u62f7\u8d1d\u51fd\u6570\uff0c\u9677\u5165\u6b7b\u5faa\u73af
\u7f16\u8bd1\u5668\u4f18\u5316
\u5b9a\u4e49\u90e8\u5206Person copy_func( Person p ) { \n p.print(); \n return p; // copy ctor called! \n} \nPerson nocopy_func( char *who ) { \n return Person( who ); \n} // no copy needed!\n
\u7f16\u8bd1\u5668\u4f18\u5316\u95ee\u9898#include <iostream>\nusing namespace std;\nclass A\n{\npublic:\n A() : value(0) { cout << \"A() \" << endl; };\n A(int a) : value(a) { cout << \"A(int a)\" << endl; };\n A(const A &other)\n {\n this->value = other.value;\n cout << \"A(&)\" << other.value << endl;\n };\n ~A() { cout << \"~A\" << endl; };\n\nprivate:\n int value;\n};\nA f(int a)\n{\n cout << \"f()\" << endl;\n return A(a);\n}\nA bar(A a)\n{\n cout << \"bar\" << endl;\n return a;\n}\n
"},{"location":"CS/OOP/#_7","title":"\u62f7\u8d1d\u8d4b\u503c\u8fd0\u7b97","text":"int main()\n{\n // \u7f16\u8bd1\u5668\u4f18\u5316\n // \u62f7\u8d1d\u6784\u9020\u88ab\u4f18\u5316 \u76f8\u5f53\u4e8e xa = A(5)\n A xa = f(5);\n /*\n f()\n A(int a)\n */\n\n // \u8fdb\u884c\u62f7\u8d1d\u6784\u9020\n A xb = bar(xa);\n /*\n A(&)5 \u53c2\u6570\u4f20\u5165\u4e00\u6b21\u62f7\u8d1d\u6784\u9020\n bar bar \u8c03\u7528\n A(&)5 \u62f7\u8d1d\u6784\u9020 xb = \u4f20\u56de\u53c2\u6570\n ~A \u5e94\u8be5\u662f\u90a3\u4e2a\u53c2\u6570\u88ab\u9500\u6bc1\u4e86\n */\n A xc = A(11);\n}\n
\u62f7\u8d1d\u8d4b\u503c
"},{"location":"CS/OOP/#vector","title":"\u6548\u7387\u95ee\u9898 Vector","text":"
- \u901a\u5e38\u8fd4\u56de\u5de6\u503c\u7684\u5f15\u7528
Cube Cube1(20,20,20),Cube2; \nCube2=Cube1; \n
\u7531\u4e8evector\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u4f1a\u53d1\u751f\u6269\u5bb9\uff0c\u6240\u4ee5\u62f7\u8d1d\u6784\u9020\u4f1a\u591a\u6b21\u8fdb\u884c
\u4f18\u5316\u62f7\u8d1d
\u5c06
alist.push_back(A(0));
\u6539\u4e3aalist.emplace_back(0);
\uff0c\u53ef\u4ee5\u4e0d\u6267\u884c\u62f7\u8d1d\u6784\u9020\u800c\u662f\u76f4\u63a5\u6784\u9020C11 \u7981\u7528copy\uff0c
Person(const Person &rhs) = delete;
"},{"location":"CS/OOP/#friend","title":"Friend","text":"vector<A> alist;\n// push_back\nalist.push_back(A(0));\nalist.push_back(A(1));\nalist.push_back(A(2));\n\nalist.emplace_back(0);\nalist.emplace_back(1);\nalist.emplace_back(2);\n
// Rectangle\u4e2d\u7684\u6210\u5458\u51fd\u6570\u90fd\u53ef\u4ee5\u4f7f\u7528Square\u4e2d\u7684\u6240\u6709\u6210\u5458\nclass Square { \n friend class Rectangle; \nprivate:\n int side; \npublic: \n Square (int a) : side(a) {} \n};\n
"},{"location":"CS/OOP/#_8","title":"\u7ee7\u627f","text":"
- \u53cb\u5143\u7684\u5173\u7cfb\u4e0d\u80fd\u4f20\u9012\u3002
- \u53cb\u5143\u7684\u5173\u7cfb\u662f\u5355\u5411\u7684\u800c\u4e0d\u662f\u53cc\u5411\u7684
\u6784\u9020\u6267\u884c\u987a\u5e8f
example
- \u8c03\u7528\u57fa\u7c7b\u7684\u6784\u9020\u51fd\u6570;
- \u8c03\u7528\u5185\u5d4c\u5bf9\u8c61\u6210\u5458\uff08\u5b50\u5bf9\u8c61\u7c7b\uff09\u7684\u6784\u9020\u51fd\u6570\uff08\u6709\u591a\u4e2a\u5bf9\u8c61\u6210\u5458\u65f6,\u8c03\u7528\u987a\u5e8f\u7531\u5b83\u4eec\u5728\u7c7b\u4e2d\u58f0\u660e\u7684\u987a\u5e8f\u786e\u5b9a\uff09; \u5185\u5d4c\u5bf9\u8c61\u7684\u6784\u9020\u4f18\u5148\u7ea7\u6bd4\u8f83\u9ad8
- \u6d3e\u751f\u7c7b\u7684\u6784\u9020\u51fd\u6570\u4f53\u4e2d\u7684\u5185\u5bb9
- \u540c\u540d\u51fd\u6570\u7684\u7ee7\u627f\u95ee\u9898 \u4e00\u4e2a\u6d3e\u751f\u7c7b\u4e2doverride\uff0c\u5176\u4ed6\u57fa\u7c7b\u540c\u540d\u51fd\u6570\u4e5f\u88ab\u8986\u76d6\u6389(\u5373\u4f7f\u7c7b\u578b\u4e0d\u540c) \u8bb0\u5f97override\u6240\u6709\u7684\u76f8\u5173\u51fd\u6570
Answer#include <iostream>\nstruct X {\n X() {\n std::cout << \"X::X()\" << std::endl;\n }\n ~X() {\n std::cout << \"X::~X()\" << std::endl;\n }\n};\nstruct Y {\n Y() {\n std::cout << \"Y::Y()\" << std::endl;\n }\n ~Y() {\n std::cout << \"Y::~Y()\" << std::endl;\n }\n};\nstruct Parent {\n Parent() {\n std::cout << \"Parent::Parent()\" << std::endl;\n }\n ~Parent() {\n std::cout << \"Parent::~Parent()\" << std::endl;\n }\n X x;\n};\nstruct Child : public Parent {\n Child() {\n std::cout << \"Child::Child()\" << std::endl;\n }\n ~Child() {\n std::cout << \"Child::~Child()\" << std::endl;\n }\n Y y;\n};\nint main() {\n Child c;\n}\n
Line 1: X::X()
Line 2: Parent::Parent()
Line 3: Y::Y()
Line 4: Child::Child()
Line 5: Child::~Child()
Line 6: Y::~Y()
Line 7: Parent::~Parent()
Line 8: X::~X()
- \u57fa\u7c7b\u6784\u9020\u51fd\u6570\u4e0d\u5e26\u53c2\u6570\u65f6\uff0c\u6d3e\u751f\u7c7b\u53ef\u4e0d\u5b9a\u4e49\u6784\u9020\u51fd\u6570\uff0c\u4f46\u57fa\u7c7b\u6784\u9020\u51fd\u6570\u5e26\u6709\u53c2\u6570\uff0c\u5219\u6d3e\u751f\u7c7b\u5fc5\u987b\u5b9a\u4e49\u6784\u9020\u51fd\u6570\u3002
- \u57fa\u7c7b\u548c\u6d3e\u751f\u7c7b\u7684\u6790\u6784\u51fd\u6570\u662f\u5404\u81ea\u72ec\u7acb\u7684\u3002
- \u57fa\u7c7b\u4e2d\u7684Private\u5c5e\u6027\u4e0d\u80fd\u76f4\u63a5\u901a\u8fc7\u6d3e\u751f\u7c7b\u8bbf\u95ee
"},{"location":"CS/OOP/#_9","title":"\u591a\u7ee7\u627f","text":"// \u8fdb\u884c\u521d\u59cb\u5316\u7684\u65f6\u5019,\u57fa\u7c7b\u6ca1\u6709\u65e0\u53c2\u6570\u7684\u6784\u9020\u51fd\u6570,\u6d3e\u751f\u7c7b\u5fc5\u987b\u663e\u5f0f\u5b9a\u4e49\nclass Derived\uff1apublic Base\n{\n Base d; //d\u4e3a\u57fa\u7c7b\u5bf9\u8c61\uff0c\u4f5c\u4e3a\u6d3e\u751f\u7c7b\u7684\u5bf9\u8c61\u6210\u5458\n public\uff1a\n Derived(int i)\uff1aBase(i),d(i)\n { \n cout<<\"Constructing derived class\\n\";\n }\n ~Derived() //\u6d3e\u751f\u7c7b\u7684\u6790\u6784\u51fd\u6570\n { cout<<\"Destructing derived class\\n\"; }\n };\n
\u9ed8\u8ba4\u4e3a
private
"},{"location":"CS/OOP/#_10","title":"\u591a\u6001","text":"
class z\uff1ax,public y
x\u4e3aprivate\u9759\u6001\u591a\u6001\u6027\u2014\u2014\u51fd\u6570\u91cd\u8f7d\u548c\u8fd0\u7b97\u7b26\u91cd\u8f7d\uff1b \u8fd0\u884c\u65f6\u7684\u591a\u6001\u2014\u2014\u7ee7\u627f\u548c\u865a\u51fd\u6570\uff1b
\u9759\u6001 : \u5728\u7f16\u8bd1\u65f6\u5c31\u51b3\u5b9a\u4e86\u51fd\u6570\u6240\u5c5e
"},{"location":"CS/OOP/#virtual","title":"virtual \u865a\u51fd\u6570","text":"class A\n{\npublic:\n void show() { cout << \"A\"; }\n};\nclass B : public A\n{\npublic:\n void show() { cout << \"B\"; }\n};\nint main()\n{\n A a, *pc;\n B b;\n pc = &a;\n pc->show();\n pc = &b;\n pc->show();\n return 0;\n}\n
virtual
- \u901a\u8fc7\u5b9a\u4e49\u865a\u51fd\u6570\u6765\u4f7f\u7528C++\u63d0\u4f9b\u7684\u591a\u6001\u673a\u5236\u65f6\uff0c\u6d3e\u751f\u7c7b\u5e94\u8be5\u4ece\u5b83\u7684\u57fa\u7c7b\u516c\u6709\u6d3e\u751f\u3002\u8d4b\u503c\u517c\u5bb9\u89c4\u5219\u6210\u7acb\u7684\u524d\u63d0\u6761\u4ef6\u662f\u6d3e\u751f\u7c7b\u4ece\u5176\u57fa\u7c7b\u516c\u6709\u6d3e\u751f\u3002
- \u5fc5\u987b\u9996\u5148\u5728\u57fa\u7c7b\u4e2d\u5b9a\u4e49\u865a\u51fd\u6570\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u5e94\u8be5\u5728\u7c7b\u7b49\u7ea7\u5185\u9700\u8981\u5177\u6709\u52a8\u6001\u591a\u6001\u6027\u7684\u51e0\u4e2a\u5c42\u6b21\u4e2d\u7684\u6700\u9ad8\u5c42\u7c7b\u5185\u9996\u5148\u58f0\u660e\u865a\u51fd\u6570\u3002
- \u5728\u6d3e\u751f\u7c7b\u5bf9\u57fa\u7c7b\u4e2d\u58f0\u660e\u7684\u865a\u51fd\u6570\u8fdb\u884c\u91cd\u65b0\u5b9a\u4e49\u65f6\uff0c\u5173\u952e\u5b57virtual\u53ef\u4ee5\u5199\u4e5f\u53ef\u4ee5\u4e0d\u5199\u3002
- \u4f7f\u7528\u5bf9\u8c61\u540d\u548c\u70b9\u8fd0\u7b97\u7b26\u7684\u65b9\u5f0f\u4e5f\u53ef\u4ee5\u8c03\u7528\u865a\u51fd\u6570\uff0c\u4f46\u662f\u8fd9\u79cd\u8c03\u7528\u5728\u7f16\u8bd1\u65f6\u8fdb\u884c\u7684\u662f\u9759\u6001\u8054\u7f16\uff0c\u5b83\u6ca1\u6709\u5145\u5206\u5229\u7528\u865a\u51fd\u6570\u7684\u7279\u6027\u3002\u53ea\u6709\u901a\u8fc7\u57fa\u7c7b\u6307\u9488\u8bbf\u95ee\u865a\u51fd\u6570\u65f6\u624d\u80fd\u83b7\u5f97\u8fd0\u884c\u65f6\u7684\u591a\u6001\u6027
- \u865a\u51fd\u6570\u5fc5\u987b\u662f\u5176\u6240\u5728\u7c7b\u7684\u6210\u5458\u51fd\u6570\uff0c\u800c\u4e0d\u80fd\u662f\u53cb\u5143\u51fd\u6570\uff0c\u4e5f\u4e0d\u80fd\u662f\u9759\u6001\u6210\u5458\u51fd\u6570\uff0c\u56e0\u4e3a\u865a\u51fd\u6570\u8c03\u7528\u8981\u9760\u7279\u5b9a\u7684\u5bf9\u8c61\u6765\u51b3\u5b9a\u8be5\u6fc0\u6d3b\u54ea\u4e2a\u51fd\u6570\u3002\u4f46\u662f\u865a\u51fd\u6570\u53ef\u4ee5\u5728\u53e6\u4e00\u4e2a\u7c7b\u4e2d\u88ab\u58f0\u660e\u4e3a\u53cb\u5143\u51fd\u6570
- \u5185\u8054\u51fd\u6570\u4e0d\u80fd\u662f\u865a\u51fd\u6570\uff0c\u56e0\u4e3a\u5185\u8054\u51fd\u6570\u662f\u4e0d\u80fd\u5728\u8fd0\u884c\u4e2d\u52a8\u6001\u786e\u5b9a\u5176\u4f4d\u7f6e\u7684\u3002\u5373\u4f7f\u865a\u51fd\u6570\u5728\u7c7b\u7684\u5185\u90e8\u5b9a\u4e49\uff0c\u7f16\u8bd1\u65f6\u4ecd\u5c06\u5176\u770b\u4f5c\u662f\u975e\u5185\u8054\u7684
- \u6784\u9020\u51fd\u6570\u4e0d\u80fd\u662f\u865a\u51fd\u6570\u3002\u56e0\u4e3a\u865a\u51fd\u6570\u4f5c\u4e3a\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u591a\u6001\u7684\u57fa\u7840\uff0c\u4e3b\u8981\u662f\u9488\u5bf9\u5bf9\u8c61\u7684\uff0c\u800c\u6784\u9020\u51fd\u6570\u662f\u5728\u5bf9\u8c61\u4ea7\u751f\u4e4b\u524d\u8fd0\u884c\u7684\uff0c\u56e0\u6b64\u865a\u6784\u9020\u51fd\u6570\u662f\u6ca1\u6709\u610f\u4e49\u7684
- \u6790\u6784\u51fd\u6570\u53ef\u4ee5\u662f\u865a\u51fd\u6570\uff0c\u800c\u4e14\u901a\u5e38\u8bf4\u660e\u4e3a\u865a\u51fd\u6570
Default Value
\u5728\u865a\u51fd\u6570\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528Default value\uff0c\u4f46\u662f\u9700\u8981\u6ce8\u610f\uff1a\u9ed8\u8ba4\u503c\u662f\u5728\u7f16\u8bd1\u65f6\u51b3\u5b9a\u7684\uff0c\u800c\u865a\u51fd\u6570\u662f\u8fd0\u884c\u65f6\u52a8\u6001\u7ed1\u5b9a\u7684
\u7eaf\u865a\u51fd\u6570
virtual void show()=0;
\u81f3\u5c11\u542b\u6709\u4e00\u4e2a\u7eaf\u865a\u51fd\u6570,\u5c31\u662f\u4e00\u4e2a\u62bd\u8c61\u7c7b
- \u62bd\u8c61\u7c7b\u4e0d\u80fd\u5b9a\u4e49\u4e00\u4e2a\u5b9e\u4f8b,\u4e0d\u80fd\u4f5c\u4e3a\u51fd\u6570\u8fd4\u56de\u503c\u6216\u8005\u53c2\u6570
- \u53ef\u4ee5\u5b9a\u4e49\u62bd\u8c61\u7c7b\u7684\u6307\u9488\u6216\u8005\u5f15\u7528
class base\n{\npublic:\n base()\n {\n cout << \"base constructor\" << endl;\n }\n virtual ~base()\n {\n cout << \"base destructor\" << endl;\n }\n};\nclass derived : public base\n{\npublic:\n derived()\n {\n cout << \"derived constructor\" << endl;\n }\n ~derived()\n {\n cout << \"derived destructor\" << endl;\n }\n};\n\nint main()\n{\n base *pb = new derived;\n delete pb;\n}\n
\u63a5\u53e3 Interface
\u5168\u4e3avirtual\u51fd\u6570
"},{"location":"CS/OOP/#overload","title":"\u91cd\u8f7d Overload","text":""},{"location":"CS/OOP/#_11","title":"\u51fd\u6570\u91cd\u8f7d","text":""},{"location":"CS/OOP/#_12","title":"\u8fd0\u7b97\u7b26\u91cd\u8f7d","text":"\u53ef\u4ee5\u91cd\u8f7d\u7684\u7c7b\u578b
+ - * / % ^ & | ~\n= < > += -= *= /= %=\n^= &= |= << >> >>= <<= ==\n!= <= >= ! && || ++ --\n, ->* -> () []\nnew new[]\ndelete delete[]\n
\u4e0d\u53ef\u4ee5
. .* :: ?:\n
\u4e0d\u53ef\u4ee5\u81ea\u5df1\u521b\u9020\u7c7b\u578b
"},{"location":"CS/OOP/#class-member","title":"Class member
","text":"
- No type conversion performed on receiver
"},{"location":"CS/OOP/#global-operators","title":"x + y; // x.operator+(y)\nz = x + y // Good \nz = x + 3 // Good\nz = 3 + y // Error\n// \u4e8c\u5143 binary\nInteger operator+(const Integer & n) const{\n return Integer(i + n.i);\n}\n// \u4e00\u5143 unary\nInteger operator-() const {\n return Integer(-i);\n}\n
Global operators
","text":"
- \u5bf9\u7c7b\u5185
private
\u6ca1\u6709\u8bbf\u95ee\u6743\u9650\uff0c\u53ef\u80fd\u9700\u8981\u662ffriend- \u53c2\u6570\u81f3\u5c11\u6709\u4e00\u4e2a\u662f
class
\u6216\u8005enum
\u7c7b\u578bclass Integer {\npublic:\n friend Integer operator+(const Integer&, const Integer&);\n ...\nprivate:\n int i;\n};\nInteger operator+(const Integer& lhs, const Integer& rhs)\n{\nreturn Integer( lhs.i + rhs.i );\n}\n
"},{"location":"CS/OOP/#detailed","title":"Detailed","text":"z = x + y; // operator+(x, y)\nz = x + 3; // operator+(x, Integer(3))\nz = 3 + y; // operator+(Integer(3), y)\nz = 3 + 7; // Integer(10) \u5148\u6c42\u548c \u540e\u8f6c\u6362\n
+ - * / % ^ & | ~
T operator X(const T& l, const T& r)
! && || < <= == >= >
bool operator X(const T& l, const T& r)
[ ]
E& T::operator [](int index)
\u4e00\u822c\u8fd8\u4f1a\u6709\u4e00\u4e2aconst\u7248\u672c\uff0c\u5426\u5219const\u5bb9\u5668\u65e0\u6cd5\u4f7f\u7528\u8fd4\u56de\u503c
int &Vector::operator [](int index)\n{\n return Element[index];\n}\n
++ -- \u4e00\u5143 \u533a\u5206 prefix postfix
class Integer {\npublic:\n...\n Integer& operator++(); //prefix++\n Integer operator++(int); //postfix++\n Integer& operator--(); //prefix--\n Integer operator--(int); //postfix--\n...\n};\n\nInteger x(5);\n++x; // calls x.operator++();\nx++; // calls x.operator++(0);\n--x; // calls x.operator--();\nx--; // calls x.operator--(0);\n
= \u8d4b\u503c\u8fd0\u7b97\u7b26 \u8fd4\u56de\u7684\u4e00\u5b9a\u8981\u662f\u5f15\u7528\uff0c\u4e00\u822c\u662f
*this
a = b = c
class Cargo{\n public:\n Cargo& operator=(const Cargo&)\n {\n return *this;\n }\n}\n// \u81ea\u52a8\u7248\u672c\uff0c\u6bcf\u4e2a\u5b57\u6bb5\u8c03\u7528 = \nclass Truck{\n Cargo mc;\n}\n\nTruck a,b;\na = b;\n
Copy constructor
\u548cassignment
\u5bf9\u4e8e\u5185\u542b\u7684\u6307\u9488\u53d8\u91cf\uff0c\u8d4b\u503c\u51fd\u6570\u8981\u8003\u8651\u91ca\u653e\u539f\u6765\u7684\u5185\u5b58\uff0c\u4e0d\u8981\u4f7f\u7528\u9ed8\u8ba4 = . \u9632\u6b62\u91cd\u590d\u91ca\u653e\u540c\u4e00\u5757\u5185\u5b58
\u6ce8\u610f
self-assiment!
\uff0cLeft Side\u53ef\u80fd\u672c\u6765\u5c31\u542b\u6709\u5185\u5bb9class A\n{\nprivate:\n char *p;\npublic:\n A& operator=(const A& a){\n if(a == *this){\n ...\n }else{\n delete [] p;\n p = new char[strlen(a.p) + 1];\n strcpy(p,a.p);\n return *this;\n }\n }\n\n}\n
Forbid it
A& operator=(const A&) = delete;\n
( ) functor
functor
overloads the function call operatorstruct F {\n void operator()(int x) const {\n std::cout << x << \"\\n\";\n }\n}; // F is a functor class\nF f; // f is a functor\nf(2); // calls f.operator()\n
void transform(vector<int>& v,int (*f)(int))\n{\n for(int &x : v)\n x = f(x);\n}\n// \u533f\u540d\u51fd\u6570 lambda\nint a = 4;\ntransform(v,[](int x){return x * 2});\n// \u5177\u6709\u73af\u5883\u53d8\u91cf\u7684\u5199\u6cd5\n#include <functional>\nvoid transform(vector<int>& v,const function<int<int>> &f)\n{\n for(int &x : v)\n x = f(x);\n}\n\n// \u6355\u83b7\u73af\u5883\u53d8\u91cf\ntransform(v,[a](int x){#f768a4b1a31b9e3a759b10a13c1e97e6}{return x * a;});\n
\u6784\u9020\u4e86\u4e00\u4e2a\u7c7b\uff08\u51fd\u6570\u5bf9\u8c61\uff09\uff0c\u8fd9\u4e2a\u7c7b\u4e2d\u91cd\u6784
( )
\u7b26\u53f7\uff0c\u53c2\u6570\u5c31\u662f\u7c7b\u4e2d\u7684\u4e00\u4e2a\u53d8\u91cf\uff1b\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b8c\u5168\u53ef\u4ee5\u7531\u4e00\u4e2a\u7c7b\u5b9a\u4e49\uff0c\u6765\u4ee3\u66ffLambda \u51fd\u6570Code
"},{"location":"CS/OOP/#_13","title":"\u9690\u5f0f\u8f6c\u6362","text":"#include <iostream>\n#include <vector>\nusing namespace std;\n\nclass vec3\n{\npublic:\n vec3(int x = 0, int y = 0, int z = 0)\n {\n v[0] = x;\n v[1] = y;\n v[2] = z;\n }\n int operator[](int index) const\n {\n return v[index];\n }\n vec3 &operator+=(const vec3 &rhs)\n {\n for (int i = 0; i < 3; ++i)\n v[i] += rhs.v[i];\n return *this;\n }\n\nprivate:\n int v[3];\n};\n\nvec3 operator+(const vec3 &v1, const vec3 &v2)\n{\n return vec3(v1) += v2;\n}\n\nostream &\noperator<<(ostream &out, const vec3 &v)\n{\n out << '(' << v[0] << ' ' << v[1] << ' ' << v[2] << ')';\n\n return out;\n}\n\nint main()\n{\n vec3 v1(1, 2, 3), v2(4, 5, 6);\n vec3 v = v1 + v2;\n v += v2;\n cout << v << endl;\n}\n
\u9690\u5f0f\u8f6c\u6362
C++\u7684\u7c7b\u578b\u8f6c\u6362
- Built-in conversions
- User-defined type conversions T => C \u901a\u8fc7\u5355\u53c2\u6570\u6784\u9020\u51fd\u6570\u8fdb\u884c
- if
C(T)
is a valid constructor call for C- if
operator C()
is defined for T
explicit
\u4e0d\u5141\u8bb8\u9690\u5f0f\u8f6c\u6362Single argument constructors
class PathName {\nstring name;\npublic:\nexplicit PathName(const string&);\n~ PathName();\n};\n\nstring abc(\"abc\");\nPathName xyz(abc); // OK!\nxyz = abc; // Error! OK if without explicit\n
\u8fd9\u91cc\uff0c\u7531\u4e8e
C(int)
\u4e3aexplicit
\u7c7b\u578b\uff0c\u6240\u4ee5\u5728\u9690\u5f0f\u8f6c\u6362\u65f6\u4e0d\u4f1a\u8003\u8651\u8fd9\u4e2a\u51fd\u6570\uff0c\u901a\u8fc7C(double)
\u8fdb\u884c\u8f6c\u6362class C\n{\npublic:\n explicit C(int)\n {\n cout << \"i\" << endl;\n }\n C(double)\n {\n cout << \"d\" << endl;\n }\n};\nint main()\n{\n C c1(7);\n C c2 = 7;\n return 0;\n}\n> i\n> d\n
Conversion Operator | \u7c7b\u7684\u8f6c\u6362
X::operator T()
- No explicit arguments
- No return type
"},{"location":"CS/OOP/#stream","title":"Stream","text":"class Rational {\npublic:\n operator double() const {\n return numerator / (double)denominator;\n }\n}\nRational r(1,3);\ndouble d = 1.3 * r; // r => double\n
\u4f18\u52bf
- Better type safety
- Extensible
- More object-oriented
\u7c7b\u578b
"},{"location":"CS/OOP/#stream_1","title":"Stream\u6d41","text":"// \u57fa\u7c7b\nistream& operator>>(istream& in, T& obj){\n // \n in >> obj. >> obj.;\n return in;\n}\nostream& operator<<(ostream& out,T& obj){\n return out << \" \";\n}\n
"},{"location":"CS/OOP/#_14","title":"\u8f93\u51fa\u63a7\u5236","text":"
cin
- standard input
cout
- standard output
cerr
- unbuffered error (debugging) output
clog
- buffered error (debugging) output
"},{"location":"CS/OOP/#_15","title":"\u7c7b\u578b\u8f6c\u6362","text":""},{"location":"CS/OOP/#template","title":"Template","text":"
#include <iomanip>
NOTE
\u5339\u914d\u63a8\u5bfc\u987a\u5e8f
\u5e38\u91cf\u4fee\u9970\u7b26\uff1aconst \u548c volatile \u4fee\u9970\u7b26\u5728\u63a8\u5bfc\u8fc7\u7a0b\u4e2d\u4f1a\u88ab\u4fdd\u7559
\u5148\u627e\u662f\u5426\u6709\u5b8c\u5168\u5339\u914d\u7684\u666e\u901a\u51fd\u6570
\u518d\u627e\u662f\u5426\u6709\u5b8c\u5168\u5339\u914d\u7684\u6a21\u677f\u51fd\u6570
\u518d\u627e\u6709\u6ca1\u6709\u901a\u8fc7\u8fdb\u884c\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\u53ef\u4ee5\u8c03\u7528\u7684\u51fd\u6570
\u8981\u5e94\u5bf9\u8fd9\u79cd\u9690\u5f0f\u8f6c\u6362
"},{"location":"CS/OOP/#functional-overloading","title":"Functional Overloading \u51fd\u6570\u91cd\u8f7d","text":"
- \u663e\u5f0f\u58f0\u660e\u4e00\u4e2a\u6a21\u677f
template<class T>\nT max(T x, T y)\n{\n return (x>y)?x:y;\n}\nint max(int, int)\uff1b//\u53ea\u58f0\u660e\u4e00\u4e2a\u975e\u6a21\u677f\u51fd\u6570\u7684\u539f\u578b\nvoid func(int i,char c)\n{\n max(i, i); //\u6b63\u786e ,\u8c03\u7528max(int,int)\n max(c, c); // Error: \u591a\u4e2a\u5339\u914d\u7684\u51fd\u6570\n max(i, c); //\u6b63\u786e ,\u8c03\u7528 max(int,int),\u4f7f\u7528\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\n max(c, i); //\u6b63\u786e ,\u8c03\u7528max(int,int),\u4f7f\u7528\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362\n}\n
Defalut value
Error
- \u6709\u9ed8\u8ba4\u503c\u7684\u60c5\u51b5\u4e0b\u518d\u6b21\u5b9a\u4e49\u4f1aError
"},{"location":"CS/OOP/#function","title":"Function \u51fd\u6570\u6a21\u677f","text":"void foo(int i = 5, int j = 4);\nvoid foo(int i, int j = 4)\n{\n cout << i << j << endl;\n}\nint main()\n{\n foo();\n}\n
inline\u7684\u4f4d\u7f6e
template <typename T>\ninline bool compare(const T &a, const T &b)\n{\n return a < b;\n}\nint main()\n{\n cout << compare(5, 1.0); // Error\n cout << compare<int>(5, 1.0); // Good\n}\n
\u4e0d\u5141\u8bb8\u9690\u5f0f\u8f6c\u6362
typename <>\u4e2d\u8fd8\u53ef\u4ee5\u5b58\u5728\u5176\u4ed6\u53d8\u91cf\u751a\u81f3\u662f\u7f3a\u7701\u91cf
- "},{"location":"CS/OOP/#class_1","title":"Class \u7c7b\u6a21\u677f","text":"
\u51fd\u6570\u5339\u914d
template <typename T>\ninline bool compare(const T &a, const T &b)\n{\n return a < b;\n}\nbool compare(const float &a, const float &b)\n{\n return a < b;\n}\nint main()\n{\n cout << compare(5.0, 1.0); // \u8c03\u7528 \u51fd\u6570\u6a21\u677f\n}\n
NOTE
"},{"location":"CS/OOP/#template-specialization","title":"\u6a21\u677f\u7279\u5316 Template specialization","text":"
- \u7c7b\u6a21\u677f\u4e2d\u7684\u90fd\u662f\u6a21\u677f\u51fd\u6570 \u5982\u679c\u5728\u7c7b\u5916\u5b9a\u4e49\u51fd\u6570\uff0c\u8bb0\u5f97
T Class::Function(T a)
```c++ title = \"\u539f\u6a21\u7248\" template class A { / ... / };
```c++ title = \"\u5168\u7279\u5316\"\ntemplate<>\nclass A<int, double, 5> { /* ... */ };\n
```c++ title = \"\u504f\u7279\u5316\" template class A { / ... / }; // \u53e6\u5916\u4e00\u4e2a\u4f8b\u5b50\uff0c\u5c06\u6307\u9488\u7c7b\u578b\u8fdb\u884c partial template class B{ };
\u51fd\u6570\u5339\u914d\u987a\u5e8f\uff1a\n1. \u4f18\u5148\u5bfb\u627e\u5168\u7279\u5316\n2. \n\n## Iterator\n\n> Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation.\n\n\u5c01\u88c5\n```c++ \ntemplate<class T>\nclass auto_ptr {\nprivate:\n T *pointee;\npublic:\n /* ... */\n T& operator *() { return *pointee; }\n T* operator ->() { return pointee; }\n};\n
++ * ==
\u6ce8\u610f\u4e0d\u540c\u7684\u5e95\u5c42\u5b9e\u73b0\uff0c\u5176\u5b9e\u5bf9Iterator\u7684\u64cd\u4f5c\u6709\u5f71\u54cd
\u6bd4\u5982\uff0c
set
\u4f7f\u7528\u7ea2\u9ed1\u6811\u4f5c\u4e3a\u5e95\u5c42\u5b9e\u73b0\uff0c\u4f7f\u7528It++
\u5f97\u5230\u7684\u7ed3\u679c\u4e0d\u662f\u6309\u521d\u59cb\u5316\u987a\u5e8f\u6392\u5217\u7684\u5982\u4f55\u83b7\u5f97Iterator\u7684\u7c7b\u578b\u4ee5\u53ca\u5176\u5143\u7d20\u7684\u7c7b\u578b ?
"},{"location":"CS/OOP/#iterator_traits","title":"iterator_traits
","text":""},{"location":"CS/OOP/#catagory","title":"Catagory","text":"template<class I>\nclass iterator_traits\n{\npublic:\n typedef typename I::iterator_category iterator_category;\n typedef typename I::value_type value_type;\n typedef typename I::difference_type differece_type;\n typedef typename I::pointer pointer;\n typedef typename I::reference reference;\n /* ... */\n}\n
category info
"},{"location":"CS/OOP/#_16","title":"\u5f02\u5e38\u5904\u7406","text":"struct input_iterator_tag {};\nstruct output_iterator_tag {};\nstruct forward_iterator_tag\n : public input_iterator_tag {};\nstruct bidirectional_iterator_tag\n : public forward_iterator_tag {};\nstruct random_access_iterator_tag\n : public bidirectional_iterator_tag {};\n
\u6ce8\u610f
Try-Catch Block\u4e2d\uff0c\u5fc5\u987b\u5b58\u5728Try-Catch\u7684\u914d\u5bf9\uff0c\u4f46\u662fcatch\u4e2d\u7684\u53c2\u6570\u53ef\u4ee5\u4e3a\u7a7a\uff0c\u8868\u793a\u8fd9\u91cc\u4e0d\u53bb\u6355\u6349\u5904\u7406\u9519\u8bef
try {\n // -----------------------\n // main logic here\n open the file;\n determine its size;\n allocate that much memory;\n read the file into memory;\n close the file;\n // -----------------------\n} catch ( fileOpenFailed ) {\n doSomething;\n} catch ( sizeDeterminationFailed ) {\n doSomething;\n} catch ( memoryAllocationFailed ) {\n doSomething;\n} catch ( readFailed ) {\n doSomething;\n} catch ( fileCloseFailed ) {\n doSomething;\n}\n
assert
Debug\u7684\u65f6\u5019\u4f1a\u5f88\u6709\u7528\uff0c\u4e5f\u53ef\u4ee5\u653e\u5728Test\u91cc\u9762\u3002\u5728MiniSQL\u91cc\u9762\u6709\u5f88\u591a\u5e94\u7528\u3002
\u66f4\u8be6\u7ec6\u7684\u5185\u5bb9\u53ef\u89c1\u5206\u533a\uff1a\u3010::TODO::\u3011assert(index > 0 && index < size);\n
? throw \u4e00\u4e2a\u5bf9\u8c61\u56de\u53bb\uff0c\u8fd9\u4e2a\u5bf9\u8c61\u4ec0\u4e48\u65f6\u5019\u6790\u6784\uff1f
throw
throw exception
\u629b\u51fa\u5f02\u5e38throw
throw \u540e\u9762\u4e0d\u52a0\u4efb\u4f55\u4e1c\u897f\uff0c\u76f4\u63a5\u4f20\u9012\u7ed9\u4e0a\u5c42\u51fd\u6570\uff0c\u53ea\u80fd\u5728catch\u4e2d\u4f7f\u7528
- re-raises the exception being handled
- valid only within a handler
- \u53ef\u4ee5 throw \u4efb\u610f\u7c7b\u578b\u7684\u6570\u636e
void f0()\n{\n try\n {\n f1();\n }\n catch (double)\n {\n cout << \"f0() double\" << endl;\n }\n cout << \"f0() End\" << endl;\n}\n
\u5c3d\u91cf\u4e0d\u8981\u4f7f\u7528
throw new Exception()
\uff0c\u76f4\u63a5\u4f7f\u7528throw Exception()
\u5426\u5219new\u51fa\u6765\u7684\u5bf9\u8c61\u4e5f\u8981\u81ea\u5df1\u53bb\u91ca\u653e
catch
"},{"location":"CS/OOP/#_17","title":"\u5f02\u5e38\u6307\u5b9a","text":"
catch(...)
catch(Exception)
\u52a8\u6001\u5f02\u5e38\u89c4\u8303\u5df2\u7ecf\u5728C++11\u4e4b\u540e\u88ab\u53d6\u6d88
warning: dynamic exception specifications are deprecated in C++11
\u5f02\u5e38\u6307\u5b9a\u662f\u51fd\u6570\u58f0\u660e\u7684\u4e00\u90e8\u5206\uff0c\u5fc5\u987b\u540c\u65f6\u51fa\u73b0\u5728\u51fd\u6570\u58f0\u660e\u548c\u51fd\u6570\u5b9a\u4e49\u7684\u9996\u884c\u4e2d\uff0c\u5426\u5219\u5728\u8fdb\u884c\u51fd\u6570\u7684\u53e6\u4e00\u6b21\u58f0\u660e\u65f6\uff0c\u7f16\u8bd1\u7cfb\u7edf\u4f1a\u62a5\u544a\u201c\u7c7b\u578b\u4e0d\u5339\u914d\u201d\u3002
\u5339\u914d\u673a\u5236
\u9488\u5bf9\u6bcf\u4e00\u6761catch\uff0c\u4f9d\u6b21\u8fdb\u884c\u5339\u914d\uff0c\u6240\u4ee5\u53ef\u80fd\u5bfc\u81f4\u63d0\u524d\u201c\u622a\u65ad\u201d\u2014\u2014\u57fa\u7c7b\u5904\u7406\u5c06\u6d3e\u751f\u7c7b\u5904\u7406\u9876\u6389
- \u7c7b\u578b\u5b8c\u7f8e\u5339\u914d
- \u57fa\u7c7b\u8f6c\u5316 \u4e00\u5b9a\u8981\u662f\u6307\u9488/\u5f15\u7528\u7c7b\u578b ? TODO
catch(...)
\u6240\u6709\u90fd\u80fd\u5339\u914d\uff0c\u5fc5\u987b\u653e\u5728\u7ed3\u675f\u4f4d\u7f6e\uff0c\u5426\u5219Error// Warning : UnderFlowError will be caught by earlier Exception\ntry\n{\n ...\n}\ncatch (MathError &e)\n{\n cout << \"MathError\" << endl;\n}\ncatch (UnderFlowError &e)\n{\n cout << \"UnderFlow\" << endl;\n}\ncatch (...)\n
\u65e0\u5f02\u5e38\u51fd\u6570
void foo() noexcept{...}
\u5728\u8fd0\u884c\u65f6\u68c0\u67e5\uff0c\u5982\u679c\u8fd0\u884c\u65f6\u4ecd\u7136\u629b\u51fa\u5f02\u5e38\uff0c\u90a3\u4e48\u5c06\u4f1a\u505c\u6b62\u7a0b\u5e8fFILE \u7c7b\u578b\u7684\u6790\u6784\u51fd\u6570\u53ef\u4ee5\u6267\u884c
"},{"location":"CS/OOP/#_18","title":"\u6784\u9020\u5f02\u5e38","text":"f.close()
\uff0c\u65e0\u9700\u5728try blockvoid f()\n{\n // \u4e0d\u4f1a\u53d1\u751f\u5185\u5b58\u6cc4\u6f0f\n X x; // \n Y *p = new Y(); // \u5185\u5b58\n}\n
- \u5728\u8c03\u7528\u6784\u9020\u51fd\u6570\u65f6\u51fa\u73b0\u5f02\u5e38\uff0c\u9000\u51fa
- \u6790\u6784\u51fd\u6570\u4e0d\u4f1a\u88ab\u6267\u884c\uff0c\u4f46\u662f\u5df2\u7ecf\u751f\u6210\u3001\u7533\u8bf7\u7684\u5185\u5b58\u4e0d\u4f1a\u88ab\u91ca\u653e\uff08\u6307\u7684\u662f\u6790\u6784\u4e2d\u4ea7\u751f\u7684\u5185\u5b58\uff0c\u6bd4\u5982
new int
\uff09;example
\n
\u89e3\u51b3\u65b9\u6cd5 - \u5728\u68c0\u6d4b\u5230Exception\u65f6\u624b\u52a8\u91ca\u653e\u5185\u5b58 - \u4e24\u5c42\u6784\u9020\uff0c\u901a\u8fc7\u53e6\u5916\u4e00\u4e2a\u51fd\u6570init\u5b9e\u73b0, \u8ba9\u7528\u6237\u624b\u52a8\u5b9e\u73b0\u7c7b\u7684Init - \u5c06\u539f\u751f\u6307\u9488\u653e\u5165\u4e00\u4e2awarpper\u7c7b - \u4f7f\u7528
unique_ptr
\u7ba1\u7406\u52a8\u6001\u7684\u8d44\u6e90\uff0c\u4f5c\u7528\u4e0a\u76f8\u5f53\u4e8e\u4e00\u4e2aWrapper\u7684\u6a21\u677f\u7c7b"},{"location":"CS/OOP/#_19","title":"\u6790\u6784\u5f02\u5e38","text":"\n
\u4e0d\u80fd\u629b\u51fa\u5f02\u5e38\uff0c\u5c06\u4f1a\u6267\u884c
"},{"location":"CS/OOP/#_20","title":"\u4f7f\u7528","text":"std::terminate()
"},{"location":"CS/OOP/#_21","title":"\u6807\u51c6\u5e93","text":""},{"location":"CS/OOP/#_22","title":"\u667a\u80fd\u6307\u9488","text":"
- \u5728\u4e0e\u5916\u754c\u6a21\u5757\u8fdb\u884c\u4ea4\u4e92\u7684\u65f6\u5019\u4f7f\u7528\u5f02\u5e38\u5904\u7406
- \u5e93\u5185\u90e8\u6700\u597d\u7528
assert
\u6765\u68c0\u67e5\u8fb9\u754c\u6761\u4ef6\u629b\u51fa\u53bb\u6700\u7ec8\u6ca1\u6709catch\u5c06terminate
\u505a\u5230
exception-safe code
\uff0c\u8981\u5b9e\u73b0\u7c7b\u4f3c\u6570\u636e\u5e93\u4e2d\u201c\u539f\u5b50\u6027\u201d\u7684\u64cd\u4f5c\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6a21\u677f\u7c7b\uff0c\u6765
- std::unique_ptr
\u6784\u5efa
// Error\nunique_ptr<A> pa = new A();\n//\nunique_ptr<A> pa(A());\n// \u4e86\u89e3,\u4e0d\u63a8\u8350\u4f7f\u7528new\u53bb\u6784\u5efa\nunique_ptr<A> pa{new A()};\n\nauto pa = make_unique<A>();\n
std::move(source)
string str(\"hello!\");\nstring target(std::move(str));\n\u6240\u6709\u6743\u7684\u8f6c\u8ba9\n\u4e4b\u540e\u7684str\u4e0d\u80fd\u518d\u4f7f\u7528\uff0c\u5176\u4e2d\u7684\u503c\u65f6undefined\u3001\n
pa.get()
\u83b7\u5f97\u539f\u751f\u6307\u9488``
std::shared_ptr
pt.use_count()
\u5f15\u7528\u8ba1\u6570
std::weak_ptr
\u80fd\u591f\u770b\u5230\u7ba1\u7406\u6743\uff0c\u4f46\u662f\u4e0d\u4f1a\u589e\u52a0\u5176
use_count
\u6bd4\u5982\u4e24\u4e2a\u7c7b\uff0c\u5f7c\u6b64\u4e4b\u95f4\u7528shared_ptr\u4e92\u6307\uff0c\u5c06\u9020\u6210\u6b7b\u9501
"},{"location":"CS/OOP/#application","title":"Application","text":""},{"location":"CS/OOP/#_23","title":"\u6392\u5e8f","text":"
std::auto_ptr
(deprecated in C++11)"},{"location":"CS/OOP/#stl","title":"STL","text":""},{"location":"CS/OOP/#map","title":"map","text":"
less
greater
\u51fd\u6570map<string, int> a = {{\"a\", 1}, {\"b\", 2}};\na.emplace(\"c\", 4);\na[\"d\"] = 4;\na.insert({\"e\", 5});\nfor (const auto &[key, value] : a)\n{\n cout << \"Key: \" << key << \", Value: \" << value << endl;\n}\n
\u8fd9\u91cc\u7684i\u4e3apair\u7c7b\u578b
"},{"location":"CS/OOP/#list","title":"list","text":""},{"location":"CS/%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96/","title":"\u3010\u77ed\u5b66\u671f\u3011\u5927\u6570\u636e\u53ef\u89c6\u5316","text":"\u7ea6 324 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
2023 \u65f6\u95f4\u5b89\u6392
\u8bfe\u8868.pdf \u56e0\u4e3a\u7ebf\u4e0b\u4e0a\u8bfe\u7684\u5bb9\u91cf\u95ee\u9898\uff0c\u5e76\u6ca1\u6709\u9009\u4e0a\u5927\u540d\u9f0e\u9f0e\u7684\u8ba1\u7b97\u673a\u7cfb\u7edf\u6982\u8bba\uff0c\u4e8e\u662f\u5728 ljj \u7684\u538b\u8feb\u4e0b\u6beb\u4e0d\u72b9\u8c6b\u5730\u9009\u62e9\u4e86\u8fd9\u95e8\u8bfe\uff08\u3002\u6bd4\u8d77\u8ba1\u6982\uff0c\u8fd9\u95e8\u8bfe\u7b97\u662f\u5f88\u6c34\u5f88\u6c34\u4e86\u3002 \u8fd9\u95e8\u8bfe\u7a0b\u4e3b\u8981\u662f\u4ee5 \u8bb2\u5ea7 + \u52a9\u6559\u8bb2\u89e3 \u7684\u65b9\u5f0f\u5448\u73b0\u3002 \u5176\u4e2d\uff0c\u8bb2\u5ea7\u7684\u90e8\u5206\u591a\u6570\u662f\u7eaf\u82f1\u6587\uff0c\u6709\u4e00\u4e9b\u8001\u5e08\u8bb2\u8ff0\u524d\u6cbf\u7684\u7814\u7a76\uff0c\u5206\u4eab\u4ed6\u4eec\u7684\u7814\u7a76\u5185\u5bb9\uff08\u5f53\u7136\uff0c\u4e0d\u4f1a\u662f\u7279\u522b\u6df1\u5965\u90a3\u79cd\uff0c\u867d\u7136\u6211\u4e5f\u6ca1\u600e\u4e48\u542c\u8fc7\uff09 \u7b2c\u4e00\u5468\u4f1a\u628a\u5f00\u53d1\u8981\u7528\u7684\u4e1c\u897f\u8bb2\u5b8c\uff0c\u7b2c\u4e8c\u5468\u7684\u4e0b\u5348\u65f6\u95f4\u5c31\u7559\u7ed9\u56e2\u961f\u5b8c\u6210\u5927\u4f5c\u4e1a
","tags":["class/visialization"]},{"location":"CS/%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96/#_1","title":"\u8bfe\u7a0b\u8bc4\u4ef7\u65b9\u5f0f","text":"
Project 1
20%Learn to use visual analytics tools (Tableau, \u2026).
\u4f7f\u7528 Tableau \u505a\u4e00\u4e2a\u7b80\u5355\u7684\u56fe\u8868\u5206\u6790\uff0c\u5199\u4e00\u4efd\u62a5\u544a
Project 2
50%
- Data analysis with visual analytics tools (Python, Tableau, \u2026)
- or a visual analytics system designed by yourself
\u4e3b\u9898\u81ea\u9009 \u4e00\u822c\u4e09\u4eba\u4e3a\u4e00\u7ec4
pre
20%
Attendance
10% \u4f1a\u6709\u70b9\u540d
Bonus
5 pointsProject 2 \u9009\u62e9\u8bbe\u8ba1\u53ef\u89c6\u5316\u5206\u6790\u7cfb\u7edf\u5373\u53ef\u83b7\u5f97
","tags":["class/visialization"]},{"location":"CS/%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96/#_2","title":"\u5b66\u4ec0\u4e48","text":"
- \u524d\u7aef\u4e09\u4ef6\u5957
Javascript
,css
,html
","tags":["class/visialization"]},{"location":"CS/AI/","title":"Index","text":"
- \u4e00\u4e9b\u6846\u67b6\u7684\u642d\u5efa\uff0c\u811a\u624b\u67b6\u7684\u4f7f\u7528
REACT
\u6216\u8005Vue
\uff0c\u4e0a\u8bfe\u4f1a\u7b80\u5355\u6559\u4e00\u4e9b React \u7684\u5185\u5bb9\uff08\u4e0d\u5f97\u4e0d\u5410\u69fd\u6559\u5f97\u5f88\u5c11\uff0c\u66f4\u591a\u8fd8\u662f\u662f\u8981\u81ea\u5df1\u5b66\uff09\u7ea6 48 \u4e2a\u5b57
\u4eba\u5de5\u667a\u80fd
\u4efb\u8bfe\u6559\u5e08\uff1a\u8303\u9e64\u9e64 \u6559\u6750\uff1a\u4eba\u5de5\u667a\u80fd\u5bfc\u8bba\uff1a\u6a21\u578b\u4e0e\u7b97\u6cd5 (\u5434\u98de) \u6210\u7ee9\u6784\u6210\uff1a - \u9879\u76ee\u7f16\u7a0b\u4f5c\u4e1a 35% - \u8003\u52e4 5% - \u671f\u672b\u95ed\u5377\u8003\u8bd5 60%
"},{"location":"CS/AI/Review/","title":"Review","text":"\u7ea6 152 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CS/AI/Review/#_1","title":"\u5f3a\u5316\u5b66\u4e60","text":"\u201c\u5c1d\u8bd5\u4e0e\u8bd5\u9519\u201d\u548c\u201c\u63a2\u7d22\u4e0e\u5229\u7528\u201d\u7b49\u673a\u5236\u5728\u6240\u5904\u72b6\u6001\u91c7\u53d6\u884c\u52a8\uff0c\u4e0d\u65ad\u4e0e\u73af\u5883\u4ea4\u4e92\uff0c\u76f4\u81f3\u8fdb\u5165\u7ec8\u6b62\u72b6\u6001\uff0c\u6839\u636e\u5728\u7ec8\u6b62\u72b6\u6001\u6240\u83b7\u5f97\u7684\u5956\u60e9\u6765\u6539\u8fdb\u884c\u52a8\u7b56\u7565\uff0c\u5e8f\u8d2f\u5b8c\u6210\u51b3\u7b56\u4efb\u52a1\u3002
\u5728\u5f3a\u5316\u5b66\u4e60\u4e2d\uff0c\u5b66\u4e60\u4fe1\u53f7\u4ee5\u5956\u52b1\u5f62\u5f0f\u51fa\u73b0\uff0c\u667a\u80fd\u4f53\u5728\u4e0e\u73af\u5883\u4ea4\u4e92\u4e2d\u53d6\u5f97\u6700\u5927\u5316\u6536\u76ca
\u9a6c\u5c14\u53ef\u592b\u6027\u8d28\u2014\u2014\u5373\u4e0b\u4e00\u4e2a\u72b6\u6001\u7684\u6982\u7387\u5206\u5e03\u4ec5\u4f9d\u8d56\u4e8e\u5f53\u524d\u72b6\u6001\u548c\u6240\u91c7\u53d6\u7684\u884c\u52a8\uff0c\u4e0e\u4e4b\u524d\u7684\u5386\u53f2\u72b6\u6001\u6216\u884c\u52a8\u65e0\u5173
"},{"location":"CS/AI/Review/#q-learning","title":"Q Learning","text":""},{"location":"CS/CO/","title":"\u8ba1\u7b97\u673a\u7ec4\u6210","text":"\u7ea6 17 \u4e2a\u5b57
\u4ecb\u7ecd
\u666e\u901aCS\u7684\u8ba1\u7ec4\u4e13\u4e1a\u8bfe
"},{"location":"CS/CO/1_Interface/","title":"Chapter 1 | Computer Abstraction","text":"\u7ea6 360 \u4e2a\u5b57 38 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
info
\u8fd9\u4e00\u7ae0\u662f\u603b\u89c8\u6027\u8d28\u7684\uff0c\u6ca1\u6709\u7279\u522b\u7684\u77e5\u8bc6\u70b9\uff0c\u5f88\u591a\u90fd\u662f\u6027\u8d28\u3001\u6982\u8ff0\u3002 \u8981\u6ce8\u610fTime\u7684\u8ba1\u7b97
"},{"location":"CS/CO/1_Interface/#_1","title":"\u7ec4\u6210","text":"Graph From https://xuan-insr.github.io/
- Instruction set architecture\uff08ISA,\u6307\u4ee4\u96c6\u7cfb\u7edf\u7ed3\u6784\uff09 ---- the interface between hardware and lowest-level software
graph LR\n1[Computer System]\n2[Software]\n3[Hardware]\n2.1[Application Software]\n\n2.2[System Software]\n\n2.2.1[Operation System]\n2.2.2[GCC]\n2.2.3[Firmware/Driver Software]\n\n1 --> 2\n1-->3\n2-->2.1\n2-->2.2\n2.2-->2.2.1\n2.2-->2.2.2\n2.2-->2.2.3\n\n3.1[CPU]\n3.2[Memory]\n3.3[I/O interface]\n3.1.1[Control unit]\n3.1.2[DataPath]\n3-->3.1\n3-->3.2\n3-->3.3\n3.1-->3.1.1\n3.1-->3.1.2\n3.3.1[Input: keyboard]\n3.3.2[Bidirectional: RS-232,USB]\n3.3.3[Output: VGA\uff0cLCD]\n3.3-->3.3.1\n3.3-->3.3.2\n3.3-->3.3.3
\u6ca1\u60f3\u5230\u671f\u4e2d\u8003\u8bd5\u7adf\u7136\u8003\u4e86Software\u90e8\u5206\u7684\u6846\u56fe
SoftWare
"},{"location":"CS/CO/1_Interface/#io-interface","title":"I/O Interface","text":""},{"location":"CS/CO/1_Interface/#memory","title":"Memory","text":""},{"location":"CS/CO/1_Interface/#_2","title":"\u8bed\u8a00\u8f6c\u6362","text":""},{"location":"CS/CO/1_Interface/#time","title":"* Time\u7684\u8ba1\u7b97","text":"graph\n\u9ad8\u7ea7\u7f16\u7a0b\u8bed\u8a00--Compiler-->\u6c47\u7f16--ASsembler-->3[Machine Code]
\u5904\u7406\u5668\u6267\u884c\u65f6\u95f4\u7531\u5904\u7406\u9891\u7387\uff0c \u7a0b\u5e8f\u6267\u884c\u7684\u6307\u4ee4\u6570\u76ee\u548c\u6bcf\u6761\u6307\u4ee4\u7684\u6027\u80fd\u51b3\u5b9a\uff1b \u800c\u6bcf\u6761\u6307\u4ee4\u7684\u6027\u80fd\uff0c\u7531\u6bcf\u6761\u6307\u4ee4\u6240\u9700\u65f6\u949f\u6570\u51b3\u5b9a
Response time/execution time \u54cd\u5e94\u65f6\u95f4/\u6267\u884c\u65f6\u95f4
- How long it takes to do a task
Throughput (bandwidth) \u541e\u5410\u7387
\u4e86\u89e3cost
- Total work done per unit time
- e.g., tasks/transactions/\u2026 per hour
Performance = 1/Execution Time
\u4e00\u4e2a\u6307\u4ee4\u5468\u671f\uff0c\u5305\u542b\u591a\u4e2a CPU \u5468\u671f\uff0c\u800c\u4e00\u4e2a CPU \u5468\u671f\u5305\u542b\u591a\u4e2a\u65f6\u949f\u5468\u671f\u3002
example
- CPI : \u6bcf\u6761\u6307\u4ee4\u7684\u5e73\u5747\u5468\u671f\u6570(Average cycles per instruction) \u2192 CPU \u5468\u671f
example
example
"},{"location":"CS/CO/1_Interface/#eight-great-ideas","title":"Eight Great Ideas","text":"
- MIPS: Millions of Instructions Per Second
"},{"location":"CS/CO/1_Interface/#_3","title":"\u8865\u5145","text":""},{"location":"CS/CO/1_Interface/#power-trend","title":"Power Trend","text":"
Design for Moore\u2019s Law \uff08\u8bbe\u8ba1\u7d27\u8ddf\u6469\u5c14\u5b9a\u5f8b\uff09
Use Abstraction to Simplify Design ( \u91c7\u7528\u62bd\u8c61\u7b80\u5316\u8bbe\u8ba1 )
Make the Common Case Fast ( \u52a0\u901f\u5927\u6982\u7387\u4e8b\u4ef6 )
Performance via Parallelism ( \u901a\u8fc7\u5e76\u884c\u63d0\u9ad8\u6027\u80fd )
Performance via Pipelining ( \u901a\u8fc7\u6d41\u6c34\u7ebf\u63d0\u9ad8\u6027\u80fd )
Performance via Prediction ( \u901a\u8fc7\u9884\u6d4b\u63d0\u9ad8\u6027\u80fd )
Hierarchy of Memories ( \u5b58\u50a8\u5668\u5c42\u6b21 )
Dependability via Redundancy ( \u901a\u8fc7\u5197\u4f59\u63d0\u9ad8\u53ef\u9760\u6027)
\u671f\u4e2d\u8003\u5230\u4e86, \u9898\u76ee\u5927\u610f\u8ddf\u4e0a\u56fe\u4e00\u81f4\uff0c\u8ba1\u7b97\\(\\frac{P_{new}}{P_{old}}\\)
"},{"location":"CS/CO/1_Interface/#_4","title":"\u9898\u76ee","text":""},{"location":"CS/CO/1_Interface/#eight-idea","title":"Eight Idea","text":""},{"location":"CS/CO/2_Instruction/","title":"Chapter 2 | Instruction","text":"\u7ea6 866 \u4e2a\u5b57 50 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
\u6982\u8ff0
- Introduction
- Operations of the computer hardware (\u8ba1\u7b97\u673a\u786c\u4ef6\u7684\u64cd\u4f5c)
- Operands of the computer hardware(\u8ba1\u7b97\u673a\u786c\u4ef6\u7684\u64cd\u4f5c\u6570)
- Signed and unsigned numbers (\u6709\u7b26\u53f7\u548c\u65e0\u7b26\u53f7\u6570)
- Representing instructions in the computer(\u8ba1\u7b97\u673a\u4e2d\u6307\u4ee4\u7684\u8868\u793a)
- Logical operations(\u903b\u8f91\u64cd\u4f5c)
- Instructions for making decision(\u51b3\u7b56\u6307\u4ee4)
- Supporting procedures in computer hardware(\u8ba1\u7b97\u673a\u5bf9\u8fc7\u7a0b\u7684\u652f\u6301)
- Instruction addressing (\u6307\u4ee4\u7684\u5bfb\u5740)
\u4fe1\u606f\u91cf Op > Func 3 > Func 6/7
"},{"location":"CS/CO/2_Instruction/#mention","title":"Mention","text":"\u91cd\u70b9\u7406\u89e3
- Branch\u6307\u4ee4\u8fdb\u884c\u5faa\u73af\u7b49\u64cd\u4f5c
- Procdure\u5c24\u5176\u662f\u6808\u7684\u5199\u6cd5
- \u9012\u5f52\uff0c\u6590\u6ce2\u90a3\u5951
- \u533a\u5206jal jalr
jal \u8df3\u8f6c\u662f\u57fa\u4e8ePC\u7684\u8df3\u8f6c UJ type
jalr \u76f8\u5f53\u4e8ejal\u7684\u5bc4\u5b58\u5668\u7248\u672c \u8df3\u8f6c\u8303\u56f4\u66f4\u52a0\u5e7f I type
PC + 4 \u90fd\u8981\u5b58\u56de\u53bb
"},{"location":"CS/CO/2_Instruction/#introduction","title":"Introduction","text":"
- \u7acb\u5373\u6570\u7684\u79cd\u7c7b
- \u8f6c\u6362code\u7684\u65f6\u5019\u6ce8\u610frs1\uff0crs2\u7684\u4f4d\u7f6e
\u5b58\u50a8\u7a0b\u5e8f\u6982\u5ff5\uff1a \u6307\u4ee4\u548c\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\u4e0d\u52a0\u533a\u5206\u5730\u5b58\u50a8\u5728\u5b58\u50a8\u5668\u4e2d\u5e76\u56e0\u6b64\u6613\u4e8e\u66f4\u6539\uff0c\u56e0\u4e3a\u4ea7\u751f\u4e86\u5b58\u50a8\u7a0b\u5e8f\u8ba1\u7b97\u673a
"},{"location":"CS/CO/2_Instruction/#operation","title":"Operation","text":""},{"location":"CS/CO/2_Instruction/#operands","title":"Operands","text":"
- \u4e00\u6761\u6307\u4ee4\u4e00\u4e2a\u64cd\u4f5c
RISC - V 32 \u00d7 64-bit register file
word: 32 bits
double word : 64 bits
"},{"location":"CS/CO/2_Instruction/#register","title":"Register","text":"
- Arithmetic instructions use register operands \u5fc5\u987b\u5728\u5bc4\u5b58\u5668
- \u4ee564bits\u7684\u60f3\u6cd5\u7406\u89e3\u540e\u7eed\u7684\u6240\u6709\u64cd\u4f5c
C code: f = (g + h) - (i + j); f, \u2026, j in x19, x20, \u2026, x23 Compiled
RISC-V code: add x5, x20, x21 add x6, x22, x23 sub x19, x5, x6
"},{"location":"CS/CO/2_Instruction/#memory-operands","title":"Memory Operands","text":""},{"location":"CS/CO/2_Instruction/#byte-addressed","title":"byte addressed","text":""},{"location":"CS/CO/2_Instruction/#little-endian","title":"little endian","text":"
\u5927\u7aef\u5c0f\u7aef\u9488\u5bf9\u7684\u662f\u4e00\u4e2aword, \u5728\u5185\u5b58\u4e2d\u6709\u5f71\u54cd
Least-significant byte at least address of a word
c.f. Big Endian: most-significant byte at least address
0x 12345678 word index : 3210
32bits,4bytes
==> 78 is the lsb, \u8fd9\u4e2abyte\u4f4d\u4e8e3
"},{"location":"CS/CO/2_Instruction/#word-alignment","title":"word \u5bf9\u9f50 Alignment","text":"RISV - V\u4e0d\u5f3a\u5236\u8981\u6c42
word aligned
"},{"location":"CS/CO/2_Instruction/#example","title":"example","text":"struct {\n int a;\n char b;\n char c[2];\n char d[3]\n float e;\n}\n
"},{"location":"CS/CO/2_Instruction/#constant-or-immediate-operands","title":"Constant or immediate operands","text":"
- \u80fd\u8bbf\u95ee\u5bc4\u5b58\u5668\u7684\u53ea\u6709
load
store
- \u8fd9\u91cc\u5c55\u793a\u7684\u662f
\u5b57\u8282\u5bfb\u5740\uff088 bits\uff09
\u907f\u514d\u5e38\u6570\u64cd\u4f5c\u65f6load store \u6d6a\u8d39\u65f6\u95f4
"},{"location":"CS/CO/2_Instruction/#representing-instructions","title":"Representing Instructions","text":"Offer versions of the instruction \n addi x22, x22, 4 // x22= x22+ 4 \n\nConstant zero: a register x0\n
Mapping registers into numbers map registers x0 to x31 onto registers 0 to 31
RISC-V instructions
- Encoded as 32-bit instruction words \u6bcf\u6761\u6307\u4ee4\u4e00\u4e2aword
- Small number of formats encoding operation code (opcode), register numbers, \u2026Regularity
"},{"location":"CS/CO/2_Instruction/#r-format-instructions","title":"R-Format instructions","text":"
sd A,B
ld
opcode
: operation coderd
: destination register numberfunct3
: 3-bit function code (additional opcode) \u4f8b\u5982\u533a\u5206\u52a0\u51cf\u6cd5rs1
: the first source register numberrs2
: the second source register numberfunct7
: 7-bit function code (additional opcode)example
"},{"location":"CS/CO/2_Instruction/#i-format-instructions","title":"I-Format Instructions","text":"
load
addi
"},{"location":"CS/CO/2_Instruction/#s-format-instructions","title":"S-Format Instructions","text":"Example\uff1ald x9, 64(x22)\n22 (x22) is placed rs1;\n64 is placed immediate\n9 (x9) is placed rd\n
Example\uff1asd x9, 64(x22)\n 22 (x22) is placed rs1;\n 64 is placed immediate\n 9 (x9) is placed rs2\n
\u200b
"},{"location":"CS/CO/2_Instruction/#logical","title":"Logical","text":""},{"location":"CS/CO/2_Instruction/#instructions-for-making-decisions","title":"Instructions for making decisions","text":""},{"location":"CS/CO/2_Instruction/#branch","title":"Branch \u6307\u4ee4","text":"
slli\u3001ori...
\u4f7f\u7528\u7684\u4ecd\u7136\u662fI type Instruction
\uff0c\u53ea\u662fimm\u53ea\u7528\u4e86\u4f4e6\u4f4d"},{"location":"CS/CO/2_Instruction/#slt","title":"SLT","text":"
- \u901a\u8fc7
slli x10\uff0cx22\uff0c3
\u5c06 i \u5de6\u79fb3\u4f4d\u5f97\u5230\u5730\u5740\u504f\u79fb\u91cf
- \u6ce8\u610f\u8fd9\u91cc\u7684\u5927\u4e8e\u8868\u793a\u65b9\u6cd5,
bge>= beq== bne!=
A>B B>=A\u6709\u7b26\u53f7\u6570\u6bd4\u8f83
blt
: less thanbge
: greater equal\u65e0\u7b26\u53f7\u6570
"},{"location":"CS/CO/2_Instruction/#switchcase","title":"Switch/Case","text":"bltu
bgeu
jalr \uff1ajump and load register
JumpTable\u4e2d\u5b58\u50a8\u7684\u662f\u76ee\u6807\u7a0b\u5e8f\u7684\u5730\u5740\uff0c\u8fd9\u4e2aTable\u7684\u8d77\u59cb\u5730\u5740\u5047\u8bbe\u5728
X6
"},{"location":"CS/CO/2_Instruction/#basic-blocks","title":"Basic Blocks","text":""},{"location":"CS/CO/2_Instruction/#procedurefunction","title":"Procedure/function","text":"
- \u8fb9\u754c\u63a7\u5236
- \u8ba1\u7b97Table\u4e2d\u7684\u5730\u5740
- \u53d6\u51faTable\u4e2d\u7684\u503c\uff08\u4e00\u4e2a\u8df3\u8f6c\u7684\u5730\u5740\uff09
- \u8df3\u8f6c
jal
: jump and link
jal x1,100
\u8df3\u5230 PC + 100 \u7684\u4f4d\u7f6e
jarl x1,100(x5)
\u51e0\u4e4e\u76f8\u540c\uff0c\u53ea\u662f\u8df3\u8f6c\u7684\u57fa\u5740\u662freg\u4e2d\u7684\u503c\u57fa\u672c\u6d41\u7a0b\n // Caller !push to stack!\n Place Parameters in a place where the procedure can access them\n\n Transfer control to the procedure\uff1ajump to \n\n Acquire the storage resources needed for the procedure\n\n Perform the desired task\n\n Place the result value in a place where the calling program can access it \n // Callee jalr x0,0(x1) \n // !pull from stack and recover!\n // !\u6ce8\u610f\u51fd\u6570return\u7684\u503c\u8981\u7ed9\u67d0\u4e2a\u53e6\u5916\u7684\u5bc4\u5b58\u5668\uff0c\u800c\u4e0d\u662ftemporary\u5bc4\u5b58\u5668!\n Return control to the point of origin \n
Stack
- \u5f53\u53c2\u6570\u591a\u4e8e\u4e34\u65f6\u5bc4\u5b58\u5668\u7684\u4e2a\u6570 - \u6062\u590d\u539f\u6765\u7684\u53c2\u6570 \u9488\u5bf9
"},{"location":"CS/CO/2_Instruction/#communicating-with-people","title":"Communicating with People","text":"Saved value
- \u6ce8\u610f\u65b9\u5411\uff0c\u53ef\u4ee5\u770b\u5230\u4e0b\u9762\u662f\u4f4e\u4f4d\uff0c\u6240\u4ee5push\u8981sp - 8*bitsstrcpy: addi sp, sp, -8 # adjust stack for 1 doubleword\n sd x19, 0(sp) # save x19\n add x19, x0, x0 # i = 0 \n L1: \n add x5, x19, x11 # x5 = address of y[ i ]\n lbu x6, 0(x5) # x6 = y [ i ]\n add x7, x19, x10 # x7 = address of x[ i ] \n sb x6, 0(x7) # x[ i ] = y[ i ]\n beq x6, x0, L2 # if y[i] == 0 then exit\n addi x19, x19, 1 # i = i + 1\n jal x0, L1 # next iteration of loop\n L2: ld x19, 0(sp) # restore saved old s3\n addi sp, sp, 8 # pop 1 double word from stack\n jalr x0 0(x1) # return\n
\u6ce8\u610f\u8fd9\u91cc\u8ba1\u7b97
"},{"location":"CS/CO/2_Instruction/#32-bit-immediate-and-addresses","title":"32-Bit Immediate and Addresses","text":"address
\u7684\u65f6\u5019\u662fchar
\u7c7b\u578b\u7684lui
"},{"location":"CS/CO/2_Instruction/#_1","title":"\u5bfb\u5740","text":"
- PC\u76f8\u5bf9\u5bfb\u5740\u65b9\u5f0f
\u4e0b\u9762\u4e24\u79cdimm\u7684\u6700\u4f4e\u4e3a\u6052\u4e3a1
Branches
Jump
\u8fd9\u91cc\u7684jump\u6307\u7684\u662f
"},{"location":"CS/CO/2_Instruction/#synchronization-in-risc-v","title":"Synchronization in RISC-V | \u540c\u6b65","text":"jal
\u4e0d\u60f3\u5b66\u4e86
hobbitqia\u7684Notes
"},{"location":"CS/CO/2_Instruction/#a-c-sort-example-to-put-it-all-together","title":"A C Sort Example To Put it All Together","text":"\u4e3b\u8981\u8981\u7406\u89e3\u4e00\u4e0bloop
"},{"location":"CS/CO/2_Instruction/#_2","title":"\u9898\u76ee","text":""},{"location":"CS/CO/2_Instruction/#_3","title":"\u5927\u5c0f\u7aef\u5bf9\u9f50","text":"\u8fd9\u91cc\u4e00\u4e2abyte\u5b58\u50a8\u4e24\u4e2a16\u8fdb\u5236\u6570
answer"},{"location":"CS/CO/2_Instruction/#_4","title":"\u6c47\u7f16","text":""},{"location":"CS/CO/2_Instruction/#_5","title":"\u6590\u6ce2\u90a3\u5951\u6570","text":""},{"location":"CS/CO/2_Instruction/#_6","title":"\u5c3e\u9012\u5f52\u7684\u4f18\u5316\u3001","text":""},{"location":"CS/CO/3_Arithmetic/","title":"Chapter 3 | Arithmetic for Computer","text":"
0x11
0x88
\u7ea6 926 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
3.1 Introduction - \u6570\u503c\u8868\u8fbe -
3.2 Signed and Unsigned Numbers - Possible Representations
- \u6ea2\u51fa
3.3 Arithmetic--Addition & Subtraction and ALU
- CLA
- \u884c\u6ce2
3.4 Multiplication
3.5 Division
3.6 Floating point numbers
"},{"location":"CS/CO/3_Arithmetic/#introduction","title":"Introduction","text":""},{"location":"CS/CO/3_Arithmetic/#arithmetic","title":"Arithmetic","text":"
- \u4e00\u4e2a\u6570\u5b57\u53ea\u662f\u4e00\u4e2a\u6570\u5b57\uff0c\u672a\u6307\u660e\u542b\u4e49\u5b83\u5e76\u4e0d\u8868\u5f81\u4efb\u4f55\u610f\u4e49
overflow
\\(OverFlow = C_{n} \\oplus C_{n-1}\\)
Delay\u7684\u8ba1\u7b97
\u8fd9\u91cc\u8ddf\u6570\u5b57\u903b\u8f91\u7684\u57fa\u672c\u76f8\u540c
"},{"location":"CS/CO/3_Arithmetic/#cla","title":"CLA","text":""},{"location":"CS/CO/3_Arithmetic/#multiplication","title":"Multiplication","text":"Multiplicand=\u88ab\u4e58\u6570
Multiplier=\u4e58\u6570
"},{"location":"CS/CO/3_Arithmetic/#v1","title":"V1","text":"
- \u4e58\u6cd5\u4e0d\u80fd\u7528\u8865\u7801\u64cd\u4f5c
"},{"location":"CS/CO/3_Arithmetic/#v2","title":"V2","text":"
- \u4e0d\u65ad\u79fb\u52a8\u4f4d\u7f6e\uff08\u5de6\u79fb\u52a8\uff09\uff0c\u505a\u52a0\u6cd5
- \u79fb\u52a8\u88ab\u4e58\u6570
- \u5bf9\u4e58\u6570\u7684\u6700\u540e\u4e00\u4f4d\u5224\u65ad\uff0c\u662f1\uff0c\u7ed3\u679c\u52a0\u4e0a\u5f53\u524d\u7684\u88ab\u4e58\u6570
- \u4e0d\u79fb\u52a8\u88ab\u4e58\u6570\uff0c\u800c\u662f\u79fb\u52a8\u4e58\u79efproduct
- \u5bf9\u4e8e128bits\u7684product\uff0c\u9ad864bits\u8fdb\u884c\u7b97\u672f\u8fd0\u7b97\uff0c\u7136\u540e\u4e0d\u65ad\u53f3\u79fb
example
"},{"location":"CS/CO/3_Arithmetic/#v3","title":"V3","text":"
- \u4e4b\u524dV2\u91cc\u9762\u7684Product\u4f4e64bits\u6ca1\u6709\u4efb\u4f55\u7528\u5904\uff0c\u8fd9\u91cc\u7528\u6765\u88c5\u4e58\u6570\uff0c\u4f7f\u4e4b\u53f3\u79fb\u79fb\u9664\u7684bit\u8fdb\u884c\u5224\u65ad
"},{"location":"CS/CO/3_Arithmetic/#_1","title":"\u6709\u7b26\u53f7\u4e58\u6cd5","text":"
- 129bits\u662f\u4e3a\u4e86\u4fdd\u5b58\u8fdb\u4f4d\uff08\u4e2a\u4eba\u611f\u89c9\u7528\u4e0d\u5230\u554a
- \u8bb0\u5f55\u7b26\u53f7\uff0c\u8f6c\u4e3a\u7edd\u5bf9\u503c\u76f8\u4e58
Booth Algorithm
\u9002\u7528\u4e8e\u5f0f\u5b50\u4e2d1\u6bd4\u8f83\u591a\u7684\u60c5\u51b5\uff0c\u5c06\u591a\u7684\u52a0\u6cd5\u8f6c\u6362\u4e3ashift\uff08\u5de6\u5230\u53f3\u7684\u5e8f\u5217\uff09
\u6839\u636e\u76f8\u90bb\u7684\u4e24\u4e2abits\u5224\u65ad\u5bf9\u8fd9\u4e00\u4f4d\u8981\u505a\u4ec0\u4e48\u64cd\u4f5c\uff0c\u00b1\u88ab\u4e58\u6570
- \u4e0e\u4e0a\u9762\u7684\u601d\u60f3\u7c7b\u4f3c\uff0c\u5728\u4e00\u4e2a\u5bc4\u5b58\u5668\u5de6\u534a\u90e8\u5206\uff0c\u53f3\u534a\u90e8\u5206 \u5206\u522b \u653e\u7f6e Result\uff0c\u4e58\u6570\uff1b\u6bcf\u6b21\u6839\u636e\u4e58\u6570\u6700\u4f4e\u4f4d\u7684\u5e8f\u5217\u5bf9Result\u90e8\u5206\u8fdb\u884c\u64cd\u4f5c\uff0c\u6bd4\u5982 add \u88ab\u4e58\u6570\uff1b
- \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8ba1\u7b97\u8fd9\u4e2a\u5e8f\u5217\u662f\u4ece -1 \u4f4d\uff08\u9ed8\u8ba4\u4e3a0\uff09\u5f00\u59cb\u7684
- shift\u64cd\u4f5c\u6bcf\u6b21\u90fd\u8981\u8fdb\u884c 11\u300100 \u7684\u60c5\u51b5\u76f8\u5f53\u4e8eoperation\u73af\u8282\u662f\u7a7a\u7684
Example
"},{"location":"CS/CO/3_Arithmetic/#division","title":"Division","text":"Dividend=\u88ab\u9664\u6570\uff0c
Divisor=\u9664\u6570
Quotient \u5546
"},{"location":"CS/CO/3_Arithmetic/#v1_1","title":"V1","text":"
- \u9664\u6570\u6700\u5f00\u59cb\u5728Divisor\u5de664bits\uff0c\u88ab\u9664\u6570\u5728Remainder\u53f364bits\uff0c
Note
"},{"location":"CS/CO/3_Arithmetic/#v2_1","title":"V2","text":"\u6539\u8fdb
\u9664\u6570\u4e0d\u52a8\uff0c\u88ab\u9664\u6570\u5de6\u79fb\uff0c\u8fdb\u884c\u8ba1\u7b97\uff0c\u5c0f\u4e8e\u96f6\u5219\u56de\u9000\uff0c\u5de6\u79fbremainder\u7f6e0\uff1b\u5927\u4e8e\u96f6\u5de6\u79fbremainder\u7f6e1
shift right
\u9488\u5bf9\u7684\u662f\u6700\u540e\u4e00\u6b65\uff0c\u628a\u4f59\u6570\u90e8\u5206\u7684\u7ed3\u679c\u53f3\u79fb1bitexample
"},{"location":"CS/CO/3_Arithmetic/#_2","title":"\u6709\u7b26\u53f7\u9664\u6cd5","text":"
- \u6ce8\u610f\u6700\u540e\u4e00\u6b65
"},{"location":"CS/CO/3_Arithmetic/#floating-point-numbers","title":"Floating point Numbers","text":"
remainder
\u9ad8\u4f4d\uff0c\u7b26\u53f7\u7531\u88ab\u9664\u6570\u51b3\u5b9a- \u4f4e\u4f4d \u5546
- Overflow and division-by-zero don\u2019t produce errors
- Just return defined results
- Faster for the common case of no error
- \u5355\u7cbe\u5ea6 float 1 + 8 + 23
- \u53cc\u7cbe\u5ea6 double 1 + 11 + 52
\u4e3a\u4e86\u8282\u7701\u7b26\u53f7\u4f4d\u7684\u7a7a\u95f4\uff0c
\\[ \u4e8e\u662f\u53ef\u4ee5\u8868\u793a\uff1a \\ \\ (-1)^{sign}(1+significand)*2^{exponent - bias} \\] "},{"location":"CS/CO/3_Arithmetic/#range","title":"Range","text":"exponent
\u6211\u4eec\u90fd\u52a0\u4e0a\u4e86\u4e00\u4e2abiased
Exponents
"},{"location":"CS/CO/3_Arithmetic/#_3","title":"\u7cbe\u5ea6","text":"
- 00000000 and 11111111 reserved
\u8ba1\u7b97\u7cbe\u5ea6\u4e0e\u5c0f\u6570\u4f4d\u6570\u76f8\u5173
"},{"location":"CS/CO/3_Arithmetic/#_4","title":"\u52a0\u6cd5","text":""},{"location":"CS/CO/3_Arithmetic/#algorithm","title":"Algorithm","text":"
- Alignment \u5bf9\u9f50 \u4e00\u822c\u7531\u8f83\u5c0f\u7684\u6570\u5411\u5927\u7684\u53d8
- The proper digits have to be added
- Addition of significands
- Normalization of the result \u5f52\u4e00\u5316\u5904\u7406
- Rounding \u8fdb\u4f4d
example
"},{"location":"CS/CO/3_Arithmetic/#_5","title":"\u4e58\u6cd5","text":""},{"location":"CS/CO/3_Arithmetic/#ieee","title":"IEEE \u62d3\u5c55 \u7cbe\u786e\u7b97\u672f\u8fd0\u7b97","text":"
- \u8bb0\u5f97exponent\u90e8\u5206\u76f8\u52a0\u4e4b\u540e\u51cf\u53bb\u4e00\u4e2a
bias
- \\(y={exponent - bias},y_1+y_2=ex_1+ex_2-2*bias,ex_1+ex_2=y+2*bias\\)
\u6ce8\u610f\uff01
\u8fd9\u4e2aBlog\u5b9a\u4e49\u7684\u6982\u5ff5\u8ddf\u8bfe\u672c\u4e0a\u7684\u4e0d\u4e00\u81f4
"},{"location":"CS/CO/3_Arithmetic/#_6","title":"\u9898\u76ee","text":""},{"location":"CS/CO/3_Arithmetic/#_7","title":"\u6d6e\u70b9\u6570\u8ba1\u7b97","text":"Answer Answer
Blog
\u8fd9\u4e9bbits\u7684\u4f5c\u7528\u662f\u5728\u8fd0\u7b97\u8fc7\u7a0b\u4e2d\u4fdd\u7559\u7cbe\u5ea6\u4fbf\u4e8e\u4e4b\u540e\u8fdb\u4f4d\u635f\u5931\u7684\u7cbe\u5ea6\u4e0d\u8d85\u8fc70.5ulp
sticky bit
\u5728Round bit\u4e4b\u540e\u7684\u6240\u6709\u4f4d\u4e2d\u53ea\u8981\u67091\u5c31\u5b58\u4e3a1\uff0c\u8fd9\u4e2abit\u4e0d\u4e00\u5b9a\u8981\u7528\u5230\uff0c\u662f\u4e3a\u4e86\u68c0\u6d4b\u7c7b\u4f3c2.500000000\u4e0e2.500000001
\u7684\u533a\u522bGuard bit
\u8981\u4fdd\u7559\u7684\u6700\u4f4e\u4f4d\u4e4b\u540e\u7684\u7b2c\u4e00\u4f4dRound bit
- \u820d\u5165\u89c4\u5219:
- \u5982\u679cguard bit\u662f0\uff0c\u90a3\u4e48\u76f4\u63a5\u622a\u65ad\u3002
- \u5982\u679cguard bit\u662f1\u4e14round bit\u6216sticky bit\u81f3\u5c11\u4e00\u4e2a\u662f1\uff0c\u90a3\u4e48\u5411\u4e0a\u820d\u5165\uff08\u52a01\u81f3\u5c3e\u6570\u7684\u6700\u540e\u4e00\u4f4d\uff09\u3002
- \u5982\u679c\u4ec5\u4ec5guard bit\u662f1\uff0c\u90a3\u4e48\u6267\u884c\u5411\u5076\u6570\u820d\u5165\uff08\u5982\u679c\u5c3e\u6570\u7684\u6700\u540e\u4e00\u4f4d\u662f0\u5219\u4e0d\u53d8\uff0c\u5982\u679c\u6700\u540e\u4e00\u4f4d\u662f1\u5219\u52a01\uff09\u3002
\u5982\u679c\u5148\u8ba1\u7b97\u540e\u4e24\u4e2a\u6570\uff0c\u7ed3\u679c\u4f1a\u53d1\u751f\u53d8\u5316\uff0c\u56e0\u4e3a\u4e2d\u95f4\u8fc7\u7a0b\u7684GRTbit\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u5bfc\u81f4\u4fdd\u6301\u7684\u7cbe\u5ea6\u53d8\u5316
"},{"location":"CS/CO/4_Processor/","title":"Chapter 4 | Processor","text":"\u7ea6 1228 \u4e2a\u5b57 8 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 6 \u5206\u949f
"},{"location":"CS/CO/4_Processor/#part-1","title":"Part 1 \u5355\u5468\u671f","text":""},{"location":"CS/CO/4_Processor/#data-path","title":"Data Path","text":"\u7565
"},{"location":"CS/CO/4_Processor/#control","title":"Control","text":"
- \u4e03\u4e2a\u63a7\u5236\u4fe1\u53f7\u548c\u4e00\u4e2a\u56db\u4f4d\u7684
ALU operation
"},{"location":"CS/CO/4_Processor/#part-2","title":"Part 2 \u6d41\u6c34\u7ebf","text":"
- ALU \u4fe1\u53f7
\u5355\u5468\u671f\u7684\u5f0a\u7aef\uff1a \u5047\u8bbe\u53d6\u6307\u4ee4 200ps, \u5bc4\u5b58\u5668\u8bfb 100ps, ALU \u8ba1\u7b97 200ps, \u5185\u5b58\u8bbf\u95ee 200ps, \u5bc4\u5b58\u5668\u5199 100ps. \u90a3\u4e48
add
\u9700\u8981 600ps,ld
\u9700\u8981 800ps,sd
\u9700\u8981 700ps,beq
\u9700\u8981 500ps.
- a pipeline in which one instruction is in each stage
- CPI is decreased to 1, since one instruction will be issued (or finished) each cycle.
\u541e\u5410\u7387 | throughput
\u6d41\u6c34\u7ebf\u5b9e\u9645\u4e0a\u662f\u63d0\u9ad8\u4e86\u7cfb\u7edf\u7684\u541e\u5410\u7387\u3002\u4f46\u662fLatency (time for each instruction)\u4e0d\u4f1a\u51cf\u5c11
"},{"location":"CS/CO/4_Processor/#hazards","title":"\u7ade\u4e89 | Hazards","text":"\u5bfc\u81f4\u4e0b\u4e00\u6761\u6307\u4ee4\u65e0\u6cd5\u6b63\u5e38\u8fdb\u884c\u7684
"},{"location":"CS/CO/4_Processor/#structure","title":"\u7ed3\u6784\u7ade\u4e89 | Structure","text":"A required resource is busy \u5927\u591a\u6570\u662f\u786c\u4ef6\u95ee\u9898\u5bfc\u81f4
"},{"location":"CS/CO/4_Processor/#data","title":"\u6570\u636e\u7ade\u4e89 | Data","text":"
- In RISC-V pipeline with a single memory
- Load/store requires data access
Instruction fetch would have to stall for that cycle
- Would cause a pipeline \u201cbubble\u201d
\u628a\u6307\u4ee4\u548c\u6570\u636e\u5206\u5f00\u5b58\u50a8 \u5982\u679c\u53ea\u6709\u4e00\u5757\uff0c\u90a3\u4e48\u5f53IF\u9700\u8981\u83b7\u53d6\u6307\u4ee4\uff0cMem\u9700\u8981\u83b7\u53d6\u6570\u636e\u65f6\u5c31\u4f1a\u53d1\u751f\u7ed3\u6784\u5192\u9669
Need to wait for previous instruction to complete its data read/write
\u524d\u4e00\u4e2a\u7684\u7ed3\u679c\u662f\u540e\u4e00\u4e2a\u7684\u64cd\u4f5c\u6570
- WB\u5728\u4e0b\u964d\u6cbf\u89e6\u53d1
- ID\u5728\u4e0a\u5347\u6cbf\u89e6\u53d1
- \u63d2\u5165\"Bubble\"\u8fdb\u884c\"\u7f13\u51b2\"
Solution
- Forwarding (aka Bypassing)
ld
\u6307\u4ee4"},{"location":"CS/CO/4_Processor/#control_1","title":"\u63a7\u5236\u7ade\u4e89 | Control","text":"
- \u7f16\u8bd1\u5668\u65b9\u9762
Deciding on control action depends on previous instruction
\u5728ID\u9636\u6bb5\u52a0\u5165\u66f4\u591a\u7684\u786c\u4ef6\u53bb\u5224\u65ad
\u6216\u8005
\u4f7f\u7528Prediction\u6280\u672f
"},{"location":"CS/CO/4_Processor/#prediction","title":"Prediction","text":"
- \u4f8b\u5982\uff0c\u5bf9
beq
\uff0cIF
\u9700\u8981\u5f97\u77e5\u8981\u53bb\u7684\u5730\u5740\uff0c\u4f1a\u628a\u8ba1\u7b97\u63d0\u524d\u5230ID
\u6b65\u9aa4"},{"location":"CS/CO/4_Processor/#risc-v-pipelined-datapath","title":"RISC-V Pipelined Datapath","text":""},{"location":"CS/CO/4_Processor/#form","title":"Form","text":"
- Can predict branches not taken
- Fetch instruction after branch, with no delay
"},{"location":"CS/CO/4_Processor/#control_2","title":"Control \u6307\u4ee4","text":"
- \u6ce8\u610f\uff0c\u4e0a\u56fe\u4e2d\u7684Write Register\u662f\u9519\u8bef\u7684
"},{"location":"CS/CO/4_Processor/#data-hazards","title":"Data hazards","text":"
WB
\u6b65\u9aa4\u7684Write Register
\u4f20\u56de\u5bc4\u5b58\u5668\u5806Consider this sequence:
sub x2, x1,x3 and x12,x2,x5 or x13,x6,x2 add x14,x2,x2 sd x15,100(x2)
ID/EX
\u90a3\u91cc\u8981\u4f7f\u7528\u7684RS
\u662f\u5176\u4ed6\u6d41\u6c34\u7ebf\u7684RD
, \u5c31\u51fa\u73b0\u4e86\u6570\u636e\u7ade\u4e89\uff08\u8fd9\u91cc\u7684\u5b9a\u4e49\u6709\u4e9b\u7b3c\u7edf\uff0c\u66f4\u51c6\u786e\u5730\u8fd8\u8981\u52a0\u4e0a\u6761\u4ef6\uff1a\u9700\u8981\u7528\u5230RS
\uff09\\[ 1.\\ EX/MEM.RegisterRd=ID/EX.RegisterRs\\\\ 2.\\ EX/MEM.RegisterRd\\ !=0 \\\\ 3.\\ EX/MEM.RegWrite==1 \\\\ \u5bf9\u4e8eMEM/WB\u7ea7\u540c\u7406 \\\\ \\text{\u9700\u8981\u786e\u4fdd\u53d1\u751f\u6570\u636e\u7ade\u4e89\u7684\u4e0a\u4e00\u7ea7\u7684Rd\u662f\u8981\u5199\u56de\u7684\uff0c\u4e14\u5199\u56de\u7684\u5bc4\u5b58\u5668\u4e0d\u662f}X_0 \\] "},{"location":"CS/CO/4_Processor/#double-data-hazard","title":"Double Data Hazard","text":"
- \u6ce8\u610f\u5bc4\u5b58\u5668\u7684\u5199\u6cd5\uff0c
ID/EX.RegisterRd
\u8003\u8651\u4e24\u4e2a\u5730\u65b9\u90fd\u89e6\u53d1\u4e86\u6570\u636e\u7ade\u4e89\uff0c\u9009\u62e9\u6700\u8fd1\u7684\u90a3\u4e2a\u6570\u636e
add x1,x1,x2 add x1,x1,x3 add x1,x1,x4
\u9700\u8981\u5bf9
Mem/WB
\u5bc4\u5b58\u5668\u7684\u7279\u5224
EX/MEM
EX/MEM.RegWrite and (EX/MEM.RegisterRd!=0) and EX/MEM.RegisterRd = ID/EX.RegisterRs1
"},{"location":"CS/CO/4_Processor/#load-use-hazard-detection","title":"Load-Use Hazard Detection","text":"
MEM/WB
graph LR\n1[IF]\n2[ID]\n3[EX]\n4[Mem]\n5[WB]\n1-->2-->3-->4-->5\n
- Load\u7684\u65f6\u5019\uff0c\u5728
IF/ID
\u6b65\u9aa4\u9700\u8981\u5224\u65ad\uff0c\u56e0\u4e3a Load \u7684\u7ed3\u679c\u5fc5\u987b\u8981\u5230mem\u7ea7\u624d\u80fd\u83b7\u53d6\uff0c\u4e0d\u80fdID\u5230\u9519\u8bef\u7684\u6570\u636e
ld
\u7684\u7ed3\u679c\u5728EX/Mem
\u9636\u6bb5\u624d\u80fd\u5f97\u5230Bubble\uff1a\u7a7a\u6321
"},{"location":"CS/CO/4_Processor/#branch-hazard-control","title":"Branch hazard | Control","text":"
- Force control values in ID/EX register to 0 \u63d2\u96f6\u540e\u9762\u7684\uff0c\u628a\u5f53\u524d\u7684ID/EX\u53d8\u4e3aNOP
- EX, MEM and WB do
nop (no-operation)
- Prevent update of PC and IF/ID register \u505c\u6ede\u4e4b\u524d\u7684
- Using instruction is decoded again
"},{"location":"CS/CO/4_Processor/#_1","title":"\u7f29\u77ed\u5206\u652f\u5ef6\u8fdf","text":"
- \u9700\u8981\u6e05\u9664\u5206\u652f\u6307\u4ee4\u5230\u8fbeMem\u9636\u6bb5\u65f6\u5176\u4ed6\u524d\u9762\u51e0\u4e2a\u5bc4\u5b58\u5668
\u5c06\u5bf9\u5206\u652f\u7684\u68c0\u6d4b\u63d0\u524d\u5230ID\u9636\u6bb5
"},{"location":"CS/CO/4_Processor/#_2","title":"\u52a8\u6001\u9884\u6d4b","text":"
- \u9700\u8981\u65b0\u7684\u524d\u9012\u548cStall\u5355\u5143
- bypass
- Stall \uff1a\u6bd4\u5982\u8ba1\u7b97\u5206\u652f\u5730\u5740\u9700\u8981\u7684\u6570\u636e\u6765\u81ea\u4e8e\u4e0a\u4e00\u7ea7\u7684EX\u3001Mem
- \u4e0a\u4e00\u7ea7\u5b58\u5728ALU\u64cd\u4f5c\uff0c\u4e14\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u3002Stall one bubble
- \u4e0a\u4e00\u7ea7\u5b58\u5728ld\u64cd\u4f5c\uff0c\u4e14\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u3002Stall two bubbles
Branch prediction buffer (aka branch history table)
Indexed by recent branch instruction addresses \u6309\u7167\u5206\u652f\u6307\u4ee4\u7684\u4f4e\u4f4d\u5730\u5740\u5b9a\u4f4d\u7684\u5c0f\u5b58\u50a8
Stores outcome (taken/not taken)
- To execute a branch
- Check table, expect the same outcome
- Start fetching from fall-through or target
- If wrong, flush pipeline and flip prediction
\u5206\u652f\u9884\u6d4b\u5355\u5143\u53ef\u4ee5\u653e\u5728ID\u7ea7
\u5373\u4f7f\u5b58\u5728Prediction\uff0c\u8ba1\u7b97Branch Target\u7684\u4e00\u4e2a\u5468\u671f\u635f\u5931\u4e5f\u4e0d\u53ef\u907f\u514d
Branch target buffer | \u5206\u652f\u76ee\u6807\u7f13\u5b58
"},{"location":"CS/CO/4_Processor/#exceptions-and-interrupts","title":"Exceptions and Interrupts | \u5f02\u5e38\u4e0e\u4e2d\u65ad","text":"Interrupts
\u6539\u53d8CPU\u7684 work flow \u7684\u4e24\u79cd\u5f62\u5f0f
predictable \u6bd4\u5982beq\u3001bne\u7b49\u547d\u4ee4\u53d1\u751f\u8df3\u8f6c
unpredictable \u51fa\u73b0\u5f02\u5e38
\u5f88\u591a\u65f6\u5019\u4e8c\u8005\u4e0d\u52a0\u533a\u5206, \u5e7f\u4e49\u7684Exception\u5305\u62ecInterrupt
\u9047\u5230\u5f02\u5e38\u9700\u8981\u5904\u7406\u4e24\u4ef6\u4e8b\uff1a - \u5728\u54ea\u91cc\u5904\u7406\u5f02\u5e38\uff0c\u5982\u4f55\u8df3\u8fc7\u53bb - \u5982\u4f55\u56de\u53bb
1.\u4e2d\u65ad\u6765\u4e86\u600e\u4e48\u529e\u3002
2.\u5b58PC\u5230Supervisor Exception Program Counter (SEPC)\uff0c\u63a7\u5236\u6743\u4ea4\u7ed9\u64cd\u4f5c\u7cfb\u7edf\uff0c\u901a\u8fc7\u5f3a\u5236\u8df3\u8f6c\uff0c
3.\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u884c\u9884\u5148\u89c4\u5b9a\u7684\u64cd\u4f5c\uff0c\u4e5f\u53ef\u80fd\u662f\u6267\u884c\u95ee\u9898\u5206\u6790\uff0c\u4e5f\u53ef\u80fd\u662f\u91cd\u590d\u6267\u884c\u3002
4.\u5206\u6790\u539f\u56e0\u65f6\u4f7f\u7528\u4e24\u79cd\u65b9\u6cd5\u901a\u77e5\u7cfb\u7edf\uff0c
a. \u8bbe\u7f6eSCAUSE
b. \u5411\u91cf\u5f0f\u4e2d\u65ad | vectored interrupt
Privilege
- RISCV\u4e2d\uff0c\u7531\u786c\u4ef6\u90e8\u5206\u5b9e\u73b0\u5bf9\u591a\u4e2a\u5f02\u5e38\u7684\u4f18\u5148\u7ea7\u6392\u5e8f
\u4e86\u89e3 \u53ef\u4ee5\u770b\u9a6c\u5fb7\u8001\u5e08\u667a\u4e91
- \u6a21\u5f0f
- \u4e0e\u6a21\u5f0f\u76f8\u5173
- \u7528\u6237\u6a21\u5f0f(User Mode)
- \u673a\u5668\u6a21\u5f0f(Machine Mode)
- \u76d1\u7763\u6a21\u5f0f(Supervisor Mode)
- \u539f\u5b50\u64cd\u4f5c
- \u4e00\u51714096\u4e2aCSR\u5bc4\u5b58\u5668
Instruction
"},{"location":"CS/CO/4_Processor/#multiple","title":"Multiple","text":"
- \u5f02\u5e38\u63a7\u5236\u7a0b\u5e8f
"},{"location":"CS/CO/4_Processor/#pipline-itp","title":"Pipline | ITP","text":""},{"location":"CS/CO/4_Processor/#problem","title":"Problem","text":""},{"location":"CS/CO/4_Processor/#excution-diagram","title":"Excution Diagram\u7684\u753b\u6cd5","text":"Answer"},{"location":"CS/CO/5_/","title":"Speed and Size","text":"
precise
\u6309\u7167\u5f02\u5e38\u7684\u5148\u540e\u5b9e\u73b0imprecise
SEPC\u4fdd\u5b58\u7684\u5730\u5740\u4e0d\u4e00\u5b9a\u662f\u53d1\u751f\u4f8b\u5916/\u5f02\u5e38\u65f6\u7684\u5730\u5740
- Let the handler work out
- Simplifies hardware, but more complex handler software
- Not feasible for complex multiple-issue out-of-order pipelines \u5bf9\u4e8e\u65e0\u5e8f\u7684\u6d41\u6c34\u7ebf\u4e0d\u9002\u7528
\u7ea6 2625 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 13 \u5206\u949f
\u5904\u7406\u5668\u901f\u5ea6 <= \u9ad8\u5ea6\u76f8\u5173 => \u5bc4\u5b58\u5668\u901f\u5ea6
"},{"location":"CS/CO/5_/#memory-technology","title":"Memory Technology","text":""},{"location":"CS/CO/5_/#sram","title":"SRAM","text":""},{"location":"CS/CO/5_/#dram","title":"DRAM","text":"
- value is stored on a pair of inverting gates \u4e24\u4e2a\u53cd\u76f8\u5668
- very fast but takes up more space than DRAM
- Value is stored as a charge on capacitor \u7535\u5bb9\u5668
- Very small but slower than SRAM (factor of 5 to 10)
- Must periodically be refreshed \u5fc5\u987b\u5b9a\u671f\u5237\u65b0
- Read contents and write back (destructive read) \u7834\u574f\u6027\u8bfb\u53d6
Bits in a DRAM are organized as a rectangular array
DRAM accesses an entire row
Burst mode: supply successive words from a row with reduced latency (SDRAM)
\u4ece\u4e00\u884c\u4e2d\u8fde\u7eed\u8bfb\u53d6\u6bd4\u8f83\u5feb
\u6570\u5b57\u903b\u8f91
\u9ad8\u901f\u7684\u53e3\u4e00\u822c\u662f\u4e32\u884c\u7684\uff0c\u63a5\u53e3\u5f88\u5c11 <== \u4fdd\u8bc1\u591a\u6761\u7ebf\u540c\u65f6\u5230\u8fbe\u76ee\u6807
"},{"location":"CS/CO/5_/#flash","title":"Flash","text":"Nonvolatile semiconductor storage \u975e\u6613\u5931\u534a\u5bfc\u4f53
\u53ea\u80fd\u4ece1\u5199\u52300\uff0c\u64e6\u9664\u4ee3\u4ef7\u5927
"},{"location":"CS/CO/5_/#disk","title":"Disk","text":"
- NOR flash: bit cell like a NOR gate
- Random read/write access
- Used for instruction memory in embedded systems
- NAND flash: bit cell like a NAND gate
- Denser (bits/area), but block-at-a-time access
- Cheaper per GB
- Used for USB keys, media storage, \u2026
- Flash bits wears out after 1000\u2019s of accesses
- Not suitable for direct RAM or disk replacement
- Wear leveling: remap data to less used blocks
\u8bbf\u95ee\u65f6\u95f4\u7684\u8ba1\u7b97\uff1a
"},{"location":"CS/CO/5_/#memory-hierarchy-introduction","title":"Memory Hierarchy Introduction","text":"
- \u6bcf\u6b21\u8bfb\u53d6\u4e00\u4e2asector\u6247\u533a\u7684\u6570\u636e
locality
- Temporal locality \u65f6\u95f4\u5c40\u90e8\u6027
- Items accessed recently are likely to be accessed again soon
- e.g., instructions in a loop, induction variables
Spatial locality \u7a7a\u95f4\u5c40\u90e8\u6027
- Items near those accessed recently are likely to be accessed soon
- E.g., sequential instruction access, array data
Copy recently accessed (and nearby) items from disk to smaller DRAM memory Main memory \u4e3b\u5b58
Copy more recently accessed (and nearby) items from DRAM to smaller SRAM memory Cache memory attached to CPU \u7f13\u51b2
\u200b cache \u5728CPU\u5185\u90e8
\u6982\u5ff5
"},{"location":"CS/CO/5_/#the-basic-of-cache","title":"The basic of Cache","text":"
Block
: unit of copying \u642c\u8fd0\u7684\u6700\u5c0f\u5355\u4f4d \u53ef\u80fd\u662f\u4e00\u4e2aword\u6216\u8005\u591a\u4e2aword
Hit
: If accessed data is present in upper level \u4e24\u5c42\uff1a\u4ece\u786c\u76d8\u5230\u5185\u5b58\uff0c\u4ece\u5185\u5b58\u5230cache
Hit Time
: The time to access the upper level of the memory hierarchy, which includes the time needed to determine whether the access is a hit or a miss.
Hit ratio
: hits/accesses
Miss
: block copied from lower level
Miss ratio
: misses/accesses = 1 \u2013 hit ratioMiss penalty
: The time to replace a block in the upper level with the corresponding block from the lower level, plus the time to deliver this block to the processor. \u628a\u6570\u636e\u4ece\u5e95\u5c42\u62ff\u5230\u9ad8\u5c42\uff0c\u4e4b\u540e\u518d\u4f20\u7ed9processorSRAM and DRAM (main memory)
"},{"location":"CS/CO/5_/#direct-mapped","title":"Direct mapped","text":"(Block address) modulo (Number of blocks in the cache)
\u56fa\u5b9a\u7684\u4f4d\u7f6e $\\text{(Block address) \\% (Number of blocks in the cache)} $
Tag \u533a\u5206\u5b58\u653e\u7684\u54ea\u4e2a\u6570\u636e
- Store block address as well as the data
- Actually, only need the high-order bits
Valid Bits \u8fd9\u4e2aBlock\u662f\u5426\u4e3a\u7a7a
Valid bit: 1 = present, 0 = not present \u6700\u521d\u8bbe\u7f6e\u4e3a0
Cache Block Address
example\u7406\u89e3cache\u4e2d\u7684\u5404\u4e2a\u4f4d
\u4e0a\u9762\u7684\u90e8\u5206\u662f Memory address\uff08Tag + Index)\uff0c\u4e0b\u9762\u7684\u624d\u662fcache\u4e2d\u7684(\u8fd9\u91ccCache Address\u5c31\u662f\u5b83\u7684\u7d22\u5f15Index)\u3002\u8fd9\u91cc\u6bcf\u4e00\u4e2aBlock\u6709\u56db\u4e2aword\uff0c\u9700\u8981\u4e24\u4f4d\u6765\u5b9a\u4f4dword\uff0c\u6bcf\u4e2aword\u6709\u56db\u4e2a\u5b57\u8282\uff0c\u9700\u8981\u4e24\u4f4d\u6765\u5b9a\u4f4dbyte\uff0c\u6545\u800c
Byte offset = 4
index
\u5728cache\u4e2d\u5bfb\u627eblock\uff0c\u5176\u5927\u5c0f\u7531cache size\u51b3\u5b9a
Offset
\u7528\u4e8e\u53bb\u5728data\u4e2d\u5bfb\u5740\u3002\u6ce8\u610f\u5bfb\u5740\u65b9\u5f0f\uff0c\u4e00\u822c\u662f\u5b57\u8282\u5bfb\u5740\uff0c\u4f46\u662f\u5f88\u591a\u9898\u76ee\u4f1a\u662fword\u5bfb\u5740\uff0c\u540c\u65f6\u4e5f\u770b\u6e05\u695a\u7ed9\u7684\u5730\u5740\u662f\u4ee5\u5b57\u8282\u5740\u8fd8\u662fWord\u3002\u6bd4\u5982\uff0c\u4e00\u4e2a 4-word blocks\uff0c\u5c31\u9700\u8981 index \u5148\u53bb\u5bfb\u627eblock\uff0c\u518d\u7531offset\u5206\u522b\u786e\u5b9aword\u548cbyte\uff0c\u6545\u9700\u89814bit\u4e00\u4e2acache slot\u5b9e\u9645\u7684size\u662f data size of a block + Tag + Valid\uff0c\u4f46\u662f\u63d0\u53ca\u67d0\u4e2acache\u5927\u5c0f\u65f6\uff0c\u90fd\u662f\u53ea\u8ba1\u7b97Data\u90e8\u5206
Tag
\u7531 memory address \u51cf\u53bb Index\u3001Byte Offset\u8ba1\u7b97
Total cache size
: Block num(2^n) * (data size + tag size + valid bit)\u8ba1\u7b97
cache\u7684\u547d\u540d\u4e0d\u8003\u8651\u6807\u7b7e\u548c\u6709\u6548\u4f4d\u7684\u5927\u5c0f\uff0c\u53ea\u8003\u8651\u6570\u636e\u7684\u5927\u5c0f
example
Handling Cache reads hit and Misses
detail
Read
Read Miss \u6682\u505c\u5904\u7406\u5668\uff0c\u76f4\u5230\u4ece\u5185\u5b58\u4e2d\u8fd4\u56de\u6570\u636e
instruction cache miss
data cache miss
1. Send the original PC value (current PC-4) to the memory.
2. Instruct main memory to perform a read and wait for the memory to complete its access. (in multiple cycles)
3. Write the cache entry, putting the data from memory in the data portion of the entry, writing the upper bits of the address (from the ALU) into the tag field, and turning the valid bit on.
4. Restart the instruction execution at the first step, which will refetch the instruction again, this time finding it in the cache.
"},{"location":"CS/CO/5_/#deep-concept","title":"Deep Concept","text":"
Write hits
\u4e0d\u540c\u7684\u5199\u7b56\u7565 \u8be6\u7ec6\u5185\u5bb9\u89c1\u540e
write-back: Cause Inconsistent Wrote the data into only the data cache
write-through: Ensuring Consistent
Write Miss
\u5f15\u5165
1-word block
"},{"location":"CS/CO/5_/#block-placement","title":"Block Placement","text":""},{"location":"CS/CO/5_/#fully-associative","title":"Fully Associative","text":"Block can go anywhere in cache
"},{"location":"CS/CO/5_/#set-associative","title":"Set Associative","text":"Block can go in one of a set of places in the cache.
A set is a group of blocks in the cache.
Block address MOD Number of sets in the cache \u4e5f\u5c31\u662f\u9488\u5bf9\u4e0a\u9762\u7684index\u5728\u8fd9\u91cc\u4f1a\u662fset index
If sets have n blocks, the cache is said to be n-way set associative. \u00a0\u6ce8\u610f\u8fd9\u91cc\u662f\u4e00\u4e2a\u7ec4\u6709n\u4e2aBlock\u5219\u79f0\u4e4b\u4e3aN-way set\u800c\u975e n \u4e2aset
"},{"location":"CS/CO/5_/#block-identification","title":"Block identification","text":"\u57fa\u672c\u76f8\u540c
"},{"location":"CS/CO/5_/#block-replacement","title":"Block replacement","text":"
Random replacement
- randomly pick any block
Least-recently used (LRU)
- pick the block in the set which was least recently accessed
Assumed more recently accessed blocks more likely to be referenced again
This requires extra bits in the cache to keep track of accesses.
"},{"location":"CS/CO/5_/#write-strategy","title":"Write Strategy","text":"
First in,first out(FIFO)
- Choose a block from the set which was first came into the cache
write hit
- If the data are written to memory, the cache is called a write-through cache
- Can always discard cached data - most up-to-date data is in memory \u5728Disk\u4e2d\u603b\u662f\u6700\u65b0\u7684\u6570\u636e
- Cache control bit: only a valid bit
- memory (or other processors) always have latest data
- \u8bfb\u53d6miss\u4e0d\u4f1a\u5f71\u54cdwrite
- If the data are NOT written to memory, the cache is called a write-back cache
- dirty page \u5b58\u5728,\u4e0d\u80fd\u76f4\u63a5discard
- Cache control bits: both valid and dirty bits \u591a\u4e86Dirty bit
- much lower bandwidth, since data often overwritten multiple times
\u8fd9\u4e24\u79cd\u7b56\u7565\uff0c\u90fd\u4f1a\u4f7f\u7528Buffer\u3002 Write-Through \u4f7f\u7528Buffer\u662f\u4e3a\u4e86\u964d\u4f4e\u4e0d\u65ad\u5199\u56de\u4e0b\u4e00\u5c42\u7684cost\uff0c\u4f7f\u7528\u7684\u662f\u4e0b\u9762\u7684 Write Buffer\uff0c\u6570\u636e\u5199\u5165Cache\u7684\u540c\u65f6\uff0c\u4e5f\u5199\u5165buffer Write-Back \u4e5f\u6709\u5199\u7f13\u51b2\uff0cBuffer
Write stall
When the CPU must wait for writes to complete during write through
Write buffers
- A small cache that can hold a few values waiting to go to main memory.
- This buffer helps when writes are clustered.
- \u5982\u679c\u4e00\u6b21\u5199\u5165\u7684\u91cf\u5f88\u5927\uff0c\u5f88\u53ef\u80fd\u8d85\u8fc7buffer\u7684\u5bb9\u91cf
- \u589e\u52a0\u4e86\u6570\u636e\u8bbf\u95ee\u7684\u590d\u6742\u5ea6\uff0c\u9700\u8981\u68c0\u6d4b\u6570\u636e\u662f\u5426\u5728write buffer\u4e2d\uff0c\u5426\u5219\u5e76\u884c\u7684IC\u6570\u636e\u8bbf\u95ee\u8bfb\u53d6\u7684\u662f\u65e7\u6570\u636e
Write miss
\u770b\u662f\u5426\u5199\u56de\u5230cache\u4e2d\u53bb
- **Write allocate **
The block is loaded into the cache on a miss before anything else occurs.
"},{"location":"CS/CO/5_/#designing-the-memory-system-to-support-cache","title":"Designing the Memory system to Support Cache","text":"
**Write around (no write allocate) **
- The block is only written to main memory
- It is not stored in the cache.
In general, write-back caches use write-allocate , and write-through caches use write-around.
\u5bf9\u4e3b\u5b58\u7684\u52a0\u901f\u3002\u5355\u7eaf\u7684One-word-wide\u67b6\u6784\uff0c\u7531\u4e8e\u5bf9DRAM\u53d6\u6570\u636e\u5f88\u8017\u65f6\uff0c\u4f1a\u9020\u6210\u5f88\u591a\u65f6\u95f4\u6d6a\u8d39
\u6982\u5ff5
Bandwidth
\u5e26\u5bbd\uff0c\u662f\u4e00\u4e2a\u65f6\u949f\u5468\u671f\u80fd\u8bbf\u95ee\u7684Bytes\u6570\u76ee \\(Bandwidth = \\frac{Bytes}{CLK}\\)
miss penalty
\u79fb\u52a8\u4e00\u4e2aBlock\u7684\u4ee3\u4ef7example
\u589e\u5927 Memory \u4f4d\u5bbd
\u5982\u679c\u4f4d\u5bbd\u589e\u52a0\uff0c\u5355\u4f4d\u65f6\u95f4\u5185\u4f20\u8f93\u7684Block\u6570\u76ee\u589e\u52a0
\u589e\u52a0Memory\u6570\u91cf\uff08\u7c7b\u4f3c\u5e76\u884c
4 banks Interleaved Memory
\u4f46\u662fbus\u7684\u4f4d\u5bbd\u6ca1\u6709\u53d8\u5316\uff0c\u5bfc\u81f4\u901a\u8fc7bus\u4f20\u8f93\u6570\u636e\u9700\u8981\u7b49\u5f85
"},{"location":"CS/CO/5_/#measuring-and-improving-cache-performance","title":"Measuring and improving cache performance","text":"The main contents are the following:
\\[ \\text{Average Memory Assess Time (AMAT) = hit time + miss time}\\\\ \\text{= hit rate \u00d7 Cache time + miss rate \u00d7memory time} \\]"},{"location":"CS/CO/5_/#measuring","title":"Measuring","text":"
Measuring cache performance
Reducing cache misses by more flexible placement of blocks
Reducing the miss penalty using multilevel caches
\u6211\u4eec\u4f7f\u7528CPU Time\u6765\u8861\u91cf how good it works $$ {CPU Time} = \\text{CPI * I * CPU cycle time} \\ =\\text{CPU Excution Time} + \\text{CPU Memory-stall Time} $$
\\[ \\text{CPU Memory-Stall Time} = \\text{Read-stall+Write-stall}\\\\ = \\#of\\ instructions\\text{ * miss ratio * miss penalty} \\]For Read
\\(\\text{Read-stall} = \\frac{Read}{Program}*\\text{Read miss rate * Read miss penalty}\\)
For Write
\\(Write-stall = \\frac{Write}{Program}*\\text{Write miss rate * Write miss penalty} + Write Buffer\\)
If the write buffer stalls are small, we can safely ignore them .
If the cache block size is one word, the write miss penalty is 0.
- \u901a\u5e38\u60c5\u51b5\u4e0b\u90fd\u53ef\u4ee5\u5ffd\u7565 <== \u8bbe\u8ba1\u7684\u8f83\u597d\u7684CPU\u4e00\u822c\u4e0d\u4f1a\u6ee1
\u4e00\u5b9a\u8981\u6ce8\u610fWrite\u7684\u7c7b\u578b\uff0c\u9488\u5bf9write hit
Write-through Write-back
\u8fd8\u6709miss\u7684\u5e94\u5bf9
Write-allocate Write-around
\u8ba1\u7b97
"},{"location":"CS/CO/5_/#improving","title":"Improving","text":"
- Miss
- Instruction miss
- Data miss
"},{"location":"CS/CO/5_/#block-placement_1","title":"\u6620\u5c04 Block Placement","text":"
- \u63d0\u9ad8\u547d\u4e2d\u7387
- \u51cf\u5c11 miss \u4ee3\u4ef7
Tag\u8ba1\u7b97
- \u76f8\u8054\u5ea6\u548c\u5bb9\u91cf\u4e0d\u662f\u76f8\u4e92\u72ec\u7acb\u7684
\u4e3b\u5b58\u4e2d\u7684Block Address = Index + Tag
\u524d\u9762\u5df2\u7ecf\u5199\u7684\u6bd4\u8f83\u8be6\u7ec6\u4e86
"},{"location":"CS/CO/5_/#decreasing-miss-penalty-with-multilevel-caches","title":"Decreasing miss penalty with multilevel caches","text":"Add a second level cache:
often primary cache is on the same chip as the processor \u4e00\u7ea7\u7f13\u5b58\u5728\u5904\u7406\u5668\u7684\u82af\u7247\u4e0a
use SRAMs to add another cache above primary memory (DRAM)
miss penalty goes down if data is in 2nd level cache
\u4e00\u7ea7\u548c\u4e8c\u7ea7\u7684cache\u5173\u6ce8\u7684\u76ee\u6807\u4e0d\u540c\uff1a
- \u4e00\u7ea7 hit time\uff0c\u964d\u4f4e\u5931\u6548\u4ee3\u4ef7
- \u4e8c\u7ea7 miss rate \u76f8\u8054\u5ea6\u66f4\u9ad8
\u5982\u679c\u7b2c\u4e00\u7ea7\u7684cache\u5931\u6548\uff0c\u5c31\u4f1a\u8bbf\u95ee\u7b2c\u4e8c\u7ea7\u7684cache\uff0c\u5982\u679c\u6210\u529f\uff0c\u90a3\u4e48\u7b2c\u4e00\u7ea7\u7684penalty\u5c31\u662f\u7b2c\u4e8c\u7ea7\u7684\u8bbf\u95ee\u65f6\u95f4\uff1b... (\u8fd9\u91cc\u6709\u70b9\u7591\u95ee)
\u4f8b\u9898
- Main Memory \u7684\u5931\u6548\u4ee3\u4ef7\uff1a\u8bbf\u95eeMain Memory \u7684\u65f6\u95f4
- \u603bCPI = \u57fa\u51c6CPI + \u5404\u7ea7\u4ee3\u4ef7 \u6ce8\u610f\u8ba1\u7b97\u7684\u662f\u4ec0\u4e48\u5355\u4f4d
Local/Global miss rate
\u5b9e\u9645\u505a\u9898\u7684\u65f6\u5019,\u6709\u65f6\u5019\u7b97L2-cache\u5931\u6548\u7684CPI\u9700\u8981\u5728\u7b2c\u4e00\u7ea7\u5931\u6548\u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u8ba1\u7b97,\u90a3\u65f6\u5019\u7b2c\u4e8c\u7ea7\u7684miss rate\u5b9e\u9645\u4e0a\u5c31\u662flocal miss rate
"},{"location":"CS/CO/5_/#virtual-memory","title":"Virtual Memory","text":"Main Memory act as a \u201cCache\u201d for the secondary storage.
Translation of a program\u2019s address space to physical address
Motivation:
Efficient and safe sharing of memory among multiple programs.\uff08\u591a\u4e2aVa\u6620\u5c04\u5230\u540c\u4e00\u4e2aPa\uff09
Remove the programming burdens of a small, limited amount of main memory.
Larger number of virtual pages than physical pages \u73b0\u5982\u4eca\u4e0d\u518d\u662f\u8fd9\u6837
"},{"location":"CS/CO/5_/#page-faults","title":"Page faults | \u7f3a\u9875","text":"
- \u4e2a\u4eba\u8bbe\u5907\u4e2d\uff0c\u901a\u5e38\u662fDRAM\u548c\u95ea\u5b58\u5145\u5f53\u4e24\u7ea7\u5b58\u50a8\u5c42\u6b21\u7ed3\u6784
- illusion of having more physical memory
- program relocation
- protection
The data is not in memory, retrieve it from disk
"},{"location":"CS/CO/5_/#page-table","title":"Page Table | \u9875\u8868","text":"
- huge miss penalty, thus pages should be fairly large (e.g., 4KB)
- reducing page faults is important (LRU is worth the price)
- can handle the faults in software instead of hardware \u901a\u8fc7\u8f6f\u4ef6\u89e3\u51b3\u7f3a\u9875\u95ee\u9898 Cache\u662f\u786c\u4ef6
- using write-through is too expensive so we use write back \u540c\u65f6\u5199\u5230\u786c\u76d8\u548c\u4e3b\u5b58\u4ee3\u4ef7\u592a\u5927
Page Table \u5305\u542b\u4e86\u6240\u6709\u7684\u5bf9\u5e94\u5173\u7cfb,\u4e0d\u9700\u8981Tag
- Page offset \u8ba1\u7b97\uff1a\u7531\u6574\u4e2aPage size\u51b3\u5b9a\uff0c = log(Page Size)
\u9875\u8868\u6307\u9488 Page Table Register
- \u5728Memory\u4e2d\u5b58\u50a8 indexed by the virtual page number
- Each Entry in the table contains the physical page number for that virtual pages if the page is current in memory, \u5373\u4f7f\u4e0d\u5728Main Memory\u4e2d,\u4e5f\u4f1a\u4fdd\u7559\u4e00\u4e2a\u7269\u7406\u5730\u5740(In Disk)
- Page table, Program counter and the page table register, specifies the state of the program. Each process has one page table. \u5982\u679c\u8f6c\u6362\u8fdb\u7a0b\uff0c\u8981\u4fdd\u5b58\u5f53\u524d\u8fdb\u7a0b\u7684\u72b6\u6001 \u5305\u62ec \u9875\u8868\u3001\u7a0b\u5e8f\u8ba1\u6570\u5668\u3001\u5bc4\u5b58\u5668
- \u64cd\u4f5c\u7cfb\u7edf\u53ea\u5206\u914d\u7269\u7406\u5185\u5b58\u5730\u5740\uff0c\u4e0d\u4fdd\u5b58\u9875\u8868\u3002
- Each program has its own page table \u6bcf\u4e00\u4e2a\u8fdb\u7a0b\u6709\u81ea\u5df1\u7684\u9875\u8868\u3002
Size
- Virtual Address - Page Offset = #bits(Virtual Page Number)
\u64cd\u4f5c\u7cfb\u7edf OS
- When the OS creates a process, it usually creates the space on disk for all the pages of a process.
- When a page fault occurs, the OS will be given control through exception mechanism.
- The OS will find the page in the disk by the page table.
- the OS will bring the requested page into main memory. If all the pages in main memory are in use, the OS will use LRU strategy to choose a page to replace
Virtual Address
virtual page number
Page offset
Write
"},{"location":"CS/CO/5_/#tlb","title":"TLB","text":"
use write-back strategy. To do so, the machines need add a dirty bit to the entry of page table.
The dirty bit is set when a page is first written. If the dirty bit of a page is set, the page must be written back to disk before being replaced.
\u76f8\u5f53\u4e8ePage Table\u7684\u4e00\u4e2acache
- Without a TLB, almost every memory access would require two accesses to RAM: An access to the page table, followed by an access to the requested data.
\u4f7f\u7528Page Table\u4e2d\u7684Valid\u6807\u8bb0\u662f\u5426\u5728\u4e3b\u5b58\u4e2d
TLB\u4e00\u822c\u91c7\u7528\u5168\u76f8\u8054
- \u786c\u4ef6/\u8f6f\u4ef6\u5904\u7406\u5931\u6548\uff0c\u5927\u591a\u6570MIPS\u4f7f\u7528\u8f6f\u4ef6
Combination of Miss
"},{"location":"CS/CO/5_/#_1","title":"\u4f8b\u9898","text":"Note
\u5927\u90e8\u5206\u5730\u5740\u90fd\u662f\u4ece00\u5f00\u59cb\u7684\uff0c\u522b\u5fd8\u4e860\u7684\u5730\u5740\u3002
"},{"location":"CS/CO/5_/#write-back-through","title":"Write back / through\u6982\u5ff5","text":"
- \u8ba1\u7b97
- cache
- cache\u7684size
- \u591a\u91cdcache\u7684performance measure
- Virtual Memory
- Page Table\u3001TLB \u662f\u5982\u4f55work\u7684\uff0c\u53ef\u80fd\u8981\u7ed9\u51fa\u6d41\u7a0b
- Page Table \u7684size
Answer
- If all blocks in the higher level cache are also present in the lower level cache, then the lower level cache is said to be inclusive of the higher level cache.
- If the lower level cache contains only blocks that are not present in the higher level cache, then the lower level cache is said to be exclusive of the higher level cache.
5.6.2 And the result written to L2, may update it in L2, and then tag it dirty. 5.6.3
"},{"location":"CS/CO/5_/#cache","title":"Cache \u8ba1\u7b97","text":""},{"location":"CS/CO/5_/#tlb_1","title":"TLB","text":"
instruction access, data access
\\(\\text{Total CPI = Base + Instruction miss + Data miss}\\)"},{"location":"CS/CO/5_/#_2","title":"\u66ff\u6362\u7b56\u7565","text":"
- TLB \u4e2d\u7684 Tag \u3001Index\uff08\u5f53\u7ec4\u76f8\u8054\uff09
two-way set associative cache with four one-word blocks
\u4e24\u7ec4
\u6bcf\u7ec4\u4e24\u4e2ablock
"},{"location":"CS/CO/5_/#408","title":"408","text":""},{"location":"CS/CO/6/","title":"IO","text":"
- Page size 4KB => Page Offset = 12
- Virtual Size 4GB = > virtual address 32 bits
- Virtual Page Number 20 bits
- \u6ce8\u610f\u8fdb\u5236
\u7ea6 163 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CS/CO/6/#introduction","title":"Introduction","text":"
- Behavior \u884c\u4e3a
Input (read once), output (write only, cannot read) ,or storage (can be reread and usually rewritten)
- Partner \u4ea4\u4e92\u5bf9\u8c61
Either a human or a machine is at the other end of the I/O device, either feeding data on input or reading data on output. \u4e00\u7aef\u4e00\u5b9a\u662fCPU <= \u6570\u636e\u5fc5\u987b\u4f20\u5230CPU\u5904\u7406
- Data rate
The peak rate at which data can be transferred between the I/O device and the main memory or processor.
"},{"location":"CS/CO/6/#performance","title":"Performance","text":""},{"location":"CS/CO/6/#amdahls-law","title":"Amdahl\u2019s (\u963f\u59c6\u8fbe\u5c14)law","text":""},{"location":"CS/CO/6/#disk-storage-and-dependability","title":"Disk Storage and Dependability","text":""},{"location":"CS/CO/6/#performance_1","title":"Performance","text":""},{"location":"CS/CO/6/#raid","title":"RAID","text":""},{"location":"CS/CO/6/#-survive","title":"- \u53ea\u6709\u6700\u540e\u4e00\u4e2a\u53ef\u4ee5\u5728\u4e24\u4e2a\u9519\u8bef\u53d1\u751f\u7684\u60c5\u51b5\u4e0bsurvive","text":""},{"location":"CS/CO/6/#buses-and-other-connections-between-processors-memory-and-io-devices","title":"Buses and Other Connections between Processors Memory, and I/O Devices","text":""},{"location":"CS/CO/6/#_1","title":"\u8ba1\u7b97","text":"
- Capacity penalty to store redundant info
- Bandwidth penalty to update redundant info
\u540c\u6b65\u5f02\u6b65\u7684BandWidth
"},{"location":"CS/DB/","title":"Index","text":"
- \u5730\u5740\u7ed9Memory
- \u8bfb\u53d6\u6570\u636e
- \u4f20\u8f93\u6570\u636e
\u7ea6 0 \u4e2a\u5b57
"},{"location":"CS/DB/Chapter_1/","title":"1. Interface","text":"\u7ea6 140 \u4e2a\u5b57 30 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
flowchart LR\n0{\u6982\u8ff0}\n0-->1\n1[View Of Data]-->2[Data Abstraction]\n\n\n1-->b[Data Models]\n\n0-->0.1[Schema and instances \u6a21\u5f0f\u4e0e\u5b9e\u4f8b]\n0.1-->\u533a\u5206\n0.1-->0.1.1[Physical Data Independence]\n0-->1.2[Language]\n1.2-->1.2.1[DDL:Data Difinition Language]\n1.2-->1.2.2[DML:Data Manipulation Language]\n1.2.2-->\u58f0\u660e\u5f0f:SQL\n1.2.2-->\u8fc7\u7a0b\u5f0f\n\n0-->4[Database Design]\n4-->4.1[E-R\u6a21\u578b \u5b9e\u4f53-\u8054\u7cfb\u6a21\u578b]\n4-->4.2[\u89c4\u8303\u5316]\n\n0-->3[Database Engine]\n3-->1.8\n3-->3.2[Storage Manager]\n3-->3.3[The Query Processor]\n3.3-->3.3.1[DDL interpreter]\n3.3-->3.3.2[DML compiler]\n3.3-->3.3.3[Query evaluation engine]\n1.8[\u4e8b\u52a1\u7ba1\u7406\u5668]-->1.8.1[\u5e76\u53d1\u63a7\u5236\u7ba1\u7406\u5668]\n1.8-->1.8.2[\u6062\u590d\u7ba1\u7406\u5668]
- Database Management System (DBMS)
A database system is a collection of interrelated data and a set of programs that allow users to access and modify these data.
Characteristics of Databases
\u200b data persistence (\u6570\u636e\u6301\u4e45\u6027)
\u200b convenience in accessing data (\u6570\u636e\u8bbf\u95ee\u4fbf\u5229\u6027)
\u200b data integrity (\u6570\u636e\u5b8c\u6574\u6027)
\u200b concurrency control for multiple user (\u591a\u7528\u6237\u5e76\u53d1\u63a7\u5236)
\u200b failure recovery (\u6545\u969c\u6062\u590d)
\u200b security control (\u5b89\u5168\u63a7\u5236)
file system\u7684\u95ee\u9898
","tags":["class/DB"]},{"location":"CS/DB/Chapter_1/#view-of-data","title":"View Of data","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_1/#language","title":"Language","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_1/#ddl","title":"DDL","text":"Data dictionary contains metadata
","tags":["class/DB"]},{"location":"CS/DB/Chapter_1/#dml","title":"DML","text":"
- \u6570\u636e\u6a21\u5f0f
- \u5b8c\u6574\u6027\u7ea6\u675f
- \u6388\u6743
SQL
A query takes as input several tables (possibly only one) and always returns a single table.
SQL does not support actions such as input from users, output to
displays, or communication over the network.
","tags":["class/DB"]},{"location":"CS/DB/Chapter_12/","title":"Physical Storage","text":"\u7ea6 212 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CS/DB/Chapter_12/#overview","title":"Overview","text":"- \u4e09\u7ea7\u5b58\u50a8 offline storage - optical disk \u5149\u5b66\u5b58\u50a8\u5668 CD - tape disk \u78c1\u5e26 \u8bbf\u95ee\u5fc5\u987b\u4ece\u5934\u5f00\u59cb\uff0c\u987a\u5e8f\u8bbf\u95ee
"},{"location":"CS/DB/Chapter_12/#flash-memory","title":"Flash Memory | \u95ea\u5b58","text":"NOR\u5feb\u95ea
\u53ef\u4ee5\u8bbf\u95ee\u5355\u4e2a\u5b57
\u901f\u5ea6\u53ef\u4ee5\u4e0e\u4e3b\u5b58\u5ab2\u7f8e
NAND\u5feb\u95ea SSD
Reading from NAND flash requires an entire page of data, which is very commonly 4096 bytes, to be fetched from NAND flash into main memory.
\u66f4\u7ecf\u5e38\u7528\u7684
\u95ea\u5b58\u7279\u70b9
"},{"location":"CS/DB/Chapter_12/#magnetic-disk","title":"Magnetic Disk","text":"
- \u5199\u64cd\u4f5c\u6bd4\u8f83\u590d\u6742\uff0c\u4e00\u65e6\u5b8c\u6210\u5199\u64cd\u4f5c\uff0c\u60f3\u8981\u590d\u5199\u5fc5\u987b\u64e6\u9664\u4e4b\u540e\u518d\u5199
- The erase operation must be performed on a group of pages, called an erase block
- \u5bb9\u6613\u635f\u574f Further, there is a limit to how many times a flash page can be erased, typically around 100,000 to 1,000,000 times. Once this limit is reached, errors in storing bits are likely to occur.
- \u901a\u8fc7\u673a\u68b0\u8fd0\u52a8\uff0c\u6bd4\u8f83\u6162
- \u6247\u533a\u662f\u6700\u5c0f\u7684\u8bfb\u5199\u5355\u5143
"},{"location":"CS/DB/Chapter_12/#performance","title":"Performance","text":""},{"location":"CS/DB/Chapter_12/#optimization","title":"Optimization","text":""},{"location":"CS/DB/Chapter_13/","title":"Data Storage Structures","text":"
- \u4e0a\u9762\u7684IOPS\u652f\u6301\u7684\u64cd\u4f5c\u662fRandom\u7684R/W
\u7ea6 932 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"CS/DB/Chapter_13/#file-organization","title":"File Organization","text":"Magnetic disks as well as SSDs are block structured devices, that is, data are read or written in units of a block(\u6570\u636e\u4f20\u8f93\u548c\u5b58\u50a8\u5206\u914d\u7684\u57fa\u672c\u5355\u5143\uff0c\u901a\u5e38\u662f4-8KB). In contrast, databases deal with records, which are usually much smaller than a block (although in some cases records may have attributes that are very large).
"},{"location":"CS/DB/Chapter_13/#fixed-length-records","title":"Fixed Length Records","text":"
- The database is stored as a collection of files.
- Each file is a sequence of records.
- A record is a sequence of fields.
- use freelist
"},{"location":"CS/DB/Chapter_13/#variable-length","title":"Variable Length","text":"\u8981\u89e3\u51b3\u7684\u95ee\u9898
- \u5982\u4f55\u8868\u793a\u4e00\u4e2a\u53d8\u957f\u7684\u5c5e\u6027\uff1f\u5e76\u4e14\u80fd\u591f\u8f7b\u6613\u5730\u83b7\u53d6\uff1f
- \u5982\u4f55\u5728Block\u4e2d\u5b58\u50a8\u53d8\u957f\u7684record\uff1f
- id name dept_name salary(fixed length) - \u5728\u90e8\u5206\u8868\u793a\u65b9\u6cd5\u4e2d\uff0cNull Bitmap\u653e\u5728\u6570\u636e\u5f00\u5934\uff0c\u5e76\u4e14\u53ea\u8981\u7f6e\u4e3a1\u5176\u6570\u636e\u90e8\u5206\u5c31\u4e3a\u7a7a
Slotted page \uff08\u5206\u69fd\u9875\uff09
"},{"location":"CS/DB/Chapter_13/#organization-of-records-in-files","title":"Organization of Records in Files","text":""},{"location":"CS/DB/Chapter_13/#heap","title":"Heap","text":"
- Records usually do not move once allocated
- Important to be able to efficiently find free space within file
Free-space map (\u81ea\u7531\u7a7a\u95f4\u56fe)
"},{"location":"CS/DB/Chapter_13/#sequential-file-organization","title":"Sequential File Organization","text":"
- Free space map written to disk periodically, OK to have wrong (old) values for some entries (will be detected and fixed
"},{"location":"CS/DB/Chapter_13/#multitable-clustering-file-organization","title":"Multitable Clustering File Organization","text":"
- Search key \u6392\u5e8f\u7684\u4f9d\u636e\u3002\u53ef\u4ee5\u662f\u67d0\u4e2a\u5c5e\u6027\u6216\u8005\u5c5e\u6027\u7684\u96c6\u5408\uff0c\u662f\u5426\u662f\u8d85\u7801\u3001\u5019\u8865\u7801\u4e0d\u5f71\u54cd
- Deletion Using the pointer
- Insertion locate the position where the record is to be inserted
- if there is free space insert there(\u8fd9\u91cc\u662ffree_list\uff0c\u4f18\u5148\u8003\u8651free_list\u4e2d\u7684\u5757\uff0c\u5982\u679c\u5176\u4e2d\u6ca1\u6709\u7a7a\u4f59\uff0c\u90a3\u4e48\u518d\u53bboverflow block\u63d2\u5165)
- if no free space, insert the record in an overflow block (\u6ea2\u51fa\u5757)
In either case, pointer chain must be updated
Reorganize \u4f7f\u4e4b\u91cd\u65b0\u7269\u7406\u6709\u5e8f\u5b58\u50a8. \u7531\u4e8e\u4e0a\u9762\u7684\u6ea2\u51fa\u5757\u6a21\u5f0f\uff0c\u5bfc\u81f4\u7269\u7406\u5b58\u50a8\u4e0d\u4e00\u5b9a\u6309\u7167\u6307\u9488\u987a\u5e8f\uff0c\u8fdb\u800c\u964d\u4f4e\u8bbf\u95ee\u6548\u7387
- \u5bf9\u76f8\u540c\u7684\u4fe1\u606f\u805a\u7c7b\uff1b\u628a\u4e0d\u540c\u7684\u5173\u7cfb\u653e\u5728\u540c\u4e00\u4e2a\u8868\u4e2d
- Results in variable size records
- Can add pointer chains to link records of a particular relation
"},{"location":"CS/DB/Chapter_13/#partitioning","title":"Partitioning","text":""},{"location":"CS/DB/Chapter_13/#data-dictionary-storage","title":"Data Dictionary Storage","text":"
- \u628a\u4e00\u4e2adepartment\u7684instructor\u805a\u96c6\u5728\u4e00\u8d77
"},{"location":"CS/DB/Chapter_13/#buffer","title":"Buffer","text":"
- \u6709\u52a9\u4e8e\u8bed\u4e49\u68c0\u67e5
- \u4f7f\u7528
metadata
\u7684\u60f3\u6cd5
- Blocks are units of both storage allocation and data transfer \u5185\u5b58\u7533\u8bf7\u3001\u6570\u636e\u4f20\u8f93
- Buffer (\u7f13\u51b2\u533a) \u2013 portion of main memory available to store copies of disk blocks\uff0c\u4f46\u662f\u5728\u78c1\u76d8\u4e0a\u7684\u62f7\u8d1d\u53ef\u80fd\u65e7\u4e8e\u7f13\u51b2\u533a\u7684
- Buffer manager (\u7f13\u51b2\u533a\u7ba1\u7406\u5668) \u2013 subsystem responsible for allocating buffer space in main memory.
\u6d41\u7a0b
- System Call
- in the buffer Return
- not in the buffer
- buffer is full
- The replaced block is updated -> write back to disk
- not , deleted the replaced page, and replaced
- buffer is not full
- Read The Page and return
pinned Block
memory block that is not allowed to be written back to disk - Pin done before reading/writing data from a block \u5728\u7533\u8bf7\u6570\u636e/\u5199\u6570\u636e\u4e4b\u524d\u201cPin\u201d - Unpin done when read /write is complete - Multiple concurrent pin/unpin operations possible - Keep a pin count, buffer block can be evicted only if pin count = 0
Shared and exclusive locks on buffer | \u5171\u4eab\u9501\u548c\u6392\u4ed6\u9501
Needed to prevent concurrent operations from reading page contents as they are moved/reorganized, and to ensure only one move/reorganize at a time
"},{"location":"CS/DB/Chapter_13/#_1","title":"\u7f13\u51b2\u533a\u66ff\u6362\u7b56\u7565","text":""},{"location":"CS/DB/Chapter_13/#lru","title":"LRU","text":"
- \u5171\u4eab\u9501\u548c\u6392\u4ed6\u9501\u4e0d\u80fd\u5e76\u884c
- \u540c\u4e00\u65f6\u95f4\u6700\u591a\u4e00\u4e2a\u8fdb\u7a0b\u5177\u6709\u6392\u4ed6\u9501
\u4ecebuffer\u4e2d\u53bb\u6389\u6700\u8fd1\u6700\u5c11\u7528\u5230\u7684
example
\u5bf9\u4e8e\u8981\u201c\u6254\u6389\u201d\u7684\u6570\u636e\uff0c\u8981\u5224\u65ad\u662f\u5426\u5df2\u7ecf\u4fee\u6539\u8fc7\uff08buffer\u4e2d\u7684\u6570\u636e\u53ef\u80fd\u662f\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u4fee\u6539\u540e\u7684\u6570\u636e\uff09\u3002
\u200b
Clock: An approximation of LRU\u4ecb\u7ecd
"},{"location":"CS/DB/Chapter_13/#others","title":"others","text":"Toss-immdiate \u7acb\u5373\u4e22\u5f03
Most recently used (MRU) strategy
\u64cd\u4f5c\u7cfb\u7edf/\u7f13\u5b58\u7ba1\u7406\u5668\u53ef\u80fd\u4f1a\u5bf9\u5199\u64cd\u4f5c\u8fdb\u884c\u91cd\u65b0\u6392\u5e8f
Operating system or buffer manager may reorder writes
"},{"location":"CS/DB/Chapter_13/#_2","title":"\u65e5\u5fd7","text":""},{"location":"CS/DB/Chapter_13/#column-oriented-storage","title":"Column-Oriented Storage","text":"
- Can lead to corruption of data structures on disk
- E.g., linked list of blocks with missing block on disk
- File systems perform consistency check to detect such situations \u6216\u8005\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u4ecb\u7ecd\u7684\u65e5\u5fd7
Store each attribute of a relation separately
- \u6700\u7b80\u5355\u7684\u60c5\u51b5\u662f\u6bcf\u4e00\u79cd\u5c5e\u6027\u5206\u6587\u4ef6\u5b58\u653e Further, each file is compressed, to reduce its size.
\u4f18\u70b9 Analysis Queries \u2014\u2014 \u53ef\u80fd\u8bbf\u95ee\u5f88\u591arows\uff0c\u4f46\u662f\u53ea\u53d6\u5176\u4e2d\u90e8\u5206\u5c5e\u6027
- \u63d0\u9ad8CPU\u6548\u7387
- \u51cf\u5c11I/O
- \u51cf\u5c11Disk\u8bbf\u95ee\u65f6\u95f4
- \u5411\u91cf\u8bbf\u95ee\u65b9\u4fbf
- \u5bf9\u4e8eDecision Support\u66f4\u52a0\u9ad8\u6548
\u7f3a\u70b9
Traditional row-oriented representation preferable for transaction processing
"},{"location":"CS/DB/Chapter_14/","title":"Indexing","text":"\u7ea6 1776 \u4e2a\u5b57 5 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 9 \u5206\u949f
"},{"location":"CS/DB/Chapter_14/#basic","title":"Basic","text":"Evaluation
"},{"location":"CS/DB/Chapter_14/#ordered-indices","title":"Ordered Indices","text":"
Access Type
- Point query: records with a specified value in the attribute
- Range query: records with an attribute value falling in a specified range of values.
Access time
- insertion time \u5305\u62ec\u627e\u5230\u63d2\u5165\u4f4d\u7f6e\u3001\u66f4\u65b0\u7d22\u5f15\u7ed3\u6784\u7684\u65f6\u95f4
- Deletion time \u5305\u62ec\u627e\u5230\u5220\u9664\u9879\u3001\u66f4\u65b0\u7d22\u5f15\u7ed3\u6784\u7684\u65f6\u95f4
- Space overhead \u7d22\u5f15\u7ed3\u6784\u6240\u5360\u636e\u7684\u989d\u5916\u7a7a\u95f4
"},{"location":"CS/DB/Chapter_14/#primary-index-clustering-index","title":"Primary Index | \u4e3b\u7d22\u5f15 || Clustering index | \u805a\u96c6\u7d22\u5f15","text":"
- \u5f53\u53d1\u751f\u63d2\u5165/\u5220\u9664
- \u6240\u6709\u53d7\u5230\u5f71\u54cd\u7684index\u90fd\u8981\u6539\u53d8
- update
- \u53d7\u5f71\u54cd\u5219\u53d8
"},{"location":"CS/DB/Chapter_14/#dense-index","title":"Dense Index | \u7a20\u5bc6\u7d22\u5f15","text":"
- In a sequentially ordered file, the index whose search key specifies the sequential order of the file.
\u53ef\u4ee5\u662f\u805a\u96c6\u6216\u8005\u975e\u805a\u96c6
"},{"location":"CS/DB/Chapter_14/#sparse-index","title":"Sparse Index | \u7a00\u758f\u7d22\u5f15","text":"
- \u5de6\u4fa7\u7684\u90e8\u5206\u90fd\u662f
index entry
\uff0c\u5305\u62ec\u4e00\u4e2a\u7d22\u5f15\u952e\u503c\u548c\u6307\u9488- \u5b83\u7684
pointer
\u6709\u4e09\u79cd\u60c5\u51b5\uff08\u7d22\u5f15\u662f\u5426\u662fkey
\uff09
- \u76f4\u63a5\u6307\u5411\u5bf9\u5e94search key\u7684\u8bb0\u5f55
- \u6307\u5411\u6240\u6709\u5177\u6709\u76f8\u540csearch key\u7684\u6307\u9488\uff0c\u76f8\u5f53\u4e8e\u662f\u4e0a\u56fe\u4e2d\u7684\u6307\u9488\u6307\u5411\u4e00\u4e2abucket\uff0c\u8fd9\u4e2abucket\u542b\u6709\u6240\u6709\u6307\u5411\u76f8\u5e94\u8bb0\u5f55\u7684\u6307\u9488
- \u6307\u5411\u6240\u6709\u5177\u6709\u76f8\u540csearch key\u7684\u7b2c\u4e00\u6761\u8bb0\u5f55\u7684\u6307\u9488\uff0c\u5982\u4e0a\u56fe
\u5fc5\u987b\u662f\u805a\u96c6\u7d22\u5f15\uff0c\u6309\u987a\u5e8f\u5b58\u653e
"},{"location":"CS/DB/Chapter_14/#secondary-index-non-clustering-index","title":"Secondary Index | Non clustering Index","text":"
- Contains index records for only some search-key values.
\u6587\u4ef6\u7684\u7d22\u5f15\u8ddf\u7269\u7406\u5b58\u50a8\u987a\u5e8f\u4e0d\u4e00\u81f4
"},{"location":"CS/DB/Chapter_14/#multi-level-index","title":"Multi Level index","text":"
index entry
Index record points to a bucket that contains pointers to all the actual records with that particular search-key value.- \u5fc5\u987b\u662f\u7a20\u5bc6\u7d22\u5f15\uff0c\u7269\u7406\u5b58\u50a8\u5fc5\u987b\u662f\u6709\u5e8f\u7684
- \u5bf9\u5176\u8fdb\u884c\u987a\u5e8fScan\u4ee3\u4ef7\u5f88\u9ad8
"},{"location":"CS/DB/Chapter_14/#others","title":"Others","text":"
- outer index \u2013 a sparse index of the basic index
- inner index \u2013 the basic index file
- Indices at all levels must be updated on insertion or deletion from the file
Composite search key
"},{"location":"CS/DB/Chapter_14/#operation","title":"Operation","text":""},{"location":"CS/DB/Chapter_14/#b-tree-index","title":"B+ Tree Index","text":"Paths: all leaf in same level
**Root: **
- non-Leaf. has at least 2 children.
- Leaf. If the root is a leaf (that is, there are no other nodes in the tree), it can have between 0 and (n\u20131) values.
Inner node: Each node that is not a root or a leaf has between \\(\\lceil n/2\\rceil\\) and n children.
Leaf: A leaf node has between \\(\\lceil (n\u20131)/2\\rceil\\)and n\u20131 values
\u603b\u4f53\u7ed3\u6784\u90fd\u662f\u4e0a\u9762\u7684
Leaf Node
\\(P_i\u6307\u5411\u8bb0\u5f55,P_n\u6307\u5411\u4e0b\u4e00\u4e2a\u53f6\u5b50\\)
Non Leaf Node
\\(P_i\u90fd\u6307\u5411\u5b83\u7684Children\\)
trick
Block_id entry Block_id + \u7edd\u5bf9\u504f\u79fb\u7684\u8868\u793a\u65b9\u6cd5\u5e76\u4e0d\u5229\u4e8e\u4f4d\u7f6e\u7684\u8bb0\u5f55
\u652f\u6301\u67e5\u8be2\u65b9\u5f0f Point Query \u548c Range Query \u548c Scanning
\u56e0\u4e3a\u53f6\u5b50\u8282\u70b9\u542b\u6709\u6307\u5411\u5144\u5f1f\u7684\u6307\u9488\uff1b\u53ef\u80fd\u542b\u6709\u4e00\u4e2aScanning pointer\uff0c\u6307\u5411\u7b2c\u4e00\u4e2aLeaf
"},{"location":"CS/DB/Chapter_14/#query","title":"Query","text":"\u6bcf\u4e00\u4e2a\u8282\u70b9\u90fd\u5bf9\u5e94\u4e00\u4e2a\u78c1\u76d8\u7684\u5757 block, \u628a\u8fd9\u4e00\u5757\u8bfb\u5165\u5185\u5b58\uff0c\u4e4b\u540e\u53ef\u4ee5\u83b7\u5f97\u8fd9\u4e2a\u8282\u70b9. A node is generally the same size as a disk block, typically 4 kilobytes
info
\u5728DB\u4e2d\u7684B+ Tree\u4e0b\uff0cinner node\u7684\u503c\u4e0d\u4e00\u5b9a\u5728leaf\u51fa\u73b0\uff0c\u4e2d\u95f4\u7ed3\u70b9\u7684\u503c\u53ea\u8d77\u5230\u7d22\u5f15\u7684\u4f5c\u7528\u3002\uff08\u8fd9\u79cd\u60c5\u51b5\u662f\u5728Deletion\u4e0b\u53d1\u751f\uff09
"},{"location":"CS/DB/Chapter_14/#insert-delete","title":"Insert / Delete","text":"Deletion
- Gold\u5220\u9664\u540e\u4ecd\u7136\u5728root\u7684\u7d22\u5f15\u4e2d
\u4f18\u5148\u8003\u8651\u5408\u5e76\u8282\u70b9\uff0c\u53ea\u6709\u5f53\u5408\u5e76\u540e\u7684\u5927\u4e8e\u80fd\u5bb9\u7eb3\u91cf\uff0c\u624d\u4f1a\u53bb\u8003\u8651\u91cd\u65b0\u5206\u914d\u6307\u9488
"},{"location":"CS/DB/Chapter_14/#_1","title":"\u8ba1\u7b97","text":"height & size \u4f30\u8ba1
height
$$ \\ \u6700\u5927\u9ad8\u5ea6\uff1a(\u4e0d\u8003\u8651\u6839\u7684\"\u4e8c\u53c9\"\uff0c\u53ea\u9700\u8981\u8003\u8651\u6bcf\u4e00\u5c42\u6700\u5c11\u6709\u591a\u5c11\u4e2avalue)\\ \\ Height\\leq \\lceil log_{\\lceil \\frac{n}{2}\\rceil}K \\rceil $$
Records per block \u6bcf\u4e00\u4e2anode\u662f\u4e00\u4e2a\u5757\uff0c\u4e00\u4e2a\u5757\u4e00\u822c\u662f4K\u5927\u5c0f(Block Size)\uff0cBlock Size / Data Size Blocks for storing Records size / Records per block
\u8981\u8ba1\u7b97
fan-out
\uff0c\u4e5f\u5c31\u662f\u8fd9\u4e2aB+ Tree\u7684\u5206\u652f\uff0c\u5bf9\u4e8e\u4e00\u4e2aM\u53c9\u7684B+ Tree\uff0c\u5b83\u6709 M+1 \u4e2a\u6307\u9488\uff0cM\u4e2a\u7d22\u5f15\u503c\u3002\uff08\u6bcf\u4e00\u4e2a\u8282\u70b9\u90fd\u662f\u4e00\u4e2aPage/Block\uff09 \u4e8e\u662f\uff0c\u8ba1\u7b97\u65b9\u5f0f\u5c31\u662f (\\(\\frac{Block Size - 4}{index\\ size+\\ pointer\\ size}\\) +1 )\u5c42\u6570
\u6839\u8282\u70b9\u7684level\u4e3a1
- Level 2 \uff1amin = 2 * leaf value , max = \u5168\u6ee1
- Level 3 \uff1amin = 2 * Inner value * leaf value
- Level K(K > 1) :
$$ min = 2 (Inner Pointer)_{min}^{K-2}(Leaf value){min}\\ max = (Inner Pointer) $$}^{K-1}*(Leaf value)_{max
size
"},{"location":"CS/DB/Chapter_14/#extension","title":"Extension","text":""},{"location":"CS/DB/Chapter_14/#_2","title":"\u6587\u4ef6\u7d22\u5f15","text":"
leaf\u7684\u90e8\u5206\uff0c\u8981\u5b58\u653e1000000\u4e2a(N)\u6570\u636e\uff0c\u90a3\u4e48\u9700\u8981N / leaf values\u4e2a\u53f6\u5b50\u8282\u70b9
\u6700\u5c11\u7684nodes leaf : 1000000 / 186
- \u6700\u591a\u7684nodes
"},{"location":"CS/DB/Chapter_14/#_3","title":"\u8f85\u52a9\u7d22\u5f15","text":"
- \u5b58\u653e\u7684\u662f\u8bb0\u5f55\u672c\u8eab\u800c\u4e0d\u662f\u6307\u5411\u8bb0\u5f55\u7684\u6307\u9488
\u5728\u6539\u53d8\u7d22\u5f15\u7684\u65f6\u5019\uff0c\u5373\u4f7f\u6ca1\u6709\u76f4\u63a5\u4f5c\u7528\u4e8e\u8fd9\u6761\u8bb0\u5f55\uff0c\u4f46\u4ed6\u7684\u7d22\u5f15\u4e5f\u53ef\u80fd\u53d1\u751f\u53d8\u5316\uff0c\u8fd9\u5bfc\u81f4\u7ef4\u62a4\u7684\u4ee3\u4ef7\u76f8\u5f53\u9ad8
Solution: use search key of B+-tree file organization instead of record pointer in secondary index
"},{"location":"CS/DB/Chapter_14/#_4","title":"\u5b57\u7b26\u4e32","text":"
- Add record-id if B+-tree file organization search key is non-unique
- Extra traversal of file organization to locate record
- Higher cost for queries, but node splits are cheap
\u4f7f\u7528 \u524d\u7f00\u538b\u7f29 | prefix encoding \u6765\u5bf9\u53d8\u957f\u7684\u6570\u636e\u8fdb\u884c\u7d22\u5f15
"},{"location":"CS/DB/Chapter_14/#bulk-loading-and-bottom-up-build","title":"\u6279\u91cf\u52a0\u8f7d\u4e0e\u6784\u5efa | Bulk Loading and Bottom-Up Build","text":"Algorithm 1
- sort entries first
- insert in sorted order
- much improved I/O performance, but most leaf nodes half full
Algorithm 2 | Bottom-up B+-tree construction
"},{"location":"CS/DB/Chapter_14/#hash","title":"Hash | \u6563\u5217","text":"
- sort entries
- create tree layer-by-layer, starting with leaf level
A bucket is a unit of storage containing one or more entries (a buckets typically a disk block).
- we obtain the bucket of an entry from its search-key value using a hash function
Hash function h is a function from the set of all search-key values K to the set of all bucket addresses B.
"},{"location":"CS/DB/Chapter_14/#static-hashing","title":"Static hashing","text":"Bucket Overflow
\u4f7f\u7528 overflow bucket \u5904\u7406\uff0c\u5f62\u6210\u6ea2\u51fa\u94fe
\u95ed\u6563\u5217
\u5f00\u6563\u5217
\u63d2\u5165\u5230\u5176\u4ed6bucket\u4e2d\uff0c\u6bd4\u5982\u4f7f\u7528\u7ebf\u6027\u63a2\u6d4b\u7b49\u65b9\u5f0f
"},{"location":"CS/DB/Chapter_14/#dynamic-hashing","title":"Dynamic Hashing","text":""},{"location":"CS/DB/Chapter_14/#multiple-key-access","title":"Multiple-key access","text":"
Periodic rehashing
Linear Hashing
- Extendable Hashing
Use multiple indices for certain types of queries
"},{"location":"CS/DB/Chapter_14/#definition-of-index","title":"Definition of Index","text":"select ID\nfrom instructor\nwhere dept_name = \u201cFinance\u201d and salary = 80000\n
create index takes_pk on takes (ID,course_ID, year, semester, section) \ndrop index takes_pk\n
"},{"location":"CS/DB/Chapter_14/#write-optimized-indices","title":"Write-Optimized Indices","text":"
- Indices on primary key created automatically by all databases
Performance of B+-trees can be poor for write-intensive workloads
- One I/O per leaf, assuming all internal nodes are in memory
With magnetic disks, < 100 inserts per second per disk
With flash memory, one page overwrite per insert
\u95ea\u5b58\u7684update\u4ee3\u4ef7\u6bd4\u8f83\u5927
"},{"location":"CS/DB/Chapter_14/#log-structured-merge-lsm-tree","title":"Log Structured Merge (LSM) Tree","text":"
- Size threshold for \\(\ud835\udc3f_{\ud835\udc56+1}\\) tree is \ud835\udc58 times size threshold for \\(\ud835\udc3f_\ud835\udc56\\) tree \u4e00\u4e2arecord\u5728\u4e00\u4e2a\u8282\u70b9\u6700\u591a\u5199K\u6b21
\u63d2\u5165 - Records inserted first into in-memory tree (\ud835\udc3f0 tree) - When in-memory tree is full, records moved to disk (\ud835\udc3f1 tree) B+-tree constructed using bottom-up build by merging existing \ud835\udc3f1 tree with records from \ud835\udc3f0 tree \u5185\u5b58\u91cc\u7684 B+ \u6811\u5982\u679c\u6ee1\u4e86\uff0c\u5c31\u9a6c\u4e0a\u5199\u5230\u78c1\u76d8\u91cc\u53bb\uff08\u53ef\u4ee5\u8fde\u7eed\u5199\uff09 - When \ud835\udc3f1 tree exceeds some threshold, merge into \\(L_2\\) tree And so on for more levels
\u8fd9\u6837\u6211\u4eec\u628a\u968f\u673a\u5199\u53d8\u4e3a\u4e86\u987a\u5e8f\u5199\u3002\u4f46\u6b64\u65f6\u67e5\u627e\u4e00\u4e2a\u7d22\u5f15\uff0c\u5c31\u8981\u904d\u5386\u6240\u6709 B + Tree
Stepped-merge index
\u5728\u6bcf\u4e00\u7ea7\u4f7f\u7528\u66f4\u591a\u7684B+ Tree \u800c\u4e0d\u662f\u50cf\u4e0a\u9762\u4e00\u6837\u6bcf\u6b21\u4e00\u68f5\u6811\u6ee1\u5c31\u53bbmerge\u5230\u4e0b\u4e00\u5c42
- Variant of LSM tree with multiple trees at each level
- Reduces write cost compared to LSM tree
- But queries are even more expensive
- Bloom filters to avoid lookups in most trees
- Bloom filters to avoid lookups in most trees
\u5220\u9664\u64cd\u4f5c
\u4e0d\u540c\u4e8e\u4e0a\u9762\u7684\u67e5\u627e\u548cinsert\uff0c\u5220\u9664\u901a\u8fc7
deletion entry
\u6765\u5b9e\u73b0Indicates which index entry is to be deleted. The process of inserting a deletion entry is identical to the process of insertinga normal index entry.
"},{"location":"CS/DB/Chapter_14/#buffer-tree","title":"Buffer Tree","text":"
- When trees are merged, if we find a delete entry matching an originalentry, both are dropped.
- When lookups, find both original entry and the delete entry, and mustreturn only those entries that do not have matching delete entry
\u5728\u6bcf\u4e2aInternal\u8282\u70b9\u52a0\u4e00\u4e2aBuffer\u7f13\u51b2
"},{"location":"CS/DB/Chapter_14/#bitmap-indices","title":"Bitmap Indices","text":"
Insert
- \u5148\u653e\u5728Root\u7684\u7f13\u51b2\u533a
- \u6ee1\u4e86\u5f80\u4e0b\u653e
- \u653e\u5728internal\u7f13\u51b2\u533a...
- \u4e00\u76f4\u5230\u53f6\u5b50\u8282\u70b9
Query
- \u5728\u67e5\u627e\u6240\u904d\u5386\u7684\u6bcf\u4e2a\u5185\u90e8\u8282\u70b9\u65f6\uff0c\u90fd\u5fc5\u987b\u68c0\u67e5\u8be5\u8282\u70b9\u7684\u7f13\u51b2\u533a\uff0c\u4ee5\u67e5\u770b\u662f\u5426\u6709\u4e0e\u67e5\u627e\u952e\u5339\u914d\u7684\u8bb0\u5f55\u3002\u662f\u5426\u6709\u4e0e\u67e5\u627e\u952e\u5339\u914d\u7684\u8bb0\u5f55\u3002\u8303\u56f4\u67e5\u627e\u4e0e\u666e\u901a B+-\u6811\u4e2d\u7684\u505a\u6cd5\u4e00\u6837\uff0c\u4f46\u5b83\u4eec\u8fd8\u5fc5\u987b\u68c0\u67e5\u88ab\u8bbf\u95ee\u7684\u53f6\u8282\u70b9\u4e0a\u9762\u7684\u6240\u6709\u5185\u90e8\u8282\u70b9\u7684\u7f13\u51b2\u533a\u3002
Bitmap indices are a special type of index designed for efficient querying on multiple keys not particularly useful for single attribute queries
- Applicable on attributes that take on a relatively small number of distinct values \u6bcf\u4e00\u5217\u4e0d\u540c\u7684\u5c5e\u6027\u503c\u4e0d\u8981\u592a\u591a
"},{"location":"CS/DB/Chapter_15/","title":"\u67e5\u8be2\u5904\u7406","text":"
- \u53ef\u4ee5\u8fdb\u884c\u4ea4\u5e76\u64cd\u4f5c
\u7ea6 1060 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"CS/DB/Chapter_15/#basic-step","title":"Basic Step","text":"
Parsing and Translation
- Translate the query into its internal form. This is then translated into relational algebra.
Parser checks syntax, verifies relations \u89e3\u6790\u5668
Optimization
- Amongst all equivalent evaluation plans choose the one with lowest cost.
Evaluation
- The query-execution engine takes a query-evaluation plan, executes that plan, and returns the answers to the query.
An evaluation plan defines exactly what algorithm is used for each operation, and how the execution of the operations is coordinated.
"},{"location":"CS/DB/Chapter_15/#measures-of-query-cost","title":"Measures of Query Cost","text":"
- Resource Consumption
"},{"location":"CS/DB/Chapter_15/#selection-operation-external-sort-merge","title":"Selection Operation | External Sort-Merge","text":"
- We often use worst case estimates, assuming only the minimum amount of memory needed for the operation is available
https://note.hobbitqia.cc/DB/db11/#selection-operation
"},{"location":"CS/DB/Chapter_15/#sorting","title":"Sorting","text":"\u6570\u636e\u5e93\u4e3b\u8981\u8003\u8651\u9700\u8981\u5916\u6392\u7684\u60c5\u51b5
We may build an index on the relation, and then use the index to read the relation in sorted order. May lead to one disk block access for each tuple.
"},{"location":"CS/DB/Chapter_15/#external-sort-merge","title":"External Sort-Merge","text":"
- Build Runs \u5f97\u5230 \\(\\lceil{\\frac{B_r}{M}}\\rceil\\) Runs \u9700\u8981\\(2B_r\\)\u6b21Transfer \uff0c\\(2\\lceil{\\frac{B_r}{M}}\\rceil\\)\u6b21Seek\uff08\u8fd9\u91cc\u5e94\u8be5\u662f\u7269\u7406\u5b58\u50a8\u4e34\u8fd1
- Merge Runs \u5f52\u5e76\u6b21\u6570 \\(\\lceil{\\log_{\\lfloor{\\frac{M}{B_b}-1}\\rfloor}{B_r/M}}\\rceil\\) \u9664\u4e86\u6700\u540e\u4e00\u6b21\u5f52\u5e76\uff0c\u5176\u4f59\u6bcf\u6b21\u90fd\u662f\\(2B_r\\)\u6b21Transfer Seek\uff1a\u6bcf\u4e00\u6b21\\(2\\lceil{\\frac{B_r}{B_b}}\\rceil\\)\u200b
- \\(B_b\\)\u628a\\(B_b\\)\u4e2a\u7f13\u51b2\u5757\u5206\u914d\u7ed9 \u6bcf\u4e2a \u5f52\u5e76\u6bb5
Cost of Transfer $$ 2 B_r \\lceil{\\log_{\\lfloor{\\frac{M}{B_b}-1}\\rfloor}{B_r/M}}\\rceil + 2B_r-B_r $$ Cost of Seek $$ 2\\lceil{\\frac{B_r}{B_b}}\\rceil\\lceil{\\log_{\\lfloor{\\frac{M}{B_b}-1}\\rfloor}{B_r/M}}\\rceil+2\\lceil{\\frac{B_r}{M}}\\rceil - \\lceil{\\frac{B_r}{B_b}}\\rceil\\ =\\lceil{\\frac{B_r}{B_b}}\\rceil(Merge-1)+build Seek $$
"},{"location":"CS/DB/Chapter_15/#join-operation","title":"Join Operation","text":""},{"location":"CS/DB/Chapter_15/#nested-loop-join","title":"Nested-loop join","text":"cost
\u8fd9\u91cc\u6709\u4e00\u4e2a\u9690\u542b\u7684\u5047\u8bbe\uff1a\u5185\u5c42\u7684\u6570\u636e\u53ef\u4ee5\u901a\u8fc7\u4e00\u6b21seek\u83b7\u53d6\u5168\u90e8
"},{"location":"CS/DB/Chapter_15/#block-nested-loop-join","title":"Block nested-loop join","text":"
- Transfer
- Seek \u5916\u5c42\u9700\u8981seek \\(b_r\\) times\uff0c\u5185\u5c42\u5176\u5b9e\u662f\\(n_r*b_s\\)
\u5c3d\u53ef\u80fd\u628a\u5c0f\u7684\u653e\u5728\u5916\u5c42
Improvement
\u5bf9\u5916\u5c42\u4f7f\u7528\u66f4\u591a\u7684\u7f13\u51b2\u5757
"},{"location":"CS/DB/Chapter_15/#indexed-nested-loop-join","title":"Indexed nested-loop join","text":"\u2022 Where c is the cost of traversing index and fetching all matching s tuples for one tuple of r
\u2022 c can be estimated as cost of a single selection on s using the join condition.
"},{"location":"CS/DB/Chapter_15/#merge-join","title":"Merge-Join","text":"
- Can be used only for equi-joins and natural joins
- \u76f4\u63a5\u5bf9\u8f85\u52a9\u7d22\u5f15\u7684\u503c\u6392\u5e8f\u4ee3\u4ef7\u592a\u5927\u4e86
- \u5148\u628a\u6709\u5e8f\u5173\u7cfb\u548cB+ Tree\u7684\u53f6\u5b50\u8fdb\u884cMerge
- \u6309\u7167\u7269\u7406\u5730\u5740\u5bf9\u4e0a\u8ff0\u7ed3\u679c\u6392\u5e8f\uff0c\u4f7f\u4e4b\u80fd\u591f\u66f4\u52a0\u65b9\u4fbf\u5730\u8fdb\u884c\u7269\u7406\u8bbf\u95ee
- \u8fdb\u884cMerge\uff0c\u7528\u771f\u5b9e\u7269\u7406\u5730\u5740\u66ff\u6362
"},{"location":"CS/DB/Chapter_15/#hash-join","title":"Hash-join","text":"
- \u6309\u7167\u5730\u5740\u6392\u5e8f\uff0c\u4f7f\u5f97\u5730\u5740\u8fde\u7eed\uff0c\u65b9\u4fbf\u4ece\u4e00\u4e2aBlock\u4e2d\u53d6\u51fa
- \u7528\u540c\u4e00\u4e2a\u54c8\u5e0c\u51fd\u6570\u8fdb\u884c\u5212\u5206 \u5206\u522b\u8fdb\u884c\u4e00\u6b21\u5b8c\u6574\u7684\u8bfb\u5165\u5199\u56de
- \u4e3a\u6bcf\u4e2a\\(S_i\\)\u200b\u6784\u9020\u4e00\u4e2a\u6563\u5217\u7d22\u5f15\uff08\u5185\u5b58\u4e2d\uff09\uff0c\u8fd9\u4e2a\u6563\u5217\u51fd\u6570\u5fc5\u987b\u4e0e\u4e4b\u524d\u7684\u4e0d\u540c
- \u5c0f\u7684\u8868\u8981\u80fd\u653e\u5728\u5185\u5b58\u4e2d
- \u7528\\(R_i\\)\u4e2d\u7684\u6bcf\u4e00\u4e2atuple\u53bb\u63a2\u67e5
"},{"location":"CS/DB/Chapter_15/#recursive-partitioning","title":"\u9012\u5f52\u5212\u5206 | recursive partitioning","text":"
- \u8fd9\u91cc\u4f7f\u7528\u7684\u6563\u5217\u51fd\u6570\u5fc5\u987b\u4e0e\u4e4b\u524d\u4f7f\u7528\u7684H\u4e0d\u540c
\u6ca1\u6709\u8db3\u591f\u7684\u7f13\u51b2\u5757\u652f\u6491\u4e00\u6b21\u5b8c\u6210\u6240\u6709\u7684partition
\u591a\u6b21\u4ea7\u751f\u66f4\u5c0f\u7684\u5212\u5206\u3002\u6bcf\u4e00\u8d9f\u7684\u6563\u5217\u51fd\u6570\u90fd\u4e0d\u540c\uff0c\u4e0d\u65ad\u91cd\u590d\u8f93\u5165\u7684\u5206\u88c2\u8fc7\u7a0b\u76f4\u5230\u6784\u9020\u7528\u8f93\u5165\u5173\u7cfb\u7684\u6bcf\u4e2a\u5212\u5206\u90fd\u80fd\u88ab\u5185\u5b58\u5bb9\u7eb3\u4e3a\u6b62 $$ M>b_s/M+1\\ \\text{\u7f13\u51b2\u533a\u5927\u5c0f\u5927\u4e8e\u6bcf\u4e2apartition\u7684\u5927\u5c0f + \u4e00\u4e2a\u8f93\u51fa\u5757}\\ M>\\sqrt {b_s} $$
"},{"location":"CS/DB/Chapter_15/#hash-table-overflow","title":"\u6ea2\u51fa\u5904\u7406 | hash-table overflow","text":"\u6563\u5217\u7d22\u5f15\u5927\u4e8e\u4e3b\u5b58
skewed \u5212\u5206\u4e0d\u5747\u5300 if some partitions have significantly more tuples than some others
fudge factor \u907f\u8ba9\u56e0\u5b50 \u4f7f\u5f97\u6bcf\u4e2a\u5212\u5206\u7684\u671f\u671b\u5927\u5c0f\u6bd4\u5185\u5b58\u5bb9\u91cf\u7565\u5c0f\uff0c\u589e\u52a0\u7684\u5212\u5206\u4e2a\u6570\u79f0\u4e4b\u4e3a\u907f\u8ba9\u94f6\u5b50
"},{"location":"CS/DB/Chapter_15/#cost","title":"cost","text":"
\u6ea2\u51fa\u5206\u89e3 | resolution \u6784\u9020\u9636\u6bb5\uff0c\\(s_i\\)\u200b\u592a\u5927\uff0c\u7528\u53e6\u4e00\u4e2ahash func\u8fdb\u884c\u8fdb\u4e00\u6b65\u5212\u5206\uff1b\u540c\u65f6\\(r_i\\)\u5fc5\u987b\u8fdb\u884c\u540c\u6837\u7684\u5212\u5206
\u6ea2\u51fa\u907f\u514d | avoidance \u5728\u6784\u9020\u9636\u6bb5\u8fdb\u884c\u8c28\u614e\u7684\u5212\u5206 partition build relation into many partitions, then combine them
example
"},{"location":"CS/DB/Chapter_15/#hybrid-hash-join","title":"\u6df7\u5408\u6563\u5217\u8fde\u63a5 | Hybrid hash-join","text":"\u628a\u4e00\u4e2a\\(S_0\\)\u5b58\u653e\u5728\u5185\u5b58\u4e2d\uff0c\u4e4b\u540e\u8bfb\u5165\\(R_i\\)\uff0c\u5bf9\u4e8e\\(R_0\\)\uff0c\u5c31\u53ea\u9700\u8981\u8bfb\u5165\u4e4b\u540e\u76f4\u63a5\u53bb\u548c\\(s_0\\)\u201c\u8fde\u63a5\u201d\uff0c\u4e4b\u540e\u4e0d\u9700\u8981\u5199\u56de\uff0c\u76f4\u63a5\u4e22\u5f03
"},{"location":"CS/DB/Chapter_15/#_2","title":"\u590d\u6742\u8fde\u63a5","text":"$ \\Pi_{T.branch_name} ( (\\Pi_{branch_name, assets}(\\rho_T(branch))) \\bowtie_{T.assets > S.assets} (\\Pi_{assets} (\\sigma_{branch_city = 'Brooklyn'}(\\rho_S(branch))))) $
\\(\\Pi_{}\\)
"},{"location":"CS/DB/Chapter_15/#other-operation","title":"other operation","text":""},{"location":"CS/DB/Chapter_15/#project","title":"Project","text":""},{"location":"CS/DB/Chapter_15/#_3","title":"15. Process","text":""},{"location":"CS/DB/Chapter_15/#evaluation-of-expressions","title":"Evaluation of Expressions","text":""},{"location":"CS/DB/Chapter_15/#materialized","title":"Materialized | \u7269\u5316","text":""},{"location":"CS/DB/Chapter_15/#pipeline","title":"pipeline | \u6d41\u6c34\u7ebf","text":"
- \u4ece\u6700\u5e95\u5c42\u5f00\u59cb
- \u9700\u8981\u5b58\u50a8\u4e34\u65f6\u7ed3\u679c
demand driven
- pull
- \u72b6\u6001\u7684\u7ef4\u62a4\u4f9d\u8d56\u4e8e\u7b97\u5b50 operator\uff0c
open() next() close()
producer driven
- push \u4ece\u5e95\u5c42\u5f80\u4e0apush
Blocking operations | \u963b\u585e\u64cd\u4f5c: cannot generate any output until all input is consumed
Pipeline stages:
- All operations in a stage run concurrently
- A stage can start only after preceding stages have completed execution
Double-pipeline
"},{"location":"CS/DB/Chapter_15/#memory","title":"\u52a0\u901fMemory\u4e2d\u7684\u67e5\u8be2\u8fc7\u7a0b","text":""},{"location":"CS/DB/Chapter_16/","title":"\u67e5\u8be2\u4f18\u5316","text":"\u7ea6 86 \u4e2a\u5b57
"},{"location":"CS/DB/Chapter_16/#intro","title":"Intro","text":""},{"location":"CS/DB/Chapter_16/#equivalent","title":"Equivalent","text":"
- An evaluation plan defines exactly what algorithm is used for each operation, and how the execution of the operations is coordinated.
"},{"location":"CS/DB/Chapter_16/#statistics-for-cost-estimation","title":"Statistics for Cost Estimation","text":"
- \u4e0a\u9762\u7684\u5f0f\u5b50\u5de6\u53f3\u53ef\u4ee5\u76f8\u4e92\u8f6c\u6362
- \u81ea\u7136\u8fde\u63a5\u53ef\u4ea4\u6362\u3001\u7ed3\u5408
Select\u5f80\u53f6\u5b50\u4e0apush
\\(\\theta _2\u4e0a\u9762\u6709\u7d22\u5f15\\)
Size Estimation
"},{"location":"CS/DB/Chapter_16/#choice-of-evaluation-plans","title":"Choice of Evaluation Plans","text":"\u5c40\u90e8\u6700\u4f18\u4e0d\u4e00\u5b9a\u5168\u5c40\u6700\u4f18
"},{"location":"CS/DB/Chapter_16/#additional-optimization-techniques","title":"Additional Optimization Techniques","text":""},{"location":"CS/DB/Chapter_17/","title":"\u4e8b\u52a1\u7ba1\u7406","text":"\u7ea6 100 \u4e2a\u5b57
"},{"location":"CS/DB/Chapter_17/#concepts","title":"Concepts","text":"ACID
"},{"location":"CS/DB/Chapter_17/#concurrent-executions","title":"Concurrent Executions","text":""},{"location":"CS/DB/Chapter_17/#serializability","title":"Serializability","text":""},{"location":"CS/DB/Chapter_17/#conflict-serializability","title":"Conflict Serializability | \u51b2\u7a81\u53ef\u4e32\u884c","text":"
- \u539f\u5b50\u6027
- \u4e00\u81f4\u6027
- \u9694\u79bb\u6027
- \u6301\u4e45\u6027
\u4ece\u51b2\u7a81\u7684\u89c6\u89d2\u770b\uff0c\u901a\u8fc7\u4ea4\u6362\u51b2\u7a81\u53ef\u4ee5\u8fbe\u6210serial
If a schedule S can be transformed into a schedule S\u2019 by a series of swaps of non-conflicting instructions, we say that S and S\u2019 are conflict equivalent
\u51b2\u7a81\u7b49\u4ef7\uff1a\u901a\u8fc7\u4ea4\u6362\u975e\u51b2\u7a81\u7684\u6307\u4ee4\uff0c
"},{"location":"CS/DB/Chapter_17/#view-serializability","title":"View Serializability | \u89c6\u56fe\u53ef\u4e32\u884c","text":""},{"location":"CS/DB/Chapter_17/#recoverable-schedules","title":"Recoverable Schedules","text":"\u5fc5\u987b\u5728
"},{"location":"CS/DB/Chapter_18/","title":"\u5e76\u53d1\u63a7\u5236","text":"\u7ea6 738 \u4e2a\u5b57 13 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 4 \u5206\u949f
"},{"location":"CS/DB/Chapter_18/#two-phase-locking-protocol","title":"Two-Phase Locking Protocol | \u4e24\u9636\u6bb5\u5c01\u9501\u534f\u8bae","text":"
- \u65e0\u6cd5\u4fdd\u8bc1\u53ef\u6062\u590d\u6027
=> \u662f\u51b2\u7a81\u53ef\u5e76\u884c\u7684\u5145\u5206\u6761\u4ef6\uff0c\u4f46\u4e0d\u662f\u5fc5\u8981\u6761\u4ef6\uff1b\u6ee1\u8db3\u4e24\u9636\u6bb5\u5c01\u9501\u534f\u8bae\uff0c\u4e00\u5b9a\u53ef\u51b2\u7a81\u4e32\u884c\u5316\uff0c\u4f46\u53ef\u51b2\u7a81\u4e32\u884c\u5316\uff0c\u4e0d\u4e00\u5b9a\u6ee1\u8db3\u4e24\u9636\u6bb5\u5c01\u9501\u534f\u8bae
strict | \u4e25\u683c\u7684
a transaction must hold all its exclusive locks till it commits/aborts.
- \u6392\u4ed6\u9501\u7ef4\u6301\u66f4\u957f\u7684\u65f6\u95f4
- Ensures recoverability and avoids cascading roll-backs
rigorous | \u5f3a
"},{"location":"CS/DB/Chapter_18/#lock-conversion","title":"Lock Conversion","text":"
- \u6240\u6709\u7684\u9501\u90fd\u5230\u6700\u540e\uff08commit/abort\uff09\u624d\u91ca\u653e
- Transactions can be serialized in the order in which they commit.
U Lock, \u5148\u8bfb\u540e\u9762\u53ef\u80fd\u4f1a\u5199
Growing
- upgrade
Shrinking
"},{"location":"CS/DB/Chapter_18/#automatic-acquisition-of-locks","title":"Automatic Acquisition of Locks","text":"
- downgrade
write
"},{"location":"CS/DB/Chapter_18/#dead-lock","title":"Dead Lock | \u6b7b\u9501","text":"The operation write(D) is processed as:\n if Ti has a lock-X on D\n then\n write(D)\n else begin\n if necessary wait until no other trans. has any lock on D,\n if Ti has a lock-S on D\n then\n upgrade lock on D to lock-X\n else\n grant Ti a lock-X on D\n write(D)\n end;\n
System is deadlocked if there is a set of transactions such that every transaction in the set is waiting for another transaction in the set. \u4e24\u4e2a\u4e8b\u52a1\u76f8\u4e92\u7b49\u5f85\u3002
- \u6b7b\u9501\u662f\u57fa\u4e8e\u9501\u534f\u8bae\u5171\u6709\u7684\u95ee\u9898
Deadlock Prevention
Timeout-Based Schemes
"},{"location":"CS/DB/Chapter_18/#detection","title":"Detection","text":"
a transaction waits for a lock only for a specified amount of time. After that, the wait times out and the transaction is rolled back.
thus deadlocks are not possible
simple to implement; but starvation is possible. Also difficult to determine good value of the timeout interval. \u4e00\u76f4\u65e0\u6cd5\u83b7\u5f97\u9501\uff0c\u4e00\u76f4\u5728\u7b49\u5f85
wait-for Graph
"},{"location":"CS/DB/Chapter_18/#recovery","title":"Recovery","text":"
- \\(T_i -> T_j\uff0c\u524d\u4e00\u4e2a\u7b49\u5f85\u540e\u9762\u7684\\)
"},{"location":"CS/DB/Chapter_18/#graph-based","title":"Graph-Based","text":"
- Some transaction will have to rolled back (made a victim) to break deadlock. \u9009\u62e9\u727a\u7272\u8005
- Select that transaction as victim that will incur minimum cost.
- Rollback -- determine how far to roll back transaction \u56de\u6eda
- Total rollback: Abort the transaction and then restart it.
- Partial rollback: Roll back victim transaction only as far as necessary to release locks that another transaction in cycle is waiting for.
\u5bf9\u6570\u636e\u7684\u8bbf\u95ee\u6709\u4e00\u5b9a\u201c\u9884\u77e5\u201d
"},{"location":"CS/DB/Chapter_18/#tree-protocol","title":"Tree Protocol","text":"
- \u53ea\u6709\u6392\u4ed6\u9501
- \u7b2c\u4e00\u4e2a\u9501\u53ef\u4ee5\u52a0\u5230\u4efb\u4f55\u5730\u65b9\uff0c\u4f46\u662f\u4e4b\u540e\u7684\u9501\u8981\u52a0\u7684\u6570\u636e \u7684\u7236\u8282\u70b9\u4e00\u5b9a\u8981\u6709\u9501
- \u9501\u7528\u8fc7\u4e4b\u540e\u5c31\u53ef\u4ee5\u968f\u65f6\u653e\u6389
- \u540c\u4e00\u4e2a\u8282\u70b9\u4e0d\u80fd\u91cd\u590d\u52a0\u9501\uff08lock - unlock - lock \u00d7\uff09
\u597d\u5904
- \u51b2\u7a81\u53ef\u4e32\u884c
- \u4e0d\u4f1a\u4ea7\u751f\u6b7b\u9501\uff0cdeadlock-free
- \u53ef\u4ee5\u65e9\u70b9\u653e\u9501\uff0c\u63d0\u9ad8\u4e86\u5e76\u53d1\u5ea6\u3001\u541e\u5410\u7387
\u7f3a\u70b9
"},{"location":"CS/DB/Chapter_18/#multiple-granularity","title":"Multiple Granularity | \u591a\u7c92\u5ea6","text":"
- \u4e0d\u4fdd\u8bc1\u53ef\u6062\u590d\u6027 recoverability. \u53ef\u80fd\u8bfb\u53d6\u810f\u6570\u636e
- \u53ef\u901a\u8fc7\u6dfb\u52a0\u201c\u63d0\u4ea4\u4f9d\u8d56\u201d\u6765\u4fdd\u8bc1\u8fd9\u4e00\u70b9
- \u53ef\u80fd\u9501\u4f4f\u66f4\u591a\u4e0d\u9700\u8981\u7684\u6570\u636e\uff0clock more data items \u2014\u2014 \u6bd4\u5982\u540c\u65f6\u8bbf\u95ee\u6839\u8282\u70b9\u548c\u67d0\u4e00\u4e2a\u53f6\u5b50\u8282\u70b9\uff0c\u5c31\u9700\u8981\u6309\u7167Tree\u7684\u4e00\u6761path\u9501\u5230\u53f6\u5b50\u8282\u70b9
Granularity of locking (level in tree where locking is done):
- Fine granularity (\u7ec6\u7c92\u5ea6) (lower in tree): high concurrency, high locking overhead
- Coarse granularity (\u7c97\u7c92\u5ea6) (higher in tree): low locking overhead, low concurrency
- \u53ef\u4ee5\u5728\u66f4\u5927\u7684\u7c92\u5ea6\u4e0a\u9762\u52a0\u9501
Intension Lock
\u5728\u4e00\u4e2a\u8282\u70b9\u663e\u5f0f\u52a0\u9501\u4e4b\u524d, \u5bf9\u4ed6\u7684\u7236\u8282\u70b9\u52a0\u610f\u5411\u9501
\u76f8\u5bb9\u8868
- \u5728\u7c97\u7c92\u5ea6\u4e0a\u9762\u52a0\u9501\uff0c\u53ef\u4ee5\u5148\u4e0d\u53bb\u7ba1\u4e0b\u9762\u7684\u7ec6\u7c92\u5ea6\u662f\u5426\u4f1a\u51b2\u7a81\uff1b\u610f\u5411
example
- \u52a0\u9501\u4ece\u4e0a\u9762 - Unlock\u4ece\u4e0b\u9762
"},{"location":"CS/DB/Chapter_18/#insert-and-delete-operations","title":"Insert and Delete Operations","text":""},{"location":"CS/DB/Chapter_18/#phantom-phenomenon","title":"Phantom Phenomenon | \u5e7b\u8bfb","text":""},{"location":"CS/DB/Chapter_18/#_2","title":"\u8c13\u8bcd\u9501","text":""},{"location":"CS/DB/Chapter_18/#index-locking-to-prevent-phantoms","title":"Index Locking To Prevent Phantoms | \u7d22\u5f15\u5c01\u9501","text":"
- Locking rules for insert/delete operations
- An exclusive lock must be obtained on an item before it is deleted \u81ea\u52a8\u52a0\u6392\u4ed6\u9501
- A transaction that inserts a new tuple into the database automatically gives an X-mode lock on the tuple
"},{"location":"CS/DB/Chapter_18/#next-key-locking-to-prevent-phantoms","title":"Next-Key Locking to Prevent Phantoms","text":"
- \u5728\u7d22\u5f15\u4e0a\u9762\u9501\u4f4f\u4e00\u6bb5
"},{"location":"CS/DB/Chapter_19/","title":"Recovery","text":"
- \u9501\u4f4f\u5355\u72ec\u7684\u6570\u636e
\u7ea6 393 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
"},{"location":"CS/DB/Chapter_19/#failure-classification","title":"Failure Classification","text":""},{"location":"CS/DB/Chapter_19/#_1","title":"\u4e8b\u52a1\u7684\u7269\u7406\u5b9e\u73b0","text":""},{"location":"CS/DB/Chapter_19/#_2","title":"\u65e5\u5fd7\u8bb0\u5f55","text":""},{"location":"CS/DB/Chapter_19/#_3","title":"\u4e8b\u52a1\u6062\u590d","text":"\u4e00\u4e2a\u4e8b\u52a1\u7684Commit\u6807\u5fd7\uff1a\u65e5\u5fd7\u5199\u5165\u7a33\u5b9a\u5b58\u50a8\u5668
A transaction is said to have committed when its commit log record is output to stable storage
- All previous log records of the transaction must have been output already
\u8fd9\u65f6\u7684\u4fee\u6539\u4e0d\u4e00\u5b9a\u5199\u5230\u4e86\u78c1\u76d8
\u7acb\u5373\u4fee\u6539
The immediate-modification scheme allows updates of an uncommitted transaction to be made to the buffer, or the disk itself, before the transaction commits
redo undo
- redo \u5386\u53f2\u91cd\u6f14
- undo \u9700\u8981\u8bb0\u5f55\u65e5\u5fd7 redo-only\uff0c\u5b8c\u6210\u540e\uff0c\u8bb0\u5f55
"},{"location":"CS/DB/Chapter_19/#check-point","title":"Check Point","text":"
- \u6b63\u5e38\u6267\u884c\u8fc7\u7a0b\u4e2d\u7684\u56de\u6eda
- \u7cfb\u7edf\u5d29\u6e83\u540e\u6062\u590d\u53d1\u73b0\u6ca1\u6709\u7ed3\u675f
fuzzy check point
"},{"location":"CS/DB/Chapter_19/#_4","title":"\u4e8b\u52a1\u56de\u6eda","text":"\u8865\u507f\u65e5\u5fd7\u8bb0\u5f55
"},{"location":"CS/DB/Chapter_19/#_5","title":"19. Recovery","text":""},{"location":"CS/DB/Chapter_19/#_6","title":"\u7f13\u51b2\u533a\u7ba1\u7406","text":"log force \u5c06\u7f13\u51b2\u7684\u65e5\u5fd7\u5f3a\u884c\u5199\u5230Disk
"},{"location":"CS/DB/Chapter_19/#logical-undo","title":"Logical Undo","text":"Redo\u662f\u6309\u7167\u7269\u7406\u6267\u884c
"},{"location":"CS/DB/Chapter_19/#aries","title":"ARIES","text":"
- \u6bcf\u4e2a\u8bb0\u5f55\u4e00\u4e2a\u65e5\u5fd7\u987a\u5e8f\u53f7 LSN
Typically an offset from beginning of log file to allow fast access
- \u5728\u6570\u636e\u9875\u4e2d\u8bb0\u5f55\u4e00\u4e2aLSN - Page LSN
- \u66f4\u65b0\u53d1\u751f\uff0c\u65e5\u5fd7\u7684LSN\u8bb0\u5f55\u8fdb\u53bb
- \u9632\u6b62 \u91cd\u590d\u7684 redo
- Log Record
Special redo-only log record called compensation log record (CLR) used to log actions taken during recovery that never need to be undone
- \u5728\u56de\u6eda\u65f6\uff0c\u6709\u52a9\u4e8e\u8df3\u8fc7\u5df2\u7ecf\u56de\u6eda\u7684\u65e5\u5fd7
Physiological redo
Dirty Page Table
- \u5728\u540e\u53f0\u5468\u671f\u6027\u5199\u56de\uff0c\u800c\u4e0d\u662f\u5728Check Point
\u8bb0\u5f55\u810f\u9875
- Fuzzy Check Point
only records information about dirty pages, and does not require dirty pages to be written out at checkpoint time
"},{"location":"CS/DB/Chapter_19/#_7","title":"\u6d41\u7a0b","text":"
\u5206\u6790
- \u5f97\u5230redo\u7684\u4f4d\u7f6eRedoLSN \u2014\u2014 \u81f3\u5c11\u5728Check Point \u4e4b\u524d\uff0c\u5bf9\u810f\u9875Table\u7684Rec\u53d6Min
- undo-list \u4eceCheck Point \u5f80\u4e0b\u626b\u63cf\uff0c\u5b8c\u5584undo list
- \u66f4\u65b0\u810f\u9875\u8868
Redo
- \u810f\u9875\u8868\uff0c\u6ce8\u610f\u662f\u8ddflog record\u4e2d\u7684LSN\u6bd4\u8f83
- \u78c1\u76d8\u9875
- Undo
"},{"location":"CS/DB/Chapter_2/","title":"Relation","text":"
\u7ea6 228 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
\u00a7 Structure of Relational Databases
\u00a7 Database Schema \u6570\u636e\u5e93\u6a21\u5f0f
- A relation instance r defined over schema R is denoted by r (R)
\u00a7 Keys
\u00a7 Schema Diagrams
\u00a7 Relational Query Languages
\u00a7 The Relational Algebra
","tags":["class/DB"]},{"location":"CS/DB/Chapter_2/#structure-of-relational-databases","title":"Structure of Relational Databases","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_2/#attributes","title":"Attributes","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_2/#database-schema","title":"Database Schema \u6570\u636e\u5e93\u6a21\u5f0f","text":"
\u539f\u5b50\u6027 \u2192 \u4e0d\u53ef\u62c6\u5206\uff08\u6570\u7ec4\u3001\u7ed3\u6784\u4f53\u4e4b\u7c7b\u4e0d\u53ef\uff09
The set of allowed values for each attribute is called the domain \uff08\u57df\uff09 of the attribute
The special value null \uff08\u7a7a\u503c\uff09 is a member of every domain. Indicated that the value is \u201cunknown\u201d
\u65e0\u5e8f\u6027\uff0c\u987a\u5e8f\u6ca1\u6709\u5f71\u54cd
schema \u5173\u7cfb\u6a21\u5f0f\uff0clogical structure
instance \u67d0\u4e00\u77ac\u95f4\u7684\u5feb\u7167
","tags":["class/DB"]},{"location":"CS/DB/Chapter_2/#keys","title":"Keys","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_2/#database","title":"Database","text":"
super key \u8d85\u7801 \u53ef\u4ee5\u552f\u4e00\u6807\u8bc6
candidate key \u6700\u5c0f\u5355\u5143\u7684\u8d85\u7801
primary key \u7684\u7ea6\u675f\u6761\u4ef6 \u4efb\u610f\u4e00\u4e2a\u5019\u9009\u7801\u90fd\u53ef\u4ee5\u4f5c\u4e3a\u4e3b\u952e\uff1b\u4e0d\u80fd\u662fnull
Foreign
- \\(R_1\\)\u4e2d\u7684\u4e00\u4e2a\u5c5e\u6027\uff0c\u662f\u53e6\u5916\u4e00\u4e2a\u53c2\u7167\\(R_2\\)\u7684 primary key
- \u7ea6\u675f\u6761\u4ef6\u6bd4\u8f83\u5f3a\uff0c\u5fc5\u987b\u662f A\u7684\u5c5e\u6027 B\u7684
primary key
referential integrity constraint \u53c2\u7167\u5b8c\u6574\u6027\u7ea6\u675f
- \u7ea6\u675f\u6761\u4ef6\u8f83\u5f31\uff0c
\u542b\u6709\u591a\u4e2arelation
","tags":["class/DB"]},{"location":"CS/DB/Chapter_2/#relation-algebra","title":"Relation Algebra","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/","title":"SQL","text":"\u7ea6 884 \u4e2a\u5b57 355 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 9 \u5206\u949f
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#essential","title":"Essential","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#ddl","title":"DDL","text":"
- A query returns a single table
Create
create table student\n(\n id int,\n name varchar(8) not null,\n ...\n <\u5b8c\u6574\u6027\u7ea6\u675f>\n primary key(id),\n foreign key(..) references department\n);\n
Select
SELECT * FROM Websites \nWHERE xx>15\nAND (country = 'US' or 'CN')\n;\n// \u53bb\u91cd\u590d\nSELECT DISTINCT country FROM Websites;\n// \u81ea\u7136\u8fde\u63a5 \u8003\u8651\u7684\u662f\u4e0d\u540c\u5173\u7cfb\u4e2d\u90fd\u51fa\u73b0\u7684\u5c5e\u6027\uff0c\u53d6\u8fd9\u4e9b\u76f8\u540c\u5c5e\u6027\u90fd\u76f8\u7b49\u7684tuple;\nselect A\nfrom r1 natural join R2 using <attributes>\n// \u6392\u5e8f\norder by salary desc, name asc\n
- The operands of the logical connectives can be expressions involving the comparison operators <, <=, >, >=, =, and <>.
order by (conlumns) ASC|DESC
Insert INTO
INSERT INTO table_name (column1,column2,column3,...)\nVALUES (value1,value2,value3,...);\n\nINSERT INTO table_name\nVALUES (value1,value2,value3,...);\n\ninsert into table1 select * from table1\n\ninsert into instructor\n select ID, name, dept_name, 18000\n from student \n where dept_name = 'Music' and total_cred > 144;\n
Update
where \u9650\u5236\u5f88\u91cd\u8981\uff01\uff01
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#dml","title":"DML","text":"UPDATE Table\nSET name = \"666\",Country = 'CN'\nWHERE id = 4;\n
Delete
delete from Table \u5220\u9664\u6240\u6709\u5c5e\u6027\nwhere ...\n// \u5728\u6267\u884c\u4efb\u4f55\u5220\u9664\u4e4b\u524d\u5bf9\u6240\u6709\u5143\u7ec4\u5b8c\u6210\u5904\u7406\u5f88\u91cd\u8981\uff0c\u5426\u5219\u6267\u884c\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u53d1\u751f\u53d8\u5316\ndelete from instructor\nwhere salary < (select avg (salary) \n from instructor);\n
Drop
drop table r; \u5220\u9664\n
Alter
alter \u64cd\u4f5c\u9488\u5bf9\u7684\u662fattribute
https://www.runoob.com/mysql/mysql-alter.html
alter table r add att Domain\n\n\nalter table r drop att\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_1","title":"\u64cd\u4f5c","text":"alter table drop foreign key <\u7ea6\u675f\u540d>;\nalter table takes add constraint tb_id foreign key(id) references student(id);\n
Limit
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_2","title":"\u9644\u52a0\u7684\u64cd\u4f5c","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_3","title":"\u66f4\u540d","text":"\u9650\u5236\u9009\u4e2d\u7684\u6570\u76ee\nlimit number;\n
- \u7528\u4e8e\u533a\u5206\u540c\u4e00\u4e2a\u5173\u7cfb\u7684\u7b1b\u5361\u5c14\u79ef
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#string","title":"string","text":"select distinct T.name\nfrom instructor as T, instructor as S\nwhere T.salary > S.salary and S.dept_name = \"\"\n
\u4f7f\u7528
LIKE
\u5b57\u7b26\u6765\u5b8c\u6210\u6a21\u5f0f\u5339\u914d
- % \u5339\u914d\u4efb\u610f\u5b57\u7b26\u4e32 \"%dar%\"
- _ \u5339\u914d\u4efb\u610f\u4e00\u4e2a\u5b57\u7b26 \" _ \" \u4e09\u4e2a\u5b57\u7b26
\u7528
escape
\u6765\u5b9a\u4e49\u8f6c\u4e49\u5b57\u7b26","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#set-operation","title":"\u96c6\u5408 | Set Operation","text":"where building like '%ab\\%cd%' escape '\\'\n// \u5305\u542bab%cd\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#null","title":"null","text":"// \u81ea\u52a8\u53bb\u91cd\nA union B\nA union all B\n\nA intersect B\n\nA except B\n
- \u7b97\u672f\u8868\u8fbe \u7ed3\u679c\u4e3a\u7a7a
- \u6bd4\u8f83 unknown
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_4","title":"\u805a\u96c6\u51fd\u6570","text":"select count (distinct ID)\nfrom teaches\nwhere semester = 'Spring' and year = 2018;\n
avg min max sum count
group by
having
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#nested","title":"Nested | \u5d4c\u5957\u5b50\u67e5\u8be2","text":"select dept_name, avg (salary) as avg_salary\nfrom instructor\ngroup by dept_name;\n\nselect count (*)\nfrom course;\n\nselect dept_name, avg (salary) as avg_salary\nfrom instructor\ngroup by dept_name\nhaving avg (salary) > 42000;\n
select distinct course_id\nfrom section\nwhere semester = 'Fall' and year= 2017 and \ncourse_id in (select course_id\n from section\n where semester = 'Spring' and year= 2018);\n
some
all
exists
select name\nfrom instructor\nwhere salary > some (select salary\n from instructor\n where dept name = 'Biology')\n\nselect distinct\n S.ID,\n S.name\nfrom\n student as S\nwhere\n not exists (\n (\n select\n course_id\n from\n course\n where\n dept_name = 'Biology'\n )\n except\n (\n select\n T.course_id\n from\n takes as T\n where\n S.ID = T.ID\n )\n );\n
unique
not unique
SQL \u4e2dunique\u7528\u4e8e\u7ea6\u675f
select T.course_id\nfrom course as T\nwhere unique ( select R.course_id\n from section as R\n where T.course_id= R.course_id\n and R.year = 2017); \n
select id,name,course_code,score,year\nfrom \n student natural join takes as C\nwhere (id,course_code) in\n(\n select distinct id, course_code\n from takes as T\n where C.id = T.id\n);\n
from
# Error : Every derived table must have its own alias\nselect id,name,course_code,score,year\nfrom \n(\n select id,name,course_code,score,year\n from student natural join takes\n where id = '0001'\n# ' as course ' here is bound to be added\n) as course\nwhere score >= 90;\n
with
with max_budget (value) as \n (select max(budget)\n from department)\n\nselect department.name\nfrom department, max_budget\nwhere department.budget = max_budget.value;\n
Scalar
Scalar \uff08\u6807\u91cf\uff09 subquery is one which is used where a single value is expected
\n
case
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#intermediate","title":"Intermediate","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#join","title":"Join","text":"case \n when pred then result\n when pred then result\n else result\nend\n\nupdate student S\nset score = case\n when ... t.hen\n else 0\nend\n
natural join
\u53ea\u4fdd\u7559\u4e00\u7ec4\u76f8\u540c\u7684\u5143\u7d20; \u4f7f\u7528 on condition \u7684join\u64cd\u4f5c\u5c06\u4f1a\u5b58\u5728\u4e24\u4e2a\u91cd\u590d\u7684condition\u5c5e\u6027","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#views","title":"Views","text":"natural left/right/full outer join\nusing (attribute)\non condition\n\u4f8b\u5982\nusing course_id\non takes.course_id = student.course_id\n
- \u4e00\u79cd\u865a\u5173\u7cfb
create view v as <query>\n\ncreate view departments_total_salary (dept_name, total_salary) as\n select dept_name , sum salary\n from instructor\n group by dept_name\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#materialized-views","title":"Materialized Views | \u7269\u5316\u89c6\u56fe","text":"
- Recursive case \u7684expand?
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_5","title":"\u89c6\u56fe\u66f4\u65b0","text":"
- \u7269\u7406\u5b58\u50a8 \uff1a\u4e0d\u9700\u8981\u5728\u6bcf\u6b21\u8c03\u7528\u65f6\u91cd\u65b0\u8fdb\u884c\u67e5\u8be2\u64cd\u4f5c\uff08\u865a\u5173\u7cfb\u9700\u8981\uff09
- If relations used in the query are updated, the materialized view\uff08\u89c6\u56fe\u7ef4\u62a4\uff09 result becomes out of date
- Need to maintain the view, by updating the view whenever the underlying relations are updated.
- \u66f4\u65b0\u4e00\u4e2a\u89c6\u56fe\u5fc5\u987b\u8981\u7ed9\u51fa\u5bf9\u5b9e\u9645\u5173\u7cfb\u7684\u4fee\u6539
Most SQL implementations allow updates only on simple views
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#transaction","title":"Transaction | \u4e8b\u52a1","text":"
- The from clause has only one database relation.
- The select clause contains only attribute names of the relation, and does not have any expressions, aggregates, or distinct specification.
- Any attribute not listed in the select clause can be set to null
- The query does not have a group by or having clause.
Atomic transaction
\u4e8b\u52a1\u662f\u7531\u67e5\u8be2\u548c\uff08\u6216\uff09\u66f4\u65b0\u8bed\u53e5\u7684\u5e8f\u5217\u7ec4\u6210\u3002SQL\u8bed\u53e5\u89c4\u5b9a\u5f53\u4e00\u6761\u8bed\u53e5\u5f00\u59cb\u65f6\uff0c\u4e00\u4e2a\u4e8b\u52a1\u5f00\u59cb\u6267\u884c\uff0c\u4e0b\u9762\u7684\u8bed\u53e5\u4f1a\u7ec8\u6b62\u4e00\u4e2a\u4e8b\u52a1
commit work
: \u63d0\u4ea4\u4e8b\u52a1rollback work
: \u56de\u6eda\u4e8b\u52a1\u5728SQL\u7684\u5b9e\u73b0\u4e2d\uff0c\u5f88\u591a\u60c5\u51b5\u4e0b\u90fd\u9ed8\u8ba4\u4e00\u6761\u8bed\u53e5\u81ea\u6210\u4e00\u4e2a\u4e8b\u52a1\uff0c\u4e00\u65e6\u6267\u884c\u5b8c\u6210\u5c31\u4f1a\u63d0\u4ea4
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#integrity-constraints","title":"Integrity Constraints","text":"Constraints on a Single Relation
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#check-assertion","title":"check & assertion","text":"
- not null
- primary key
- **unique ** ? a super key
- check (P), where P is a predicate
- \u8c13\u8bcd\u68c0\u6d4b
create table section \n(\n course_id varchar (8),\n sec_id varchar (8),\n semester varchar (6),\n year numeric (4,0),\n building varchar (15),\n room_number varchar (7),\n time slot id varchar (4), \n primary key (course_id, sec_id, semester, year),\n check (semester in ('Fall', 'Winter', 'Spring', 'Summer'))\n)\n
- assertion\u7684\u7ef4\u62a4\u4ee3\u4ef7\u6bd4\u8f83\u9ad8
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#referential-intergrity","title":"referential intergrity | \u53c2\u7167\u5b8c\u6574\u6027","text":"create assertion <assertion-name> check <predicate>;\n\n// \u63d2\u5165\u4fee\u6539tuple\u65f6\u8981check\uff0ctime_slot\u6539\u53d8\u65f6\u4e5f\u8981check\ncheck (time_slot_id in (select time_slot_id from time_slot) )\n\n\n\ncreate assertion credits_earned_constraint check (\n not exists (\n select\n ID\n from\n student\n where\n tot cred <> (\n select\n coalesce(sum(credits), 0)\n from\n takes natural\n join course\n where\n student.ID = takes.ID\n and grade is not null\n and grade <> 'F'\n )\n )\n);\n
\u4e0d\u540c\u4e8e\u5916\u7801\u7ea6\u675f\uff0c\u53c2\u7167\u5b8c\u6574\u6027\u7ea6\u675f\u5e76\u4e0d\u8981\u6c42\u76ee\u6807\u5c5e\u6027\u662f\u67d0\u4e2a\u5173\u7cfb\u7684\u4e3b\u7801\u3002\u4f46\u662f\uff0cforeign key \u8981\u6c42\u81f3\u5c11\u662f\u5019\u8865\u7801
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_6","title":"\u589e\u52a0\u4e0e\u5220\u9664","text":"foreign key () references _\non delete set NULL\n// \u7ea7\u8054\non delete cascade\non update cascade\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#data-type-schema","title":"Data Type & Schema","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#data","title":"Data","text":"ALTER TABLE <\u6570\u636e\u8868\u540d> ADD CONSTRAINT <\u5916\u952e\u540d>\nFOREIGN KEY(<\u5217\u540d1>) REFERENCES <\u4e3b\u8868\u540d> (<\u5217\u540d2>);\n# \u6ce8\u610f\uff0c\u5916\u952e\u540d\u662f\u7528\u6237\u5b9a\u4e49\u7684\uff0c\n\nalter table takes add constraint tb_id foreign key(id) references student(id);\n
Time
\u9ed8\u8ba4\u503c
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#index","title":"Index","text":"create table student\n(\n ID varchar(5),\n tot_cred numeric(3,0) default 0\n)\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#large-object","title":"Large Object | \u5927\u5bf9\u8c61\u7c7b\u578b","text":"create index <name> on <relation name> (attribute);\n\ncreate table student(\n ID varchar (5),\n name varchar (20) not null,\n dept_name varchar (20),\n tot_cred numeric (3, 0),\n default 0,\n primary key (ID)\n);\ncreate index studentID_index on student(ID)\n// \u5220\u9664\u7d22\u5f15\ndrop index student_id on student;\n\nThe query:\nselect *\n from student\n where ID = '1001'\ncan be executed by using the index to find the required record, without\nlooking at all records of studen\n
bookreview clob (2KB)\nimage blob (10MB)\nmovie blob (2GB)\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#user-defined-type","title":"User-defined Type","text":"
- When a query returns a large object, a pointer \uff08\u5b9a\u4f4d\u5668\uff09 is returned rather than the large object itself.
\u8fd9\u91cc\u4ecb\u7ecd\u7684\u662fdistinct Type
create type Dollars as numeric (12,2) final\n\ncreate domain DDollars as numeric (12,2) not null \nconstraint Dollars_test check ...;\n\ncreate table department\n (\n dept_name varchar (20)\n building varchar (15)\n budget Dollars\n );\n
cast \u6570\u503c\u8f6c\u6362
cast(department.budget to numeric(12,2))
\u5bf9\u4e8e\u5f3a\u7c7b\u578b\u68c0\u67e5\uff0c\u5fc5\u987b\u8fd9\u6837\u5904\u7406
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#domain","title":"Domain","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#authorization","title":"Authorization","text":"grant / revoke <privileges list>\non <\u5173\u7cfb/\u89c6\u56fe>\nto <user list>\n\ngrant update(dept)\non department\nto Alan\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#role","title":"Role","text":"
- a
user id
public
, which allows all valid users the privilege granted- A
role
- \u521b\u5efa\u4e00\u4e2a role\uff0c\u8fd9\u4e2arole\u53ef\u4ee5\u6388\u4e88\u7ed9\u5176\u4ed6role/user\uff0c\u4e5f\u53ef\u4ee5\u63a5\u53d7\u6388\u6743(\u7ed9\u6211\u7684\u611f\u89c9\u50cf\u662f\u4e00\u4e2aTag)
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_7","title":"\u89c6\u56fe\u7684\u6388\u6743","text":"create role instructor\n\ngrant class to instructor\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_8","title":"\u6a21\u5f0f\u7684\u6388\u6743","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_9","title":"\u6743\u9650\u8f6c\u79fb","text":"
- \u89c6\u56fe\u7684\u521b\u5efa\u8005\u4e0d\u9700\u8981\u89c6\u56fe\u4e0a\u7684\u6240\u6709\u6743\u9650
with grant option
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_10","title":"\u6743\u9650\u6536\u56de","text":"grant select on depart to Aimit with grant option\n
- \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6743\u9650\u7684\u6536\u56de\u662f\u7ea7\u8054\u7684
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#advanced","title":"Advanced","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_11","title":"\u7a0b\u5e8f\u8bed\u8a00","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#odbc","title":"ODBC","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#jdbc","title":"JDBC","text":"revoke select on department from Amit , Satoshi cascade\n\nrevoke select on department from Amit , Satoshi restrict\n
- try \u5c06\u5f02\u5e38\u629b\u51fa \u5230 catch
Prepared Statement
SQL Injection
Metadata Features
Transaction Control in JDBC
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#sqlj","title":"SQLJ","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#embedded","title":"Embedded","text":"# \u8fde\u63a5\u5230\u6570\u636e\u5e93\nEXEC SQL connect to server user user-name using password;\n# \u5bbf\u4e3b\u53d8\u91cf\u7528 : \u52a0\u4ee5\u533a\u5206\n# They are preceded by a colon (:) to distinguish from SQL variables (e.g., :credit_amount )\n# must be declared within DECLARE section,\nEXEC-SQL BEGIN DECLARE SECTION\nint credit-amount ;\nEXEC-SQL END DECLARE SECTION;\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#function-and-procedures","title":"\u51fd\u6570\u548c\u8fc7\u7a0b | function and procedures","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#trigger","title":"\u89e6\u53d1\u5668 | Trigger","text":"EXEC SQL\n# \u7528c\u4f5c\u4e3a\u6807\u8bc6\n declare c cursor for \n select ID, name\n from student\n where tot_cred > :credit_amount\nEND_EXEC\n\nEXEC SQL open c ;\n
- **Event : ** delete \u3001 insert \u3001update(
create trigger <trigger name> after <Event> of <relation> on <attribute>
)- before \u89e6\u53d1 \u7ef4\u62a4\u5b8c\u6574\u6027\u7ea6\u675f\uff1b\u6709\u52a9\u4e8e\u5916\u952e\u7684\u63d2\u5165
- after \u89e6\u53d1
TIPS\uff1a
IN MySQL, \u4e0b\u9762\u7684\u8bed\u53e5\u662f\u4e0d\u5b58\u5728\u7684\uff0c\u8981\u4f7f\u7528\u5173\u952e\u5b57
old
new
\u6765\u8868\u5f81referencing new row as nrow;\nreferencing old row as orow;\n
create trigger <trigger name> after <Event> on <relation>\n referencing new row as nrow;\n referencing old row as orow;\n# \u6307\u5b9a\u4e3a\u884c\u7ea7\u89e6\u53d1\uff0c\u5bf9\u4e8e\u6bcf\u4e00\u884c\u89e6\u53d1\u7684tuple\u90fd\u6267\u884c\u4e0b\u8ff0\u884c\u4e3a\nfor each row\nwhen ( condition )\n begin atmotic\n end;\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_12","title":"\u4f55\u65f6\u4e0d\u5e94\u4f7f\u7528\u89e6\u53d1\u5668","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#function","title":"Function","text":"# \u5bf9\u5b66\u5206\u7684\u66f4\u65b0\ncreate trigger credits_earned\nafter\nupdate\n of takes on (grade) referencing new row as nrow referencing old row as orow for each row\n when nrow.grade <> 'F'\n and nrow.grade is not null\n and (\n orow.grade = 'F'\n or orow.grade is null\n ) begin atomic\nupdate\n student\nset\n tot_cred = tot_cred + (\n select\n credits\n from\n course\n where\n course.course_id = nrow.course_id\n )\nwhere\n student.id = nrow.id;\nend;\n
create function dept_count (dept_name varchar(20))\nreturns integer\n\nbegin\n declare d_count integer;\n select count (* ) into d_count\n from instructor\n where instructor.dept_name = dept_name\n return d_count;\nend\n\n# The function dept_count can be used to find the department names and budget of all departments with more that 12 instructors.\nselect dept_name, budget\n from department\n where dept_count (dept_name ) > 12\n
","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#procedure","title":"Procedure","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#_13","title":"\u4f8b\u9898","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_3_4_5/#trigger_1","title":"Trigger","text":"
- \u6ce8\u610f\u4e0b\u9762\u7684 return \u548c returns
- \u63d2\u5165\u591a\u884c\u7684\u4e00\u79cd\u7528\u6cd5
insert into select from
","tags":["class/DB"]},{"location":"CS/DB/Chapter_6/","title":"Chapter 6 | ER Model","text":"create trigger insert_depositor\nafter insert on depositor \nreferencing new row as nrow\nfor each row \nbegin\ninsert into\n select branch_name, customer_name\n from depositor, account\n where nrow.account_number = account.account_number\nend;\n\ncreate trigger insert_customer\nafter insert on customer\nreferencing new row as nrow\nfor each row \nbegin\ninsert into\n select branch_name, customer_name\n from depositor, account\n where nrow.account_number = depositor.account_number\nend;\n
\u7ea6 86 \u4e2a\u5b57
","tags":["class/DB"]},{"location":"CS/DB/Chapter_6/#how-to-draw-a-er-graph","title":"How to draw a ER graph","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_6/#_1","title":"\u57fa\u6570\u8868\u793a","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_6/#weak-entity","title":"Weak Entity","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_6/#_2","title":"\u8f6c\u5316","text":"\u591a\u503c\u5c5e\u6027
\u591a\u5bf9\u4e00
","tags":["class/DB"]},{"location":"CS/DB/Chapter_6/#_3","title":"\u5176\u4ed6\u7279\u6027","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_6/#_4","title":"\u7279\u5316","text":"
- \u90e8\u5206\u53ef\u80fd\u4f1a\u51fa\u73b0null
","tags":["class/DB"]},{"location":"CS/DB/Chapter_6/#_5","title":"\u6cdb\u5316","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_6/#-partial-generalization-is-the-default","title":"- Partial generalization is the default.","text":"","tags":["class/DB"]},{"location":"CS/DB/Chapter_7/","title":"Chapter 7 Relational Database Design","text":"
- \u91cd\u53e0\u7279\u5316 Overlapping \u4e00\u4e2a\u5b9e\u4f53\u96c6\u53ef\u80fd\u5c5e\u4e8e\u591a\u4e2a\u7279\u5316\u5b9e\u4f53\u96c6
- \u4e0d\u76f8\u4ea4\u7279\u5316 \u5fc5\u987b\u5c5e\u4e8e\u81f3\u591a\u4e00\u4e2a\u7279\u5316\u5b9e\u4f53\u96c6
\u7ea6 763 \u4e2a\u5b57 11 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 4 \u5206\u949f
"},{"location":"CS/DB/Chapter_7/#features-of-good-relational-design","title":"Features of Good Relational Design","text":"\u4e0d\u89c4\u8303\u7684\u5173\u7cfb\u6a21\u5f0f
\u540c\u65f6\u4e5f\u662f\u8981\u53bbdecompose\u4e00\u4e2a\u5173\u7cfb\u6a21\u5f0f\u7684\u539f\u56e0
\u51fd\u6570\u4f9d\u8d56 | functional dependency
graph\n 2[candidate key]\n 3[primary key]\n subgraph \"super key\"\n 2\n 2 -- one -->3\n end
\u65e0\u635f\u8fde\u63a5\u7684\u5b9a\u4e49 \u81ea\u7136\u8fde\u63a5\u4e4b\u540e\u7b49\u4e8e\u539f\u7ec4\u5408
\u65e0\u635f\u8fde\u63a5\u7684\u5206\u89e3
\u5206\u89e3 \u4e4b\u540e \u81f3\u5c11\u6709\u4e00\u4e2a\u516c\u5171\u5c5e\u6027\uff0c\u4e14\u662f\u5176\u4e2d\u4e00\u4e2a\u5173\u7cfb\u7684
key
(\u4e0d\u662fprimary
)\u8fd9\u91cc\u662f\u4e00\u4e2a\u5145\u5206\u6761\u4ef6\uff0c\u800c\u4e0d\u662f\u5fc5\u8981\u7684\uff1a
\\(\u8bc1\u660e\u7684\u601d\u8def\\\\ R_1\\cap R_2\\to R_1 \\\\or \\\\ R_1\\cap R_2\\to R_2\\)\u200b
- lossy decomposition
\u539f\u56e0\u5728\u4e8ename\u5c5e\u6027\u4e0d\u662f\u4e00\u4e2a\u5019\u8865\u952e\uff0c\u4e0d\u80fd\u51b3\u5b9a\u5176\u4ed6\u5c5e\u6027
"},{"location":"CS/DB/Chapter_7/#functional-dependency","title":"Functional Dependency","text":"
- \u53ef\u4ee5\u6839\u636e\u81ea\u7136\u8fde\u63a5\u540e\u80fd\u5426\u6062\u590d\u6765\u5224\u65ad\uff08\u6709\u53ef\u80fd\u4f1a\u53d8\u591a/\u5c11\uff09
\u5c31\u662f\u4e00\u79cd constraint
Trivial case
"},{"location":"CS/DB/Chapter_7/#closure","title":"Closure | \u95ed\u5305","text":""},{"location":"CS/DB/Chapter_7/#armstrongs-axioms","title":"\u516c\u7406 | Armstrong`s Axioms","text":"
- \u6ca1\u6709\u5b9e\u9645\u7684\u4fe1\u606f\u5b58\u5728
- \u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u9690\u542b\u8fd9\u6837\u7684\u5047\u8bbe\uff1a\u8fd9\u4e2a\u51fd\u6570\u4f9d\u8d56\u4e0d\u662fTrivial\u7684\uff08\u975e\u5e73\u51e1\u7684\uff09
- \u63a8\u8bba
$$ 1 \\alpha \\to \\beta,\\alpha\\to\\gamma \\Rightarrow \\alpha\\to\\alpha\\beta,\\alpha\\beta\\to\\beta\\gamma\\Rightarrow\\alpha\\to\\beta\\gamma \\ 2 apply tansitive law \\ 3 apply tansitive law \\ $$
- \u6d88\u53bb\u5f8b \u6d88\u53bb\u67d0\u4e00\u8fb9\u7684\u516c\u5171\u5c5e\u6027
Example
"},{"location":"CS/DB/Chapter_7/#_1","title":"\u5c5e\u6027\u7684\u95ed\u5305","text":"
- \u5c31\u662f\u67d0\u4e2a\u5c5e\u6027A\u53ef\u4ee5\u51b3\u5b9a\u5176\u4ed6\u54ea\u4e9b\u5c5e\u6027\uff0c\u8fd9\u4e9b\u5c5e\u6027\u5c31\u662fA\u7684\u95ed\u5305
graph LR\nA --> B\nB-->C\nB-->D
uses
- \u7528\u4e8e\u8ba1\u7b97\u51fd\u6570\u4f9d\u8d56 F \u7684\u95ed\u5305
"},{"location":"CS/DB/Chapter_7/#canonical-cover","title":"Canonical Cover | \u6b63\u5219\u8986\u76d6","text":"
- \u5316\u7b80\uff0c\u4f7f\u5f97\u4e0d\u5b58\u5728\u591a\u4f59\u7684\u5c5e\u6027\u548c\u51fd\u6570\u4f9d\u8d56
- Extraneous Attributes(\u65e0\u5173\u5c5e\u6027)
Example
\u7b2c\u4e00\u79cd\u65b9\u6cd5\u5f80\u5f80\u662f\u8ba1\u7b97\u7a0b\u5e8f\u4f7f\u7528\u7684\uff0c\u4eba\u5de5\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\u5e76\u4e0d\u9ad8\u6548
example "},{"location":"CS/DB/Chapter_7/#boyce-codd-normal-form-bcnf","title":"Boyce-Codd Normal Form | BCNF","text":"
- \u4efb\u4f55\u4e00\u6761\u51fd\u6570\u4f9d\u8d56\u8981\u4e48\u662f\u5e73\u51e1\u7684\uff0c\u8981\u4e48\u5de6\u8fb9\u662fkey == \u4efb\u4f55\u4e00\u6761\u975e\u5e73\u51e1\u7684\u5de6\u8fb9\u90fd\u662f
super key
Warning
\u4e0d\u662f\u6307\\(\\alpha\\to\\beta \u4e2d\u7684\\alpha\\)\u662fkey\u7684\u4e00\u90e8\u5206\uff0c\u800c\u662f\u5b83\u672c\u8eab\u5c31\u53ef\u4ee5\u51b3\u5b9a\u5176\u4ed6\u6240\u6709
example "},{"location":"CS/DB/Chapter_7/#how-good-is-bcnf","title":"How good is BCNF","text":"
- \u8f6c\u6362\u4e3aBCNF
- \u628a\u8fdd\u53cd\u5b9a\u4e49\u7684Func\u62ff\u51fa\u6765\uff0c\u4fdd\u6301\u65e0\u635f\u53bb\u5206\u89e3
"},{"location":"CS/DB/Chapter_7/#dependency-preservation","title":"Dependency Preservation","text":"
- \u662fBCNF\u4f46\u662f\u4ecd\u7136\u5b58\u5728\u95ee\u9898 <= \u5b58\u5728\u591a\u503c\u4f9d\u8d56\u4e14\u8fd8\u6709\u5176\u4ed6\u5c5e\u6027
- \u4f7f\u7528 4-NF\uff0c \u89c1 \u591a\u503c\u4f9d\u8d56
\u5b9a\u4e49
example
- \u4e0d\u9700\u8981\u5728\u5206\u89e3\u540e\u7684\\(R_i\\)\u4e4b\u95f4\u5efa\u7acb\u65b0\u7684\u5173\u8054\uff08\u901a\u8fc7\u81ea\u7136\u8fde\u63a5\u91cd\u65b0\u5efa\u7acb\u5c5e\u6027\u95f4\u7684\u8054\u7cfb\uff09\u5c31\u53ef\u4ee5\u5f97\u5230\u6240\u6709\u7684
DF\uff08Dependency Func\uff09
\\((F_1 \\cup F_2)^+ <>F^+\\)
execise- BCNF\u5206\u89e3\u7684\u65f6\u5019\u4e0d\u9700\u8981\u53bb\u7ba1\u51fd\u6570\u4f9d\u8d56\u7684\u95ee\u9898
"},{"location":"CS/DB/Chapter_7/#third-normal-form","title":"Third Normal Form","text":"\u5b9a\u4e49
\u7b97\u6cd5
\u751f\u6210\u6b63\u5219\u8986\u76d6
\u5bf9\u6240\u6709\u7684\u51fd\u6570\u4f9d\u8d56\u751f\u6210\u5173\u7cfb\u6a21\u5f0f
\u68c0\u6d4b\u662f\u5426\u6709\u5173\u7cfb\u6a21\u5f0f\u5305\u542b
candidate key
\uff0c\u4e00\u5b9a\u8981\u6ce8\u610f\u81ea\u59cb\u81f3\u7ec8\u6ca1\u6709\u5728\u51fd\u6570\u4f9d\u8d56\u4e2d\u51fa\u73b0\u7684\u5c5e\u6027\uff01example
\\[ schema(A,B,C,D,E,G) \\\\A\\to BCD \\\\BC\\to DE \\\\B\\to D \\\\D\\to A \\\\G\u8fd9\u4e2a\u5c5e\u6027\u6ca1\u6709\u5728\u4e0a\u8ff0\u51fd\u6570\u4f9d\u8d56\u4e2d\u51fa\u73b0 \\]Q1 : \u6c42BCNF
\u901a\u8fc7\u6c42A\u3001BC\u3001B\u3001D\u7684\u95ed\u5305\uff0c\u53ef\u4ee5\u53d1\u73b0\u4ed6\u4eec\u90fd\u76f8\u540c(ABCDE)\uff0c\u8fd9\u4e2a\u65f6\u5019\u4e00\u5b9a\u4e0d\u8981\u60f3\u5f53\u7136\u7684\u8ba4\u4e3a\u4ed6\u4eec\u6ee1\u8db3BCNF\u7684\u6761\u4ef6\uff0c\u9898\u4e2d\u7684FG\u662f\u5b64\u7acb\u7684\u5143\u7d20
\\(R_1=(A,B,C,D)\\ left = AEG\\) \u7531\u4e8e\\(A^+=ABCDE,\u6240\u6709\u8fd9\u91cc\u6709\u51fd\u6570\u4f9d\u8d56A\\to E\u6210\u7acb\\) \\(R_2=(A,E),R_3=(A,G)\\)
"},{"location":"CS/DB/Chapter_7/#multivalued-dependencies","title":"Multivalued Dependencies","text":"definition
\u51fd\u6570\u4f9d\u8d56\u662f\u591a\u503c\u4f9d\u8d56\u7684\u7279\u6b8a\u5f62\u5f0f
"},{"location":"CS/DB/Chapter_7/#4-nf","title":"4 NF","text":"
- \u5e73\u51e1\u7684\u591a\u503c\u4f9d\u8d56
- \u03b1\u662f
super key
ER graph
"},{"location":"CS/DB/Chapter_7/#process","title":"Process","text":"
- \u8bbe\u8ba1ER Graph\uff0c\u7531ER\u56fe\u8f6c\u4e3a\u5173\u7cfb\u6a21\u5f0f\uff0c\u4e0d\u9700\u8981\u518d\u53bbnormalize
- \u4e0d\u8bbe\u8ba1\uff0c\u4e4b\u540e\u518d\u53bbnormalize
\u5f15\u5165\u5197\u4f59\uff0c\u4fdd\u6301\u6027\u80fd
"},{"location":"CS/DIP/","title":"Index","text":"\u7ea6 185 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
\u6559\u5e08\uff1a\u5b8b\u660e\u9ece
\u8fd9\u4e2a\u8bfe\u53ea\u6709\u524d\u51e0\u8282\u8bfe\u548c\u6700\u540e\u4e00\u8282\u8bfe\u6765\u7684\u4eba\u591a\u4e00\u70b9\uff08\u56e0\u4e3a\u4f1a\u5212\u91cd\u70b9\uff09 \u4e0d\u5f97\u4e0d\u8bf4\u9ece\u53d4\u7684\u58f0\u97f3\u8fd8\u662f\u6709\u70b9\u50ac\u7720\u7684
\u6700\u540e\u8bb2\u7684\u5f88\u591a\u4e1c\u897f\u5f53\u65f6\u65e0\u6cd5\u7406\u89e3\uff0c\u5b66\u4e86\u4e00\u4e9bAI\u4e4b\u540e\u56de\u5934\u770b\u611f\u89c9\u5f53\u65f6\u8bb2\u7684\u8fd8\u633a\u591a\u7684\uff0c\u6709\u4e9b\u4e1c\u897f\u86ee\u6709\u7528\u7684
\u5173\u4e8e\u8003\u8bd5\uff1a
\u6700\u540e\u590d\u4e60\u8d77\u6765\u4e1c\u897f\u8fd8\u633a\u591a\uff0c\u53c8\u662f\u95ed\u5377\uff0c\u4e34\u65f6\u80cc\u5f88\u6709\u53ef\u80fd\u8bb0\u5fc6\u4e0d\u5b8c\u5168\uff0c\u5bfc\u81f4\u8003\u8bd5\u7684\u65f6\u5019\u6a21\u68f1\u4e24\u53ef\uff0c\u7b80\u7b54\u9898\u5199\u7684\u4e1c\u4e00\u5757\u3001\u897f\u4e00\u5757\uff08\u5c31\u662f\u5728\u8bf4\u6211\u81ea\u5df1\uff09
98\u4e0a\u9762\u6709\u633a\u591a\u5386\u5e74\u5377\uff0c\u53ef\u4ee5\u53bb\u62df\u5408\u4e00\u4e0b\uff1b\u5370\u8c61\u4e2d\u5f53\u65f6\u8003\u7684\u5f88\u591a\u90fd\u5728\u5386\u5e74\u5377\u4e2d\u51fa\u73b0\u8fc7
","tags":["class/DIP"]},{"location":"CS/DIP/DIP_Review/","title":"\u671f\u672b\u590d\u4e60","text":""},{"location":"CS/DIP/DIP_Review/#introduction","title":"Introduction","text":""},{"location":"CS/DIP/DIP_Review/#ch1","title":"Ch1","text":"
- \u4e0d\u540c\u5f62\u5f0f\u7684\u6210\u50cf
\u7ea6 8764 \u4e2a\u5b57 23 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 44 \u5206\u949f
"},{"location":"CS/DIP/DIP_Review/#_1","title":"* \u6210\u50cf\u8fc7\u7a0b","text":""},{"location":"CS/DIP/DIP_Review/#_2","title":"\u5149\u5708\u5bf9\u4e8e\u6210\u50cf\u7684\u5f71\u54cd","text":"(1)\u5f53\u4f7f\u7528\u6570\u7801\u76f8\u673a\u62cd\u6444\u666f\u7269\u65f6\uff0c\u666f\u7269\u53cd\u5c04\u7684\u5149\u7ebf\u901a\u8fc7\u6570\u7801\u76f8\u673a\u7684\u955c\u5934\u900f\u5c04\u5230CCD\u4e0a\u3002\n(2)\u5f53CCD\u66dd\u5149\u540e\uff0c\u5149\u7535\u4e8c\u6781\u7ba1\u53d7\u5230\u5149\u7ebf\u7684\u6fc0\u53d1\u800c\u91ca\u653e\u51fa\u7535\u8377\uff0c\u751f\u6210\u611f\u5149\u5143\u4ef6\u7684\u7535\u4fe1\u53f7\u3002\n(3) CCD\u63a7\u5236\u82af\u7247\u5229\u7528\u611f\u5149\u5143\u4ef6\u4e2d\u7684\u63a7\u5236\u4fe1\u53f7\u7ebf\u8def\u5bf9\u53d1\u5149\u4e8c\u6781\u7ba1\u4ea7\u751f\u7684\u7535\u6d41\u8fdb\u884c\u63a7\u5236\uff0c\u7531\u7535\u6d41\u4f20\u8f93\u7535\u8def\u8f93\u51fa\uff0cCCD\u4f1a\u5c06\u4e00\u6b21\u6210\u50cf\u4ea7\u751f\u7684\u7535\u4fe1\u53f7\u6536\u96c6\u8d77\u6765\uff0c\u7edf\u4e00\u8f93\u51fa\u5230\u653e\u5927\u5668\u3002\n(4)\u7ecf\u8fc7 \u653e\u5927\u548c\u6ee4\u6ce2\u540e \u7684\u7535\u4fe1\u53f7\u88ab\u4f20\u9001\u5230ADC\uff0c\u7531ADC\u5c06\u7535\u4fe1\u53f7\uff08\u6a21\u62df\u4fe1\u53f7\uff09\u8f6c\u6362\u4e3a\u6570\u5b57\u4fe1\u53f7\uff0c\u6570\u503c\u7684\u5927\u5c0f\u548c\u7535\u4fe1\u53f7\u7684\u5f3a\u5ea6\u4e0e\u7535\u538b\u7684\u9ad8\u4f4e\u6210\u6b63\u6bd4\uff0c\u8fd9\u4e9b\u6570\u503c\u5176\u5b9e\u4e5f\u5c31\u662f\u56fe\u50cf\u7684\u6570\u636e\u3002\n(5)\u6b64\u65f6\u8fd9\u4e9b\u56fe\u50cf\u6570\u636e\u8fd8\u4e0d\u80fd\u76f4\u63a5\u751f\u6210\u56fe\u50cf\uff0c\u8fd8\u8981\u8f93\u51fa\u5230DSP\uff08\u6570\u5b57\u4fe1\u53f7\u5904\u7406\u5668\uff09\u4e2d\uff0c\u5728DSP\u4e2d\uff0c\u5c06\u4f1a\u5bf9\u8fd9\u4e9b\u56fe\u50cf\u6570\u636e\u8fdb\u884c\u8272\u5f69\u6821\u6b63\u3001\u767d\u5e73\u8861\u5904\u7406\uff0c\u5e76\u7f16\u7801\u4e3a\u6570\u7801\u76f8\u673a\u6240\u652f\u6301\u7684\u56fe\u50cf\u683c\u5f0f\u3001\u5206\u8fa8\u7387\uff0c\u7136\u540e\u624d\u4f1a\u88ab\u5b58\u50a8\u4e3a\u56fe\u50cf\u6587\u4ef6\u3002\n(6)\u5f53\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u56fe\u50cf\u6587\u4ef6\u5c31\u4f1a\u88ab\u4fdd\u5b58\u5230\u5b58\u50a8\u5668\u4e0a,\u6211\u4eec\u5c31\u53ef\u4ee5\u6b23\u8d4f\u4e86\u3002\n
\u5149\u5708\u5b54\u5f84\u2f24\u7684\u65f6\u5019\uff0c\u4f1a\u5bfc\u81f4\u6a21\u7cca\uff1b
\u5149\u5708\u5b54\u5f84\u8fc7\u2f29\u7684\u65f6\u5019\uff0c\u53ef\u901a\u8fc7\u7684\u5149\u7ebf\u5c31\u5f88\u5c11\uff0c\u5bfc\u81f4\u5149\u5f3a\u592a\u5f31\uff0c\u540c\u65f6\u5f53\u5b54\u5f84\u2f29\u5230\u2f00\u5b9a\u7a0b\u5ea6\u65f6\uff0c\u4f1a\u4ea7\u2f63\u884d\u5c04\u73b0\u8c61\u3002
"},{"location":"CS/DIP/DIP_Review/#_3","title":"\u5f25\u6563\u5706\u7684\u5b9a\u4e49","text":"\u901a\u8fc7\u4f7f\u2f64\u900f\u955c\u53ef\u4ee5\u4f1a\u805a\u66f4\u591a\u7684\u5149\u7ebf\u5230\u2f00\u4e2a\u6210\u50cf\u70b9\uff0c\u53ea\u662f\u53ea\u6709\u5728\u7279\u6b8a\u7684\u4f4d\u7f6e\u4e0a\u624d\u80fd\u8fbe\u5230\u8fd9\u4e2a\u2f6c\u6807\uff0c\u4f4d\u4e8e\u5408\u9002\u8ddd\u79bb\u7684\u7269\u4f53\u70b9\u53ef\u4ee5\u6210\u6e05\u6670\u50cf\uff0c\u5176\u4ed6\u7684\u70b9\u5219\u4f1a\u4ea7\u2f63\u5f25\u6563\u5706\u3002\u5f25\u6563\u5706\u662f\u6307\u5728\u7126\u70b9\u524d\u540e\uff0c\u5149\u7ebf\u5f00\u59cb\u805a\u96c6\u548c\u6269\u6563\uff0c\u70b9\u7684\u5f71\u50cf\u53d8\u6a21\u7cca\uff0c\u5f62\u6210\u2f00\u4e2a\u6269\u2f24\u7684\u5706\u3002
\u5982\u679c\u5f25\u6563\u5706\u7684\u76f4\u5f84\u2f29\u4e8e\u2f08\u773c\u7684\u9274\u522b\u80fd\u2f12\uff0c\u5728\u2f00\u5b9a\u8303\u56f4\u5185\u5b9e\u9645\u5f71\u50cf\u4ea7\u2f63\u7684\u6a21\u7cca\u662f\u4e0d\u80fd\u8fa8\u8ba4\u7684\u3002\u4e0d\u80fd\u8fa8\u8ba4\u7684\u76f4\u5f84\u53eb\u505a\u5bb9\u8bb8\u5f25\u6563\u5706\u3002
"},{"location":"CS/DIP/DIP_Review/#_4","title":"**\u5149\u5708\u5bf9\u4e8e\u666f\u6df1\u7684\u5f71\u54cd","text":"\u7126\u70b9\u524d\u540e\u5404\u6709\u2f00\u4e2a\u5bb9\u8bb8\u5f25\u6563\u5706\uff0c\u4ed6\u4eec\u4e4b\u95f4\u7684\u8ddd\u79bb\u53eb\u505a\u666f\u6df1\u3002\u666f\u6df1\u968f\u955c\u5934\u7684\u7126\u8ddd\u3001\u5149\u5708\u503c\u3001\u62cd\u6444\u8ddd\u79bb\u2f7d\u53d8\u5316
(1)\u3001\u955c\u5934\u5149\u5708 \u5149\u5708\u8d8a\u2f24\uff0c\u666f\u6df1\u8d8a\u2f29\uff1b\u5149\u5708\u8d8a\u2f29\uff0c\u666f\u6df1\u8d8a\u2f24\uff1b (2)\u3001\u955c\u5934\u7126\u8ddd \u955c\u5934\u7126\u8ddd\u8d8a\u2ed3\uff0c\u666f\u6df1\u8d8a\u2f29\uff1b\u7126\u8ddd\u8d8a\u77ed\uff0c\u666f\u6df1\u8d8a\u2f24\uff1b (3)\u3001\u62cd\u6444\u8ddd\u79bb \u8ddd\u79bb\u8d8a\u8fdc\uff0c\u666f\u6df1\u8d8a\u2f24\uff1b\u8ddd\u79bb\u8d8a\u8fd1\uff0c\u666f\u6df1\u8d8a\u2f29
"},{"location":"CS/DIP/DIP_Review/#_5","title":"\u5f69\u2f8a\u548c\u6d88\u2f8a\u7684\u5b9a\u4e49","text":"\u5f69\u2f8a\u662f\u6307\u7ea2\u3001\u2ee9\u3001\u84dd\u7b49\u5355\u2f8a\u4ee5\u53ca\u5b83\u4eec\u7684\u6df7\u5408\u2f8a\u3002\u5f69\u2f8a\u7269\u4f53\u5bf9\u5149\u8c31\u5404\u6ce2\u2ed3\u7684\u53cd\u5c04\u5177\u6709\u9009\u62e9\u6027\uff0c\u6240\u4ee5\u5b83\u4eec\u5728\u2f69\u5149\u7167\u5c04\u4e0b\u5448\u73b0\u51fa\u4e0d\u540c\u7684\u989c\u2f8a\u3002
\u6d88\u2f8a\uff0c\u4e5f\u5c31\u662f\u7070\u5ea6\uff0c\u662f\u6307\u2f69\u2f8a\uff0c\u2fca\u2f8a\u4ee5\u53ca\u5404\u79cd\u6df1\u6d45\u4e0d\u540c\u7684\u7070\u2f8a\u3002\u6d88\u2f8a\u7269\u4f53\u5bf9\u5149\u8c31\u5404\u6ce2\u2ed3\u7684\u53cd\u5c04\u6ca1\u6709\u9009\u62e9\u6027\uff0c\u5b83\u4eec\u662f\u4e2d\u6027\u2f8a\u3002
\u7ea2\u7eff\u84dd\u5149\u7684\u6ce2\u2ed3
\u7ea2 > \u7eff > \u84dd
"},{"location":"CS/DIP/DIP_Review/#_6","title":"\u89c6\u2f79\u819c\u7684\u4e24\u79cd\u7ec6\u80de","text":"\u89c6\u2f79\u819c\u4e0a\u5206\u5e03\u7740\u4e24\u79cd\u89c6\u89c9\u7ec6\u80de\uff0c\u2f00\u79cd\u4e3a\u6746\u72b6\u4f53\uff0c\u53e6\u2f00\u79cd\u4e3a\u9525\u72b6\u4f53\u3002\u6746\u72b6\u4f53\u7ec6\u80de\u2f50\u8f83\u591a\uff0c\u2f24\u7ea6\u6709\u4e0a\u4ebf\u4e2a\uff0c\u5b83\u5bf9\u5149\u6781\u4e3a\u7075\u654f\uff0c\u4f46\u6ca1\u6709\u533a\u5206\u2f8a\u5f69\u7684\u80fd\u2f12\u3002\u9525\u72b6\u4f53\u7ec6\u80de\u5219\u53ea\u6709\u516d\u3001\u4e03\u767e\u4e07\u4e2a\uff0c\u5b83\u8981\u5728\u8f83\u5f3a\u7684\u7167\u5ea6\u4e0b\u624d\u80fd\u6fc0\u53d1\uff0c\u5b83\u7684\u5b58\u5728\u4f7f\u6211\u4eec\u80fd\u591f\u8fa8\u522b\u5404\u79cd\u4e0d\u540c\u7684\u989c\u2f8a\u3002
\u6746\u72b6\uff1a\u591a\uff0c\u5bf9\u5149\u7075\u654f\uff0c\u4f46\u662f\u4e0d\u80fd\u533a\u5206\u2f8a\u5f69 \u9525\u72b6\uff1a\u5c11\uff0c\u5f3a\u5149\u624d\u80fd\u6fc0\u53d1\uff0c\u2f64\u6765\u533a\u5206\u2f8a\u5f69
"},{"location":"CS/DIP/DIP_Review/#_7","title":"\u4e09\u539f\u2f8a\u5f62\u6210\u7684\u539f\u7406","text":"\u5728\u89c6\u2f79\u819c\u4e0a\u5b58\u5728\u7740\u4e09\u79cd\u5206\u522b\u5bf9\u7ea2\u3001\u7eff\u548c\u84dd\u5149\u7ebf\u7684\u6ce2\u2ed3\u7279\u522b\u654f\u611f\u7684\u89c6\u9525\u7ec6\u80de\u6216\u76f8\u5e94\u7684\u611f\u5149\u2f8a\u7d20\uff0c\u5f53\u4e0d\u540c\u6ce2\u2ed3\u7684\u5149\u7ebf\u8fdb\u2f0a\u2f08\u773c\u65f6\uff0c\u4e0e\u4e4b\u76f8\u7b26\u6216\u76f8\u8fd1\u7684\u89c6\u9525\u7ec6\u80de\u53d1\u2f63\u4e0d\u540c\u7a0b\u5ea6\u7684\u5174\u594b\uff0c\u4e8e\u662f\u5728\u2f24\u8111\u4ea7\u2f63\u76f8\u5e94\u7684\u2f8a\u89c9\uff1b\u4e09\u79cd\u89c6\u9525\u7ec6\u80de\u82e5\u53d7\u5230\u540c\u7b49\u7a0b\u5ea6\u7684\u523a\u6fc0\uff0c\u5219\u4ea7\u2f63\u6d88\u2f8a\u3002
"},{"location":"CS/DIP/DIP_Review/#_8","title":"\u611f\u77e5\u7684\u4f18\u5148\u7a0b\u5ea6\u548c\u654f\u611f\u5ea6","text":"\u4f18\u5148\u7a0b\u5ea6\uff1a\u540c\u7b49\u6761\u4ef6\u4e0b\uff0c\u2f08\u4eec\u5f80\u5f80\u4f1a\u6ce8\u610f\u5230\u2f8a\u8c03\uff08Hue, H\uff09\u7684\u53d8\u5316\uff0c\u7136\u540e\u662f\u9971\u548c\u5ea6\uff08Saturation, S\uff09\uff0c\u7136\u540e\u662f\u4eae\u5ea6\uff08Value, V\uff09\u3002\u8c03\u4fdd\u4eae HSV
\u654f\u611f\u5ea6\uff1a\u2f08\u773c\u5bf9\u4e8e\u4eae\u5ea6\u7684\u53d8\u5316\u6700\u4e3a\u654f\u611f\uff0c\u5206\u8fa8\u80fd\u2f12\u6700\u5f3a\u3002\u6070\u597d\u4e0e\u2f08\u773c\u7684\u2fbc\u52a8\u6001\u80fd\u2f12\u76f8\u5339\u914d\u3002
"},{"location":"CS/DIP/DIP_Review/#_9","title":"* \u4e0e\u8bbe\u5907\u76f8\u5173\u548c\u2f46\u5173\u7684\u989c\u2f8a\u6a21\u578b","text":"
\u4e0e\u8bbe\u5907\u76f8\u5173\u7684\u989c\u2f8a\u6a21\u578b\uff1aRGB, CMY, HSV
\u4e0e\u8bbe\u5907\u2f46\u5173\u7684\u989c\u2f8a\u6a21\u578b\uff1aCIE XYZ, CIE L*a*b\u548c CIE YUV
HSV\u66f4\u63a5\u8fd1\u2f08\u7684\u611f\u77e5
"},{"location":"CS/DIP/DIP_Review/#rgb","title":"RGB","text":"RBG \u989c\u8272\u6a21\u578b\u662f\u4e09\u7ef4\u76f4\u89d2\u5750\u6807\u989c\u8272\u7cfb\u7edf\u4e2d\u7684\u4e00\u4e2a\u5355\u4f4d\u6b63\u65b9\u4f53\u5728\u6b63\u65b9\u4f53\u7684\u4e3b\u5bf9\u89d2\u7ebf\u4e0a\uff0c\u5404\u539f\u8272\u7684\u91cf\u76f8\u7b49\uff0c\u4ea7\u751f\u7531\u6697\u5230\u4eae\u7684\u767d\u8272\uff0c\u5373\u7070\u5ea6\u3002\uff080\uff0c0\uff0c0\uff09\u4e3a\u9ed1\uff0c\uff081\uff0c1\uff0c1\uff09\u4e3a\u767d\uff0c\u6b63\u65b9\u4f53\u7684\u5176\u4ed66\u4e2a\u89d2\u70b9\u5206\u522b\u4e3a\u7ea2\u3001\u9ec4\u3001\u7eff\u3001\u9752\u3001\u84dd\u548c\u54c1\u7ea2\u3002RGB\u989c\u8272\u6a21\u578b\u6784\u6210\u7684\u989c\u8272\u7a7a\u95f4\u662fCIE\u539f\u8272\u7a7a\u95f4\u7684\u4e00\u4e2a\u771f\u5b50\u96c6\u3002RGB\u989c\u8272\u6a21\u578b\u901a\u5e38\u7528\u4e8e\u5f69\u8272\u9634\u6781\u5c04\u7ebf\u7ba1\u548c\u5f69\u8272\u5149\u6805\u56fe\u5f62\u663e\u793a\u5668\uff08\u8ba1\u7b97\u673a\u548c\u7535\u89c6\u673a\u91c7\u7528\uff09\u3002
"},{"location":"CS/DIP/DIP_Review/#hsv","title":"HSV","text":"HSV\u989c\u8272\u7a7a\u95f4\u662f\u4ece\u4eba\u7684\u89c6\u89c9\u7cfb\u7edf\u51fa\u53d1\uff0c\u7528\u8272\u8c03\uff08Hue)\u3001\u8272\u9971\u548c\u5ea6\uff08Saturation\uff09\u548c\u4eae\u5ea6\uff08Intensity\uff0c\u6216\u8005Value\uff09\u6765\u5706\u9525\u7684\u9876\u9762\u5bf9\u5e94\u4e8eV=1\uff0c\u5b83\u5305\u542bRGB\u6a21\u578b\u4e2d\u7684R=1\uff0cG=1\uff0cB=1\u4e09\u4e2a\u9762\uff0c\u6545\u6240\u4ee3\u8868\u7684\u989c\u8272\u8f83\u4eae\u3002\u8272\u5ea6H\u7531\u7ed5V\u8f74\u7684\u65cb\u8f6c\u89d2\u7ed9\u5b9a\u3002\u7ea2\u8272\u5bf9\u5e94\u4e8e\u89d2\u5ea60o\uff0c\u7eff\u8272\u5bf9\u5e94\u4e8e\u89d2\u5ea6120o\uff0c\u84dd\u8272\u5bf9\u5e94\u4e8e\u89d2\u5ea6240o\u3002\u63cf\u8ff0\u989c\u8272\u3002\u5728\u5706\u9525\u7684\u9876\u70b9\u5904\uff0cV=0\uff0cH\u548cS\u65e0\u5b9a\u4e49\uff0c\u4ee3\u8868\u9ed1\u8272\u3002
"},{"location":"CS/DIP/DIP_Review/#_10","title":"\u52a0\u8272 \u51cf\u8272(\u52a0\u8272\u7684\u8865\u8272)","text":"RGB CMY \u5f69\u8272\u5370\u5237\u6216\u8005\u5f69\u8272\u6253\u5370\u7684\u7eb8\u5f20\u4e0d\u80fd\u53d1\u5c04\u5149\u7ebf\uff0c\u56e0\u800c\u5370\u5237\u673a\u6216\u6253\u5370\u673a\u5c31\u53ea\u80fd\u4f7f\u7528\u4e00\u4e9b\u80fd\u591f\u5438\u6536\u7279\u5b9a\u5149\u6ce2\u800c\u53cd\u5c04\u5176\u4ed6\u5149\u6ce2\u7684\u6cb9\u58a8\u6216\u8005\u989c\u8272\u3002\u6cb9\u58a8\u6216\u989c\u6599\u76843\u79cd\u57fa\u8272\u662f\u4ee5\u7ea2\u3001\u7eff\u3001\u84dd\u4e09\u8272\u7684\u8865\u8272\u9752\uff08Cyan\uff09\u3001\u54c1\u7ea2\uff08Magenta\uff09\u3001\u9ec4\uff08Yellow\uff09\u4e3a\u57fa\u8272\u3002\u7528CMY\u6a21\u578b\u4ea7\u751f\u7684\u989c\u8272\u79f0\u4e3a\u76f8\u51cf\u8272\uff0c\u662f\u56e0\u4e3a\u5b83\u51cf\u6389\u4e86\u4e3a\u89c6\u89c9\u7cfb\u7edf\u8bc6\u522b\u989c\u8272\u6240\u9700\u8981\u7684\u53cd\u5c04\u5149
"},{"location":"CS/DIP/DIP_Review/#jpeg","title":"JPEG\u7684\u538b\u7f29\u7684\u57fa\u672c\u7b56\u7565\u4ee5\u53ca\u4f18\u70b9","text":"\u538b\u7f29\u7b56\u7565:\u6839\u636e\u538b\u7f29\u2f50\u8981\u6c42\uff0c\u4ece\u2fbc\u9891\u5230\u4f4e\u9891\u9010\u6b65\u524a\u51cf\u4fe1\u606f
\u597d\u5904\uff1a
"},{"location":"CS/DIP/DIP_Review/#_11","title":"\u56fe\u50cf\u683c\u5f0f","text":"
- \u2fbc\u9891\u4fe1\u606f\u5360\u2f64\u5b58\u50a8\u7a7a\u95f4\u2f24\uff0c\u51cf\u5c11\u2fbc\u9891\u4fe1\u606f\u66f4\u5bb9\u6613\u83b7\u5f97\u2fbc\u538b\u7f29\u2f50\uff1b
- \u4f4e\u9891\u4fe1\u606f\u53ef\u4ee5\u4fdd\u7559\u7269\u4f53\u7684\u57fa\u672c\u8f6e\u5ed3\u548c\u2f8a\u5f69\u5206\u5e03\uff0c\u6700\u2f24\u9650\u5ea6\u7ef4\u6301\u56fe\u50cf\u8d28\u91cf\u3002
- \u9002\u5408\u2f64\u4e8e\u4e92\u8054\u2f79
\u76ee\u7684\uff1a\u5b58\u50a8\u56fe\u50cf\u4fe1\u606f \u56fe\u50cf\u7279\u70b9\uff1a\u4ee5\u50cf\u7d20\u4e3a\u5355\u4f4d\u3001\u77e9\u5f62\u533a\u57df\u3001\u4fe1\u606f\u91cf\u2f24
\u6709\u4e9b\u2f42\u4ef6\u683c\u5f0f\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u6709\u5173\uff1awindows\u3001unix\u3001mac \u7f16\u7801\u2f45\u5f0f\uff1a\u2f46\u538b\u7f29\uff08BMP\uff09\u3001\u2f46\u635f\u538b\u7f29(PNG,GIF)\u3001\u6709\u635f\u538b\u7f29(JPEG)
\u5e38\u2f64\u7684\u56fe\u50cf\u2f42\u4ef6\u683c\u5f0f\uff1aBMP\u3001JPEG\u3001TIFF\u3001GIF\u3001PNG\u2026\u2026
"},{"location":"CS/DIP/DIP_Review/#bmp","title":"BMP","text":"Windows\u64cd\u4f5c\u7cfb\u7edf\u7684\u6807\u51c6\u6587\u4ef6\u683c\u5f0f\u4e4b\u4e00\uff0c\u6709\u65f6\u5019\u4e5f\u5b58\u4e3a.dib\u6587\u4ef6\u5927\u90e8\u5206BMP\u6587\u4ef6\u662f\u4e0d\u538b\u7f29\u7684\u5f62\u5f0f\u4f46\u5b83\u672c\u8eab\u8fd8\u662f\u652f\u6301\u56fe\u50cf\u538b\u7f29\u7684\uff0c\u5982rle\u683c\u5f0f\uff08\u884c\u7a0b\u957f\u5ea6\u7f16\u7801\uff0crunlength encoding\uff09\u538b\u7f29\u683c\u5f0f\u7b49
"},{"location":"CS/DIP/DIP_Review/#image-file-header","title":"Image file header | \u6587\u4ef6\u5934","text":"
bfType
\u8bf4\u660e\u6587\u4ef6\u7684\u7c7b\u578b\uff0c\u8be5\u503c\u5fc5\u9700\u662f0x4D42\uff0c\u4e5f\u5c31\u662f\u5b57\u7b26'BM'\u3002
bfSize
\u8bf4\u660e\u8be5\u4f4d\u56fe\u6587\u4ef6\u7684\u5927\u5c0f\uff0c\u7528\u5b57\u8282\u4e3a\u5355\u4f4d
bfReserved1
\u4fdd\u7559\uff0c\u5fc5\u987b\u8bbe\u7f6e\u4e3a0
bfReserved2
\u4fdd\u7559\uff0c\u5fc5\u987b\u8bbe\u7f6e\u4e3a0"},{"location":"CS/DIP/DIP_Review/#image-information-header","title":"Image information header | \u4fe1\u606f\u5934","text":"
bfOffBits
\u8bf4\u660e\u4ece\u6587\u4ef6\u5934\u5f00\u59cb\u5230\u5b9e\u9645\u7684\u56fe\u8c61\u6570\u636e\u4e4b\u95f4\u7684\u5b57\u8282\u7684\u504f\u79fb\u91cf\u3002\u8fd9\u4e2a\u53c2\u6570\u662f\u975e\u5e38\u6709\u7528\u7684\uff0c\u56e0\u4e3a\u4f4d\u56fe\u4fe1\u606f\u5934\u548c\u8c03\u8272\u677f\u7684\u957f\u5ea6\u4f1a\u6839\u636e\u4e0d\u540c\u60c5\u51b5\u800c\u53d8\u5316\uff0c\u6240\u4ee5\u4f60\u53ef\u4ee5\u7528\u8fd9\u4e2a\u504f\u79fb\u503c\u8fc5\u901f\u7684\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u5230\u4f4d\u6570\u636e\u3002typedef struct tagBITMAPINFOHEADER{\n// \u957f\u5ea6\u56fa\u5b9a 40\nDWORD biSize;\nLONG biWidth;\nLONG biHeight;\nWORD biPlanes;\nWORD biBitCount\nDWORD biCompression;\nDWORD biSizeImage;\nLONG biXPelsPerMeter;\nLONG biYPelsPerMeter;\nDWORD biClrUsed;\nDWORD biClrImportant;\n} BITMAPINFOHEADER;\n
biSize
How many bytes are needed to define \u8bf4\u660e\u4e0a\u8ff0\u7ed3\u6784\u6240\u9700\u8981\u7684\u5b57\u6570\u3002
biWidth
\u8bf4\u660e\u56fe\u8c61\u7684\u5bbd\u5ea6\uff0c\u4ee5\u8c61\u7d20\u4e3a\u5355\u4f4d\u3002
biHeight
\u8bf4\u660e\u56fe\u8c61\u7684\u9ad8\u5ea6\uff0c\u4ee5\u8c61\u7d20\u4e3a\u5355\u4f4d\u3002\u5982\u679c\u8be5\u503c\u662f\u4e00\u4e2a\u6b63\u6570\uff0c\u8bf4\u660e\u56fe\u50cf\u662f\u5012\u5411\u7684\uff0c\u5982\u679c\u8be5\u503c\u662f\u4e00\u4e2a\u8d1f\u6570\uff0c\u5219\u8bf4\u660e\u56fe\u50cf\u662f\u6b63\u5411\u7684\u3002\u5927\u591a\u6570\u7684BMP\u6587\u4ef6\u90fd\u662f\u5012\u5411\u7684\u4f4d\u56fe\uff0c\u4e5f\u5c31\u662f\u65f6\uff0c\u9ad8\u5ea6\u503c\u662f\u4e00\u4e2a\u6b63\u6570\u3002
biPlanes
\u4e3a\u76ee\u6807\u8bbe\u5907\u8bf4\u660e\u4f4d\u9762\u6570\uff0c\u5176\u503c\u5c06\u603b\u662f\u88ab\u8bbe\u4e3a1\u3002
biBitCount
\u8bf4\u660e\u6bd4\u7279\u6570/\u8c61\u7d20\uff0c\u5176\u503c\u4e3a1\u30014\u30018\u300116\u300124\u3001\u621632\u3002\u4f46\u662f\u7531\u4e8e\u6211\u4eec\u5e73\u65f6\u7528\u5230\u7684\u56fe\u50cf\u7edd\u5927\u90e8\u5206\u662f24\u4f4d\u548c32\u4f4d\u7684\uff0c\u6240\u4ee5\u6211\u4eec\u8ba8\u8bba\u8fd9\u4e24\u7c7b\u56fe\u50cf\u3002
biCompression
\u8bf4\u660e\u56fe\u8c61\u6570\u636e\u538b\u7f29\u7684\u7c7b\u578b\uff0c\u6211\u4eec\u53ea\u8ba8\u8bba\u6ca1\u6709\u538b\u7f29\u7684\u7c7b\u578b\uff1aBI_RGB\u3002
biSizeImage
\u8bf4\u660e\u56fe\u8c61\u7684\u5927\u5c0f\uff0c\u4ee5\u5b57\u8282\u4e3a\u5355\u4f4d\u3002\u5f53\u7528BI_RGB\u683c\u5f0f\u65f6\uff0c\u53ef\u8bbe\u7f6e\u4e3a0\u3002biSizeImage=biWidth\u2019 \u00d7 biHeight biWidth` \u5fc5\u987b\u662f 4 \u7684\u500d\u6570
biXPelsPerMeter
\u8bf4\u660e\u6c34\u5e73\u5206\u8fa8\u7387\uff0c\u7528\u8c61\u7d20/\u7c73\u8868\u793a\u3002
biYPelsPerMeter
\u8bf4\u660e\u5782\u76f4\u5206\u8fa8\u7387\uff0c\u7528\u8c61\u7d20/\u7c73\u8868\u793a\u3002
biClrUsed
\u8bf4\u660e\u4f4d\u56fe\u5b9e\u9645\u4f7f\u7528\u7684\u5f69\u8272\u8868\u4e2d\u7684\u989c\u8272\u7d22\u5f15\u6570\uff08\u8bbe\u4e3a0\u7684\u8bdd\uff0c\u5219\u8bf4\u660e\u4f7f\u7528\u6240\u6709\u8c03\u8272\u677f\u9879\uff09\u3002"},{"location":"CS/DIP/DIP_Review/#palette","title":"Palette | \u8c03\u8272\u677f","text":"| \u542b\u4e49 |
biClrImportant
\u8bf4\u660e\u5bf9\u56fe\u8c61\u663e\u793a\u6709\u91cd\u8981\u5f71\u54cd\u7684\u989c\u8272\u7d22\u5f15\u7684\u6570\u76ee\uff0c\u5982\u679c\u662f0\uff0c\u8868\u793a\u90fd\u91cd\u8981\u3002\u6709\u4e00\u4e2a\u957f\u5bbd\u5404\u4e3a200\u4e2a\u8c61\u7d20\uff0c\u989c\u8272\u6570\u4e3a16\u8272\u7684\u5f69\u8272\u56fe\uff0c\u6bcf\u4e00\u4e2a\u8c61\u7d20\u90fd\u7528R\u3001G\u3001B\u4e09\u4e2a\u5206\u91cf\u8868\u793a\u3002\u56e0\u4e3a\u6bcf\u4e2a\u5206\u91cf\u6709256\u4e2a\u7ea7\u522b\uff0c\u8981\u75288\u4f4d(bit)\uff0c\u5373\u4e00\u4e2a\u5b57\u8282(byte)\u6765\u8868\u793a\uff0c\u6240\u4ee5\u6bcf\u4e2a\u8c61\u7d20\u9700\u8981\u75283\u4e2a\u5b57\u8282\u3002\u6574\u4e2a\u56fe\u8c61\u8981\u7528200\u00d7200\u00d73\uff0c\u7ea6120k\u5b57\u8282\uff0c\u53ef\u4e0d\u662f\u4e00\u4e2a\u5c0f\u6570\u76ee\u5440\uff01
\u5982\u679c\u6211\u4eec\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\uff0c\u5c31\u80fd\u7701\u7684\u591a\u3002\u56e0\u4e3a\u662f\u4e00\u4e2a16\u8272\u56fe\uff0c\u4e5f\u5c31\u662f\u8bf4\u8fd9\u5e45\u56fe\u4e2d\u6700\u591a\u53ea\u670916\u79cd\u989c\u8272\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u4e2a\u8868\uff1a\u8868\u4e2d\u7684\u6bcf\u4e00\u884c\u8bb0\u5f55\u4e00\u79cd\u989c\u8272\u7684R\u3001G\u3001B\u503c\u3002\u8fd9\u6837\u5f53\u6211\u4eec\u8868\u793a\u4e00\u4e2a\u8c61\u7d20\u7684\u989c\u8272\u65f6\uff0c\u53ea\u9700\u8981\u6307\u51fa\u8be5\u989c\u8272\u662f\u5728\u7b2c\u51e0\u884c\uff0c\u5373\u8be5\u989c\u8272\u5728\u8868\u4e2d\u7684\u7d22\u5f15\u503c\u3002\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5982\u679c\u8868\u7684\u7b2c0\u884c\u4e3a255\uff0c0\uff0c0(\u7ea2\u8272)\uff0c\u90a3\u4e48\u5f53\u67d0\u4e2a\u8c61\u7d20\u4e3a\u7ea2\u8272\u65f6\uff0c\u53ea\u9700\u8981\u6807\u660e0\u5373\u53ef\u3002\u8fd9\u5f20R\u3001G\u3001B\u7684\u8868\uff0c\u5c31\u662f\u6211\u4eec\u5e38\u8bf4\u7684\u8c03\u8272\u677f(Palette)\uff0c\u53e6\u4e00\u79cd\u53eb\u6cd5\u662f\u989c\u8272\u67e5\u627e\u8868LUT(Look Up Table)\uff0c\u4f3c\u4e4e\u66f4\u786e\u5207\u4e00\u4e9b\u3002Windows\u4f4d\u56fe\u4e2d\u4fbf\u7528\u5230\u4e86\u8c03\u8272\u677f\u6280\u672f\u3002\u5176\u5b9e\u4e0d\u5149\u662fWindows\u4f4d\u56fe\uff0c\u8bb8\u591a\u56fe\u8c61\u6587\u4ef6\u683c\u5f0f\u5982pcx\u3001tif\u3001gif\u7b49\u90fd\u7528\u5230\u4e86\u3002\u6240\u4ee5\u5f88\u597d\u5730\u638c\u63e1\u8c03\u8272\u677f\u7684\u6982\u5ff5\u662f\u5341\u5206\u6709\u7528\u7684\u3002
"},{"location":"CS/DIP/DIP_Review/#image-data","title":"Image data | \u56fe\u50cf\u6570\u636e","text":"
Palette
N * 4 bytes. \u6bcf\u4e00\u4e2a\u5143\u7d20\u90fd\u6709\u56db\u4e2a\u6bd4\u7279\uff0c\u5206\u522b\u5b58\u50a8\u84dd\u7eff\u7ea2\u7684 RGB \u503c\u548c\u4e00\u4e2a reserved byte.(1) \u6bcf\u4e00\u884c\u7684\u5b57\u8282\u6570\u5fc5\u987b\u662f4\u7684\u6574\u500d\u6570\uff0c\u5982\u679c\u4e0d\u662f\uff0c\u5219\u9700\u8981\u8865\u9f50\u3002\u8fd9\u5728\u524d\u9762\u4ecb\u7ecdbiSizeImage\u65f6\u5df2\u7ecf\u63d0\u5230\u4e86\u3002
(2) \u4e00\u822c\u6765\u8bf4\uff0c.bMP\u6587\u4ef6\u7684\u6570\u636e\u4ece\u4e0b\u5230\u4e0a\uff0c\u4ece\u5de6\u5230\u53f3\u7684\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4ece\u6587\u4ef6\u4e2d\u6700\u5148\u8bfb\u5230\u7684\u662f\u56fe\u8c61\u6700\u4e0b\u9762\u4e00\u884c\u7684\u5de6\u8fb9\u7b2c\u4e00\u4e2a\u8c61\u7d20\uff0c\u7136\u540e\u662f\u5de6\u8fb9\u7b2c\u4e8c\u4e2a\u8c61\u7d20\u2026\u2026\u63a5\u4e0b\u6765\u662f\u5012\u6570\u7b2c\u4e8c\u884c\u5de6\u8fb9\u7b2c\u4e00\u4e2a\u8c61\u7d20\uff0c\u5de6\u8fb9\u7b2c\u4e8c\u4e2a\u8c61\u7d20\u2026\u2026\u4f9d\u6b21\u7c7b\u63a8 \uff0c\u6700\u540e\u5f97\u5230\u7684\u662f\u6700\u4e0a\u9762\u4e00\u884c\u7684\u6700\u53f3\u4e00\u4e2a\u8c61\u7d20\u3002
"},{"location":"CS/DIP/DIP_Review/#rle","title":"RLE \u4e8c\u503c\u56fe\u50cf\u7f16\u7801","text":""},{"location":"CS/DIP/DIP_Review/#ch2","title":"Ch2","text":""},{"location":"CS/DIP/DIP_Review/#_12","title":"\u2f06\u503c\u56fe\u50cf\u7684\u4f18\u7f3a\u70b9","text":"
- \u6bcf\u4e00\u884c\u90fd\u7528subterm\u8868\u793a\uff0c\u7b2c\u4e00\u4e2a\u4e3a\u884c\u53f7\uff0c
\u4f18\u70b9\uff1a
- \u66f4\u2f29\u7684\u5185\u5b58\u9700\u6c42
- \u8fd0\u2f8f\u901f\u5ea6\u66f4\u5feb
- \u4e3a\u2f06\u503c\u56fe\u50cf\u5f00\u53d1\u7684\u7b97\u6cd5\u5f80\u5f80\u53ef\u4ee5\u2f64\u4e8e\u7070\u5ea6\u7ea7\u56fe\u50cf
- \u66f4\u4fbf\u5b9c
\u7f3a\u70b9\uff1a
"},{"location":"CS/DIP/DIP_Review/#_13","title":"\u56fe\u50cf\u7684\u2f06\u503c\u5316","text":"
- \u5e94\u2f64\u8303\u56f4\u6bd5\u7adf\u6709\u9650\uff1b
- \u66f4\u2f46\u6cd5\u63a8\u2f34\u5230\u4e09\u7ef4\u7a7a\u95f4\u4e2d
- \u8868\u73b0\u2f12\u2f4b\u7f3a\uff0c\u4e0d\u80fd\u8868\u73b0\u7269\u4f53\u5185\u90e8\u7ec6\u8282
- \u2f46\u6cd5\u63a7\u5236\u5bf9\u2f50\u5ea6
"},{"location":"CS/DIP/DIP_Review/#_14","title":"\u9009\u53d6\u5408\u9002\u7684\u9608\u503c\u7684\u57fa\u672c\u601d\u60f3","text":"
- \u8bbe\u7f6e\u2f00\u4e2a\u9608\u503c
\u5c06\u2f06\u503c\u5316\u5f97\u5230\u7684\u2f06\u503c\u56fe\u50cf\u89c6\u4e3a\u4e24\u90e8\u5206\uff0c\u2f00\u90e8\u5206\u5bf9\u5e94\u524d\u666f\uff08Foreground\uff09\uff0c\u53e6\u2f00\u90e8\u5206\u5bf9\u5e94\u80cc\u666f\uff08Background\uff09\u3002\u5c1d\u8bd5\u627e\u5230\u2f00\u4e2a\u5408\u9002\u7684threshold\u4f7f\u5f97\u5230\u7684\u524d\u666f\u548c\u80cc\u666f\u7684\u5185\u90e8\u534f\u2f45\u5dee\u6700\u2f29\uff0c\u2f7d\u5b83\u4eec\u4e4b\u95f4\u7684\u5916\u90e8\u534f\u2f45\u5dee\u6700\u2f24\u3002
"},{"location":"CS/DIP/DIP_Review/#_15","title":"\u2f24\u6d25\u7b97\u6cd5","text":"Step 1: \u786e\u5b9a\u539f\u59cb\u56fe\u50cf\u4e2d\u50cf\u7d20\u7684\u6700\u2f24\u503c\u548c\u6700\u2f29\u503c\uff1b
Step 2: \u6700\u2f29\u503c\u52a01\u4f5c\u4e3athreshold\u5bf9\u539f\u59cb\u56fe\u50cf\u8fdb\u2f8f\u2f06\u503c\u5316\u64cd\u4f5c\uff1b
Step 3: \u6839\u636e\u5bf9\u5e94\u5173\u7cfb\u786e\u5b9a\u524d\u666f\u548c\u80cc\u666f\uff0c\u5206\u522b\u8ba1\u7b97\u5f53\u524dthreshold\u4e0b\u7684\u5185\u90e8\u534f\u2f45\u5dee\u548c\u5916\u90e8\u534f\u2f45\u5dee\uff1b
Step 4: \u56de\u5230Step 2\u76f4\u5230\u8fbe\u5230\u50cf\u7d20\u6700\u2f24\u503c\uff1b
Step 5\uff1a\u627e\u5230\u6700\u2f24\u5916\u90e8\u548c\u6700\u2f29\u5185\u90e8\u534f\u2f45\u5dee\u5bf9\u5e94\u7684threshold.
"},{"location":"CS/DIP/DIP_Review/#_16","title":"\u5c40\u90e8\u2f83\u9002\u5e94\u64cd\u4f5c","text":"\u8bbe\u5b9a\u2f00\u4e2a\u5c40\u90e8\u7a97\u2f1d\uff0c\u5728\u6574\u4e2a\u56fe\u50cf\u4e0a\u6ed1\u52a8\u8be5\u7a97\u2f1d\uff1b\u5bf9\u4e8e\u6bcf\u2f00\u7a97\u2f1d\u4f4d\u7f6e\uff0c\u786e\u5b9a\u9488\u5bf9\u8be5\u7a97\u2f1d\u7684threshold\u3002
"},{"location":"CS/DIP/DIP_Review/#dilation","title":"\u81a8\u80c0(Dilation)","text":"\u7269\u7406\u610f\u4e49\uff1a\u4f7f\u8fb9\u754c\u5411\u5916\u90e8\u6269\u5f20\u7684\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u2f64\u6765\u586b\u8865\u7269\u4f53\u4e2d\u7684\u7a7a\u6d1e\u3002
"},{"location":"CS/DIP/DIP_Review/#erosion","title":"\u8150\u8680\uff08Erosion\uff09","text":"\u7269\u7406\u610f\u4e49\uff1a\u6d88\u9664\u8fb9\u754c\u70b9\uff0c\u4f7f\u8fb9\u754c\u5411\u5185\u90e8\u6536\u7f29\u7684\u8fc7\u7a0b\u3002\u53ef\u4ee5\u2f64\u6765\u6d88\u9664\u2f29\u4e14\u2f46\u610f\u4e49\u7684\u7269\u4f53
"},{"location":"CS/DIP/DIP_Review/#application","title":"Application","text":""},{"location":"CS/DIP/DIP_Review/#_17","title":"*** \u8150\u8680\u548c\u81a8\u80c0\u5177\u6709\u5bf9\u5076\u6027","text":""},{"location":"CS/DIP/DIP_Review/#opening-e-d","title":"\u5f00\u8fd0\u7b97(Opening = E + D)","text":"\u5148\u8150\u8680\uff0c\u540e\u81a8\u80c0\u3002
\u7269\u7406\u610f\u4e49\uff1a\u2f64\u6765\u6d88\u9664\u2f29\u7269\u4f53\u3001\u5728\u7ea4\u7ec6\u70b9\u5904\u5206\u79bb\u7269\u4f53\u3001\u5e73\u6ed1\u8f83\u2f24\u7269\u4f53\u7684\u8fb9\u754c\u7684\u540c\u65f6\u5e76\u4e0d\u660e\u663e\u6539\u53d8\u5176\u79ef\u3002
"},{"location":"CS/DIP/DIP_Review/#closing-d-e","title":"\u95ed\u8fd0\u7b97(Closing = D + E)","text":"\u5148\u81a8\u80c0\u540e\u8150\u8680
\u7269\u7406\u610f\u4e49\uff1a\u2f64\u6765\u586b\u5145\u7269\u4f53\u5185\u7ec6\u2f29\u7a7a\u6d1e\u3001\u8fde\u63a5\u90bb\u8fd1\u7269\u4f53\u3001\u5e73\u6ed1\u5176\u8fb9\u754c\u7684\u540c\u65f6\u5e76\u4e0d\u660e\u663e\u6539\u53d8\u5176\u2faf\u79ef\u3002
"},{"location":"CS/DIP/DIP_Review/#_18","title":"\u6307\u7eb9\u7684\u9884\u5904\u7406\u8fc7\u7a0b","text":""},{"location":"CS/DIP/DIP_Review/#ch3","title":"Ch3","text":"
- Opening \u6d88\u9664\u5916\u90e8\u566a\u70b9
- \u8150\u8680
- \u81a8\u80c0
- Closing \u6d88\u9664\u5185\u90e8\u566a\u70b9
\u8ba1\u7b97\u7070\u5ea6\u611f\u77e5
\u6839\u636e\u2ed9\u4f2f\u5b9a\u7406
"},{"location":"CS/DIP/DIP_Review/#log","title":"** Log \u53ef\u89c6\u5316\u589e\u5f3a","text":"Ld\u662f\u663e\u793a\u4eae\u5ea6\uff0cLw\u662f\u771f\u5b9e\u4eae\u5ea6,Lmax\u662f\u56fe\u50cf\u4e2d\u7684\u6700\u2f24\u4eae\u5ea6\u3002
\u8fd9\u4e2a\u6620\u5c04\u80fd\u591f\u786e\u4fdd\u4e0d\u7ba1\u573a\u666f\u7684\u52a8\u6001\u8303\u56f4\u662f\u600e\u4e48\u6837\u7684\uff0c\u5176\u6700\u2f24\u503c\u90fd\u80fd\u6620\u5c04\u52301\uff08\u2f69\uff09\uff0c\u5176\u4ed6\u7684\u503c\u80fd\u591f\u2f50\u8f83\u5e73\u6ed1\u5730\u53d8\u5316\u3002
"},{"location":"CS/DIP/DIP_Review/#_19","title":"** \u56fe\u50cf\u76f4\u65b9\u56fe\u5747\u8861\u5316","text":"\u76f4\u65b9\u56fe\u5747\u8861\u5316\u5b9e\u8d28\u4e0a\u662f\u51cf\u5c11\u56fe\u50cf\u7684\u7070\u5ea6\u7ea7\u4ee5\u6362\u53d6\u5bf9\u6bd4\u5ea6\u7684\u52a0\u5927\u3002\u5728\u5747\u8861\u8fc7\u7a0b\u4e2d\uff0c\u539f\u6765\u7684\u76f4\u65b9\u56fe\u4e0a\u51fa\u73b0\u6982\u7387\u8f83\u5c0f\u7684\u7070\u5ea6\u7ea7\u88ab\u5f52\u5165\u5f88\u5c11\u51e0\u4e2a\u751a\u81f3\u4e00\u4e2a\u7070\u5ea6\u7ea7\u4e2d\uff0c\u6545\u5f97\u4e0d\u5230\u589e\u5f3a\u3002\u82e5\u8fd9\u4e9b\u7070\u5ea6\u7ea7\u6240\u6784\u6210\u7684\u56fe\u8c61\u7ec6\u8282\u6bd4\u8f83\u91cd\u8981\uff0c\u5219\u9700\u91c7\u7528\u5c40\u90e8\u533a\u57df\u76f4\u65b9\u56fe\u5747\u8861\u5316\u5904\u7406\u3002
\u5047\u8bbe\uff1a
\u4ee4r\u548cs\u5206\u522b\u4ee3\u8868\u53d8\u5316\u524d\u540e\u56fe\u50cf\u7684\u7070\u5ea6\u7ea7\uff0c\u5e76\u4e14 0\u2264r,s \u22641 \u3002
P(r)\u548cP(s) \u5206\u522b\u4e3a\u53d8\u5316\u524d\u540e\u5404\u7ea7\u7070\u5ea6\u7684\u6982\u7387\u5bc6\u5ea6\u51fd\u6570\uff08r\u548cs\u503c\u5df2\u5f52\u2f00\u5316\uff0c\u6700\u2f24\u7070\u5ea6\u503c\u4e3a1\uff09\u3002
\u89c4\u5b9a\uff1a
\u57280\u2264r \u22641\u4e2d\uff0cT(r)\u662f\u5355\u8c03\u9012\u589e\u51fd\u6570\uff0c\u5e76\u4e140\u2264T(r)\u22641\u3002
\u53cd\u53d8\u6362r = T-1(s)\u4e5f\u4e3a\u5355\u8c03\u9012\u589e\u51fd\u6570\u3002
\u7070\u5ea6\u76f4\u2f45\u56fe\u5747\u8861\u5316
\u8bbe\u56fe\u50cf\u670964*64=4096\u4e2a\u50cf\u7d20\uff0c\u67098\u4e2a\u7070\u5ea6\u7ea7\uff0c\u7070\u5ea6\u5206\u5e03\uff1a
\u5982\u679c\u57281/7\u548c2/7\u4e4b\u95f4\uff0c\u90a3\u4e48\u548c\u54ea\u4e2a\u66f4\u8fd1\u5c31\u7ea6\u7b97\u5230\u54ea\u4e2a
\u76f4\u2f45\u56fe\u5747\u8861\u5316\u7684\u95ee\u9898
\u6309\u7167\u5747\u8861\u5316\u7684\u8981\u6c42\uff0c\u5728\u5747\u8861\u5316\u540e\u7684\u7ed3\u679c\u76f4\u2f45\u56fe\u4e2d\uff0c\u5404\u7070\u5ea6\u7ea7\u53d1\u2f63\u7684\u6982\u7387\u5e94\u8be5\u662f\u76f8\u540c\u7684\uff0c\u5982\u53f3\u4e0a\u56fe\u6240\u793a\u8fde\u7eed\u7070\u5ea6\u7ea7\u5747\u8861\u5316\u7ed3\u679c\u90a3\u6837\u3002\u4f46\u662f\uff0c\u53f3\u4e0b\u56fe\u4e2d\u79bb\u6563\u7070\u5ea6\u7ea7\u5747\u8861\u5316\u540e\uff0c\u5404\u7070\u5ea6\u7ea7\u51fa\u73b0\u7684\u6982\u7387\u5e76\u4e0d\u5b8c\u5168\u2f00\u6837\uff0c\u4e3a\u4ec0\u4e48\uff1f
\u6b65\u9aa42\u4e2d\uff0c\u6240\u5f97\u7684sk\u4e0d\u53ef\u80fd\u6b63\u597d\u7b49\u4e8e8\u7ea7\u7070\u5ea6\u503c\u4e2d\u7684\u67d0\u2f00\u7ea7\uff0c\u56e0\u6b64\u9700\u8981\u5c31\u8fd1\u5f52\u2f0a\u67d0\u2f00\u4e2a\u7070\u5ea6\u7ea7\u4e2d\u3002
\u8fd9\u6837\uff0c\u76f8\u90bb\u7684\u591a\u4e2ask\u5c31\u53ef\u80fd\u843d\u2f0a\u540c\u2f00\u4e2a\u7070\u5ea6\u7ea7\uff0c\u9700\u8981\u5728\u6b65\u9aa43\u65f6\u5c06\u5904\u4e8e\u540c\u2f00\u4e2a\u7070\u5ea6\u7ea7\u7684\u50cf\u7d20\u4e2a\u6570\u7d2f\u52a0\u3002\u56e0\u6b64\uff0c\u79bb\u6563\u7070\u5ea6\u76f4\u2f45\u56fe\u5747\u8861\u5316\u64cd\u4f5c\u4ee5\u540e\uff0c\u6bcf\u4e2a\u7070\u5ea6\u7ea7\u5904\u7684\u6982\u7387\u5bc6\u5ea6\uff08\u6216\u50cf\u7d20\u4e2a\u6570\uff09\u5e76\u4e0d\u5b8c\u5168\u2f00\u6837\u3002
"},{"location":"CS/DIP/DIP_Review/#histogram-fitting","title":"\u76f4\u2f45\u56fe\u7684\u5339\u914d(Histogram fitting)","text":"
- \u6240\u8c13\u76f4\u65b9\u56fe\u5339\u914d\uff0c\u5c31\u662f\u4fee\u6539\u4e00\u5e45\u56fe\u50cf\u7684\u76f4\u65b9\u56fe\uff0c\u4f7f\u5f97\u5b83\u4e0e\u53e6\u4e00\u5e45\u56fe\u50cf\u7684\u76f4\u65b9\u56fe\u5339\u914d\u6216\u5177\u6709\u4e00\u79cd\u9884\u5148\u89c4\u5b9a\u7684\u51fd\u6570\u5f62\u72b6\u3002
\u76f4\u65b9\u56fe\u5339\u914d\u7684\u76ee\u6807\uff0c\u662f\u7a81\u51fa\u6211\u4eec\u611f\u5174\u8da3\u7684\u7070\u5ea6\u8303\u56f4\uff0c\u4f7f\u56fe\u50cf\u8d28\u91cf\u6539\u5584
\u5229\u7528\u76f4\u65b9\u56fe\u5747\u8861\u5316\u64cd\u4f5c\uff0c\u53ef\u4ee5\u5b9e\u73b0\u76f4\u65b9\u56fe\u5339\u914d\u8fc7\u7a0b\u3002
\u2f6c\u7684\uff0c\u628a\u76f4\u2f45\u56feA\u8f6c\u6362\u5230B
\u7b2c\u2f00\u6b65\uff0c\u901a\u8fc7\u76f4\u2f45\u56fe \u5747\u8861\u5316\u628ar\u6620\u5c04\u5230s
\u7b2c\u2f06\u6b65\uff0c\u540c\u7406\u628a\u7070\u5ea6\u7ea7z\u6620\u5c04\u5230v
\u7b2c\u4e09\u6b65,\u7531v = G(z)\u5f97\u5230z =G-1(v)\u3002\u7531\u4e8es\u548cv\u6709\u76f8\u540c\u7684\u5206\u5e03\uff0c\u9010\u2f00\u53d6v = s\uff0c\u6c42\u51fa\u4e0er\u5bf9\u5e94\u7684z =G- 1(s)\u3002
\u7b80\u8ff0\u7248\u672c\uff1a
\u5728\u6b65\u9aa41\u548c2\u4e2d\uff0c\u5206\u522b\u8ba1\u7b97\u83b7\u5f97\u4e24\u5f20\u8868\uff08\u53c2\u2ec5\u76f4\u2f45\u56fe\u5747\u8861\u5316\u4e2d\u7684\u7b97\u4f8b\uff09\uff0c\u4ece\u4e2d\u9009\u53d6\u2f00\u5bf9vk\u3001 sj\uff0c\u4f7fvk = sj\uff0c\u5e76\u4ece\u4e24\u5f20\u8868\u4e2d\u67e5\u51fa\u5bf9\u5e94\u7684zk\u3001rj\u3002\u8fd9\u6837\uff0c\u539f\u59cb\u56fe\u50cf\u4e2d\u7070\u5ea6\u7ea7\u4e3arj\u7684\u6240\u6709\u50cf\u7d20\u90fd\u6620\u5c04\u6210\u7070\u5ea6\u7ea7zk\uff0c\u6700\u7ec8\u5f97\u5230\u6240\u671f\u671b\u7684\u56fe\u50cf\u3002
"},{"location":"CS/DIP/DIP_Review/#ch4","title":"Ch4","text":""},{"location":"CS/DIP/DIP_Review/#_20","title":"** \u5404\u79cd\u53d8\u6362\u7684\u5750\u6807\u516c\u5f0f\u8981\u638c\u63e1","text":"\u65cb\u8f6c\u4ee5\u540e\u4ea7\u2f63\u7a7a\u6d1e\u7684\u63d2\u503c\u2f3f\u6cd5
\u2f8f\u63d2\u503c\u2014\u2014\u6309\u987a\u5e8f\u5bfb\u627e\u6bcf\u2f00\u2f8f\u4e2d\u7684\u7a7a\u6d1e\u50cf\u7d20\uff0c\u8bbe\u7f6e\u5176\u50cf\u7d20\u503c\u4e0e\u540c\u2f00\u2f8f\u4e2d\u524d\u2f00\u4e2a\u50cf\u7d20\u7684\u50cf\u7d20\u503c\u76f8\u540c\u3002
\u6700\u8fd1\u90bb\u63d2\u503c---\u4e3a\u4e86\u8ba1\u7b97\u2f0f\u4f55\u53d8\u6362\u540e\u65b0\u56fe\u50cf\u4e2d\u67d0\u2f00\u70b9P\u2019\u5904\u7684\u50cf\u7d20\u503c\uff0c\u53ef\u4ee5\u2fb8\u5148\u8ba1\u7b97\u8be5\u2f0f\u4f55\u53d8\u6362\u7684\u9006\u53d8\u6362\uff0c\u8ba1\u7b97\u51faP\u2019\u6240\u5bf9\u5e94\u7684\u539f\u56fe\u50cf\u4e2d\u7684\u4f4d\u7f6eP\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cP\u7684\u4f4d\u7f6e\u4e0d\u53ef\u80fd\u6b63\u597d\u5904\u5728\u539f\u56fe\u50cf\u7684\u67d0\u2f00\u4e2a\u50cf\u7d20\u4f4d\u7f6e\u4e0a\uff08\u5373P\u70b9\u7684\u5750\u6807\u901a\u5e38\u90fd\u4e0d\u4f1a\u6b63\u597d\u662f\u6574\u6570\uff09\u3002\u5bfb\u627e\u4e0eP\u70b9\u6700\u63a5\u8fd1\u7684\u50cf\u7d20Q\uff0c\u628aQ\u70b9\u7684\u50cf\u7d20\u503c\u4f5c\u4e3a\u65b0\u56fe\u50cf\u4e2dP\u2019\u70b9\u7684\u50cf\u7d20\u503c\u3002
\u5f53\u56fe\u50cf\u4e2d\u5305\u542b\u660e\u663e\u7684\u51e0\u4f55\u7ed3\u6784\u65f6\uff0c\u7ed3\u679c\u5c06\u4e0d\u592a\u5149\u6ed1\u8fde\u7eed\uff0c\u4ece\u800c\u5728\u56fe\u50cf\u4e2d\u4ea7\u751f\u4eba\u4e3a\u7684\u75d5\u8ff9\u3002
- \u2f00\u7ef4\u7ebf\u6027\u63d2\u503c
- \u53cc\u7ebf\u6027\u63d2\u503c
\u5df2\u77e5\u56fe\u50cf\u7684\u6b63\u2f45\u5f62\u2f79\u683c\u4e0a\u56db\u4e2a\u70b9A\u3001B\u3001C\u3001D\u7684\u7070\u5ea6\uff0c\u6c42P\u70b9\u7684\u7070\u5ea6\u3002
"},{"location":"CS/DIP/DIP_Review/#morph","title":"Morph\u56fe\u50cf\u7684\u53d8\u5f62","text":"\u5b9a\u4e49\u53cc\u7ebf\u6027\u65b9\u7a0bg(x,y)=ax+by+cxy+d \u3002\n\u5206\u522b\u5c06A\u3001B\u3001C\u3001D\u56db\u70b9\u7684\u4f4d\u7f6e\u548c\u7070\u5ea6\u4ee3\u5165\u65b9\u7a0b\uff0c\u5f97\u5230\u65b9\u7a0b\u7ec4\u3002\n\u89e3\u65b9\u7a0b\u7ec4\uff0c\u89e3\u51faa\u3001b\u3001c\u3001d\u56db\u4e2a\u7cfb\u6570\u3002\n\u5c06P\u70b9\u7684\u4f4d\u7f6e\u4ee3\u5165\u65b9\u7a0b\uff0c\u5f97\u5230P\u70b9\u7684\u7070\u5ea6\u3002\n
\u8fd9\u91cc\u8ba8\u8bba\u7684Morph\u53d8\u5f62\u4e0d\u540c\u4e8e\u4e00\u822c\u7684\u51e0\u4f55\u53d8\u6362(Warp)\u3002 Morph\u53d8\u5f62\u6307\u666f\u7269\u7684\u5f62\u4f53\u53d8\u5316\uff0c\u5b83\u662f\u4f7f\u4e00\u5e45\u56fe\u50cf\u9010\u6b65\u53d8\u5316\u5230\u53e6\u4e00\u5e45\u56fe\u50cf\u7684\u5904\u7406\u65b9\u6cd5\u3002 \u8fd9\u662f\u4e00\u79cd\u8f83\u590d\u6742\u7684\u4e8c\u7ef4\u56fe\u50cf\u5904\u7406\uff0c\u9700\u8981\u5bf9\u5404\u50cf\u7d20\u70b9\u7684\u989c\u8272\u3001\u4f4d\u7f6e\u4f5c\u53d8\u6362\u3002 \u53d8\u5f62\u7684\u8d77\u59cb\u56fe\u50cf\u548c\u7ed3\u675f\u56fe\u50cf\u5206\u522b\u4e3a\u4e24\u5e45\u5173\u952e\u5e27\uff0c\u4ece\u8d77\u59cb\u5f62\u72b6\u53d8\u5316\u5230\u7ed3\u675f\u5f62\u72b6\u7684\u5173\u952e\u5728\u4e8e\u81ea\u52a8\u5730\u751f\u6210\u4e2d\u95f4\u5f62\u72b6\uff0c\u4e5f\u5373\u81ea\u52a8\u751f\u6210\u4e2d\u95f4\u5e27\u3002
Change A to B
\u2f24\u2f29\u76f8\u540c\u7684\u4e24\u5e45\u56fe\u7684\u8f6c\u6362\u4f5c\u9759\u6001\u53d8\u6362\u3002\u4ece\u2f00\u5e45\u56fea\u9010\u6e10\u53d8\u5316\u6210\u7b2c\u2f06\u5e45\u56feb\u3002\u539f\u7406\uff1a\u8ba9\u56fea\u4e2d\u6bcf\u4e2a\u50cf\u7d20\u7684\u989c\u2f8a\uff0c\u9010\u6e10\u53d8\u6210\u56feb\u76f8\u540c\u4f4d\u7f6e\u50cf\u7d20\u7684\u989c\u2f8a\u3002
\u2f45\u6cd5\uff1a\u6839\u636e\u53d8\u6362\u7684\u5feb\u6162\uff0c\u8bbe\u7f6e\u76f8\u5e94\u7684\u6b65\u2ed3\uff0c\u5c06\u56fea\u6bcf\u2f00\u70b9\u7684RGB\u9010\u6e10\u53d8\u6210\u56feb\u76f8\u540c\u4f4d\u7f6e\u8c61\u7d20\u7684 RGB\u3002\u53ef\u4ee5\u9009\u62e9\u7b49\u2f50\u6216\u7b49\u5dee\u7684\u2f45\u5f0f\uff0c\u6216\u5176\u5b83\u2f45\u5f0f\u8ba9\uff1ara-->rb\u3002
\u5bf9\u4e8e\u7070\u5ea6\u56fe\u50cf\uff0c\u53ef\u4ee5\u76f4\u63a5\u2f64\u7b49\u2f50\u6216\u7b49\u5dee\u7ea7\u6570\u5b9a\u4e49\u6b65\u2ed3\uff0c\u4f7f\u989c\u2f8a\u4ece\u539f\u56fe\u53d8\u5230\u2f6c\u6807\u56fe\u3002
"},{"location":"CS/DIP/DIP_Review/#morph_1","title":"* \u5e94\u7528 Morph \u8868\u60c5\u5339\u914d","text":"Assumption: Human faces have approximately the same normals
"},{"location":"CS/DIP/DIP_Review/#ch5","title":"Ch5","text":""},{"location":"CS/DIP/DIP_Review/#_21","title":"\u2f00\u7ef4\u5377\u79ef","text":"\u5377\u79ef\u672c\u8d28\u4e0a\u7b49\u540c\u4e8e\u8ba1\u7b97\u56fe\u50cf\u50cf\u7d20\u7684\u52a0\u6743\u548c\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\u8981\u638c\u63e1
- \u5b83\u8868\u793a\u4e24\u4e2a\u51fd\u6570\u7684\u5377\u79ef\u53ef\u4ee5\u8f6c\u5316\u6210\u4e58\u79ef\u7684\u79ef\u5206\u6765\u8ba1\u7b97\u3002\u901a\u5e38\u5c06f(x)\u79f0\u4e3a\u8f93\u5165\u51fd\u6570\uff0c\u5c06h(x)\u79f0\u4e3a\u5377\u79ef\u51fd\u6570\u3002
\u8fd9\u2fa5\u8981\u6ce8\u610f\u7684\u662f\u5f97\u5230\u7684g(x)\u7684\u5b9a\u4e49\u57df\u4e3a[0,799]
\u6b65\u9aa41\uff1a \u5c06\u5377\u79ef\u51fd\u6570h(t)\u5173\u4e8e\u539f\u70b9\u8fdb\u884c\u955c\u50cf\u6620\u5c04\uff08\u5012\u8f6c\uff09\uff0c\u5f97\u5230h(-t)\u3002
\u6b65\u9aa42\uff1a \u5c06\u5012\u8f6c\u8fc7\u7684\u51fd\u6570h(-t)\u6ed1\u8fc7f(t)\uff0c\u8fd9\u8981\u589e\u52a0\u4e00\u4e2a\u5e38\u6570\u4f4d\u79fbx\u5230h(-t)\uff0c\u5373\u53d8\u6210h(x-t)\u3002
\u6b65\u9aa43\uff1a \u5bf9\u6bcf\u4e00\u4e2a\u6837\u672c\u70b9t \uff08t = 0, 1, 2, 3, \u2026, 399\uff09\u90fd\u8ba1\u7b97\u4e58\u79eff(t)h(x-t)\uff0c\u7136\u540e\u5c06\u8fd9\u4e9b\u4e58\u79ef\u76f8\u52a0\u540e\u9664\u4ee5\u5e38\u6570M\uff08=400\uff09\uff0c\u5c31\u5f97\u5230\u5728\u4f4d\u79fbx\u4e0b\u7684\u5377\u79ef\u3002
\u6b65\u9aa44\uff1a \u5bf9\u6709\u6548\u8303\u56f4\u5185\u7684\u6240\u6709\u4f4d\u79fbx\u5747\u8ba1\u7b97\u4e00\u4e2a\u5377\u79ef\uff0c\u8fd9\u6837\uff0c\u6240\u6709\u8fd9\u4e9b\u503c\u5c31\u5f62\u6210\u4e86\u4e00\u6761\u66f2\u7ebf\u3002
"},{"location":"CS/DIP/DIP_Review/#sharping-filter","title":"Sharping filter \u62c9\u666e\u62c9\u65af","text":"\u5fae\u5206\u7b97\u5b50\u662f\u5b9e\u73b0\u9510\u5316\u7684\u5de5\u5177\uff0c\u5176\u54cd\u5e94\u7a0b\u5ea6\u4e0e\u56fe\u50cf\u5728\u8be5\u70b9\u5904\u7684\u7a81\u53d8\u7a0b\u5ea6\u6709\u5173\u3002\u5fae\u5206\u7b97\u5b50\u589e\u5f3a\u4e86\u8fb9\u7f18\u548c\u5176\u4ed6\u7a81\u53d8\uff08\u5982\u566a\u58f0\uff09\u5e76\u524a\u5f31\u4e86\u7070\u5ea6\u53d8\u5316\u7f13\u6162\u7684\u533a\u57df\u3002
- \u57fa\u4e8e\u4e00\u9636\u5fae\u5206\u7684\u56fe\u50cf\u589e\u5f3a\u2014\u2014\u68af\u5ea6\u6cd5
- \u57fa\u4e8e\u4e8c\u9636\u5fae\u5206\u7684\u56fe\u50cf\u589e\u5f3a\u2014\u2014\u62c9\u666e\u62c9\u65af\u7b97\u5b50
\u5de6\u4fa7\u4e3a\u6b63\u5e38\u7684\u7b97\u5b50\uff0c\u53f3\u4fa7\u4e3aextending one
\u5f53\u62c9\u666e\u62c9\u65af\u6ee4\u6ce2\u540e\u7684\u56fe\u50cf\u4e0e\u5176\u5b83\u56fe\u50cf\u5408\u5e76\u65f6\uff08\u76f8\u52a0\u6216\u76f8\u51cf\uff09\uff0c\u5219\u5fc5\u987b\u8003\u8651\u7b26\u53f7\u4e0a\u7684\u5dee\u522b \u5c06\u539f\u59cb\u56fe\u50cf\u548c\u62c9\u666e\u62c9\u65af\u56fe\u50cf\u53e0\u52a0\u5728\u4e00\u8d77\u7684\u7b80\u5355\u65b9\u6cd5\u53ef\u4ee5\u4fdd\u62a4\u62c9\u666e\u62c9\u65af\u9510\u5316\u5904\u7406\u7684\u6548\u679c\uff0c\u540c\u65f6\u53c8\u80fd\u590d\u539f\u80cc\u666f\u4fe1\u606f\u3002
"},{"location":"CS/DIP/DIP_Review/#_22","title":"\u5e73\u6ed1\u7a7a\u95f4\u6ee4\u6ce2 | \u4f4e\u901a\u6ee4\u6ce2","text":"\u7a7a\u95f4\u6ee4\u6ce2
\u641e\u6e05\u695a\uff0c\u5747\u503c\u6ee4\u6ce2\u548c\u4e2d\u503c\u6ee4\u6ce2\u4e0d\u662f\u2f00\u56de\u4e8b\uff0c\u5747\u503c\u6ee4\u6ce2\u662f\u2fbc\u65af\u6ee4\u6ce2\u7684\u2f00\u79cd\u7279\u4f8b\uff0c\u2fbc\u65af\u6ee4\u6ce2\u662f\u2f00\u79cd\u4f4e\u901a\u6ee4\u6ce2\u3002
\u5f53\u53d1\u73b0\u56fe\u50cf\u4e2d\u6709\u592a\u591a\u7684\u4f2a\u5f71\u6216\u566a\u58f0\u65f6\uff0c\u53ef\u4ee5\u5bf9\u56fe\u50cf\u8fdb\u2f8f\u5e73\u6ed1\u5904\u7406\uff0c\u6291\u5236\u566a\u58f0\uff0c\u51cf\u5c11\u4f2a\u5f71\u3002 \u7136\u2f7d\uff0c\u5e73\u6ed1\u64cd\u4f5c\u4f1a\u4f7f\u56fe\u50cf\u53d8\u5f97\u6a21\u7cca\u3002
Linear smoothing filter
- \u7ebf\u6027
Statistical sorting filter
"},{"location":"CS/DIP/DIP_Review/#general-idea","title":"\u53cc\u8fb9\u6ee4\u6ce2\u7684general idea","text":"
- \u975e\u7ebf\u6027
- \u5e38\u7528n\u00d7n\u7684\u4e2d\u503c\u6ee4\u6ce2\u5668\u53bb\u9664\u90a3\u4e9b\u76f8\u5bf9\u4e8e\u5176\u90bb\u57df\u50cf\u7d20\u66f4\u4eae\u6216\u66f4\u6697\uff0c\u5e76\u4e14\u5176\u533a\u57df\u5c0f\u4e8en2/2\uff08\u6ee4\u6ce2\u5668\u533a\u57df\u7684\u4e00\u534a\uff09\u7684\u5b64\u7acb\u50cf\u7d20\u96c6\u3002
\u2f00\u5e45\u56fe\u50cf\u6709\u4e24\u4e2a\u4e3b\u8981\u7279\u5f81
\u7a7a\u95f4\u57dfS\uff0c\u5b83\u662f\u2f00\u5e45\u56fe\u50cf\u4e2d\u53ef\u80fd\u4f4d\u7f6e\u7684\u96c6\u5408\u3002 \u8fd9\u4e0e\u5206\u8fa8\u7387\u6709\u5173\uff0c\u4e5f\u5c31\u662f\u56fe\u50cf\u4e2d\u7684\u2f8f\u6570\u548c\u5217\u6570\u3002
\u5f3a\u5ea6\u57dfR\uff0c\u662f\u53ef\u80fd\u50cf\u7d20\u503c\u7684\u96c6\u5408\u3002 \u2f64\u6765\u8868\u793a\u50cf\u7d20\u503c\u7684\u4f4d\u6570\u53ef\u80fd\u4f1a\u53d8\u5316\u3002 \u5e38\u2ec5\u7684\u50cf\u7d20\u8868\u793a\u5f62\u5f0f\u662f\u2f46\u7b26\u53f7\u5b57\u8282(0\u5230255)\u548c\u6d6e\u70b9\u6570\u3002
\u2fbc\u65af\u6ee4\u6ce2\u53ea\u8003\u8651\u4e86\u524d\u2f00\u4e2a\u57df\u3002\uff08\u628a\\(r\\)\u62c9\u5230\u6b63\u65e0\u7a77\uff0c\u90a3\u4e48\u5c06\u53d8\u6210\u9ad8\u65af\u6a21\u7cca\uff09
\u53cc\u8fb9\u6ee4\u6ce2\u516c\u5f0f\u6bcf\u4e2a\u7684\u542b\u4e49
From GPT \u53cc\u8fb9\u6ee4\u6ce2\uff08Bilateral Filter\uff09\u662f\u4e00\u79cd\u5e38\u7528\u7684\u56fe\u50cf\u5904\u7406\u6280\u672f\uff0c\u5b83\u53ef\u4ee5\u5728\u4fdd\u6301\u8fb9\u7f18\u6e05\u6670\u7684\u540c\u65f6\u5bf9\u56fe\u50cf\u8fdb\u884c\u5e73\u6ed1\u5904\u7406\u3002\u53cc\u8fb9\u6ee4\u6ce2\u5668\u7684\u4e24\u4e2a\u53c2\u6570\u5206\u522b\u662f\u7a7a\u95f4\u57df\u6807\u51c6\u5dee\uff08\\(\\sigma_s\\)\uff09\u548c\u7070\u5ea6\u503c\u57df\u6807\u51c6\u5dee\uff08\\(\\sigma_r\\)\uff09\u3002
- \\(\\sigma_s\\)\uff1a\u63a7\u5236\u4e86\u5728\u7a7a\u95f4\u4e0a\u8fdb\u884c\u5e73\u6ed1\u7684\u8303\u56f4\u3002\u8f83\u5927\u7684 \\(\\sigma_s\\) \u503c\u610f\u5473\u7740\u66f4\u5e7f\u6cdb\u7684\u7a7a\u95f4\u8303\u56f4\u5185\u7684\u50cf\u7d20\u5c06\u88ab\u8003\u8651\uff0c\u4ece\u800c\u4ea7\u751f\u66f4\u5927\u8303\u56f4\u7684\u5e73\u6ed1\u6548\u679c\u3002
- \\(\\sigma_r\\)\uff1a\u63a7\u5236\u4e86\u5bf9\u7070\u5ea6\u503c\u8fdb\u884c\u5e73\u6ed1\u7684\u8303\u56f4\u3002\u8f83\u5927\u7684 \\(\\sigma_r\\) \u503c\u610f\u5473\u7740\u5bf9\u4e8e\u7070\u5ea6\u503c\u5dee\u5f02\u8f83\u5927\u7684\u50cf\u7d20\uff0c\u5176\u6743\u91cd\u4f1a\u66f4\u5927\uff0c\u8fd9\u53ef\u4ee5\u5e2e\u52a9\u4fdd\u6301\u56fe\u50cf\u7684\u8fb9\u7f18\u4fe1\u606f\u3002
- \u589e\u5927 \\(\\sigma_s\\) \u4f1a\u5bfc\u81f4\u66f4\u5927\u8303\u56f4\u7684\u50cf\u7d20\u88ab\u8003\u8651\u5728\u5185\uff0c\u56e0\u6b64\u4ea7\u751f\u66f4\u5927\u8303\u56f4\u7684\u5e73\u6ed1\u6548\u679c\uff0c\u4f46\u4e5f\u53ef\u80fd\u5bfc\u81f4\u56fe\u50cf\u5931\u771f\u3002\u800c\u589e\u5927 \\(\\sigma_r\\) \u4f1a\u4f7f\u5f97\u5bf9\u7070\u5ea6\u503c\u5dee\u5f02\u8f83\u5927\u7684\u50cf\u7d20\u6709\u66f4\u5927\u7684\u6743\u91cd\uff0c\u56e0\u6b64\u53ef\u4ee5\u66f4\u597d\u5730\u4fdd\u7559\u56fe\u50cf\u7684\u8fb9\u7f18\u4fe1\u606f\uff0c\u4f46\u4e5f\u53ef\u80fd\u5bfc\u81f4\u8fb9\u7f18\u7ec6\u8282\u4e0d\u591f\u5e73\u6ed1\u3002 \u56e0\u6b64\uff0c\u5408\u7406\u9009\u62e9 \\(\\sigma_s\\) \u548c \\(\\sigma_r\\) \u7684\u503c\u5bf9\u4e8e\u83b7\u5f97\u6ee1\u610f\u7684\u53cc\u8fb9\u6ee4\u6ce2\u6548\u679c\u975e\u5e38\u91cd\u8981\u3002
How to set \uff08From PPT\uff09
- \\(\\sigma_s\\) : \u4e0e\u7a97\u53e3\u5927\u5c0f\u6709\u5173
- \\(\\sigma_r\\) : \u4e0e\u8fb9\u7f18\u632f\u5e45\u6210\u6b63\u6bd4
- \u4e0e\u5206\u8fa8\u7387\u548c\u66dd\u5149\u65e0\u5173
\u53cc\u8fb9\u6ee4\u6ce2\u56e0\u4e3a\u5f15\u2f0a\u4e86\u5feb\u901f\u5085\u2fa5\u53f6\u53d8\u5316\u624d\u5b9e\u73b0\u52a0\u901f
"},{"location":"CS/DIP/DIP_Review/#_23","title":"\u6d88\u9664\u566a\u97f3","text":""},{"location":"CS/DIP/DIP_Review/#guided-filterguided-filter","title":"Guided filter\u4e3a\u4ec0\u4e48\u2f50\u53cc\u8fb9\u6ee4\u6ce2\u597d\uff0c\u4ee5\u53caGuided filter\u7684\u4f18\u70b9","text":"Regularization \u8d8a\u5927\uff0c\u4fdd\u8fb9\u80fd\u529b\u8d8a\u5f3a
\u56e0\u4e3aGuided filter\u8003\u8651\u4e86\u4fdd\u68af\u5ea6\uff0c\u4e0d\u4f1a\u9020\u6210\u68af\u5ea6\u7684\u9006\u8f6c\uff0c\u4f46\u662f\u53cc\u8fb9\u6ee4\u6ce2\u4f1a\u4ea7\u2f63\u68af\u5ea6\u7684\u9006\u8f6c\uff0c\u56e0\u4e3a\u53cc\u8fb9\u4fdd\u7684\u662fdifference\u7684\u7edd\u5bf9\u503c\uff0c\u2f7d\u4e0d\u662f\u2f45\u5411\u3002
\u79fb\u9664\u4e0d\u9700\u8981\u7684\u9891\u7387
"},{"location":"CS/DIP/DIP_Review/#snf","title":"SNF \u7a00\u758f\u8303\u6570\u6ee4\u6ce2","text":"
- p>1\u4e0d\u80fd\u9632\u6b62\u68af\u5ea6\u9006\u8f6c\uff0cp<1\u624d\u53ef
\u8bc1\u660e\uff1ap = 1\uff0c\u4e2d\u503c\u6ee4\u6ce2\uff1bp=2\uff0c\u9ad8\u65af\u6ee4\u6ce2\uff08\u5747\u503c\uff09
\u56e0\u4e3a SNF \u7684\u5fae\u5206\u662f\u975e\u5c40\u90e8\u7684\uff0c\u4ed6\u4e0d\u90a3\u4e48\u53ef\u80fd\u9677\u5165\u68af\u5ea6\u4e0b\u964d\u7684\u60c5\u51b5
"},{"location":"CS/DIP/DIP_Review/#ch6","title":"Ch6","text":""},{"location":"CS/DIP/DIP_Review/#ft","title":"FT \u5085\u91cc\u53f6\u53d8\u6362","text":"
- \u4e0b\u9762\u4e3aFT\u7684\u53bb\u566a
"},{"location":"CS/DIP/DIP_Review/#dft","title":"DFT","text":"1. \u8fdb\u884c\u5085\u91cc\u53f6\u53d8\u6362\n2. \u5728\u53d8\u6362\u540e\u7684X\uff08t\uff09\u4e2d\u8fdb\u884c\u6ee4\u6ce2\n3. \u8fdb\u884c\u9006\u5085\u91cc\u53f6\u53d8\u6362\n
"},{"location":"CS/DIP/DIP_Review/#fft","title":"FFT \u5feb\u901f\u5085\u91cc\u53f6\u53d8\u6362","text":"
- \u76f8\u4f4d\u53ef\u4ee5\u7528\u6765\u4f20\u9012\u7ed3\u6784\u4fe1\u606f\uff0c\u5e45\u503c\u4e0d\u884c
- \u5c06\u539f\u59cb\u7684 N \u70b9\u5e8f\u5217\u4f9d\u6b21\u5206\u89e3\u4e3a\u4e00\u7cfb\u5217\u77ed\u5e8f\u5217\uff1b
- \u6c42\u51fa\u8fd9\u4e9b\u77ed\u5e8f\u5217\u7684\u79bb\u6563\u5085\u7acb\u53f6\u53d8\u6362\uff1b
- \u7ec4\u5408\u51fa\u6240\u9700\u7684\u53d8\u6362\u503c\uff1b
- \u8ba1\u7b97\u91cf\uff08\u4e58\u9664\u6cd5\uff09\uff1a
FFT\u7684\u63a8\u5bfc
"},{"location":"CS/DIP/DIP_Review/#ch7","title":"Ch7","text":""},{"location":"CS/DIP/DIP_Review/#_24","title":"\u89d2\u70b9\u7279\u5f81\u68c0\u6d4b","text":"\u6211\u4eec\u8003\u8651\u4e00\u4e2a\u5c0f\u7a97\u53e3\u7684\u50cf\u7d20
- flat: \u5728\u4efb\u4f55\u65b9\u5411\u90fd\u4e0d\u4f1a\u6709\u50cf\u7d20\u7684\u6539\u53d8
- egde: \u6cbf\u7740\u8fb9\u7684\u65b9\u5411\u4e0d\u4f1a\u6709\u50cf\u7d20\u7684\u6539\u53d8
- corner: \u5728\u4efb\u4f55\u65b9\u5411\u90fd\u4f1a\u6709\u660e\u663e\u7684\u6539\u53d8
\u7279\u5f81
- \u65cb\u8f6c\u4e0d\u53d8\u6027
- \u7f29\u653e\u4f1a\u5177\u6709\u5f71\u54cd
Detect the Error \u4f7f\u7528SSD suming up the Square Differen'vce
\u6211\u4eec\u53ef\u4ee5\u5728\u84dd\u8272\u7684\u5706\u5708\u5185\u79fb\u52a8window\uff0c\u6700\u5927\u548c\u6700\u5c0f\u7684E\u7684\u4f4d\u7f6e\u5982\u4f55\u53d6\u5f97\u4f9d\u8d56\u4e8eH\u7684\u7279\u5f81\u5411\u91cf
"},{"location":"CS/DIP/DIP_Review/#_25","title":"\u4e0d\u53d8\u6027","text":""},{"location":"CS/DIP/DIP_Review/#harris-laplacian","title":"Harris Laplacian","text":"\u4e0d\u540c\u7ef4\u5ea6\u8ba1\u7b97\u65b9\u6cd5\u4e0d\u4e00\u6837
- \u521d\u59cb\u5316\uff1a\u591a\u5c3a\u5ea6\u7684 Harris corner detection(\u6539\u53d8\u6e05\u6670\u5ea6\u540e\uff0c\u5355\u72ec\u627e\u89d2\u70b9) \u53ea\u6709\u5728\u4efb\u4f55\u5c3a\u5ea6\u4e0a\u90fd\u662f\u89d2\u70b9\u7684\u70b9\uff0c\u624d\u80fd\u88ab\u4fdd\u7559
- \u57fa\u4e8e\u62c9\u666e\u62c9\u65af\u7b97\u5b50\uff0c\u8fdb\u884c\u5c3a\u5ea6\u9009\u62e9\u3002\u5bf9\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u54ea\u4e00\u4e2a\u5c3a\u5ea6\u4e0a\u62c9\u666e\u62c9\u65af\u503c\u6700\u5927\uff0c\u5c06\u8fd9\u4e2a\u4f4d\u7f6e\u548c\u5c3a\u5ea6\u4f5c\u4e3a\u89d2\u70b9\u3002\uff08\u552f\u4e00\u6027\uff0c\u5728\u8fd9\u4e2a\u5c3a\u5ea6\u4e0a\u662f\u6781\u5927\u503c\uff0c\u90a3\u4e48\u5728\u53e6\u4e00\u4e2a\u5c3a\u5ea6\u4e0a\u4e5f\u662f\u6781\u5927\u503c\uff0c\u53ea\u662f\u6781\u5927\u503c\u7684\u6570\u503c\u53ef\u80fd\u4e0d\u540c\uff09
Laplacian-of-Gaussian = \"blob\" detector
\u5728\u56fe\u50cf\u4e2d\u7ed9\u5b9a\u7684\u4e00\u4e2a\u70b9\uff0c\u6211\u4eec\u5b9a\u4e49\u62c9\u666e\u62c9\u65af\u54cd\u5e94\u503c\u8fbe\u5230\u5cf0\u503c\u7684\u5c3a\u5ea6\u4e3a\u7279\u5f81\u5c3a\u5ea6(characteristic scale)
"},{"location":"CS/DIP/DIP_Review/#sift","title":"SIFT","text":"
- \u5728\u68c0\u6d4b\u5230\u7684\u7279\u5f81\u89d2\u70b9\u5468\u56f4\u9009\u53d6 16\u00d716 \u7684\u65b9\u5f62\u7a97\u53e3
- \u8ba1\u7b97\u6bcf\u4e2a\u50cf\u7d20\u7684\u8fb9\u7684\u671d\u5411(\u68af\u5ea6\u7684\u89d2\u5ea6- 90\u00b0)
- \u5254\u9664\u5f31\u8fb9\u7f18(\u5c0f\u4e8e\u9608\u503c\u68af\u5ea6\u5e45\u5ea6)
- \u521b\u5efa\u5269\u4e0b\u8fb9\u7684\u65b9\u5411\u7684\u76f4\u65b9\u56fe
\u5b8c\u6574\u7248\uff1a
"},{"location":"CS/DIP/DIP_Review/#sift_1","title":"SIFT\u4e3a\u4ec0\u4e48\u80fd\u505a\u5230\u65cb\u8f6c\u4e0d\u53d8\u6027","text":"
- \u5c06 16\u00d716 \u7684\u7a97\u53e3 \u5212\u5206\u4e3a 4\u00d74 \u7684\u7f51\u683c
- \u5bf9\u6bcf\u4e2a\u7f51\u683c\u8ba1\u7b97\u5176\u65b9\u5411\u76f4\u65b9\u56fe
- 16 cells * 8 orientations = 128 dimensional descriptor(128 \u7ef4\u5411\u91cf)
SIFT \u7279\u5f81\uff1a\u65cb\u8f6c\u4e0d\u53d8\u6027 \u6839\u636e\u5176\u4e3b\u8981\u68af\u5ea6\u65b9\u5411(dominant gradient orientation)\u65cb\u8f6c patch, \u8fd9\u6837\u53ef\u4ee5\u4f7f\u4ed6\u5904\u4e8e\u89c4\u8303\u65b9\u5411
"},{"location":"CS/DIP/DIP_Review/#sift_2","title":"SIFT\u4e3a\u4ec0\u4e48\u80fd\u505a\u5230\u5c3a\u5ea6\u4e0d\u53d8\u6027","text":"
\u5728\u68c0\u6d4b\u7279\u5f81\u9644\u8fd1\u521b\u5efa\u2f00\u4e2a16*16\u7684\u6b63\u2f45\u5f62\u7a97\u2f1d
\u5bf9\u4e8e\u6bcf\u4e2a\u50cf\u7d20\u8ba1\u7b97\u5176\u8fb9\u7f18\u2f45\u5411
\u9664\u53bb\u5f31\u7684\u8fb9
\u5bf9\u5269\u4e0b\u7684\u8fb9\u521b\u5efa\u2f00\u4e2a\u76f4\u2f45\u56fe
SIFT\u7684128\u7ef4\u7684\u7279\u5f81\u662f\u54ea\u6765\u7684
16*16\u7684\u7a97\u2f1d\u5206\u4e3a16\u4e2a4*4\u7684\u2f29\u5757\uff0c\u6bcf\u4e2a\u2f29\u5757\u6709\u2f0b\u4e2a\u2f45\u5411\uff0c\u6240\u4ee5\u6709128\u7ef4\u7684\u7279\u5f81
"},{"location":"CS/DIP/DIP_Review/#sift_3","title":"SIFT\u7684\u5e94\u2f64","text":"\u56fe\u50cf\u7684\u8bc6\u522b\u4e0e\u62fc\u63a5
"},{"location":"CS/DIP/DIP_Review/#sift_4","title":"SIFT\u7684\u4f18\u7f3a\u70b9","text":"\u4f18\u70b9\uff1a
\u5177\u6709\u5c3a\u5ea6\u3001 \u65cb\u8f6c\u3001 \u4eae\u5ea6\u4e0d\u53d8\u6027
\u5728\u5c40\u90e8\u5757\u4e0a\u6709\u2fbc\u5ea6\u72ec\u7279\u548c\u63cf\u8ff0\u6027
\u5728\u521a\u6027\u5bf9\u8c61\u8868\u793a\u4e2d\u7279\u522b\u6709\u6548
\u7f3a\u70b9\uff1a\u00a0
"},{"location":"CS/DIP/DIP_Review/#surf","title":"SURF","text":""},{"location":"CS/DIP/DIP_Review/#ransac","title":"RANSAC\u7684\u6d41\u7a0b","text":"
\u63d0\u53d6\u65f6\u95f4\u8fc7\u2ed3
\u5bf9\u4e8e\u2fae\u521a\u6027\u5bf9\u8c61\u7684\u8868\u73b0\u8f83\u5dee
\u2f46\u6cd5\u5728\u4e25\u91cd\u4eff\u5c04\u5931\u771f\u4e2d\u2f2f\u4f5c
\u62df\u5408\u6570\u5b66\u6a21\u578b\u5e76\u8bc6\u522b\u6570\u636e\u4e2d\u7684\u79bb\u7fa4\u503c\u7684\u8fed\u4ee3\u65b9\u6cd5\u3002\u5b83\u7684\u4e3b\u8981\u5e94\u7528\u662f\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u548c\u56fe\u50cf\u5904\u7406\u9886\u57df\uff0c\u7528\u4e8e\u4f30\u8ba1\u6a21\u578b\u53c2\u6570\uff0c\u4f8b\u5982\u62df\u5408\u7ebf\u3001\u5e73\u9762\u6216\u5176\u4ed6\u51e0\u4f55\u5f62\u72b6\uff0c\u5e76\u6392\u9664\u5f02\u5e38\u503c\u7684\u5f71\u54cd\u3002
\u968f\u673a\u62bd\u6837\uff1a\u9996\u5148\u4ece\u6570\u636e\u96c6\u4e2d\u968f\u673a\u9009\u62e9\u4e00\u5b9a\u6570\u91cf\u7684\u6570\u636e\u70b9\u6765\u6784\u5efa\u5019\u9009\u6a21\u578b\u3002
\u6a21\u578b\u62df\u5408\uff1a\u4f7f\u7528\u9009\u5b9a\u7684\u6570\u636e\u70b9\u6765\u62df\u5408\u6a21\u578b\uff08\u4f8b\u5982\uff0c\u62df\u5408\u4e00\u6761\u76f4\u7ebf\u4ee5\u9002\u5e94\u9009\u5b9a\u7684\u4e24\u4e2a\u70b9\uff09\u3002
- \u5185\u70b9\u7b5b\u9009\uff1a\u5bf9\u4e8e\u5269\u4f59\u7684\u6570\u636e\u70b9\uff0c\u68c0\u67e5\u5b83\u4eec\u662f\u5426\u4e0e\u5f53\u524d\u62df\u5408\u7684\u6a21\u578b\u4e00\u81f4\u3002\u5982\u679c\u4e00\u4e2a\u6570\u636e\u70b9\u4e0e\u5f53\u524d\u6a21\u578b\u4e00\u81f4\uff08\u4f8b\u5982\uff0c\u8ddd\u79bb\u5728\u4e00\u5b9a\u9608\u503c\u5185\uff09\uff0c\u5219\u5c06\u5176\u6807\u8bb0\u4e3a\u201c\u5185\u70b9\u201d\uff0c\u5426\u5219\u6807\u8bb0\u4e3a\u201c\u5916\u70b9\u201d\u3002
- \u8bc4\u4f30\u6a21\u578b\uff1a\u8ba1\u7b97\u6a21\u578b\u9002\u5e94\u6570\u636e\u7684\u5ea6\u91cf\uff0c\u4f8b\u5982\u7b26\u5408\u5185\u70b9\u7684\u6570\u91cf\u3002
- \u91cd\u590d\u8fed\u4ee3\uff1a\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa4\u591a\u6b21\uff08\u901a\u5e38\u662f\u51e0\u5341\u751a\u81f3\u51e0\u767e\u6b21\uff09\uff0c\u9009\u62e9\u4ea7\u751f\u6700\u5927\u5185\u70b9\u6570\u7684\u6a21\u578b\u3002
\u6a21\u578b\u9a8c\u8bc1\uff1a\u6700\u7ec8\u6a21\u578b\u9700\u8981\u7ecf\u8fc7\u9a8c\u8bc1\uff0c\u4ee5\u786e\u4fdd\u5176\u5728\u6574\u4e2a\u6570\u636e\u96c6\u4e0a\u7684\u6027\u80fd\u3002
\u968f\u673a\u9009\u62e9\u79cd\u5b50\u70b9\u4f5c\u4e3a\u8f6c\u6362\u4f30\u8ba1\u7684\u57fa\u7840
- \u8ba1\u7b97\u79cd\u5b50\u70b9\u4e4b\u95f4\u7684\u53d8\u6362
- \u627e\u5230\u8fd9\u6b21\u53d8\u6362\u7684 inliers
- \u5982\u679c inliners \u7684\u6570\u76ee\u8db3\u591f\u591a\uff0c\u90a3\u4e48\u91cd\u65b0\u8ba1\u7b97\u6240\u6709 inliners \u4e0a\u7684\u6700\u5c0f\u4e8c\u4e58\u6cd5\u4f30\u8ba1
- \u56de\u5f52\u4e4b\u540e\u518d\u8ba1\u7b97 inliners \u5982\u6b64\u5f80\u590d\uff0c\u7ee7\u7eed\u8c03\u6574\u3002\u5982\u679c\u6ca1\u6709\u8c03\u6574\u90a3\u6211\u4eec\u53ef\u4ee5\u505c\u6b62\u5faa\u73af\u3002\u6700\u7ec8\u4f7f\u5f97\u56de\u5f52\u51fa\u7684\u7ebf\u8fbe\u5230\u6700\u591a\u7684 inliners.
w=0.8, \u6a21\u578b\u53d6\u70b9\u6570\u4e3a3\uff0c\u95ee\u6700\u5c11\u8981\u53d6\u51e0\u4e2a\u70b9\u624d\u80fd\u4fdd\u8bc1\u6982\u7387>95%RANSEC\u6536\u655b
"},{"location":"CS/DIP/DIP_Review/#_26","title":"\u56fe\u50cf\u62fc\u63a5\u7684\u4e3b\u8981\u6d41\u7a0b","text":""},{"location":"CS/DIP/DIP_Review/#_27","title":"\u62c9\u666e\u62c9\u65af\u91d1\u5b57\u5854","text":""},{"location":"CS/DIP/DIP_Review/#ch8","title":"Ch8","text":""},{"location":"CS/DIP/DIP_Review/#_28","title":"\u795e\u7ecf\u5143","text":""},{"location":"CS/DIP/DIP_Review/#bp","title":"BP\u7b97\u6cd5","text":"\u62c9\u666e\u62c9\u65af\u91d1\u5b57\u5854\u662f\u901a\u8fc7\u9ad8\u65af\u91d1\u5b57\u5854\u8ba1\u7b97\u5f97\u5230\u7684\u3002\u4e0b\u9762\u662f\u83b7\u5f97\u62c9\u666e\u62c9\u65af\u91d1\u5b57\u5854\u7684\u6b65\u9aa4\uff1a\n\n1. \u9996\u5148\uff0c\u901a\u8fc7\u5bf9\u539f\u59cb\u56fe\u50cf\u8fdb\u884c\u91cd\u590d\u91c7\u6837\u548c\u9ad8\u65af\u6a21\u7cca\u64cd\u4f5c\uff0c\u5f97\u5230\u9ad8\u65af\u91d1\u5b57\u5854\u3002\u9ad8\u65af\u91d1\u5b57\u5854\u662f\u7531\u4e00\u7cfb\u5217\u5206\u8fa8\u7387\u9010\u6e10\u51cf\u5c0f\u7684\u56fe\u50cf\u7ec4\u6210\u7684\uff0c\u6bcf\u4e00\u5c42\u56fe\u50cf\u90fd\u662f\u901a\u8fc7\u5bf9\u4e0a\u4e00\u5c42\u56fe\u50cf\u8fdb\u884c\u964d\u91c7\u6837\u548c\u9ad8\u65af\u6a21\u7cca\u5f97\u5230\u7684\u3002\n\n2. \u63a5\u4e0b\u6765\uff0c\u901a\u8fc7\u5bf9\u9ad8\u65af\u91d1\u5b57\u5854\u8fdb\u884c\u4e0a\u91c7\u6837\uff0c\u5f97\u5230\u4e00\u4e2a\u6bd4\u539f\u59cb\u56fe\u50cf\u5927\u4e00\u500d\u7684\u56fe\u50cf\u3002\u7136\u540e\uff0c\u5c06\u4e0a\u4e00\u5c42\u9ad8\u65af\u91d1\u5b57\u5854\u7684\u56fe\u50cf\u51cf\u53bb\u4e0a\u91c7\u6837\u5f97\u5230\u7684\u56fe\u50cf\uff0c\u5f97\u5230\u5f53\u524d\u5c42\u7684\u62c9\u666e\u62c9\u65af\u56fe\u50cf\u3002\n\n3. \u91cd\u590d\u8fdb\u884c\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u76f4\u5230\u8fbe\u5230\u91d1\u5b57\u5854\u7684\u9876\u5c42\u3002\n\n\u901a\u8fc7\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u62c9\u666e\u62c9\u65af\u91d1\u5b57\u5854\uff0c\u5b83\u662f\u7531\u4e00\u7cfb\u5217\u56fe\u50cf\u7ec4\u6210\u7684\uff0c\u6bcf\u4e2a\u56fe\u50cf\u90fd\u4ee3\u8868\u4e86\u539f\u59cb\u56fe\u50cf\u5728\u4e0d\u540c\u7a7a\u95f4\u5c3a\u5ea6\u4e0a\u7684\u7ec6\u8282\u4fe1\u606f\u3002\n
- BP\u7b97\u6cd5\u89e3\u51b3\u7684\u662f\u591a\u91cd\u795e\u7ecf\u7f51\u7edc\u7684\u6c42\u89e3\u8fc7\u7a0b\uff08\u5e2e\u52a9\u7406\u89e3\uff09
\u200b \u4e0d\u65ad\u91cd\u590d\uff0c\u76f4\u5230E\u5c0f\u4e8e\u4e00\u4e2a\u9608\u503c
"},{"location":"CS/DIP/DIP_Review/#_29","title":"\u4e3a\u4ec0\u4e48\u52a0\u5165\u5377\u79ef\u6838\uff0c\u597d\u5904","text":"\u52a0\u5165\u5377\u79ef\u6838\u6709\u52a9\u4e8e\u51cf\u5c11\u8ba1\u7b97\u91cf\uff0c\u8fd9\u4e3b\u8981\u4f53\u73b0\u5728\u4e24\u4e2a\u65b9\u9762\uff1a
"},{"location":"CS/DIP/DIP_Review/#_30","title":"\u8ba1\u7b97","text":"
- \u53c2\u6570\u5171\u4eab\uff1a - \u5377\u79ef\u6838\u7684\u53c2\u6570\u662f\u5171\u4eab\u7684\uff0c\u8fd9\u610f\u5473\u7740\u5728\u6574\u4e2a\u8f93\u5165\u6570\u636e\u4e0a\u4f7f\u7528\u76f8\u540c\u7684\u5377\u79ef\u6838\u8fdb\u884c\u7279\u5f81\u63d0\u53d6\u3002 \u56e0\u6b64\uff0c\u65e0\u8bba\u8f93\u5165\u6570\u636e\u7684\u5927\u5c0f\u5982\u4f55\uff0c\u5377\u79ef\u6838\u7684\u53c2\u6570\u6570\u91cf\u90fd\u4fdd\u6301\u4e0d\u53d8\u3002\u8fd9\u79cd\u53c2\u6570\u5171\u4eab\u51cf\u5c11\u4e86\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u6570\u91cf\uff0c\u4ece\u800c\u964d\u4f4e\u4e86\u6a21\u578b\u7684\u590d\u6742\u6027\u3002
- \u4e3e\u4f8b\u6765\u8bf4\uff0c\u5047\u8bbe\u8f93\u5165\u6570\u636e\u662f\u4e00\u4e2a\u56fe\u50cf\uff0c\u5982\u679c\u6211\u4eec\u4f7f\u7528\u5927\u5c0f\u4e3a3x3\u7684\u5377\u79ef\u6838\u8fdb\u884c\u7279\u5f81\u63d0\u53d6\uff0c\u65e0\u8bba\u56fe\u50cf\u7684\u5c3a\u5bf8\u5982\u4f55\uff0c\u5377\u79ef\u6838\u7684\u53c2\u6570\u6570\u91cf\u90fd\u662f\u56fa\u5b9a\u7684\uff0c\u56e0\u4e3a\u5377\u79ef\u6838\u5728\u6574\u4e2a\u56fe\u50cf\u4e0a\u5171\u4eab\u53c2\u6570\u3002\u8fd9\u79cd\u53c2\u6570\u5171\u4eab\u5927\u5927\u51cf\u5c11\u4e86\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u6570\u91cf\uff0c\u964d\u4f4e\u4e86\u8ba1\u7b97\u6210\u672c\u3002
- \u7a00\u758f\u4ea4\u4e92\uff1a - \u5377\u79ef\u64cd\u4f5c\u662f\u5c40\u90e8\u8fde\u63a5\u7684\uff0c\u6bcf\u4e2a\u8f93\u51fa\u5143\u7d20\u4ec5\u4e0e\u8f93\u5165\u7684\u5c40\u90e8\u533a\u57df\u6709\u5173\u3002\u8fd9\u79cd\u7a00\u758f\u4ea4\u4e92\u4f7f\u5f97\u6a21\u578b\u66f4\u5177\u6709\u6548\u6027\uff0c\u56e0\u4e3a\u5728\u5377\u79ef\u64cd\u4f5c\u4e2d\uff0c\u53ea\u6709\u5377\u79ef\u6838\u8986\u76d6\u5230\u7684\u533a\u57df\u624d\u4f1a\u53c2\u4e0e\u8ba1\u7b97\uff0c\u800c\u5176\u4ed6\u533a\u57df\u5219\u4e0d\u4f1a\u5f71\u54cd\u8f93\u51fa\u7ed3\u679c\u3002
- \u4e3e\u4f8b\u6765\u8bf4\uff0c\u5047\u8bbe\u8f93\u5165\u6570\u636e\u662f\u4e00\u4e2a\u5927\u5c3a\u5bf8\u7684\u56fe\u50cf\uff0c\u800c\u5377\u79ef\u6838\u7684\u5927\u5c0f\u76f8\u5bf9\u8f83\u5c0f\uff0c\u90a3\u4e48\u5728\u5377\u79ef\u64cd\u4f5c\u4e2d\uff0c\u6bcf\u4e2a\u5377\u79ef\u6838\u53ea\u9700\u8981\u4e0e\u8f93\u5165\u6570\u636e\u7684\u4e00\u4e2a\u5c0f\u533a\u57df\u8fdb\u884c\u4ea4\u4e92\uff0c\u800c\u4e0d\u9700\u8981\u8003\u8651\u6574\u4e2a\u56fe\u50cf\u3002\u8fd9\u79cd\u7a00\u758f\u4ea4\u4e92\u51cf\u5c11\u4e86\u9700\u8981\u5904\u7406\u7684\u6570\u636e\u91cf\uff0c\u4ece\u800c\u964d\u4f4e\u4e86\u8ba1\u7b97\u6210\u672c\u3002 \u56e0\u6b64\uff0c\u901a\u8fc7\u53c2\u6570\u5171\u4eab\u548c\u7a00\u758f\u4ea4\u4e92\uff0c\u52a0\u5165\u5377\u79ef\u6838\u6709\u52a9\u4e8e\u51cf\u5c11\u8ba1\u7b97\u91cf\uff0c\u964d\u4f4e\u6a21\u578b\u7684\u590d\u6742\u6027\uff0c\u5e76\u63d0\u9ad8\u6a21\u578b\u7684\u8ba1\u7b97\u6548\u7387\u3002
From GPT \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u8ba1\u7b97\u6bcf\u4e2a\u5377\u79ef\u5c42\u8f93\u51fa\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\u3002
\u5047\u8bbe\u8f93\u5165\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\u4e3a \\(W_{\\text{in}}\\times H_{\\text{in}}\\times D_{\\text{in}}\\)\uff0c\u5377\u79ef\u6838\u7684\u5c3a\u5bf8\u4e3a \\(F\\times F\\times D_{\\text{in}}\\times D_{\\text{out}}\\)\uff0c\u6b65\u957f\u4e3a \\(S\\)\uff0c\u586b\u5145\u4e3a \\(P\\)\u3002
\u5bf9\u4e8e\u6ca1\u6709\u586b\u5145\u7684\u60c5\u51b5\uff0c\u8f93\u51fa\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u516c\u5f0f\u8ba1\u7b97\uff1a $$ W_{\\text{out}} = \\frac{W_{\\text{in}} - F}{S} + 1 $$ $$ H_{\\text{out}} = \\frac{H_{\\text{in}} - F}{S} + 1 $$ $$ D_{\\text{out}} = \\text{\u5377\u79ef\u6838\u7684\u6570\u91cf} $$
\u5bf9\u4e8e\u6c60\u5316\u5c42\uff0c\u8f93\u51fa\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\u8ba1\u7b97\u65b9\u5f0f\u7c7b\u4f3c\uff0c\u4f46\u662f\u662f\u4f7f\u7528\u6c60\u5316\u6838\u7684\u5c3a\u5bf8\u548c\u6b65\u957f\u8fdb\u884c\u8ba1\u7b97\u3002 \u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0a\u8ff0\u516c\u5f0f\u8ba1\u7b97\u6bcf\u4e2a\u5377\u79ef\u5c42\u7684\u8f93\u51fa\u7279\u5f81\u56fe\u5c3a\u5bf8\u3002
"},{"location":"CS/DIP/DIP_Review/#_31","title":"\u56fe\u50cf\u5206\u7c7b\u7684\u533a\u522b","text":""},{"location":"CS/DIP/DIP_Review/#_32","title":"\u4ea4\u53c9\u71b5","text":"
\u4f20\u7edf\u7684\u56fe\u50cf\u5206\u7c7b\uff1a
\u4f20\u7edf\u7684\u56fe\u50cf\u5206\u7c7b\u65b9\u6cd5\u901a\u5e38\u57fa\u4e8e\u624b\u5de5\u8bbe\u8ba1\u7684\u7279\u5f81\u63d0\u53d6\u5668\uff0c\u4f8b\u5982SIFT\uff08\u5c3a\u5ea6\u4e0d\u53d8\u7279\u5f81\u53d8\u6362\uff09\u548cHOG\uff08\u65b9\u5411\u68af\u5ea6\u76f4\u65b9\u56fe\uff09\u3002\u8fd9\u4e9b\u7279\u5f81\u63d0\u53d6\u65b9\u6cd5\u4f9d\u8d56\u4e8e\u9886\u57df\u4e13\u5bb6\u5bf9\u56fe\u50cf\u7279\u5f81\u7684\u7406\u89e3\uff0c\u7136\u540e\u4f7f\u7528\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\uff08\u5982\u652f\u6301\u5411\u91cf\u673a\u3001\u968f\u673a\u68ee\u6797\u7b49\uff09\u5bf9\u63d0\u53d6\u7684\u7279\u5f81\u8fdb\u884c\u5206\u7c7b\u3002
\u4f20\u7edf\u65b9\u6cd5\u7684\u5c40\u9650\u5728\u4e8e\u7279\u5f81\u63d0\u53d6\u9700\u8981\u4f9d\u8d56\u9886\u57df\u4e13\u5bb6\u7684\u77e5\u8bc6\uff0c\u5e76\u4e14\u5728\u590d\u6742\u6570\u636e\u96c6\u4e0a\u7684\u6cdb\u5316\u80fd\u529b\u6709\u9650\u3002
\u6df1\u5ea6\u5b66\u4e60\u7684\u56fe\u50cf\u5206\u7c7b\uff1a
\u6df1\u5ea6\u5b66\u4e60\u65b9\u6cd5\uff0c\u7279\u522b\u662f\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\uff08CNN\uff09\uff0c\u80fd\u591f\u7aef\u5230\u7aef\u5730\u5b66\u4e60\u56fe\u50cf\u7684\u7279\u5f81\u8868\u793a\u548c\u5206\u7c7b\u5668\uff0c\u65e0\u9700\u624b\u52a8\u8bbe\u8ba1\u7279\u5f81\u63d0\u53d6\u5668\u3002\u6df1\u5ea6\u5b66\u4e60\u65b9\u6cd5\u901a\u8fc7\u5b66\u4e60\u4ece\u539f\u59cb\u6570\u636e\u5230\u76ee\u6807\u6807\u7b7e\u7684\u6620\u5c04\u5173\u7cfb\uff0c\u53ef\u4ee5\u81ea\u52a8\u5730\u53d1\u73b0\u548c\u63d0\u53d6\u7279\u5f81\uff0c\u4ece\u800c\u5728\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\u4e0a\u53d6\u5f97\u4e86\u663e\u8457\u7684\u6027\u80fd\u63d0\u5347\u3002
- \u6df1\u5ea6\u5b66\u4e60\u65b9\u6cd5\u7684\u4f18\u52bf\u5728\u4e8e\u5b83\u4eec\u80fd\u591f\u4ece\u5927\u89c4\u6a21\u6570\u636e\u4e2d\u5b66\u4e60\u7279\u5f81\u8868\u793a\uff0c\u65e0\u9700\u4f9d\u8d56\u9886\u57df\u4e13\u5bb6\u7684\u5148\u9a8c\u77e5\u8bc6\uff0c\u540c\u65f6\u5728\u5904\u7406\u590d\u6742\u6570\u636e\u96c6\u65f6\u5177\u6709\u66f4\u597d\u7684\u6cdb\u5316\u80fd\u529b\u3002
"},{"location":"CS/DIP/DIP_Review/#cnn","title":"CNN","text":"
- \u4ee3\u8868\u542b\u4e49\uff1a - \u4ea4\u53c9\u71b5\u662f\u4e00\u79cd\u8861\u91cf\u4e24\u4e2a\u6982\u7387\u5206\u5e03\u4e4b\u95f4\u5dee\u5f02\u7684\u5ea6\u91cf\u65b9\u5f0f\u3002\u5728\u673a\u5668\u5b66\u4e60\u4e2d\uff0c\u4ea4\u53c9\u71b5\u5e38\u88ab\u7528\u4f5c\u635f\u5931\u51fd\u6570\uff0c\u7279\u522b\u662f\u5728\u5206\u7c7b\u95ee\u9898\u4e2d\u3002
- \u635f\u5931\\(L\\)\uff1a
- \u5bf9\u4e8e\u4e8c\u5206\u7c7b\u95ee\u9898\uff0c\u7ed9\u5b9a\u771f\u5b9e\u6807\u7b7e\\(y\\)\u548c\u6a21\u578b\u9884\u6d4b\u7684\u6982\u7387\u5206\u5e03\\(\\hat{y}\\)\uff0c\u4ea4\u53c9\u71b5\u635f\u5931\\(L\\)\u53ef\u4ee5\u8868\u793a\u4e3a\uff1a\\(L(y, \\hat{y}) = -\\left(y \\log(\\hat{y}) + (1 - y) \\log(1 - \\hat{y})\\right)\\)\u3002
- \u5bf9\u4e8e\u591a\u5206\u7c7b\u95ee\u9898\uff0c\u7ed9\u5b9a\u771f\u5b9e\u6807\u7b7e\\(y\\)\u548c\u6a21\u578b\u9884\u6d4b\u7684\u6982\u7387\u5206\u5e03\\(\\hat{y}\\)\uff0c\u4ea4\u53c9\u71b5\u635f\u5931\\(L\\)\u53ef\u4ee5\u8868\u793a\u4e3a\uff1a\\(L(y, \\hat{y}) = -\\sum_{i} y_i \\log(\\hat{y}_i)\\)\uff0c\u5176\u4e2d\\(y_i\\)\u8868\u793a\u771f\u5b9e\u6807\u7b7e\u7684\u6982\u7387\u5206\u5e03\uff0c\\(\\hat{y}_i\\)\u8868\u793a\u6a21\u578b\u9884\u6d4b\u7684\u6982\u7387\u5206\u5e03\u3002 \u4ea4\u53c9\u71b5\u635f\u5931\u51fd\u6570\u5728\u8bad\u7ec3\u795e\u7ecf\u7f51\u7edc\u65f6\u7ecf\u5e38\u88ab\u7528\u4f5c\u76ee\u6807\u51fd\u6570\uff0c\u56e0\u4e3a\u5b83\u80fd\u591f\u6709\u6548\u5730\u8861\u91cf\u6a21\u578b\u8f93\u51fa\u4e0e\u771f\u5b9e\u6807\u7b7e\u4e4b\u95f4\u7684\u5dee\u5f02\uff0c\u5e76\u4e14\u80fd\u591f\u4fc3\u4f7f\u6a21\u578b\u4ea7\u751f\u66f4\u4e3a\u51c6\u786e\u7684\u6982\u7387\u5206\u5e03\u8f93\u51fa\u3002
"},{"location":"CS/DIP/DIP_Review/#cnn_1","title":"\u4e3a\u4ec0\u4e48\u5f15\u2f0aCNN\u53ef\u4ee5\u2f24\u89c4\u6a21\u51cf\u5c11\u6743\u6570\u53c2\u6570\u8bad\u7ec3\u91cf","text":"
- CNN \u662f\u5c11\u6709\u7684\u53ef\u4ee5\u76d1\u7763\u8bad\u7ec3\u7684\u6df1\u5ea6\u6a21\u578b\uff0c\u800c\u4e14\u5bb9\u6613\u7406\u89e3\u3001\u5b9e\u73b0\u3002
\u56e0\u4e3aCNN\u901a\u8fc7
1\uff09 \u5c40\u90e8\u8fde\u63a5\uff08Local Connectivity\uff09 \u5377\u79ef\u64cd\u4f5c\u662f\u5c40\u90e8\u8fde\u63a5\u7684\uff0c\u8fd9\u610f\u5473\u7740\u6bcf\u4e2a\u795e\u7ecf\u5143\u4ec5\u4e0e\u8f93\u5165\u7684\u5c40\u90e8\u533a\u57df\u76f8\u8fde\uff0c\u800c\u4e0d\u662f\u4e0e\u6574\u4e2a\u8f93\u5165\u76f8\u8fde\u3002\u8fd9\u79cd\u5c40\u90e8\u8fde\u63a5\u7684\u65b9\u5f0f\u4e5f\u51cf\u5c11\u4e86\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u6570\u91cf\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u795e\u7ecf\u5143\u53ea\u9700\u8981\u5b66\u4e60\u4e0e\u5c40\u90e8\u4fe1\u606f\u76f8\u5173\u7684\u6743\u91cd\u3002
2\uff09 \u6743\u503c\u5171\u4eab\uff08Shared Weights\uff09 \u5728CNN\u4e2d\uff0c\u5377\u79ef\u5c42\u4f7f\u7528\u6ee4\u6ce2\u5668\uff08\u6216\u5377\u79ef\u6838\uff09\u5bf9\u8f93\u5165\u8fdb\u884c\u5377\u79ef\u64cd\u4f5c\u3002\u8fd9\u4e9b\u6ee4\u6ce2\u5668\u5728\u56fe\u50cf\u7684\u4e0d\u540c\u4f4d\u7f6e\u90fd\u4f7f\u7528\u76f8\u540c\u7684\u53c2\u6570\u8fdb\u884c\u7279\u5f81\u63d0\u53d6\u3002\u8fd9\u79cd\u53c2\u6570\u5171\u4eab\u673a\u5236\u53ef\u4ee5\u5927\u5927\u51cf\u5c11\u9700\u8981\u8bad\u7ec3\u7684\u53c2\u6570\u6570\u91cf\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u6ee4\u6ce2\u5668\u7684\u53c2\u6570\u90fd\u88ab\u91cd\u590d\u4f7f\u7528\u5728\u8f93\u5165\u7684\u4e0d\u540c\u4f4d\u7f6e\u4e0a
3\uff09 \u6c60\u5316\uff08Pooling\uff09 \u6c60\u5316\u5c42\u901a\u8fc7\u5bf9\u8f93\u5165\u6570\u636e\u8fdb\u884c\u4e0b\u91c7\u6837\uff0c\u51cf\u5c11\u4e86\u6bcf\u4e2a\u7279\u5f81\u56fe\u7684\u5c3a\u5bf8\uff0c\u4ece\u800c\u51cf\u5c11\u4e86\u540e\u7eed\u5c42\u7684\u8ba1\u7b97\u91cf\u3002\u8fd9\u6709\u52a9\u4e8e\u964d\u4f4e\u6a21\u578b\u7684\u590d\u6742\u5ea6\u548c\u8ba1\u7b97\u6210\u672c\u3002
\u6765\u964d\u4f4e\u53c2\u6570\u91cf
"},{"location":"CS/DIP/DIP_Review/#cnn_2","title":"CNN\u6c60\u5316\u7684\u610f\u4e49","text":"\u200b CNN\u6c60\u5316\u53ef\u4ee5\u901a\u8fc7\u6c60\u5316\u5c42\u6765\u964d\u4f4e\u5377\u79ef\u5c42\u8f93\u51fa\u7684\u7279\u5f81\u7ef4\u5ea6\uff0c\u5728\u6709\u6548\u51cf\u5c11\u2f79\u7edc\u53c2\u6570\u7684\u540c\u65f6\u8fd8\u53ef\u4ee5\u9632\u2f4c\u8fc7\u62df\u5408\u73b0\u8c61\u3002
\u66f4\u5927\u7684\u63a5\u53d7\u57df
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/","title":"Index","text":"\u7ea6 351 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
\u8bfe\u7a0b\u4fe1\u606f
- \u7b14\u8bb0\u5185\u5bb9\u4e3b\u8981\u6765\u81ea\u4e8e\u8bfe\u672c\u548c\u4e0a\u8bfe\u7528\u7684PPT
- \u7406\u8bba\u90e8\u5206: \u8fd9\u95e8\u8bfe\u7684\u7406\u8bba\u90e8\u5206\u96be\u5ea6\u8fd8\u597d\uff0c\u4e3b\u8981\u662f\u8981\u7406\u89e3\u4e00\u4e0b\u65f6\u5e8f\u7535\u8def\u8fd8\u6709\u540e\u9762\u7684\u5b58\u50a8\u5668\u90e8\u5206\uff0c\u8fd9\u4e00\u90e8\u5206\u7684\u65f6\u5e8f\u5ef6\u8fdf\u5206\u6790\u3001\u7535\u8def\u8bbe\u8ba1\u90fd\u6bd4\u8f83\u91cd\u8981\u3002
- \u5b9e\u9a8c\u90e8\u5206: \u786c\u4ef6\u8bfe\u7684\u5b9e\u9a8c\u6bd4\u8f83\u8ba9\u4eba\u5934\u5927\u3002\u524d\u4e09\u6b21\u5b9e\u9a8c\u662f\u7c7b\u4f3c\u4e8e\u7269\u7406\u5b9e\u9a8c\u7684\uff0c\u793a\u6ce2\u5668\u7684\u4f7f\u7528\u3001\u7535\u8def\u7684\u642d\u5efa\u7b49\u7b49\uff1b\u4e4b\u540e\u76844-7\u6b21\u5b9e\u9a8c\u4e3b\u8981\u5b66\u4e60ISE\u7684\u642d\u5efa\u4e0e\u57fa\u672c\u4f7f\u7528\uff08\u6211\u4eec\u8fd9\u4e00\u5c4a\u90e8\u5206\u73ed\u7ea7\u7528\u7684vivado\uff0c\u4e4b\u540e\u4e5f\u53ef\u80fd\u7edf\u4e00\u7528vivado\uff09\uff1b\u518d\u4e4b\u540e\u7684\u5b9e\u9a8c\u4f1a\u8981\u6c42\u5199\u4e00\u4e9bVerilog\u4ee3\u7801\uff08\u524d\u9762\u7684\u4e5f\u8981\u5199\uff0c\u4f46\u4e00\u822c\u90fd\u4f1a\u76f4\u63a5\u7ed9\u51fa\uff09\u3002 \u5c31\u6211\u4e2a\u4eba\u7684\u4f53\u9a8c\u6765\u8bf4\uff0c\u524d\u9762\u7684\u5b9e\u9a8c\u96be\u5ea6\u8fd8\u597d\uff0c\u4f46\u6700\u597d\u5728\u8fd9\u6bb5\u65f6\u95f4\u8d81\u7740\u6709\u6307\u5bfc\u628a\u4e00\u4e9b\u4e1c\u897f\u5f04\u660e\u767d\uff0c\u4e0d\u7136\u5230\u540e\u9762\u505a\u8d77\u6765\u4f1a\u5f88\u6162\u3002\u5927\u7a0b\u7684\u8bdd\uff0c\u8fd8\u662f\u5efa\u8bae\u65e9\u4e00\u70b9\u5f00\u59cb\uff0c\u6211\u4eec\u7ec4\u5f00\u59cb\u7684\u6bd4\u8f83\u65e9\uff0c\u5927\u6982\u641e\u4e86\u4e24\u4e09\u5468\u5728\u671f\u672b\u5468\u4e4b\u524d\u641e\u5b8c\u4e86\u3002\u5982\u679c\u5f00\u59cb\u665a\u7684\u8bdd\u5f88\u53ef\u80fd\u5f71\u54cd\u671f\u672b\u7684\u590d\u4e60\u3002
- \u8bfe\u7a0b\u5206\u6570
- Theory: 70%
- Quizzes 40% * 70% = 28%
- Projects: 20% *70 = 14%
- The final Examination: 40%*70% = 28% \u2022 Necessary condition: the score \u226550
- Experiments: 30%
\u8d44\u6e90
\u5f3a\u63a8\uff01\u4fee\u4f6c\u7684\u7b14\u8bb0\uff1aIsshiki\u4fee's Notebook
\u5386\u5e74\u5377\u548c\u8bfe\u672c\u7b54\u6848\uff1a \u6c42\u662f\u6f6e
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/","title":"Labs","text":"\u671f\u672b\u590d\u4e60\u7528
https://guahao31.github.io/2023_DD/lab5/decoder/
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#lab-05-decoder","title":"Lab 05 Decoder","text":"
- 74LS138
- G1,G2 G
- MC14495
\u7ea6 977 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
\u4f4e\u7535\u5e73\u6709\u6548(Low-Level Active)\uff0c\u6216\u79f0\u4f4e\u7535\u5e73\u89e6\u53d1\uff0c\u6307\u7684\u662f\u5728\u6570\u5b57\u7535\u8def\u4e2d\uff0c\u903b\u8f91\u95e8\u6216\u89e6\u53d1\u5668\u7684\u8f93\u5165\u6216\u63a7\u5236\u4fe1\u53f7\u5728\u4f4e\u7535\u5e73\uff08\u8f83\u4f4e\u7684\u7535\u538b\u503c\uff09\u65f6\u88ab\u89c6\u4e3a\u6709\u6548\u6216\u89e6\u53d1\u52a8\u4f5c\u3002\u9ad8\u7535\u5e73\u6709\u6548\u5219\u4e0e\u4e4b\u76f8\u5bf9\u3002 \u5728\u8fdb\u884c\u8bbe\u8ba1\u65f6\uff0c\u4e24\u8005\u90fd\u662f\u53ef\u884c\u7684\u9009\u9879\u3002
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#74ls138","title":"74LS138","text":"74LS138 \u82af\u7247\u662f\u4e00\u79cd 3-8 \u8bd1\u7801\u5668\u82af\u7247\uff0c\u7528\u4e8e\u5c06 3 \u4f4d\u4e8c\u8fdb\u5236\u5730\u5740\u8f93\u5165\u4fe1\u53f7\u8f6c\u6362\u4e3a 8 \u4e2a\u8f93\u51fa\u4fe1\u53f7\u4e4b\u4e00\u3002\u4e3b\u8981\u7aef\u53e3\u4e3a\u4f7f\u80fd\u8f93\u5165\u7ba1\u811a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#_1","title":"\u4f7f\u80fd\u4fe1\u53f7","text":"G, G2A, G2B
\uff0c\u5730\u5740\u8f93\u5165\u7ba1\u811aA, B, C
\uff08\u5176\u4e2dA
\u4e3a\u4f4e\u5730\u5740\uff09\uff0c\u8f93\u51fa\u7ba1\u811aY0~Y7
\u300274LS138 \u6709\u4e09\u4e2a\u4f7f\u80fd\u4fe1\u53f7
G, G2A, G2B
\uff0c\u5176\u4e2dG
\u4fe1\u53f7\u4e3a\u9ad8\u7535\u5e73\u6709\u6548\u7684\u4e3b\u8981\u4f7f\u80fd\u4fe1\u53f7\uff0c\u5f53\u5b83\u5904\u4e8e\u4f4e\u7535\u4f4d\u65f6\uff0c\u6240\u6709\u7684\u8f93\u51fa\u4fe1\u53f7\u5747\u5904\u4e8e\u65e0\u6548\u7535\u4f4d\uff08\u9ad8\u7535\u4f4d\uff09\u3002
G2A, G2B
\u662f\u770b\u8d77\u6765\u6709\u4e9b\u5197\u4f59\u7684\u4f7f\u80fd\u4fe1\u53f7\uff0c\u4ece\u771f\u503c\u8868\u53ef\u4ee5\u770b\u51fa\uff0c\u5b83\u4eec\u4e3a\u4f4e\u7535\u5e73\u6709\u6548\uff0c\u5f53\u4e24\u4e2a\u4fe1\u53f7\u90fd\u4e3a\u4f4e\u7535\u5e73\u4e14G
\u4e3a\u9ad8\u7535\u5e73\u65f6\uff0c3-8 \u8bd1\u7801\u5668\u80fd\u6b63\u5e38\u5de5\u4f5c\uff1b\u5f53G2A
\u4e0eG2B
\u4e2d\u6709\u4e00\u4e2a\u4e3a\u9ad8\u7535\u5e73\u65f6\uff0c\u8f93\u51fa\u5747\u5904\u4e8e\u65e0\u6548\u7535\u5e73\u3002\u8fd9\u4e24\u4e2a\u201c\u5197\u4f59\u201d\u7684\u4f7f\u80fd\u4fe1\u53f7\u53ef\u4ee5\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u53d1\u6325\u4f5c\u7528\uff0c\u6bd4\u5982\u5c06 74LS138 \u7528\u4f5c\u6570\u636e\u5206\u914d\u5668\uff08\u6216\u79f0\u591a\u8def\u5206\u914d\u5668\uff09\u65f6\uff0c\u53ef\u4ee5\u5c06
G2B
\u7f6e\u4e8e\u4f4e\u7535\u5e73\uff0c\u8fd9\u65f6\u5730\u5740\u4fe1\u53f7\u5bf9\u5e94\u7684\u90a3\u4e2a\u8f93\u51fa\u7aef\u53e3\u8f93\u51fa\u7684\u7535\u5e73\u5c06\u4e0eG2A
\u7684\u7535\u5e73\u76f8\u540c\u3002\u540c\u6837\u7684\uff0c\u5f53\u6211\u4eec\u5e0c\u671b\u4f7f\u7528\u4e24\u4e2a 74LS138 \u82af\u7247\u7ec4\u6210\u4e00\u4e2a 4-16 \u8bd1\u7801\u5668\u65f6\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e24\u4e2a\u4fe1\u53f7\u4e2d\u7684\u4e00\u4e2a\u7528\u4e8e\u5206\u914d\u9ad8\u4e00\u534a\u5730\u5740\u4e0e\u7b2c\u4e00\u534a\u5730\u5740\uff0c\u800c\u4fdd\u7559
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#_2","title":"\u5730\u5740\u4fe1\u53f7","text":"G
\u4e3b\u4f7f\u80fd\u4fe1\u53f7\u7684\u4f5c\u7528\uff08\u5982\u679c\u4ec5\u6709\u4e00\u4e2aG
\u4f7f\u80fd\u4fe1\u53f7\uff0c\u5b83\u5c06\u88ab\u7528\u4e8e\u533a\u5206\u9ad8\u4f4e\u5730\u5740\uff0c\u800c\u4f7f\u5f97\u5230\u7684\u7535\u8def\u9700\u8981\u6dfb\u52a0\u989d\u5916\u7684\u903b\u8f91\u6765\u5b9e\u73b0\u4e3b\u4f7f\u80fd\u4fe1\u53f7\u7684\u4f5c\u7528\uff09\u3002\u6211\u4eec\u7ea6\u5b9a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#lab-06","title":"Lab 06 \u4e03\u6bb5\u6570\u7801\u7ba1","text":"A
\u4fe1\u53f7\u4e3a\u6700\u4f4e\u4f4d\u7684\u5730\u5740\u4fe1\u53f7\uff0cC
\u4e3a\u6700\u9ad8\u4f4d\u7684\u5730\u5740\u4fe1\u53f7\uff0c\u6bd4\u5982A, B, C
\u4fe1\u53f7\u503c\u5206\u522b\u4e3a0, 1, 1
\u65f6\uff0c\u6211\u4eec\u8868\u8fbe\u7684\u5730\u5740\u4e3ab110
\uff0c\u5373\u5bf9\u5e94\u9009\u62e9Y6
\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u4e9b LED \u5171\u9633\u6781\uff0c\u6211\u4eec\u7ed9\u51fa
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#mc14495","title":"MC14495","text":"0
\u624d\u80fd\u70b9\u4eae\uff08\u4f4e\u7535\u5e73\u6709\u6548\uff09\u3002\u6bd4\u5982\uff0c\u6211\u4eec\u5e0c\u671b\u4e03\u6bb5\u6570\u7801\u7ba1\u663e\u793a\u4e3a\u4e0a\u56fe\u4e2d\u201c0\u201d\u7684\u6837\u5b50\uff0c\u9700\u8981\u5c06g
\u4ee5\u5916\u7684\u4fe1\u53f7\u8bbe\u7f6e\u4e3a0
\u8868\u793a\u70b9\u4eae\u5e76\u5c06g
\u8bbe\u7f6e\u4e3a1
\u3002\u6211\u4eec\u8981\u5b9e\u73b0\u7684\u7ec4\u5408\u90e8\u4ef6
MyMC14495
\u7aef\u53e3\u5982\u4e0b\uff1a
D3~D0
\uff1a\u8f93\u5165\u7684 4 \u4f4d\u4e8c\u8fdb\u5236\u6570\u5b57LE
\uff1a\u4f7f\u80fd\u4fe1\u53f7\uff0c\u4f4e\u7535\u5e73\u6709\u6548point
\uff1a\u7528\u6765\u8868\u793a\u5c0f\u6570\u70b9\u662f\u5426\u70b9\u4eae\uff0c\u9ad8\u7535\u5e73\u6709\u6548- \u8f93\u51fa\u4fe1\u53f7
a~g, p
\uff1a\u5747\u4e3a\u4f4e\u7535\u5e73\u6709\u6548\u5728\u8fdb\u884c\u5b9e\u73b0\u65f6\uff0c\u8bf7\u6ce8\u610f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#lab-07-multiplexer","title":"Lab 07 Multiplexer","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#_3","title":"\u8ba1\u6570\u5668\u548c\u8ba1\u65f6\u5668","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/#74ls161","title":"74LS161","text":"LE
\u4e3a\u4f4e\u7535\u5e73\u6709\u6548\uff0c\u5373\u503c\u4e3a1
\u65f6\u6240\u6709\u7684\u8f93\u51fa\u5747\u4e3a\u65e0\u6548\u76841
\uff1bpoint
\u4e3a\u9ad8\u7535\u5e73\u6709\u6548\uff0c\u5373\u503c\u4e3a1
\u65f6\u70b9\u4eae\u5c0f\u6570\u70b9p
\u8f93\u51fa\u4e3a0
\u300274LS161 \u82af\u7247\u5177\u6709\u540c\u6b65\u56db\u4f4d\u4e8c\u8fdb\u5236\u8ba1\u6570\u5668\u529f\u80fd\uff0c\u5176\u5f15\u811a\u5982\u4e0b\uff1a
CP
\uff1a\u63a5\u5165\u65f6\u949f\u4fe1\u53f7\uff0c\u4e0a\u5347\u6cbf\u89e6\u53d1CRn
\uff1a\u6e05\u96f6\u7aef\uff0c\u4f4e\u7535\u5e73\u6709\u6548\uff0c\u4e14\u4e3a\u5f02\u6b65\u6e05\u96f6LDn
\uff1a\u7f6e\u6570\u63a7\u5236\u7aef\uff0c\u4f4e\u7535\u5e73\u6709\u6548D3~D0
\uff1a\u7f6e\u6570\u6570\u636e\u7aef\uff0c\u5f53LDn
\u6709\u6548\u65f6\u5c06\u6570\u636e\u5199\u5165CTT, CTP
\uff1a\u4f7f\u80fd\u7aef\uff0c\u4e24\u811a\u5747\u4e3a\u9ad8\u7535\u5e73\u65f6\u542f\u7528\u8ba1\u6570\u529f\u80fd\uff0c\u4efb\u610f\u4e00\u811a\u4e3a\u4f4e\u7535\u5e73\u65f6\u8ba1\u6570\u5668\u4fdd\u6301\u539f\u72b6\u6001Q3~Q0
\uff1a\u6570\u636e\u8f93\u51fa\u7aefCO
\uff1a\u8fdb\u4f4d\u8f93\u51fa\u7aef\uff0c\u5f53\u8f93\u51fa\u4f4d\u5747\u4e3a 1 \u65f6\u7f6e 1\u8bf7\u7279\u522b\u5173\u6ce8\u8f93\u51fa\u6539\u53d8\u65f6\u673a\uff1a\u5f02\u6b65\u6e05\u96f6\u610f\u5473\u7740\u4e0d\u8bba\u65f6\u949f\u4fe1\u53f7\u4e3a\u4f55\u5f53\u6e05\u96f6\u7aef\u6709\u6548\u65f6\u7acb\u5373\u6539\u53d8\u8f93\u51fa\u4e3a 0\uff1b\u6e05\u96f6\u5916\u7684\u6240\u6709\u8f93\u51fa\u6539\u53d8\u90fd\u53d1\u751f\u5728\u65f6\u949f\u4e0a\u5347\u6cbf\uff08\u5305\u62ec\u7f6e\u6570\u4e0e\u8ba1\u6570\uff09\u3002\u5176\u529f\u80fd\u8868\u5982\u4e0b\uff1a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/","title":"P1","text":"\u7ea6 175 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#_2","title":"\u4fe1\u606f\u8868\u8fbe","text":"
For digital systems, the variables take on discrete values.
\u7535\u4f4d\u8868\u793a
\u6a21\u62df\u4fe1\u53f7\u3001\u6570\u5b57\u4fe1\u53f7
\u533a\u5206\u7f16\u7801\u548c\u6570\u5236\u8f6c\u6362
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#_3","title":"\u6570\u5236\u8f6c\u6362","text":"10 - 2
\u5206\u5f00\u8ba1\u7b97\u6574\u6570\u90e8\u5206\u548c\u5c0f\u6570\u90e8\u5206
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#encoding","title":"\u7f16\u7801 | Encoding","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#numeric","title":"Numeric","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#_4","title":"\u72ec\u70ed\u7801/\u72ec\u51b7\u7801","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#bcd","title":"BCD \u7801","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#excess-3","title":"\u4f59\u4e09\u7801\uff08Excess 3\uff09","text":"\u5b9e\u8d28\u662f\u4e00\u79cd\u6620\u5c04\u5173\u7cfb\u3002\u628a\u5341\u8fdb\u4f4d\u5236\u7684\u8fdb\u4f4d\u6620\u5c04\u5230 \u5341\u516d\u8fdb\u4f4d\u5236
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#gray-code","title":"\u683c\u96f7\u7801\uff08Gray Code\uff09","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#non-numeric","title":"Non-Numeric","text":"ASCII \u7801 UNICODE
\u5947\u5076\u68c0\u9a8c\uff08parity\uff09
\uff01 \u662f\u4fdd\u8bc1\u6574\u4e2aSequence\u5177\u6709\u5947\u6570\u6216\u8005\u5076\u6570\u4e2a1\uff0c\u800c\u4e0d\u662f\u7528\u6765\u5224\u65ad\u524d\u9762\u6709\u591a\u5c11\u4e2a1
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#number-system","title":"\u6570\u5236\u8f6c\u6362 | Number System","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/#_5","title":"\u9898\u76ee","text":"\u4e4b\u524d\u6ca1\u6ce8\u610f\u8fc7\u8fd9\u4e2a\u77e5\u8bc6\u70b9
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/","title":"P2","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#part-1","title":"Part 1","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#logic-gate","title":"Logic Gate | \u903b\u8f91\u95e8","text":"
- \u5c0f\u6570\u7684\u8865\u7801\uff0c\u5bf9\u6574\u6570\u90e8\u5206\u3001\u5c0f\u6570\u90e8\u5206\u5206\u522b\u505a
\u7ea6 612 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
NOT OR EXCLUCIVE OR NOT AND EXCLUCIVE NOR
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#gate-delay","title":"Gate Delay | \u95e8\u5ef6\u8fdf","text":"
- Identity
\u8f83\u8be6\u7ec6 \u4f20\u64ad\u5ef6\u65f6
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#boolean-algebra","title":"Boolean Algebra | \u5e03\u5c14\u4ee3\u6570","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#_1","title":"\u8868\u793a","text":"Truth Table Logic Graph Equation
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#duality","title":"Duality","text":"
- \u4e0d\u6539\u53d8\u4e8b\u4ef6\u672c\u8eab
- self - dual
AB + AC + BC
- \u53cd\u51fd\u6570 | Complementing
\u6539\u53d8\u4e8b\u4ef6 \u5176\u4ed6\u6027\u8d28\u540c dual
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#some-principles","title":"* some principles","text":"
- \u9700\u8981\u66f4\u591a\u6ce8\u610f\u90a3\u4e9b\u4f7f\u7528 OR \u5206\u914d\u5f8b\u6216\u7ed3\u5408\u5f8b\u7684\uff0c\u8fd9\u4e00\u4e8b\u5b9e\u672c\u8eab\u8fdd\u53cd\u4e4b\u524d\u7684\u6570\u5b66\u903b\u8f91
\u601d\u8def\uff1a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#canonical-forms","title":"Canonical Forms | \u89c4\u8303\u578b","text":"
**AND**
**\u64cd\u4f5c\u7b26\u591a\u7684\uff1a\u6c42\u5bf9\u5076 dual **
- \u65b9\u6cd5
- \u8f6c\u6362 dual
- \u5316\u5f52
- Minterm
- \u6bcf\u4e2a\u53d8\u91cf\u90fd\u51fa\u73b0
index
the decimal equivalent of the binary combination corresponding to the Minterm
- Maxterm
- SOM | sum of minterms
- POM | product of maxterms
- \u6240\u6709\u4ee4 f \u503c\u4e3a 0 \u7684\u7ec4\u5408 \u53ea\u8981\u6709\u4efb\u610f\u4e00\u4e2a\u4e0d\u4e3a 0 \u5219\u4e3a 1
:::info Tips:
- \u6700\u5927\u9879\u548c\u6700\u5c0f\u9879\u53ef\u4ee5\u76f8\u4e92\u8f6c\u5316
:::
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#standard-form","title":"Standard Form | \u6807\u51c6\u578b","text":"\u7c7b\u4f3c\u79bb\u6563\u6570\u5b66\u4e2d\u7684 DNF CNF \u4e0e Full DNF \u7684\u533a\u522b \u53ef\u4ee5\u5c11\u9879
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#part-2","title":"Part 2 \u4f18\u5316","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#cost-function","title":"cost function","text":"
- sum of product
- product of sum
\u4e09\u4e2a\u7ef4\u5ea6
literal
Complement \u5305\u62ec\u672c\u8eab\u90fd\u8ba1\u7b97\u5728\u5185\uff0c\u91cd\u590d\u4e5f\u8ba1\u7b97G
GN
- \u6ce8\u610f comlemented single literals \u53ea\u8ba1\u5165\u4e00\u6b21
\u5229\u7528\u56fe\u793a\u6570 \u67e5\u8fde\u7ebf\u6570
\u6570\u7684\u65f6\u5019\u53ef\u4ee5\u4e00\u5c42\u5c42\u62c6\u89e3\u4e0b\u53bb
\u6bd4\u5982\u4e0a\u56fe\u4e2d\u7684 2 \u5b8f\u89c2\u4e0a \u4e3a X + Y \u4e4b\u540e\u518d\u53bb \u5206\u522b\u770b XY \u662f\u5426\u8ba1\u5165\u4e00\u6b21 \u62c6\u89e3 XY \u4e0d\u65ad\u91cd\u590d
**\u4f8b\u5b50**
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#k-map","title":"K-map | \u5361\u8bfa\u56fe","text":"
- \u4ee5\u7b2c\u4e09\u4e2a\u4e3a\u4f8b\u5b50
- literal cost 8
- \u9996\u5148\uff0c + \u4e24\u8fb9\u7684\u4e24\u4e2a\u5927\u9879 2` , \u6bcf\u4e2a\u5927\u9879\u5185\u90e8\uff0cA \uff0cC single\uff1bB + D 1
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#system-simplification","title":"System Simplification","text":"
- \u53ef\u4ee5\u770b\u4f5c\u771f\u503c\u8868\u7684\u53e6\u4e00\u79cd\u8868\u8fbe
- \u6ce8\u610f\u76f8\u9694\u7684 squre \u53ea\u6709\u4e00\u4f4d\u4e0d\u540c\uff0cGray Code
- \u8574\u542b\u9879 | implicant
\u542b\u6709 2n \u4e2a 1 \u7684\u77e9\u5f62
- \u4e3b\u8574\u542b\u9879 | prime implicant
\u6781\u5927\u8574\u542b\u9879
- \u57fa\u672c\u4e3b\u8574\u542b\u9879 | essential prime implicant
\u65e0\u53ef\u66ff\u4ee3 TIP : \u4e3b\u8574\u542b\u9879\u4e00\u5b9a\u5b58\u5728\u4f46\u57fa\u672c\u4e3b\u8574\u542b\u9879\u4e0d\u4e00\u5b9a \u57fa\u672c\u4e3b\u8574\u542b\u9879\u4e00\u5b9a\u5b58\u5728\u5728\u5316\u7b80\u7ed3\u679c\u4e2d
\u548c\u4e4b\u79efSOP\u7684\u4f18\u5316\u65b9\u6cd5\uff1a \u6cd5\u4e00: \u5148\u53d6\u53cd\u518d\u64cd\u4f5c \u6cd5\u4e8c\uff1a\u76f4\u63a5\u5bf9 0 \u64cd\u4f5c
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#dont-cares","title":"Don`t Cares","text":"x
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#part-3","title":"Part 3","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#gate-types","title":"Gate Types","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#primitive-gates","title":"Primitive Gates","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#buffer","title":"Buffer | \u7f13\u51b2\u5668","text":"\u63d0\u9ad8\u7535\u8def\u7535\u538b\u6c34\u5e73\u548c\u589e\u52a0\u7535\u8def\u8fd0\u884c\u901f\u5ea6\u3002
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#three-state-buffer","title":"Three-state Buffer | \u4e09\u6001\u7f13\u51b2\u5668","text":"\u7ed9\u51fa\u4e09\u79cd\u72b6\u6001\uff1a0\uff0c1\uff0cHi-Z
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#complex-gates","title":"Complex Gates","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#_2","title":"P2","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#_3","title":"\u8865\u5145","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/#odd-function","title":"Odd Function | \u5947\u51fd\u6570","text":"*IN
\uff1a\u6570\u636e\u7aef**EN**
\uff1a\u63a7\u5236\u7aefHI-Z
:** \u65e2\u4e0d\u662f\u9ad8\u7535\u5e73\u4e5f\u4e0d\u662f\u4f4e\u7535\u5e73\uff0c\u5b83\u7684\u8868\u73b0\u4e0e\u901a\u8def\u7c7b\u4f3c\uff0c\u5982\u679c\u8f93\u5165\u5230\u4e0b\u4e00\u7aef\u53e3\u5c06\u4e0d\u9020\u6210\u5f71\u54cd\u3002\u53e6\u5916\uff0c\u5982\u679c\u7528\u4e07\u7528\u8868\u6d4b\u91cf\u7535\u5e73\uff0c\u5176\u9ad8\u4f4e\u53d6\u51b3\u4e8e\u5b83\u540e\u9762\u7684\u4e1c\u897f\u901a\u8fc7
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/","title":"P3","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#elements-for-design","title":"Elements for Design | \u8bbe\u8ba1\u8981\u7d20","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#fan-in","title":"fan-in","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#fan-out","title":"fan-out","text":"exclusive or
\u642d\u5efafan-out \u4f1a\u5f71\u54cdPropogation Delay
\u53ef\u4ee5\u88ab\u6807\u51c6\u8d1f\u8f7d\uff08stadard load\uff09\u5b9a\u4e49
\u6807\u51c6\u8d1f\u8f7d\uff1a \u5927\u5c0f\u4e0a\u7b49\u540c\u4e8e\u4e00\u4e2a\u53cd\u76f8\u5668\u7684\u8f93\u5165
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#transition-time","title":"Transition Time | \u8f6c\u6362\u65f6\u95f4","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#_1","title":"\u4f20\u64ad\u6a21\u578b","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#gate-transport-delay","title":"Gate Transport Delay | \u4f20\u64ad\u5ef6\u8fdf","text":"
- \u5bf9\u4e8e\u8f93\u51fa\u7684\u53d8\u5316\u800c\u8a00
tHL
VCC \u7684 10% \u5347\u9ad8\u5230 90% \u6240\u9700\u8981\u7684\u65f6\u95f4tLH
VCC \u7684 90% \u964d\u4f4e\u5230 10% \u6240\u9700\u8981\u7684\u65f6\u95f4- \u65e0\u9700\u6bd4\u8f83\u53d8\u5316
- \u6700\u5927\u8d1f\u8f7d\uff1a\u4e0d\u8d85\u8fc7\u89c4\u5b9a\u7684\u6700\u5927\u8f6c\u6362\u65f6\u95f4\u7684\u8d1f\u8f7d
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#inertial-delay","title":"Inertial delay | \u60ef\u6027\u5ef6\u8fdf","text":"
tPHL
High to low\u8ba1\u7b97\u65b9\u6cd5
\u662f\u53d8\u5316\u524d\u540e\u7684\u4e2d\u70b9\u65f6\u95f4\u5dee- td = max( tPHL,tPLH )
\u7c7b\u4f3c\u4e8e\u4f20\u8f93\u5ef6\u8fdf
Difinition
\uff1a \u5982\u679c\u8f93\u5165\u53d8\u5316\u4f7f\u5f97\u8f93\u51fa\u5728\u4e00\u4e2a\u5c0f\u4e8e\u62d2\u7edd\u65f6\u95f4\u7684\u95f4\u9694\u5185\u53d1\u751f\u4e24\u6b21\u53d8\u5316\uff0c\u90a3\u4e48\u7b2c\u4e00\u4e2a\u53d8\u5316\u5c06\u4e0d\u4f1a\u53d1\u751f \u4ee5\u4e0b\u56fe\u4e3a\u4f8b \u84dd\u8272\u7684\u6761\u5e26\u4ee3\u8868\u4f20\u64ad\u5ef6\u8fdf\uff0c\u5176\u4e2d\u7684\u9ed1\u8272\u6761\u4ee3\u8868\u60ef\u6027\u5ef6\u8fdf"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#circuit-delay","title":"Circuit Delay | \u7535\u8def\u5ef6\u8fdf","text":"
- a\u3001b\uff1ab \u53d1\u751f\u5728\u62d2\u7edd\u65f6\u95f4 [rejection time]\uff0c\u6545 a \u6ca1\u6709\u51fa\u73b0\u5728\u60ef\u6027\u5ef6\u8fdf\u4e2d
- c\u3001d\u3001e\uff1ad \u6070\u597d\u5728\u62d2\u7edd\u65f6\u95f4\uff0c\u6545\u800c c \u53d1\u751f\uff0c\u53c8 e \u5728\u62d2\u7edd\u65f6\u95f4\u5185\uff0c\u6545\u800c d \u4e0d\u53d1\u751f
\u7ea6 1043 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#design-procedure","title":"Design Procedure | \u8bbe\u8ba1\u8fc7\u7a0b","text":"
- Specialfication
- Formulation
Optimization
Technology mapping | \u5de5\u827a\u6620\u5c04
\u4e00\u822c\u4f7f\u7528\u4e0e\u975e\u95e8+\u975e\u95e8 \u6216\u8005 \u6216\u975e\u95e8 + \u975e\u95e8
\u5148\u5c06\u5176\u4ed6\u95e8\u66ff\u6362\u4e3a\u6307\u5b9a lib \u4e2d\u7684\u5668\u4ef6\uff0c\u7136\u540e\u6d88\u53bb doubly invertor
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#part-2","title":"Part 2","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#_2","title":"\u7ec4\u5408\u903b\u8f91","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#function-and-function-blocks","title":"Function and function Blocks | \u57fa\u672c\u51fd\u6570","text":"
- Verification | \u9a8c\u8bc1
- Manaul Logic Analysis \u5229\u7528\u771f\u503c\u8868\u3001\u5e03\u5c14\u4ee3\u6570\u7b49\u65b9\u5f0f\u8fdb\u884c\u9a8c\u8bc1
- Simulation \u8fdb\u884c\u4eff\u771f
Single varible
- \u5e38\u503c (fixing - value) | \u8f93\u51fa\u5b9a\u503c
- \u4f20\u8f93\uff08transforming\uff09| \u4fdd\u6301\u4e0d\u53d8
- \u9006\u53d8\uff08inverting\uff09| \u76f8\u53cd
Multiple Rugimentary Functions
Enabling Function
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#docoding","title":"Docoding | \u89e3\u7801","text":"
- \u5141\u8bb8
input
\u662f\u5426\u8f93\u5165- \u5f53\u4e2d\u65ad\u65f6\uff0c\u8f93\u51fa\u503c\u53ef\u80fd\u4e3aHi-Z\uff0c0\uff0c1
- \u6ce8\u610f
AND
\u548cOR
\u4e2d\u5177\u6709\u4e0d\u540c\u7684\u8868\u73b0\u5f62\u5f0f(\u539f\u7406\u4e00\u6837)
Definition
input
n
bits outputn<=m<=2^n
\u4ea7\u751f
minterm
\u4e8e\u662f\u884d\u751f\u53e6\u4e00\u4e2a \u8bdd\u9898Decoder and OR Gates
n-to-m line decoder
A general Rule
\u5982\u679c\u4e00\u76f4\u4f7f\u7528
minterm
\u8fdb\u884c\u89e3\u7801\uff0cCost\u5c06\u5927\u5e45\u5ea6\u4e0a\u5347\uff08\u4f7f\u7528\u66f4\u591a\u8f93\u5165\u7684\u4e0e\u95e8\uff09\u3002\u6211\u4eec\u9700\u8981\u4e00\u79cd\u5229\u7528\u5206\u5c42\u548c\u4e00\u7ec4\u4e0e\u95e8\u5b9e\u73b0\u7f16\u7801
\u5173\u4e8e\u8ba1\u7b97\u4e0e\u95e8\u8f93\u5165\u6210\u672c
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#decoder-with-enable","title":"Decoder with Enable","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#decoder-and-or-gates","title":"Decoder and OR gates","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#adder","title":"ADDer \u7684\u5b9e\u73b0","text":"
- 6/2 = 3\uff0c\u8fde\u63a5 64 \u4e2a\u4e8c\u8f93\u5165\u4e0e\u95e8\u7684\u662f\u4e24\u4e2a
3-8\u8bd1\u7801\u5668
- COST : 6 + 2*\uff084*2\uff09+2*(8*2)+64*2
\u5b9e\u73b0 1 bit \u7684\u52a0\u51cf\uff0c\u9700\u8981\u4e24\u4e2a\u76f8\u52a0\u4f4d\uff0c\u4e0a\u4e00\u4f4d\u7684\u8fdb\u4f4d\uff0c\u5b58\u50a8\u672c\u4f4d\u7ed3\u679c\u548c\u4e0b\u4e00\u4f4d\u8fdb\u4f4d\u3002\u5373 X+Y+Z=(CS)2
\u5bf9\u4e8e\u662f\u5426\u5229\u7528minterm\u8868\u793a\uff0c\u6211\u4eec\u9700\u8981\u81ea\u5df1\u505a\u51fa\u6743\u8861\uff1b
It`s a business of budgt.
EXAMPLE
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#encoding","title":"Encoding | \u7f16\u7801","text":"
one-hot
\u7684\u5f62\u5f0f\uff0c\u4e00\u822c\u800c\u8a00\u53ea\u6709\u4e00\u4f4d\u4e3a1Encoder
\u5b9e\u73b0\u7535\u8def\u793a\u4f8b\uff1aDecimal-to-BCD
input : 0-9 \u517110\u4e2a\u6570\u5b57
output : 4-bits BCD\u7801
function : if Di == 1, then the output (A1-A4) is just the BCD code for i
\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u6837\u4e00\u79cd\u65b9\u5f0f\u7684\u5c40\u9650\u6027\u5f88\u5927\uff0c\u4e3b\u8981\u5728\u4e8e\u6211\u4eec\u5f88\u96be\u786e\u4fdd
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#priority-encoder","title":"Priority Encoder | \u4f18\u5148\u9009\u62e9","text":"one-hot
\u7684\u5f62\u5f0f\uff0c\u4e8e\u662f\u6211\u4eec\u9700\u8981\u4e00\u79cd\u80fd\u591f\u4fdd\u8bc1\u63a5\u53d7\u6240\u6709\u8f93\u5165\u7684\u65b9\u6cd5\u3002
- \u4f18\u5148\u7f16\u7801\u5668\u80fd\u591f\u5b9e\u73b0\u4f18\u5148\u7ea7\u51fd\u6570\uff0c\u5b83\u4e0d\u8981\u6c42\u8f93\u5165\u662f one-hot \u7684\uff0c\u800c\u662f\u603b\u662f\u5173\u6ce8\u6709\u6548\u8f93\u5165\u4e2d\u4f18\u5148\u7ea7\u6700\u9ad8\u7684\u90a3\u4e00\u4e2a\u3002\u5373\u6bd4\u5982\u5f53\u4f18\u5148\u7ea7\u6700\u9ad8\u7684\u90a3\u4e00\u4f4d\u662f
1
\u65f6\uff0c\u5176\u5b83\u6240\u6709\u4f18\u5148\u7ea7\u4e0d\u5982\u5b83\u7684\u4f4d\u7f6e\u7684\u503c\u90fd\u662f\u6211\u4eec\u4e0d\u5173\u5fc3\u7684\u5185\u5bb9\u4e86\u3002\u793a\u4f8b\uff1a
\u200b \u8fd9\u91cc\u7684A2A1A0\u8868\u793a\u4e0b\u6807
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#selecting","title":"Selecting | \u9009\u62e9\u5668","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#multiplexer","title":"Multiplexer | \u591a\u8def\u590d\u7528\u5668","text":"
- \u7b80\u5199\u4e3a
MUX
\uff0c\u53c8\u88ab\u79f0\u4e3adata selecter
- \u57fa\u672c\u6784\u6210 2n-to-1-Line Multiplexer`
- n-to-2n-line decoder
- 2n\u00d7 2 AND-OR
- \u5f62\u6210\u4e00\u79cd\u89c2\u5ff5\u2014\u2014\u9009\u62e9\u662f\u76f8\u4e92\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0cINPUT\u548cEnable\u4e0d\u662f\u7edd\u5bf9\u7684\u6982\u5ff5\uff08\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u662f\u524d\u6587\u5e26\u4f7f\u80fd\u76841-2Decoder\uff0c\u4f46\u662f\u4e66\u4e0a\u79f0\u4ed6\u4e3a\u591a\u8def\u5206\u914d\u5668|demultiplexer\uff0c\u4e2a\u4eba\u611f\u89c9\u6ca1\u6709\u533a\u522b\uff09
- Example
2-to-1-Line Multiplexer
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#_3","title":"\u4f7f\u7528\u4e09\u6001\u95e8","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#implementation","title":"Implementation","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#approach-1","title":"Approach 1","text":"\u5229\u7528\u591a\u91cd\u7684\u591a\u8def\u590d\u7528\u5668\u8fdb\u884c\u64cd\u4f5c\uff0c\u8ba1\u7b97SOM\uff1b
Y = minOR
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#approach-2","title":"Approach 2","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#part-3-arithmetic-function","title":"Part 3 Arithmetic Function","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#adder_1","title":"Adder | \u52a0\u6cd5\u5668","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#half-adder","title":"Half Adder","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#full-adder","title":"Full Adder","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#ripple-curry-adder","title":"Ripple Curry Adder | \u884c\u6ce2\u52a0\u6cd5\u5668","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#curry-look-ahead","title":"Curry Look Ahead | \u8d85\u524d\u8fdb\u4f4d\u52a0\u6cd5\u5668","text":"
- \u91cd\u70b9\u5728\u4e8e\u627e\u5230\u5bf9\u5e94\u7684Function\u8fdb\u884c\u5316\u7b80
\u8ba1\u7b97Delay
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#_4","title":"\u4e8c\u8fdb\u5236\u52a0\u6cd5","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#unsigned-integer","title":"Unsigned Integer","text":"
- 1`s Complement \u53cd\u7801
- 2`s Complement \u8865\u7801
- \u51cf\u6cd5Substraction\u53ef\u4ee5 \u7531 A + B\u7684\u8865\u7801 \u5b9e\u73b0
- \u8fdb\u4f4d\u4e3a0\uff0c\u5bf9\u7ed3\u679c\u4fee\u6b63
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#signed-integer","title":"Signed Integer","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#overflow","title":"OverFlow","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#other-arithmetic-function","title":"Other Arithmetic Function","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/#incrementing-decrementing","title":"Incrementing & Decrementing","text":"
- \u8fdb\u4f4d\u4e3a1\uff0c\u4e0d\u9700\u8981\u4fee\u6b63
+1
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/","title":"P4","text":"\u200b This chapter begins with an introduction to sequential circuits, describing the difference between synchronous sequential circuits(\u540c\u6b65\u53d8\u5316), which have a clock signal to synchronize changes in the state of the circuit at discrete points in time, and asynchronous sequential circuits\uff08\u5f02\u6b65\uff09, which can change state at any time in response to changes in inputs.
\u8981\u5b9e\u73b0\u4fe1\u606f\u7684\u5b58\u50a8\uff0c\u6211\u4eec\u5c31\u9700\u8981\u4e00\u79cd\u65b0\u7684\u7535\u8def\uff1a\u65f6\u5e8f\u7535\u8def
Combinational Logic
Inputs -
Output function (Mealy) Outputs = g(Inputs, State)
Output function (Moore) Outputs = h(State)
Next state function Next State = f(Inputs, State)
Storage Elements
\u4e0b\u9762\u662f\u4e00\u79cd\u6700\u57fa\u672c\u7684
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#part-1-storage-elements-and-analysis","title":"Part 1 Storage Elements and Analysis","text":"Buffer
\uff08\u7f13\u51b2\u5668\uff09\uff0c\u53ef\u4ee5\u4fdd\u6301\u4e00\u4e2a\u503c\u5728\u4e00\u5b9a\u65f6\u95f4\u5185\u4e0d\u53d8 \u5c06\u53cd\u76f8\u5668\u6539\u4e3a\u5176\u4ed6\u539f\u4ef6\uff0c\u5373\u5f97\u5230\u6700\u57fa\u672c\u7684\u9501\u5b58\u5668\u7ea6 1070 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#type","title":"Type","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#synchronous","title":"Synchronous | \u540c\u6b65\u53d8\u5316","text":"\u5728\u6700\u7b80\u5355\u7684\u949f\u63a7\u65f6\u5e8f\u7535\u8def\u4e2d\u4f7f\u7528\u7684\u5b58\u50a8\u5355\u5143\u79f0\u4e4b\u4e3a\u89e6\u53d1\u5668\u3002
\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u89e6\u53d1\u5668\u662f\u7531\u9501\u5b58\u5668\u6784\u6210\u7684\u3002
\u949f\u63a7\u65f6\u5e8f\u7535\u8def
Clocked sequential circuit
\u901a\u8fc7\u65f6\u949f\u4ea7\u751f\u5668
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#asynchronous","title":"Asynchronous | \u5f02\u6b65\u53d8\u5316","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#latch","title":"\u9501\u5b58\u5668 | Latch","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#basic-nand-bars-barr-latch","title":"Basic (NAND) \\(\\bar{S}-\\bar{R}\\) Latch","text":"Clock Generator
\u4ea7\u751f\u5468\u671f\u6027\u7684\u65f6\u949f\u8109\u51b2clock pulse
\u6765\u5b9e\u73b0\u3002\u8109\u51b2\u7cfb\u7edf\u5206\u5e03\u4e8e\u6574\u4e2a\u7cfb\u7edf\uff0c\u540c\u6b65\u5b58\u50a8\u5143\u4ef6\u4e4b\u5728\u6bcf\u4e00\u4e2a\u8109\u51b2\u7279\u5b9a\u7684\u65f6\u523b\u53d7\u5230\u5f71\u54cd\u4e00\u822c\u6765\u8bf4\uff0cset\u4e3a\u7f6e1\u7aef\u53e3\uff0creset\u4e3a\u7f6e0\u7aef\u53e3 \u4f46\u662f\uff0c\u8fd9\u91cc\u7684\\(\\bar{R}-\\bar{S}\\)\u4f7f\u7528\u7684\u662f \\(\\bar{S\\R}\\) \u6765\u8868\u793a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#basic-nor-s-r-latch","title":"Basic (NOR) S \u2013 R Latch","text":"S \u7f6e 1 \u7aef\u53e3 R \u7f6e 0 \u7aef\u53e3
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#clocked-s-r-latch","title":"Clocked S - R Latch","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#d-latch","title":"D- Latch","text":"
- \u5b9e\u9645\u4e0a\uff0c\u5b83\u5c06NAND\u7684\u884c\u4e3a\u8f6c\u4e3a\u4e86\u4e0eNOR\u76f8\u540c\u7684\u5bc4\u5b58\u5668
- \u6ca1\u6709\u6a21\u7cca\u503c (
indeterminate value
)\u4f46\u662f\uff0c\u5728\u4e00\u4e2a\u65f6\u949f\u5468\u671f\u5185\uff0c\u53ea\u8981C = 1\u4e0d\u53d8\uff0c\u8f93\u51fa\u53ef\u4ee5\u53d1\u751f\u591a\u6b21\u53d8\u5316\uff1b\u7b2c\u4e00\u6b21\u53d8\u5316\u662f\u6211\u4eec\u9884\u671f\u4e2d\u7684\uff0c\u4e4b\u540e\u7684\u88ab\u79f0\u4e4b\u4e3a\u201d\u7a7a\u7ffb\u201c
\u4e5f\u5c31\u662f\u8bf4\uff0c it is transparent.
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#flip-flops","title":"\u89e6\u53d1\u5668 | Flip-Flops","text":"\u8fb9\u6cbf\u89e6\u53d1\u5f0f D \u89e6\u53d1\u5668\u662f\u76ee\u524d\u4f7f\u7528\u6700\u5e7f\u6cdb\u7684\u89e6\u53d1\u5668\u3002
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#s-r-master-slave-flip-flop","title":"\u4e3b\u4ece\u89e6\u53d1|S-R master-slave flip-flop","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#edge-triggered-flip-flop","title":"\u8fb9\u7f18\u68c0\u6d4b|edge-triggered flip-flop","text":"
- \u5b83\u5b58\u5728\u7684\u95ee\u9898\u4e0eR-S Latch\u7c7b\u4f3c\uff0c\u90fd\u5b58\u5728\u4e0d\u786e\u5b9a\u7684\u72b6\u6001\uff0c\u5bfc\u81f4\u53ef\u80fd\u53d1\u751f\u9519\u8bef
- 1`s catching Problem
- \u4e0a\u56fe\u8d1f\u8fb9\u7f18\u53d8\u5316
\u6b63\u8fb9\u7f18\u53d8\u5316
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#standard-symbols","title":"\u6807\u51c6\u56fe\u5f62\u7b26\u53f7 | Standard Symbols","text":"
- \u76f4\u89d2 \u7b26\u53f7\u8868\u793a \u5ef6\u65f6\u8f93\u51fa\u6307\u793a\u5668 \u8868\u793a\u8f93\u51fa\u4fe1\u53f7\u5728\u8109\u51b2\u7684\u7ed3\u5c3e\u53d1\u751f\u6539\u53d8
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_1","title":"\u65f6\u5e8f\u7535\u8def\u5206\u6790","text":"
- C\u524d\u9762\u7684\u7bad\u5934\u8868\u793a\u52a8\u6001\u8f93\u5165\uff0c\u8868\u793a\u89e6\u53d1\u5668\u76f8\u5e94\u8f93\u5165\u65f6\u949f\u8109\u51b2\u7684\u8fb9\u6cbf\u8df3\u53d8
Example
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#state-graph","title":"State Graph","text":"
- \u5f53\u524d\u72b6\u6001 \u4e0b\u4e00\u72b6\u6001 \u8f93\u5165 \u8f93\u51fa
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#state-diagram","title":"State Diagram","text":"
- Mealy\u548cMoore\u7684\u72b6\u6001\u8868\u4e0d\u540c
- \u5982\u679c\u8f93\u51fa\u65e2\u4f9d\u8d56\u4e8e\u5f53\u524d\u72b6\u6001\uff0c\u4e5f\u4f9d\u8d56\u4e8e\u8f93\u5165\u7684\u65f6\u5e8f\u7535\u8def\uff0c\u5219\u79f0\u4e3a \u7c73\u52d2\u578b\u7535\u8def(Mealy model circuit)\uff1b\u800c\u5982\u679c\u8f93\u51fa\u53ea\u4f9d\u8d56\u4e8e\u5f53\u524d\u72b6\u6001\uff0c\u5219\u79f0\u4e3a \u6469\u5c14\u578b\u7535\u8def(Moore model circuit)\u3002
Mealy\u6a21\u578b
- Node \u6307\u793a\u72b6\u6001\uff1b\u7bad\u5934\u8868\u793a\u8f93\u5165\u8f93\u51fa
Moore\u6a21\u578b \uff08\u53ea\u4f9d\u8d56\u4e8eState\uff09
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_2","title":"\u7b49\u4ef7","text":"
- Def: \u5982\u679c\u4e24\u4e2a\u72b6\u6001\u5bf9\u6bcf\u4e00\u4e2a\u8f93\u5165\u7b26\u53f7\u4ea7\u751f\u7684\u8f93\u51fa\u76f8\u540c\uff0c\u800c\u4e14\u4e0b\u4e00\u4e2a\u72b6\u6001\u76f8\u540c\u6216\u8005\u7b49\u4ef7\uff0c\u90a3\u4e48\u6211\u4eec\u79f0\u4ed6\u4eec\u7b49\u4ef7
Example
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#timing-parameter","title":"Timing Parameter","text":"
- Setup Time \\(t_s\\)\uff1a\u91c7\u6837\u8fb9\u7f18\u524d\u8f93\u5165\u4fe1\u53f7\u9700\u8981\u4fdd\u6301\u7a33\u5b9a\u7684\u65f6\u95f4\uff0c\u5426\u5219\u4f1a\u53d1\u751f
- Hold Time \\(t_h\\)\uff1a\u91c7\u6837\u8fb9\u7f18\u540e\u8f93\u5165\u4fe1\u53f7\u9700\u8981\u4fdd\u6301\u7a33\u5b9a\u7684\u65f6\u95f4\uff1b
- Propagation Time \\(t_p\\)\uff1a\u89e6\u53d1\u5668\u7684\u91c7\u6837\u8fb9\u7f18\u5230\u8f93\u51fa\u7a33\u5b9a\u7684\u65f6\u95f4\uff08\u4f20\u64ad\u65f6\u95f4\uff09\uff1b
- Slack Time\uff1a\u677e\u5f1b\u65f6\u95f4 \\(t_{slack}>=0\uff0c\u4e00\u822c\u63a5\u8fd10\\)
\u200b \u5bf9\u4e8e \\(t_h<t_{pd}\\)
\\(t_p=t_{pd}+t_{slack}+t_s = t_{pd,FF}+t_{pd,Com}+t_s+t_{slack}\\)
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#part-2-design-procedure","title":"Part 2 Design Procedure","text":"Specification
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#preparation","title":"Preparation","text":"
\u786e\u8ba4\u7cfb\u7edf\u7684\u884c\u4e3a\uff1a\u9700\u8981\u8bf4\u660e\u89c4\u683c\uff0c\u4ee5\u786e\u5b9a\u6570\u76ee\uff1b\u786e\u8ba4\u521d\u59cb\u72b6\u6001 | Spcification
Formulation - Obtain a state diagram or state table
State Assignment - Assign binary codes to the states
Flip-Flop Input Equation Determination - Select flip-flop types and derive flip-flop equations from next state entries in the table
- Output Equation Determination - Derive output equations from output entries in the table
- Optimization - Optimize the equations
- Technology Mapping - Find circuit from equations and map to flip-flops and gate technology
- Verification - Verify correctness of final design
Reset\u8bbe\u7f6e
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#formulation","title":"Formulation","text":"Example 1 : Sequence Check
\u76ee\u7684\uff1a\u5728\u4e00\u6bb5\u8fde\u7eed\u7684\u5e8f\u5217\u4e2d\u68c0\u6d4b\u8981\u6c42\u7684\u5e8f\u5217\uff0c\u5047\u8bbe\u4e3a\u201c1101\u201d \u72b6\u6001\u56fe\uff1a
- A\u4e3a\u521d\u59cb\u72b6\u6001\uff0c\"Reset\"\u4f4d
\u5173\u4e8ereset
\u540c\u6b65
\u5f02\u6b65
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_3","title":"\u72b6\u6001\u56fe\u7684\u4f18\u5316\u4e0e\u786e\u5b9a\u7b56\u7565","text":"A state is an abstraction of the history of the past applied inputs to the circuit (including power-up reset or system reset).
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_4","title":"\u4f18\u5316","text":"\u5bf9\u7b49\u6548\u72b6\u6001\u7684\u7406\u89e3
\u9690\u542b\u8868\u5316\u7b80
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_5","title":"\u72b6\u6001\u5206\u914d","text":"\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7b2c\u4e00\u6761\u539f\u5219\u8f83\u4e3a\u91cd\u8981\uff0c\u9700\u4f18\u5148\u8003\u8651\uff0c\u5176\u6b21\u8981\u8003\u8651\u7531\u524d\u4e09\u6761\u539f\u5219\u5f97\u5230\u7684\u5e94\u5206\u914d\u76f8\u90bb\u4ee3\u7801\u7684\u72b6\u6001\u5bf9\u51fa\u73b0\u7684\u6b21\u6570\uff0c\u6b21\u6570\u591a\u7684\u72b6\u6001\u5bf9\u5e94\u4f18\u5148\u5206\u914d\u76f8\u90bb\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_6","title":"\u4f8b\u9898","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/#_7","title":"\u65f6\u5e8f\u8ba1\u7b97","text":"\u6ce8\u610f\u7ed3\u5408\u65f6\u5e8f\u56fe\u8fdb\u884c\u5206\u6790
- \u8fb9\u6cbf\u89e6\u53d1\u7684\uff0c\\(t_s\\)\u5728\u8fb9\u6cbf\u89e6\u53d1\u4e4b\u524d\u8fdb\u884c
- \u6545\u800c\u5e38\u8bf4\u7684\uff0c\"to the positive clock edge\"\u9700\u8981\u8ba1\u7b97 \\(t_s\\)
- \u4e00\u822c\u5728\u8fd9\u79cdclock stew\u95ee\u9898\u4e2d\u624d\u8003\u8651\\(t_h\\),\u5728\u89e6\u53d1\u540e
- \u8ba1\u7b97\u65f6\u95f4\u5ef6\u65f6Max\u7684\u65f6\u5019\uff0c\u4ece\u4e00\u4e2aFF\u7684\u8f93\u51fa\u5230\u53e6\u5916\u4e00\u4e2a\u7684\u8f93\u5165
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/","title":"P5","text":"
- X -> S \u5ba1\u9898\uff0c\u662f\u4eceexternal input
- \u8fb9\u6cbf\u89e6\u53d1
\u7ea6 42 \u4e2a\u5b57
Technology
\u7279\u6027
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/#rom","title":"ROM","text":"Read-only
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/#pal","title":"PAL","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/#pla","title":"PLA","text":"\u5229\u7528K-map\u5bfb\u627e\u76f8\u540c\u9879 XOR\u95e8\u53ef\u4ee5\u589e\u52a0\u4e00\u7ec4\u503c\uff0c\u6709\u5229\u4e8e\u4f18\u5316\uff08\u4f7f\u5f97\u4e00\u79cd\u8f93\u51fa\u6210\u4e3a\u53ef\u80fd\uff09 NOT
Example\uff1a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/#fpga","title":"FPGA","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/","title":"P6","text":"In a digital system, a datapath and a control unit are frequently present at the upper levels of the design hierarchy.
A datapath consists of processing logic and a collection of registers that performs data processing. A control unit is made up of logic that determines the sequence of data-processing operations performed by the datapath. Register transfer notation describes elementary data-processing actions referred to as microoperations.
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#register","title":"Register | \u5bc4\u5b58\u5668","text":"Register transfers
move information between registers, between registers and memory, and through processing logic. Dedicated transfer hardware using multiplexers and shared transfer hardware called buses implement these movements of data. The design of the control unit for controlling register transfers is also covered in this chapter.
- \u5bc4\u5b58\u5668\u5176\u5b9e\u5c31\u662f\u5b58\u50a8\u6570\u636e\u7528\u7684\u89e6\u53d1\u5668\u90e8\u5206\u548c\u63a7\u5236\u4e0d\u540c\u72b6\u6001\u8f6c\u6362\u7684\u7ec4\u5408\u7535\u8def\u90e8\u5206\u7ec4\u6210
Notation
K1 : R1 <- R2 \u76f8\u5f53\u4e8e\u6761\u4ef6\u7ea6\u675f
\u5982\u679c\u5728\u5de6\u8fb9\u6761\u4ef6\u4e2d\u51fa\u73b0
A + B
\u8868\u793a\u903b\u8f91\u8fd0\u7b97\uff0c\u53f3\u8fb9\u8868\u793a\u7b97\u672f\u8fd0\u7b97 \u5982\uff1aA + B : R1 + R2
Example
\u4e00\u4e2a\u7b80\u5355\u7684\u52a0\u51cf\u6cd5\u5b9e\u73b0
\u4e00\u4e9b\u53ef\u80fd\u7528\u4e0d\u5230\u7684\u7ec6\u8282\uff1a
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#load-enable","title":"Load Enable","text":"
- \u5927\u5199\u5b57\u6bcd\u8868\u793a\u529f\u80fd\uff0c
AR
\u5730\u5740\u5bc4\u5b58\u5668\uff1a\u4fdd\u7559\u5b58\u50a8\u5355\u5143\u5730\u5740\uff1bPC
\u7a0b\u5e8f\u8ba1\u6570\u5668\uff1bIR
\u6307\u4ee4\u5bc4\u5b58\u5668\uff1bR2
\u5bc4\u5b58\u56682\uff1b- \u6700\u4f4e\u4f4d 0 \u4f4d\u53f3\u7aef \u5c0f\u7aef\u683c\u5f0f\uff1b\u5de6\u7aef \u5927\u7aef\u683c\u5f0f
\u6211\u4eec\u671f\u671b\u4e2d\u7684\u5bc4\u5b58\u5668\u9700\u8981\u6709\u4e00\u4e2a\u4fe1\u53f7\u6765\u63a7\u5236\u4ed6\u7684\u201cLoad\u201d\u6216\u8005\u201cStore\u201d\uff0c\u800c\u5355\u7eaf\u7684\u89e6\u53d1\u5668\u5728\u6bcf\u4e2a\u65f6\u949f\u5468\u671f\u90fd\u4f1a\u91cd\u65b0\u8bfb\u5165
\u4e24\u79cd\u601d\u8def\uff08\u8fd8\u6709\u4e00\u79cd\u662f\u4f7f\u7528JK\u89e6\u53d1\u5668\uff0c\u572800\u72b6\u6001\u8fdb\u884c\u9501\u5b58\uff09
- Clock Gating | \u95e8\u63a7\u65f6\u949f :
Clock
\u8fdb\u884c\u7ea6\u675f\uff0c\u7c7b\u4f3c\u4e8e\u4e4b\u524d\u7684Reset
\u64cd\u4f5c\u4e00\u79cd\u95e8\u63a7\u7684\u601d\u8def\uff0c\u4f46\u662f\u8981\u6ce8\u610f\u8fd9\u4e4b\u4e2d\u5b58\u5728\u7740
\u65f6\u949f\u504f\u79fb\u3010clock skew\u3011
,\u5c06\u5bfc\u81f4\u5230\u8fbe\u89e6\u53d1\u5668\u7684\u65f6\u949f\u4fe1\u53f7\u5e76\u4e0d\u540c\u6b65"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#transfer","title":"Transfer | \u4f20\u8f93","text":"
\u5bf9
Input
\u8fdb\u884c\u7ea6\u675f\u601d\u8def\u5f88\u7b80\u5355\uff0c\u5c31\u662f\u5229\u7528\u4e00\u4e2a\u4e8c\u9009\u4e00\u7684\u591a\u8def\u590d\u7528\u5668\u5bf9input\u5904\u7406\uff0c\u4e8e\u662f\u4fbf\u5f62\u6210\u4e86 b \u4e2d\u7684\u5e26\u6709EN\u7aef\u7684D\u89e6\u53d1\u5668
\u7ea6 984 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#multiplexer","title":"\u57fa\u4e8e Multiplexer","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#_1","title":"\u57fa\u4e8e\u591a\u8def\u590d\u7528\u548c\u603b\u7ebf","text":"Dedicated
- \u4e3a\u6bcf\u4e00\u4e2a\u5bc4\u5b58\u5668\u90fd\u63d0\u4f9b\u4e00\u4e2a\u4e13\u5c5e\u7684\u9009\u62e9\u5668
- \u597d\u5904\u4e0e\u7f3a\u70b9\u540c\u6837\u660e\u663e\uff1a\u80fd\u591f\u540c\u65f6\u63d0\u4f9b\u4e0d\u540c\u7684\u4f20\u8f93\u503c\uff08R0<-R1,R1<-R2\uff09\uff0c\u4f46\u8017\u8d39\u66f4\u591a\u7684cost
Shared
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#microoperations","title":"Microoperations","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#shift-register","title":"Shift Register | \u79fb\u4f4d\u5bc4\u5b58\u5668","text":"
- \u4e09\u6001\u95e8\u5b9e\u73b0
- ' 0 Filled'
\u4e32\u884c | Serial
- \u5e38\u5e38\u7528\u4e8e\u4e32\u884c\u3001\u5e76\u884c\u7684\u8f6c\u6362
- \u6709\u65f6\u949f\u504f\u79fb\u7684\u98ce\u9669
- \u5f53\u6570\u636e\u521a\u8fdb\u5165\u7684\u65f6\u5019\uff0c\u540e\u51e0\u4e2a\u5bc4\u5b58\u5668\u5185\u7684\u503c\u662f\u65e0\u6cd5\u786e\u5b9a\u7684\u72b6\u6001
\u5e76\u884c\u52a0\u8f7d\u7684\u79fb\u4f4d\u5bc4\u5b58\u5668 | Parallel Load Shift Registers
- \u6bcf\u4e2a\u5bc4\u5b58\u5668\u524d\u4e09\u4e2aAND
- \u7528\u4e8eShift
- \u7528\u4e8e\u5e76\u884c\u52a0\u8f7d
- \u7528\u4e8e\u4fdd\u6301\u539f\u6765\u7684\u503c
\u53cc\u5411\u79fb\u4f4d\u5bc4\u5b58\u5668
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#part-2counters-register-cells-buses-serial-operations","title":"Part 2:Counters, register cells, buses, & serial operations","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#counter","title":"Counter","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#ripple-counter","title":"ripple Counter | \u884c\u6ce2\u8ba1\u6570\u5668","text":"
- \u6ce8\u610f\uff0c\u4e0b\u56fe\u662f\u5728\u4e0a\u9762\u76846-10\u57fa\u7840\u4e0a\u5b8c\u6210\u7684\u2014\u2014\u5b83\u5728\u6bcf\u4e00\u4e2a\u5bc4\u5b58\u5668\u524d\u591a\u52a0\u4e86\u4e00\u4e2aMUX\uff08\u6bcf\u4e2a\u5bc4\u5b58\u5668\u524d\u90fd\u6709\u4e00\u4e2aMUX\uff09
\u5de5\u4f5c\u539f\u7406
- \u5728\u6bcf\u4e2a\u65f6\u949f\u5468\u671f\u53cd\u8f6c\uff08\u9ed8\u8ba4\u662f\u5728\u65f6\u949f\u4fe1\u53f7\u7684\u4e0a\u5347\u6cbf\u89e6\u53d1\uff09
- \u4f46\u662f\uff0c\u7b2c\u4e00\u4e2a\u89e6\u53d1\u5668\u4e4b\u5916\u7684\u89e6\u53d1\u5668\u6240\u4f7f\u7528\u7684\u65f6\u949f\u4fe1\u53f7\u90fd\u662f\u4e0a\u4e00\u4e2a\u89e6\u53d1\u5668\u7684\u8f93\u51fa
\u95ee\u9898
Timing Delay
\u8fd9\u4e2a\u65f6\u5e8f\u56fe\u8981\u6ce8\u610f"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#synchronous-counters","title":"Synchronous Counters | \u540c\u6b65\u4e8c\u8fdb\u5236\u8ba1\u6570\u5668","text":"
- \u597d\u5904\u662f\u529f\u8017\u4f4e
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#other-counters","title":"Other Counters","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#with-parallel-load","title":"With Parallel Load","text":"Load Count Action 0 0 Hold 0 1 Count 1 X Load
\\(Q_n\u7ffb\u8f6c\u7684\u6761\u4ef6\uff1aQ_1 - Q_{n-1}\u5747\u7b49\u4e8e1\\)
serial counter
\u53ef\u4ee5\u770b\u51fa\u6765\uff0c\u5f53Load == 1\u65f6\uff0cCount\u662f\u88ab\u6291\u5236\u4e86\u7684\uff1b\u8fd9\u6837\u8bbe\u8ba1\u6709\u4e00\u4e2a\u597d\u5904\uff0c\u5c31\u662f\u8f93\u5165\u4e3a 1 1 \u7684\u72b6\u6001\u4e0d\u4f1a\u53d1\u751f\u51b2\u7a81
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#bcd-code-counter","title":"BCD code Counter","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#module-n-counter","title":"module N Counter","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#serial-transfers-and-microoperations","title":"Serial Transfers and Microoperations | \u4e32\u884c","text":"
LOAD
\u662f\u5e76\u884c\u8fdb\u884c\u7684\u30026 - 0110 ReLOAD- \u4e00\u79cd\u4e0d\u53ef\u884c\u7684\u65b9\u6cd5\u662f\u5728 7-0111 \u65f6\u8fdb\u884c
Clear
- Clear \u64cd\u4f5c\u4e0d\u662f\u540c\u6b65\u7684\uff0c\u53ef\u80fd\u5c06D0 Reset \u52301\u65f6\uff0cclear\u4fe1\u53f7\u5df2\u7ecf\u53d1\u751f\u53d8\u5316\uff0c\u4f46clear\u8fc7\u7a0b\u5e76\u672a\u5b8c\u6210
- SRG4 \u4e3a\u56db\u4f4d\u4e32\u884c\u884c\u6ce2\u8ba1\u6570\u5668
\u4e32\u884c\u52a0\u6cd5
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#register-cell","title":"Register Cell | \u5bc4\u5b58\u5668\u5355\u5143\u8bbe\u8ba1","text":"
- \u597d\u5904\u5728\u4e8e\u7528\u7684\u7a7a\u95f4\u66f4\u5c11
- A \u4fdd\u5b58\u8fd0\u7b97\u7ed3\u679c\uff1bB \u7528\u4e8e\u52a0\u8f7d\u52a0\u6570\uff1b
- Shift \u4e3a 1\uff0cClock\u8109\u51b2\u6052\u4e3a1\uff0c\u4e00\u76f4\u79fb\u4f4d\uff1bShift 0\uff0cClock\u8109\u51b2\u6b63\u5e38\uff0c\u6839\u636e\u8109\u51b2\u8fdb\u884c\u8fd0\u7b97
# Part 3 \u2013 Control of Register Transfers | \u5bc4\u5b58\u5668\u4f20\u8f93\u63a7\u5236
\u8bbe\u8ba1\u63a7\u5236\u5355\u5143 \u5bc4\u5b58\u5668\u7ea7\u522b\u8fdb\u884c\u8bbe\u8ba1\u4e5f\u5c31\u662f RTL
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/#design-procedure","title":"Design Procedure","text":"\u4e66\u4e0a\u7684\u4e24\u4e2a\u4f8b\u5b50
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/","title":"P7","text":"Definition
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#rom","title":"ROM","text":"\u7ea6 210 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#ram","title":"RAM","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#sram","title":"SRAM","text":"\u9759\u6001\u7684RAM
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#coincident-selection","title":"Coincident Selection","text":"
- SR Latch
- Select input for control 1
- Dual Rail Data Inputs \\(B\\) and \\(\\bar{B}\\)
- Dual Rail Data Outputs $C and \\bar{C} $
\u5982\u679c\u53ea\u662f\u4f7f\u7528\u4e00\u79cdDecoder\uff0c\u95e8\u7684\u6d88\u8017\u5f88\u5927\u5f88\u5927\uff0c\u5b9e\u73b0\u8fd9\u79cd\u9635\u5217\u9009\u62e9\u66f4\u597d
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#array-of-ram","title":"Array Of RAM","text":"
- Simplified Symbol Of RAM
- The capacity OF RAM
- The number Of Word --- the address
- The length of each word --- data Input and Output
Example 1 : \u5c06\u56db\u4e2a64K*8\u7684\u8f6c\u5316\u4e3a\u4e00\u4e2a256K*8
Example 2:
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#dram","title":"DRAM","text":"\u52a8\u6001\u7684RAM\uff0c\u5229\u7528
\u6210\u672c\u4f4e\uff08\u7528\u6676\u4f53\u7ba1\u6570\u76ee\u66f4\u5c11\uff0c\u7ed3\u6784\u66f4\u7b80\u5355\uff09\uff0c\u5bb9\u91cf\u5927 SRAM Cell \u4f7f\u7528\u4e00\u4e2a\u9501\u5b58\u5668\u6765\u5b58\u50a8\u6570\u636e\uff0c\u800c DRAM Cell \u4f7f\u7528\u4e00\u4e2a\u7535\u5bb9\u548c\u4e00\u4e2a\u6676\u4f53\u7ba1\u6765\u5b58\u50a8\u6570\u636e\u3002
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#slice","title":"Slice","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#timing","title":"Timing","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#_1","title":"\u4f8b\u9898","text":"
- D\u9501\u5b58\u5668
- \u4e00\u4e2aSelect
"},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#dram_1","title":"DRAM","text":""},{"location":"CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/#_2","title":"\u5185\u5b58\u8ba1\u7b97","text":"
address line
data line
address pins
"},{"location":"CodingLanguage/","title":"Index","text":"
- \u4e2a\u4eba\u8ba4\u4e3a\uff0c\u4ed6\u5e76\u6ca1\u6709\u63d0\u53ca\u4e4b\u540e\u7684\u8f93\u51fa\u60c5\u51b5\uff0c\u6240\u4ee5\u6309\u71672 byte\u8ba1\u7b97
\u7ea6 0 \u4e2a\u5b57
!!!
"},{"location":"CodingLanguage/C/","title":"Index","text":"\u7ea6 80 \u4e2a\u5b57
\u6982\u8ff0
\u8fd9\u91cc\u7684\u6587\u6863\u662f\u6211\u4e4b\u524d\u5b66\u4e60C\u5c0fC\u5927\u65f6\u5199\u7684\uff0c\u5f53\u65f6\u7528\u7684\u7b14\u8bb0\u5e73\u53f0\u6bd4\u8f83\u6742\u4e71\uff0c\u6240\u4ee5\u5f88\u591a\u4e1c\u897f\u5df2\u7ecf\u4e22\u5931\u3002\u8fd9\u4efd\u7b14\u8bb0\u603b\u4f53\u5e76\u4e0d\u662f\u5f88\u5168\u9762\uff0c\u66f4\u591a\u7684\u662f\u6211\u5f53\u65f6\u4e0d\u592a\u7406\u89e3\u7684\u90e8\u5206\u3002
\u7b80\u5355\u6765\u8bf4\uff0c\u662f\u62ff\u6765\u5145\u6570\u7684\uff08\u96fe
"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/","title":"\u5b58\u50a8\u7c7b\u522b\u3001\u94fe\u63a5\u548c\u5185\u5b58\u7ba1\u7406","text":"\u7ea6 472 \u4e2a\u5b57 21 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_2","title":"\u5b58\u50a8\u7c7b\u522b","text":"\u4e00\u4e2a
\u5bf9\u8c61
\u5177\u6709\u5b58\u50a8\u671f \u4e00\u4e2a\u6807\u8bc6\u7b26
\u5177\u6709 \u94fe\u63a5\u548c\u4f5c\u7528\u57df \u63cf\u8ff0\u5176\u53ef\u89c1\u6027"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_3","title":"\u57fa\u672c\u6982\u5ff5","text":""},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_4","title":"\u4f5c\u7528\u57df","text":"
**\u81ea\u52a8\u53d8\u91cf**
auto
\u5173\u952e\u5b57- \u4e0d\u4f1a\u81ea\u52a8\u521d\u59cb\u5316
**\u5bc4\u5b58\u5668\u53d8\u91cf**
register
\u5173\u952e\u5b57- \u65e0\u6cd5\u83b7\u53d6\u5730\u5740\uff0c\u56e0\u4e3a\u5b58\u50a8\u5728\u5bc4\u5b58\u5668\u800c\u975e\u5185\u5b58
- \u64cd\u4f5c\u901f\u5ea6\u66f4\u5feb
- \u53ef\u58f0\u660e\u7c7b\u578b\u6709\u9650\uff0cCPU \u4e2d\u7684\u5bc4\u5b58\u5668\u53ef\u80fd\u6ca1\u6709\u8db3\u591f\u7684\u5b58\u50a8\u7a7a\u95f4
**\u5757\u4f5c\u7528\u57df\u7684\u9759\u6001\u53d8\u91cf**
\uff08\u5c40\u90e8\u9759\u6001\u53d8\u91cf\uff09static
\u5173\u952e\u5b57\u5177\u6709\u5757\u4f5c\u7528\u57df\uff0c\u4f46\u662f\u9759\u6001\u5b58\u50a8\u671f
int f(double m)\n{\n int m; # \u6bcf\u6b21\u8fd0\u884c\u65f6\u90fd\u4f1a\u6267\u884c\n static int without = 1; # \u8fd0\u884c\u65f6\u5e76\u4e0d\u6267\u884c\n}\n
**\u5916\u90e8\u94fe\u63a5\u7684\u9759\u6001\u53d8\u91cf**
\uff08\u5916\u90e8\u53d8\u91cf\uff09extern
\u5173\u952e\u5b57\u3002\u7528\u4e8e\u5f15\u7528\u5df2\u6709\u7684\u5916\u90e8\u53d8\u91cf- \u5916\u90e8\u53d8\u91cf\u53ea\u80fd\u521d\u59cb\u5316\u4e00\u6b21\uff0c\u800c\u4e14\u5fc5\u987b\u5728\u5b9a\u4e49\u65f6\u8fdb\u884c
**\u5185\u90e8\u94fe\u63a5\u7684\u9759\u6001\u53d8\u91cf**
- \u7528\u4e8e\u672c\u6587\u4ef6
Tip : \u7ffb\u8bd1\u5355\u5143\uff1a\u7f16\u8bd1\u5668\u628a\u6e90\u4ee3\u7801\u6587\u4ef6\u548c\u5176\u4e2d\u6240\u6709\u7684\u5934\u6587\u4ef6\u770b\u6210\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u5305\u542b\u4fe1\u606f\u7684\u6587\u4ef6 \u5168\u5c40\u53d8\u91cf\uff08\u6587\u4ef6\u4f5c\u7528\u57df\u53d8\u91cf\uff09\u7684\u4f5c\u7528\u8303\u56f4\u662f\u4e00\u4e2a\u7ffb\u8bd1\u5355\u5143
"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_5","title":"\u94fe\u63a5","text":"
\u5916\u90e8\u94fe\u63a5
\u591a\u6587\u4ef6\u7a0b\u5e8f\u5185\u90e8\u94fe\u63a5
\u4e00\u4e2a\u7ffb\u8bd1\u5355\u5143\u5185\u65e0\u94fe\u63a5
\u51fd\u6570\u539f\u578b\u3001 \u6587\u4ef6\u4f5c\u7528\u57df \u53ef\u4ee5\u662f\u5185\u90e8/\u5916\u90e8\u94fe\u63a5"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_6","title":"\u5b58\u50a8\u671f","text":"int giants = 5; # \u5916\u90e8\u94fe\u63a5\nstatic int dodgers = 3; # \u5185\u90e8\u94fe\u63a5\nint main()\n{\n\n}\n
- \u5206\u7c7b
"},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_7","title":"\u5185\u5b58\u5206\u914d","text":""},{"location":"CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/#_8","title":"\u52a8\u6001\u5185\u5b58\u5206\u914d","text":"
\u9759\u6001\u5b58\u50a8\u671f
\u7a0b\u5e8f\u6267\u884c\u671f\u95f4\u4e00\u76f4\u5b58\u5728 \u6ce8\u610f\uff0cstatic \u5e76\u4e0d\u5f71\u54cd\u53d8\u91cf\u5b58\u50a8\u671f\uff0c\u800c\u662f\u5f71\u54cd\u5176\u94fe\u63a5\u5c5e\u6027\u3002\u6240\u6709\u6587\u4ef6\u4f5c\u7528\u57df\u53d8\u91cf\u90fd\u5177\u6709\u9759\u6001\u5b58\u50a8\u671f\u7ebf\u7a0b\u5b58\u50a8\u671f
\u4ece\u88ab\u58f0\u660e\u5230\u7ebf\u7a0b\u7ed3\u675f\u81ea\u52a8\u5b58\u50a8\u671f
\u5757\u4f5c\u7528\u57df\u7684\u53d8\u91cf\uff08\u5c40\u90e8\u53d8\u91cf\u00b7\u00b7 \u8fdb\u5165\u5757\u65f6\u4e3a\u53d8\u91cf\u5206\u914d\u5185\u5b58\uff0c\u5b58\u50a8\u671f\u4ece\u5757\u5f00\u59cb\u5230\u5757\u7ed3\u675f \u4f46\u53d8\u957f\u6570\u7ec4\u7684\u5b58\u50a8\u671f\u662f\u4ece\u5b9a\u4e49\u5230\u5757\u7ed3\u675f\u52a8\u6001\u5206\u914d\u5b58\u50a8\u671f
stdlib.h
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/","title":"\u6307\u9488\u4e0e\u94fe\u8868","text":"
malloc
\u51fd\u6570free
\u51fd\u6570double * positon;\nint n;\nposition = (double *) malloc(n * sizeof(double));\n\nif(position == NULL)\n{\n exit(0);\n}\n\nfree(position);\n
\u7ea6 393 \u4e2a\u5b57 77 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#error","title":"Error","text":""},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#point","title":"POINT","text":""},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_2","title":"\u666e\u901a\u6307\u9488","text":"char a[]=\"axd123\";\nchar **s;\ns=&a; //\u6b64\u5904a[]\u4e3a\u5b57\u7b26\u4e32\u5e38\u91cf \u4e0d\u80fd\u53d6\u5730\u5740 a\u672c\u8eab\u8868\u793a\u8be5\u5b57\u7b26\u4e32\u7684\u5730\u5740\nchar *p;\np=a;\n// \u6b64\u65f6 \u53ef\u4ee5\u4ee4 s=&p\n
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_3","title":"\u7b97\u672f\u8fd0\u7b97\u4e0e\u5173\u7cfb\u8fd0\u7b97","text":"
- \u53d8\u91cf\u63d0\u4f9b\u8bbf\u95ee\u5730\u5740\u7684\u5feb\u6377\u65b9\u5f0f\uff0c\u4f46\u662f\u786c\u4ef6\u4ecd\u7136\u901a\u8fc7\u5730\u5740\u8bbf\u95ee\u5185\u5b58\u4f4d\u7f6e\uff0c\u540d\u5b57\u4e0e\u5185\u5b58\u4f4d\u7f6e\u7684\u5173\u8054\u7531\u7f16\u8bd1\u5668\u5b9e\u73b0\u3002
*
\u95f4\u63a5\u8bbf\u95ee\u5730\u5740\u7b26\uff0c\u53ea\u80fd\u7528\u4e8e\u6307\u9488\u7c7b\u578b\u8868\u8fbe\u5f0f\uff0c\u5bf9\u4e8e\u6307\u9488\u5e38\u91cf\u4e0d\u9002\u7528,\u5fc5\u987b\u5f3a\u5236\u8f6c\u6362 \u5176\u8bbf\u95ee\u4e00\u4e2a\u7279\u5b9a\u7684\u4f4d\u7f6e e.g. \u00a0(int )100 = 25; \u00a0 \u5373\u5728\u5df2\u77e5\u5730\u5740 100 \u7684\u4f4d\u7f6e\u5b58\u50a8\u503c 25**NULL**
\u00a0 \u5bf9\u6307\u9488\u53d8\u91cf\u8fdb\u884c\u663e\u5f0f\u7684\u521d\u59cb\u5316\uff0c\u5728\u6307\u9488\u89e3\u5f15\u7528\u4e4b\u524d\u8fdb\u884c\u68c0\u67e5\uff0c\u907f\u514d\u975e\u6cd5\u6307\u9488\u5728\u540c\u4e00\u4e2a\u6570\u7ec4\u5185 \u8fdb\u884c\u5173\u7cfb\u8fd0\u7b97\u6ce8\u610f\u4e0b\u6807
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_4","title":"\u4e8c\u7ea7\u6307\u9488","text":""},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_5","title":"\u6307\u9488\u6570\u7ec4","text":"char * color[] = {\"red\", \"blue\", \"yellow\", \"green\", \"black\"};\n int i, flag = 0; char ch;\n char **pc;\n pc = color;\n printf(\"Input a character:\");\n ch = getchar();\n for( i =0; i<5; i++ ) {\n if( **(pc+i)==ch ) {\n flag = 1;\n puts(*(pc+i));\n }\n }\n if( flag==0 )\n printf(\"Not Found\");\n
int * a[]={\"asd\",\"dwq\"}; a[]\u4e2d\u5b58\u50a8\u7684\u662f\u6307\u9488
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_6","title":"\u6570\u7ec4\u6307\u9488","text":"int a[10]; &a \u6570\u7ec4\u6307\u9488( \u00a0int (p)[10] \u00a0) \u00a0 \u6307\u5411\u6570\u7ec4 a a == &a[0] a + 1 == &a[1] a[k] \u00a0==(a+k)
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_7","title":"\u51fd\u6570\u6307\u9488","text":"\u5b9a\u4e49 \u8fd4\u56de\u503c\u7c7b\u578b\uff08*\u53d8\u91cf\u540d\uff09\uff08\u53c2\u6570\u7c7b\u578b\u8868\uff09
double \u00a0(*op) (double);
int _ (_f)();
\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u6307\u9488\uff0c\u8be5\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u6574\u578b\u7684\u6307\u9488
int _(_g[])(int,float);
g[ ]\u4e3a\u4e00\u4e2a\u6570\u7ec4\uff0c\u5176\u4e2d\u5143\u7d20\u4e3a\u51fd\u6570\u6307\u9488\uff1b\u8fd4\u56de\u6574\u578b\u6307\u9488
\u51fd\u6570\u540d\u4e5f\u662f\u4e00\u4e2a\u6307\u9488 \u7c7b\u578b\uff1a\u5374\u51b3\u4e8e\u8fd4\u56de\u503c\u7684\u7c7b\u578b\u548c\u53c2\u6570\u5217\u8868\u7684\u7c7b\u578b\u4ee5\u53ca\u4e2a\u6570
here is an error, the second line of main function, there must be ptr = f1 ;
\u65b9\u4fbf\u540c\u4e00\u4e2a\u51fd\u6570\u5185\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8c03\u7528\u4e0d\u540c\u7684\u5b50\u51fd\u6570
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#typedef","title":"typedef \u51fd\u6570\u6307\u9488\u7c7b\u578b","text":"\u6709\u5229\u4e8e\u7b80\u5316\u51fd\u6570\u6307\u9488\u7684\u4f7f\u7528
"},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_8","title":"\u6307\u9488\u4e0e\u6570\u7ec4","text":""},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_9","title":"\u94fe\u8868","text":""},{"location":"CodingLanguage/C/%E6%8C%87%E9%92%88/#_10","title":"\u5355\u94fe\u8868","text":"#include <stdio.h>\n#include <math.h>\n//typedef \u5c06\u53d8\u91cf\u540dTFunc\u66ff\u6362\u4e3a\u51fd\u6570\u6307\u9488\u7c7b\u578b\u540d\ntypedef double (*TFunc)(double);\ndouble calc(TFunc f, double a, double b);\ndouble f1(double);\ndouble f2(double);\nint main(void)\n{\n TFunc ptr = f1;\n printf(\"f1: %.4f\\n\", calc(ptr,0,1));\n printf(\"f2: %.4f\\n\", calc(f2,1,2));\n return 0;\n}\n\ndouble calc(TFunc f, double a, double b)\n{\n return (f(a)+f(b))*(b-a)/2;\n}\ndouble f1(double x)\n{\n return x*x;\n}\ndouble f2(double x)\n{\n return sin(x)/x;\n}\n
\u63d2\u5165\u4e00\u4e2a\u503c
"},{"location":"CodingLanguage/CPP/","title":"Index","text":"#include <stdio.h>\n#include <string.h>\ntypedef struct NODE{\n int value;\n struct Node *next;\n}Node;\nint value; //supposed that we have get a new value into the link\nNode *head,*pre,*p,*new;\npre=NULL;\n\n//\u5f15\u7528\u4e4b\u524d\u786e\u4fddp\u4e0d\u662fnull\nwhile(p!=NULL&&p->value<value){\n pre=p;\n p=p->next;\n}\n\n//\nnew=(Node *)malloc(sizeof(Node));\nif(new==NULL) return ;\nnew->value=value;\nnew->next=p;\n\n//\nif(pre==NULL){\n head=new;\n}else{\n pre->next=new;\n}\n\u4f20\u5165 **Node [&head] \u4fee\u6539\u5934\u6307\u9488 *head=new;\n
\u7ea6 29 \u4e2a\u5b57
\u8d44\u6599
- \u4e66
- \u300aC++ primer\u300b
- \u535a\u5ba2 \u7f51\u7ad9
- C++\u90a3\u4e9b\u4e8b
- cpp referrence
- effective C++
- \u7ec3\u4e60
\u5bfc\u822a\u680f
"},{"location":"CodingLanguage/CPP/Static%26Extern/","title":"Static & Extern","text":"
- cake
- Static&Extern
- const
- memory
\u7ea6 236 \u4e2a\u5b57 26 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
.h
"},{"location":"CodingLanguage/CPP/Static%26Extern/#static","title":"Static","text":"code
- \u5168\u5c40\u53d8\u91cf \u9650\u5236\u5728\u6b64\u6587\u4ef6\u5185\u90e8
\u51fd\u6570\u4fee\u9970 \u540c\u4e0a
\u7c7b\u4e2d\u53d8\u91cf \u6240\u6709\u7c7b\u5171\u4eab\u53d8\u91cf(\u6ce8\u610f\u9700\u8981\u5728\u7c7b\u7684\u5916\u90e8\u5bf9\u8fd9\u4e2a\u53d8\u91cf\u8fdb\u884c\u5b9a\u4e49\uff0c\u4e5f\u662f\u5bf9\u4ed6\u8fdb\u884c\u521d\u59cb\u5316\u7684\u5730\u65b9) \u4e0d\u80fd\u5728\u521d\u59cb\u5316\u5217\u8868\u4e2d\u521d\u59cb\u5316\u9759\u6001\u53d8\u91cf
\u7c7b\u4e2d\u51fd\u6570\u4fee\u9970 \u53ea\u80fd\u4f7f\u7528
static
\u53d8\u91cf\uff0c\u6bd4\u5982\u4e0b\u9762\u7684\u4f8b\u5b50\u4e2d\u5982\u679c\u5728foo\u51fd\u6570\u4e2d\u8c03\u7528value\u5c31\u4f1a\u62a5\u9519 \u8fd9\u4e2a\u51fd\u6570\u662f\u72ec\u7acb\u4e8e\u5bf9\u8c61\u4e4b\u5916\u7684\uff0c\u6ca1\u6709\u9690\u542b\u7684this
\u6307\u9488
- \u6ca1\u6709
this
\u6307\u9488- \u53ea\u80fd\u4f7f\u7528\u9759\u6001\u6570\u636e
- \u4e0d\u80fd\u88abdynamically Overridden
\u6ce8\u610f12\uff0c18\u884c\u7684\u5199\u6cd5
"},{"location":"CodingLanguage/CPP/Static%26Extern/#extern","title":"Extern","text":"#include <iostream>\nusing namespace std;\n\nclass A\n{\npublic:\n A() : value(0) { cout << \"A() \" << endl; };\n ~A() { cout << \"~A\" << endl; };\n static int count;\n static void foo()\n {\n cout << \"foo() \" << count << endl;\n }\n\nprivate:\n int value;\n};\nint A::count;\nint main()\n{\n A a;\n a.foo();\n A::foo();\n cout << a.count << endl;\n cout << A::count << endl;\n}\n
extern is a declaration says there will be such a variable somewhere in the whole program
\u5982\u679c\u9700\u8981\u91cd\u590d\u4f7f\u7528\u540c\u4e00\u4e2a\u53d8\u91cf\uff0c\u6709\u4e24\u79cd\u65b9\u5f0f\uff1a
1.\u4f7f\u7528\u5934\u6587\u4ef6\uff0c\u7136\u540e\u58f0\u660e\u5b83\u4eec\uff0c\u7136\u540e\u5176\u4ed6\u6587\u4ef6\u53bb\u5305\u542b\u5934\u6587\u4ef6\u3002
2.\u5728\u5176\u4ed6\u6587\u4ef6\u4e2d\u76f4\u63a5extern
Backlinks:
"},{"location":"CodingLanguage/CPP/TypeCast/","title":"Type Cast","text":"\u7ea6 139 \u4e2a\u5b57 3 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
Info
"},{"location":"CodingLanguage/CPP/TypeCast/#_1","title":"\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362","text":"
- \u9690\u5f0f\u7c7b\u578b\u8f6c\u6362
- \u663e\u5f0f\u7c7b\u578b\u8f6c\u6362
- \u6574\u578b\u63d0\u5347
- \u65e0\u7b26\u53f7\u7c7b\u578b\u8f6c\u6362
"},{"location":"CodingLanguage/CPP/TypeCast/#static_cast","title":"static_cast","text":"
cast-name<type>(expression)
\u53ea\u8981\u4e0d\u5305\u542b\u5e95\u5c42\u7684const\u5c31\u53ef\u4ee5\u4f7f\u7528
static_cast
\u5728\u76f8\u5173\u7684\u7c7b\u578b\u4e4b\u95f4\u8f6c\u6362\uff0c\u6bd4\u5982
- \u4e00\u4e2a\u7236\u7c7b\u548c\u6d3e\u751f\u7c7b\u4e4b\u95f4\u7684\u8f6c\u6362
void *
\u5230\u5176\u4ed6\u6307\u9488\u7c7b\u578b\u4e4b\u95f4\u7684\u8f6c\u6362int
float
\u7b49\u7c7b\u578b\u4e4b\u95f4\u7684\u8f6c\u6362- \u5b83\u7684\u5b89\u5168\u6027\u6bd4\u8f83\u9ad8\uff0c
"},{"location":"CodingLanguage/CPP/TypeCast/#const_cast","title":"const_cast","text":"double m;\nvoid *p = &m;\ndouble *dp = static_cast<double *>(p);\n
\u53ea\u80fd\u6539\u53d8\u5e95\u5c42const
"},{"location":"CodingLanguage/CPP/TypeCast/#reinterpret_cast","title":"reinterpret_cast","text":"\u4e3a\u8f6c\u6362\u5bf9\u8c61\u7684\u4f4d\u6a21\u5f0f\u63d0\u4f9b\u66f4\u4f4e\u5c42\u6b21\u7684\u91cd\u65b0\u89e3\u91ca
"},{"location":"CodingLanguage/CPP/argv/","title":"Argv","text":"\u7ea6 0 \u4e2a\u5b57
"},{"location":"CodingLanguage/CPP/const/","title":"const","text":"\u7ea6 4 \u4e2a\u5b57
Backlinks:
"},{"location":"CodingLanguage/CPP/memory/","title":"\u5185\u5b58\u6a21\u578b","text":"\u7ea6 44 \u4e2a\u5b57 19 \u884c\u4ee3\u7801
INFO
"},{"location":"CodingLanguage/CPP/memory/#_2","title":"memory","text":"
- stack \u5411\u4e0b\u589e\u957f local vars
- heap \u5411\u4e0a\u589e\u957f dynamically allocated vars.
- code/data global vars static global vars static local vars
example
"},{"location":"CodingLanguage/CPP/memory/#static","title":"static","text":"const char * s1 = \"\" // \u6307\u5411\u9759\u6001\u53d8\u91cf\u7684\u6307\u9488 \nchar s2 [] = \"\" // copy \u4e00\u4efd \u5b58\u50a8\u5728\u6808\u533a\n\n\nconst char *s1 = \"Hello\"; // \u6307\u5411\u9759\u6001\u53d8\u91cf\u7684\u6307\u9488\nchar *s3 = \"Hello\";\nchar s2[] = \"Hello\";\n\ncout << (void *)main << endl;\ncout << (void *)s1 << endl;\ncout << (void *)s2 << endl;\ncout << (void *)s3 << endl;\n/*\n0x40158f\n0x404008\n0x61fe0a\n0x404008\n*/\n
\u5728\u7c7b\u4e2d\u4f7f\u7528
Backlinks:
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/","title":"\u57fa\u7840\u90e8\u5206","text":"\u7ea6 1711 \u4e2a\u5b57 392 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 13 \u5206\u949f
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_2","title":"\u57fa\u7840","text":"\u4e00\u4e9b\u6ce8\u610f\u7684\u5730\u65b9
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_3","title":"\u5f15\u7528","text":"
- \u8d4b\u503c\u4e0e\u521d\u59cb\u5316\u5176\u5b9e\u5e76\u4e0d\u5b8c\u5168\u76f8\u540c\uff0c\u521d\u59cb\u5316\u662f\u521b\u5efa\u53d8\u91cf\u65f6\u8d4b\u4e88\u4e00\u4e2a\u521d\u59cb\u503c\uff0c\u8d4b\u503c\u662f\u64e6\u9664\u5f53\u524d\u503c\u3002
- \u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e00\u70b9\u5e76\u6ca1\u6709\u4efb\u4f55\u5f71\u54cd
\u5f15\u7528
\u8fd9\u662fC++\u4e2d\u4e00\u79cd\u65b0\u7684\u7279\u6027\u3002\u6211\u4eec\u5e38\u8bf4\u7684\u5f15\u7528\u6307\u7684\u662f\u5de6\u503c\u5f15\u7528\uff0c\u8fd8\u6709\u4e00\u79cd\u5f15\u7528\u662f\u6307\u53f3\u503c\u5f15\u7528
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_4","title":"\u5de6\u503c\u5f15\u7528","text":"\u5b9a\u4e49\u5de6\u503c\u5f15\u7528\u7684\u4f7f\u7528\uff0c\u4e00\u5b9a\u8981\u8d4b\u521d\u59cb\u503c
warning
- \u4e0d\u5141\u8bb8\u4f7f\u7528\u5f15\u7528\u7684\u6570\u7ec4C/C++(251)
- \u4e0d\u5141\u8bb8\u4f7f\u7528\u5f15\u7528\u7684\u5f15\u7528
int value;\nint &refVal = value;\nint *PtrValue = &value;\n// \u6307\u5411\u6307\u9488\u7684\u5f15\u7528\nint *&refPointer = PtrValue; \n// \u6570\u7ec4\u5f15\u7528\nint &arr[10]; // \u5143\u7d20\u4e3a\u5f15\u7528\u7c7b\u578b \uff1f \u4e0d\u5141\u8bb8\u4f7f\u7528\u5f15\u7528\u7684\u6570\u7ec4C/C++(251)\n\nint (&arr)[10]; // \u6574\u578b\u6570\u7ec4\u7684\u5f15\u7528\n
\u5bf9\u4e00\u4e2a\u5e38\u91cf\u7684\u5f15\u7528\u53ef\u80fd\u662f\u4e00\u4e2a\u975e\u5e38\u91cf,
const int &
\u53ea\u662f\u5bf9\u5f15\u7528\u7684\u64cd\u4f5c\u6709\u4e86\u9650\u5236int i = 10086;\nconst int m = i;\nint &ref_i = i;\nconst int &Ref_i = i;\nref_i -= 1;\nstd::cout << \"i:\" << i << std::endl;\nstd::cout << \"m:\" << m << std::endl; // 10086\nstd::cout << \"i:\" << ref_i << std::endl; // 10085\nstd::cout << \"I:\" << Ref_i << std::endl;\n
const \u5f15\u7528
double a = 1.12;\nconst double &ref_a = a;\nconst int &Ref_a = a;\na = a - 100;\nstd::cout << \"a:\" << ref_a << std::endl;\nstd::cout << \"A:\" << Ref_a << std::endl;\n\n>> a:-98.88\n>> A:1\n
Warning
\u5f15\u7528\u672c\u8eab\u5e76\u4e0d\u662f\u4e00\u4e2a\u5bf9\u8c61\uff0c\u5b83
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_5","title":"\u6307\u9488","text":"\u7ed1\u5b9a
\u5230\u4e00\u4e2a\u5bf9\u8c61\u4e0a\u9762\u53bb\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u5e76\u4e0d\u662f\u590d\u5236
\u4e0d\u80fd\u591f\u5f62\u6210\u4e00\u4e2a\u5f15\u7528\u7684\u5f15\u7528Warning
\u5728CPP\u4e2d\uff0c\u6307\u9488\u7684\u521d\u59cb\u5316\u6700\u597d\u4f7f\u7528
nullptr
,\u76f8\u5f53\u4e8evoid *\uff0c\u800cNULL\u5728cstdlib
\u4e2d\u5b9a\u4e49\uff0c"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#const","title":"const","text":"int * a = nullptr;\n
const \u5206\u4e3a\u9876\u5c42\u7684\u548c\u5e95\u5c42\u7684\u3002 \u9876\u5c42\u7684 Top \u8868\u793a\u672c\u8eab\u4e0d\u53ef\u53d8\uff0c\u6307\u5411\u7684\u503c\u4e0d\u4e00\u5b9a \u5e95\u5c42\u7684 \u8868\u793a\u672c\u8eab\u53ef\u53d8\uff0c\u6307\u5411\u4e00\u4e2a\u4e0d\u53ef\u53d8\u7684\u503c \u800c\u6307\u9488\u65e2\u53ef\u4ee5\u662fTop-level\uff0c\u4e5f\u53ef\u4ee5\u662fLow-level
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#const_1","title":"const\u4e0e\u6307\u9488","text":"Example
\u5176\u5b9e\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0cint * const a = &i; // \u6307\u9488\u662f\u5e38\u91cf a\u9876\u5c42\u7684\uff0c\u4e0d\u80fd\u6539\u53d8 \nconst int * b = &j; // \u6307\u5411\u5e38\u91cf\u7684\u6307\u9488\n
a
\u662f\u4e00\u4e2a\u6307\u9488\u5e38\u91cf\uff0cb
\u662f\u4e00\u4e2a\u5e38\u91cf\u6307\u9488\uff1b\u8fd9\u6837\u4fa7\u91cd\u540e\u9762\u7684\u4e00\u4e2a\uff0c\u53ef\u80fd\u5bb9\u6613\u7406\u89e3\u4e00\u70b9 \u8ddd\u79bb\u53d8\u91cf\u6700\u8fd1\u7684\u662f*
\u6216\u8005const
\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5224\u65ad\u53d8\u91cf\u7684\u7c7b\u578b"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#constexpr","title":"constexpr\u548c\u5b57\u9762\u503c\u7c7b\u578b","text":"const char * a; //\u6307\u5411const\u5bf9\u8c61\u7684\u6307\u9488\u6216\u8005\u8bf4\u6307\u5411\u5e38\u91cf\u7684\u6307\u9488\u3002\nchar const * a; //\u540c\u4e0a\nchar * const a; //\u6307\u5411\u7c7b\u578b\u5bf9\u8c61\u7684const\u6307\u9488\u3002\u6216\u8005\u8bf4\u5e38\u6307\u9488\u3001const\u6307\u9488\u3002 a\u662f\u4e0d\u53ef\u4fee\u6539\u7684\u5de6\u503c\nconst char * const a; //\u6307\u5411const\u5bf9\u8c61\u7684const\u6307\u9488\u3002\n
constexpr
\u662f\u4e00\u79cd\u5e38\u91cf\u8868\u8fbe\u5f0f\uff0cC11\u52a0\u5165\u4f5c\u4e3a\u4e00\u79cd\u7c7b\u578b constexpr\u51fd\u6570\u8fd4\u56de\u503c\u4e0d\u4e00\u5b9a\u662f\u5e38\u91cf\u8868\u8fbe\u5f0f
constexpr\u51fd\u6570
\u5b9a\u4e49\u4e00\u4e2aconstexpr\u51fd\u6570\uff0c1. \u8fd4\u56de\u503c\u548c\u5f62\u53c2\u90fd\u5fc5\u987b\u662f\u5b57\u9762\u503c\u7c7b\u578b 2. \u51fd\u6570\u4f53\u5185\u53ea\u80fd\u5b58\u5728\u4e00\u53e5return
constexpr int new_sz() { return 11; }
constexpr size_t scale(size_t cnt){return new_sz()*cnt}
\uff0c\u5728\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\u65f6\uff0c\u5fc5\u987b\u5173\u6ce8\u5b9e\u53c2\u7684\u7c7b\u578b\u3002\u5982\u679c\u4e0d\u4e3a\u5b57\u9762\u503c\u7c7b\u578b\uff0c\u8c03\u7528\u5931\u8d25\u5b57\u9762\u503c\u5e38\u91cf literal
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_6","title":"\u5904\u7406\u7c7b\u578b","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_7","title":"\u7c7b\u578b\u522b\u540d","text":"
- \u6574\u578b \u6d6e\u70b9\u578b
- \u5b57\u7b26\u4e32\u5b57\u9762\u503c\uff0c\u5b57\u7b26\u5b57\u9762\u503c '' \"\"
- \u6307\u9488\u5b57\u9762\u503c nullptr
typedef double wage;\nusing wage = double; \n
typedef
\u4f7f\u7528typedef\u65f6\uff0c\u4ee5\u4e0b\u4e24\u79cd\u7528\u6cd5\u53ef\u80fd\u5e26\u6765\u4e0d\u540c\u7684\u5f71\u54cd
typedef char *prtChar;\nconst char*A = &ch;\nconst prtChar B = &ch;\n// \u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cB\u662f\u4e00\u4e2a\u6307\u9488\uff1bA\u662f\u4e00\u4e2a\u5e38\u91cf\n\ntypedef char (*prtChar);\nconst char *A = &ch;\nconst prtChar B = &const_ch;\n// \u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cA\u3001B\u76f8\u540c\uff0c\u90fd\u662f\u4e00\u4e2a\u6307\u9488\u7c7b\u578b\u7684\u5e38\u91cf\n
\u4e3a\u4ec0\u4e48\u662f\u8fd9\u6837\u5b9a\u4e49\u7684
Todo Typedef\u7684\u5b9e\u9645\u4f5c\u7528 \u662f\u5982\u4f55\u53d1\u751f\u7684
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#auto","title":"auto","text":"C11
auto\u7684\u81ea\u52a8\u63a8\u65ad\uff0c\u4f1a\u4f7f\u5f97\u9876\u5c42\u7684const\u5931\u6548\uff0c\u4fdd\u7559\u5e95\u5c42\u7684const
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#decltype","title":"decltype","text":"int i = 0;\nconst int ci = i,&cr = ci;\nauto b = ci; // b is int\nauto c = cr;\n
C11
\u6709\u65f6\u5019\uff0c\u6211\u4eec\u53ea\u5e0c\u671b\u83b7\u5f97\u4e00\u4e2a
Function
\u7684\u6700\u7ec8\u8fd0\u7b97\u7c7b\u578b\uff0c\u800c\u4e0d\u5e0c\u671b\u7531\u5b83\u6765\u8d4b\u4e88\u521d\u59cb\u503cint i;\ndecltype(f()) sum;\nconst int ci = 0, &cj = ci;\ndecltype(ci) a = 0; // const int \ndecltype(cj) b = a; // const int &\n\ndecltype((i)) c; //Error!! \u5f15\u7528\u5fc5\u987b\u8d4b\u4e88\u521d\u59cb\u503c\n
Note
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_8","title":"\u5b57\u7b26\u4e32","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_9","title":"\u57fa\u672c\u64cd\u4f5c","text":"
decltype(())
\u7684\u7ed3\u679c\u6c38\u8fdc\u662f\u5f15\u7528decltype()
\u5219\u4e0d\u7136// Initailize\nstring s;\nstring _10c(10,'c');\nstring _hi(\"hi\");\nstring s = \"value\";\n// Input\ngetline(input,receive);\n// Method\ns.size(); // unsigned int \ns.empty();\n// \nstring str1 = \"World\";\nstring str2 = \"Hello\";\nstring str3 = str2 + \", \" + str1;\nstring str4 = \"Hello\" + \" , \" + str1; //false\n
Warning
C++\u4e2d\u7684\u5b57\u7b26\u4e32\u7684\u5b57\u9762\u503c\u7c7b\u578b\u5e76\u4e0d\u662f\u6807\u51c6\u5e93string\u7684\u5bf9\u8c61\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b57\u7b26\u4e32\u7684\u5b57\u9762\u503c\u7c7b\u578b\u548cstring\u4e0d\u662f\u540c\u4e00\u7c7b\u578b\u3002
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#cctype","title":"cctype","text":"for range"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#vector","title":"Vector","text":"for (auto c : str)\n cout << c << endl;\n\nfor (auto &c : str)\n c = toupper(c);\n
Warning
\u5c3d\u91cf\u51cf\u5c11\u4f7f\u7528\u6570\u7ec4\u548c\u6307\u9488\uff0c\u5c3d\u91cf\u4f7f\u7528 Vector \u548c iterator\u6216\u8005const_iterator \u5c3d\u91cf\u4f7f\u7528String\u800c\u4e0d\u662fC\u98ce\u683c\u7684\u57fa\u4e8e\u6570\u7ec4\u7684\u5b57\u7b26\u4e32
string str = \"ab\"; char str[] = {'a','b','\\0'}
// Initailize \nvector<int> v1(n, val);\nvector<vector<int>> v2;\nvector<string> v3;\nstring word;\n# \u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u6765\u521d\u59cb\u5316Vector\nint int_array[] = {0,1,2,3,4,5,6};\nvector<int> vec(begin(int_array),end(int_array));\n// Method\nwhile (cin >> word)\n v3.push_back(word);\nv3.pop_back();\n// \u8fd4\u56de\u7684\u662f \u5f15\u7528\u7c7b\u578b\nv3.back(); v3.front();\n// \u8fd4\u56de\u8fed\u4ee3\u5668\nv3.begin(); v3.end();\nv3.empty();\nv3.size();\n# \u5fc5\u987b\u8981\u6307\u5b9a\u6e05\u695atype\nvector<int>::size_type;\n# \u5728\u51fd\u6570\u4e2d\u8fd4\u56de\u4e00\u4e2aVector\nvector<string> process()\n{\n if(...)\n return {};\n else\n return {\"Yes\",\"No\",\"CPP\"};\n}\n
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_10","title":"\u8fed\u4ee3\u5668","text":"// \u904d\u5386 \n vector<string> a;\n a.push_back(\"begin\");\n a.push_back(\"NO.1\");\n *a.begin() = \"change\";\n for (auto ch : a[0])\n cout << ch;\n cout << endl;\n cout << \"2 : \" << a[1];\n// Insert\n position = vector.begin(); // \u662f\u4e00\u4e2aiterator\u7c7b\u578b\n vector.insert(position,number,val);\n// Erase\n vector.erase(position);\n vector.erase(position_begin,position_end);\n
Note
begin end \u8fd4\u56de\u503c\u7c7b\u578b\u53ef\u80fd\u662f iterator\u6216\u8005const_iterator
cbegin cend \u4e00\u5b9a\u662fconst_iterator
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_11","title":"\u6570\u7ec4","text":"
\u8fed\u4ee3\u5668\u7c7b\u578b
\u8fed\u4ee3\u5668\u8fd0\u7b97 string vector\u652f\u6301 \u83b7\u53d6\u4efb\u610f\u4f4d\u7f6e\u7684iterator
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#enum","title":"enum","text":"size_t cnt = 0;\nconstexpr size_t rowCnt = 3, colCnt = 4;\nint Arr[rowCnt][colCnt];\nfor(auto &Row : Arr) // note!\n for(auto Col : Row)\n {\n\n }\n
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_12","title":"\u8868\u8fbe\u5f0f","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_13","title":"\u7c7b\u578b\u8f6c\u6362","text":"
\u6cbf\u7528C\u4e2d\u7684\u8868\u8fbe
enum Color{red,green,blue};
\u4f7f\u7528C++\u7684\u7c7b
enum class Color{red,green,blue};
Info
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_14","title":"\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362","text":"
- \u9690\u5f0f\u7c7b\u578b\u8f6c\u6362
- \u663e\u5f0f\u7c7b\u578b\u8f6c\u6362
- \u6574\u578b\u63d0\u5347
- \u65e0\u7b26\u53f7\u7c7b\u578b\u8f6c\u6362
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#static_cast","title":"static_cast","text":"
cast-name<type>(expression)
\u53ea\u8981\u4e0d\u5305\u542b\u5e95\u5c42\u7684const\u5c31\u53ef\u4ee5\u4f7f\u7528
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#const_cast","title":"const_cast","text":"double m;\nvoid *p = &m;\ndouble *dp = static_cast<double *>(p);\n
\u53ea\u80fd\u6539\u53d8\u5e95\u5c42const
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#reinterpret_cast","title":"reinterpret_cast","text":"\u4e3a\u8f6c\u6362\u5bf9\u8c61\u7684\u4f4d\u6a21\u5f0f\u63d0\u4f9b\u66f4\u4f4e\u5c42\u6b21\u7684\u91cd\u65b0\u89e3\u91ca
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_15","title":"\u8fd0\u7b97\u7b26","text":"\u6982\u5ff5
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_16","title":"\u4f18\u5148\u7ea7\u7684\u95ee\u9898","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_17","title":"\u5f02\u5e38\u5904\u7406","text":"
- \u91cd\u8f7d\u8fd0\u7b97\u7b26
- \u5de6\u503c\u548c\u53f3\u503c
Info
- \u5f02\u5e38\u68c0\u6d4b
throw \u8868\u8fbe\u5f0f
- \u5f02\u5e38\u5904\u7406
try block
\u5f02\u5e38\u7c7b
// throw\n if(ISBN1 != ISBN2)\n throw runtime_error(\"Data ...\");\n// try\n try {\n // if throw one exception \n // then, go for the related catch to deal with it \n } catch(runtime_error err){\n cout << err.what();\n } catch(){\n\n }\n
list bubu
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_18","title":"\u51fd\u6570","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_19","title":"\u53ef\u53d8\u53c2\u6570\u4f20\u9012","text":"initializer_list\u81ea\u5b9a\u4e49\u53ef\u53d8\u6a21\u677f\u7701\u7565\u7b26\u53f7\u5f62\u53c2\u5f62\u53c2\u6570\u91cf\u672a\u77e5\uff0c\u4f46\u7c7b\u578b\u76f8\u540c
initializer_list<int> lst{1, 2, 3};\nlst.size();\nlst.begin();\nlst.end();\n\nvoid error_msg(int type, initializer_list<string> il)\n{\n for (auto j : il)\n cout << j;\n cout << endl;\n}\nstring a = \"NO\";\nerror_msg(0, {\"Yes\", \" or \", a});\n
\u4fbf\u4e8eC++\u8bbf\u95ee\u90e8\u5206\u7279\u6b8a\u7684C\u4ee3\u7801\u8bbe\u7f6e\u7684\u3002\u7279\u522b\u7684\u662f\uff0c\u5927\u591a\u6570\u7c7b\u7c7b\u578b\u7684\u5bf9\u8c61\u5728\u4f20\u9012\u7ed9\u7701\u7565\u7b26\u5f62\u53c2\u65f6\u90fd\u65e0\u6cd5\u6b63\u5e38\u62f7\u8d1d\u3002
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_20","title":"\u8fd4\u56de\u503c","text":"void func(int a,...);\nvoid func(...);\n
\u5c3e\u7f6e\u8fd4\u56de\u7c7b\u578b
auto func(int i) -> int (*)[10]
a
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_21","title":"\u51fd\u6570\u91cd\u8f7d","text":"\u4e0d\u5141\u8bb8
- \u4e24\u4e2a\u9664\u4e86\u8fd4\u56de\u7c7b\u578b\u4e4b\u5916\u5b8c\u5168\u76f8\u540c\u7684\u51fd\u6570
- \u53c2\u6570\u4e2d,\u9876\u5c42const\u65e0\u6cd5\u533a\u5206\uff0c\u5e95\u5c42\u53ef\u4ee5(\u6bd4\u5982\u533a\u5206\u6307\u9488\u6216\u8005\u5f15\u7528\u6307\u5411\u7684\u662f\u5e38\u91cf\u5bf9\u8c61\u6216\u8005\u975e\u5e38\u91cf\u5bf9\u8c61)
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_22","title":"\u9ed8\u8ba4\u5b9e\u53c2","text":"// \u65e0\u6cd5\u533a\u5206\nint lookup(int);\nint lookup(const int);\n// \u53ef\u4ee5\u533a\u5206\nint lookup(int *);\nint lookup(const int *);\nint lookup(int &);\nint lookup(const int &);\n
Tips
\u6ce8\u610f\uff0c\u5bf9\u540c\u4e00\u51fd\u6570\u7684\u58f0\u660e\u53ef\u4ee5\u591a\u6b21\u8fdb\u884c\u3002
\u4f46\u662f\uff0c\u5728\u7ed9\u5b9a\u7684\u4f5c\u7528\u57df\u5185\uff0c\u4e00\u4e2a\u5f62\u53c2\u53ea\u80fd\u6709\u4e00\u4e2a\u9ed8\u8ba4\u53c2\u6570\uff1b\u540e\u7eed\u7684\u58f0\u660e\u53ea\u80fd\u7ed9\u4e4b\u524d\u6ca1\u6709\u9ed8\u8ba4\u5b9e\u53c2\u7684\u53c2\u6570\u6dfb\u52a0\u9ed8\u8ba4\u5b9e\u53c2\uff0c\u800c\u4e14\u8be5\u5b9e\u53c2\u53f3\u4fa7\u7684\u5f62\u53c2\u5fc5\u987b\u5177\u6709\u9ed8\u8ba4\u5b9e\u53c2\u3002
Exampletypedef string::size_type sz;\nstring sreen(sz ht,sz wid,char = '');\nstring sreen(sz = 100,sz = 80,char );\n
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_23","title":"\u51fd\u6570\u5339\u914d","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_24","title":"\u51fd\u6570\u6307\u9488","text":"void testFunc(int a = 10086)\n{\n cout << a << endl;\n return;\n}\nint m = 0;\nint main()\n{\n testFunc();\n // \u7528\u4e8e\u521d\u59cb\u5316\u9ed8\u8ba4\u5b9e\u53c2\u7684\u5982\u679c\u662f\u53d8\u91cf\uff0c\u4e0d\u80fd\u662f\u5c40\u90e8\u53d8\u91cf\n void testFunc(int = m);\n testFunc();\n return 0;\n}\n
using PF = int(*)(int *, int );\nusing F = int(int *, int );\nPF m;\n// \u58f0\u660e\u6307\u5411\u51fd\u6570\u7684\u6307\u9488\n// f1 \u8fd4\u56de\nPF f1(int);\nP * f2(int);\n // \u7531\u5185\u5411\u5916\u8bfb f3\u662f\u4e00\u4e2a\u51fd\u6570\uff0c\u8fd4\u56de\u503c\u4e3a\u6307\u9488\uff0c\u8fd9\u4e2a\u6307\u9488\u662f\u4e00\u4e2a\u51fd\u6570\u6307\u9488\nint (* f3(int))(int * , int);\nauto f4(int) -> int (*)(int * ,int);\n
\u51fd\u6570\u6307\u9488
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_25","title":"\u7c7b","text":"int ReturnNum(int *array, int index)\n{\n return array[index];\n}\nauto f4(int) -> int (*)(int *, int)\n{\n return ReturnNum;\n};\nint main()\n{\n int array[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};\n cout << f4(4)(array, 5);\n return 0;\n}\n
\u6982\u8ff0
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_26","title":"\u4ecb\u7ecd","text":"
- \u57fa\u672c\u4ecb\u7ecd
- \u6784\u9020\u51fd\u6570
- friend private public mutable
- \u9759\u6001\u6210\u5458
this
\u76f8\u5f53\u4e8e\u4e00\u4e2a\u5e38\u91cf\u6307\u9488\uff0c\u5b83\u662f\u9690\u5f0f\u5b9a\u4e49\u7684 !!! question \"Question\" \u5982\u4e0b\u56fe\uff0cthis\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e0d\u662f\u4e00\u4e2a\u6307\u9488\u5e38\u91cf\u5417\uff1f\u611f\u89c9\u524d\u540e\u8bf4\u6cd5\u6709\u4e9b\u77db\u76fe- ``
e.g.
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_27","title":"\u6784\u9020\u51fd\u6570","text":"// \u5e38\u91cf\u6210\u5458\u51fd\u6570\uff0c\u5173\u952e\u5728\u7406\u89e3const\nstd::string isbn() const{return bookNo;}\n// \u5728\u7c7b\u5916\u90e8\u5b9a\u4e49\uff0c\u5fc5\u987b\u52a0\u4e0a\u6240\u5c5e\u7684\u7c7b\u540d\ndouble Sales_data::avg_price() const{\n if(units_sold)\n return revenue;\n}\n//\nstd::string bookNo;\n
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_28","title":"\u8bbf\u95ee\u63a7\u5236\u4e0e\u5c01\u88c5","text":"// \u7c7b\u7684\u5185\u90e8\nSales_data( ) = default;\nSales_data(const std::string &s) : bookNo(s) { }\n// \u7c7b\u7684\u5916\u90e8\nSales_data::Sales_data(std::istream &is)\n{\n // read will read a transaction from is into this object\n read(is, *this);\n}\n
abstract
example Sales_data.cppSales_data.h
- \u6211\u4eec\u4f7f\u7528private\u3001public\u3001protected\u8bbf\u95ee\u8bf4\u660e\u7b26\u52a0\u5f3a\u7c7b\u7684\u5c01\u88c5
- class \u548c struct\u7684\u552f\u4e00\u533a\u522b\u5728\u4e8e\u9ed8\u8ba4\u7684\u8bbf\u95ee\u6743\u9650: \u7c7b\u53ef\u4ee5\u5728\u7b2c\u4e00\u4e2a\u8bbf\u95ee\u8bf4\u660e\u7b26\u4e4b\u524d\u5b9a\u4e49\u6210\u5458\uff0cstruct\u5219\u9ed8\u8ba4\u4e3apublic\uff0cclass\u9ed8\u8ba4\u4e3aprivate
- friend \u5141\u8bb8\u5176\u4ed6\u7c7b\u6216\u8005\u51fd\u6570\u8bbf\u95ee private \u6210\u5458\uff08\u5728\u7c7b\u5916\u5b9a\u4e49\u4e00\u4e9b\u63a5\u53e3\uff09
#include <iostream>\nusing std::istream;\nusing std::ostream;\n\n#include \"Sales_data.h\"\nSales_data::Sales_data(std::istream &is)\n{\n // read will read a transaction from is into this object\n read(is, *this);\n}\n\ndouble\nSales_data::avg_price() const\n{\n if (units_sold)\n return revenue / units_sold;\n else\n return 0;\n}\n\n// add the value of the given Sales_data into this object\nSales_data &\nSales_data::combine(const Sales_data &rhs)\n{\n units_sold += rhs.units_sold; // add the members of rhs into\n revenue += rhs.revenue; // the members of ``this'' object\n return *this; // return the object on which the function was called\n}\n\nSales_data\nadd(const Sales_data &lhs, const Sales_data &rhs)\n{\n Sales_data sum = lhs; // copy data members from lhs into sum\n sum.combine(rhs); // add data members from rhs into sum\n return sum;\n}\n\n// transactions contain ISBN, number of copies sold, and sales price\nistream &\nread(istream &is, Sales_data &item)\n{\n double price = 0;\n is >> item.bookNo >> item.units_sold >> price;\n item.revenue = price * item.units_sold;\n return is;\n}\n\nostream &\nprint(ostream &os, const Sales_data &item)\n{\n os << item.isbn() << \" \" << item.units_sold << \" \"\n << item.revenue << \" \" << item.avg_price();\n return os;\n}\n
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_29","title":"\u5176\u4ed6\u7279\u6027","text":""},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_30","title":"\u53ef\u53d8\u6570\u636e\u6210\u5458","text":"#ifndef SALES_DATA_H\n#define SALES_DATA_H\n\n#include \"Version_test.h\"\n\n#include <string>\n#include <iostream>\n\nclass Sales_data {\nfriend Sales_data add(const Sales_data&, const Sales_data&);\nfriend std::ostream &print(std::ostream&, const Sales_data&);\nfriend std::istream &read(std::istream&, Sales_data&);\npublic:\n // constructors\n// using the synthesized version is safe only\n// if we can also use in-class initializers\n#if defined(IN_CLASS_INITS) && defined(DEFAULT_FCNS)\n Sales_data() = default;\n#else\n Sales_data(): units_sold(0), revenue(0.0) { }\n#endif\n#ifdef IN_CLASS_INITS\n Sales_data(const std::string &s): bookNo(s) { }\n#else\n Sales_data(const std::string &s): \n bookNo(s), units_sold(0), revenue(0.0) { }\n#endif\n Sales_data(const std::string &s, unsigned n, double p):\n bookNo(s), units_sold(n), revenue(p*n) { }\n Sales_data(std::istream &);\n\n // operations on Sales_data objects\n std::string isbn() const { return bookNo; }\n Sales_data& combine(const Sales_data&);\n double avg_price() const;\nprivate:\n std::string bookNo;\n#ifdef IN_CLASS_INITS // using the synthesized version is safe only\n unsigned units_sold = 0;\n double revenue = 0.0;\n#else\n unsigned units_sold;\n double revenue;\n#endif\n};\n\n// nonmember Sales_data interface functions\nSales_data add(const Sales_data&, const Sales_data&);\nstd::ostream &print(std::ostream&, const Sales_data&);\nstd::istream &read(std::istream&, Sales_data&);\n\n// used in future chapters\ninline \nbool compareIsbn(const Sales_data &lhs, const Sales_data &rhs)\n{\n return lhs.isbn() < rhs.isbn();\n}\n#endif\n
mutable
\u4f7f\u5f97const func\u4e5f\u80fd\u591f\u6539\u53d8\u5176\u503c Mutable\u7c7b\u5185\u521d\u59cb\u503cpublic:\n //\nprivate:\n mutable size_t count;\n
\u8fd4\u56de *thisclass Window_mgr{\n private:\n std::vector<Screen> sreens{Screen(24,80,'')};\n};\n
// \u5982\u679c\u51fd\u6570\u4e3aconst\u7c7b\u578b\uff0c\u8fd4\u56de\u7684\u5f15\u7528\u4e3aconst type &; \ninline Screen &Screen::Display const(){}\ninline Screen &Screen::set(char c)\n{\n contents[cursor] = c;\n return *this;\n}\n
Friend
- \u53ef\u4ee5\u5c06\u53e6\u5916\u4e00\u4e2a\u7c7b\u6307\u5b9a\u4e3a\u672c\u7c7b\u7684friend \u53cb\u5143\u5173\u7cfb\u4e0d\u5b58\u5728\u4f20\u9012\u6027
\u6211\u7684\u5974\u96b6\u7684\u5974\u96b6\u4e0d\u662f\u6211\u7684\u5974\u96b6
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_31","title":"\u9690\u5f0f\u8f6c\u6362","text":"
- \u4ee4\u6210\u5458\u51fd\u6570\u4e3afriend\uff0c\u800c\u4e0d\u662f\u4ee4\u53e6\u5916\u4e00\u6574\u4e2a\u7c7b\u53d8\u6210\u53cb\u5143
class Screen{\n friend void Window_mgr::clear(ScreenIndex);\n}\n
\u901a\u8fc7\u4e00\u4e2a\u5b9e\u53c2\u8c03\u7528\u7684\u6784\u9020\u51fd\u6570\u5b9a\u4e49\u4e00\u6761\u4ece\u6784\u9020\u51fd\u6570\u7684\u53c2\u6570\u7c7b\u578b\u5411\u7c7b\u7c7b\u578b\u8f6c\u6362\u7684\u89c4\u5219
\u9650\u5236
\u9690\u5f0f\u8f6c\u6362\u53ea\u5141\u8bb8\u6700\u591a\u4e00\u6b65
\u53ef\u4ee5\u4f7f\u7528
"},{"location":"CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/#_32","title":"\u9759\u6001\u6210\u5458","text":"explicit
\uff08\u53ea\u5141\u8bb8\u5728\u7c7b\u5185\u51fa\u73b0explicit Sales_data(std::istream &)
\uff09\u6765\u9650\u5236\u9690\u5f0f\u8f6c\u6362\uff08\u4f46\u662f\u4ecd\u7136\u53ef\u4ee5\u8fdb\u884c\u663e\u5f0f\u7684\u8f6c\u6362\uff09\u4e0e\u7c7b\u76f8\u5173\uff0c\u800c\u4e0d\u662f\u4e0e\u7c7b\u7684\u6210\u5458\u76f8\u5173\uff1b\u4e00\u65e6\u53d1\u751f\u6539\u53d8\uff0c\u6240\u6709\u7684\u6210\u5458\u5bf9\u8c61\u90fd\u80fd\u4f7f\u7528\u6539\u53d8\u540e\u7684\u503c
note
- \u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u9759\u6001\u6210\u5458\u5728\u7c7b\u7684\u5916\u90e8\u8fdb\u884c\u521d\u59cb\u5316\uff1b\u4f46\u5e38\u91cf\u8868\u8fbe\u5f0f\u60c5\u51b5\u662f\u4e00\u4e2a\u4f8b\u5916\uff0c
static constexpr int period = 30; double daily[period];
,\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u8fd8\u9700\u8981\u5728\u7c7b\u7684\u5916\u90e8\u5bf9\u5e38\u91cf\u9759\u6001\u6570\u636e\u6210\u5458\u8fdb\u884c\u5b9a\u4e49\uff0cconstexpr int Account::period;
- \u4e0e\u975e\u9759\u6001\u6210\u5458\u7684\u533a\u522b
class Bar{\npublic:\n1. \u53ef\u4ee5\u4f5c\u4e3a\u9ed8\u8ba4\u5b9e\u53c2\nScreen &clear(char = bkground)\nprivate:\n2. \u53ef\u4ee5\u4f7f\u7528\u4e0d\u5b8c\u5168\u7c7b\u578b\u5b9a\u4e49\nstatic Bar mem1;\nBar Wrong; // \u00d7\nstatic const char bkground;\n}\n
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/","title":"Algorithm","text":"// \u58f0\u660e\nclass Account {\npublic:\n static double rate() {return interestRate;}\n static void rate(double);\nprivate:\n std::string owner; \n double amount;\n static double interestRate; \n static double initRate() { return .0225; }\n static const std::string accountType;\n}\n// \u4f7f\u7528\ndouble r = Account::rate();\nAccount ac1;\nAccount &ac2;\nac1.rate(); \nac2->rate();\n\n// \u5b9a\u4e49\nvoid Account::rate(double newRate) # (1)\n{\n interestRate = newRate;\n}\n
\u7ea6 316 \u4e2a\u5b57 13 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
Abstract
\u6807\u51c6\u5e93\u63d0\u4f9b\u4e86\u4e00\u7ec4\u7b97\u6cd5\uff0c\u5927\u591a\u6570\u90fd\u72ec\u7acb\u4e8e\u5bb9\u5668\u5b58\u5728\u3002 referrence
Short Video
\u591a\u6570\u7b97\u6cd5\u5728
algorithm
\u6587\u4ef6\u4e2d\u63d0\u4f9b:
- find
\u8fd8\u6709\u4e00\u90e8\u5206\u5728
numeric
\u4e2d:\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7b97\u6cd5\u5e93\u4e2d\u7684\u7b97\u6cd5\u64cd\u4f5c\u7684\u5bf9\u8c61\u90fd\u662f\u8fed\u4ee3\u5668\u800c\u975e\u5bb9\u5668\u672c\u8eab\u3002
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#-accumulate","title":"- accumulate","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#_1","title":"\u7f57\u5217","text":"\u6ce8\u610f
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#find","title":"find","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#accumulate","title":"accumulate","text":"
- \u5bf9\u4e8e\u63a5\u53d7\u5355\u4e00\u8fed\u4ee3\u5668\u8868\u793a\u7b2c\u4e8c\u4e2a\u5bb9\u5668\u7684\u7b97\u6cd5\uff0c\u9ed8\u8ba4\u540e\u4e00\u4e2a\u5bb9\u5668\u957f\u5ea6\u5927\u4e8e\u7b49\u4e8e\u7b2c\u4e00\u4e2a
- \u4e0b\u9762\u7684\u53c2\u6570\u4e3a\u8fed\u4ee3\u5668\u5373\u53ef\uff0c\u4e0d\u4e00\u5b9a\u662fbegin(),end()
numeric
accumulate(vec.begin(),vec.end(),element);
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#equal","title":"equal","text":"
- \u7b2c\u4e09\u4e2a\u53c2\u6570\u51b3\u5b9a\u4e86\u4f7f\u7528\u7684\u52a0\u6cd5\u8fd0\u7b97\u7b26\u548c\u8fd4\u56de\u503c\u7684\u7c7b\u578b\uff0c\u540c\u65f6\u52a0\u6cd5\u4e5f\u662f\u5728 element \u7684\u57fa\u7840\u4e0a\u8fdb\u884c\u64cd\u4f5c
- \u8981\u6ce8\u610f\u662f\u5426\u53ef\u52a0
equal(vec.begin(),vec.end(),vec2.begin());
\u8981\u786e\u4fdd\u7b2c\u4e8c\u4e2a\u5e8f\u5217\u7684\u957f\u5ea6>=\u7b2c\u4e00\u4e2a
\u4e14\u6240\u6709\u7b2c\u4e8c\u4e2a\u5bb9\u5668\u53ea\u7528\u4e00\u4e2a\u8fed\u4ee3\u5668\u8868\u793a\u7684\u7b97\u6cd5\u90fd\u9ed8\u8ba4\u8fd9\u4e00\u6761\u89c4\u5219
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#fill","title":"fill","text":"\u5199\u64cd\u4f5c
warning
writing\u64cd\u4f5c\u9ed8\u8ba4\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u5bb9\u7eb3\u5199\u7684\u5143\u7d20
\u4e00\u4e2a\u5f88\u5178\u578b\u7684\u9519\u8bef\u662f\u5411\u7a7a\u5bb9\u5668\u5199\u5165\u503c
\u4e3a\u4e86\u4fdd\u8bc1\u5728\u5199\u5165\u5143\u7d20\u65f6\u5b58\u5728\u8db3\u591f\u7684\u7a7a\u95f4\uff0c\u53ef\u4ee5\u4f7f\u7528
back_inserter
vector<int> a;\n fill_n(back_inserter(a), 10, 0);\n
fill(begin,end,element);
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#copy","title":"copy","text":"
fill_n(iter,n,element)
copy
auto b = copy(a.begin(), a.begin() + 5, back_inserter(c));\ncopy(a.begin(), a.begin() + 1, b);\n
copy_if
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#_2","title":"\u91cd\u6392","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#unique","title":"unique","text":"std::copy_if(from_vector.begin(), from_vector.end(),\n std::back_inserter(to_vector),\n [](int x) { return x % 3 == 0; });\n
"},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#sort","title":"sort","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/Algorithm/#_3","title":"\u5b9a\u5236\u64cd\u4f5c","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/IO/","title":"IO\u5e93","text":"auto b = unique(a.begin(), a.end());\nPrint(a);\n// unique \u7b97\u6cd5\u64cd\u4f5c\u7684\u662f\u8fed\u4ee3\u5668\uff0c\u4e3a\u4e86\u5220\u9664\u5143\u7d20\uff0c\u53ea\u80fd\u4f7f\u7528\u5bb9\u5668\u64cd\u4f5c\na.erase(b, a.end());\nPrint(a);\n
\u7ea6 148 \u4e2a\u5b57 138 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#io","title":"IO\u7c7b","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#_1","title":"\u6761\u4ef6\u72b6\u6001","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#_2","title":"\u6d41\u7684\u72b6\u6001","text":"
- IO\u5bf9\u8c61\u65e0\u8d4b\u503c\u65e0\u62f7\u8d1d
iostate
\u7c7b\u578b
- \u53ef\u4ee5\u5229\u7528
good() fail()
\u5224\u65ad\u6574\u4f53\u6d41\u7684\u72b6\u6001State Of I/O
"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#_3","title":"\u7ba1\u7406\u7f13\u51b2","text":"// cin\u4f1a\u8fd4\u56de\u4e00\u4e2acin\uff0c\u5e76\u53bb\u68c0\u6d4bstream\u662f\u5426\u505a\u597d\u4e86\u51c6\u5907(Test)\nvector<int> read_ints(istream& is)\n{\nvector<int> res;\nint i;\nwhile (is>>i)\nres.push_back(i);\nreturn res;\n}\n\n//\nwhile (cin)\n{\n for (int i; cin >> i;)\n {\n // ... use the integer ...\n }\n if (cin.eof())\n {\n // .. all is well we reached the end-of-file ...\n }\n else if (cin.fail())\n { // a potentially recoverable error\n cin.clear(); // reset the state to good()\n char ch;\n if (cin >> ch)\n { // look for nesting represented by { ... }\n switch (ch)\n {\n case '{':\n // ... start nested structure ...\n break;\n case '}':\n // ... end nested structure ...\n break;\n default:\n cin.setstate(ios_base::failbit); // add fail() to cin\u2019s state\n }\n }\n }\n // ...\n}\n
\u5237\u65b0\u7f13\u51b2\u7684\u539f\u56e0
\u64cd\u7eb5\u7b26
cout << unitbuf; // \u6240\u6709cout\u64cd\u4f5c\u4e4b\u540e\u90fd\u5237\u65b0buffer\ncout << nounitbuf;\n
\u6d41\u7684\u5173\u8054\u64cd\u4f5c
"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#file","title":"File","text":"cin.tie(&cout);\n// old_tie\u6307\u5411\u7684\u662fcin\u7684\u5173\u8054\u6d41\uff1b\u8f6c\u5316\u540e\uff0ccin\u4e0d\u518d\u5173\u8054\nostream *old_tie = cin.tie(nullptr);\ncin.tie(&cerr);\ncin.tie(old_tie);\n
"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#_4","title":"\u6587\u4ef6\u6a21\u5f0f","text":"ifstream in; // read a file\nofstream out; // writing a file\nstring filename(\"CppLearning\");\nin.open(filename + \".md\");\nif (in)\n{ //...\n}\nin.close();\n
\"../Stadard_Library/\u5173\u8054\u5bb9\u5668.md\"
\u6ce8\u610f
\u4ee5
out
\u65b9\u5f0f\u6253\u5f00\u6587\u4ef6\uff0c\u9ed8\u8ba4\u4f1a\u8986\u76d6"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#string","title":"String","text":"ofstream out(\"filename\",mode);\nofstream out(\"filename\",ofstream::app | ofstream::out);\n
Example
\u4f7f\u7528
istringstream
\u8bfb\u53d6\uff0costringstream\u8f93\u5165 \u4f7f\u7528ostringstream
\u53ef\u4ee5\u5728\u9002\u5f53\u7684\u65f6\u673a\u8f93\u51fa\u6240\u6709\u503c istringstreamstring str, line;\nvector<PersonInfo> People;\nwhile (getline(cin, line))\n{\n PersonInfo Person;\n string name, numbers;\n istringstream iStr(line);\n iStr >> name;\n Person.name = name;\n while (iStr >> numbers)\n {\n Person.Phones.push_back(numbers);\n }\n People.push_back(Person);\n}\n// print\nfor (auto person : People)\n{\n cout << \"name:\" << person.name << endl;\n cout << \"phones:\" << endl;\n for (auto phone : person.Phones)\n cout << phone << endl;\n}\n
"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#user-defined","title":"User-defined","text":"
getline
\u4f8b\u7a0b
is.get(c)
\u51fd\u6570\u4e0d\u4f1a\u8df3\u8fc7 Space"},{"location":"CodingLanguage/CPP/Stadard_Library/IO/#formatting","title":"Formatting","text":"#include <iostream>\n#include <vector>\n#include <string>\n\nusing namespace std;\n\nstruct Entry\n{\n string name;\n int number;\n};\n\nostream &operator<<(ostream &os, const Entry &e)\n{\n return os << \"{\\\"\" << e.name << \"\\\", \" << e.number << \"}\";\n}\nistream &operator>>(istream &is, Entry &e)\n// read { \"name\" , number } pair. Note: for matted with { \" \" , and }\n{\n char c, c2;\n if (is >> c && c == '{' && is >> c2 && c2 == '\"')\n { // star t with a { \"\n string name; // the default value of a string is the empty string: \"\"\n while (is.get(c) && c != '\"') // anything before a \" is part of the name\n name += c;\n if (is >> c && c == ',')\n {\n int number = 0;\n if (is >> number >> c && c == '}')\n { // read the number and a }\n e = {name, number}; // assign to the entry\n return is;\n }\n }\n }\n return is;\n}\n\nint main()\n{\n Entry test;\n cin >> test;\n cout << test;\n}\n
, ,, and
\u7cbe\u5ea6\u63a7\u5236
constexpr double d = 123.456;\ncout << d << \"; \" // use the default for mat for d\n<< scientific << d << \"; \" // use 1.123e2 style for mat for d\n<< hexfloat << d << \"; \" // use hexadecimal notation for d\n<< fixed << d << \"; \" // use 123.456 style for mat for f\n<< defaultfloat << d << '\\n'; // use the default for mat for d\n\ncout.percision(8);\ncout << 1234.56789 << ' ' << 1234.56789 << ' ' << 123456 << '\\n';\n\n>>> 1234.5679 1234.5679 123456\n
\u5bbd\u5ea6\u63a7\u5236
"},{"location":"CodingLanguage/CPP/Stadard_Library/string/","title":"String","text":"\u7ea6 11 \u4e2a\u5b57 13 \u884c\u4ee3\u7801
INFO
"},{"location":"CodingLanguage/CPP/Stadard_Library/string/#_1","title":"\u5b57\u7b26\u4e32\u5206\u5272","text":"
- \u603b\u7ed3Blog
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/","title":"\u52a8\u6001\u5185\u5b58","text":"/*\ns = \"2024-1-2\"\n*/\nDate AnalyDate(string s)\n{\n stringstream ss(s);\n string line;\n vector<string> lines;\n while (getline(ss, line, '-'))\n lines.push_back(line);\n Date date;\n date.SetDate(stoi(lines[0]), stoi(lines[1]), stoi(lines[2]));\n}\n
\u7ea6 435 \u4e2a\u5b57 21 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
INFO
\u9664\u4e86\u9759\u6001\u5185\u5b58\u548c\u6808\u5185\u5b58\uff0c\u6bcf\u4e2a\u7a0b\u5e8f\u8fd8\u4f1a\u6709\u4e00\u4e2a\u5185\u5b58\u6c60\uff0c\u7528\u6765\u5b58\u50a8\u5728\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u521b\u5efa\u7684\u53d8\u91cf
- \u4e3a\u4ec0\u4e48\u4f7f\u7528\u52a8\u6001\u5185\u5b58\uff1f
- \u8981\u4f7f\u7528\u7684\u5927\u5c0f\u672a\u77e5
- \u8981\u4f7f\u7528\u7684\u7c7b\u578b\u672a\u77e5
- \u9700\u8981\u5728\u591a\u4e2a\u7a0b\u5e8f\u95f4\u5171\u4eab\u53d8\u91cf
- \u5728\u67d0\u4e2a\u4f5c\u7528\u57df\u4e0b\u5b9a\u4e49\u4e00\u4e2a\u52a8\u6001\u6307\u9488\uff0c\u4e4b\u540e\u8fd9\u4e2a\u6307\u9488\u88ab\u9500\u6bc1\uff0c\u4f46\u7533\u8bf7\u7684\u5185\u5b58\u8fd8\u5728
The diffence between malloc and new
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/#delete","title":"delete","text":"
delete
\u548cfree
\u51e0\u4e4e\u540c\u7406 - \u5728\u5185\u5b58\u4e2d\uff0cnew\u548cdelete\u7533\u8bf7\u7684 Space \u533a\u57df\u4e5f\u4e0d\u5b8c\u5168\u76f8\u540c. new \u4f4d\u4e8e free store \u533a\uff08\u4e5f\u6709\u8bf4\u6cd5\u662f\u5dee\u522b\u4e0d\u5927\uff09warning
\u4f7f\u7528\u52a8\u6001\u5185\u5b58\u7684\u65f6\u5019\uff0c\u4e00\u5b9a\u8981\u6ce8\u610f\u5185\u5b58\u7ba1\u7406\uff1b\u4f7f\u7528delete\u7684\u65f6\u5019\uff0c\u4e00\u5b9a\u8981\u6ce8\u610f\u91ca\u653e\u7684\u662fsingle var\u8fd8\u662f\u6570\u7ec4
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/#_2","title":"\u667a\u80fd\u6307\u9488","text":"delete single;\ndelete[] Array;\n
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/#make_shared","title":"make_shared","text":"
shared_ptr
shared_ptr p = make_shared<typename>()
unique_ptr
weak_ptr
TIPS
- \u4e0d\u4f7f\u7528\u591a\u4e2a\u667a\u80fd\u6307\u9488\u6307\u5411\u540c\u4e00\u4e2a\"\u5e95\u5c42\u7684\"(\u521d\u59cb\u7684)\u6307\u9488
- \u6bd4\u5982 p.get()\u8fd4\u56de\u7684\u6307\u9488\u5c31\u662f\u4e00\u4e2a\"\u5e95\u5c42\u7684\"
- \u6216\u8005reset
- \u5982\u679c\u4f7f\u7528\u667a\u80fd\u6307\u9488\u7ba1\u7406\u7684\u5185\u5b58\u4e0d\u662fnew\u6765\u7684\uff0c\u8981\u7ed9\u5b83\u4e00\u4e2a\u5220\u9664\u5668
make_shared \u51fd\u6570
\u53ef\u9009\u7684 \u5220\u9664\u51fd\u6570\u53c2\u6570auto a = make_shared<int>();\nauto a = make_shared<int>(5);\n
delete\u7684\u65f6\u5019\u8c03\u7528\u6790\u6784\u51fd\u6570\uff0c\u53ef\u4ee5\u7531user\u6307\u5b9a
shared_ptr<> a(val,func)
shared_ptr
shared_ptr\u53ef\u4ee5\u901a\u8fc7\u67d0\u79cd\u529e\u6cd5\u8bb0\u5f55\u5171\u4eab\u5bf9\u8c61\u7684\u6307\u9488\uff08\u4e00\u4e2a\u8ba1\u6570\u5668\uff09\uff0c\u5728count==0\u65f6\uff0c\u5c31\u4f1a\u81ea\u52a8\u91ca\u653e\u5185\u5b58
\u6240\u4ee5
shared_ptr
\u652f\u6301p.unique(),p.ues_count()
\u51fd\u6570"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/#unique_ptr","title":"unique_ptr","text":"p.reset(q) // \u5c06p\u91cd\u65b0\u7ed1\u5b9a\u5230q\n\n// \u6539\u53d8\u5e95\u5c42\u5bf9\u8c61\u4e4b\u524d\uff0c\u68c0\u6d4b\u81ea\u5df1\u662f\u5426\u662f\u552f\u4e00\u7684\nif(!p.unique())\n p.reset(new string(*p));\np.val = newVal;\n
NOTES
\u4e00\u822c\u60c5\u51b5\u4e0b\uff0cunique_ptr\u4e0d\u5141\u8bb8\u62f7\u8d1d\u3002
\u4f46\u662f\u5728\u7279\u6b8a\u60c5\u51b5\u4e0b\u2014\u2014\u7f16\u8bd1\u5668\u77e5\u9053\u8fd9\u91cc\u7684unique_ptr\u5c06\u8981\u88ab\u9500\u6bc1\u3002
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/#weak_ptr","title":"weak_ptr","text":"unique_ptr<int> clone(int p)\n{\n return unique_ptr<int>(new int(p));\n}\nunique_ptr<int> clone(int p)\n{\n rst = unique_ptr<int>(new int(p));\n return rst;\n}\n
\u6307\u5411 shared_ptr \uff0c\u4f46\u5e76\u4e0d\u589e\u52a0\u5176\u8ba1\u6570\uff1b\u9500\u6bc1\u65f6\u540c\u65f6\u9500\u6bc1
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/","title":"\u5bb9\u5668","text":"weak_ptr<T> a;\n
\u7ea6 382 \u4e2a\u5b57 100 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
Abstract
\u4e00\u4e2a\u5bb9\u5668\u662f\u4e00\u4e9b\u7279\u5b9a\u7c7b\u578b\u5bf9\u8c61\u7684\u96c6\u5408\u3002 \u6240\u6709\u5bb9\u5668\u7c7b\u90fd\u5171\u4eab\u516c\u5171\u7684\u63a5\u53e3\uff0c\u4e0d\u5bb9\u7684\u5bb9\u5668\u6309\u7167\u4e0d\u540c\u7684\u65b9\u5f0f\u8fdb\u884c\u62d3\u5c55\u3002 \u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u8303\u56f4 range(a,b) \u6307\u7684\u662f[a,b)
- \u5bb9\u5668\u64cd\u4f5c
- \u987a\u5e8f\u5bb9\u5668
- vector
- deque \u53cc\u5411
- list \u53cc\u5411\u94fe\u8868
- forward_list
- array (static)
- \u5173\u8054\u5bb9\u5668
- set
- multiset
- map
- multimap
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#_1","title":"\u57fa\u672c\u64cd\u4f5c","text":""},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#_2","title":"\u5b9a\u4e49 \u521d\u59cb\u5316","text":"
- \u7c7b\u578b
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#swap","title":"\u8d4b\u503c\u4e0eswap","text":"// \u8fd4\u56de\u53cd\u5411\u5bb9\u5668\nreverse_iterator\nconst_reverse_iterator\nc.rbegin() c.rend()\n\n// \u6784\u9020\u8d4b\u503c\nType c;\nType c1 = c2;\nType c(n,val);\nType c1(c2);\n
c1 = c2;\nc = {a,b,c};\nswap(c1,c2);\nc1.swap(c2);\nseq.assign(b,e); // b,e\u6307\u5411\u7684\u4e0d\u80fd\u662fseq\u4e2d\u7684\nseq.assign(initialList);\nseq.assign(n,val);\n
\u9664\u4e86\u6570\u7ec4\u4e4b\u5916\uff0cSwap\u64cd\u4f5c\u4e0d\u5bf9\u6570\u636e\u8fdb\u884c\u62f7\u8d1d\u3001\u5220\u9664\u3001\u63d2\u5165\uff0c\u53ef\u4ee5\u5728\u5e38\u6570\u65f6\u95f4\u5185\u5b8c\u6210
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#_3","title":"\u987a\u5e8f\u5bb9\u5668","text":"\u987a\u5e8f\u5bb9\u5668\u4e2d\u7684\u5143\u7d20\u6309\u7167\u4e25\u683c\u7684\u7ebf\u6027\u987a\u5e8f\u6392\u5e8f\u3002\u53ef\u4ee5\u901a\u8fc7\u5143\u7d20\u5728\u5e8f\u5217\u4e2d\u7684\u4f4d\u7f6e\u8bbf\u95ee\u5bf9\u5e94\u7684\u5143\u7d20\u3002
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#_4","title":"\u64cd\u4f5c","text":"**\u4ee5\u4e0b\u7684\u64cd\u4f5c\u4e0d\u4e00\u5b9a\u5bf9\u6240\u6709\u7684\u987a\u5e8f\u5bb9\u5668\u751f\u6548**\n// \u6dfb\u52a0\u5143\u7d20\nc.push_back(t);\nc.push_front(t);\nc.emplace_front(args);\nc.emplace_back(args);\n //\u8fd4\u56de\u7b2c\u4e00\u4e2a\u65b0\u52a0\u5165\u5143\u7d20\u7684\u8fed\u4ee3\u5668\nc.insert(position,n,val); // position \u4e3a \u8fed\u4ee3\u5668\nc.insert(position,begin,end);\nc.insert(position,initialList);\n\n// \u4f4d\u7f6e\nc.at(n);\n// \u5220\u9664\nc.pop_back();\nc.pop_front();\nc.erase(position);\nc.erase(b,e);\n// \u6539\u53d8\u5927\u5c0f\nc.resize(n,optional::val);\n// \u5bb9\u91cf\u5927\u5c0f\nc.capacity();\nc.size();\nc.shrink_to_fit();\nc.reserve(n);\n
\u6dfb\u52a0\u5143\u7d20
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#forward_list","title":"forward_list","text":"
- emplace\u4e0epush\u3001insert\u7684\u4e0d\u540c\u5728\u4e8e\uff0cemplace\u662f\u901a\u8fc7\u5143\u7d20\u7684\u6784\u9020\u51fd\u6570\u76f4\u63a5\u6784\u9020\u4e00\u4e2a\u65b0\u7684\u5143\u7d20\uff1b\u800c\u53e6\u5916\u4e24\u8005\u662f\u62f7\u8d1d\u7684\u65b9\u5f0f
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#string","title":"String","text":"flits.before_begin();\nflits.insert_after(...);\nemplace_after(iter_position,args);\nflits.erase_after(position);\nflits.erase_after(b,e);\n
// \u6784\u9020\u51fd\u6570\nstring s1(cp,n); // cp[n]\u4e4b\u524d\nstring s2(str,pos); // str[pos]\u4e4b\u540e\nstring s3(str,pos,len);\n// \ns.substr(pos,n); // position n\u4e2a\n\n// \u63d2\u5165 char / string\ns.insert(nth,\"\");\ns.append(\"\");\ns.replace();\n
\u641c\u7d22\u64cd\u4f5c
\u6ce8\u610f\uff0cfind()\u51fd\u6570\u7684\u8fd4\u56de\u503c\u662f
unsigned
\u7c7b\u578b\uff0cstring::size_type npos = -1;
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#adaptor","title":"\u9002\u914d\u5668 | adaptor","text":"// \u5168\u5339\u914d\ns.find();\ns.rfind(); // \u6700\u540e\u4e00\u6b21\u51fa\u73b0\n// \u90e8\u5206\u5339\u914d\ns.find_first_of();\ns.find_first_not_of();\ns.find_last_of();\ns.find_last_not_of();\n// example\ncout << a.find(); // Not Found: 18446744073709551615\nstring str = \"he is not here\";\ncout << str.find(\"he\") << endl;\ncout << str.substr(str.find(\"he\"), sizeof(\"he\"));\n// example \u9009\u62e9\u5339\u914d\nstring str = \"11h23e55 i4456s88 n77o97t here!\";\nstring numbers(\"0123456789\");\nstring result(\"\");\nstring::size_type pos = 0;\nwhile ((pos = str.find_first_not_of(numbers, pos)) != string::npos)\n{\n result.push_back(str[pos]);\n pos++;\n}\ncout << result;\n
\u9002\u914d\u5668\u53ef\u4ee5\u5c06\u4e00\u4e2a\u7c7b\u7684\u63a5\u53e3\u8f6c\u5316\u4e3a\u53e6\u5916\u4e00\u4e2a\u7c7b\u7684\u63a5\u53e3\u3002 \u901a\u8fc7\u5305\u88c5\u4e00\u4e2a\u5e95\u5c42\u7684\u7c7b\uff0c\u5bf9\u5176\u63a5\u53e3\u8fdb\u884c\u4e8c\u6b21\u5904\u7406\uff0c\u5448\u73b0\u51fa\u4e00\u79cd\u65b0\u7684\u5f62\u5f0f \u4e00\u822c\u60c5\u51b5\u4e0b\uff0c
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#_5","title":"\u5173\u8054\u5bb9\u5668","text":"stack
queue
\u57fa\u4e8edequeue
\u5b9e\u73b0\uff0cpriority_queue
\u57fa\u4e8evector\u5b9e\u73b0\uff08\u4e5f\u53ef\u4ee5\u901a\u8fc7\u91cd\u8f7d\u6539\u53d8\uff0c\u4f46\u9700\u8981\u6ee1\u8db3\u9002\u914d\u5668\u7684\u7279\u6027\uff09 \u5982stack<string, vector<string>> str_stk;
\u6ce8\u610f
"},{"location":"CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/#map","title":"map","text":"
- \u4f7f\u7528\u5173\u8054\u5bb9\u5668\u7684
find
\u6bd4\u6cdb\u578b\u7b97\u6cd5\u7684find
\u66f4\u52a0\u9ad8\u6548"},{"location":"CodingLanguage/CPP/cake/assert/","title":"Assert","text":"map< <type>,<type> >\n\nmap<string,int> M {{},{}};\n// map \u4e2d\u7684\u5143\u7d20\u662f pair \u7c7b\u578b\nmap.first();\nmap.second();\n// \u5bf9\u4e8e\u5355\u4e00\u7684 insert \u64cd\u4f5c\uff0c\u8fd4\u56de\u4e00\u4e2apair\u7c7b\u578b\uff0c\u7b2c\u4e00\u4e2a\u503c\u662f\u8fed\u4ee3\u5668\uff0c\u7b2c\u4e8c\u4e2a\u503c\u662fbool\u8868\u5f81\u6210\u529f\u4e0e\u5426\nM.insert({word, 1});\nM.insert(make_pair(word, 1));\nM.insert(pair<string, int>(word, 1));\nM.insert(map<string, int>());\n// \u5bf9map\u7684\u8bbf\u95ee\nM[]; // \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u76f4\u63a5\u4e0b\u6807\u8bbf\u95ee\u5982\u679c\u672a\u67e5\u8be2\u5230\u5c06\u4f1ainsert\uff0c\u800cat()\u8bbf\u95ee\u8fd4\u56de\u5c3e\u540e\u6307\u9488\nM.at();\n// new feature\nM.try_emplace()\nM.merge()\n
\u7ea6 60 \u4e2a\u5b57 15 \u884c\u4ee3\u7801
Ref
Geeks
Assert \u66f4\u7ecf\u5e38\u7528\u4e8e\u4e00\u4e9b\u5e95\u5c42\u7684\u68c0\u67e5\u3001Debug\u8fc7\u7a0b\u4e2d\uff0c\u800c\u5f02\u5e38\u68c0\u6d4b\u5e38\u5e38\u662f\u5728\u4e00\u4e9b\u63a5\u53e3\u8c03\u7528\u65f6\u7531\u4e0a\u5c42\u5224\u65ad
assert\u53ef\u4ee5\u5173\u95ed
"},{"location":"CodingLanguage/CPP/cake/assert/#_1","title":"\u5355\u5143\u6d4b\u8bd5","text":"// The below program runs fine because NDEBUG is defined\n# define NDEBUG\n# include <assert.h>\n\nint main()\n{\n int x = 7;\n assert (x==5);\n return 0;\n}\n
\u4e0b\u9762\u8fd9\u4e00\u6bb5\u4ee5gtest\u4e3a\u4f8b
"},{"location":"CodingLanguage/CPP/classes/","title":"Index","text":"#include \"gtest/gtest.h\"\nvoid CheckTxnLockSize(Txn &txn, size_t shared_expected, size_t exclusive_expected) {\n ASSERT_EQ(shared_expected, txn.GetSharedLockSet().size());\n ASSERT_EQ(exclusive_expected, txn.GetExclusiveLockSet().size());\n}\n
\u7ea6 0 \u4e2a\u5b57
"},{"location":"CodingLanguage/CPP/classes/Copy/","title":"Copy Control","text":"\u7ea6 256 \u4e2a\u5b57 77 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
Copy
- \u51fd\u6570\u4f20\u53c2\u6570
"},{"location":"CodingLanguage/CPP/classes/Copy/#_1","title":"\u62f7\u8d1d\u6784\u9020\u51fd\u6570","text":"class A\n{\npublic:\n A(int i) : mi(i) {}\n A(const A &rhs) : mi(rhs.mi)\n {\n cout << \"A::A(&)\" << endl;\n }\n virtual void f()\n {\n cout << \"A::f(), \" << mi << endl;\n }\nprotected:\n int mi;\n};\n
- \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u7f16\u8bd1\u5668\u4f1a\u6709\u4e00\u4e2a
- \u539f\u751f\u7c7b\u578b\u503c\u62f7\u8d1d
- class\u8c03\u7528\u5176\u62f7\u8d1d\u51fd\u6570
- \u4f46\u662f\u5bf9\u4e8e\u6307\u9488\u800c\u8a00\uff0c\u5b83\u4e5f\u662f\u503c\u62f7\u8d1d\uff0c\u5bfc\u81f4\u6709\u4e24\u4e2a\u6307\u9488\u6307\u5411\u540c\u4e00\u4e2a\u5143\u7d20\u3002\u8fd9\u5bfc\u81f4\u5b83\u7684\u7ba1\u7406\u4e0d\u660e\u786e\uff0c\u53ef\u80fd\u5bf9\u540c\u4e00\u5757\u5730\u5740\u8fdb\u884c\u4e24\u6b21\u751a\u81f3\u591a\u6b21
delete
.\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u8981\u5bf9\u6790\u6784\u51fd\u6570\u3001\u62f7\u8d1d\u6784\u9020\u51fd\u6570\u8fdb\u884c\u5b9a\u4e49Why const and why &
- const: \u4e0d\u80fd\u6539\u53d8
- \u5f15\u7528: \u4e0d\u7136\u4f20\u53c2\u6570\u7684\u65f6\u5019\u53d1\u751f\u503c\u4f20\u9012\uff0c\u53c8\u8981\u8c03\u7528\u62f7\u8d1d\u51fd\u6570\uff0c\u9677\u5165\u6b7b\u5faa\u73af
\u5b9a\u4e49\u90e8\u5206A(const A &rhs) : mi(rhs.mi)\n{\n\n}\n
\u7f16\u8bd1\u5668\u4f18\u5316\u95ee\u9898#include <iostream>\nusing namespace std;\nclass A\n{\npublic:\n A() : value(0) { cout << \"A() \" << endl; };\n A(int a) : value(a) { cout << \"A(int a)\" << endl; };\n A(const A &other)\n {\n this->value = other.value;\n cout << \"A(&)\" << other.value << endl;\n };\n\n ~A() { cout << \"~A\" << endl; };\n\nprivate:\n int value;\n};\nA f(int a)\n{\n cout << \"f()\" << endl;\n return A(a);\n}\nA bar(A a)\n{\n cout << \"bar\" << endl;\n return a;\n}\n
"},{"location":"CodingLanguage/CPP/classes/Copy/#_2","title":"\u62f7\u8d1d\u8d4b\u503c\u8fd0\u7b97","text":"int main()\n{\n // \u7f16\u8bd1\u5668\u4f18\u5316\n // \u62f7\u8d1d\u6784\u9020\u88ab\u4f18\u5316 \u76f8\u5f53\u4e8e xa = A(5)\n A xa = f(5);\n /*\n f()\n A(int a)\n */\n\n // \u8fdb\u884c\u62f7\u8d1d\u6784\u9020\n A xb = bar(xa);\n /*\n A(&)5 \u53c2\u6570\u4f20\u5165\u4e00\u6b21\u62f7\u8d1d\u6784\u9020\n bar bar \u8c03\u7528\n A(&)5 \u62f7\u8d1d\u6784\u9020 xb = \u4f20\u56de\u53c2\u6570\n ~A \u5e94\u8be5\u662f\u90a3\u4e2a\u53c2\u6570\u88ab\u9500\u6bc1\u4e86\n */\n A xc = A(11);\n}\n
\u62f7\u8d1d
"},{"location":"CodingLanguage/CPP/classes/Copy/#vector","title":"\u6548\u7387\u95ee\u9898 Vector","text":"
- \u901a\u5e38\u8fd4\u56de\u5de6\u503c\u7684\u5f15\u7528
\u7531\u4e8evector\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u4f1a\u53d1\u751f\u6269\u5bb9\uff0c\u6240\u4ee5\u62f7\u8d1d\u6784\u9020\u4f1a\u591a\u6b21\u8fdb\u884c
\u4f18\u5316\u62f7\u8d1d
\u5c06
alist.push_back(A(0));
\u6539\u4e3aalist.emplace_back(0);
\uff0c\u53ef\u4ee5\u4e0d\u6267\u884c\u62f7\u8d1d\u6784\u9020\u800c\u662f\u76f4\u63a5\u6784\u9020C11 \u7981\u7528copy\uff0c
Person(const Person &rhs) = delete;
"},{"location":"CodingLanguage/CPP/classes/Inherit/","title":"\u7ec4\u5408\u4e0e\u7ee7\u627f","text":"vector<A> alist;\n// push_back\nalist.push_back(A(0));\nalist.push_back(A(1));\nalist.push_back(A(2));\n\nalist.emplace_back(0);\nalist.emplace_back(1);\nalist.emplace_back(2);\n
\u7ea6 78 \u4e2a\u5b57 53 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 1 \u5206\u949f
"},{"location":"CodingLanguage/CPP/classes/Inherit/#_2","title":"\u7ec4\u5408","text":""},{"location":"CodingLanguage/CPP/classes/Inherit/#_3","title":"\u7ee7\u627f","text":"\u8986\u76d6\u5173\u7cfb
\u540c\u540d\u51fd\u6570\u7684\u7ee7\u627f\u95ee\u9898 \u4e00\u4e2a\u6d3e\u751f\u7c7b\u4e2doverride\uff0c\u5176\u4ed6\u57fa\u7c7b\u540c\u540d\u51fd\u6570\u4e5f\u88ab\u8986\u76d6\u6389
\u8bb0\u5f97override\u6240\u6709\u7684\u76f8\u5173\u51fd\u6570
#include <iostream>\nusing namespace std;\nclass A\n{\npublic:\n A(int i) : mi(i) {}\n A(const A &rhs) : mi(rhs.mi)\n {\n cout << \"A::A(&)\" << endl;\n }\n A &operator=(const A &rhs)\n {\n mi = rhs.mi;\n cout << \"A::operator=()\" << endl;\n return *this;\n }\n virtual void f()\n {\n cout << \"A::f(), \" << mi << endl;\n }\n\nprotected:\n int mi;\n};\n\nclass B : public A\n{\npublic:\n B(int i, int j) : A(i), mj(j) {}\n void f() override\n {\n cout << \"B::f(), \" << mi << \", \" << mj << endl;\n }\n\nprivate:\n int mj;\n};\n\nint main()\n{\n A a1(1);\n B b(3, 4);\n\n A &ra = b;\n ra.f();\n ra = a1;\n ra.f();\n\n A a2 = b;\n a2.f();\n}\n
- copy \u6d3e\u751f\u7c7b
=
\u8d4b\u503c\u7ed9\u57fa\u7c7b\uff0cvirtual\u7684\u8868\u4e0d\u4f1a\u62f7\u8d1d\u8fc7\u53bb
base = derived\n
- upcasting
\u7528
void* *
\u8f6c\u6362\n
Relaxation
"},{"location":"CodingLanguage/CPP/classes/OverloadOperator/","title":"Overload","text":"\u7ea6 3 \u4e2a\u5b57
info
"},{"location":"CodingLanguage/CPP/classes/OverloadOperator/#_1","title":"OverloadOperator","text":""},{"location":"CodingLanguage/CPP/classes/class/","title":"CLASSES","text":"\u7ea6 562 \u4e2a\u5b57 49 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
"},{"location":"CodingLanguage/CPP/classes/class/#_1","title":"\u6784\u9020\u4e0e\u6790\u6784","text":""},{"location":"CodingLanguage/CPP/classes/class/#_2","title":"\u5c01\u88c5","text":""},{"location":"CodingLanguage/CPP/classes/class/#_3","title":"\u8bbf\u95ee\u63a7\u5236","text":""},{"location":"CodingLanguage/CPP/classes/class/#protected","title":"protected","text":"\u5f53\u6210\u5458\u88ab\u58f0\u660e\u4e3a protected \u65f6\uff0c\u5b83\u4eec\u5bf9\u4e8e\u6d3e\u751f\u7c7b\u662f\u53ef\u8bbf\u95ee\u7684\uff0c\u4f46\u5bf9\u4e8e\u7c7b\u5916\u90e8\u662f\u4e0d\u53ef\u8bbf\u95ee\u7684\u3002
"},{"location":"CodingLanguage/CPP/classes/class/#private","title":"private","text":"
- \u6d3e\u751f\u7c7b\u7684\u8bbf\u95ee\uff1a\u6d3e\u751f\u7c7b\u53ef\u4ee5\u8bbf\u95ee\u5176\u57fa\u7c7b\u4e2d\u58f0\u660e\u4e3a protected \u7684\u6210\u5458\u3002
- \u7c7b\u5916\u90e8\u7684\u8bbf\u95ee\uff1a\u7c7b\u5916\u90e8\u4e0d\u80fd\u76f4\u63a5\u8bbf\u95ee\u57fa\u7c7b\u4e2d\u58f0\u660e\u4e3a protected \u7684\u6210\u5458\uff0c\u5305\u62ec\u6d3e\u751f\u7c7b\u7684\u5bf9\u8c61\u4e5f\u4e0d\u80fd\u76f4\u63a5\u8bbf\u95ee\u3002
- \u6d3e\u751f\u7c7b\u7684\u6210\u5458\u51fd\u6570\u7684\u8bbf\u95ee\uff1a\u6d3e\u751f\u7c7b\u7684\u6210\u5458\u51fd\u6570\u53ef\u4ee5\u8bbf\u95ee\u5176\u57fa\u7c7b\u4e2d\u58f0\u660e\u4e3a protected \u7684\u6210\u5458\u3002
- \u53cb\u5143\u7c7b\u548c\u53cb\u5143\u51fd\u6570\u7684\u8bbf\u95ee\uff1a\u53cb\u5143\u7c7b\u548c\u53cb\u5143\u51fd\u6570\u53ef\u4ee5\u8bbf\u95ee\u57fa\u7c7b\u4e2d\u58f0\u660e\u4e3a protected \u7684\u6210\u5458\u3002
"},{"location":"CodingLanguage/CPP/classes/class/#friend","title":"friend","text":"
- \u9488\u5bf9\u7c7b\u800c\u8a00\u7684\u6982\u5ff5\uff0c\u800c\u4e0d\u662f\u9488\u5bf9\u67d0\u4e2a\u5b9e\u4f8b. \u9488\u5bf9\u4e0b\u9762\u7684\u5b9e\u4f8b\uff0c
class A\n{\n public:\n void Foo(Base * B){cout << B.val << endl;}\n private:\n int val;\n}\n
friend
- \u4e00\u822c\u6765\u8bf4\uff0c\u6700\u597d\u628a\u53cb\u5143\u58f0\u660e\u96c6\u4e2d\u653e\u5230\u7c7b\u7684\u5f00\u59cb\u90e8\u5206
- \u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u53cb\u5143\u58f0\u660e\u672c\u8eab\u5e76\u4e0d\u662f\u4e00\u4e2a\u6b63\u5f0f\u7684\u58f0\u660e\uff0c\u6211\u4eec\u8981\u5728\u7c7b\u4e4b\u5916\u518d\u6b21\u6b63\u5f0f\u58f0\u660e\u51fd\u6570
- \u53cb\u5143\u5173\u7cfb\u662f\u5355\u5411\u7684\uff0c\u4e0d\u5177\u6709\u4f20\u9012\u6027\u3002
- \u53cb\u5143\u5173\u7cfb\u4e0d\u53d7\u8bbf\u95ee\u63a7\u5236\u7b26\u5f71\u54cd\uff0c\u5373\u53cb\u5143\u51fd\u6570\u6216\u53cb\u5143\u7c7b\u53ef\u4ee5\u8bbf\u95ee\u7c7b\u7684\u79c1\u6709\u3001\u4fdd\u62a4\u548c\u516c\u6709\u6210\u5458\u3002
\u5c3d\u91cf\u5c11\u4f7f\u7528\u53cb\u5143\uff0c\u56e0\u4e3a\u5b83\u7834\u574f\u4e86\u5c01\u88c5\u6027\uff0c\u4f7f\u4ee3\u7801\u66f4\u96be\u7406\u89e3\u548c\u7ef4\u62a4\u3002\u53ea\u5728\u786e\u5b9e\u9700\u8981\u8bbf\u95ee\u79c1\u6709\u6210\u5458\u4f46\u65e0\u6cd5\u901a\u8fc7\u6210\u5458\u51fd\u6570\u6216\u63a5\u53e3\u5b9e\u73b0\u65f6\u624d\u4f7f\u7528\u53cb\u5143\u3002 \u53cb\u5143\u51fd\u6570\u6216\u53cb\u5143\u7c7b\u7684\u58f0\u660e\u901a\u5e38\u653e\u5728\u7c7b\u7684\u5185\u90e8\uff0c\u4f46\u5b9a\u4e49\u53ef\u4ee5\u5728\u7c7b\u5185\u6216\u5916\u3002
"},{"location":"CodingLanguage/CPP/classes/class/#_4","title":"\u6784\u9020\u4e0e\u6790\u6784","text":""},{"location":"CodingLanguage/CPP/classes/class/#const","title":"const","text":"
- \u5728\u591a\u6001\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u8c03\u7528\u6d3e\u751f\u7c7b\\\u591a\u6001\u7c7b\u7684\u7684\u6790\u6784\u51fd\u6570\u65f6\uff0c\u8981\u8bb0\u5f97\u628a\u6790\u6784\u51fd\u6570\u5b9a\u4e49\u4e3a
vitual
- \u4e3a\u51fd\u6570\u6dfb\u52a0const\u4fee\u9970\uff0c
assignment & Initialization
const
\u5bf9\u8c61\u7684\u521d\u59cb\u5316\n
"},{"location":"CodingLanguage/CPP/classes/class/#_5","title":"\u5185\u5b58\u5e03\u5c40","text":"class S\n{\n static int count; // \u7531\u5b9e\u4f8b\u5171\u4eab\n static const int size = 100;\n const int selfRank;\n // int A[selfRank]; // Error\n // int A[count]; // Error\n int A[size];\n\npublic:\n void f()\n {\n cout << \"SizeOF S\" << sizeof(S) << endl;\n }\n void f() const\n {\n cout << \"f() const\" << endl;\n }\n\n static void g() // \u53ef\u4e0d\u7531\u5b9e\u4f8b\u4f7f\u7528\n {\n cout << \"Recall g()\" << endl;\n }\n S() : selfRank(0) {}\n S(int rank) : selfRank(rank)\n {\n }\n};\n\nint S::count = 100;\n\nint main()\n{\n const S s;\n S s2;\n S::g();\n s.f();\n s.g();\n s2.f();\n};\n
"},{"location":"CodingLanguage/CPP/classes/class/#_6","title":"class","text":""},{"location":"CodingLanguage/CPP/classes/class/#_7","title":"\u591a\u6001","text":"
- \u6210\u5458\u51fd\u6570\u5b58\u653e\u5728\u4ee3\u7801\u533a
static
\u4e0d\u5728class\u533a\u57df\u7684\u5185\u5b58\u5b9a\u4e49vitual
"},{"location":"CodingLanguage/CPP/classes/class/#abstract-class","title":"Abstract Class","text":""},{"location":"CodingLanguage/CPP/classes/class/#interface","title":"Interface","text":""},{"location":"CodingLanguage/CPP/classes/class/#_8","title":"class","text":""},{"location":"CodingLanguage/CPP/classes/template/","title":"\u6a21\u677f\u548c\u6cdb\u578b\u7f16\u7a0b","text":"
- vitual \u901a\u8fc7\u4e00\u4e2a\u51fd\u6570\u6307\u9488\u5b9e\u73b0
8 bytes
- \u6307\u9488\u6307\u5411\u4e00\u4e2a\u8868\uff0c\u5305\u542b\u6240\u6709\u865a\u51fd\u6570\u7684code
- \u8fd9\u4e2a\u51fd\u6570\u6307\u9488\u653e\u5728\u524d\u516b\u4e2a\u5b57\u8282\u4e2d\uff0c\u6240\u4ee5\u865a\u51fd\u6570\u5b9e\u9645\u8c03\u7528\u7684\u65f6\u5019\u5c31\u662f\u901a\u8fc7\u8fd9\u524d\u516b\u4e2a\u5b57\u8282\u8fdb\u884c\u7d22\u5f15
\u7ea6 38 \u4e2a\u5b57 12 \u884c\u4ee3\u7801
INFO
template
"},{"location":"CodingLanguage/CPP/classes/template/#_2","title":"\u6a21\u677f","text":""},{"location":"CodingLanguage/CPP/classes/template/#_3","title":"\u51fd\u6570\u6a21\u677f","text":""},{"location":"CodingLanguage/CPP/classes/template/#_4","title":"\u6a21\u677f\u5b9a\u4e49","text":"template <typename T>\nT info(T &a, T &b)\n{\n}\n
\u975e\u7c7b\u578b\u53c2\u6570
inlinetemplate <typename T,unsigned m,unsigned n>\nT info(const char (&p1)[m],const char (&p1)[n])\n{\n}\n
"},{"location":"CodingLanguage/CPP/classes/template/#_5","title":"\u7c7b\u6a21\u677f","text":"
template <> inline
template <typename T>\nclass S\n{\n}\n
\u663e\u5f0f\u6a21\u677f\u5b9e\u53c2 vector"},{"location":"CodingLanguage/Python/","title":"Index","text":"
\u7ea6 0 \u4e2a\u5b57
"},{"location":"CodingLanguage/Python/CS61A/","title":"CS61A","text":"\u7ea6 1947 \u4e2a\u5b57 553 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 17 \u5206\u949f
\u6982\u8ff0
\u8fd9\u4e2a\u6587\u6863\u8bb0\u5f55\u4e86\u4e4b\u524d\u5b66\u4e60CS61A\u7684\u4e00\u90e8\u5206\u7b14\u8bb0\uff0c\u5f53\u65f6\u5e76\u6ca1\u6709\u542c\u5b8c\u6240\u6709\u8bfe\uff0c\u8fd9\u4efd\u7b14\u8bb0\u4e0d\u7b97\u7279\u522b\u5b8c\u5584\u3002\uff08\u5f53\u7136\u6709\u4e00\u90e8\u5206\u662f\u89c9\u5f97\u6ca1\u4ec0\u4e48\u8bb0\u7684\u5fc5\u8981\uff09
\u4e0d\u5f97\u4e0d\u8bf4\uff0c\u8fd9\u4e2a\u8bfe\u4f5c\u4e3a\u6211\u4e0a\u8fc7\u7684\u7b2c\u4e00\u95e8\u56fd\u5916\u7f51\u8bfe\uff0c\u5b83\u7684\u8bfe\u7a0b\u7f51\u7ad9\u3001\u4f5c\u4e1aOJ\u3001\u5305\u62ec\u6307\u5bfc\u6559\u7a0b\u90fd\u4ee4\u6211\u5370\u8c61\u633a\u6df1\u7684\u3002
\u8d44\u6e90
FALL 2020
CS 61A Fall 2020
ANSEWR
GitHub - HobbitQia/CS61A-Fall-2020: My solutions for CS61A Fall 2020.
Python Tutor
Online Python Tutor - Composing Programs - Python 3
TextBook
Composing Programs
"},{"location":"CodingLanguage/Python/CS61A/#chapter-1-building-abstractions-with-function","title":"Chapter 1: Building Abstractions with Function","text":""},{"location":"CodingLanguage/Python/CS61A/#_1","title":"\u57fa\u672c\u7279\u5f81","text":""},{"location":"CodingLanguage/Python/CS61A/#features","title":"Features","text":"
- turediv / \u6d6e\u70b9\u6570
- floordiv // \u6574\u9664
- \u53ef\u4ee5\u6709\u591a\u4e2a\u8fd4\u56de\u503c
def divide_exact(n,d) return n//d, n%d
"},{"location":"CodingLanguage/Python/CS61A/#_2","title":"\u5b57\u7b26\u4e32","text":"
- py \u6ca1\u6709\u5355\u72ec\u7684\u5b57\u7b26\u7c7b\u578b\uff0c\u4e00\u4e2a\u5b57\u7b26\u5c31\u662f\u957f\u5ea6\u4e3a 1 \u7684\u5b57\u7b26\u4e32
- Python \u4e2d\u7684\u5b57\u7b26\u4e32\u4e0d\u80fd\u6539\u53d8
- \u53cd\u659c\u6760\u53ef\u4ee5\u7528\u6765\u8f6c\u4e49\uff0c\u4f7f\u7528 r \u53ef\u4ee5\u8ba9\u53cd\u659c\u6760\u4e0d\u53d1\u751f\u8f6c\u4e49\u3002 \u5982 r\"this is a line with \\n\" \u5219 \\n \u4f1a\u663e\u793a\uff0c\u5e76\u4e0d\u662f\u6362\u884c\u3002\uff08raw string\uff09
- \u5b57\u7b26\u4e32\u7684\u622a\u53d6\u7684\u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\uff1a\u53d8\u91cf[\u5934\u4e0b\u6807:\u5c3e\u4e0b\u6807:\u6b65\u957f]
str = '123456789'\nprint(str[0:-1])# \u8f93\u51fa\u7b2c\u4e00\u4e2a\u5230\u5012\u6570\u7b2c\u4e8c\u4e2a\u7684\u6240\u6709\u5b57\u7b26\n>>> 12345678\nprint(str[0])# \u8f93\u51fa\u5b57\u7b26\u4e32\u7b2c\u4e00\u4e2a\u5b57\u7b26\n>>> 1\nprint(str[2:5])# \u8f93\u51fa\u4ece\u7b2c\u4e09\u4e2a\u5f00\u59cb\u5230\u7b2c\u516d\u4e2a\u7684\u5b57\u7b26\uff08\u4e0d\u5305\u542b\uff09print(str[2:])# \u8f93\u51fa\u4ece\u7b2c\u4e09\u4e2a\u5f00\u59cb\u540e\u7684\u6240\u6709\u5b57\u7b26\n>>> 345\nprint(str[1:5:2])# \u8f93\u51fa\u4ece\u7b2c\u4e8c\u4e2a\u5f00\u59cb\u5230\u7b2c\u4e94\u4e2a\u4e14\u6bcf\u9694\u4e00\u4e2a\u7684\u5b57\u7b26\uff08\u6b65\u957f\u4e3a2\uff09\n>>> 24\n
- \u5b57\u7b26\u4e32\u53ef\u4ee5\u7528 + \u8fd0\u7b97\u7b26\u8fde\u63a5\u5728\u4e00\u8d77\uff0c\u7528 * \u8fd0\u7b97\u7b26\u91cd\u590d
"},{"location":"CodingLanguage/Python/CS61A/#_3","title":"\u4ea4\u4e92","text":"print(ptr * 2)\n
- Print \u548c return
print\u8f93\u51fa\u7684\u662f \u2018\u2019\u5f15\u53f7\u5185\u7684
return \u6240\u6709
"},{"location":"CodingLanguage/Python/CS61A/#environment","title":"environment","text":""},{"location":"CodingLanguage/Python/CS61A/#_4","title":"\ud83d\udca1CS61A","text":""},{"location":"CodingLanguage/Python/CS61A/#environment_1","title":"\u9ad8\u9636\u51fd\u6570\u7684 Environment","text":""},{"location":"CodingLanguage/Python/CS61A/#nested-higher","title":"Nested / Higher","text":"
- environment is combined with many frames.
- global frame and others(local frame)
- And at one time, there`s only one frame( the program can`t be in two distinct frames )
- \u5b9a\u4e49\u5e76\u4e0d\u4f1a\u521b\u5efaframe \u53ea\u6709\u5f53\u8fd0\u884c\u5230\u51fd\u6570\u65f6\u624d\u4f1a\u521b\u5efa
# \u4e00\u4e2a\u5d4c\u5957\u51fd\u6570\n# make_adder(5) \u5c06\u8fd4\u56de\u4e00\u4e2a\u51fd\u6570\uff08+5\u7684adder\uff09\ndef compose(f,g):\n def h(x):\n return f(g(x))\n return h\ndef make_adder(x):\n def adder(y):\n return y + x\n return adder\n>>> compose(f,make_adder(5))(4) ```\u5b8c\u6210\u8c03\u7528\n
"},{"location":"CodingLanguage/Python/CS61A/#_5","title":"\u5982\u4f55\u7ed8\u5236","text":""},{"location":"CodingLanguage/Python/CS61A/#funciton","title":"funciton","text":"def print_sums(n):\n \"\"\"Print all sums of arguments of repeated calls.\n n \u4e3a\u603b\u548c k \u4e3a\u4e0b\u4e00\u4e2a\u52a0\u548c\u6570\u5b57\n >>> f = print_sums(1)(2)(3)(4)(5)\n 1\n 3\n 6\n 10\n 15\n \"\"\"\n print(n)\n def next_sum(k):\n return print_sums(n+k)\n return next_sum\n
- from operator import add,mul //\u5f15\u5165\u51fd\u6570\uff08build-in\uff09
- docstring `````` ( HELP ) comments # \u6ce8\u91ca
Print and None
- Print \u8fd4\u56de\u503c\u4e3aNone None\u5728py \u4e2d\u4e0d\u662f\u4e00\u4e2a\u6570\u503c\u8868\u8fbe ==> NoneType \u548c int \u4e0d\u80fd\u8fdb\u884c\u8ba1\u7b97\uff08type Error\uff09
Control
bool \uff1a \u5bf9\u4e8e and \u548c or \u4ed6\u4eec\u603b\u662f\u8fd4\u56de\u6700\u540e\u4e00\u4e2aevaluate\u7684\u5bf9\u8c61\uff0c\u5982\u679c\u5224\u65ad\u5bf9\u8c61\u4e0d\u662fbooleans\uff0c\u5c06\u8fd4\u56de\u6570\u5b57\uff1bTure and 13 will return 13 but not True
iteration \u8fed\u4ee3\uff1a
Test \uff1a Assertions\u5728False\u65f6 \u8f93\u51fa\u540e\u9762\u7684\u5b57\u7b26\u4e32 \u2018 \u2019\u6216\u8005\u201c \u201d
Doctest
- \u5168\u5c40
from doctest import testmod
- \u5355\u4e2a\u51fd\u6570
from doctest import run_docstring_examples
- \u6587\u4ef6
python3 -m doctest \u8fd0\u884c\u6240\u6709 doctests
\u9ad8\u9636\u51fd\u6570
- Currying \u53ea\u542b\u6709\u4e00\u4e2a \u53c2\u6570
\u4f8b\u5982\uff0cg (x) (y) \u7b49\u6548\u4e8e f (x , y) , \u8fd9\u4e2a\u8f6c\u6362\u7684\u8fc7\u7a0b\u5c31\u88ab\u79f0\u4e3acurrying
from operator import add, mul\ndef curry2(f):\n def g(x):\n def h(y):\n return f(x, y)\n return h\n return g\nm = curry2(add)\nadd_three = m(3)\nadd_three(4)\nm(2)(1)\n
- Lambda Expressions
\u5b9a\u4e49\u6b64\u7c7b\u51fd\u6570\u65f6\u6ca1\u6709 intrinsic name
b = lambda x: lambda: x # Lambdas can return other lambdas!\nc = b(88)\n>>> c\nFunction\n>>> c()\n88\n
- Decorators \u4fee\u9970\u7b26
\u7528\u4e8e\u66f4\u597d\u5730\u4f7f\u7528\u9ad8\u9636\u51fd\u6570 triple \u7ed1\u5b9a\u7684\u662f trace \u5728\u8c03\u7528triple\u4e4b\u540e\u7ed1\u5b9a\u7684\u8fd4\u56de\u503c :::
"},{"location":"CodingLanguage/Python/CS61A/#_6","title":"\u542b\u6709\u4efb\u610f\u53c2\u6570\u7684\u51fd\u6570","text":"def print_sum(n):\n //\u6253\u5370n\u4e2a\u6570\u7684\u603b\u548c\n print(n)\n def f(k):\n return print_sum(n+k)\n return f\n\n>>> print_sum(3)(5)(7)\nn k print_sum(3) f(5)\n3 5 print_sum(8) f(7)\n8 7 print_sum(15) f\n
"},{"location":"CodingLanguage/Python/CS61A/#_7","title":"\u4fee\u9970","text":""},{"location":"CodingLanguage/Python/CS61A/#recursive-function","title":"Recursive Function","text":""},{"location":"CodingLanguage/Python/CS61A/#_8","title":"\u57fa\u672c\u6784\u6210","text":"def average(*args):\n k,sum = 0,0\n while k < trials_count:\n sum += original_function(*args) \n k += 1\n return sum / trials_count\n return average\n
- basic case
- recursive case
\u4f8b\u5982\uff0c\\(f_{n+1} = f_n + f (n-1)\\)
"},{"location":"CodingLanguage/Python/CS61A/#lambda","title":"** Lambda\u8868\u793a","text":""},{"location":"CodingLanguage/Python/CS61A/#_9","title":"\u57fa\u7840\u4f7f\u7528","text":""},{"location":"CodingLanguage/Python/CS61A/#y","title":"Y\u7b97\u5b50/\u4e0d\u52a8\u70b9","text":""},{"location":"CodingLanguage/Python/CS61A/#chapter-2-bulilding-abstractions-with-data","title":"Chapter 2 : Bulilding Abstractions with Data","text":""},{"location":"CodingLanguage/Python/CS61A/#sequences","title":"\u00b7 Sequences","text":""},{"location":"CodingLanguage/Python/CS61A/#lists","title":"Lists","text":"
- \u501f\u52a9 helper \u51fd\u6570 \u64cd\u7eb5\u66f4\u591a\u53c2\u6570
"},{"location":"CodingLanguage/Python/CS61A/#sequence-iteration","title":"Sequence Iteration","text":"# \u57fa\u672c\u8fd0\u7b97\n>>> digits = [1, 8, 2, 8]\n>>> len(digits)\n4\n>>> digits[3]\n8\n\n>>> [2, 7] + digits * 2 // mul \u548c add \u5bf9 list\n[2, 7, 1, 8, 2, 8, 1, 8, 2, 8]\n\n>>> pairs = [10, 20], [30, 40](10, 20], [30, 40.md){#9e0fbd15a3b78d4010362d10a44e1fa2}// \u5305\u542blist\u7684list \n>>> pairs[1]\n[30, 40]\n>>> pairs[1][0]\n30\n# unpack pair = [10,20]\n1. pair[0]\n2. x,y = pair\n3. >>> from operator import getitem\n >>> getitem(pair, 0)\n 10\n
for <name> in <expression>:\n <suite>\n
unpacking iteration
# \u5c06list\u4e2d\u7684\u591a\u4e2a\u503c\u8d4b\u7ed9\u53d8\u91cf\n>>> pairs = [1, 2], [2, 2], [2, 3], [4, 4](1, 2], [2, 2], [2, 3], [4, 4.md){#1e41902c4c4bd8a100fe6a2f77932c1c}// list\u542b\u6709\u76f8\u540c\u6570\u76ee\u5143\u7d20\n>>> for x, y in pairs:\n if x == y:\n same_count = same_count + 1\n>>> same_count\n2\n
range
"},{"location":"CodingLanguage/Python/CS61A/#sequence-processing","title":"Sequence Processing","text":">>> range(5,8) //\u5305\u62ec 5 excluding 8 \n>>> list(range(3)) // range() \n[0,1,2]\n>>> for _ in range(3): // _ \u8868\u793a\u4e0d\u518dsuit\u4e2d\u4f7f\u7528\u7684\u53d8\u91cf \u81ea\u52a8\u4ece 0 \u5f00\u59cb\n print('Go Bears!')\n
:::info List Comprehensions :::
[<map expression> for <name> in <sequence expression> if <filter expression>]\n# \u6ce8\u610f\u662f\u5728\u3010\u3011\u4e2d\u8fdb\u884c\uff0c\u751f\u6210\u65b0\u7684 List \n>>> odds = [1, 3, 5, 7, 9]\n>>> [x+1 for x in odds if ...]\n[2, 4, 6, 8, 10]\n# Aggregation\nsum max min , etc\n
:::info Higher-Order Function :::
# reduce \u91cd\u590d\u8ba1\u7b97\nfrom functools import reduce\nreduce(fn_reduce,iterable,initial)\n# map \nr = map(fn_map,iterable)\nlist(r)\n# \n
:::info Conventional Names :::
>>> apply_to_all = lambda map_fn, s: list(map(map_fn, s))\n>>> keep_if = lambda filter_fn, s: list(filter(filter_fn, s))\n
:::info Sequence Abstraction :::
"},{"location":"CodingLanguage/Python/CS61A/#trees","title":"Trees","text":"lists = [0,1,2,3,4,5,6,7]\n# Membership\nx in lists / not in\n# Slicing\nlist[0:]\n# Processing\n1. sum(iterative[,start])\n2. max(iterative[,key = function])\n3. all(iterative) -> bool()\n
- Trees. \u6709\u4e00\u4e2a rootlabel \u548c branches \u5b83\u672c\u8eab\u662f\u4e00\u79cd\u7528\u9012\u5f52\u5b9a\u4e49\u7684\u6570\u636e\u7ed3\u6784
- \u5f62\u5f0f\uff1a[label , branches = [] ] [1,[ [2 , [3]] , [4,[5]] , [6,[7]] ]]
\u5c24\u5176\u6ce8\u610fbranches\u7684\u683c\u5f0f\u95ee\u9898 \u4e5f\u53ef\u4ee5\u4f7f\u7528\u5b57\u5178\u5f62\u5f0f\u8868\u793atree\u8fd9\u79cd\u6570\u636e\u7ed3\u6784
- \u5bf9 tree \u7684\u904d\u5386\u7ecf\u5e38\u7528\u5230
for b in branches(t):\n
\u82e5\u5df2\u77e5\u4e3a\u4e8c\u53c9\u6811\uff0c\u4e5f\u53ef\u4ee5\u4e0d\u65ad\u5206\u4e3a left right \u4e24\u4e2a\u8282\u70b9
"},{"location":"CodingLanguage/Python/CS61A/#data-abstraction-of-trees","title":"Data abstraction of trees","text":"
h = **[**helper(branch,height + 1) for branch in branches(tree)**]**
\u8fd9\u6837\u7684\u8bed\u53e5\u4f1a\u5bfc\u81f4\u4e4b\u540e\u6240\u6709\u7684\u8fd4\u56de\u503c\u5f62\u6210\u5f88\u6df1\u5c42\u6b21\u7684\u5d4c\u5957**[2], 1, [[[[5]]]](2], 1, [[[[5]]].md)**
\u6700\u597d\u5728\u6bcf\u4e00\u5c42\u7ea7\u90fd\u201c\u89e3\u538b\u201d**max(t)**
\u8fd9\u6837\u4e4b\u540e\u8fd4\u56de\u7684\u624d\u662f\u6570\u503c
- \u6b64\u5904\u7684\u7ec4\u4ef6\u5e76\u4e0d\u901a\u8fc7\u9012\u5f52\u5f62\u6210\u4e00\u4e2atree\uff0c\u53ea\u662f\u5355\u7eaftree\u7684component
- \u6ce8\u610f branches \u7684\u5199\u6cd5
## the first level for abstraction\n# constructor\n>>> def tree(root_label, branches=[]):\n for branch in branches:\n assert is_tree(branch), 'branches must be trees'\n return [root_label] + list(branches)\n# selector\n>>> def label(tree):\n return tree[0]\n>>> def branches(tree):\n return tree[1:]\n\n## the second\n>>> def is_tree(tree):\n if type(tree) != list or len(tree) < 1:\n return False\n for branch in branches(tree):\n if not is_tree(branch):\n return False\n return True\n>>> def is_leaf(tree):\n return not branches(tree)\n
- partition\u7684tree\u505a\u6cd5
"},{"location":"CodingLanguage/Python/CS61A/#excises-and-application","title":"Excises and Application","text":"def partition_tree(n, m):\n \"\"\"Return a partition tree of n using parts of up to m.\"\"\"\n if n == 0:\n return tree(True)\n elif n < 0 or m == 0:\n return tree(False)\n else:\n left = partition_tree(n-m, m)\n right = partition_tree(n, m-1)\n return tree(m, [left, right])\n# recursion tree in prefix order\ndef print_parts(tree, partition=[]):\n if is_leaf(tree):\n if label(tree):\n print(' + '.join(partition))\n else:\n left, right = branches(tree)\n m = str(label(tree))\n print_parts(left, partition + [m])\n print_parts(right, partition)\n
- Add Tree
- \u8003\u8651\u9012\u5f52\u7684
Basic case
\u548cRecursive case
- Hard : \u786e\u8ba4\u5bf9\u5e94\u4f4d\u7f6e
- Tip : using the
zip
functionzip(iterable1,iterable2,...):\n Returns a zip object, which is an iterator of tuples\n \u5982\u679c\u53c2\u6570\u957f\u5ea6\u4e0d\u4e00\uff0c\u53d6\u6700\u77ed\u7684\n>>> t2\n[1, [5, [6]], [9], [4, [8], [1]]], [99](1]]], [99.md){#618df381853bde2dd02159e20c7c676c}\n>>> t1 \n[1, [5, [6]], [8], [9]]\n>>> list(zip(t1,t2))\n[(1, 1), ([5, [6]], [5, [6]]), ([8], [9]), ([9], [4, [8], [1]](1].md))]\n
- \u5f62\u6210\u65b0\u7684Tree
- \u4ecd\u7136\u662f\u5bf9 rucursive \u7ed3\u6784\u8003\u8651\u4e0d\u662f\u5f88\u6e05\u695a.
tree : [1, [5], [6, [7]]]
,branches
\u4e2d\uff0c\u6bcf\u4e00\u4e2a\u5143\u7d20\u90fd\u4ee3\u8868\u4e00\u6574\u4e2a\u5206\u652fdef add_tree(t1,t2):\n '''Return the addition tree of the two trees t1 and t2.\n Adding up the corresponding value, and making a tree.\n IF one branch is onlt in one tree, then it will be in the new tree\n >>> numbers = tree(1,\n ... [tree(2,\n ... [tree(3),\n ... tree(4)]),\n ... tree(5,\n ... [tree(6,\n ... [tree(7)]),\n ... tree(8)])])\n >>> print_tree(add_trees(numbers, numbers))\n 2\n 4\n 6\n 8\n 10\n 12\n 14\n 16\n >>> print_tree(add_trees(tree(2), tree(3, [tree(4), tree(5)])))\n 5\n 4\n 5\n >>> print_tree(add_trees(tree(2, [tree(3)]), tree(2, [tree(3), tree(4)])))\n 4\n 6\n 4\n >>> print_tree(add_trees(tree(2, [tree(3, [tree(4), tree(5)])]), \\\n tree(2, [tree(3, [tree(4)]), tree(5)])))\n 4\n 6\n 8\n 5\n 5\n '''\n if is_leaf(t1) and is_leaf(t2): \n return tree(label(t1) + label(t2)) \n elif is_leaf(t1): \n return tree(label(t1) + label(t2), branches(t2)) \n elif is_leaf(t2): \n return tree(label(t1) + label(t2), branches(t1)) \n else: \n new_label = label(t1) + label(t2) \n new_branches = [add_trees(b1, b2) for b1, b2 in zip(branches(t1), branches(t2))] \n if len(branches(t1)) > len(branches(t2)): \n new_branches += branches(t1)[len(branches(t2)):] \n elif len(branches(t1)) < len(branches(t2)): \n new_branches += branches(t2)[len(branches(t1)):] \n return tree(new_label, new_branches)\n
-
"},{"location":"CodingLanguage/Python/CS61A/#linked-lists","title":"Linked Lists","text":"
- \u5b9a\u4e49\uff1a\u4e0e tree\u7c7b\u4f3c\uff0c[ element , new_linked]
[ 2, [3, [4, 'empty']]]
-
"},{"location":"CodingLanguage/Python/CS61A/#data-abstraction","title":"\u00b7 Data abstraction","text":""},{"location":"CodingLanguage/Python/CS61A/#abstraction-barrier","title":"Abstraction barrier","text":"four = [1,[2,[3,[4,'empty']]]]\n\n# constructor\nempty = 'empty'\n\ndef link(label , rest):\n if is_link(rest):\n return [label,rest]\n\ndef first(s):\n assert is_link(s), \"first only applies to linked lists.\"\n assert s != empty, \"empty linked list has no first element.\"\n return s[0]\n\ndef rest(s):\n assert is_link(s), \"first only applies to linked lists.\"\n assert s != empty, \"empty linked list has no rest.\"\n return s[1]\n\n# convenience\ndef is_link(s):\n return s == empty or (len(s) == 2 and is_link(s[1]))\n\ndef getitem_link(s,i):\n if i == 0:\n return first(s)\n else:\n return getitem_link( rest(s) ,i - 1)\n\ndef len_link(s):\n length = 0\n while s != empty:\n length += 1\n s = rest(s)\n return length\n\n## \n\n## application\n
"},{"location":"CodingLanguage/Python/CS61A/#dictionary","title":"Dictionary","text":"
- \u5bf9\u529f\u80fd\u8fdb\u884c\u4e0d\u540c\u7684\u5206\u5c42\uff0c\u5176\u5c42\u7ea7\u4e4b\u95f4\u5f62\u6210abstraction barrier
- \u8c03\u7528\u90e8\u5206\u529f\u80fd\u65f6\u4e0d\u8981\u4f7f\u7528\u8fc7\u4f4e\u5c42\u7ea7\uff0ceg\uff1aadd_rational( ) \u4e2d\uff0c\u4f7f\u7528 rational \u3001numer\u3001denom\u51fd\u6570\u4f5c\u4e3acomponent\u6784\u5efa\u76f8\u5173\u51fd\u6570
- \u5176\u76ee\u7684\u662f\u4e3a\u4e86\u5c3d\u53ef\u80fd\u51cf\u5c11\u4fee\u6539\u4ee3\u7801\u65f6\u7684\u5de5\u4f5c\u91cf\uff0c\u5373\u6240\u8c13 isolution
:::info Basic operation :::
**\u521b\u5efa\u65b9\u6cd5**
**dict**(_**kwargs_)
******dict**(mapping,_**kwargs_)
**dict**(iterable,_**kwargs_)
\u952e\u503c\u5bf9 {a:1,b:2}
\u63a8\u5bfc\u5f0f {x: x ** 2 for x in range(10)}
\u7c7b\u578b\u6784\u9020\u5668 dict([(a,1),(b,2)])
**methods**
**\u5b57\u5178\u89c6\u56fe\u5bf9\u8c61**
\u52a8\u6001\u53d8\u5316\uff0c\u4e0d\u662f iterator \u4f46\u53ef\u4ee5\u901a\u8fc7\u51fd\u6570\u4ea7\u751fiter(dictview)
**keys()**
**items()**
**values()**
**popitem**()
**pop()**
\u8fed\u4ee3\u65b9\u6cd5\uff1a
- \u5229\u7528
dic.items
\u4ea7\u751f\u4e00\u4e2a\u952e\u503c\u5bf9\u7684 listfor i,j in dic.items()
2.key -> value\ndic = {'I':1,'A'\uff1a2,5:a} # \u6b64\u5904\u7684a\u4e3a\u5df2\u8d4b\u503c\u7684\u53d8\u91cf\uff0c\u6216\u8005'a'\u4ee3\u8868\u53d8\u91cf\n>>> dic['I'] == 1\n>>> dic.values()\n>>> dic.key()\n>>> items = dic.items()\n>>> dict(items)\n>>> dic.get('X',0) # get \u6253\u5370value ornot print 0\n
:::info Dictionary comprehension and limitation :::
"},{"location":"CodingLanguage/Python/CS61A/#mutable-data","title":"\u00b7 Mutable Data","text":">>> {x:x*x for x in range(10}\n\u00b7 key \u4e0d\u80fd\u91cd\u590d\n\u00b7 key \u4e0d\u80fd\u662f\u53ef\u53d8\u5316\u7684\u503c/list/sequence\n
- Mutable Data \u7528\u4e8e\u8868\u793a\u52a8\u6001\u53d8\u5316\u7684\u503c
- py\u5185\u7f6e\u7684numbers\u3001string\u3001tuple\u4e0d\u80fd\u53d8\u5316\uff0csequence\u53ef\u4ee5
- default argument value is part of a function value
"},{"location":"CodingLanguage/Python/CS61A/#object","title":"Object","text":"def f(s = []):\n s.append(5)\n return len(s)\n>>> f()\n1\n>>> f()\n2\n
- Objects are both information and processes (bundling information and behavior together)
- Objects have attributes,we use dot to represent
.\u8fd9\u91cc\u7684name\u76f8\u5f53\u4e8e object \u7684\u4e00\u79cd\u5c5e\u6027\uff0c\u53ea\u5728 . \u540e\u6709\u7528
"},{"location":"CodingLanguage/Python/CS61A/#sequence-object","title":"Sequence Object","text":"
- method \u76f8\u5f53\u4e8efunction-valued attribute
- In python, all values are objects
# operation on data \n# share and identity\n''' = \u5e76\u6ca1\u6709\u521b\u5efa\u65b0\u7684object \u6545\u800c suits \u4e0e chinese \u6307\u5411\u76f8\u540c\u7684object'''\nchinese = ['coin', 'string', 'myriad'] # A list literal\nsuits = chinese # Two names refer to the same list\n\n## \u79fb\u9664\nsuits.pop() # Remove and return the final element\nsuits.remove('string') # Remove the first element that equals the argument\n\n## \u589e\u6dfb\nsuits.append('cup') # Add an element to the end\nsuits.extend(['sword', 'club']) # Add all elements of a sequence to the end\n\n## \u66f4\u6539 mutable\nsuits[2] = 'spade' # Replace an element\nsuits[0:2] = ['heart', 'diamond'] # Replace a slice\n\n### slicing \u5207\u7247\u65f6\u4e0d\u662fmutable\u7684\na = suits[0:2]\n\n## \u590d\u5236 \n'\u4f7f\u7528constructor\uff1alist\u521b\u5efa\u4e00\u4e2a\u526f\u672c\u5373\u4e00\u4e2a\u65b0\u53d8\u91cf'\nnested = list(suits)\nnested[0] = suits # \u6307\u5411suits\u5217\u8868\n\n## check\n'identity is much stronger than equality'\n'\u4f7f\u7528 is \u6216\u8005 is not \u5224\u65ad\u6307\u5411\u7684\u662f\u5426\u4e3a\u540c\u4e00\u5bf9\u8c61'\n>>> suits is nested[0]\nTrue\n
# comprehension\n\n'\u521b\u5efa\u65b0\u7684list'\n## slicing\nsuits[1:]\n\n## complicated examples\n'\u5f15\u7528\u81ea\u8eab\u7684list'\n>>> t = [1,2,3]\n>>> t[1:3] = [t]\n[1,[...]]\n'\u8fd9\u91cc\u7684[...]\u5c31\u662f\u8fd9\u4e2a list \u672c\u8eab '\n>>>t.extend(t)\n[1,[...],1,[...]]\n>>> t[1]\n[1,[...],1,[...]]\n\n>>> t = [1,2],[3,4](1,2],[3,4.md){#b62caabac6f0b056c943105b6c99d2aa}\n>>> t[0].append(t[1:2]) # t[1:2] -> [3,4](3,4.md){#3217f0200a9316574561e220f77a82c2}\n[1,2,[[3,4]],[3,4](1,2,[[3,4]],[3,4.md){#cfc817a5247d573d544970abfc9d61ff}\n
\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff1a\u4ee5 list \u4f5c\u4e3a\u5143\u7d20\u65f6\uff0c\u662f\u4ee5\u5360\u4f4d\u7b26\u5f62\u5f0f\u5c55\u73b0\u7684
"},{"location":"CodingLanguage/Python/CS61A/#tuples","title":"Tuples","text":"a = [0,1,2,3,4,[5,6]]\nb = a\nc = b[:]\n\nprint(c is b)\nprint(c[5] is b[5])\n
- \u5143\u7ec4 \u5177\u6709\u7c7b\u4f3clist\u7684\u64cd\u4f5c\uff0c\u4f46\u662f\u5143\u7ec4\u672c\u8eab\u4e0d\u53ef\u4ee5\u76f4\u63a5\u6539\u53d8\uff08unmutable\uff09
- \u53ef\u4ee5\u5305\u62ec\u4efb\u4f55\u7c7b\u578b\u7684\u5bf9\u8c61
- \u53ef\u4ee5\u5bf9\u5bf9\u8c61\u8fdb\u884c\u6539\u53d8\uff08mutable data\uff09
- \u521b\u5efa\uff0c\u4f7f\u7528 \uff0c \uff08 \uff09
"},{"location":"CodingLanguage/Python/CS61A/#dictionary-object","title":"Dictionary Object","text":">>> 1, 2 + 3\n(1, 5)\n>>> (\"the\", 1, (\"and\", \"only\"))\n('the', 1, ('and', 'only'))\n>>> type( (10, 20) )\n<class 'tuple'>\n\n>>> () # 0 elements\n()\n>>> (10,) # 1 element\n(10,)\n
Dictionaries do have some restrictions:
- A key of a dictionary cannot be or contain a mutable value.
- There can be at most one value for a given key.
"},{"location":"CodingLanguage/Python/CS61A/#string","title":"String","text":"# \n##\n'\u666e\u901a\u7684\u6539\u53d8\u6216\u8005\u589e\u52a0\u53ef\u4ee5\u901a\u8fc7\u8d4b\u503c\u8bed\u53e5\u5b9e\u73b0'\n\n## methods\uff1akeys, values, and items all return iterable values.\n>>> sum(dic.values())\n\n'\u901a\u8fc7\u952e\u503c\u5bf9\u521b\u5efadict'\n>>> dict([(3, 9), (4, 16), (5, 25)])\n{3: 9, 4: 16, 5: 25}\n\n## methods\n'get: \u5982\u679c\u6ca1\u6709\u8be5\u952e\u503c\u5bf9\uff0c\u8fd4\u56de 0 '\n>>> numerals.get('V', 0)\n5\n
- Unicode,ASCII,UTF-8\u7684\u533a\u522b-\u817e\u8baf\u4e91\u5f00\u53d1\u8005\u793e\u533a-\u817e\u8baf\u4e91 :::info ASCII : \u4e00\u4e2a\u5b57\u8282 \u82f1\u6587\u7f16\u7801 Unicode :\u4e24\u4e2a\u5b57\u8282 \u6240\u6709\u7f16\u7801\u7edf\u4e00 UTF - 8 :\u81ea\u52a8\u51b3\u5b9a\u5b57\u8282\u6570
TIP :
"},{"location":"CodingLanguage/Python/CS61A/#local-state","title":"Local State","text":"
- \u5185\u5b58\u7edf\u4e00\u4f7f\u7528 unicode \u7f16\u7801 :::
- nonlocal statement \u5fc5\u987b\u4f7f\u7528\u5728\u5df2\u7ecf\u8d4b\u503c\u540e\u7684\u53d8\u91cf\u524d[ in nonlocal frame ]
no binging for nonlocal '' found
- \u4e00\u4e2a\u53d8\u91cf\u4e0d\u80fd\u5148\u8bbf\u95ee
non-local frame
\u4e4b\u540e\u518d\u5728local frame
\u4e2d\u8d4b\u503c
name '' is parameter and nonlocal
- \u7ed1\u5b9a\u7684\u662f\u7b2c\u4e00\u4e2a
non-local frame
\u4e2d\u7684name \u3010enclosing scope\u3011- \u3010referential transparency\u3011expression -> \u7528\u8868\u8fbe\u5f0f\u7684\u503c\u66ff\u6362\u8868\u8fbe\u5f0f\u4e4b\u540e\u4e0d\u5f71\u54cd\u6574\u4e2a program
\u3010violate ...\u3011mutable operation
- Instances\uff1a
"},{"location":"CodingLanguage/Python/CS61A/#implementing-on-list","title":"Implementing on List","text":"def make_withdraw(balance):\n def withdraw(amount):\n nonlocal balance\n if amount > balance:\n return 'Insufficient funds'\n balance = balance - amount\n return balance\n return withdraw\n
This part is going to introduce one way to creat mutable data structure by mutable function
"},{"location":"CodingLanguage/Python/CS61A/#-dispatch-function-the-message-determines-the-behavior-of-the-function","title":"- Dispatch Function : the message determines the behavior of the function","text":""},{"location":"CodingLanguage/Python/CS61A/#object-oriented-programming","title":"\u00b7 Object-Oriented Programming","text":""},{"location":"CodingLanguage/Python/CS61A/#implementing-classes-and-objects","title":"\u00b7 Implementing Classes and Objects","text":""},{"location":"CodingLanguage/Python/CS61A/#object-abstraction","title":"\u00b7 Object Abstraction","text":""},{"location":"CodingLanguage/Python/CS61A/#objects-and-classes","title":"Objects And Classes","text":""},{"location":"CodingLanguage/Python/CS61A/#creating-a-class","title":"Creating a class","text":"
instance attribute
/fileds
/instance variables
/properties
methods
: functions that operate on the object or perform object-specific computations are called methodsattribute
/class variables
/static variables
\uff1adifined without the range of methods. It is shared by all the class and among all instances definedinstance attribute
specific attributes for one instance**\u533a\u5206**
\u5bf9\u4e8e instance \uff0cobject
\u8bbf\u95ee\u5bf9\u8c61\u65f6\u4f18\u5148\u8bbf\u95eeinstance attr
\uff0c\u672a\u5bfb\u627e\u5230\u624d\u8bbf\u95eeclass attribute
\u4e5f\u5c31\u662f\u8bf4\uff0c\u53ef\u4ee5\u5b58\u5728\u4e00\u4e2aattr
\u53ea\u5b58\u5728\u4e8e\u67d0\u4e2a\u7279\u5b9a\u5b9e\u4f8b\u800c\u4e0d\u5b58\u5728\u4e8eclass
class Account:\n# definitiate a new method\n def __init__(self, account_holder):\n# self is bound to the newly defined class\n self.balance = 0\n self.holder = account_holder\n def deposit(self, amount):\n self.balance = self.balance + amount\n return self.balance\n def withdraw(self, amount):\n if amount > self.balance:\n return 'Insufficient funds'\n self.balance = self.balance - amount\n return self.balance\n\na = Account('Kirk')\n# \u4e24\u79cd\u4e0d\u540c\u8c03\u7528 function \u548c method \u7684\u65b9\u6cd5\n'\u6839\u636eclass \u548c instance \u7684\u4e0d\u540c\uff0c\u8fd4\u56de\u503c\u4e5f\u4e0d\u540c'\n>>> Account.deposit(spock_account, 1001) # The deposit function takes 2 arguments\n1011\n>>> spock_account.deposit(1000) # The deposit method takes 1 argument\n2011\n
getattr(instance,attr)\n'Return the value of calling it which is identical to the dot expression'\n# the attr must be a string\ngetattr(a,'balance')\n\nhasattr(instance,attr)\n'''return True or False'''\n
"},{"location":"CodingLanguage/Python/CS61A/#inheritance","title":"Inheritance","text":"
- As an attribute of a class, a method is just a function, but as an attribute of an instance, it is a bound method. \u533a\u522b\uff1a\u5f53
method
\u88ab\u8c03\u7528\u65f6\uff0cself \u5c06\u81ea\u52a8\u7ed1\u5b9a\u8fd9\u4e2aobject
- Python's convention\uff1a dictates that if an attribute name starts with an underscore, it should only be accessed within methods of the class itself, rather than by users of the class.
is-a
\u7c7b\u7ee7\u627fhas-a
\u805a\u5408- \u4ece\u7236\u7c7b\u7ee7\u627f\u6240\u6709attr\uff0c\u4f46\u662f\u53ef\u4ee5override
"},{"location":"CodingLanguage/Python/CS61A/#multiple-inheritance","title":"Multiple Inheritance","text":">>> class CheckingAccount(Account):\n \"\"\"A bank account that charges for withdrawals.\"\"\"\n withdraw_charge = 1\n interest = 0.01\n def withdraw(self, amount):\n return Account.withdraw(self, amount + self.withdraw_charge)\n
- For non-ambigious case, it works nuturally.
- For ambigious case, for example, both the two have one same name, then the order matters
"},{"location":"CodingLanguage/Python/CS61A/#efficiency","title":"\u00b7 Efficiency","text":""},{"location":"CodingLanguage/Python/CS61A/#recursive-objects","title":"\u00b7 Recursive Objects","text":""},{"location":"CodingLanguage/Python/CS61A/#chapter-4-data-processing","title":"Chapter 4 : Data Processing","text":""},{"location":"CodingLanguage/Python/CS61A/#implicit-sequence","title":"Implicit Sequence","text":""},{"location":"CodingLanguage/Python/CS61A/#iterator","title":"Iterator","text":"class SavingsAccount(Account):\n deposit_charge = 2\n def deposit(self, amount):\n return Account.deposit(self, amount - self.deposit_charge)\nclass AsSeenOnTVAccount(CheckingAccount, SavingsAccount):\n def __init__(self, account_holder):\n self.holder = account_holder\n self.balance = 1 # A free dollar!\n\n# one way to find out the order of inheritance\n>>> [c.__name__ for c in AsSeenOnTVAccount.mro()]\n['AsSeenOnTVAccount', 'CheckingAccount', 'SavingsAccount', 'Account', 'object']\n
- components
- a mechanism for retrieving the next element in the sequence being processed and
- a mechanism for signaling that the endof the sequence has been reached no further elements remain
- Calling
**iter**
on an iterator will return that iterator, not a copy"},{"location":"CodingLanguage/Python/CS61A/#build-in-iterator","title":"Build-in Iterator","text":">>> next(iterator)\n7\n>>> next(iterator)\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nStopIteration\n>>> try:\n next(iterator)\n except StopIteration:\n print('No more values')\nNo more values\n
- Taking an iterator and return an iterator
lazy processing
\u8c03\u7528iterator function \u4e0d\u4f1a\u76f4\u63a5\u8ba1\u7b97\u7ed3\u679c\uff0c\u8fd4\u56de\u4e00\u4e2aiterator\uff0c\u53ea\u6709\u5f53\u4f7f\u7528\u67d0\u4e2a\u6570\u503c\u65f6\u624d\u4f1a\u53d1\u751f\u8ba1\u7b97. \u5982\uff1a\u4e0b\u4f8b\u4e2d\uff0c\u82e5\u4e4b\u540e\u518d\u6b21\u8c03\u7528doubled
\u76f8\u5173\uff0c\u5c06\u4f1a\u51fa\u9519\uff0c\u56e0\u4e3a\u8fd9\u4e2aiterator
\u5df2\u7ecf\u5230\u8fbe\u5c3d\u5934>>> def double_and_print(x):\n print('***', x, '=>', 2*x, '***')\n return 2*x\n>>> s = range(3, 7)\n>>> doubled = map(double_and_print, s) # double_and_print not yet called\n>>> next(doubled) # double_and_print called once\n*** 3 => 6 ***\n6\n>>> next(doubled) # double_and_print called again\n*** 4 => 8 ***\n8\n>>> list(doubled) # double_and_print called twice more\n*** 5 => 10 ***\n*** 6 => 12 ***\n[10, 12]\n
"},{"location":"CodingLanguage/Python/CS61A/#iterables","title":"Iterables","text":"
zip
map
reversed
"},{"location":"CodingLanguage/Python/CS61A/#generator","title":"Generator","text":"
- Any value that can produce iterators is called an
_**iterable**_** value**
.- \u5bf9\u4e8e\u4e00\u4e9b\u672c\u8eab\u65e0\u5e8f\u7684\u7ed3\u6784\uff0c\u5982\u5b57\u5178\u548c\u96c6\u5408\uff0cPython \u5c06\u4f1a\u5185\u7f6e\u4e00\u4e2a\u987a\u5e8f\uff0c\u4f7f\u5f97
iter``next
\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c- \u4f46\u5982\u679c\u6539\u52a8\u6216\u5220\u9664\u4e86
key
\uff0c\u5c06\u4f1a\u51fa\u73b0\u65b0\u987a\u5e8f\uff0c\u4e4b\u524d\u4ea7\u751f\u7684iter
\u5931\u6548- \u5728\u9ad8\u7248\u672cpy\u4e2d\u5b57\u5178\u5df2\u7ecf\u6709\u4e86\u987a\u5e8f
- is one type of special iterator
- returned by a special class of function called a generator function.
- \u6bcf\u6b21\u8c03\u7528\u76f4\u5230\u5230\u8fbe
yield
\u65f6return
\u4e00\u4e2agenerator
\uff0c\u5e76\u8bb0\u5f55\u6b64\u6b21\u8fd0\u884c\u7684 name \u548c value\uff0c\u4e0b\u4e00\u6b21\u4ece\u6b64\u6b21\u7ed3\u675f\u5904\u91cd\u590d\u64cd\u4f5c>>> def letters_generator():\n current = 'a'\n while current <= 'd':\n yield current\n current = chr(ord(current)+1)\n>>> for letter in letters_generator():\n print(letter)\na\nb\nc\nd\n
- \u4ea7\u751f\u53ef\u91cd\u590d\u4f7f\u7528\u7684 iterable \uff08Creating Iterables with Yield\uff09
"},{"location":"CodingLanguage/Python/CS61A/#library","title":"Library","text":""},{"location":"CodingLanguage/Python/CS61A/#standard-library","title":"Standard Library","text":""},{"location":"CodingLanguage/Python/CS61A/#q-a","title":"Q & A","text":""},{"location":"CodingLanguage/Python/CS61A/#_10","title":"\u6d6e\u70b9\u6570\u95ee\u9898","text":"class LettersWithYield:\n def __init__(self, start='a', end='e'):\n self.start = start\n self.end = end\n def __iter__(self):\n next_letter = self.start\n while next_letter < self.end:\n yield next_letter\n next_letter = chr(ord(next_letter)+1)\n\n\nclass LetterIter:\n \"\"\"An iterator over letters of the alphabet in ASCII order.\"\"\"\n def __init__(self, start='a', end='e'):\n self.next_letter = start\n self.end = end\n def __next__(self):\n if self.next_letter == self.end:\n raise StopIteration\n letter = self.next_letter\n self.next_letter = chr(ord(letter)+1)\n return letter\n
- \u4fdd\u7559\u4f4d\u6570
\u4f7f\u7528 round \u51fd\u6570 \u56db\u820d\u4e94\u5165\u7c7b\u578b\u7684\u51fd\u6570 \u5982\u679c\u6709 0 \u5b58\u5728\u81ea\u52a8\u820d\u53bb\u591a\u4f59\u76840
>>> round( 4.000 , 2 )\n4.0\n>>> round(4,2)\n4\n>>> round(float(4),2)\n4.0\n
-
"},{"location":"CodingLanguage/Python/CS61A/#_11","title":"\u5176\u4ed6\u5e38\u7528\u51fd\u6570\u7684\u7ec6\u8282","text":"
- max & min
# \u539f\u578b\nmax(iterable, *, default, key=None)\n''' \u8fd4\u56de\u7b2c\u4e00\u4e2a\u627e\u5230\u7684max\u503c\n iterable\u4e3a\u7a7a\u65f6\u8fd4\u56dedefault\n key\u4e3a\u6307\u5b9a\u7684 \u5b9e\u9645\u4f20\u5165list.sort()\u7684\u53c2\u6570\n'''\n\n# \u5e94\u7528 \n '''\u6309\u5b57\u5178\u987a\u5e8f\u6bd4\u8f83'''\n ## \u6bd4\u8f83\u5b57\u7b26\u4e32 \n>>> max('1', '9', '10', '100') # \u8fd4\u56de\u591a\u4e2a\u5b57\u7b26\u4e32\u4e2d\u6700\u5927\u7684\u5b57\u7b26\u4e32\n'9'\n>>> max('asdxyz')\n'z'\n ## \u6bd4\u8f83\u5217\u8868\n>>> min(['8',4],['8',4,'2']) # \u8fd4\u56de\u591a\u4e2a\u5217\u8868\u4e2d\u6700\u5c0f\u7684\u5217\u8868\n['8', 4]\n>>> min(('8',4, '3'),('8',4,'2')) # \u8fd4\u56de\u591a\u4e2a\u5143\u7ec4\u4e2d\u6700\u5c0f\u7684\u5143\u7ec4\n('8', 4, '2')\n ## \u6bd4\u8f83\u5b57\u5178 \u6ce8\u610f \u8fd4\u56de\u503c\u4e3a \u952e\n>>> d = {'x':5, 'y':7, 'z':3}\n>>> min(d) # \u8fd4\u56de\u5b57\u5178\u5143\u7d20\u4e2d\u7684\u6700\u5c0f\u503c\uff0c\u7ed3\u679c\u662f\u6700\u5c0f\u7684\u952e\n'x'\n>>> min(d , key = lambda x:d[x])\n'z'\n
"},{"location":"CodingLanguage/Python/CS61A/#_12","title":"\u4e00\u4e9b\u601d\u8003\u65b9\u5f0f","text":"
- print\u51fd\u6570
"},{"location":"CodingLanguage/Python/basic/","title":"Basic and Warning","text":"
- \u5206cases\u8003\u8651\u9012\u5f52\u95ee\u9898 tree\u7684\u60f3\u6cd5
\u7ea6 479 \u4e2a\u5b57 89 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 4 \u5206\u949f
info
\u8fd9\u91cc\u4e00\u65b9\u9762\u653e\u4e00\u4e9b\u81ea\u5df1\u91cd\u65b0\u770bpy\u8bed\u6cd5\u65f6\u4e00\u4e9b\u57fa\u7840\u7684\u77e5\u8bc6\uff0c\u53e6\u4e00\u65b9\u9762\u653e\u4e00\u4e9b\u5b9e\u8df5\u8fc7\u7a0b\u4e2d\u9047\u5230\u7684\u5751\u6216\u8005\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9
"},{"location":"CodingLanguage/Python/basic/#some","title":"Some","text":""},{"location":"CodingLanguage/Python/basic/#string","title":"\u5173\u4e8estring","text":"
- \u4ee5\u4e0b\u5212\u7ebf\u5f00\u5934\u7684\u6807\u8bc6\u7b26\u662f\u6709\u7279\u6b8a\u610f\u4e49\u7684\u3002\u4ee5\u5355\u4e0b\u5212\u7ebf\u5f00\u5934 _foo \u7684\u4ee3\u8868\u4e0d\u80fd\u76f4\u63a5\u8bbf\u95ee\u7684\u7c7b\u5c5e\u6027\uff0c\u9700\u901a\u8fc7\u7c7b\u63d0\u4f9b\u7684\u63a5\u53e3\u8fdb\u884c\u8bbf\u95ee\uff0c\u4e0d\u80fd\u7528 from xxx import * \u800c\u5bfc\u5165\u3002
- \u4ee5\u53cc\u4e0b\u5212\u7ebf\u5f00\u5934\u7684 foo \u4ee3\u8868\u7c7b\u7684\u79c1\u6709\u6210\u5458\uff0c\u4ee5\u53cc\u4e0b\u5212\u7ebf\u5f00\u5934\u548c\u7ed3\u5c3e\u7684 __foo \u4ee3\u8868 Python \u91cc\u7279\u6b8a\u65b9\u6cd5\u4e13\u7528\u7684\u6807\u8bc6\uff0c\u5982 init() \u4ee3\u8868\u7c7b\u7684\u6784\u9020\u51fd\u6570\u3002
"},{"location":"CodingLanguage/Python/basic/#_1","title":"\u5305\u4e0e\u6a21\u5757","text":""},{"location":"CodingLanguage/Python/basic/#_2","title":"\u6a21\u5757\u8c03\u7528","text":"s = '\u5b66\u4e60Python'\n# \u5207\u7247\ns[0], s[-1], s[3:], s[::-1] # '\u4f18', 'n', 'ython', 'nohtyP\u7684\u4e60\u5b66'\n# \u66ff\u6362\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u66ff\u6362\ns.replace('Python', 'Java') # '\u5b66\u4e60Java'\n# \u67e5\u627e\uff0cfind()\u3001index()\u3001rfind()\u3001rindex()\ns.find('P') # 3, \u8fd4\u56de\u7b2c\u4e00\u6b21\u51fa\u73b0\u7684\u5b50\u4e32\u7684\u4e0b\u6807\ns.find('h', 2) # 6, \u8bbe\u5b9a\u4e0b\u68072\u5f00\u59cb\u67e5\u627e\ns.find('23333') # -1, \u67e5\u627e\u4e0d\u5230\u8fd4\u56de-1\ns.index('y') # 4, \u8fd4\u56de\u7b2c\u4e00\u6b21\u51fa\u73b0\u7684\u5b50\u4e32\u7684\u4e0b\u6807\ns.index('P') # \u4e0d\u540c\u4e0efind(), \u67e5\u627e\u4e0d\u5230\u4f1a\u629b\u51fa\u5f02\u5e38\n# \u8f6c\u5927\u5c0f\u5199, upper()\u3001lower()\u3001swapcase()\u3001capitalize()\u3001istitle()\u3001isupper()\u3001islower()\ns.upper() # '\u5b66\u4e60PYTHON'\ns.swapcase() # '\u5b66\u4e60pYTHON', \u5927\u5c0f\u5199\u4e92\u6362\ns.istitle() # True\ns.islower() # False\n# \u53bb\u7a7a\u683c,strip()\u3001lstrip()\u3001rstrip()\n# \u683c\u5f0f\u5316\ns1 = '%s %s' % ('Windrivder', 21) # 'Windrivder 21'\ns2 = '{}, {}'.format(21, 'Windridver') # \u63a8\u8350\u4f7f\u7528format\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\ns3 = '{0}, {1}, {0}'.format('Windrivder', 21)\ns4 = '{name}: {age}'.format(age=21, name='Windrivder')\n# \u8fde\u63a5\u4e0e\u5206\u5272\uff0c\u4f7f\u7528 + \u8fde\u63a5\u5b57\u7b26\u4e32\uff0c\u6bcf\u6b21\u64cd\u4f5c\u4f1a\u91cd\u65b0\u8ba1\u7b97\u3001\u5f00\u8f9f\u3001\u91ca\u653e\u5185\u5b58\uff0c\u6548\u7387\u5f88\u4f4e\uff0c\u6240\u4ee5\u63a8\u8350\u4f7f\u7528join\nl = ['2017', '03', '29', '22:00']\ns5 = '-'.join(l) # '2017-03-29-22:00'\ns6 = s5.split('-') # ['2017', '03', '29', '22:00']\n
import
\u4fdd\u5b58\u539f\u6709\u7684module\u547d\u540d\u7a7a\u95f4"},{"location":"CodingLanguage/Python/basic/#_3","title":"\u5305","text":"
from module import func
\u628afunnc
\u5bfc\u5165\u5230\u5f53\u524d\u7684\u547d\u540d\u7a7a\u95f4\u5e38\u89c1\u7684\u5305\u7ed3\u6784\u5982\u4e0b\uff1a
pakageName\n-------__init__.py\n-------moduleName1.py\n-------moduleName2.py\n------- ...\n
\u5305\u8def\u5f84\u4e0b\u5fc5\u987b\u5b58\u5728
__init__.py
\u6587\u4ef6\u3002\u5173\u4e8e import
from blog
init .py\u6587\u4ef6 \u7528\u4e8e\u7ec4\u7ec7\u5305\uff08package\uff09\uff0c\u65b9\u4fbf\u7ba1\u7406\u5404\u4e2a\u6a21\u5757\u4e4b\u95f4\u7684\u5f15\u7528\u3001\u63a7\u5236\u7740\u5305\u7684\u5bfc\u5165\u884c\u4e3a\u3002 \u8be5\u6587\u4ef6\u53ef\u4ee5\u4ec0\u4e48\u5185\u5bb9\u90fd\u4e0d\u5199\uff0c\u5373\u4e3a\u7a7a\u6587\u4ef6\uff08\u4e3a\u7a7a\u65f6\uff0c\u4ec5\u4ec5\u7528import [\u8be5\u5305]\u5f62\u5f0f \u662f\u4ec0\u4e48\u4e5f\u505a\u4e0d\u4e86\u7684\uff09\uff0c\u5b58\u5728\u5373\u53ef\uff0c\u76f8\u5f53\u4e8e\u4e00\u4e2a\u6807\u8bb0\u3002
\u5f53\u6211\u4eec\u5728\u5bfc\u5165\u4e00\u4e2a\u5305\uff08package\uff09\u65f6\uff08\u4f1a\u5148\u52a0\u8f7d init .py\u5b9a\u4e49\u7684\u5f15\u5165\u6a21\u5757\uff0c\u7136\u540e\u518d\u8fd0\u884c\u5176\u4ed6\u4ee3\u7801\uff09\uff0c\u5b9e\u9645\u4e0a\u662f\u5bfc\u5165\u7684\u5b83\u7684 init .py\u6587\u4ef6\uff08\u5bfc\u5165\u65f6\uff0c\u8be5\u6587\u4ef6\u81ea\u52a8\u8fd0\u884c\uff0c\u52a9\u6211\u4eec\u4e00\u4e0b\u5bfc\u5165\u8be5\u5305\u4e2d\u7684\u591a\u4e2a\u6a21\u5757\uff09\u3002\u6211\u4eec\u53ef\u4ee5\u5728 init .py\u4e2d\u518d\u5bfc\u5165\u5176\u4ed6\u7684\u5305\uff08package\uff09\u6216\u6a21\u5757 \u6216\u81ea\u5b9a\u4e49\u7c7b\u3002
"},{"location":"CodingLanguage/Python/basic/#_4","title":"\u5143\u7d20\u7c7b\u578b","text":""},{"location":"CodingLanguage/Python/basic/#list","title":"list","text":"
append
extend
# \u5b9a\u4e49\u4e00\u4e2alist\nname = list('Pyther')\n\n# \u6539\u53d8 list \u4e2d\u7684\u6700\u540e\u4e24\u4e2a\u503c\nname[4:]='on'\nname\n['P', 'y', 't', 'h', 'o', 'n']\n
\u6784\u9020\u4e00\u4e2alist
"},{"location":"CodingLanguage/Python/basic/#tuple","title":"tuple","text":"even_squares = [x**2 for x in range(1, 11) if x % 2 == 0]\n
"},{"location":"CodingLanguage/Python/basic/#dict","title":"dict","text":"a = (1,2,3)\n
"},{"location":"CodingLanguage/Python/basic/#set","title":"set","text":"a = {1:a,}\n\n# method\ndict.get(val,default = None)\n# \u67e5\u627e\nif key in dict\ndict.setdefault() # \u672a\u627e\u5230\u5219\u63d2\u5165\n\ndict.items( ) \n
\u57fa\u672c\u7528\u6cd5
"},{"location":"CodingLanguage/Python/basic/#function","title":"function","text":""},{"location":"CodingLanguage/Python/basic/#_5","title":"\u9ed8\u8ba4\u53c2\u6570","text":"a = {'a','b','c'}\n# \u7a7a\u5b57\u5178\na = {}\n# \u7a7aset\na = set()\n#\na.update(iterable) # dict \u6dfb\u52a0\u7684\u662f\u952e\u503c\n>>> a\n>>> {1, 2, 3, 4, 6, 45, 23, 56}\n>>> a.update({1:2,'a':5})\n>>> a\n>>> {1, 2, 3, 4, 6, 45, 23, 56, 'a'}\na.add()\n#\na.remove()\na.discard() # nonexsitence won`t throw error\n# \u4ea4\u96c6\nset.intersection(set1, set2 ... etc)\n\n**\u53c2\u6570\uff1a**\nset1 -- \u5fc5\u9700\uff0c\u8981\u67e5\u627e\u76f8\u540c\u5143\u7d20\u7684\u96c6\u5408\nset2 -- \u53ef\u9009\uff0c\u5176\u4ed6\u8981\u67e5\u627e\u76f8\u540c\u5143\u7d20\u7684\u96c6\u5408\uff0c\u53ef\u4ee5\u591a\u4e2a\uff0c\u591a\u4e2a\u4f7f\u7528\u9017\u53f7 , \u9694\u5f00\n
Warning!
\u9ed8\u8ba4\u503c\u53ea\u8ba1\u7b97\u4e00\u6b21\u3002\u9ed8\u8ba4\u503c\u4e3a\u5217\u8868\u3001\u5b57\u5178\u6216\u7c7b\u5b9e\u4f8b\u7b49\u53ef\u53d8\u5bf9\u8c61\u65f6\uff0c\u4f1a\u4ea7\u751f\u4e0e\u4e0d\u540c\u7684\u7ed3\u679c\u3002
"},{"location":"CodingLanguage/Python/basic/#lambda","title":"lambda","text":"def f(a, L=[]):\n L.append(a)\n return L\ndef f(a, L=None):\n if L is None:\n L = []\n L.append(a)\n return L\n\nprint(f(1))\nprint(f(2))\nprint(f(3))\n
"},{"location":"CodingLanguage/Python/basic/#class","title":"class","text":""},{"location":"CodingLanguage/Python/basic/#method","title":"method","text":""},{"location":"CodingLanguage/Python/basic/#method_1","title":"\u5b9e\u4f8bmethod","text":""},{"location":"CodingLanguage/Python/basic/#method_2","title":"\u9759\u6001method","text":""},{"location":"CodingLanguage/Python/basic/#method_3","title":"\u7c7bmethod","text":""},{"location":"CodingLanguage/Python/%E7%88%AC%E8%99%AB/","title":"\u722c\u866b","text":"pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]\npairs.sort(key=lambda pair: pair[1])\npairs\n[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]\n
\u7ea6 2 \u4e2a\u5b57
abstract
"},{"location":"CodingLanguage/Python/library/numpy/","title":"numpy","text":"\u7ea6 5 \u4e2a\u5b57 14 \u884c\u4ee3\u7801
"},{"location":"CodingLanguage/Python/library/numpy/#array","title":"array","text":"\u521d\u59cb\u5316
"},{"location":"Tools/","title":"Index","text":"import numpy as np\n\n# \u521b\u5efa\u4e00\u4e2a\u5305\u542b\u7279\u5b9a\u6570\u76ee\u5143\u7d20\u7684\u6570\u7ec4\narr = np.array([1, 2, 3, 4, 5])\nprint(arr)\n\n# \u521b\u5efa\u4e00\u4e2a\u6307\u5b9a\u6570\u76ee\u7684\u6570\u7ec4\uff0c\u6240\u6709\u5143\u7d20\u521d\u59cb\u5316\u4e3a0\narr_zeros = np.array([0] * 5)\nprint(arr_zeros)\n\n# \u521b\u5efa\u4e00\u4e2a\u6307\u5b9a\u6570\u76ee\u7684\u6570\u7ec4\uff0c\u6240\u6709\u5143\u7d20\u521d\u59cb\u5316\u4e3a1\narr_ones = np.array([1] * 5)\nprint(arr_ones)\n
\u7ea6 75 \u4e2a\u5b57
\u6982\u8ff0
\u8fd9\u91cc\u653e\u4e00\u4e9b\u81ea\u5df1\u5728CS\u5b66\u4e60\u8fc7\u7a0b\u4e2d\u7528\u5230\u7684\u4e00\u4e9b\u5de5\u5177\u4ee5\u53ca\u5b66\u4e60\u8fd9\u4e9b\u5de5\u5177\u7684\u8d44\u6e90\u7d22\u5f15\u3002
\u540d\u79f0 \u8d44\u6e90 CMake \u5b98\u65b9\u6559\u7a0b GNUMake \u8d44\u6599: makefile \u4ecb\u7ecd \u2014 \u8ddf\u6211\u4e00\u8d77\u5199 Makefile 1.0 \u6587\u6863 \u89c6\u9891: \u4e00\u4e2a\u8f83\u7b80\u5355\u7684\u5165\u95e8 git \u5ed6\u96ea\u5cf0Git\u5165\u95e8Progit Shell"},{"location":"Tools/CMake/","title":"CMake","text":"
- MissingSemester
\u7ea6 14 \u4e2a\u5b57
\u8d44\u6e90
\u5b98\u65b9\u6559\u7a0b : https://cmake.org/cmake/help/latest/guide/tutorial/index.html
Backlinks:
","tags":["tools/Cmake"]},{"location":"Tools/Collection/","title":"\u6536\u96c6","text":"\u7ea6 75 \u4e2a\u5b57
"},{"location":"Tools/Collection/#_2","title":"\u7535\u8111\u4e0a\u7684\u5c0f\u5de5\u5177","text":""},{"location":"Tools/Collection/#_3","title":"\u56fe\u50cf","text":""},{"location":"Tools/Collection/#-draw-io-vsc","title":"- \u6d41\u7a0b\u56fe draw io \u4e3b\u8981\u662f\u53ef\u4ee5\u96c6\u6210\u5230VSC\u4e2d","text":"
- everything \u597d\u7528\u7684\u67e5\u627e\u5de5\u5177
- Snipaste \u6bd4\u8f83\u597d\u7528\u7684\u622a\u56fe\u5de5\u5177
- chorme\u62d3\u5c55 : \u6c99\u62c9\u67e5\u8bcd \u6253\u5f00chorme\u670d\u52a1\u4e4b\u540e\u4efb\u4f55\u60c5\u51b5\u4e0b\u67e5\u8bcd\u90fd\u4f1a\u6bd4\u8f83\u65b9\u4fbf
Backlinks:
"},{"location":"Tools/Conda/","title":"Conda","text":"\u7ea6 1 \u4e2a\u5b57
"},{"location":"Tools/GNUMake/","title":"GNU Make","text":"\u7ea6 1035 \u4e2a\u5b57 88 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 6 \u5206\u949f
\u8d44\u6599:
makefile \u4ecb\u7ecd \u2014 \u8ddf\u6211\u4e00\u8d77\u5199 Makefile 1.0 \u6587\u6863
\u89c6\u9891:
\u4e00\u4e2a\u8f83\u7b80\u5355\u7684\u5165\u95e8 https://www.youtube.com/watch?v=E1_uuFWibuM&t=1152s
TIPS
- cc \u662f C \u7f16\u8bd1\u5668\u7684\u547d\u4ee4\u3002\u5728\u4e00\u822c\u7684\u7cfb\u7edf\u4e0a\uff08Unix/Linux\uff09\uff0c\u901a\u5e38\u662f\u4e00\u4e2a\u6307\u5411 \u5b9e\u9645 C \u7f16\u8bd1\u5668\uff08gcc\uff09\u7684\u7b26\u53f7\u94fe\u63a5\u6216\u522b\u540d
windows \u4e0b\u53ef\u4ee5\u4f7f\u7528 gcc .c -o .o
## \u4f7f\u7528\u8fc7\u7a0b\n// \u6307\u5b9a\u6587\u4ef6\ngcc your_source_file.c -o ../your_executable\n// \u94fe\u63a5c++\u6807\u51c6\u5e93\ngcc source/pdShow.cpp pd.cpp -o source/pdShow -lstdc++\n
\u200b
","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_1","title":"\u57fa\u672c\u4ecb\u7ecd","text":"
target ... : prerequisites ...\n recipe\n ...\n ...\n// \u5b9a\u4e49\u4f9d\u8d56\u5173\u7cfb\n
target \u53ef\u4ee5\u662f\u4e00\u4e2a object file\uff08\u76ee\u6807\u6587\u4ef6\uff09\uff0c\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u8fd8\u53ef\u4ee5\u662f\u4e00\u4e2a\u6807\u7b7e\uff08label\uff09\u3002 prerequisites \u751f\u6210\u8be5 target \u6240\u4f9d\u8d56\u7684\u6587\u4ef6\u548c/\u6216 target\u3002 recipe \u8be5 target \u8981\u6267\u884c\u7684\u547d\u4ee4\uff08\u4efb\u610f\u7684 shell \u547d\u4ee4\uff09\u3002
","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_2","title":"\u53d8\u91cf","text":"
- \u7b2c\u4e00\u4e2a\u76ee\u6807\u4f1a\u4f5c\u4e3a\u9ed8\u8ba4\u76ee\u6807
- makefile \u4e2d\u7684\u53d8\u91cf\u76f8\u5f53\u4e8e C \u4e2d\u7684\u5b8f\u5b9a\u4e49
","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#makefile","title":"Makefile \u5982\u4f55\u5de5\u4f5c","text":"
def
:objects = main.o
usage
:edit : $(objects)
","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#windows","title":"windows","text":"","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_3","title":"\u4e66\u5199\u89c4\u5219","text":"
- make \u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u627e\u540d\u5b57\u53eb\u201cMakefile\u201d\u6216\u201cmakefile\u201d\u7684\u6587\u4ef6\u3002
- \u5982\u679c\u627e\u5230\uff0c\u5b83\u4f1a\u627e\u6587\u4ef6\u4e2d\u7684\u7b2c\u4e00\u4e2a\u76ee\u6807\u6587\u4ef6\uff08target\uff09\uff0c\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u4ed6\u4f1a\u627e\u5230\u201cedit\u201d\u8fd9\u4e2a\u6587\u4ef6\uff0c\u5e76\u628a\u8fd9\u4e2a\u6587\u4ef6\u4f5c\u4e3a\u6700\u7ec8\u7684\u76ee\u6807\u6587\u4ef6\u3002
- \u5982\u679c edit \u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u6216\u662f edit \u6240\u4f9d\u8d56\u7684\u540e\u9762\u7684 .o \u6587\u4ef6\u7684\u6587\u4ef6\u4fee\u6539\u65f6\u95f4\u8981\u6bd4 edit \u8fd9\u4e2a\u6587\u4ef6\u65b0\uff0c\u90a3\u4e48\uff0c\u4ed6\u5c31\u4f1a\u6267\u884c\u540e\u9762\u6240\u5b9a\u4e49\u7684\u547d\u4ee4\u6765\u751f\u6210 edit \u8fd9\u4e2a\u6587\u4ef6\u3002
- \u5982\u679c edit \u6240\u4f9d\u8d56\u7684 .o \u6587\u4ef6\u4e5f\u4e0d\u5b58\u5728\uff0c\u90a3\u4e48 make \u4f1a\u5728\u5f53\u524d\u6587\u4ef6\u4e2d\u627e\u76ee\u6807\u4e3a .o \u6587\u4ef6\u7684\u4f9d\u8d56\u6027\uff0c\u5982\u679c\u627e\u5230\u5219\u518d\u6839\u636e\u90a3\u4e00\u4e2a\u89c4\u5219\u751f\u6210 .o \u6587\u4ef6\u3002\uff08\u8fd9\u6709\u70b9\u50cf\u4e00\u4e2a\u5806\u6808\u7684\u8fc7\u7a0b\uff09
- \u5f53\u7136\uff0c\u4f60\u7684 C \u6587\u4ef6\u548c\u5934\u6587\u4ef6\u662f\u5b58\u5728\u7684\u5566\uff0c\u4e8e\u662f make \u4f1a\u751f\u6210 .o \u6587\u4ef6\uff0c\u7136\u540e\u518d\u7528 .o \u6587\u4ef6\u751f\u6210 make \u7684\u7ec8\u6781\u4efb\u52a1\uff0c\u4e5f\u5c31\u662f\u53ef\u6267\u884c\u6587\u4ef6 edit \u4e86\u3002
","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_4","title":"\u901a\u914d\u7b26","text":"
- \u547d\u4ee4\u4e00\u5b9a\u8981\u4ee5
tab
\u5f00\u5934","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_5","title":"\u6587\u4ef6\u641c\u5bfb","text":"
*
.o .c?
~
\u5728\u6587\u4ef6\u540d\u4e2d\u6709\u7528\u9014 \u3002 \u6bd4\u5982\uff0c~/test
\u8868\u793a\u5f53\u524d\u7528\u6237\u7684 $HOME \u76ee\u5f55\u4e0b\u7684 test \u76ee\u5f55\u3002
VPATH \u53d8\u91cf
VPATH = src:../headers
\u6b64\u5904\uff0c\u7528 : \u5206\u9694\u4e0d\u540c\u8def\u5f84vpath \u5173\u952e\u5b57
**vpath <pattern> <directories>**
\u4e3a\u7b26\u5408\u6a21\u5f0f\u7684\u6587\u4ef6\u6307\u5b9a\u641c\u7d22\u76ee\u5f55\u3002**vpath <pattern>**
\u6e05\u9664\u7b26\u5408\u6a21\u5f0f\u7684\u6587\u4ef6\u7684\u641c\u7d22\u76ee\u5f55\u3002**vpath**
\u6e05\u9664\u6240\u6709\u5df2\u88ab\u8bbe\u7f6e\u597d\u4e86\u7684\u6587\u4ef6\u641c\u7d22\u76ee\u5f55\u3002","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_6","title":"\u4f2a\u76ee\u6807","text":"
.PHONY : clean
\u58f0\u660e\u8fd9\u4e2a\u76ee\u6807\u662f\u4f2a\u76ee\u6807\uff0c\u907f\u514d\u4e0e\u6587\u4ef6\u540d\u91cd\u590d.PHONY : clean\nclean :\n rm *.o temp\n
\u5229\u7528\u4f2a\u76ee\u6807\u5b9e\u73b0\u4e00\u4e2a makefile \u7f16\u8bd1\u591a\u4e2a\u6587\u4ef6\uff0c\u751f\u6210\u591a\u4e2a exe
all : prog1 prog2 prog3\n# \u6b64\u5904\u7684\u4f9d\u8d56\u4e5f\u662f\u76ee\u6807\n.PHONY : all\n\nprog1 : prog1.o utils.o\n cc -o prog1 prog1.o utils.o\n\nprog2 : prog2.o\n cc -o prog2 prog2.o\n\nprog3 : prog3.o sort.o utils.o\n cc -o prog3 prog3.o sort.o utils.o\n
\u4f2a\u76ee\u6807\u4f5c\u4e3a\u4f9d\u8d56
","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_7","title":"\u591a\u76ee\u6807","text":".PHONY : cleanall cleanobj cleandiff\n\ncleanall : cleanobj cleandiff\n rm program\n\ncleanobj :\n rm *.o\n\ncleandiff :\n rm *.diff\n
- \u4f7f\u7528\u4e00\u4e2a\u81ea\u52a8\u5316\u53d8\u91cf
$@
\uff0c\u8fd9\u4e2a\u53d8\u91cf\u8868\u793a\u7740\u76ee\u524d\u89c4\u5219\u4e2d\u6240\u6709\u7684\u76ee\u6807\u7684\u96c6\u5408","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_8","title":"\u9759\u6001\u6a21\u5f0f","text":"bigoutput littleoutput : text.g\n generate text.g -$(subst output,,$@) > $@\n\n#\u4e0a\u8ff0\u89c4\u5219\u7b49\u4ef7\u4e8e\uff1a\n\nbigoutput : text.g\n generate text.g -big > bigoutput\nlittleoutput : text.g\n generate text.g -little > littleoutput\n
\u66f4\u5bb9\u6613\u5b9a\u4e49\u591a\u76ee\u6807\u7684\u89c4\u5219
<targets ...> : <target-pattern> : <prereq-patterns ...>\n <commands>\n ...\n# Example\nobjects = foo.o bar.o\n\nall: $(objects)\n# $< \u8868\u793a\u7b2c\u4e00\u4e2a\u4f9d\u8d56\u6587\u4ef6\n# $@ \u8868\u793a\u76ee\u6807\u96c6\uff08\u4e5f\u5c31\u662f\u201cfoo.o bar.o\u201d\uff09\n$(objects): %.o: %.c\n $(CC) -c $(CFLAGS) $< -o $@\n
targets
\u5b9a\u4e49\u4e86\u4e00\u7cfb\u5217\u7684\u76ee\u6807\u6587\u4ef6\uff0c\u53ef\u4ee5\u6709\u901a\u914d\u7b26\u3002\u662f\u76ee\u6807\u7684\u4e00\u4e2a\u96c6\u5408\u3002
target-pattern
\u6307\u660e\u4e86 targets \u7684\u6a21\u5f0f\uff0c\u4e5f\u5c31\u662f\u7684\u76ee\u6807\u96c6\u6a21\u5f0f\u3002
prereq-patterns
\u662f\u76ee\u6807\u7684\u4f9d\u8d56\u6a21\u5f0f\uff0c\u5b83\u5bf9 target-pattern \u5f62\u6210\u7684\u6a21\u5f0f\u518d\u8fdb\u884c\u4e00\u6b21\u4f9d\u8d56\u76ee\u6807\u7684\u5b9a\u4e49\u3002
","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_9","title":"* \u81ea\u52a8","text":"GNU \u7ec4\u7ec7\u5efa\u8bae\u628a\u7f16\u8bd1\u5668\u4e3a\u6bcf\u4e00\u4e2a\u6e90\u6587\u4ef6\u7684\u81ea\u52a8\u751f\u6210\u7684\u4f9d\u8d56\u5173\u7cfb\u653e\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff0c\u4e3a\u6bcf\u4e00\u4e2a
name.c
\u7684\u6587\u4ef6\u90fd\u751f\u6210\u4e00\u4e2aname.d
\u7684 Makefile \u6587\u4ef6\uff0c.d
\u6587\u4ef6\u4e2d\u5c31\u5b58\u653e\u5bf9\u5e94.c
\u6587\u4ef6\u7684\u4f9d\u8d56\u5173\u7cfb\u3002 \u901a\u8fc7gcc
\u547d\u4ee4\u81ea\u52a8\u751f\u6210\u4f9d\u8d56\u6587\u4ef6>>> gcc -MM main.c\nmain.o: main.c variable.h\n
\u5728\u7f16\u8bd1\u5668\u751f\u6210\u7684\u4f9d\u8d56\u5173\u7cfb\u4e2d\u52a0\u5165
.d
\u6587\u4ef6\u7684\u4f9d\u8d56","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_10","title":"\u4e66\u5199\u547d\u4ee4","text":"","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_11","title":"\u547d\u4ee4\u663e\u793a","text":"%.d: %.c\n @set -e; rm -f $@; \\\n $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \\\n sed 's,\\($*\\)\\.o[ :]*,\\1.o $@ : ,g' < $@.$$$$ > $@; \\\n rm -f $@.$$$$\n
- \u901a\u5e38\uff0cmake \u4f1a\u628a\u5176\u8981\u6267\u884c\u7684\u547d\u4ee4\u884c\u5728\u547d\u4ee4\u6267\u884c\u524d\u8f93\u51fa\u5230\u5c4f\u5e55\u4e0a\u3002\u5f53\u6211\u4eec\u7528 @ \u5b57\u7b26\u5728\u547d\u4ee4\u884c\u524d\uff0c\u90a3\u4e48\uff0c\u8fd9\u4e2a\u547d\u4ee4\u5c06\u4e0d\u88ab make \u663e\u793a\u51fa\u6765\uff0c\u6700\u5177\u4ee3\u8868\u6027\u7684\u4f8b\u5b50\u662f\uff0c\u6211\u4eec\u7528\u8fd9\u4e2a\u529f\u80fd\u6765\u5411\u5c4f\u5e55\u663e\u793a\u4e00\u4e9b\u4fe1\u606f\u3002
@echo \u6b63\u5728\u7f16\u8bd1\n>>>\u6b63\u5728\u7f16\u8bd1\necho \u6b63\u5728\u7f16\u8bd1\n>>>echo \u6b63\u5728\u7f16\u8bd1\n>>>\u6b63\u5728\u7f16\u8bd1\n
- make \u53c2\u6570
","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_12","title":"\u547d\u4ee4\u6267\u884c","text":"
-n
\u6216--just-print
\uff0c\u90a3\u4e48\u5176\u53ea\u662f\u663e\u793a\u547d\u4ee4\uff0c\u4f46\u4e0d\u4f1a\u6267\u884c\u547d\u4ee4\uff0c\u8fd9\u4e2a\u529f\u80fd\u5f88\u6709\u5229\u4e8e\u6211\u4eec\u8c03\u8bd5\u6211\u4eec\u7684 Makefile\uff0c\u770b\u770b\u6211\u4eec\u4e66\u5199\u7684\u547d\u4ee4\u662f\u6267\u884c\u8d77\u6765\u662f\u4ec0\u4e48\u6837\u5b50\u7684\u6216\u662f\u4ec0\u4e48\u987a\u5e8f\u7684\u3002 make \u53c2\u6570-s
\u6216--silent
\u6216--quiet
\u5219\u662f\u5168\u9762\u7981\u6b62\u547d\u4ee4\u7684\u663e\u793a\u3002","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_13","title":"\u5d4c\u5957\u6267\u884c","text":"","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#-","title":"- \u4f18\u70b9\uff1a\u6a21\u5757\u5316","text":"","tags":["tools/GNUMake"]},{"location":"Tools/GNUMake/#_14","title":"\u793a\u4f8b","text":"
exec: cd /home/hchen; pwd
\u4e0d\u80fd\u5199\u5728\u4e24\u884c\u4e0a \u4f7f\u5f97pwd
\u547d\u4ee4\u5728cd
\u547d\u4ee4\u57fa\u7840\u4e0a\u8fdb\u884cobjects = main.o kbd.o command.o display.o \\\n insert.o search.o files.o utils.o\n\nedit : $(objects)\n cc -o edit $(objects)\n\nmain.o : defs.h\nkbd.o : defs.h command.h\ncommand.o : defs.h command.h\ndisplay.o : defs.h buffer.h\ninsert.o : defs.h buffer.h\nsearch.o : defs.h buffer.h\nfiles.o : defs.h buffer.h command.h\nutils.o : defs.h\n\n# \u8868\u793a clean \u662f\u4e2a\u4f2a\u76ee\u6807\u6587\u4ef6\n.PHONY : clean\nclean :\n rm edit $(objects)\n
Backlinks:
","tags":["tools/GNUMake"]},{"location":"Tools/Git/","title":"Git","text":"\u7ea6 334 \u4e2a\u5b57 75 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 3 \u5206\u949f
Collection
Docs
","tags":["tools/git"]},{"location":"Tools/Git/#git_1","title":"Git \u914d\u7f6e","text":"
- Command \u6c47\u603b
- Learn Branch \uff1a\u4e00\u4e2a\u5206\u652f\u7684\u7ec3\u4e60\\\u5b66\u4e60\u7f51\u7ad9
- \u63a8\u8350\u9605\u8bfb\uff1aProGit
","tags":["tools/git"]},{"location":"Tools/Git/#gitignore","title":"gitignore\u7684\u5199\u6cd5","text":"
- \u67e5\u770b\u914d\u7f6e\u6587\u4ef6
git config --list --show-origin
- \u67e5\u770b\u914d\u7f6e\u4fe1\u606f
git config --list
- \u914d\u7f6e\u7528\u6237\u4fe1\u606f
$ git config --global user.name \"ZZIcarus\"\n$ git config --global user.email 2450606426@qq.com\n
\u901a\u914d\u7b26
","tags":["tools/git"]},{"location":"Tools/Git/#usage","title":"Usage","text":"# \u5ffd\u7565\u6240\u6709\u7684 .a \u6587\u4ef6\n*.a\n\n# \u4f46\u8ddf\u8e2a\u6240\u6709\u7684 lib.a\uff0c\u5373\u4fbf\u4f60\u5728\u524d\u9762\u5ffd\u7565\u4e86 .a \u6587\u4ef6\n!lib.a\n\n# \u53ea\u5ffd\u7565\u5f53\u524d\u76ee\u5f55\u4e0b\u7684 TODO \u6587\u4ef6\uff0c\u800c\u4e0d\u5ffd\u7565 subdir/TODO\n/TODO\n\n# \u5ffd\u7565\u4efb\u4f55\u76ee\u5f55\u4e0b\u540d\u4e3a build \u7684\u6587\u4ef6\u5939\nbuild/\n\n# \u5ffd\u7565 doc/notes.txt\uff0c\u4f46\u4e0d\u5ffd\u7565 doc/server/arch.txt\ndoc/*.txt\n\n# \u5ffd\u7565 doc/ \u76ee\u5f55\u53ca\u5176\u6240\u6709\u5b50\u76ee\u5f55\u4e0b\u7684 .pdf \u6587\u4ef6\ndoc/**/*.pdf\n
\u82f1\u6587\u72b6\u6001\u4e0b\u6309
q
\u53ef\u4ee5\u9000\u51fagit log
\u7b49\u8f93\u51fa\u4fe1\u606f\u7684\u547d\u4ee4git log
usage","tags":["tools/git"]},{"location":"Tools/Git/#_1","title":"\u7248\u672c\u56de\u9000","text":"git init \n\ngit add\n\ngit commit -m \"message\"\n\ngit status\n\ngit diff\n\ngit push origin main\n\ngit pull origin main\n
HEAD\u8868\u793a\u6700\u65b0\u7248\u672c\uff0cHEAD,HEAD^,HEAD~100\u8868\u793a\u524d\u4e00\u4e2a\u3001\u524d\u4e24\u4e2a\u3001\u524d100\u4e2a\u7248\u672c
d16f1504a39840ea6962aa3e464a51bd8f72f298
\u662f\u7248\u672c\u53f7\uff0c\u53ef\u4ee5\u5728git log
\u547d\u4ee4\u4e2d\u67e5\u770b\u5982\u679c\u5728\u4e00\u6b21\u56de\u9000\u4e4b\u540e\u60f3\u8981\u56de\u5230\u201c\u672a\u6765\u201d\uff0c\u4f7f\u7528
git relog
, \u53ef\u4ee5\u67e5\u770b\u4e4b\u524d\u7684\u547d\u4ee4","tags":["tools/git"]},{"location":"Tools/Git/#_2","title":"\u8fdc\u7a0b\u8fde\u63a5","text":"git reset --hard HEAD\ngit reset --hard d16f1504a39840ea6962aa3e464a51bd8f72f298\n
SSH
\u5173\u8054\u8fdc\u7a0b\u5e93 - origin \u662f\u5f53\u524d\u7684\u4ed3\u5e93\u540d
","tags":["tools/git"]},{"location":"Tools/Git/#_3","title":"\u5206\u652f\u7ba1\u7406","text":"git remote add origin ...
\u5206\u79bbHead
\u5206\u79bb\u7684 HEAD \u5c31\u662f\u8ba9\u5176\u6307\u5411\u4e86\u67d0\u4e2a\u5177\u4f53\u7684\u63d0\u4ea4\u8bb0\u5f55\u800c\u4e0d\u662f\u5206\u652f\u540d\u3002
git checkout HEAD
","tags":["tools/git"]},{"location":"Tools/Git/#_4","title":"\u5206\u652f\u5408\u5e76","text":"git checkout -b dev // \u521b\u5efa\u5e76\u8df3\u8f6c\n# \u521b\u5efa \u79fb\u52a8\u5206\u652f\ngit branch dev\ngit checkout dev\n# \u79fb\u52a8\u6307\u5b9a\u5206\u652f\u5230\u6307\u5b9a\u4f4d\u7f6e\ngit branch -f main HEAD~3\n\ngit branch // \u67e5\u770b\u5f53\u524d\u5206\u652f\n\n# \u5206\u652f\u5408\u5e76\ngit checkout main\ngit merge dev\n\n# \u5220\u9664\u5206\u652f\ngit branch -d dev\n
\u4e24\u79cd\u65b9\u5f0f
","tags":["tools/git"]},{"location":"Tools/Git/#tag","title":"Tag","text":"","tags":["tools/git"]},{"location":"Tools/Git/#errors","title":"Errors","text":"","tags":["tools/git"]},{"location":"Tools/Git/#_5","title":"\u51b2\u7a81","text":"git merge
git rebase
stockOverflow
","tags":["tools/git"]},{"location":"Tools/Git/#_6","title":"\u5206\u652f","text":"! [rejected] main -> main (non-fast-forward)\nerror: failed to push some refs to 'github.com:zzicarus/zzicarus.github.io.git' \nhint: Updates were rejected because the tip of your current branch is behind \nhint: its remote counterpart. Integrate the remote changes (e.g.\nhint: 'git pull ...') before pushing again.\nhint: See the 'Note about fast-forwards' in 'git push --help' for details. \n
\u5207\u6362\u5230\u65b0\u5efa\u7684\u5206\u652f\u540e\uff0c\u8fdb\u884cpush\u62a5\u9519
\u9700\u8981\u5c06\u672c\u5730\u65b0\u5efa\u7684\u5206\u652f\u4e0e\u8fdc\u7a0b\u7684\u5206\u652f\u5efa\u7acb\u8fde\u63a5
\u65b9\u6cd51\uff1a
git push --set-upstream origin dev
\u8fd9\u91cc\u7684dev\u662f\u65b0\u7684\u5206\u652f\u65b9\u6cd52\uff1a
","tags":["tools/git"]},{"location":"Tools/Git/#_7","title":"\u4ee3\u7406\u95ee\u9898","text":"fatal: The current branch dev has no upstream branch.\nTo push the current branch and set the remote as upstream, use\n\n git push --set-upstream origin dev\n\nTo have this happen automatically for branches without a tracking\nupstream, see 'push.autoSetupRemote' in 'git help config'.\n
\u95ee\u9898
\u7531\u4e8e\u8bbe\u7f6e\u7684\u4ee3\u7406\u4e0e\u5f53\u524d\u7684\u4ee3\u7406\u4e0d\u540c\u3002\u4e00\u822c\u662f\u7ffb\u5899\u4e4b\u540e\uff0c\u7f51\u7edc\u4ee3\u7406\u53d1\u751f\u53d8\u5316\u3002Connection reset by 20.205.243.160 port 443\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n
Solution
\u5173\u4e8e\u4ee3\u7406","tags":["tools/git"]},{"location":"Tools/Shell/","title":"Shell","text":"git config --global http.proxy http://127.0.0.1:7890 \ngit config --global https.proxy http://127.0.0.1:7890\n\n# \u53d6\u6d88\u4ee3\u7406\ngit config --global --unset http.proxy\ngit config --global --unset https.proxy\n
\u7ea6 849 \u4e2a\u5b57 42 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
\u73af\u5883\u53d8\u91cf
echo $path
$ which echo\n$ pwd\n$ cd . current\n$ cd .. parent\n
ls -l
drwxr-xr-x
\u662f\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u8868\u793a\u65b9\u5f0f\u4e2d\u7684\u4e00\u90e8\u5206\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cdrwxr-xr-x
\u8868\u793a\u4e00\u4e2a\u76ee\u5f55\u7684\u6743\u9650\u3002
- \u7b2c\u4e00\u4e2a\u5b57\u7b26
d
\u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u76ee\u5f55\u3002\u5982\u679c\u662f\u6587\u4ef6\uff0c\u8be5\u5b57\u7b26\u4f1a\u662f-
\u3002- \u63a5\u4e0b\u6765\u7684\u4e09\u4e2a\u5b57\u7b26
rwx
\u8868\u793a\u6240\u6709\u8005\uff08owner\uff09\u5bf9\u8be5\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0crwx
\u8868\u793a\u6240\u6709\u8005\u5177\u6709\u8bfb\uff08read\uff09\u3001\u5199\uff08write\uff09\u548c\u6267\u884c\uff08execute\uff09\u7684\u6743\u9650\u3002- \u63a5\u4e0b\u6765\u7684\u4e09\u4e2a\u5b57\u7b26
r-x
\u8868\u793a\u7ec4\uff08group\uff09\u5bf9\u8be5\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cr-x
\u8868\u793a\u7ec4\u5177\u6709\u8bfb\u548c\u6267\u884c\u7684\u6743\u9650\uff0c\u4f46\u6ca1\u6709\u5199\u7684\u6743\u9650\u3002- \u6700\u540e\u7684\u4e09\u4e2a\u5b57\u7b26
r-x
\u8868\u793a\u5176\u4ed6\u7528\u6237\u5bf9\u8be5\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u6743\u9650\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0cr-x
\u8868\u793a\u5176\u4ed6\u7528\u6237\u5177\u6709\u8bfb\u548c\u6267\u884c\u7684\u6743\u9650\uff0c\u4f46\u6ca1\u6709\u5199\u7684\u6743\u9650\u3002\u56e0\u6b64\uff0c
drwxr-xr-x
\u8868\u793a\u8fd9\u4e2a\u76ee\u5f55\u7684\u6240\u6709\u8005\u5177\u6709\u8bfb\u3001\u5199\u548c\u6267\u884c\u7684\u6743\u9650\uff0c\u7ec4\u548c\u5176\u4ed6\u7528\u6237\u5177\u6709\u8bfb\u548c\u6267\u884c\u7684\u6743\u9650\uff0c\u4f46\u6ca1\u6709\u5199\u7684\u6743\u9650\u3002","tags":["tools/shell"]},{"location":"Tools/Shell/#streams","title":"streams","text":"
rmdir
mkdir
man
ctrl + L
\u6e05\u9664cat
\u91cd\u5b9a\u5411
missing:~$ echo hello > hello.txt\nmissing:~$ cat hello.txt\nhello\nmissing:~$ cat < hello.txt\nhello\nmissing:~$ cat < hello.txt > hello2.txt\nmissing:~$ cat hello2.txt\nhello\n
\u8ffd\u52a0
>>
pipe |
sudo : super user
","tags":["tools/shell"]},{"location":"Tools/Shell/#unixroot","title":"\u5173\u4e8eUnix\u4e2d\u7684root\u7528\u6237","text":"\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 ls -l \u6765\u67e5\u770b\u8be6\u7ec6\u4fe1\u606f\n\u4f7f\u7528 chmod \u6765\u4fee\u6539\n
\u5728UNIX\u6216\u7c7bUNIX\u7cfb\u7edf\u4e2d\uff0c\u6bcf\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u90fd\u6709\u4e00\u4e2a\u6240\u6709\u8005\uff08owner\uff09\uff0c\u4e00\u4e2a\u7ec4\uff08group\uff09\u548c\u5176\u4ed6\u7528\u6237\uff08others\uff09\u3002
- \u6240\u6709\u8005\uff08owner\uff09\u662f\u521b\u5efa\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u7528\u6237\u3002\u6240\u6709\u8005\u5bf9\u6587\u4ef6\u6216\u76ee\u5f55\u5177\u6709\u6700\u9ad8\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u8bfb\u53d6\u3001\u5199\u5165\u548c\u6267\u884c\u3002
- \u7ec4\uff08group\uff09\u662f\u4e00\u7ec4\u7528\u6237\uff0c\u53ef\u4ee5\u5171\u4eab\u5bf9\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u8bbf\u95ee\u6743\u9650\u3002\u7ec4\u6210\u5458\u5177\u6709\u4e0e\u7ec4\u76f8\u5173\u8054\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u662f\u8bfb\u53d6\u3001\u5199\u5165\u548c\u6267\u884c\u3002
- \u5176\u4ed6\u7528\u6237\uff08others\uff09\u662f\u9664\u4e86\u6240\u6709\u8005\u548c\u7ec4\u4e4b\u5916\u7684\u6240\u6709\u7528\u6237\u3002\u5176\u4ed6\u7528\u6237\u5177\u6709\u72ec\u7acb\u4e8e\u6240\u6709\u8005\u548c\u7ec4\u7684\u6743\u9650\uff0c\u53ef\u4ee5\u662f\u8bfb\u53d6\u3001\u5199\u5165\u548c\u6267\u884c\u3002
\u4f7f\u7528
chmod
\u547d\u4ee4\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u7f29\u5199\u6765\u6307\u5b9a\u4e0d\u540c\u7528\u6237\u7c7b\u522b\u7684\u6743\u9650\uff1a
u
\u4ee3\u8868\u6240\u6709\u8005\uff08user\uff09\u3002g
\u4ee3\u8868\u7ec4\uff08group\uff09\u3002o
\u4ee3\u8868\u5176\u4ed6\u7528\u6237\uff08others\uff09\u3002\u4f8b\u5982\uff0c
chmod u+rwx,g+rw,o+x file.txt
\u5c06\u4e3a\u6587\u4ef6file.txt
\u5206\u914d\u5982\u4e0b\u6743\u9650\uff1a
- \u6240\u6709\u8005\u5177\u6709\u8bfb\u53d6\u3001\u5199\u5165\u548c\u6267\u884c\u6743\u9650\u3002
- \u7ec4\u5177\u6709\u8bfb\u53d6\u548c\u5199\u5165\u6743\u9650\u3002
- \u5176\u4ed6\u7528\u6237\u5177\u6709\u6267\u884c\u6743\u9650\u3002
\u8fd9\u6837\u7684\u6743\u9650\u8bbe\u7f6e\u5c06\u786e\u4fdd\u4e0d\u540c\u7528\u6237\u7c7b\u522b\u5177\u6709\u9002\u5f53\u7684\u6743\u9650\uff0c\u4ee5\u63a7\u5236\u5bf9\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u8bbf\u95ee\u3002
","tags":["tools/shell"]},{"location":"Tools/Shell/#bash","title":"Bash \u7f16\u7a0b","text":"
- shell\u4e2d\u7684\u7a7a\u683c\u5341\u5206\u91cd\u8981
foo=bar
foo = bar
\u524d\u8005\u6b63\u5e38\u5de5\u4f5c\uff0c\u540e\u8005\u627e\u4e0d\u5230foo\u547d\u4ee4- \u7f16\u5199shell\u51fd\u6570\u65f6
$0
- \u811a\u672c\u540d$1
\u5230$9
- \u811a\u672c\u7684\u53c2\u6570\u3002$1
\u662f\u7b2c\u4e00\u4e2a\u53c2\u6570\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002$@
- \u6240\u6709\u53c2\u6570$#
- \u53c2\u6570\u4e2a\u6570$?
- \u524d\u4e00\u4e2a\u547d\u4ee4\u7684\u8fd4\u56de\u503c$$
- \u5f53\u524d\u811a\u672c\u7684\u8fdb\u7a0b\u8bc6\u522b\u7801!!
- \u5b8c\u6574\u7684\u4e0a\u4e00\u6761\u547d\u4ee4\uff0c\u5305\u62ec\u53c2\u6570\u3002\u5e38\u89c1\u5e94\u7528\uff1a\u5f53\u4f60\u56e0\u4e3a\u6743\u9650\u4e0d\u8db3\u6267\u884c\u547d\u4ee4\u5931\u8d25\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528sudo !!
\u518d\u5c1d\u8bd5\u4e00\u6b21\u3002$_
- \u4e0a\u4e00\u6761\u547d\u4ee4\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u3002\u5982\u679c\u4f60\u6b63\u5728\u4f7f\u7528\u7684\u662f\u4ea4\u4e92\u5f0f shell\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u6309\u4e0bEsc
\u4e4b\u540e\u952e\u5165 . \u6765\u83b7\u53d6\u8fd9\u4e2a\u503c\u3002\u8fdb\u7a0b\u66ff\u6362
<(CMD)
\u5c06\u4f1a\u6267\u884cCMD\u5e76\u5c06\u7ed3\u679c\u8f93\u51fa\u5230\u4e00\u4e2a\u4e34\u65f6\u6587\u4ef6\u4e2d\uff0c\u5e76\u5c06<(CMD)
\u66ff\u6362\u4e3a\u4e34\u65f6\u6587\u4ef6\u540d\u3002\u6ce8\u610f\uff0c\u8fd4\u56de\u503c\u901a\u8fc7\u6587\u4ef6\u800c\u4e0d\u662fSTDOUT#!/bin/bash\n\necho \"Starting program at $(date)\" # date\u4f1a\u88ab\u66ff\u6362\u6210\u65e5\u671f\u548c\u65f6\u95f4\n\necho \"Running program $0 with $# arguments with pid $$\"\n\nfor file in \"$@\"; do\n grep foobar \"$file\" > /dev/null 2> /dev/null\n # \u5982\u679c\u6a21\u5f0f\u6ca1\u6709\u627e\u5230\uff0c\u5219grep\u9000\u51fa\u72b6\u6001\u4e3a 1\n # \u6211\u4eec\u5c06\u6807\u51c6\u8f93\u51fa\u6d41\u548c\u6807\u51c6\u9519\u8bef\u6d41\u91cd\u5b9a\u5411\u5230Null\uff0c\u56e0\u4e3a\u6211\u4eec\u5e76\u4e0d\u5173\u5fc3\u8fd9\u4e9b\u4fe1\u606f\n if [ \"\"$?\" -ne 0 ]( \"\"$?\" -ne 0 .md){#d2c9477a5ae1eaf7dda2777e66b04317}; then\n echo \"File $file does not have any foobar, adding one\"\n echo \"# foobar\" >> \"$file\"\n fi\ndone\n
There`s a
test
to check\u901a\u914d\u7b26
","tags":["tools/shell"]},{"location":"Tools/Shell/#prompt","title":"prompt","text":"ls *.py\nls project?\n{}\n
xargs
","tags":["tools/shell"]},{"location":"Tools/Shell/#instance","title":"Instance","text":"#!/bin/bash\n# Test run in Git bash\n\ndate1=\"2021 02 03\"\ncontent=\"today\\nI get a little bit happy\\n\"\n\necho \"hello\"\necho \"--- Running to Get the Exe ---\"\n# gcc source/pdRemove.cpp source/pd.cpp -o pdRemove -lstdc++\n# gcc source/pdAdd.cpp source/pd.cpp -o pdAdd -lstdc++\n# gcc source/pdList.cpp source/pd.cpp -o pdList -lstdc++\n# gcc source/pdShow.cpp source/pd.cpp -o pdShow -lstdc++\necho \"--- Complete ---\"\n\n# \u5c06\u811a\u672c\u4e2d\u7684\u5185\u5bb9\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9pdAdd\u547d\u4ee4\necho -e \"$date1\\n$content\" | xargs ./pdAdd\n
\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528echo -e\u6765\u6253\u5370\u5b57\u7b26\u4e32\uff0c\u5e76\u4f7f\u7528\u7ba1\u9053\u7b26\uff08|\uff09\u5c06\u5176\u91cd\u5b9a\u5411\u5230xargs\u547d\u4ee4\u7684stdin\u3002\u7136\u540e\uff0cxargs\u547d\u4ee4\u5c06\u8fd9\u4e9b\u8f93\u5165\u6570\u636e\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9pdAdd\u547d\u4ee4
","tags":["tools/shell"]},{"location":"Tools/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/","title":"\u6b63\u5219\u8868\u8fbe\u5f0f","text":"\u7ea6 6 \u4e2a\u5b57
","tags":["tools/\u6b63\u5219"]},{"location":"Tools/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/#_2","title":"\u6b63\u5219\u8868\u8fbe\u5f0f","text":"","tags":["tools/\u6b63\u5219"]},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/","title":"\u535a\u5ba2\u642d\u5efa","text":"\u7ea6 566 \u4e2a\u5b57 108 \u884c\u4ee3\u7801 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 4 \u5206\u949f
Abstract
\u8bb0\u5f55\u642d\u5efa MkDocs \u7684\u8fc7\u7a0b
\u53c2\u8003\u6587\u6863\uff1a
Material for mkdocs
\u77e5\u4e4e
Task
- \u521d\u6b65\u642d\u5efa\u5e73\u53f0
- \u642d\u5efa\u7b14\u8bb0\u6846\u67b6
- \u4e0a\u4f20\u7b14\u8bb0
- \u5bf9\u9875\u9762\u7f8e\u5316\uff0c\u98ce\u683c\u5316
- \u9875\u9762\u7f8e\u5316
- \u5b57\u6570\u7edf\u8ba1
- Comment\u7cfb\u7edf
Question
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_2","title":"\u9884\u4e0b\u8f7d","text":"
- \u591a\u4e2a H1 \u7684\u60c5\u51b5\uff0c\u6e32\u67d3\u4f1a\u51fa\u9519\uff1a\u4e3b\u8981\u662f\u53f3\u4fa7\u5bfc\u822a\u680f\u7684\u6e32\u67d3
\u4e3a\u4e86\u6210\u529f\u642d\u5efa\uff0c\u4f60\u9700\u8981\u5982\u4e0b\u9884\u5907\uff1a
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#material","title":"Material","text":"
- python \u73af\u5883\uff0c\u5e76\u4e14\u5b89\u88c5\u597d\u4e86 pip
- \u4e86\u89e3\u57fa\u672c\u7684 git \u8bed\u6cd5\uff08online \u90e8\u7f72\uff09
- \u4e86\u89e3\u57fa\u672c\u7684 md \u8bed\u6cd5
\u7531\u4e8e
MkDocs
\u7684\u539f\u7248\u4e3b\u9898\u786e\u5b9e\u4e0d\u592a\u597d\u770b\uff0c\u6240\u4ee5\u8fd9\u91cc\u4f7f\u7528\u4e86Material For MkDocs
\u8fdb\u884c\u4f18\u5316"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#github-page","title":"Github Page \u7684\u90e8\u7f72","text":"mkdocs new // \u65b0\u5efa\u4e00\u4e2aMkDocs\n\nmkdocs serve // \u5efa\u7acb\u4e00\u4e2a\u9884\u89c8\n\nmkdocs build // \u5efa\u7acb\u4e00\u4e2a\u9759\u6001\u7f51\u9875\n
- \u81ea\u52a8\u90e8\u7f72\u9700\u8981\u5728
.github\\workflows
\u4e2d\u52a0\u5165ci.yml
\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_3","title":"\u529f\u80fd","text":"name: ci\non:\n push:\n branches:\n - master\n - main\npermissions:\n contents: write\njobs:\n deploy:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v4\n - name: Configure Git Credentials\n run: |\n git config user.name github-actions[bot]\n git config user.email 41898282+github-actions[bot]@users.noreply.github.com\n - uses: actions/setup-python@v4\n with:\n python-version: 3.x\n - run: echo \"cache_id=$(date --utc '+%V')\" >> $GITHUB_ENV\n - uses: actions/cache@v3\n with:\n key: mkdocs-material-${{ env.cache_id }}\n path: .cache\n restore-keys: |\n mkdocs-material-\n - run: pip install mkdocs-material\n - run: mkdocs gh-deploy --force\n
\u4ecb\u7ecd
\u8fd9\u91cc\u6211\u9009\u4e86\u51e0\u4e2a\u81ea\u5df1\u4e4b\u540e\u5e94\u8be5\u5e38\u7528\u7684\uff0c\u8bb0\u4e00\u4e0b\u7528\u6cd5
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_4","title":"\u9009\u9879\u5361","text":""},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_5","title":"\u5206\u7ec4\u4ee3\u7801\u5757","text":"CC++=== \"C\"\n\n ``` c\n #include <stdio.h>\n\n int main(void) {\n printf(\"Hello world!\\n\");\n return 0;\n }\n ```\n\n=== \"C++\"\n\n ``` c++\n #include <iostream>\n\n int main(void) {\n std::cout << \"Hello world!\" << std::endl;\n return 0;\n }\n ```\n
#include <stdio.h>\n\nint main(void) {\n printf(\"Hello world!\\n\");\n return 0;\n}\n
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_6","title":"\u5d4c\u5165\u683c\u5f0f","text":"#include <iostream>\n\nint main(void) {\n std::cout << \"Hello world!\" << std::endl;\n return 0;\n}\n
\u5d4c\u5165
Unordered ListOrdered List* Sed sagittis eleifend rutrum\n* Donec vitae suscipit est\n* Nulla tempor lobortis orci\n
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#box","title":"box","text":"1. Sed sagittis eleifend rutrum\n2. Donec vitae suscipit est\n3. Nulla tempor lobortis orci\n
From
\u8fd9\u4e00\u90e8\u5206\u662f\u4ecexyjj \u7684 Page\u770b\u5230\u7684
<span class=\"box box-blue\">blue</span>\n<span class=\"box box-green\">green</span>\n<span class=\"box box-red\">red</span>\n<span class=\"box box-yellow\">yellow</span>\n<span class=\"box box-gray\">gray</span>\n
blue green red yellow gray
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_7","title":"\u5b57\u6570\u7edf\u8ba1","text":"\u76f4\u63a5\u4f7f\u7528\u4e86\u4e00\u4f4d\u5b66\u957f\u7684\u63d2\u4ef6
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#vsc","title":"\u4f18\u5316 vsc \u4e2d\u7684\u5de5\u4f5c\u6d41\u7a0b","text":"
- \u5feb\u6377\u952e Markdown ShortCuts \u63d2\u4ef6
- \u81ea\u5b9a\u4e49 Snippet
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#_8","title":"\u4e00\u4e9b\u7528\u6cd5 | \u6d4b\u8bd5\u683c\u5f0f","text":""},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#code-block","title":"Code Block","text":"\"Color Box\": {\n \"prefix\": \"box\",\n \"body\": [\n \"<span class=\\\"box box-${1|blue,red,green,yellow|}\\\">$2</span>\",\n \"$3\",\n ],\n \"description\": \"Inserts a colored box span\"\n },\n \"Prompt\": {\n \"prefix\": \"annotation\",\n \"body\": [\n \"!!! ${1|note,info,abstract,tip,success,quote,question,warning,bug,example,failure|} \\\"$2\\\"\",\n \"\\t$3\",\n ],\n \"description\": \"Inserts an annotation\"\n },\n
- \u7a81\u51fa\u663e\u793a\u7279\u5b9a\u884c
def bubble_sort(items):\n for i in range(len(items)):\n for j in range(len(items) - 1 - i):\n if items[j] > items[j + 1]:\n items[j], items[j + 1] = items[j + 1], items[j]\n
```py hl_lines=\"2 3\"\ndef bubble_sort(items):\n for i in range(len(items)):\n for j in range(len(items) - 1 - i):\n if items[j] > items[j + 1]:\n items[j], items[j + 1] = items[j + 1], items[j]\n```\n
- \u9ad8\u4eae\u5185\u90e8\u4ee3\u7801
The `#!python range()` function is used to generate a sequence of numbers.\n
The
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#md","title":"md \u683c\u5f0f\u7684\u8c03\u6574","text":"range()
function is used to generate a sequence of numbers.\u4ee3\u7801\u89c1 CSS \u90e8\u5206
- \u6709\u5e8f\u5217\u8868
- \u6709\u5e8f\u5217\u8868
- \u65e0\u5e8f\u5217\u8868
\u659c\u4f53
\u52a0\u7c97
\u5f15\u7528
\u94fe\u63a5
\u4e0b\u9762\u7684\u662f\u4e00\u4e9b\u62d3\u5c55\u7684\uff0c\u5728 markdown - extension \u4e2d\u53ef\u4ee5\u9009\u62e9\u52a0\u5165\uff08\u5efa\u8bae\u8bfb\u5b98\u65b9\u6587\u6863\uff09
:bread:\n~~\u5220\u9664~~\n==\u7a81\u51fa\u663e\u793a==\n^^\u63d2\u5165^^\n
\u5220\u9664
\u7a81\u51fa\u663e\u793a
\u63d2\u5165
"},{"location":"Tools/%E7%AB%99%E7%82%B9/mkdocs/#todo-mermaid","title":":Todo: Mermaid \u5e8f\u5217\u56fe","text":"\u8fd9\u91cc\u53d1\u73b0\u683c\u5f0f\u5e76\u4e0d\u662f\u5f88\u597d\uff0c\u4e4b\u540e\u6709\u65f6\u95f4\u4e86\u518d\u4fee\u6539 Mermaid \u7684\u914d\u7f6e\u5427\u3002\u800c\u4e14 Mermaid \u7684\u6e32\u67d3\u6709\u70b9\u6162\uff1f\uff08
https://mermaid.js.org/syntax/flowchart.html
note
flowchart LR\nsubgraph subgraph1\ndirection TB\ntop1[top] --> bottom1[bottom]\nend\nsubgraph subgraph2\ndirection TB\ntop2[top] --> bottom2[bottom]\nend\n Link *to* subgraph1: subgraph1 direction is maintained\n outside --> subgraph1\n subgraph2 inherits the direction of the top-level graph (LR)\n outside ---> top2\n ```\n\n### annotation\n\n```md\n!!! \u6216\u8005 ???\n???+ \u6298\u53e0\uff0c\u9ed8\u8ba4\u5c55\u5f00\u72b6\u6001
Note
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.
info
info
abstract
abstract
tip
octicons/squirrel-16
successsuccess
quotequote
questionquestion
warningwarning
bugbug
example
example
failure
failure
"},{"location":"_templates/_README/","title":"None","text":"\u7ea6 0 \u4e2a\u5b57
"},{"location":"_templates/_note/","title":"NOTE","text":"\u7ea6 0 \u4e2a\u5b57
","tags":["doing"]},{"location":"others/","title":"Index","text":"\u7ea6 12 \u4e2a\u5b57
Abstract
\u8fd9\u91cc\u653e\u4e00\u4e9bCS\u4e4b\u5916\u7684\u4e1c\u897f
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/","title":"\u5927\u5b66\u7269\u7406\u5b9e\u9a8c","text":"\u7ea6 484 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
\u4ecb\u7ecd
\u603b\u4f53
\u8fd9\u95e8\u8bfe\u600e\u4e48\u8bf4\u5462\uff0c\u611f\u89c9\u4ef7\u503c\u4e0d\u5927\u3002 \u4ee4\u4eba\u8bdf\u75c5\u7684\u624b\u6284\u62a5\u544a\u3001\u4e0e\u7406\u8bba\u5b8c\u5168\u4e0d\u5339\u914d\u7684\u8fdb\u5ea6\uff0c\u5bf9\u4e8e\u5f88\u591a\u4e0a\u8fd9\u95e8\u8bfe\u7a0b\u7684\u540c\u5b66\u6765\u8bf4\uff0c\u5f88\u53ef\u80fd\u4e4b\u540e\u4e0d\u5927\u4f1a\u7528\u5f97\u5230\u7269\u7406\uff08
\u6210\u7ee9\u6784\u6210
- 60% \u5e73\u65f6\u5b9e\u9a8c\u7684\u5e73\u5747
- 40% \u671f\u672b\u8003\u8bd5
\u8bfe\u7a0b\u8d44\u6599
\u7535\u5b50\u8bfe\u672c \u5927\u5b66\u7269\u7406\u5b9e\u9a8c (\u674e\u6d77\u6d0b) (Z-Library) (1).pdf
\u5f80\u5c4a\u7684\u90e8\u5206\u53c2\u8003 xyjj\u7684Page
\u671f\u672b\u590d\u4e60
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_2","title":"\u7eea\u8bba","text":""},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_3","title":"\u5b9e\u9a8c\u6d4b\u91cf\u4e0e\u8bef\u5dee","text":""},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_4","title":"\u6d4b\u91cf","text":"
- \u6700\u7ec8\u7ed3\u679c\u7684\u8868\u8ff0
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_5","title":"\u4e0d\u540c\u4eea\u5668\u4f7f\u7528","text":"
\u6d4b\u91cf
\u88ab\u6d4b\u5bf9\u8c61\u3001\u6d4b\u91cf\u7a0b\u5e8f\u3001\u6d4b\u91cf\u51c6\u786e\u5ea6\u548c\u8ba1\u91cf\u5355\u4f4d\u6709\u6548\u4f4d\u6570
\u6709\u6548\u6570\u5b57\u7684\u4f4d\u6570\u6709\u6548\u6570\u5b57
=\u53ef\u9760\u6570\u5b57\uff08\u76f4\u63a5\u8bfb\uff09
+\u4e00\u4f4d\u5b58\u7591\u6570\u5b57\uff08\u4f30\u8bfb\uff09
\u6e38\u6807\u5361\u5c3a
\u87ba\u65cb\u6d4b\u5fae\u5668 \u5206\u5ea6\u5c3a
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_6","title":"\u8bef\u5dee","text":"
- \u6ce8\u610f\u5916\u90e8\u523b\u5ea6\u548c\u5185\u90e8\u523b\u5ea6
\u8868\u793a
\u7edd\u5bf9\u8bef\u5dee = \u6d4b\u91cf - \u771f\u503c\uff08\u4e00\u822c\u4f1a\u662f\u7ea6\u5b9a\u4fd7\u6210\u7684\u503c\uff09
- \u76f8\u5bf9\u8bef\u5dee \uff08\u767e\u5206\u8bef\u5dee\uff09
E = | \u6d4b\u91cf - \u771f\u503c | / \u771f\u503c * 100 %
- \u6807\u51c6\u8bef\u5dee
\u5206\u7c7b
\u7cfb\u7edf\u8bef\u5dee
- \u5df2\u5b9a\u7cfb\u7edf\u8bef\u5dee\uff08\u4eea\u5668\u672c\u8eab\uff09
- \u672a\u5b9a\u7cfb\u7edf\u8bef\u5dee\uff08\u793a\u503c\u8bef\u5dee\uff09
- \u968f\u673a\u8bef\u5dee - \u4e0d\u53ef\u4fee\u6b63
- \u7c97\u5927\u8bef\u5dee
- ** \u8bef\u5dee\u5206\u5e03
\u6b63\u6001\u5206\u5e03
- \u6807\u51c6\u5dee
- \u6570\u5b66\u671f\u671b\u503c - \u8fd1\u4f3c\u771f\u503c
- \u6807\u51c6\u504f\u5dee\uff08\u5355\u6b21\u6d4b\u91cf\u503c\uff09
- \u5e73\u5747\u503c\u7684\u6807\u51c6\u504f\u5dee
- \u5355\u5cf0 \u5bf9\u79f0 \u6709\u754c \u62b5\u507f
\u5747\u5300\u5206\u5e03
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_7","title":"\u8bef\u5dee\u4e0e\u4e0d\u786e\u5b9a\u5ea6","text":"
- \u7cbe\u5bc6\u5ea6\u4e0e\u51c6\u786e\u5ea6
\u603b\u4e0d\u786e\u5b9a\u5ea6
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_8","title":"\u6807\u51c6\u4e0d\u786e\u5b9a\u5ea6","text":"A\u7c7b\uff1a\u7528\u7edf\u8ba1\u65b9\u6cd5\u8bc4\u5b9a B\u7c7b\uff1a\u7528\u5176\u4ed6\u65b9\u6cd5\u8bc4\u5b9a
- \u76f4\u63a5\u6d4b\u91cf
- A \u7c7b
6 \u2264 n \u226410\uff0c\u7f6e\u4fe1\u6982\u7387\u4e3a68.3%
- B \u7c7b
\u5b9e\u4f8b
- \u95f4\u63a5\u6d4b\u91cf\uff08\u5408\u6210\u6807\u51c6\u4e0d\u786e\u5b9a\u5ea6\uff09
- \u548c\u5dee\u5f62\u5f0f
- \u79ef\u5546\u5f62\u5f0f
\u5b9e\u4f8b
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_9","title":"\u6709\u6548\u6570\u5b57","text":""},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_10","title":"\u4fee\u7ea6","text":"
- \u53d6\u5076\u6cd5\u5219 \u5728\u6709\u591a\u4e2a\u6700\u63a5\u8fd1\u7684\u503c\u65f6\uff0c\u4e00\u822c\u53d6\u4fee\u7ea6\u533a\u95f4\u7684\u5076\u6570\u500d
\u4e0d\u5141\u8bb8\u8fde\u7eed\u4fee\u7ea6 \u4f8b\u5b502.2500 -> 2.2 \u6709\u6548\u6570\u5b57\u7684\u8868\u793a\u6cd5
\u53d6\u5076\u6cd5\u5219 \u5728\u6709\u591a\u4e2a\u6700\u63a5\u8fd1\u7684\u503c\u65f6\uff0c\u4e00\u822c\u53d6\u4fee\u7ea6\u533a\u95f4\u7684\u5076\u6570\u500d
- \u6709\u6548\u6570\u5b57\u7684\u4f4d\u6570\u591a\u5c11\u76f4\u63a5\u53cd\u6620\u6d4b\u91cf\u7684\u51c6\u786e\u5ea6\u3002\u6709\u6548\u4f4d\u6570 \u8d8a\u591a\uff0c\u8868\u660e\u6d4b\u91cf\u7684\u51c6\u786e\u5ea6\u8d8a\u9ad8\u3002
- \u6709\u6548\u6570\u503c\u4e66\u5199\u65f6\u5e94\u6ce8\u610f\uff1a\u6709\u6548\u6570\u503c\u7684\u4f4d\u6570\u4e0e\u5c0f\u6570\u70b9\u4f4d\u7f6e \u65e0\u5173\u3002\u4e0d\u56e0\u4f7f\u7528\u7684\u5355\u4f4d\u4e0d\u540c\u800c\u6539\u53d8\u3002
- \u5728
\u8fd0\u7b97\u8fc7\u7a0b
\u4e2d\u7684\u6709\u6548\u6570\u5b57\u53d6\u820d\uff0c \u4e00\u822c\u9075\u5faa\uff1a \u52a0\u51cf\u8fd0\u7b97\u7684\u7ed3\u679c\u4ee5\u53c2\u4e0e\u8fd0\u7b97\u7684\u672b\u4f4d\u6700\u9ad8\u7684\u6570\u4e3a\u51c6\uff1a\u4e58\u9664\u5219\u4ee5_\u6709\u6548\u6570\u5b57\u6700\u5c11_\u7684\u6570\u4e3a\u51c6\u3002\u4e0d\u786e\u5b9a\u5ea6\u4fee\u7ea6\u6cd5\u5219
"},{"location":"others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/#_11","title":"\u6570\u503c\u4e66\u5199","text":"
- \u60f3\u8981\u4fdd\u7559\u7684\u6700\u4f4e\u4e3a\u4e4b\u540e\u7684\u4e00\u4f4d\u6570\u4e0d\u662f 0 \u5c31\u8fdb\u4f4d\u5426\u5219\u820d\u53bb
- \u4f4d\u6570\u7531\u5408\u6210\u4e0d\u786e\u5b9a\u5ea6\u51b3\u5b9a\u3002
- \u5408\u6210\u4e0d\u786e\u5b9a\u5ea6\uff1a\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u9996\u4f4d\u5927\u4e8e\u7b49\u4e8e 3 \u53ea\u53d6\u4e00\u4f4d\uff0c\u5426\u5219\u53d6 2 \u4f4d
\u540c\u65f6\uff0c\u6d4b\u91cf\u503c\u7684\u6700\u540e\u4e00\u4f4d\u5e94\u8be5\u548c\u4e0d\u786e\u5b9a\u5ea6\u7684\u6700\u540e\u4e00\u4f4d\u5bf9\u9f50 \u8ba1\u7b97\u4e0d\u786e\u5b9a\u5ea6 -> \u4e0d\u786e\u5b9a\u5ea6\u4fee\u7ea6\uff08\u00bd\uff09 ->
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/","title":"\u5fae\u89c2\u7ecf\u6d4e\u5b66","text":"\u7ea6 474 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
\u672c\u7b14\u8bb0\u7c97\u5236\u6ee5\u9020\uff0c\u5199\u7684\u4e0d\u662f\u5f88\u8be6\u7ec6\uff0c\u66f4\u591a\u662f\u5f53\u65f6\u4e3a\u4e86\u5e2e\u52a9\u81ea\u5df1\u68b3\u7406\u3002\u8bf7\u5ba1\u614e\u89c2\u770b
Abstract
\u6388\u8bfe\u6559\u5e08: \u8d56\u666e\u6e05
\u2665 \u975e\u5e38\u597d\u7b14\u8bb0\uff0c\u7231\u6765\u81ea\u6d59\u5927 \u2665
\u4e00\u4efd\u524d\u8f88\u7684\u7b14\u8bb0
\u5fae\u89c2\u7ecf\u6d4e\u5b66\uff08\u4e0a\uff09
\u5fae\u89c2\u7ecf\u6d4e\u5b66\uff08\u4e0b\uff09
\u4e00\u4e9b\u8bfe\u7a0b\u8d44\u6e90\uff1a
\u7eff\u76ae\u4e66\uff08\u5f3a\u70c8\u63a8\u8350\uff01\uff09 \u5fae\u89c2\u7ecf\u6d4e\u5b66\u6559\u7a0b (\u6d59\u6c5f\u5927\u5b66\u73b0\u4ee3\u7ecf\u6d4e\u5b66\u4e1b\u4e66) (\u674e\u5efa\u7434) (Z-Library).pdf
\u7b54\u6848 \u5fd8\u8bb0\u5b58\u5728\u54ea\u91cc\u4e86\uff0c98\u7248\u641c\u5427(
\u3010ljq \u667a\u4e91\u5750\u6807\u3011 \u667a\u4e91\u8bfe\u5802
\u8bfe\u7a0b\u6210\u7ee9\u76f8\u5173
\u5e73\u65f6 40%
\u4f5c\u4e1a\uff08\u5b66\u5728\u6d59\u5927\uff09
\u51fa\u52e4\uff08\u7ebf\u4e0b\uff09
\u671f\u672b 60% - \u95ed\u5377\uff08\u96be\u5ea6\u8fd1\u4f5c\u4e1a\uff09
\u8865\u5145\uff1a\u8fd9\u91cc\u7684\u96be\u5ea6\u662f\u6307\u8ba1\u7b97\u9898\uff0c\u6bd5\u7adf\u5e73\u65f6\u7684\u4f5c\u4e1a\u4e5f\u6ca1\u6709\u9009\u62e9\u9898\uff0c\u7b80\u7b54\u4e5f\u5c31\u5076\u5c14\u4e00\u9053\uff1b\u4e2a\u4eba\u611f\u89c9\u671f\u672b\u7684\u9009\u62e9\u9898\u8003\u7684\u8fd8\u633a\u7ec6\uff0c\u5f88\u591a\u6982\u5ff5\u90fd\u6a21\u68f1\u4e24\u53ef\u7684\uff08\n
\u9009\u62e9\u9898(\u7ea620%)\u3001\u8ba1\u7b97\u9898(\u7ea630% )\u3001\u7b80\u7b54\u9898(\u7ea630%)\u3001\u7efc\u5408\u5206\u6790\u9898(\u7ea620% )
Tips
\u8fd9\u95e8\u8bfe\u7684\u5e73\u65f6\u5b66\u4e60\u7684\u8d1f\u62c5\u5e76\u4e0d\u662f\u5f88\u5927\uff0c\u4e00\u4e2a\u5b66\u671f\u603b\u7684\u4f5c\u4e1a\u6b21\u6570\u4e5f\u5e76\u4e0d\u591a\u3002(\u8fd9\u4e5f\u95f4\u63a5\u5bfc\u81f4\u6211\u6bcf\u6b21\u53ea\u628a\u4f5c\u4e1a\u4e0a\u7684\u8ba1\u7b97\u9898\u641e\u5b8c\u5c31\u5b8c\u4e8b\u513f\u4e86)\u7b14\u8005\u540e\u671f\u4e0a\u8bfe\u8d8a\u6765\u8d8a\u6446\u70c2\uff0c\u4e0a\u8bfe\u4e0d\u542c\uff0c\u4e0b\u8bfe\u8865\u8bfe\u4e5f\u4e0d\u662f\u5f88\u53ca\u65f6\uff0c\u6700\u540e\u8865\u5929\u8fd8\u662f\u633a\u75db\u82e6\u7684 QAQ\u3002
\u5982\u679c\u60f3\u8981\u6210\u7ee9\u9ad8\u4e00\u70b9\u7684\u8bdd\uff0c\u5efa\u8bae\u8981\u4e48\u4e0a\u8bfe\u8ddf\u7740\u8001\u5e08\u597d\u597d\u542c\uff08\u627e\u4e00\u4e2a\u8bb2\u5f97\u597d\u4e00\u70b9\u7684\u8001\u5e08\uff09\uff0c\u8981\u4e48\u8ba4\u771f\u770b\u4e00\u770b\u7eff\u76ae\u4e66
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/","title":"\u4ef7\u683c\u673a\u5236","text":"\u7ea6 426 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_2","title":"\u533a\u5206\u6982\u5ff5","text":"
- \u9700\u6c42\u548c\u6b32\u671b \u9700\u6c42\u4e0e\u6b32\u671b\uff08Wants\uff09\u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u6982\u5ff5\u3002\u6b32\u671b\u6216\u8d2d\u4e70\u6b32\u671b\u662f\u6307\u4eba\u4eec\u5bf9\u67d0\u79cd\u7269\u54c1\u611f\u5230\u7f3a\u4e4f\uff0c\u5e0c\u671b\u5f97\u5230\u7684\u4e00\u79cd\u5fc3\u7406\u73b0\u8c61\uff0c\u800c\u9700\u6c42\u5219\u662f\u5177\u6709\u8d2d\u4e70\u80fd\u529b\u7684\u6709\u6548\u9700\u6c42\u3002 \u4e5f\u5c31\u662f
\u9700\u6c42 = \u6b32\u671b + \u8d2d\u4e70\u80fd\u529b
- \u9700\u6c42\u548c\u9700\u6c42\u91cf \u9700\u6c42\u91cf\u5fc5\u987b\u8981\u6709\u4e00\u5b9a\u7684\u65f6\u95f4\u9650\u5236 \u800c\u4e14\u9700\u6c42\u662f\u6240\u6709\u4ef7\u683c\u6c34\u5e73\uff1b\u9700\u6c42\u91cf\u662f\u9488\u5bf9\u67d0\u4e00\u7279\u5b9a\u4ef7\u683c\u6c34\u5e73 \u9700\u6c42\u7684\u53d8\u5316 \u4ef7\u683c\u4e4b\u5916\u7684\u56e0\u7d20\uff1b\u66f2\u7ebf\u6574\u4f53 \u9700\u6c42\u91cf\u7684\u53d8\u5316 \u4ef7\u683c\u7684\u53d8\u5316\u5f15\u8d77\uff1b\u5355\u4e2a\u70b9
- \u66ff\u4ee3\u4ea7\u54c1\u548c\u4e92\u8865\u4ea7\u54c1
\u66ff\u4ee3\u4ea7\u54c1\uff1a\u4ea4\u66ff\u4f7f\u7528\u80fd\u591f\u6ee1\u8db3\u4eba\u4eec\u540c\u4e00\u9700\u6c42\u6216\u76f8\u4f3c\u9700\u6c42\u7684\u5546\u54c1\u3002 \u4e92\u8865\u4ea7\u54c1\uff1a\u914d\u5408\u4f7f\u7528
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_3","title":"\u9700\u6c42","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_4","title":"\u523b\u753b\u9700\u6c42","text":"
- \u6b63\u5e38\u5546\u54c1\u548c\u4f4e\u6863\u5546\u54c1 \u6d88\u8d39\u8005\u6536\u2f0a\u2f54\u5e73\u7684\u53d8\u5316\u4f1a\u5f15\u8d77\u5176\u5bf9\u67d0\u79cd\u5546\u54c1\u7684\u9700\u6c42\u53d1\u2f63\u540c\u2f45\u5411\u6216\u53cd\u2f45\u5411\u53d8\u5316\u3002\u5982\u679c\u6d88\u8d39\u8005\u6536\u2f0a\u2f54\u5e73\u7684\u53d8\u5316\u5f15\u8d77\u5bf9\u67d0\u79cd\u5546\u54c1\u7684\u9700\u6c42\u53d1\u2f63\u540c\u2f45\u5411\u53d8\u5316\uff0c\u5219\u8be5\u5546\u54c1\u662f\u6b63\u5e38\u5546\u54c1\uff08Normal Goods\uff09\uff1b\u5982\u679c\u6d88\u8d39\u8005\u6536\u2f0a\u2f54\u5e73\u7684\u53d8\u5316\u5f15\u8d77\u5bf9\u67d0\u79cd\u5546\u54c1\u7684\u9700\u6c42\u53d1\u2f63\u53cd\u2f45\u5411\u53d8\u5316\uff0c\u5219\u8be5\u5546\u54c1\u662f\u4f4e\u6863\u5546\u54c1\uff08Inferior Goods\uff09\u3002
image.png
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_5","title":"\u4e2a\u522b\u9700\u6c42\u548c\u5e02\u573a\u9700\u6c42","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_6","title":"\u4f9b\u7ed9","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_7","title":"\u523b\u753b","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/#_8","title":"\u5747\u8861\u4ef7\u683c","text":"
**\u4e2a\u522b\u9700\u6c42**
\u662f\u6307\u5355\u4e2a\u6d88\u8d39\u8005\u5728\u2f00\u5b9a\u65f6\u95f4\u5185\u5728\u6bcf\u2f00\u4e2a\u4ef7\u683c\u2f54\u5e73 \u4e0a\u5bf9\u67d0\u79cd\u5546\u54c1\u7684\u9700\u6c42\u91cf\u3002**\u5e02\u573a\u9700\u6c42**
\u5728\u2f00\u4e2a\u7279\u5b9a\u7684\u5e02\u573a\u4e2d\uff0c\u6240\u6709\u6d88\u8d39\u8005\u5728\u2f00\u5b9a\u65f6\u95f4\u5185\u5bf9\u67d0\u79cd\u5546\u54c1\u7684\u9700 \u6c42\u7684\u603b\u548c\uff0c\u79f0\u4e4b\u4e3a\u5e02\u573a\u9700\u6c42\uff08Market Demand\uff09\u3002"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/","title":"Chapter 2 \u6d88\u8d39\u8005\u7406\u8bba","text":"
- \u4e00\u4e2a\u5c0f\u65b9\u6cd5\uff1a\u76f4\u63a5\u8003\u8651\u6781\u9650\u7684\u60c5\u51b5
\u7ea6 1616 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 8 \u5206\u949f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_1","title":"\u57fa\u6570\u6548\u7528\uff1a\u8fb9\u9645\u6548\u7528\u5206\u6790","text":"\u6548\u7528\uff08utility\uff09\uff1a\u6d88\u8d39\u8005\u6d88\u8d39\u67d0\u79cd\u5546\u54c1\u6216\u52b3\u52a1\u800c\u5f97\u5230\u7684\u6ee1\u8db3\u3002\u5546\u54c1\u672c\u8eab\u7684\u6709\u7528\u6027\u6216\u4f7f\u7528\u4ef7\u503c\uff0c\u66f4\u662f\u6d88\u8d39\u8005\u5bf9\u6240\u6d88\u8d39\u5546\u54c1\u6216\u52b3\u52a1\u6ee1\u8db3\u81ea\u8eab\u6b32\u671b\u80fd\u529b\u7684\u4e00\u79cd\u4e3b\u89c2\u5fc3\u7406\u611f\u53d7\u6216\u8bc4\u4ef7 \u57fa\u6570\u6548\u7528\uff08Cardinal Utility\uff09\u7406\u8bba\u8ba4\u4e3a\uff0c\u4e00\u79cd\u5546\u54c1\u5bf9\u6d88\u8d39\u8005\u7684\u6548\u7528\u662f\u53ef\u4ee5\u7528\u57fa\u65701\uff0c2\uff0c3\uff0c4\u2026\u2026\u52a0\u4ee5\u6d4b\u91cf\uff0c\u5e76\u8ba1\u603b\u6c42\u548c\u7684\u3002 \u603b\u6548\u7528\uff08Total Utility, TU\uff09\u662f\u6307\u6d88\u8d39\u8005\u5728\u4e00\u5b9a\u65f6\u671f\u5185\u6d88\u8d39\u4e00\u5b9a\u91cf\u67d0\u5546\u54c1\u800c\u5f97\u5230\u7684\u6548\u7528\u603b\u548c\u6216\u603b\u7684\u6ee1\u8db3\u7a0b\u5ea6\uff1b \u8fb9\u9645\u6548\u7528\uff08Marginal Utility, MU\uff09\u662f\u6307\u4ece\u989d\u5916\u4e00\u5355\u4f4d\uff08\u6700\u540e\u4e00\u5355\u4f4d\uff09\u67d0\u79cd\u5546\u54c1\u7684\u6d88\u8d39\u4e2d\u6240\u83b7\u5f97\u7684\u989d\u5916\u7684\u6548\u7528\uff08\u6216\u6ee1\u8db3\u611f\uff09\u3002 \u4f8b\u5982\uff0c\u6d88\u8d393\u676f\u53ef\u4e50\u7684\u603b\u6548\u7528\u4e3a9\u6548\u7528\u5355\u4f4d\uff1b\u6d88\u8d394\u676f\u53ef\u4e50\u7684\u603b\u6548\u7528\u4e3a10\u6548\u7528\u5355\u4f4d\uff0c\u5219\u53ef\u4ee5\u77e5\u9053\u7b2c4\u676f\u53ef\u4e50\u7684\u8fb9\u9645\u6548\u7528\u4e3a1\u5355\u4f4d\uff0810\uff0d9\uff1d1\uff09\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_2","title":"\u8fb9\u9645\u6548\u7528","text":"\u8fb9\u9645\u6548\u7528\u9012\u51cf\u89c4\u5f8b : \u5176\u4ed6\u6761\u4ef6\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\uff0c\u6d88\u8d39\u8005\u8fde\u7eed\u6d88\u8d39\u67d0\u79cd\u5546\u54c1\u7684\u8fb9\u9645\u6548\u7528\uff0c\u5c06\u968f\u5176\u6d88\u8d39\u91cf\u7684\u589e\u52a0\u800c\u4e0d\u65ad\u51cf\u5c0f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_3","title":"\u5e8f\u6570\u6548\u7528\uff1a\u65e0\u5dee\u5f02\u66f2\u7ebf","text":"
- \u8fb9\u9645\u6548\u7528\u662f\u7279\u5b9a\u65f6\u95f4\u5185\u7684\u6548\u7528\uff0c\u4e5f\u5177\u6709\u65f6\u95f4\u6027\u3002
- \u5728\u5b9e\u9645\u4e2d\uff0c\u8fb9\u9645\u6548\u7528\u4e0d\u4f1a\u4e3a\u96f6\u6216\u8d1f\u503c\u3002\u56e0\u4e3a\u5fae\u89c2\u7ecf\u6d4e\u5b66\u5047\u8bbe\u6d88\u8d39\u8005\u662f\u7406\u6027\u7684\uff0c\u8ffd\u6c42\u603b\u6548\u7528\u6700\u5927\u5316\uff0c\u56e0\u6b64\uff0c\u5f53\u67d0\u4e00\u5546\u54c1\u7684\u8fb9\u9645\u6548\u7528\u63a5\u8fd1\u4e8e\u96f6\u65f6\uff0c\u6d88\u8d39\u8005\u5c06\u4e0d\u518d\u589e\u52a0\u6d88\u8d39\u91cf\u3002
\u4ee5\u4eba\u4eec\u7684\u6b32\u671b\u5f3a\u5ea6\u9012\u51cf\u548c\u6b32\u671b\u5f3a\u5ea6\u9971\u548c\u4e3a\u57fa\u7840\u7684
\u5e8f\u6570\u6548\u7528\uff08Ordinal Utility\uff09\u7406\u8bba\u8ba4\u4e3a\u4e00\u79cd\u5546\u54c1\u5bf9\u6d88\u8d39\u8005\u7684\u6548\u7528\uff0c\u6ca1\u6709\u4e00\u4e2a\u5ba2\u89c2\u7684\u8861\u91cf\u6807\u51c6\uff0c\u800c\u4e14\u53d7\u5230\u540c\u65f6\u6d88\u8d39\u7684\u6709\u5173\u5546\u54c1\u7684\u5f71\u54cd\u3002 \u4f46\u8be5\u7406\u8bba\u8ba4\u4e3a\uff0c\u4e00\u4e2a\u6d88\u8d39\u8005\u867d\u7136\u8bf4\u4e0d\u51fa\u5404\u79cd\u5546\u54c1\u7684\u6548\u7528\u5927\u5c0f\uff0c\u5374\u80fd\u591f\u660e\u786e\u6392\u51fa\u81ea\u5df1\u5bf9\u8fd9\u4e9b\u5546\u54c1\u7684\u504f\u597d\u6b21\u5e8f\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_4","title":"\u504f\u597d\u5047\u8bbe","text":"\u504f\u597d\u7684\u5b8c\u5907\u6027\uff1a\u6d88\u8d39\u8005\u9762\u4e34\u4e0d\u540c\u7684\u5546\u54c1\u7ec4\u5408\u65f6\uff0c\u5b8c\u5168\u80fd\u591f\u6309\u7167\u81ea\u8eab\u7684\u504f\u597d\u6392\u5217\u4e00\u4e2a\u987a\u5e8f\u3002 \u504f\u597d\u7684\u4f20\u9012\u6027\uff1a\u6d88\u8d39\u8005\u7684\u504f\u597d\u5177\u6709\u53ef\u4f20\u9012\u7684\u7279\u6027\uff0c\u5373\u504f\u597d\u5728\u903b\u8f91\u4e0a\u7684\u4e00\u81f4\u6027\u3002 \u504f\u597d\u7684\u975e\u9971\u548c\u6027(\u8d8a\u591a\u8d8a\u597d)\uff1a\u5bf9\u4e8e\u6d88\u8d39\u4e0d\u540c\u7ec4\u5408\u7684\u76f8\u540c\u5546\u54c1\uff0c\u6d88\u8d39\u8005\u603b\u662f\u504f\u597d\u6570\u91cf\u8f83\u591a\u7684\u4e00\u7ec4\u5546\u54c1\u3002- \u5047\u8bbe\u8fb9\u9645\u6548\u7528>0
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_5","title":"\u65e0\u5dee\u5f02\u66f2\u7ebf","text":"\u65e0\u5dee\u5f02\u66f2\u7ebf\uff08Indifference Curve\uff0cIC\uff09\u662f\u6307\u5728\u504f\u597d\u65e2\u5b9a\u7684\u6761\u4ef6\u4e0b\uff0c\u80fd\u591f\u7ed9\u6d88\u8d39\u8005\u5e26\u6765\u76f8\u540c\u603b\u6548\u7528\u7684\u6240\u6709\u4e24\u79cd\u5546\u54c1\u4e0d\u540c\u7ec4\u5408\u7684\u8fde\u7ebf\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_6","title":"\u8fb9\u9645\u66ff\u4ee3\u7387","text":"
- \u65e0\u5dee\u5f02\u66f2\u7ebf\u5411\u53f3\u4e0b\u65b9\u503e\u659c\uff0c\u5373\u659c\u7387\u4e3a\u8d1f\u3002
- \u4efb\u4f55\u4e24\u6761\u65e0\u5dee\u5f02\u66f2\u7ebf\u4e0d\u53ef\u80fd\u76f8\u4ea4\u3002
- \u79bb\u539f\u70b9\u8d8a\u8fdc\u7684\u65e0\u5dee\u5f02\u66f2\u7ebf\u4ee3\u8868\u7684\u6548\u7528\u6c34\u5e73\u8d8a\u9ad8\u3002
- \u51f8\u5411\u539f\u70b9\u7684\u7ebf\uff0c\u5373\u65e0\u5dee\u5f02\u66f2\u7ebf\u7684\u659c\u7387\u7684\u7edd\u5bf9\u503c\u662f\u9012\u51cf\u7684\u3002
\u5728\u4fdd\u6301\u603b\u6548\u7528\u6c34\u5e73\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\uff0c\u6d88\u8d39\u8005\u4e3a\u589e\u52a0\u4e00\u4e2a\u5355\u4f4d\u67d0\u2014\u5546\u54c1\u7684\u6d88\u8d39\u800c\u5fc5\u987b\u51cf\u5c11\u7684\u53e6\u4e00\u79cd\u5546\u54c1\u7684\u6d88\u8d39\u6570\u91cf\uff0c\u5c31\u662f\u5546\u54c1\u7684\u8fb9\u9645\u66ff\u4ee3\u7387\uff08Marginal Rate of Substitution\uff09\uff0c\u901a\u5e38\u7528MRS\u6765\u8868\u793a\u3002
MRS = \u659c\u7387\u7684\u7edd\u5bf9\u503c
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_7","title":"\u7279\u6b8a\u7c7b\u578b","text":"
- \u8fb9\u9645\u66ff\u4ee3\u7387\u4e5f\u53ef\u5199\u4f5c\u8fb9\u9645\u6548\u7528\u4e4b\u6bd4
- \u5b8c\u5168\u66ff\u4ee3\u54c1
\u5b8c\u5168\u66ff\u4ee3\u54c1\uff08Perfect Substitutes\uff09\u662f\u6307\u66ff\u4ee3\u6bd4\u4f8b\u56fa\u5b9a\u4e0d\u53d8\u7684\u4e24\u79cd\u5546\u54c1\u3002\u56e0\u6b64\uff0c\u5728\u5b8c\u5168\u66ff\u4ee3\u7684\u60c5\u51b5\u4e0b\uff0c\u4e24\u79cd\u5546\u54c1\u4e4b\u95f4\u7684\u8fb9\u9645\u66ff\u4ee3\u7387MRSXY\u5c31\u662f\u4e00\u4e2a\u5e38\u6570\uff0c\u76f8\u5e94\u7684\u65e0\u5dee\u5f02\u66f2\u7ebf\u662f\u4e00\u6761\u659c\u7387\u4e0d\u53d8\u7684\u76f4\u7ebf\u3002
- \u5b8c\u5168\u4e92\u8865\u54c1
\u5b8c\u5168\u4e92\u8865\u54c1\u3002\u5b8c\u5168\u4e92\u8865\u54c1\uff08Perfect Complements\uff09\u610f\u5473\u7740\u5fc5\u987b\u6309\u56fa\u5b9a\u4e0d\u53d8\u7684\u6bd4\u4f8b\u540c\u65f6\u4f7f\u7528\u7684\u4e24\u79cd\u5546\u54c1\u3002\u76f8\u5e94\u7684\u65e0\u5dee\u5f02\u66f2\u7ebf\u76f4\u89d2\u5f62\u72b6\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_8","title":"\u6d88\u8d39\u9884\u7b97\u7ebf","text":"\u6d88\u8d39\u8005\u5728\u8d2d\u4e70\u65f6\u603b\u8981\u53d7\u5230\u5236\u7ea6\uff0c\u5373\u4ed6\u4e0d\u5f97\u4e0d\u5728\u5546\u54c1\u4ef7\u683c\u65e2\u5b9a\u548c\u8d27\u5e01\u6536\u5165\u6709\u9650\u7684\u6761\u4ef6\u4e0b\u51b3\u5b9a\u81ea\u5df1\u7684\u6d88\u8d39\u884c\u4e3a\u3002
\u6d88\u8d39\u9884\u7b97\u7ebf\uff08Budget Line\uff09\u662f\u6307\u5728\u6d88\u8d39\u8005\u6536\u5165\u548c\u6240\u8d2d\u4e70\u5546\u54c1\u4ef7\u683c\u65e2\u5b9a\u7684\u6761\u4ef6\u4e0b\uff0c\u6d88\u8d39\u8005\u7528\u5168\u90e8\u6536\u5165\u6240\u80fd\u4e70\u5230\u7684\u4e24\u79cd\u5546\u54c1\u7684\u6700\u5927\u6570\u91cf\u7ec4\u5408\u7684\u8fde\u7ebf\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_9","title":"\u53d8\u5316","text":"\u91cd\u70b9\u5728\u4e8e\u641e\u6e05\u695a\u6d88\u8d39\u9884\u7b97\u7ebf\u662f\u5982\u4f55\u6765\u7684\uff0c\u8fd9\u6837\u5404\u79cd\u60c5\u51b5\u90fd\u5341\u5206\u6e05\u6670\u660e\u4e86
\u6536\u5165\u6c34\u5e73 \u548c \u5546\u54c1\u4ef7\u683c
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_10","title":"\u6d88\u8d39\u8005\u5747\u8861","text":"
- \u6536\u5165\u6c34\u5e73\u53d8\u5316\uff0c\u5f15\u8d77\u9884\u7b97\u7ebf\u4e0a\u4e0b\u79fb\u52a8
- \u5546\u54c1\u4ef7\u683c\u53d8\u5316\uff0c\u4e0e\u5750\u6807\u8f74\u4ea4\u70b9\u53d8\u5316
- \u540c\u65f6\u53d8\u5316\uff0c\u5177\u4f53\u5206\u6790\uff0c\u6ca1\u5fc5\u8981\u8bb0
\u6d88\u8d39\u8005\u884c\u4e3a\u7406\u8bba\u5047\u5b9a\uff0c\u6d88\u8d39\u8005\u4ee5\u603b\u6548\u7528\u6700\u5927\u5316\u4e3a\u76ee\u6807\u3002 \u6d88\u8d39\u8005\u5747\u8861\uff08Consumer Equilibrium\uff09\u662f\u6307\u6d88\u8d39\u8005\u5728\u6536\u5165\u548c\u5546\u54c1\u4ef7\u683c\u65e2\u5b9a\u7684\u6761\u4ef6\u4e0b\uff0c\u9009\u62e9\u8d2d\u4e70\u4e00\u5b9a\u6570\u91cf\u7684\u5546\u54c1\u7ec4\u5408\uff0c\u4ece\u800c\u83b7\u5f97\u6700\u5927\u6ee1\u8db3\u7684\u72b6\u6001\uff0c\u5373\u603b\u6548\u7528\u6700\u5927\u5316\u7684\u72b6\u6001\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_11","title":"\u9700\u6c42\u66f2\u7ebf\u7684\u63a8\u5bfc","text":"\u867d\u7136\u57fa\u6570\u6548\u7528\u8bba\u4e0e\u5e8f\u6570\u6548\u7528\u8bba\u6240\u63a8\u5bfc\u51fa\u6765\u7684\u9700\u6c42\u66f2\u7ebf\u7279\u5f81\u76f8\u540c\uff0c\u4f46\u4e24\u8005\u7684\u63a8\u5bfc\u65b9\u6cd5\u4e0d\u540c\u3002 \u524d\u8005\u5728\u6548\u7528\u53ef\u4ee5\u8861\u91cf\u548c\u8fb9\u9645\u6548\u7528\u9012\u51cf\u89c4\u5f8b\u7684\u5047\u5b9a\u6761\u4ef6\u4e0b\u63a8\u5bfc\u51fa\u9700\u6c42\u66f2\u7ebf\uff1b \u540e\u8005\u5219\u8ba4\u4e3a\u8fd9\u4e24\u4e2a\u5fc3\u7406\u5047\u8bbe\u65e0\u6cd5\u5f97\u5230\u5b9e\u8bc1\uff0c\u4ece\u800c\u8f6c\u5411\u7528\u6d88\u8d39\u8005\u504f\u597d\u6240\u51b3\u5b9a\u7684\u6548\u7528\u6c34\u5e73\u6216\u6ee1\u8db3\u987a\u5e8f\u6765\u4ee3\u66ff\u6548\u7528\u7684\u5177\u4f53\u8861\u91cf\uff0c\u7528\u5546\u54c1\u7684\u8fb9\u9645\u66ff\u4ee3\u7387\u9012\u51cf\u89c4\u5f8b\u6765\u53d6\u4ee3\u5546\u54c1\u7684\u8fb9\u9645\u6548\u7528\u9012\u51cf\u89c4\u5f8b\uff0c\u540c\u6837\u63a8\u5bfc\u51fa\u4e86\u5411\u53f3\u4e0b\u65b9\u503e\u659c\u7684\u9700\u6c42\u66f2\u7ebf\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_12","title":"\u6bd4\u8f83\u9759\u6001\u5206\u6790","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/#_13","title":"\u6536\u5165\u3001\u66ff\u4ee3\u4e0e\u4ef7\u683c\u6548\u5e94","text":"\u5b9e\u9645\u6536\u5165\u6c34\u5e73\u6216\u8d27\u5e01\u8d2d\u4e70\u529b\uff1a\u7528\u540c\u6837\u7684\u8d27\u5e01\u80fd\u591f\u8d2d\u5165\u7684\u5546\u54c1\u6570\u91cf\u8861\u91cf \u6536\u5165\u6548\u5e94\uff08Income Effect\uff09\u6d88\u8d39\u8005\u7684\u5b9e\u9645\u6536\u5165\u6c34\u5e73\u53d8\u5316\u6240\u5f15\u8d77\u7684\u5546\u54c1\u9700\u6c42\u91cf\u7684\u53d8\u5316\u3002\u5b9e\u9645\u6536\u5165\u6c34\u5e73\u53d7\u5546\u54c1\u4ef7\u683c\u548c\u6536\u5165\u7684\u5f71\u54cd \u66ff\u4ee3\u6548\u5e94\uff08Substitution Effect\uff09\u5b9e\u9645\u6536\u5165\u6c34\u5e73\u4e0d\u53d8\u7684\u6761\u4ef6\u4e0b\uff0c\u7531\u4e8e\u4e00\u79cd\u5546\u54c1\u7684\u4ef7\u683c\u53d8\u5316\u6216\u4e24\u79cd\u5546\u54c1\u4ef7\u683c\u7684\u53cd\u65b9\u5411\u53d8\u5316\uff0c\u4f7f\u5f97\u76f8\u5bf9\u4ef7\u683c\u53d1\u751f\u53d8\u5316\uff0c\u5bfc\u81f4\u6d88\u8d39\u8005\u589e\u52a0\u4ef7\u683c\u4e0b\u964d\u7684\u5546\u54c1\u7684\u9700\u6c42\u91cf\u4ee5\u66ff\u4ee3\u4ef7\u683c\u4e0a\u6da8\u7684\u5546\u54c1\uff0c\u8fd9\u4e00\u73b0\u8c61\u88ab\u79f0\u4e3a\u66ff\u4ee3\u6548\u5e94
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/","title":"Chapter 3 \u751f\u4ea7\u8005\u7406\u8bba","text":"\u7ea6 1264 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 6 \u5206\u949f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_1","title":"\u751f\u4ea7\u8005","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_2","title":"\u4f01\u4e1a","text":"
- \u72ec\u8d44\u4f01\u4e1a
\u200b \u72ec\u8d44\u4f01\u4e1a\u662f\u6307\u7531\u4e2a\u4eba\u51fa\u8d44\u548c\u4e2a\u4eba\u6240\u6709\u7684\u4f01\u4e1a\uff0c\u6240\u4ee5\u53c8\u79f0\u5355\u4e00\u4e1a\u4e3b\u5236\uff08Individual Proprietorship\uff09
- \u5408\u4f19\u4f01\u4e1a
- \u6709\u9650\u516c\u53f8 \u8d23\u4efb\u6709\u9650 \u80a1\u4efd\u6709\u9650
\u5171\u540c\u7279\u70b9
\uff081\uff09\u8d23\u4efb\u6709\u9650\uff0c\u6240\u6709\u6295\u8d44\u8005\uff08\u80a1\u4e1c\uff09\u7684\u8d23\u4efb\u4ec5\u9650\u4e8e\u6240\u6295\u5165\u7684\u8d44\u672c\uff1b
\uff082\uff09\u516c\u53f8\u5177\u6709\u8fde\u7eed\u6027\uff0c\u80a1\u4efd\u6301\u6709\u8005\u7684\u79bb\u53bb\u4e5f\u4e0d\u5f71\u54cd\u4f01\u4e1a\u6cd5\u4eba\u7684\u5b58\u5728\uff0c\u5373\u516c\u53f8\u662f\u72ec\u7acb\u4e8e\u80a1\u4efd\u6301\u6709\u8005\u7684\u6cd5\u4eba\uff1b
\uff083\uff09\u7531\u6295\u8d44\u8005\u9009\u51fa\u7684\u8463\u4e8b\u4f1a\u638c\u63e1\u516c\u53f8\u7684\u7ecf\u8425\u7ba1\u7406\u6743\uff0c\u5176\u4ed6\u4eba\u65e0\u6743\u884c\u4f7f\u516c\u53f8\u7ba1\u7406\u6743\u3002
\u4e3b\u8981\u533a\u522b
\uff081\uff09\u5728\u7ec4\u6210\u4f01\u4e1a\u7684\u6210\u5458\u6570\u76ee\u4e0a\uff0c\u6709\u9650\u8d23\u4efb\u516c\u53f8\u89c4\u5b9a\u662f2\u4eba\u4ee5\u4e0a\uff0c50\u4eba\u4ee5\u4e0b\uff0c\u800c\u80a1\u4efd\u6709\u9650\u516c\u53f8\u53ea\u89c4\u5b9a2\u4eba\u4ee5\u4e0a\uff0c\u4e0d\u89c4\u5b9a\u4f01\u4e1a\u6210\u5458\u6570\u76ee\u7684\u4e0a\u9650
\uff082\uff09\u5728\u6240\u6709\u6743\u8f6c\u8ba9\u65b9\u9762\uff0c\u6709\u9650\u8d23\u4efb\u516c\u53f8\u4e2d\u67d0\u4e2a\uff08\u4e9b\uff09\u80a1\u4efd\u6301\u6709\u8005\u987b\u5f81\u5f97\u5176\u4ed6\u80a1\u4efd\u6301\u6709\u8005\u7684\u540c\u610f\u624d\u80fd\u8f6c\u8ba9\u80a1\u4efd\uff0c\u800c\u80a1\u4efd\u6709\u9650\u516c\u53f8\u7684\u80a1\u4efd\u53ef\u7531\u6301\u80a1\u4eba\u81ea\u7531\u8f6c\u8ba9\u3002
\u4f01\u4e1a\u5b58\u5728\u7684\u4e00\u4e2a\u4e3b\u8981\u7406\u7531\u5c31\u662f\u901a\u8fc7\u4f01\u4e1a\u7684\u5185\u90e8\u534f\u8c03\u6765\u6d88\u9664\u5e02\u573a\u7684\u4ea4\u6613\u6210\u672c\uff0c\u4f01\u4e1a\u5c31\u662f\u4e3a\u4e86\u51cf\u5c11\u5e02\u573a\u4ea4\u6613\u6210\u672c\u800c\u4ea7\u751f\u7684\u66ff\u4ee3\u5e02\u573a\u7684\u4e00\u79cd\u7ec4\u7ec7\u5f62\u5f0f\u3002
\u5e02\u573a\u4ea4\u6613\u6210\u672c\u548c\u4f01\u4e1a\u7ec4\u7ec7\u534f\u8c03\u6210\u672c\u7684\u6982\u5ff5\u63d0\u51fa\u540e\uff0c\u751f\u4ea7\u8fc7\u7a0b\u4e2d\u7684\u67d0\u4e00\u73af\u8282\u3001\u67d0\u4e00\u9053\u5de5\u5e8f\u3001\u67d0\u4e00\u90e8\u4ef6\u3001\u67d0\u4e00\u4e2a\u96f6\u4ef6\u662f\u7531\u5e02\u573a\u4ea4\u6613\u6765\u534f\u8c03\uff0c\u8fd8\u662f\u7531\u4f01\u4e1a\u7684\u5185\u90e8\u7ec4\u7ec7\u7ba1\u7406\u6765\u534f\u8c03\uff0c\u5c31\u53d6\u51b3\u4e8e\u5e02\u573a\u4ea4\u6613\u6210\u672c\u5927\uff0c\u8fd8\u662f\u4f01\u4e1a\u7684\u7ec4\u7ec7\u534f\u8c03\u6210\u672c\u5927\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_3","title":"\u751f\u4ea7\u5206\u6790","text":"
\u751f\u4ea7\u8981\u7d20
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_4","title":"\u751f\u4ea7\u51fd\u6570","text":"
- \u8d44\u672c
- \u52b3\u52a8
- \u571f\u5730
- \u4f01\u4e1a\u5bb6\u624d\u80fd
\u4e00\u822c\u800c\u8a00\uff0c\u6211\u4eec\u53ea\u8003\u8651\u8d44\u672c\u548c\u52b3\u52a8\u7684\u6295\u5165\uff0c\u800c\u5ffd\u7565\u5176\u4ed6\u7684\u751f\u4ea7\u8981\u7d20
- \u56fa\u5b9a\u6bd4\u4f8b\u751f\u4ea7\u51fd\u6570\u548c\u53ef\u53d8\u6bd4\u4f8b\u751f\u4ea7\u51fd\u6570
\u7531\u8d44\u672c\u548c\u52b3\u52a8\u7684\u7ec4\u5408\u6bd4\u4f8b\u51b3\u5b9a \u52b3\u52a8 / \u8d44\u672c\u5bc6\u96c6\u578b\u751f\u4ea7\u65b9\u5f0f
- C-D\u51fd\u6570\uff08\u67ef\u5e03-\u9053\u683c\u62c9\u65af\uff09
\u200b Q = C L\u03b1 K\u03b2 \u90e8\u5206\u60c5\u51b5\u4e0b\u6ee1\u8db3 \u03b1 + \u03b2 = 1
- \u957f\u671f\u548c\u77ed\u671f\u751f\u4ea7\u51fd\u6570
\u77ed\u671f \u957f\u671f
\u5e76\u4e0d\u53ea\u662f\u4f9d\u636e\u65f6\u95f4\u957f\u77ed\uff0c\u5176\u533a\u5206\u4f9d\u8d56\u7684\u662f \u662f\u5426\u6240\u6709\u751f\u4ea7\u8981\u7d20\u90fd\u53d1\u751f\u53d8\u5316
\u53ef\u53d8\u751f\u4ea7\u8981\u7d20 \u56fa\u5b9a\u751f\u4ea7\u8981\u7d20
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_5","title":"\u77ed\u671f\u751f\u4ea7\u51fd\u6570","text":"\u603b\u4ea7\u91cf TP \u5e73\u5747\u4ea7\u91cf AP \u8fb9\u9645\u4ea7\u91cf MP
Q = f(K) or f(L)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_6","title":"\u8fb9\u9645\u62a5\u916c\u9012\u51cf","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_7","title":"\u957f\u671f\u751f\u4ea7\u51fd\u6570","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_8","title":"\u7b49\u4ea7\u91cf\u66f2\u7ebf","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_9","title":"\u8fb9\u9645\u6280\u672f\u66ff\u4ee3\u7387","text":"\u8fb9\u9645\u6280\u672f\u66ff\u4ee3\u7387 Marginal Rate of Technological Substitution
\\(MRTS_{LK} = - \\Delta K/\\Delta L = \\frac{MP_L}{MP_K} = \\frac{w}{k}\\)
\u6b64\u5904 w \u4e3a\u52b3\u52a8\u7684\u4ef7\u683c\uff0ck \u4e3a\u8d44\u672c\u7684\u4ef7\u683c \u7531\u4e8e K\u51cf\u5c11\u5e26\u6765\u7684\u4ea7\u91cf\u51cf\u5c11 \u5fc5\u7136\u7b49\u4e8e L\u589e\u52a0\u5e26\u6765\u7684\u4ea7\u91cf\u589e\u52a0 \\(-\\Delta K*MP_K = \\Delta L*MP_L\\) L\u5bf9K\u7684\u8fb9\u9645\u66ff\u4ee3\u7387 \u2014\u2014 \u589e\u52a0 1 \u5355\u4f4d L \u53ef\u4ee5\u5e26\u6765 K\u7684\u53d8\u5316
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_10","title":"\u6700\u4f18\u5316","text":"
- \u603b\u4ea7\u91cf\u4e00\u5b9a\uff0c\u6210\u672c\u6700\u4f4e
- \u6210\u672c\u4e00\u5b9a\uff0c\u603b\u4ea7\u91cf\u6700\u5927
Example
\\(\u5229\u7528\u504f\u5bfc \u6c42\u51faMP_L \u548cMP_K\u8981\u6ce8\u610f\u4ed6\u4eec\u90fd\u662f\u5173\u4e8eQ\u7684\u51fd\u6570\uff0c\u5373Q=f(K,L)\\) \\(\u4e4b\u540e\u5229\u7528 MRTS_{LK} = \\frac{w}{k}\\)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_11","title":"\u7b49\u6210\u672c\u65b9\u7a0b","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_12","title":"\u6210\u672c\u5206\u6790","text":"\u4f1a\u8ba1\u6210\u672c\u4e0d\u8ba1\u7b97\u9690\u6027\u6210\u672c
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_13","title":"\u77ed\u671f\u6210\u672c","text":"\u8fd9\u91cc\u63cf\u8ff0\u7684\u662f\u6210\u672c\u548c\u4ea7\u91cf\u7684\u5173\u7cfb C = f\uff08Q\uff09
\u77ed\u671f\u603b\u6210\u672c TC \u603b\u56fa\u5b9a\u6210\u672c FC \u603b\u53ef\u53d8\u6210\u672c VC \u77ed\u671f\u5e73\u5747\u6210\u672c AC \u5e73\u5747\u56fa\u5b9a\u6210\u672c AFC \u5e73\u5747\u53ef\u53d8\u6210\u672c AVC \u77ed\u671f\u8fb9\u9645\u6210\u672c MC
TC = FC + VC
\\(MC = \\frac{\\Delta TC}{\\Delta Q}=\\frac{\\Delta VC}{\\Delta Q}\\)
- \u968f\u7740\u4ea7\u91cf\u7684\u589e\u52a0\uff0cSMC\u66f2\u7ebf\u4e0eAVC\u66f2\u7ebf\u548cSAC\u66f2\u7ebf\u5148\u540e\u76f8\u4ea4\u4e8eAVC\u66f2\u7ebf\u548cSAC\u66f2\u7ebf\u7684\u6700\u4f4e\u70b9E\u70b9\u548cF\u70b9\u3002
SMC
\u5148\u4e0b\u964d\u540e\u4e0a\u5347Q : \u603b\u53ef\u53d8\u6210\u672c\u4e3a\u4ec0\u4e48\u5148\u4ee5\u9012\u51cf\u7684\u901f\u5ea6\u589e\u52a0\u540e\u53c8\u4ee5\u9012\u589e\u7684\u901f\u5ea6\u589e\u52a0?
A : \u4ece\u751f\u4ea7\u51fd\u6570\u8fdb\u884c\u5206\u6790\uff0c\u6210\u672c\u51fd\u6570\u5c31\u662f\u751f\u4ea7\u51fd\u6570\u7684\u201c\u53cd\u8f6c\u201d
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_14","title":"\u957f\u671f\u6210\u672c\u51fd\u6570","text":"\u957f\u671f\u603b\u6210\u672c \uff1a LTC \u957f\u671f\u5e73\u5747\u6210\u672c\uff1a LAC \u957f\u671f\u8fb9\u9645\u6210\u672c\uff1aLMC
\u957f\u671f\u662f\u7531\u65e0\u6570\u4e2a\u77ed\u671f\u7ec4\u6210\u7684\uff0c\u56e0\u6b64\uff0c\u6240\u6709\u7684\u957f\u671f\u6210\u672c\u6216\u957f\u671f\u6210\u672c \u66f2\u7ebf\u90fd\u53ef\u4ee5\u4ece\u77ed\u671f\u6210\u672c\u6216\u77ed\u671f\u6210\u672c\u66f2\u7ebf\u4e2d\u63a8\u5bfc\u51fa\u6765\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_15","title":"\u89c4\u6a21\u7ecf\u6d4e","text":"
- \u7531\u77ed\u671f\u5e73\u5747\u6210\u672c\u66f2\u7ebf\u63a8\u5bfc
\u5982\u679c\u91c7\u7528Q = aL\u03b1K\u03b2\u7684\u9053\u683c\u62c9\u65af\u51fd\u6570\uff0c\u90a3\u4e48\u6211\u4eec\u53ef\u4ee5\u5f97\u5230\uff1a \u751f\u4ea7\u89c4\u6a21\u6269\u5927x\u500d\u540e\uff0cQ = a X\u03b1+\u03b2L\u03b1K\u03b2
\u4e5f\u5c31\u662f\u8bf4\uff0c\u03b1+\u03b2 = \u4e0a\u56fe\u4e2d\u7684 n
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_16","title":"\u89c4\u6a21\u7ecf\u6d4e","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/#_17","title":"\u8ba1\u7b97","text":"Q = aL\u03b1K\u03b2 C = aL + bK \u6c42C(Q) ,\u4e5f\u5c31\u662f\u6c42\u6210\u672c\u51fd\u6570\uff0c\u5c31\u662f\u5728Q\u7684\u6761\u4ef6\u7ea6\u675f\u4e0b\uff0c\u6c42\u51faC\u7684\u6700\u5c0f\u503c
- \u62c9\u683c\u6717\u65e5\u51fd\u6570
- \u76f4\u63a5\u4f7f\u7528\u6700\u4f18\u89e3\u7684\u6761\u4ef6\uff0c\u4e5f\u5c31\u662f\u8fb9\u9645\u4e4b\u6bd4 = K L\u4ef7\u683c\u4e4b\u6bd4
\u5047\u8bbe\u67d0\u4f01\u4e1a\u751f\u4ea7\u51fd\u6570Q=KL\uff0c\u5176\u4e2dK\u3001L\u5206\u522b\u4e3a\u8d44\u672c\u3001\u52b3\u52a8\u6295\u5165\u91cf\uff0c\u5176\u4ef7\u683c\u5206\u522br\u3001w\uff0c\u8bd5\u6c42\u8be5\u4f01\u4e1a\u7684\u6210\u672c\u51fd\u6570\u548c\u8fb9\u9645\u6210\u672c\u51fd\u6570\u3002
MC = C`(Q)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/","title":"Chapter 4 \u5f39\u6027\u7406\u8bba","text":"\u7ea6 307 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_1","title":"\u6982\u5ff5\u533a\u5206","text":"
- \u9700\u6c42\u5f39\u6027 \u9700\u6c42\u4ef7\u683c\u5f39\u6027
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_2","title":"\u9700\u6c42\u7684\u4ef7\u683c\u5f39\u6027","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_3","title":"\u8ba1\u7b97","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_4","title":"\u4e0e\u603b\u6536\u76ca\u7684\u5173\u7cfb","text":"
\u9700\u6c42\u5f39\u6027
\uff1a\u7528\u6765\u8861\u91cf\u6d88\u8d39\u8005\u5bf9\u5546\u54c1\u4ef7\u683c\u3001\u66ff\u4ee3\u54c1\u4ef7\u683c\u3001\u6536\u5165\u7b49\u53d8\u91cf\u53d8\u52a8\u7684\u53cd\u5e94\u7a0b\u5ea6\u9700\u6c42\u4ef7\u683c\u5f39\u6027
\uff08Price Elasticity of Demand\uff09\uff1a\u8861\u91cf\u9700\u6c42\u91cf\u5bf9\u4ef7\u683c\u53d8\u52a8\u7684\u53cd\u5e94\u7a0b\u5ea6\uff0c\u5373\u67d0\u79cd\u5546\u54c1\u9700\u6c42\u91cf\u53d8\u52a8\u7684\u767e\u5206\u6bd4\u4e0e\u5176\u4ef7\u683c\u53d8\u52a8\u7684\u767e\u5206\u6bd4\u4e4b\u6bd4"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_5","title":"\u5f71\u54cd\u56e0\u7d20","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_6","title":"\u4ea4\u53c9","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/#_7","title":"\u9700\u6c42\u7684\u6536\u5165\u5f39\u6027","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/","title":"Chapter 5 \u5b8c\u5168\u7ade\u4e89\u5e02\u573a","text":"
TR = P * Qd
\u82e5\u9500\u552e\u8fd9\u79cd\u5546\u54c1\u7684\u603b\u6536\u76ca\u4e0e\u5176\u4ef7\u683c\u6210\u53cd\u5411\u53d8\u52a8\uff0c\u5373\u4ef7\u683c\u4e0b\u964d\u603b\u6536\u76ca\u589e\u52a0\uff0c\u4ef7\u683c\u4e0a\u6da8\u603b\u6536\u76ca\u51cf\u5c11\uff0c\u5219\u8be5\u5546\u54c1\u5c5e\u4e8e\u9700\u6c42\u5bcc\u6709\u5f39\u6027\u7684\u5546\u54c1\uff1b\u82e5\u9500\u552e\u8fd9\u79cd\u5546\u54c1\u7684\u603b\u6536\u76ca\u4e0e\u5176\u4ef7\u683c\u53d8\u52a8\u2f46\u5173\uff0c\u8bf4\u660e\u2f46\u8bba\u4ef7\u683c\u4e0a\u6da8\u6216\u4e0b\u964d\uff0c\u603b\u6536\u76ca\u90fd\u4e0d\u53d8\uff0c\u5219\u8be5\u5546\u54c1\u7684\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u4e3a\u5355\u4f4d\u5f39\u6027\uff1b\u82e5\u9500\u552e\u8fd9\u79cd\u5546\u54c1\u7684\u603b\u6536\u76ca\u4e0e\u5176\u4ef7\u683c\u6210\u540c\u2f45\u5411\u53d8\u52a8\uff0c\u5373\u4ef7\u683c\u4e0b\u964d\u603b\u6536\u76ca\u4e0b\u964d\uff0c\u4ef7\u683c\u4e0a\u6da8\u603b\u6536\u76ca\u4e5f\u589e\u52a0\uff0c\u5219\u8be5\u5546\u54c1\u5c5e\u4e8e\u9700\u6c42\u7f3a\u4e4f\u5f39\u6027\u7684\u5546\u54c1\u3002 \u7b56\u7565\uff1a\u65e0\u5f39\u6027 \u63d0\u4ef7 \u6709\u5f39\u6027 \u964d\u4ef7\u7ea6 966 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 5 \u5206\u949f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_1","title":"\u57fa\u672c\u7279\u5f81","text":"\u5224\u65ad\u4e0d\u540c\u5e02\u573a\u7684\u6807\u51c6 \uff081\uff09\u4ea4\u6613\u8005\u7684\u6570\u91cf\uff1b \uff082\uff09\u4ea4\u6613\u5546\u54c1\u7684\u6027\u8d28\uff1b \uff083\uff09\u8fdb\u5165\u5e02\u573a\u6709\u65e0\u969c\u788d\uff1b \uff084\uff09\u4ea4\u6613\u8005\u6240\u5f97\u5230\u7684\u4fe1\u606f\u662f\u5426\u5b8c\u5168\u3002
\u4f01\u4e1a\u9762\u4e34\u4e24\u79cd\u7ea6\u675f\uff1a
- \u6280\u672f\u7ea6\u675f\uff1a\u7528\u751f\u4ea7\u51fd\u6570\u6216\u6210\u672c\u51fd\u6570\u52a0\u4ee5\u6982\u62ec
- \u5e02\u573a\u7ea6\u675f\uff1a\u7528\u5e02\u573a\u7ed3\u6784\u6216\u9700\u6c42\u66f2\u7ebf\u52a0\u4ee5\u6982\u62ec
\u5206\u7c7b
\u5b8c\u5168\u7ade\u4e89\u7684\u7279\u5f81
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_2","title":"\u5382\u5546\u6536\u76ca\u66f2\u7ebf","text":"
- \u5b58\u5728\u7740\u5927\u91cf\u7684\u5356\u8005\u548c\u4e70\u8005\uff08Price taker\uff09 \u8fd9\u610f\u5473\u7740\uff0c\u5356\u5bb6\u548c\u4e70\u5bb6\u90fd\u65e0\u6cd5\u5355\u72ec\u5730\u51b3\u5b9a\u5546\u54c1\u7684\u5b9a\u4ef7\uff0c\u4ed6\u4eec\u90fd\u662f\u5e02\u573a\u4ef7\u683c\u7684\u88ab\u52a8\u63a5\u53d7\u8005
- \u9500\u552e\u7684\u4ea7\u54c1\u662f\u540c\u8d28\u7684 \u4e0d\u6b62\u7269\u7406\u7279\u6027\u76f8\u540c\uff0c\u5176\u4ed6\u5c5e\u6027\u4e5f\u5e94\u8be5\u662f\u76f8\u540c\u7684
- \u8d44\u6e90\u7684\u6d41\u52a8\u4e0d\u53d7\u9650\u5236\uff08\u8fdb\u51fa\u5e02\u573a\u4e0d\u53d7\u9650\u5236\uff09
- \u4fe1\u606f\u5b8c\u5168 \u6240\u6709\u51b3\u7b56\u8005\u90fd\u62e5\u6709\u5b8c\u5168\u7684\u5bf9\u8fc7\u53bb\u3001\u73b0\u5728\u3001\u672a\u6765\u7684\u4fe1\u606f
\u6536\u76ca\u90e8\u5206 \\(R = PQ = P(Q) * Q\\) \\(AR = \\frac{R}{Q} = P(Q)\\) \\(MR= \\frac{dR}{dQ}=\\frac{dP(Q)}{dQ}*Q+P(Q)\\)
\u5229\u6da6\u51fd\u6570 \\(\\pi(Q)=R(Q)-C(Q)\\) \u6700\u5927\u5316\u6761\u4ef6 \\(MR(Q)=MC(Q)\\)
\u5bf9\u5b8c\u5168\u7ade\u4e89\u800c\u8a00 \\(P(Q)=P_0 \\ \u59cb\u7ec8\u4e0d\u53d8\\)\uff08\u4ed6\u4eec\u90fd\u662f
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_3","title":"\u77ed\u671f\u4f9b\u7ed9\u4e0e\u5747\u8861","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_4","title":"\u5382\u5546","text":"Price Taker
\uff09 \u4e8e\u662f\u53ef\u4ee5\u63a8\u51fa \\(MC = MR = P_0\\)\u4e00\uff1a\u603b\u91cf\u5206\u6790 \u7565 \u4e8c\uff1a\u8fb9\u9645\u5206\u6790 \u5206\u4e3a\u4e09\u79cd\u60c5\u51b5\uff1a
- \\(P > min(AC)\\)
- \\(P = min(AC)\\) \\(E_2\\) \u76c8\u4e8f\u5e73\u8861\u70b9
- \\(P < min(AC)\\) \u4e8f\u635f\u51b3\u7b56 \uff08\u5173\u952e\u5728\u4e8e\u80fd\u5426cover\u5168\u90e8\u7684AVC\u53ef\u53d8\u751f\u4ea7\u6210\u672c\uff09
- \\(q_3:AC>P>AVC\\) \u7ee7\u7eed\u8425\u4e1a\uff0c
- \\(q_4:AC>P=AVC\\) \u505c\u4e1a\u8425\u4e1a\u70b9
\\(q_5:P<AVC\\) \u505c\u6b62\u8425\u4e1a
\u5229\u6da6\u6700\u5927\u5316\u4e0e\u5b9e\u9645\u5229\u6da6\u591a\u5c11\u65e0\u5173\uff0c\u5b9e\u9645\u5229\u6da6\u9700\u8981\u8003\u8651
AC
\u4e0e\u4e4b\u7684\u5927\u5c0f\u5173\u7cfb\u77ed\u671f\u4f9b\u7ed9\u66f2\u7ebf
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_5","title":"\u5382\u5546\u5230\u5e02\u573a","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_6","title":"\u5269\u4f59\u4ef7\u503c","text":"
- \u505c\u6b62\u8425\u4e1a\u70b9\u4e4b\u4e0a\u7684\u90e8\u5206
- \u751f\u4ea7\u8005\u5269\u4f59\uff1a\u4efb\u610f\u4e00\u4e2a\u751f\u4ea7\u8005\u5728\u751f\u4ea7\u548c\u51fa\u552e\u5546\u54c1\u65f6\u5f97\u5230\u7684\u5b9e\u9645\u6536\u76ca\u548c\u610f\u613f\u6536\u76ca\uff08\u5373\u4ed6\u613f\u610f\u63a5\u53d7\u7684\u6700\u5c0f\u6536\u76ca\uff09\u4e4b\u95f4\u5e38\u5e38\u4e5f\u5b58\u5728\u4e00\u5b9a\u7684\u5dee\u989d\u3002
- \u6d88\u8d39\u8005\u5269\u4f59\uff1a\u4efb\u610f\u4e00\u4e2a\u6d88\u8d39\u8005\u5728\u8d2d\u4e70\u5546\u54c1\u65f6\u7684\u610f\u613f\u652f\u4ed8\uff08\u5373\u4ed6\u613f\u610f\u652f\u4ed8\u7684\u6700\u9ad8\u4ee3\u4ef7\uff09\u4e0e\u5b9e\u9645\u652f\u4ed8\u4e4b\u95f4\u5e38\u5e38\u5b58\u5728\u4e00\u5b9a\u7684\u5dee\u989d\u3002
- \u5e02\u573a\u603b\u5269\u4f59\uff1a\u4e8c\u8005\u603b\u548c
\u751f\u4ea7\u8005\u5269\u4f59\u4e0e\u5229\u6da6\u76f8\u5173\uff0c\u4f46\u5e76\u4e0d\u76f8\u540c
\\(\u751f\u4ea7\u8005\u5269\u4f59 = TR - TVC\\) \\(\u5229\u6da6\\pi=TR-TC=TR-TVC-TFC\\)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_7","title":"\u957f\u671f\u5747\u8861","text":"\u6240\u6709\u751f\u4ea7\u8981\u7d20\u7684\u8c03\u6574\u53ef\u4ee5\u8868\u73b0\u5728\u4e24\u4e2a\u65b9\u9762\uff1a
\u4e00\u662f\u5382\u5546\u81ea\u7531\u5730\u8fdb\u5165\u6216\u9000\u51fa\u67d0\u4e00\u884c\u4e1a\uff0c\u5373\u884c\u4e1a\u5185\u5382\u5546\u6570\u76ee\u7684\u8c03\u6574\uff1b \u4e8c\u662f\u5382\u5546\u5bf9\u81ea\u8eab\u751f\u4ea7\u89c4\u6a21\u7684\u8c03\u6574\u3002
\u5b8c\u5168\u7ade\u4e89\u5382\u5546\u7684\u957f\u671f\u5747\u8861\u5c31\u662f\u901a\u8fc7\u8fd9\u4e24\u65b9\u9762\u7684\u8c03\u6574\u800c\u5b9e\u73b0\u7684\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_8","title":"\u5382\u5546","text":"\u6570\u76ee\u53d8\u5316
- \u5047\u8bbe\uff0c\u6700\u521d\\(P_0,Q_0\\)\u4e3a\u5747\u8861\u503c\uff0c\u7531\u4e8e\\(P_0>AC\\)\uff0c\u5728\u5de8\u989d\u5229\u6da6\u5f71\u54cd\u4e0b\u65b0\u5382\u5546\u8fdb\u5165
- \u4f9b\u5e94\u79fb\u52a8\u81f3\\(S_2\\)\u66f2\u7ebf\uff0c\u5e73\u8861\u53d8\u5316
- \u6700\u7ec8\u5e73\u8861\u4f4d\u7f6e\u5728E\u70b9
\u89c4\u6a21\u8c03\u6574
- \u957f\u671f\u7684\u89c4\u6a21\u8c03\u6574\uff0c\u6216\u957f\u671f\u7684\u5229\u6da6\u6700\u5927\u5316\uff0c\u5c31\u662f\u5728\u6240\u6709\u7684\u77ed\u671f\u5747\u8861\u4e2d\u9009\u62e9\u4e00\u4e2a\u201c\u6700\u4f18\u201d\u7684\u77ed\u671f\u5747\u8861\u3002
\u5747\u8861\u6761\u4ef6
\\(P\uff1dLMC\uff1dLAC\uff1dSMC\uff1dSAC\\)
\u8fb9\u9645\u6210\u672c = \u5e02\u573a\u4ef7\u683c = \u5e73\u5747\u6210\u672c ==> \u6548\u7387\u9ad8
\u6b64\u65f6\uff0c\\(LMC =0,LAC\u53d6\u6700\u5c0f\u503c\\)
\u957f\u671f\u5747\u8861\u610f\u5473\u7740\u5382\u5546\u7684\u603b\u5229\u6da6\u4e3a0\uff0c\u5426\u5219\u5176\u4ed6\u5382\u5546\u4f1a\u76f8\u5e94\u4f5c\u51fa\u53cd\u5e94\uff0c\u5bfc\u81f4\u5747\u8861\u53d8\u5316
\u6bd4\u5982\uff0c\u5229\u6da6 > 0, \u65b0\u5382\u5546\u8fdb\u5165\uff0c\u4ef7\u683c\u964d\u4f4e\uff0c\u5229\u6da6\u4e0b\u964d \u5229\u6da6<0\uff0c\u539f\u5382\u5546\u9000\u51fa\uff0c\u4ef7\u683c\u4e0a\u5347\uff0c\u5355\u4e2a\u5382\u5546\u4e8f\u635f\u51cf\u5c11\uff0c\u76f4\u81f3\u4e8f\u635f\u4e3a0\uff0c\u4e0d\u518d\u9000\u51fa
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_9","title":"\u884c\u4e1a","text":"\u5728\u957f\u671f\u4e2d\uff0c\u5b8c\u5168\u7ade\u4e89\u884c\u4e1a\u7684\u6210\u672c\u53ef\u80fd\u662f\u4e0d\u53d8\u7684\uff0c\u9012\u589e\u7684\uff0c\u9012\u51cf\u7684
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_10","title":"\u6210\u672c\u4e0d\u53d8","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_11","title":"\u4f8b\u9898","text":"
- \\(S_0,D_0\\)\u4e3a\u6700\u521d\u7684\u5e73\u8861
- \u5047\u8bbe\u9700\u6c42\u589e\u52a0\u4e3a\\(D_1\\)\uff0c\u77ed\u671f\u5185\u4f9b\u7ed9\u4e0d\u53d8\uff0c
- \u7531\u4e8e\u5de8\u989d\u5229\u6da6\uff0c\u5382\u5546\u8fdb\u5165\uff0c\u4f9b\u7ed9\u53d8\u4e3a\\(S_1\\)
(1) MC = P , \u03a0 = q * P - STC (2) min(SAC) = min(SVC / q) \u6ce8\u610f\u533a\u5206SVC\u548cFC \u6bd4\u5982\u8fd9\u91cc\u7684STC = SFC + SVC, SFC\u5373\u4e3a\u5e38\u6570 (3) MC with limitation(P > P0)
( 1 ) LAC \u53d6min\u65f6\uff0c\u6c42\u51fa\u4ea7\u91cfq \u5747\u8861\u65f6 P = LAC \u5047\u8bbe\u6210\u672c\u4e0d\u53d8\uff0c\u53ef\u5f97\u957f\u671f\u4f9b\u7ed9\u51fd\u6570\u4e3a\u4e00\u6761\u76f4\u7ebf D = (LAC)min
(2) n\u4e3a\u5382\u5546\u6570\u76ee,q\u4e3aLAC\u53d6min\u65f6\u7684\u4ea7\u91cf QD==QS==q*n
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/","title":"Chapter 6 \u4e0d\u5b8c\u5168\u7ade\u4e89\u5e02\u573a","text":"\u7ea6 2834 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 14 \u5206\u949f
\u4e0d\u5b8c\u5168\u7ade\u4e89\uff1a\u5b8c\u5168\u5784\u65ad\u3001\u5be1\u5934\u5784\u65ad\u3001\u5784\u65ad\u7ade\u4e89\u5e02\u573a
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_1","title":"\u5b8c\u5168\u5784\u65ad\u5e02\u573a","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_2","title":"\u7279\u5f81\u4e0e\u6210\u56e0","text":"\u7279\u5f81 \u5b8c\u5168\u5784\u65ad\u901a\u5e38\u7b80\u79f0\u5784\u65ad\u3002\u5728\u5356\u65b9\u5e02\u573a\u4e0a\uff0c\u5b8c\u5168\u5784\u65ad\uff08Monopoly\uff09\u662f\u6307\u4e00\u4e2a\u884c\u4e1a\u53ea\u6709\u552f\u4e00\u4e00\u5bb6\u5382\u5546\u7684\u5e02\u573a\u7ed3\u6784\u3002
- \u4e00\u4e2a\u884c\u4e1a\u4e2d\u53ea\u6709\u4e00\u5bb6\u5382\u5546\u751f\u4ea7\u548c\u9500\u552e\u5168\u90e8\u4ea7\u54c1\uff0c\u800c\u6d88\u8d39\u8005\u7684\u6570\u76ee\u4f17\u591a\u3002
- \u5382\u5546\u751f\u4ea7\u548c\u9500\u552e\u7684\u4ea7\u54c1\u4e0d\u5b58\u5728\u4efb\u4f55\u63a5\u8fd1\u7684\u66ff\u4ee3\u54c1\u3002\u5982\u679c\u5b58\u5728\u66ff\u4ee3\u54c1\u7684\u8bdd\uff0c\u8be5\u5382\u5546\u5c31\u4e0d\u5f97\u4e0d\u9762\u4e34\u5176\u4ed6\u5382\u5546\u7684\u7ade\u4e89\u800c\u6ca1\u6709\u5b8c\u5168\u63a7\u5236\u5e02\u573a\u7684\u80fd\u529b\u3002
- \u884c\u4e1a\u4e2d\u5b58\u5728\u7740\u4e25\u683c\u7684\u8fdb\u5165\u58c1\u5792\uff0c\u5176\u4ed6\u5382\u5546\u8981\u8fdb\u5165\u8be5\u884c\u4e1a\u6781\u5176\u56f0\u96be\uff0c\u751a\u81f3\u662f\u4e0d\u53ef\u80fd\u7684
\u5206\u7c7b
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_3","title":"\u6536\u76ca\u66f2\u7ebf","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_4","title":"\u5747\u8861","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_5","title":"\u77ed\u671f\u5747\u8861","text":"
- \u8d44\u6e90\u5784\u65ad \uff1a\u4e3b\u8981\u6307\u539f\u6599\u7684\u63a7\u5236
- \u7279\u8bb8\u5784\u65ad
- \u4e13\u5229\u5784\u65ad
- \u81ea\u7136\u5784\u65ad\uff1a\u4e00\u5bb6\u5382\u5546\u80fd\u4ee5\u6700\u4f4e\u6210\u672c\u6ee1\u8db3\u6574\u4e2a\u5e02\u573a\u5bf9\u67d0\u4e00\u4ea7\u54c1\u7684\u9700\u6c42\uff0c\u8be5\u5382\u5546\u5c31\u80fd\u53d6\u5f97\u5e02\u573a\u7684\u5784\u65ad\u5730\u4f4d\u3002\u7531\u4e8e\u89c4\u6a21\u7ecf\u6d4e\u5bfc\u81f4\u7684\u5784\u65ad
- \u6ee1\u8db3\u5747\u8861\u7684\u6761\u4ef6\uff1a\\(SMC=MR\\)
- \u77ed\u671f\u5185\uff0c\u751f\u4ea7\u89c4\u6a21\u4e0d\u53d1\u751f\u53d8\u5316\uff0c\u4e5f\u5c31\u662fSMC\u548cSAC\u4e0d\u53d8\uff1b\u901a\u8fc7\u6539\u53d8\u4ef7\u683c\u548c\u4ea7\u91cf\u8fdb\u884c\u5747\u8861\u8c03\u6574
- \u4e8f\u635f\u662f\u5426\u7ee7\u7eed\u751f\u4ea7\uff1f
- \u540c\u5b8c\u5168\u7ade\u4e89\u6761\u4ef6\u4e0b\uff1a\u4e0eAVC\u6bd4\u8f83
\u4f9b\u7ed9\u7684\u95ee\u9898
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_6","title":"\u957f\u671f\u5747\u8861","text":"\u957f\u671f\u5747\u8861\u5c31\u662f\u5bfb\u627e\u6700\u4f18\u77ed\u671f\u5747\u8861\u7684\u8fc7\u7a0b
\u5747\u8861\u6761\u4ef6 \uff1a \\(LMC = MR=SMC\\)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_7","title":"\u4ef7\u683c\u6b67\u89c6","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_8","title":"\u5f62\u6210","text":"\u5b9e\u884c\u4ef7\u683c\u6b67\u89c6\u9700\u8981\u4e09\u4e2a\u57fa\u672c\u6761\u4ef6\uff1a
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_9","title":"\u7279\u5f81","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_10","title":"\u4e00\u7ea7\u4ef7\u683c\u6b67\u89c6","text":"
\u7b2c\u4e00\uff0c\u5382\u5546\u5fc5\u987b\u62e5\u6709\u4e00\u5b9a\u7684\u5e02\u573a\u529b\u91cf\uff0c\u5373\u80fd\u591f\u5c06\u4ef7\u683c\u5b9a\u4e8e\u8fb9\u9645\u6210\u672c\u4e4b\u4e0a\uff0c\u5426\u5219\u7ade\u4e89\u8005\u80fd\u591f\u4ee5\u7ade\u4e89\u4ef7\u683c\u7834\u574f\u4ef7\u683c\u6b67\u89c6\uff1b
\u7b2c\u4e8c\uff0c\u5546\u54c1\u80fd\u591f\u5728\u4e24\u4e2a\u6216\u4e24\u4e2a\u4ee5\u4e0a\u88ab\u5206\u5272\u7684\u5e02\u573a\u4e0a\u51fa\u552e\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u6d88\u8d39\u8005\u4e0d\u53ef\u80fd\u8f7b\u800c\u6613\u4e3e\u5730\u5c06\u5546\u54c1\u5728\u4e0d\u540c\u7684\u5e02\u573a\u4e4b\u95f4\u8fdb\u884c\u5012\u5356\u3002\u5426\u5219\uff0c\u4e0d\u540c\u5e02\u573a\u7684\u4ef7\u683c\u4f1a\u56e0\u4e3a\u5546\u54c1\u5012\u5356\u800c\u8d8b\u4e8e\u76f8\u7b49\uff1b
\u7b2c\u4e09\uff0c\u4e0d\u540c\u5e02\u573a\u7684\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u4e0d\u540c\u3002\u5bf9\u4e8e\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u8f83\u5927\u7684\u5e02\u573a\uff0c\u4ef7\u683c\u5b9a\u5f97\u8f83\u4f4e\uff1b\u800c\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u8f83\u5c0f\u7684\u5e02\u573a\uff0c\u4ef7\u683c\u5b9a\u5f97\u8f83\u9ad8\u3002\u5982\u679c\u4e0d\u540c\u5e02\u573a\u7684\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u76f8\u540c\uff0c\u90a3\u4e48\u5229\u6da6\u6700\u5927\u5316\u7684\u4e0d\u540c\u5e02\u573a\u7684\u4ef7\u683c\u4e5f\u4f1a\u4e00\u6837\u3002
\u6240\u8c13\u4e00\u7ea7\u4ef7\u683c\u6b67\u89c6\uff08First-degree Price Discriminations\uff09\u662f\u6307\u5784\u65ad\u5382\u5546\u5411\u8d2d\u4e70\u5546\u54c1\u7684\u6bcf\u4e00\u4e2a\u6d88\u8d39\u8005\u7d22\u53d6\u4ed6\u613f\u610f\u652f\u4ed8\u7684\u6700\u9ad8\u4ef7\u683c\uff0c\u6216\u8005\u662f\u5784\u65ad\u5382\u5546\u5411\u5355\u4e2a\u6d88\u8d39\u8005\u8d2d\u4e70\u7684\u6bcf\u4e00\u5355\u4f4d\u5546\u54c1\u7d22\u53d6\u4ed6\u613f\u610f\u652f\u4ed8\u7684\u6700\u9ad8\u4ef7\u683c\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_11","title":"\u4e8c\u7ea7\u4ef7\u683c\u6b67\u89c6","text":"
- \u5382\u5546\u83b7\u53d6\u6240\u6709\u7684\u751f\u4ea7\u8005\u5269\u4f59
- \u5982\u679c\u5784\u65ad\u5382\u5546\u4e0d\u5b9e\u884c\u4ef7\u683c\u6b67\u89c6\uff0c\u4ee5\u4e0d\u53d8\u4ef7\u683cP0\u51fa\u552eQ0\u5355\u4f4d\u5546\u54c1\uff0c\u5219\u5784\u65ad\u5382\u5546\u7684\u603b\u6536\u76ca\u4e3aP0Q0 ;\u6b64\u65f6\u6d88\u8d39\u8005\u603b\u5269\u4f59\u4e3a\u4e09\u89d2\u5f62AP0B\u7684\u9762\u79ef
\u5784\u65ad\u5382\u5546\u5bf9\u540c\u4e00\u6d88\u8d39\u8005\u8d2d\u4e70\u4e0d\u540c\u6570\u91cf\u7684\u540c\u4e00\u5546\u54c1\u7d22\u53d6\u4e0d\u540c\u7684\u4ef7\u683c\uff0c\u4ece\u800c\u5360\u6709\u6bcf\u4e2a\u6d88\u8d39\u8005\u4ee5\u4e0d\u53d8\u7684\u5e02\u573a\u4ef7\u683c\u8d2d\u4e70\u5546\u54c1\u65f6\u5e94\u8be5\u5f97\u5230\u7684\u6d88\u8d39\u8005\u5269\u4f59\u3002
\u5982\u679c\u5784\u65ad\u5382\u5546\u5b9e\u884c\u4e8c\u7ea7\u4ef7\u683c\u6b67\u89c6\uff0c\u5728\u6d88\u8d39\u8005\u8d2d\u4e70\u91cfQ\u2264Q1\u65f6\uff0c\u5b9a\u4ef7\u4e3aP1\uff1b\u5728\u6d88\u8d39\u8005\u8d2d\u4e70\u91cfQ1\uff1cQ\u2264Q2\u65f6\uff0c\u5b9a\u4ef7\u4e3aP2\uff1b\u5728\u6d88\u8d39\u8005\u8d2d\u4e70\u91cfQ2\uff1cQ\u2264Q3\u65f6\uff0c\u5b9a\u4ef7\u4e3aP3\u3002
\u90a3\u4e48\uff0c\u5382\u5546\u5c06\u83b7\u53d6\u90e8\u5206\u7684\u751f\u4ea7\u8005\u5269\u4f59\uff0c\u5229\u6da6\u589e\u52a0
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_12","title":"\u4e09\u7ea7\u4ef7\u683c\u6b67\u89c6","text":"\u4ee5\u4e0d\u540c\u7684\u4ef7\u683c\u5411\u4e0d\u540c\u7c7b\u578b\u7684\u6d88\u8d39\u8005\u6216\u5728\u4e0d\u540c\u7684\u5e02\u573a\u4e0a\u51fa\u552e\u540c\u4e00\u5546\u54c1\u3002
OR
\u4e09\u7ea7\u4ef7\u683c\u6b67\u89c6\u9488\u5bf9\u7684\u662f\u5177\u6709\u4e0d\u540c\u7684\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u7684\u6d88\u8d39\u7fa4\u4f53\uff0c\u5e76\u6839\u636e\u8fd9\u4e9b\u4e0d\u540c\u7684\u9700\u6c42\u4ef7\u683c\u5f39\u6027\u5bf9\u8fd9\u4e9b\u6d88\u8d39\u7fa4\u4f53\u6536\u53d6\u4e0d\u540c\u7684\u4ef7\u683c\u3002
\u63a8\u65ad\uff1a
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_13","title":"\u5784\u65ad\u7ade\u4e89\u5e02\u573a","text":"
- \u9996\u5148\uff0c\u5728\u4e24\u4e2a\u4e0d\u540c\u7684\u5e02\u573a\uff0c\u5206\u522b\u5177\u6709\u9700\u6c42\u51fd\u6570\\(D_1 \\ \\ D_2\\)
- \u5229\u6da6\\(\\pi=TR(Q_1)+TR(Q_2)-TC(Q_0)=TR(Q_1)+TR(Q_2)-TC(Q_1+Q_2)\\)
- \u6839\u636e\u62c9\u683c\u6717\u65e5\u6761\u4ef6
- \\(MR(Q_1)-MC(Q)=0\\)
- \\(MR(Q_2)-MC(Q)=0\\)
- \u6545\u800c\uff0c\\(MR(Q_1)=MR(Q_2)=MC(Q)\\)
\u5784\u65ad\u7ade\u4e89\uff08Monopolistic Competition\uff09\u5e02\u573a\u662f\u4e00\u79cd\u65e2\u6709\u5784\u65ad\u53c8\u6709\u7ade\u4e89\u7684\u5e02\u573a\u3002\u5728\u8fd9\u4e2a\u5e02\u573a\u4e0a\u5b58\u5728\u7740\u8bb8\u591a\u751f\u4ea7\u548c\u9500\u552e\u6709\u5dee\u522b\u7684\u540c\u79cd\u4ea7\u54c1\u7684\u5382\u5546.
\u901a\u5e38\uff0c\u5728\u77ed\u671f\u4e2d\uff0c\u5382\u5546\u80fd\u591f\u51ed\u501f\u4ea7\u54c1\u7684\u5dee\u522b\u83b7\u5f97\u76f8\u5bf9\u5784\u65ad\u5730\u4f4d\uff1b\u800c\u5728\u957f\u671f\u4e2d\uff0c\u7531\u4e8e\u4fe1\u606f\u57fa\u672c\u5b8c\u5907\uff0c\u8fdb\u51fa\u884c\u4e1a\u8f83\u81ea\u7531\uff0c\u5176\u4ed6\u5382\u5546\u80fd\u591f\u901a\u8fc7\u521b\u65b0\u3001\u6a21\u4eff\u7b49\u624b\u6bb5\u751f\u4ea7\u6709\u5dee\u522b\u7684\u4ea7\u54c1\uff0c\u4e0e\u539f\u6709\u7684\u5382\u5546\u8fdb\u884c\u7ade\u4e89\u3002
\u7279\u5f81
- \u5e02\u573a\u4e0a\u6709\u8bb8\u591a\u7684\u5382\u5546\u548c\u6d88\u8d39\u8005\u3002\u7531\u4e8e\u5382\u5546\u7684\u6570\u76ee\u5f88\u591a\uff0c\u6bcf\u4e00\u5bb6\u5382\u5546\u5bf9\u4ea7\u54c1\u7684\u4ef7\u683c\u867d\u7136\u6709\u5f71\u54cd\uff0c\u4f46\u53ea\u662f\u5f88\u5c0f\u7684\u5f71\u54cd\u3002
- **\u5e02\u573a\u4e0a\u7684\u8bb8\u591a\u5382\u5546\u751f\u4ea7\u7684\u662f\u6709\u5dee\u522b\u7684\u540c\u79cd\u4ea7\u54c1\uff0c\u56e0\u800c\uff0c\u4e00\u65b9\u9762\u8fd9\u4e9b\u4ea7\u54c1\u80fd\u591f\u6ee1\u8db3\u6d88\u8d39\u8005\u7684\u5404\u79cd\u4e0d\u540c \u504f\u597d\uff0c\u53e6\u4e00\u65b9\u9762\u8fd9\u4e9b\u4ea7\u54c1\u4e4b\u95f4\u53c8\u5177\u6709\u5f88\u5f3a\u7684\u66ff\u4ee3\u6027\u3002
\u8fd9\u79cd\u5dee\u522b\u6709\u5b9e\u8d28\u4e0a\u7684\uff0c\u6bd4\u5982\u8d28\u91cf\uff1b\u53c8\u6709\u975e\u5b9e\u8d28\u7684\uff0c\u6bd4\u5982\u5ba3\u4f20\u3001\u5e7f\u544a \u8fd9\u4e00\u70b9\u6b63\u662f\u5bfc\u81f4\u8fd9\u79cd\u5e02\u573a\u5f62\u6210\u7684\u4e3b\u8981\u539f\u56e0
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_14","title":"\u9700\u6c42\u66f2\u7ebf","text":"
\u4ece\u957f\u671f\u6765\u770b\uff0c\u5382\u5546\u53ef\u4ee5\u6bd4\u8f83\u81ea\u7531\u5730\u8fdb\u5165\u6216\u9000\u51fa\u4e00\u4e2a\u884c\u4e1a\u3002\u7531\u4e8e\u5382\u5546\u6570\u76ee\u5f88\u591a\uff0c\u6bcf\u4e2a\u5382\u5546\u7684\u89c4\u6a21\u4e5f\u4e0d\u662f\u592a\u5927\uff0c\u6240\u9700\u8981\u7684\u8d44\u672c\u4e0d\u662f\u5f88\u591a\uff0c\u56e0\u800c\u8981\u8fdb\u51fa\u884c\u4e1a\u6ca1\u6709\u591a\u5927\u7684\u969c\u788d\u3002
\u5e02\u573a\u4fe1\u606f\u57fa\u672c\u5b8c\u5907\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_15","title":"\u77ed\u671f\u5747\u8861","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_16","title":"\u5be1\u5934\u5784\u65ad\u5e02\u573a","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_17","title":"\u7279\u5f81\u4e0e\u6210\u56e0","text":"
- \u5784\u65ad\u7ade\u4e89\u5382\u5546\u6240\u9762\u4e34\u7684\u9700\u6c42\u66f2\u7ebf\u6709\u4e24\u6761\uff1a\u4e00\u6761\u79f0\u4e3a\u4e3b\u89c2\u9700\u6c42\u66f2\u7ebfd0\uff0c\u8868\u793a\u5784\u65ad\u7ade\u4e89\u884c\u4e1a\u4e2d\u7684\u5355\u4e2a\u5382\u5546\u6539\u53d8\u4ea7\u54c1\u4ef7\u683c\uff0c\u800c\u5176\u4ed6\u5382\u5546\u7684\u4ea7\u54c1\u4ef7\u683c\u90fd\u4fdd\u6301\u4e0d\u53d8\u65f6\uff0c\u8be5\u5382\u5546\u7684\u4ea7\u54c1\u4ef7\u683c\u4e0e\u4ea7\u9500\u91cf\u4e4b\u95f4\u7684\u5173\u7cfb\uff1b\u53e6\u4e00\u6761\u79f0\u4e3a\u5b9e\u9645\u9700\u6c42\u66f2\u7ebfD\uff0c\u8868\u793a\u5784\u65ad\u7ade\u4e89\u884c\u4e1a\u4e2d\u7684\u5355\u4e2a\u5382\u5546\u6539\u53d8\u4ea7\u54c1\u4ef7\u683c\uff0c\u5176\u4ed6\u5382\u5546\u7684\u4ea7\u54c1\u4ef7\u683c\u540c\u65f6\u53d8\u5316\u65f6
\u5be1\u5934\u662f\u5bf9\u5be1\u5934\u5784\u65ad\u5e02\u573a\u4e0a\u5382\u5546\u7684\u522b\u79f0\uff0c\u5be1\u5934\u5784\u65ad\uff08Oligopoly\uff09\u5e02\u573a\u662f\u6307\u5c11\u6570\u5382\u5546\u63a7\u5236\u67d0\u4e00\u4ea7\u54c1\u6781\u5927\u90e8\u5206\u751f\u4ea7\u548c\u9500\u552e\u7684\u5e02\u573a\u7ed3\u6784\u3002
\u7279\u5f81
\u7b2c\u4e00\uff0c\u6709\u8bb8\u591a\u4e70\u8005\uff0c\u4f46\u53ea\u6709\u5c11\u6570\u5356\u8005\u3002\u5356\u8005\u7684\u6570\u76ee\u81f3\u5c11\u7b49\u4e8e2\uff0c\u5426\u5219\u5c31\u53d8\u6210\u4e86\u5b8c\u5168\u5784\u65ad\u3002\u5f53\u4e00\u4e2a\u884c\u4e1a\u4e2d\u4ec5\u6709\u4e24\u5bb6\u5382\u5546\u65f6\uff0c\u79f0\u4e4b\u4e3a\u53cc\u5be1\u5934\u3002\u4e00\u822c\u5356\u8005\u7684\u6570\u76ee\u53ef\u4ee5\u591a\u81f3\u51e0\u5bb6\u3001\u5341\u51e0\u5bb6\u4e43\u81f3\u51e0\u5341\u5bb6\u3002\u6bcf\u4e00\u5bb6\u5382\u5546\u5728\u5e02\u573a\u4e0a\u90fd\u6709\u4e3e\u8db3\u8f7b\u91cd\u7684\u5730\u4f4d\uff0c\u5bf9\u5176\u4ea7\u54c1\u7684\u4ef7\u683c\u90fd\u6709\u76f8\u5f53\u7684\u5f71\u54cd\u529b\uff0c\u56e0\u6b64\uff0c\u4ed6\u4eec\u5728\u5e02\u573a\u4e0a\u76f8\u4e92\u4f9d\u5b58\uff0c\u5176\u51b3\u7b56\u8981\u6bd4\u5176\u4ed6\u5e02\u573a\u5382\u5546\u7684\u51b3\u7b56\u590d\u6742\u5f97\u591a\u3002\u4e00\u822c\u53ef\u4ee5\u6839\u636e\u4ed6\u4eec\u4e4b\u95f4\u7684\u4f9d\u5b58\u5173\u7cfb\uff0c\u5c06\u4ed6\u4eec\u7684\u884c\u52a8\u65b9\u5f0f\u5206\u4e3a\u72ec\u7acb\u884c\u52a8\u548c\u76f8\u4e92\u52fe\u7ed3\u4e24\u79cd\u7c7b\u578b\u3002
\u7b2c\u4e8c\uff0c\u5404\u5bb6\u5382\u5546\u6240\u751f\u4ea7\u6216\u9500\u552e\u7684\u4ea7\u54c1\u53ef\u4ee5\u662f\u540c\u8d28\u7684\uff0c\u4e5f\u53ef\u4ee5\u662f\u5f02\u8d28\u7684\u3002\u5bf9\u4e8e\u751f\u4ea7\u6216\u9500\u552e\u540c\u8d28\u4ea7\u54c1\u7684\u5382\u5546\uff0c\u79f0\u5176\u4e3a\u7eaf\u7cb9\u5be1\u5934\uff0c\u800c\u5bf9\u4e8e\u751f\u4ea7\u6216\u9500\u552e\u5f02\u8d28\u4ea7\u54c1\u5382\u5546\uff0c\u5219\u79f0\u5176\u4e3a\u5dee\u522b\u5be1\u5934\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u94a2\u94c1\u3001\u70bc\u94dd\u3001\u77f3\u6cb9\u3001\u6c34\u6ce5\u7b49\u884c\u4e1a\u5c5e\u4e8e\u7eaf\u7cb9\u5be1\u5934\uff0c\u5404\u5382\u5546\u7684\u4ea7\u54c1\u51e0\u4e4e\u6ca1\u6709\u5dee\u522b\uff0c\u5f7c\u6b64\u95f4\u7684\u66ff\u4ee3\u7a0b\u5ea6\u5f88\u9ad8\uff1b\u800c\u673a\u68b0\u3001\u77f3\u6cb9\u4ea7\u54c1\u3001\u6c7d\u8f66\u3001\u5bb6\u7535\u7b49\u884c\u4e1a\u5c5e\u4e8e\u5dee\u522b\u5be1\u5934\uff0c\u5404\u5382\u5546\u7684\u4ea7\u54c1\u6709\u5dee\u522b\uff0c\u5f7c\u6b64\u95f4\u7684\u66ff\u4ee3\u7a0b\u5ea6\u76f8\u5bf9\u8f83\u4f4e\u3002
\u7b2c\u4e09\uff0c\u5382\u5546\u8fdb\u51fa\u884c\u4e1a\u53d7\u5230\u9650\u5236\u3002\u5bf9\u4e8e\u5728\u4f4d\u5382\u5546\u6765\u8bf4\uff0c\u7531\u4e8e\u89c4\u6a21\u8f83\u5927\uff0c\u5e76\u4e14\u62e5\u6709\u65e2\u5f97\u5229\u76ca\uff0c\u4e00\u822c\u4e0d\u4f1a\u8f7b\u6613\u9000\u51fa\u6240\u5728\u884c\u4e1a\uff1b\u800c\u5bf9\u4e8e\u65b0\u5382\u5546\u6765\u8bf4\uff0c\u7531\u4e8e\u89c4\u6a21\u7ecf\u6d4e\u7b49\u81ea\u7136\u969c\u788d\u548c\u5728\u4f4d\u5382\u5546\u7684\u4eba\u4e3a\u8bbe\u969c\uff0c\u901a\u5e38\u5f88\u96be\u8fdb\u5165\u5be1\u5934\u5784\u65ad\u884c\u4e1a\u3002
\u7b2c\u56db\uff0c\u4fe1\u606f\u4e0d\u5b8c\u5168\u3002\u5be1\u5934\u5784\u65ad\u5e02\u573a\u4e0a\uff0c\u7531\u4e8e\u5be1\u5934\u4e4b\u95f4\u7684\u4f9d\u5b58\u5173\u7cfb\uff0c\u4ea4\u6613\u7684\u4fe1\u606f\u662f\u4e0d\u5b8c\u5168\u7684\uff0c\u800c\u4e14\u60c5\u51b5\u975e\u5e38\u590d\u6742\u3002
\u6210\u56e0
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_18","title":"\u7ade\u4e89\u6a21\u578b","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_19","title":"\u53e4\u800c\u8bfa\u6a21\u578b","text":"
- \u89c4\u6a21\u7ecf\u6d4e\u3002
- \u5bf9\u6295\u5165\u7684\u63a7\u5236\u3002\u5982\u679c\u884c\u4e1a\u4e2d\u7684\u8001\u5382\u5546\u80fd\u5bf9\u4ea7\u54c1\u7684\u5173\u952e\u6295\u5165\u8fdb\u884c\u63a7\u5236\uff0c\u90a3\u4e48\u5c31\u80fd\u6709\u6548\u5730\u9650\u5236\u65b0\u5382\u5546\u7684\u8fdb\u5165
- \u5927\u91cf\u7684\u8d44\u672c\u3002\u5728\u8bb8\u591a\u884c\u4e1a\u4e2d\uff0c\u5382\u5546\u9700\u8981\u5927\u91cf\u7684\u8d44\u672c\u624d\u80fd\u4f7f\u5176\u7ecf\u8425\u5904\u5728\u6709\u6548\u7387\u7684\u6c34\u5e73\u4e0a\u3002
- \u6280\u672f\u9886\u5148
- \u6c89\u6ca1\u6210\u672c
- \u653f\u5e9c\u4fdd\u62a4
\u5047\u8bbe\u5982\u4e0b\uff1a
\uff081\uff09\u53ea\u6709\u4e24\u4e2a\u5382\u5546(\u5be1\u5934\u7532\u548c\u5be1\u5934\u4e59)\uff1b \uff082\uff09\u751f\u4ea7\u540c\u8d28\u4ea7\u54c1\uff08\u77ff\u6cc9\u6c34\uff09\uff1b \uff083\uff09\u751f\u4ea7\u6210\u672c\u4e3a\u96f6\uff1b \uff084\uff09\u5382\u5546\u90fd\u51c6\u786e\u4e86\u89e3\u5e02\u573a\u9700\u6c42\u66f2\u7ebf\uff1b \uff085\uff09\u5382\u5546\u65e0\u5408\u8c0b\uff1b \uff086\uff09\u5382\u5546\u901a\u8fc7\u8c03\u6574\u4ea7\u91cf\u5b9e\u73b0\u5229\u6da6\u6700\u5927\u5316
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_20","title":"\u63a8\u5bfc","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_21","title":"\u4e00 \uff1a\u56fe\u63a8\u5bfc\uff08\u9012\u5f52\uff09","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_22","title":"\u4e8c \uff1a\u516c\u5f0f\u63a8\u5bfc","text":"\u53cd\u9700\u6c42\u51fd\u6570\\(P=H-aQ\\) \\(Q=Q_A+Q_B\\) \\(CQ_A=CQ_B=0\\) \\(\\pi _A=P_AQ_A-TC_A=HQ_A-aQ_A^2-aQ_AQ_B\\) \\(\\pi _B=P_BQ_B-TC_B=HQ_B-aQ_B^2-aQ_AQ_B\\) \\(\\frac{d\\pi}{dQ_A}=H-2aQ_A-aQ_B=0\\)
\\(\\frac{d\\pi}{dQ_B}=H-2aQ_B+aQ_A=0\\)
==>\\(Q_A=\\frac{H}{2a}-\\frac{Q_B}{2}\\) \\(Q_B=\\frac{H}{2a}-\\frac{Q_A}{2}\\) \\(Q_A=Q_B=\\frac{H}{3a}\\) ==> \\(P=\\frac{H}{3}\\)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_23","title":"\u7f3a\u9677","text":"\u8be5\u6a21\u578b\u5047\u5b9a\u5382\u5546\u7684\u6700\u4f18\u884c\u4e3a\u662f\u4ee5\u5176\u7ade\u4e89\u5bf9\u624b\u7684\u4ea7\u91cf\u4e0d\u53d8\u4e3a\u6761\u4ef6\u7684\uff0c\u8fd9\u663e\u7136\u4e0d\u7b26\u5408\u73b0\u5b9e\u4e2d\u5be1\u5934\u7684\u884c\u4e3a\u3002\u6b63\u56e0\u4e3a\u5982\u6b64\uff0c\u53e4\u5c14\u8bfa\u6a21\u578b\u4e0d\u662f\u5be1\u5934\u884c\u4e3a\u7684\u4e00\u822c\u5206\u6790\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_24","title":"\u65af\u5a01\u9f50\u6a21\u578b","text":"\u5f53\u5382\u5546A\u964d\u4ef7\u65f6\uff0c\u5176\u4ed6\u5382\u5546\u4e3a\u9632\u6b62\u5931\u53bb\u987e\u5ba2\u4e5f\u76f8\u5e94\u5730\u964d\u4ef7\uff1b\u800c\u5f53\u5382\u5546A\u63d0\u4ef7\u65f6\uff0c\u5176\u4ed6\u5382\u5546\u4e3a\u5438\u5f15\u987e\u5ba2\u5374\u4e0d\u63d0\u4ef7\u3002\u8fd9\u6837\u5382\u5546A\u7684\u9700\u6c42\u66f2\u7ebf\u5c31\u6210\u4e3adED\u90a3\u6837\u7684\u5f2f\u6298\u66f2\u7ebf\uff0c\u5373\u5f53\u4ef7\u683c\u9ad8\u4e8eP0\u65f6\uff0c\u5382\u5546A\u7684\u9700\u6c42\u66f2\u7ebf\u7531\u7ebf\u6bb5dE\u6784\u6210\uff0c\u800c\u5f53\u4ef7\u683c\u4f4e\u4e8eP0\u65f6\uff0c\u5382\u5546A\u7684\u9700\u6c42\u66f2\u7ebf\u7531\u7ebf\u6bb5ED\u6784\u6210
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/#_25","title":"\u4f8b\u9898","text":"\u4f8b\u98986.1\u3000\u5047\u5b9a\u5784\u65ad\u8005\u9762\u4e34\u7684\u9700\u6c42\u66f2\u7ebf\u4e3aP\uff1d100\uff0d4Q\uff0c\u603b\u6210\u672c\u51fd\u6570\u4e3aTC\uff1d50\uff0b20Q\uff0c\u6c42\uff1a\uff081\uff09\u5784\u65ad\u8005\u5229\u6da6\u6781\u5927\u5316\u65f6\u7684\u4ea7\u91cf\u3001\u4ef7\u683c\u53ca\u5229\u6da6\uff1b\uff082\uff09\u5047\u8bbe\u5784\u65ad\u8005\u9075\u4ece\u5b8c\u5168\u7ade\u4e89\u6cd5\u5219\uff0c\u90a3\u4e48\u5382\u5546\u7684\u4ea7\u91cf\u3001\u4ef7\u683c\u53ca\u5229\u6da6\u5982\u4f55\uff1f\u5e76\u4e0e\uff081\uff09\u8fdb\u884c\u6bd4\u8f83\u3002
(1) \u5229\u7528\u5784\u65ad\u7684\u5747\u8861\u6761\u4ef6\uff1aMC = MR
(2) \u5229\u7528\u5b8c\u5168\u7ade\u4e89\u7684\u5747\u8861\u6761\u4ef6\uff1aMC \uff08= MR\uff09 = P
\u4f8b\u98986.2\u3000\u5047\u5982\u67d0\u5784\u65ad\u5382\u5546\u751f\u4ea7\u7684\u4ea7\u54c1\u80fd\u591f\u5728\u4e24\u4e2a\u4e0d\u540c\u7684\u5e02\u573a\u4e0a\u5b9e\u884c\u5dee\u522b\u5b9a\u4ef7\uff0c\u5176\u751f\u4ea7\u7684\u603b\u6210\u672c\u51fd\u6570\u4e3aTC\uff1dQ2\uff0b10Q\uff0c\u4e24\u4e2a\u5e02\u573a\u7684\u9700\u6c42\u51fd\u6570\u5206\u522b\u4e3aQ1\uff1d32\uff0d0.4P1\uff0cQ2\uff1d18\uff0d0.1P2\uff0c\u6c42\uff1a\uff081\uff09\u5784\u65ad\u5382\u5546\u5229\u6da6\u6781\u5927\u65f6\u4e24\u4e2a\u5e02\u573a\u7684\u9500\u552e\u91cf\u3001\u9500\u552e\u4ef7\u683c\u53ca\u5382\u5546\u7684\u603b\u5229\u6da6\uff1b\uff082\uff09\u5047\u5982\u4e24\u4e2a\u5e02\u573a\u53ea\u80fd\u7d22\u53d6\u76f8\u540c\u7684\u4ef7\u683c\uff0c\u6c42\u89e3\u5229\u6da6\u6781\u5927\u65f6\u7684\u9500\u552e\u91cf\u3001\u9500\u552e\u4ef7\u683c\u548c\u5229\u6da6\u3002
\u4f8b\u9898 6.3
\uff081\uff09\u6839\u636e\u516c\u5f0f\uff0c\u6216\u8005\u91cd\u65b0\u63a8\u5bfc\u62c9\u683c\u6717\u65e5\u6761\u4ef6\u6c42R\u6700\u5927\u503c\uff1b\u6ce8\u610f\u4ed6\u7ed9\u7684\u5f62\u5f0f\u4e3a\u9700\u6c42\u51fd\u6570\uff0c\u8981\u6362\u4e3a\u53cd\u9700\u6c42\u51fd\u6570 \uff082\uff09\\(p_1=p_2\\)\u5c06\u51fd\u6570\u53e0\u52a0\u4e3a\u603b\u53cd\u9700\u6c42\u51fd\u6570\u5373\u53ef\uff0c\u4e4b\u540e\u6839\u636eMR=MC\u8ba1\u7b97
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%207%20%E5%8D%9A%E5%BC%88%E8%AE%BA/","title":"Chapter 7 \u535a\u5f08\u8bba","text":"\u7ea6 0 \u4e2a\u5b57
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/","title":"Chapter 8 \u8981\u7d20\u5e02\u573a","text":"\u7ea6 482 \u4e2a\u5b57 \u9884\u8ba1\u9605\u8bfb\u65f6\u95f4 2 \u5206\u949f
\u672c\u7ae0\u4ece\u4ea7\u54c1\u5e02\u573a\u8f6c\u5411\u2f63\u4ea7\u8981\u7d20\u5e02\u573a\uff0c\u7740\u91cd\u5206\u6790\u8981\u7d20\u4ef7\u683c\u7684\u51b3\u5b9a\u95ee\u9898\u3002 \u2fb8\u5148\uff0c\u8003\u5bdf\u2f63\u4ea7\u8981\u7d20\u7684\u9700\u6c42\u3001\u4f9b\u7ed9\u53ca\u5176\u4ef7\u683c\u7684\u51b3\u5b9a\uff1b \u5176\u6b21\u5206\u6790\u52b3\u52a8\u3001\u8d44\u672c\u3001\u2f1f\u5730\u3001\u4f01\u4e1a\u5bb6\u624d\u80fd\u7b49\u5404\u79cd\u2f63\u4ea7\u8981\u7d20\u5e02\u573a\u4e0a\u7684\u4f9b\u6c42\u53ca\u5176\u4ef7\u683c\u7684\u51b3\u5b9a\u3002 \u7531\u4e8e\u8981\u7d20\u4ef7\u683c\u548c\u6570\u91cf\u662f\u51b3\u5b9a\u6d88\u8d39\u8005\u6536\u2f0a\u2f54\u5e73\u7684\u91cd\u8981\u56e0\u7d20\uff0c\u51b3\u5b9a\u4e86\u8981\u7d20\u4ef7\u683c\u548c\u6570\u91cf\uff0c\u5728\u5f88\u2f24\u7a0b\u5ea6\u4e0a\u51b3\u5b9a\u4e86\u8981\u7d20\u6240\u6709\u8005\u7684\u6536\u2f0a\u5206\u914d\uff0c\u6240\u4ee5\u8981\u7d20\u5e02\u573a\u7406\u8bba\u5728\u7ecf\u6d4e\u5b66\u4e2d\u4e5f\u88ab\u79f0\u4f5c\u201c\u5206\u914d\u7406\u8bba\u201d\u3002
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_1","title":"\u8981\u7d20\u7684\u9700\u6c42","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_2","title":"\u8fb9\u9645\u6536\u76ca","text":"\\(MR_F\\)\u8981\u7d20\u7684\u8fb9\u9645\u6536\u76ca \\(MC_F\\)\u8981\u7d20\u7684\u8fb9\u9645\u6210\u672c
\u8fb9\u9645\u4ea7\u54c1\u4ef7\u503c\uff08Value of Marginal Product, VMP\uff09 \u8fb9\u9645\u4ea7\u91cf\uff08MP\uff09 \\(VMP=MP*P\\)
\u8fb9\u9645\u4ea7\u54c1\u6536\u76ca\uff08Revenue of Marginal Product,MRP\uff09 \\(MRP=MP*MR\\)
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_3","title":"\u8fb9\u9645\u6210\u672c","text":"\u603b\u6210\u672c\\(TC=wL+rK,L\u52b3\u52a8\uff0cK\u8d44\u672c\\) \u5b8c\u5168\u7ade\u4e89 P=MR
\u200b \u5bf9\u4e8e\u5e02\u573a\u800c\u8a00\uff0c\u5e02\u573a\u5bf9\u8981\u7d20\u7684\u9700\u6c42\u66f2\u7ebf != \u8fb9\u9645\u4ea7\u54c1\u4ef7\u503c\u66f2\u7ebf\uff08VMP\uff09 \u200b \u5de5\u8d44w\u4e0b\u964d\uff0c\u6240\u6709\u5382\u5546\u5bf9\u52b3\u52a8\u529b\u7684\u9700\u6c42\u589e\u52a0\uff0c\u66f2\u7ebf\u6574\u4f53\u53f3\u79fb \u200b \u5f53\u2f2f\u8d44\uff08w\uff09\u4e0b\u964d\u65f6\uff0c\u7531\u4e8e\u6240\u6709\u2f1a\u5546\u90fd\u4f1a\u589e\u52a0\u5bf9\u52b3\u52a8\u7684\u9700\u6c42\u91cf\uff0c\u2f63\u4ea7\u51fa\u66f4\u591a\u7684\u4ea7\u54c1\u3002\u8fd9\u6837\uff0c\u5728\u4ea7\u54c1\u7684\u5e02\u573a\u9700\u6c42\u4e0d\u53d8\u65f6\uff0c\u4ea7\u54c1\u5e02\u573a\u4f9b\u7ed9\u7684\u589e\u52a0\u4f1a\u5f15\u8d77\u4ea7\u54c1\u5e02\u573a\u4ef7\u683c\u7684\u4e0b\u964d\uff0c\u2f7d\u4ea7\u54c1\u7684\u5e02\u573a\u4ef7\u683c\u7684\u4e0b\u964d\u4f7f\u5f97\u5404\u4e2a\u2f1a\u5546\u7684\u52b3\u52a8\u7684\u9700\u6c42\u66f2\u7ebf\u90fd\u4ecedL\u5411\u5de6\u79fb\u2f84dL \u2032\u3002
\u975e\u5b8c\u5168\u7ade\u4e89 \u6c42\u504f\u5bfc\uff0c\u5f97\u5230L\u6216\u8005K\u7684\u8fb9\u9645\u6210\u672c
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_4","title":"\u5382\u5546\u4f7f\u7528\u8981\u7d20\u7684\u539f\u5219","text":""},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_5","title":"\u8981\u7d20\u7684\u4f9b\u7ed9","text":"\u6d88\u8d39\u8005\uff1a
\u4ece\u8981\u7d20\u7684\u4f9b\u7ed9\u6765\u8bb2\uff0c\u7531\u4e8e\u8981\u7d20\u4f9b\u7ed9\u672c\u2f9d\u5bf9\u6d88\u8d39\u8005\u5e76\u4e0d\u76f4\u63a5\u4ea7\u2f63\u6548\u2f64\uff0c\u53ea\u6709\u5f53\u6d88\u8d39\u8005\u4f9b\u7ed9\u8981\u7d20\u5f97\u5230\u6536\u2f0a\u5e76\u2f64\u4e8e\u6d88\u8d39\u65f6\u624d\u4ea7\u2f63\u6548\u2f64.
\u200b \u8981\u7d20\u4f9b\u7ed9 \u4e00\u822c\u4ea7\u751f\u95f4\u63a5\u6548\u7528
\u200b \u4fdd\u7559\u81ea\u7528 \u4e00\u822c\u4ea7\u751f\u76f4\u63a5\u6548\u7528
"},{"location":"others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/#_6","title":"\u52b3\u52a8\u4e0e\u5de5\u8d44","text":""},{"location":"%E6%9D%82%E8%B0%88/","title":"Index","text":"\u7ea6 15 \u4e2a\u5b57
Abstrct
\u5728\u8fd9\u91cc\u653e\u4e00\u70b9\u4e0d\u592a\u597d\u5206\u7c7b\u7684\u4e1c\u897f
"},{"location":"%E6%9D%82%E8%B0%88/Compile/","title":"What happened when Compiling?","text":"\u7ea6 4 \u4e2a\u5b57
"}]} \ No newline at end of file diff --git a/sitemap.xml b/sitemap.xml index de87052..037745d 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -2,462 +2,452 @@\ No newline at end of file diff --git a/sitemap.xml.gz b/sitemap.xml.gz index 93115fd..9bf9c34 100644 Binary files a/sitemap.xml.gz and b/sitemap.xml.gz differ https://zzicarus.github.io/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/OOP/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/%E5%A4%A7%E6%95%B0%E6%8D%AE%E5%8F%AF%E8%A7%86%E5%8C%96/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/AI/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/AI/Review/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/CO/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/CO/1_Interface/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/CO/2_Instruction/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/CO/3_Arithmetic/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/CO/4_Processor/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/CO/5_/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/CO/6/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_1/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_12/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_13/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_14/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_15/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_16/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_17/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_18/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_19/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_2/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_3_4_5/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_6/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DB/Chapter_7/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DIP/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/DIP/DIP_Review/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/Labs/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P1/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P2/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P3/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P4/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P5/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P6/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CS/%E6%95%B0%E5%AD%97%E9%80%BB%E8%BE%91%E5%9F%BA%E7%A1%80/P7/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/C/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/C/%E5%AD%98%E5%82%A8%E7%B1%BB%E5%88%AB%E3%80%81%E9%93%BE%E6%8E%A5%E5%92%8C%E5%86%85%E5%AD%98%E7%AE%A1%E7%90%86/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/C/%E6%8C%87%E9%92%88/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/Static%26Extern/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/TypeCast/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/argv/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/const/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/memory/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/%E5%9F%BA%E7%A1%80/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/Stadard_Library/Algorithm/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/Stadard_Library/IO/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/Stadard_Library/string/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/Stadard_Library/%E5%8A%A8%E6%80%81%E5%86%85%E5%AD%98/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/Stadard_Library/%E5%AE%B9%E5%99%A8/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/cake/assert/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/classes/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/classes/Copy/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/classes/Inherit/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/classes/OverloadOperator/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/classes/class/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/CPP/classes/template/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/Python/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/Python/CS61A/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/Python/basic/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/Python/%E7%88%AC%E8%99%AB/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/CodingLanguage/Python/library/numpy/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/Tools/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/Tools/CMake/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/Tools/Collection/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/Tools/Conda/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/Tools/GNUMake/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/Tools/Git/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/Tools/Shell/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/Tools/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/Tools/%E7%AB%99%E7%82%B9/mkdocs/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/_templates/_README/ -2024-07-30 +2024-08-02 daily - -https://zzicarus.github.io/_templates/_changelog/ -2024-07-30 -daily -- -https://zzicarus.github.io/_templates/_page/ -2024-07-30 -daily -- https://zzicarus.github.io/_templates/_post/ -2024-07-30 +https://zzicarus.github.io/_templates/_note/ +2024-08-02 daily https://zzicarus.github.io/others/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/others/%E5%A4%A7%E7%89%A9%E5%AE%9E%E9%AA%8C/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%201%20%20%E4%BB%B7%E6%A0%BC%E6%9C%BA%E5%88%B6/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%202%20%E6%B6%88%E8%B4%B9%E8%80%85%E7%90%86%E8%AE%BA/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%203%20%E7%94%9F%E4%BA%A7%E8%80%85%E7%90%86%E8%AE%BA/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%204%20%E5%BC%B9%E6%80%A7%E7%90%86%E8%AE%BA/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%205%20%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%206%20%E4%B8%8D%E5%AE%8C%E5%85%A8%E7%AB%9E%E4%BA%89%E5%B8%82%E5%9C%BA/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%207%20%E5%8D%9A%E5%BC%88%E8%AE%BA/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/others/%E5%BE%AE%E8%A7%82%E7%BB%8F%E6%B5%8E%E5%AD%A6/Chapter%208%20%E8%A6%81%E7%B4%A0%E5%B8%82%E5%9C%BA/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/%E6%9D%82%E8%B0%88/ -2024-07-30 +2024-08-02 daily https://zzicarus.github.io/%E6%9D%82%E8%B0%88/Compile/ -2024-07-30 +2024-08-02 daily