0%
Pde数值解第六章连续内罚有限元
发表于:
分类于:
PDE数值解
/
[pdf]
Mathematica第一讲
发表于:
分类于:
符号计算
Mathematica及其应用
Lec1-1
其他数学软件
Matlab
矩阵实验室, 关注矩阵运算 数值计算
Mathematica
符号计算 语言适合数学研究 贴近数学
Maple
符号计算 版本之间可能缺少兼容性 语言设计存在问题 贴近C语言 不具有友好性
优点工具包比较多
其他数学 略
欧拉计划

参考书
- Mathematica 文档
- Essentials Of Programming In Mathematica
- Mathematica programming: an advanced introduction
- Mathematica Cookbook 例子
Mathematica帮助系统

- 主讲第一部分核心语言与结构(到字符串处理)
Lec1-2
- 只介绍Mathematica的核心语言
- 从 2+2=4 开始,讲到如何定义 Mathematica 中没有的运算
- 不关注数据结构、算法和计算复杂度等内容
106Blec5Stacks and Queues
发表于:
分类于:
106B
栈和队列
Stack Overview 堆栈概述
- The first ADT we saw today was the stack. A stack is a LIFO (last-in, first-out) data structure. It generally supports a limited set of operations: 我们今天看到的第一个抽象数据类型是栈。栈是一种后进先出( LIFO )数据结构。它通常只支持有限的操作:
| Member Function 成员函数 | Description 描述 |
|---|---|
| clear() | removes all elements from the stack 从栈中移除所有元素 |
| equals(stack) | returns true if the two stacks contain the same elements in the same order, false otherwise 如果两个栈包含相同顺序的相同元素,则返回 true,否则返回 false |
| isEmpty() | returns true if the stack contains no elements, false otherwise 如果栈不包含任何元素,则返回 true,否则返回 false |
| peek() | returns the element on the top of the stack without removing it 返回栈顶元素但不移除它 |
| pop() | removes the element from the top of the stack and returns it 从栈顶移除元素并返回它 |
| push(value) | pushes value onto the stack 将值压入栈中 |
| size() | returns the number of values in the stack 返回栈中的元素数量 |
| . . . | For an exhaustive list, see: Stanford Stack class 如需完整列表,请参阅:斯坦福栈类 |
Queue Overview 队列概述
- We then discussed the queue ADT. A queue is a FIFO (first-in, first-out) data structure. Like the stack, it generally supports a limited set of operations: 我们接着讨论了队列抽象数据类型。队列是一种先进先出(FIFO)的数据结构。和栈一样,它通常支持一组有限的操作:
| Member Function 成员函数 | Description 描述 |
|---|---|
| clear() | removes all elements from the queue 从队列中移除所有元素 |
| dequeue() | removes and returns the frontmost element in the queue 移除并返回队列中最前面的元素 |
| enqueue(value) | adds value to the back of the queue 将 value 添加到队列的末尾 |
| equals() | returns true if the two queues contain the same elements in the same order, false otherwise 如果两个队列包含相同顺序的相同元素,则返回 true,否则返回 false |
| isEmpty() | returns true if the queue contains no elements, false otherwise 如果队列不包含任何元素,则返回 true,否则返回 false |
| peek() | returns the frontmost element in the queue without removing it 返回队列中最前面的元素,但不移除它 |
| size() | returns the number of values in the queue 返回队列中的值数量 |
| . . . | For an exhaustive list, see: Stanford Queue class 如需完整列表,请参阅:斯坦福队列类 |
106BLec4作业有感
发表于:
分类于:
106B
作业1
We wrote various tests for the extractAlpha() function in class today. Add to that code a separate STUDENT_TEST that contains a suite of test cases for the passwordChecksOut() function. What sorts of things would you test to ensure you have robust testing coverage for that function?
我们今天在课堂上为 extractAlpha() 函数编写了各种测试。在该代码中添加一个单独的 STUDENT_TEST,其中包含一套 passwordChecksOut() 函数的测试用例。您将测试哪些内容来确保该函数具有强大的测试覆盖率?
主要是为了给 passwordChecksOut() 函数编写测试用例没有难度
| |
作业2
简单情形
Write a function that takes a vector of integers as its only argument and prints it in the following format:
编写一个函数,该函数将整数向量作为其唯一参数,并按以下格式打印:
The function signature is: 函数签名为:
1printVector(Vector<int>& v)To simplify the problem, you may assume all the integers in the vector have exactly two digits. 为了简化问题,您可以假设向量中的所有整数恰好有两位数字。
这个问题也是简单的, 因为假设了二位整数所以没有任意整数的困难(包括负数, 位数不同等).
| |
改进
Additional challenge (this is fairly advanced; don’t worry too much about this one if you don’t have time): 额外的挑战(这是相当高级的,如果你没有时间,不要太担心这个):
- How could you ensure when printing the contents of a vector that the largest box has exactly enough space for the largest integer in the vector to be surrounded by one space on either side, and all other boxes have the same amount of space, with each integer being centered within its cell to the extend possible? For example: 在打印向量的内容时,如何确保最大的框有足够的空间让向量中最大的整数在两侧被一个空格包围,并且所有其他框具有相同的空间量,每个整数在其单元格内居中,尽可能地扩大? 例如:
这里位数不同的问题应该是普遍意识到的问题, 但是还有一个问题在于我们事实上是可以考虑负数的情形的但是这样需要考虑一些额外的情况.
如图所示存在问题: 计算整数位数时, 负数需要计算-号也会占用一个位置.
| |
可能的改进
- 可能可以使用一些更好的方法来拼接字符串或者是直接打印.
作业3
In the previous problem, why would we pass the vector by reference if we have no intention of modifying it in the printVector() function?
在上一个问题中,如果我们无意在 printVector() 函数中修改向量,为什么还要通过引用传递向量?
个人感觉还是直接传递变量副本太占据存储空间.
Tips: 需要注意所有程序中的 main() 函数都添加了 _filename 使得能够在同一个空白项目中编译成功, 需要用的时候去掉后缀同时保证项目中没有其他 main() 函数即可
Lecture 4. Testing, Vectors, and Grids
发表于:
分类于:
106B
设计原则:功能分解及其他
(Key Concept!) Breaking up a task into constituent functions that each fulfill a single purpose is called functional decomposition and improves the readability and maintainability of our code.
(核心概念!)将任务分解为各自实现单一功能的组成函数,称为功能分解,并提高代码的可读性和可维护性。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41#include <iostream> #include "console.h" #include "strlib.h" using namespace std; string extractAlpha(string s) { string result; for (int i = 0; i < s.length(); i++) { if (isalpha(s[i])) { result += s[i]; } } return result; } bool passwordChecksOut(string username, string password) { string alphaPortion = extractAlpha(password); return !stringContains(toLowerCase(alphaPortion), toLowerCase(username)); } int main() { string username = "Sean"; string password = "s1e1a1n1'1s1p1a1s1s1w1o1r1d"; if (passwordChecksOut(username, password)) { cout << "Hooray!" << endl; } else { cout << "Oh no! Bad password." << endl; } return 0; }
pde数值解第五章有限元多重网格法
发表于:
分类于:
PDE数值解
/
[pdf]
pde数值解第四章有限元方法的收敛性理论
发表于:
分类于:
PDE数值解
/
[pdf]
pde数值解第三章有限元方法
发表于:
分类于:
PDE数值解
/
[pdf]
pde数值解第二章椭圆问题变分原理
发表于:
分类于:
PDE数值解
/
[pdf]